/* ============================================================
   LLM RELAY —— 基础 + 组件(胶囊按钮/chips/卡片/表格/输入/弹窗/toast/侧边栏)
   ============================================================ */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--brand-tint-2); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
img { max-width: 100%; }
code, kbd, samp { font-family: var(--mono); }

/* 滚动条(浅) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--n-300); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--n-400); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 布局工具 ---------- */
.container { max-width: 1280px; margin: 0 auto; padding: 0 24px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--fg-2); }
.small { font-size: 13px; }
.caption { font-size: 12.5px; color: var(--fg-3); }
.mono { font-family: var(--mono); }
.hide { display: none !important; }
.nowrap { white-space: nowrap; }
.text-err { color: var(--err); }
.text-ok { color: var(--ok); }
.text-brand { color: var(--brand); }

/* ---------- 按钮(胶囊) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 18px;
  border: 1px solid transparent; border-radius: var(--r-pill);
  font-size: 14px; font-weight: 500; line-height: 1; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
  user-select: none; text-decoration: none !important;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 主 CTA: 近黑/近白胶囊 */
.btn-cta { background: var(--cta); color: var(--cta-fg); }
.btn-cta:hover:not(:disabled) { background: var(--cta-hover); }

/* 品牌蓝 */
.btn-brand { background: var(--brand); color: var(--on-brand); }
.btn-brand:hover:not(:disabled) { background: var(--brand-deep); }

/* 次: 玻璃 blur / 白底 */
.btn-sec {
  background: var(--bg-2); color: var(--fg);
  border-color: var(--card-border);
  backdrop-filter: blur(12px);
}
.btn-sec:hover:not(:disabled) { background: var(--bg-3); }

/* 幽灵: 透明 + 边框 */
.btn-ghost { background: transparent; color: var(--fg-2); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--hover); color: var(--fg); }
.btn-ghost.rec { background: var(--err); color: #fff; animation: rec-pulse 1.2s ease-in-out infinite; }
@keyframes rec-pulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }
.btn-outline { background: transparent; color: var(--fg); border-color: var(--n-300); }
.btn-outline:hover:not(:disabled) { background: var(--hover); }

/* 危险 */
.btn-danger { background: transparent; color: var(--err); border-color: var(--card-border); }
.btn-danger:hover:not(:disabled) { background: var(--err-tint); border-color: var(--err); }

/* 尺寸 */
.btn-lg { height: 44px; padding: 0 26px; font-size: 15px; }
.btn-sm { height: 30px; padding: 0 13px; font-size: 13px; }
.btn-xs { height: 26px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }

/* icon 按钮 */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: var(--r-s);
  border: none; background: transparent; color: var(--fg-2);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--hover); color: var(--fg); }

/* ---------- chip(开关/筛选) ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 14px;
  border: 1px solid var(--card-border); border-radius: var(--r-pill);
  background: var(--bg-2); color: var(--fg-2);
  font-size: 13.5px; font-weight: 500; cursor: pointer;
  transition: all .15s; user-select: none;
}
.chip:hover { border-color: var(--n-400); color: var(--fg); }
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.chip.on-alt { background: var(--fg); border-color: var(--fg); color: var(--bg); }
[data-theme="dark"] .chip.on-alt { background: var(--fg); color: var(--bg); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }
.card-hover { transition: border-color .15s, box-shadow .15s, transform .15s; }
.card-hover:hover { border-color: var(--n-400); box-shadow: var(--shadow-md); }
.card-title { font-size: 16px; font-weight: 600; margin: 0 0 4px; }

/* ---------- 输入 ---------- */
.input, .select, .textarea {
  width: 100%;
  border: 1px solid var(--card-border);
  border-radius: var(--r-m);
  background: var(--input-bg);
  color: var(--fg);
  padding: 9px 13px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint);
}
.input::placeholder, .textarea::placeholder { color: var(--fg-3); }
.textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
.select { appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a9099' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13.5px; font-weight: 500; color: var(--fg-2); }
.field .hint { font-size: 12px; color: var(--fg-3); }
.input-err { border-color: var(--err) !important; }

/* ---------- 表格 ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; font-weight: 500; color: var(--fg-2);
  padding: 10px 12px; border-bottom: 1px solid var(--card-border);
  white-space: nowrap; font-size: 12.5px; letter-spacing: .02em;
}
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--n-100); vertical-align: middle; }
[data-theme="dark"] .tbl td { border-bottom-color: var(--n-150); }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr:hover { background: var(--hover); }
.tbl tbody tr:last-child td { border-bottom: none; }

/* ---------- 状态 pill ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-ok   { background: var(--ok-tint);   color: var(--ok); }
.pill-warn { background: var(--warn-tint); color: var(--warn); }
.pill-err  { background: var(--err-tint);  color: var(--err); }
.pill-dim  { background: var(--n-100); color: var(--fg-2); }
.pill-brand{ background: var(--brand-tint); color: var(--brand); }

/* key 掩码 */
.mask { font-family: var(--mono); font-size: 12.5px; color: var(--fg-2);
  background: var(--bg-3); border-radius: 6px; padding: 3px 7px; }

/* ---------- 弹窗 ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(15, 17, 21, .45);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; transition: opacity .18s;
}
.modal-back.show { opacity: 1; }
.modal {
  background: var(--bg-2); color: var(--fg);
  border: 1px solid var(--card-border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 430px; max-height: 90vh;
  overflow-y: auto;
  transform: translateY(8px) scale(.98); transition: transform .18s;
}
.modal-back.show .modal { transform: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 0; }
.modal-title { font-size: 17px; font-weight: 600; margin: 0; }
.modal-body { padding: 14px 20px 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 0 20px 20px; }
.modal-close { border: none; background: none; color: var(--fg-3); font-size: 20px;
  width: 30px; height: 30px; border-radius: 8px; line-height: 1; }
.modal-close:hover { background: var(--hover); color: var(--fg); }
.modal-lg { max-width: 620px; }
.modal-xl { max-width: 860px; }

/* ---------- toast ---------- */
#toast-zone {
  position: fixed; right: 20px; bottom: 20px; z-index: 120;
  display: flex; flex-direction: column; gap: 8px; max-width: 380px;
}
.toast {
  background: var(--n-900); color: var(--n-50);
  border-radius: var(--r-m); padding: 11px 15px;
  font-size: 13.5px; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 9px;
  animation: toast-in .2s ease;
  border-left: 3px solid var(--brand);
}
[data-theme="dark"] .toast { background: var(--n-100); color: var(--fg); border-left-color: var(--brand); }
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.toast.warn { border-left-color: var(--warn); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.toast.out { opacity: 0; transform: translateY(6px); transition: all .25s; }

/* ---------- 侧边栏(控制台) ---------- */
.side {
  width: 232px; flex: none;
  background: var(--sidebar);
  border-right: 1px solid var(--card-border);
  display: flex; flex-direction: column;
  padding: 16px 12px; gap: 2px;
  overflow-y: auto;
}
.side a, .side button.side-item {
  display: flex; align-items: center; gap: 10px;
  height: 38px; padding: 0 12px;
  border-radius: var(--r-m); border: none; background: none;
  color: var(--fg-2); font-size: 14px; font-weight: 500;
  text-decoration: none !important; width: 100%; text-align: left;
  transition: background .12s, color .12s;
}
.side a:hover, .side button.side-item:hover { background: var(--hover); color: var(--fg); }
.side a.on { background: var(--active); color: var(--fg); font-weight: 600; }
.side svg { flex: none; }
.side-sep { height: 1px; background: var(--card-border); margin: 10px 6px; }
.side-label { font-size: 11.5px; letter-spacing: .06em; color: var(--fg-3);
  padding: 8px 12px 4px; text-transform: uppercase; font-weight: 600; }
.side-foot { margin-top: auto; padding-top: 10px; display: flex; flex-direction: column; gap: 4px; }

/* ---------- 顶栏(landing/docs) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border-bottom: 1px solid transparent;
}
.topbar.in { border-bottom-color: var(--card-border); }
.topbar .container { display: flex; align-items: center; gap: 22px; height: var(--header-h); }
.topbar nav { display: flex; align-items: center; gap: 4px; }
.topbar nav a {
  color: var(--fg-2); font-size: 14px; font-weight: 500;
  padding: 7px 13px; border-radius: var(--r-pill); text-decoration: none !important;
  transition: background .12s, color .12s;
}
.topbar nav a:hover { background: var(--hover); color: var(--fg); }
.topbar nav a.on { color: var(--fg); background: var(--active); }

/* ---------- logo ---------- */
.logo-full { display: inline-flex; align-items: center; gap: 9px;
  text-decoration: none !important; }
.logo-full img { height: 26px; width: auto; }
.logo-full .word { font-size: 16.5px; font-weight: 700; letter-spacing: .01em; color: var(--fg); }
.logo-full .sub { font-size: 10.5px; letter-spacing: .14em; color: var(--fg-3);
  text-transform: uppercase; font-weight: 600; margin-top: 1px; }

/* ---------- tab ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--card-border); }
.tabs button {
  height: 40px; padding: 0 16px; border: none; background: none;
  color: var(--fg-2); font-size: 14px; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button:hover { color: var(--fg); }
.tabs button.on { color: var(--fg); font-weight: 600; border-bottom-color: var(--brand); }

/* ---------- 代码卡 ---------- */
.code-card {
  position: relative;
  background: var(--code-bg); color: var(--code-fg);
  border-radius: var(--r-l); overflow: hidden;
  font-family: var(--mono); font-size: 13px; line-height: 1.55;
}
.code-card .code-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; font-size: 12px; color: #8b949e;
  background: rgba(255, 255, 255, .04);
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.code-card .code-lang { text-transform: uppercase; letter-spacing: .08em; font-size: 11px; font-weight: 600; }
.code-card pre { margin: 0; padding: 14px 16px; overflow-x: auto; }
.code-card code { font-family: var(--mono); white-space: pre; }
.code-card .copy-btn {
  border: 1px solid rgba(255, 255, 255, .14); background: rgba(255, 255, 255, .06);
  color: #c9d1d9; border-radius: 7px; font-size: 12px; padding: 4px 10px;
}
.code-card .copy-btn:hover { background: rgba(255, 255, 255, .12); }

/* ---------- 空态 ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 48px 20px; text-align: center; color: var(--fg-3);
}
.empty .empty-ic { font-size: 34px; opacity: .55; }

/* ---------- markdown ---------- */
.md { font-size: 15px; line-height: 1.7; word-break: break-word; }
.md > *:first-child { margin-top: 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 1.3em 0 .5em; line-height: 1.35; font-weight: 600; }
.md h1 { font-size: 1.6em; } .md h2 { font-size: 1.35em; }
.md h3 { font-size: 1.15em; } .md h4 { font-size: 1.02em; }
.md p { margin: .55em 0; }
.md ul, .md ol { margin: .5em 0; padding-left: 1.5em; }
.md li { margin: .25em 0; }
.md blockquote { margin: .8em 0; padding: 2px 16px; border-left: 3px solid var(--brand);
  color: var(--fg-2); background: var(--brand-tint); border-radius: 0 var(--r-s) var(--r-s) 0; }
.md code:not(pre code) { background: var(--bg-3); border: 1px solid var(--card-border);
  padding: 1.5px 6px; border-radius: 6px; font-size: .88em; }
[data-theme="dark"] .md code:not(pre code) { background: var(--n-150); border-color: var(--n-200); }
.md pre { margin: .8em 0; border-radius: var(--r-l); overflow: hidden; }
.md table { border-collapse: collapse; margin: .8em 0; font-size: 14px; }
.md th, .md td { border: 1px solid var(--card-border); padding: 7px 12px; }
.md th { background: var(--bg-3); font-weight: 600; }
.md a { color: var(--brand); }
.md hr { border: none; border-top: 1px solid var(--card-border); margin: 1.2em 0; }
.md img { max-width: 100%; border-radius: var(--r-m); }

/* ---------- 进度条 ---------- */
.prog { height: 6px; border-radius: 4px; background: var(--n-100); overflow: hidden; min-width: 70px; }
[data-theme="dark"] .prog { background: var(--n-150); }
.prog > i { display: block; height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--brand), var(--brand-soft)); transition: width .3s; }
.prog.warn > i { background: var(--warn); }
.prog.err > i { background: var(--err); }

/* ---------- 骨架屏 ---------- */
.skl {
  border-radius: 8px;
  background: linear-gradient(90deg, var(--n-100) 25%, var(--n-150) 50%, var(--n-100) 75%);
  background-size: 400% 100%;
  animation: skl 1.4s ease infinite;
}
@keyframes skl { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* 分段筛选(用量天数等) */
.seg { display: inline-flex; background: var(--bg-3); border-radius: var(--r-pill); padding: 3px; gap: 2px; }
.seg button {
  height: 28px; padding: 0 13px; border: none; border-radius: var(--r-pill);
  background: transparent; color: var(--fg-2); font-size: 13px; font-weight: 500;
}
.seg button.on { background: var(--bg-2); color: var(--fg); box-shadow: var(--shadow-sm); }
[data-theme="dark"] .seg button.on { background: var(--n-200); }

/* 遮罩工具 */
.spin { display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 🎙 实时对话条 */
.vt-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; margin-bottom: 8px;
  border: 1px solid var(--card-border); border-radius: var(--r-m);
  background: color-mix(in srgb, var(--brand) 6%, var(--bg-2));
}
.vt-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); flex: none;
  animation: rec-pulse 1.6s ease-in-out infinite; }
.vt-dot.talk { background: var(--err); animation-duration: .9s; }
.vt-status { font-size: 13px; color: var(--fg-2); flex: none; }
.vt-partial { font-size: 13.5px; color: var(--fg); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; min-width: 0; }
