/* 共享视觉主题：/、/account、/console、/agents、/guide、/docs 六个页面统一引用，
   保证同一套配色 token / 排版 / 基础组件，改风格只用改这一个文件。
   页面自己的 <style> 块只放这个文件覆盖不到的、页面专属的结构样式。 */

:root {
  --bg: #0b0e13;
  --bg-wash: rgba(69, 193, 240, 0.05);
  --panel: #12161e;
  --panel-hover: #161b24;
  --text: #edf0f4;
  --text-dim: #8991a1;
  --text-faint: #566072;
  --border: #212834;
  --border-hover: #2e3849;
  --accent: #4cc2ef;
  --accent-2: #6f8dfb;
  --accent-soft: rgba(76, 194, 239, 0.12);
  --accent-line: rgba(76, 194, 239, 0.35);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.14);
  --warn: #f2b84b;
  --warn-soft: rgba(242, 184, 75, 0.14);
  --danger: #f2637a;
  --danger-soft: rgba(242, 99, 122, 0.14);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-sm: 0 1px 2px rgba(8, 10, 14, 0.4);
  --shadow-md: 0 8px 24px -8px rgba(8, 10, 14, 0.55);
  --shadow-lg: 0 24px 64px -16px rgba(4, 6, 10, 0.6);

  /* ---------- 字号刻度：全站唯一的字号来源，页面自己的 <style> 块不再写死 px，
     统一引用这几个 token。级差大致按 1.125 递增，从 --fs-base（正文）往两头展开；
     比这套刻度上线前整体调大了 1-2 档（比如正文 13.5px → 15px，大标题 26px → 32px）。 */
  --fs-2xs: 12px;   /* 表头、徽章、极小的元信息 */
  --fs-xs: 13px;    /* 次要说明文字、hint */
  --fs-sm: 14px;    /* 按钮、输入框、表格正文、导航 */
  --fs-base: 15px;  /* 正文默认字号 */
  --fs-md: 16.5px;  /* 面板小标题、加粗小节标题 */
  --fs-lg: 19px;    /* 页面级标题（非 Hero），h3 */
  --fs-xl: 22px;    /* 文档 h2、次级大标题 */
  --fs-2xl: 27px;   /* 文档 h1 */
  --fs-3xl: 32px;   /* Hero h1，全站最大字号 */
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6f9;
    --bg-wash: rgba(13, 143, 199, 0.05);
    --panel: #ffffff;
    --panel-hover: #fbfcfe;
    --text: #171b21;
    --text-dim: #5b6472;
    --text-faint: #93a0b3;
    --border: #e4e8ee;
    --border-hover: #ccd4e0;
    --accent: #0d8fc7;
    --accent-2: #4f63d1;
    --accent-soft: rgba(13, 143, 199, 0.08);
    --accent-line: rgba(13, 143, 199, 0.3);
    --ok: #0f9d68;
    --ok-soft: rgba(15, 157, 104, 0.1);
    --warn: #b8790f;
    --warn-soft: rgba(184, 121, 15, 0.1);
    --danger: #d6304a;
    --danger-soft: rgba(214, 48, 74, 0.1);
    --shadow-sm: 0 1px 2px rgba(23, 27, 33, 0.04);
    --shadow-md: 0 12px 28px -12px rgba(23, 27, 33, 0.12);
    --shadow-lg: 0 24px 64px -20px rgba(23, 27, 33, 0.16);
  }
}

* { box-sizing: border-box; }
/* 注意：不能给 html/body 设置固定 height:100%——那会把 body 的布局盒子锁死在一屏高度，
   长页面往下滚动超过一屏后，body 内 position:sticky 的元素（比如 .topbar-shell）会
   因为「父级包含块」到底了而失去粘性，表现为滚多了顶栏就跟着滚走。改用 min-height
   即可，不影响背景铺满，也不影响 sticky 的生效范围。 */
body {
  margin: 0;
  font-family: var(--sans);
  font-size: var(--fs-base);
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(760px 420px at 14% -8%, var(--bg-wash), transparent 62%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.55;
}

.kicker {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 650;
  letter-spacing: 0.09em;
  color: var(--accent);
  margin-bottom: 10px;
  display: block;
}

/* ---------- page intro：品牌身份（logo + 产品名）只在 .topbar-shell 里出现一次，
   这里只放「这个页面是什么」的页面级标题 + 一句话说明，不重复 logo/产品名，
   避免跟顶栏的 brand 在视觉上打架。/account、/console、/agents、/guide、/docs
   五个页面统一用这一套。 */
.page-intro { margin: 28px 0 28px; max-width: 640px; }
.page-intro h1 {
  font-size: var(--fs-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
.page-intro p { font-size: var(--fs-md); color: var(--text-dim); line-height: 1.65; margin: 0; }

.shell { max-width: 1120px; margin: 0 auto; padding: 28px 24px 64px; }
.shell--narrow { max-width: 640px; }

/* ---------- topbar (含 /guide、/docs 用的 .topbar-shell 外壳)：整条 sticky 固定在
   视口顶部，滚动时始终可见（参考 workbuddy.cn 的固定导航条）。做成毛玻璃通栏，
   内部内容再收进 .topbar-shell-inner 保持跟其它区块一致的居中宽度。 ---------- */
.topbar-shell {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  box-shadow: var(--shadow-md);
}
.topbar-shell-inner { max-width: 1120px; margin: 0 auto; padding: 26px 24px 0; }
.topbar-shell .topbar { margin-bottom: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 24px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; transition: opacity 0.15s var(--ease); }
.brand:hover { opacity: 0.82; }
.brand-mark {
  width: 46px; height: 46px;
  border-radius: 13px;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--accent-line);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-md);
  flex-shrink: 0;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand-name { font-size: var(--fs-xl); font-weight: 750; letter-spacing: -0.02em; }
.brand-tag {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 650;
  color: var(--accent);
  letter-spacing: 0.02em;
  margin-left: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
}
h1.page-title { font-size: var(--fs-lg); font-weight: 650; letter-spacing: -0.01em; margin: 0; }

.topbar nav { display: flex; align-items: center; gap: 16px; font-size: var(--fs-sm); }
.topbar nav a.link { color: var(--text-dim); text-decoration: none; }
.topbar nav a.link:hover { color: var(--text); }

/* ---------- tab nav (页面级导航：首页/控制台/Agent/如何使用/文档，五个页面统一
   用同一套「顶栏 + 独立一行 tab」结构，见 .topbar-shell 的用法)。每一项用等宽的
   line-height + inline-flex 居中，避免中英文混排（比如「Agent」「API 文档」跟纯
   中文的「我的」「任务」放在同一行）因为字体基线不同而看起来没对齐。 ---------- */
.tab-nav {
  display: flex;
  gap: 6px;
  margin: -28px 0 28px;
  border-bottom: 1px solid var(--border);
}
.topbar-shell .tab-nav { margin: 0; border-bottom: none; }
.tab-nav a {
  display: inline-flex;
  align-items: center;
  height: 44px;
  padding: 0 14px;
  line-height: 1;
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-dim);
  text-decoration: none;
  border-radius: 9px;
  transition: color 0.15s var(--ease), background-color 0.15s var(--ease);
}
.tab-nav a:hover { color: var(--text); background: var(--panel-hover); }
.tab-nav a.active {
  color: var(--accent);
  font-weight: 700;
  background: var(--accent-soft);
}

.session, #topbar-session { display: flex; align-items: center; gap: 14px; }
#topbar-session { display: none; }
#topbar-guest { display: none; align-items: center; }
.session-email {
  font-family: var(--mono);
  font-size: var(--fs-sm);
  color: var(--text-dim);
  display: flex; align-items: center; gap: 7px;
}
.status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
  flex-shrink: 0;
}

/* ---------- buttons ---------- */
button, .icon-btn {
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.18s var(--ease), color 0.18s var(--ease), background 0.18s var(--ease), transform 0.12s var(--ease);
}
button {
  background: linear-gradient(155deg, var(--accent), var(--accent-2));
  color: #04121a;
  border: none;
  border-radius: 7px;
  padding: 9px 17px;
  font-size: var(--fs-sm);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
button:hover { filter: brightness(1.06); box-shadow: var(--shadow-md); }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
button.secondary, .icon-btn {
  background: var(--panel);
  color: var(--text-dim);
  border: 1px solid var(--border);
  font-weight: 500;
  box-shadow: none;
}
button.secondary:hover, .icon-btn:hover { border-color: var(--border-hover); color: var(--text); background: var(--panel-hover); box-shadow: none; }
button:focus-visible, .icon-btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  padding: 5px 11px;
  font-size: var(--fs-xs);
  font-weight: 500;
  box-shadow: none;
}
button.danger:hover { background: var(--danger-soft); }
.icon-btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; font-size: var(--fs-xs); }
.icon-btn svg { width: 14px; height: 14px; }

/* ---------- panels & layout ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
label { font-size: var(--fs-xs); color: var(--text-dim); display: block; margin-bottom: 5px; }

/* ---------- form controls ---------- */
input, select, textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 12px;
  font-size: var(--fs-sm);
  font-family: inherit;
  transition: border-color 0.15s var(--ease);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { width: 100%; resize: vertical; min-height: 64px; }
.form-field { display: flex; flex-direction: column; margin-bottom: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.form-field.full { grid-column: 1 / -1; }

/* ---------- table ---------- */
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th, td { text-align: left; padding: 10px 11px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-faint); font-weight: 600; font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: 0.03em; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--accent-soft); }
code { font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-dim); }

/* ---------- badges ---------- */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: var(--fs-2xs);
  font-weight: 600;
  font-family: var(--mono);
  letter-spacing: 0.01em;
  border: 1px solid transparent;
}
.badge-ok, .badge.active, .badge.completed, .badge.met, .badge.ok {
  background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent);
}
.badge-warn, .badge.pending, .badge.partial, .badge.in_call {
  background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent);
}
.badge-danger, .badge.disabled, .badge.expired, .badge.not_met, .badge.revoked, .badge.no_dialogue {
  background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent);
}
.verdict.met { color: var(--ok); }
.verdict.partial { color: var(--warn); }
.verdict.not_met { color: var(--danger); }

/* ---------- misc ---------- */
a.link { color: var(--accent); text-decoration: none; }
a.link:hover { text-decoration: underline; }
.hint, .subtitle { color: var(--text-dim); font-size: var(--fs-xs); }
#empty-state, #error-state, #empty-sessions, #empty-keys {
  color: var(--text-faint); font-size: var(--fs-sm); padding: 20px 0; text-align: center;
}
#error-state { color: var(--danger); }

.spinner {
  width: 13px; height: 13px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- toast / confirm 弹窗（替代浏览器原生 alert()/confirm()），
   由 /static/ui.js 的 window.UI.toast() / window.UI.confirm() 驱动 ---------- */
.ui-toast-stack {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(360px, calc(100vw - 40px));
}
.ui-toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: var(--fs-sm);
  line-height: 1.5;
  color: var(--text);
  box-shadow: var(--shadow-lg);
  animation: ui-toast-in 0.22s var(--ease);
}
.ui-toast.leaving { animation: ui-toast-out 0.18s var(--ease) forwards; }
.ui-toast-icon { flex-shrink: 0; width: 16px; height: 16px; margin-top: 1px; }
.ui-toast.success { border-color: color-mix(in srgb, var(--ok) 35%, var(--border)); }
.ui-toast.success .ui-toast-icon { color: var(--ok); }
.ui-toast.error { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.ui-toast.error .ui-toast-icon { color: var(--danger); }
.ui-toast.info .ui-toast-icon { color: var(--accent); }
@keyframes ui-toast-in { from { opacity: 0; transform: translateY(-6px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes ui-toast-out { to { opacity: 0; transform: translateX(12px); } }

.ui-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: color-mix(in srgb, black 55%, transparent);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: ui-fade-in 0.15s var(--ease);
}
.ui-modal {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 22px 18px;
  box-shadow: var(--shadow-lg);
  animation: ui-modal-in 0.18s var(--ease);
}
.ui-modal h3 { margin: 0 0 8px; font-size: var(--fs-lg); font-weight: 650; letter-spacing: -0.01em; }
.ui-modal p { margin: 0; font-size: var(--fs-sm); color: var(--text-dim); line-height: 1.65; }
.ui-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
@keyframes ui-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes ui-modal-in { from { opacity: 0; transform: translateY(6px) scale(0.97); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .ui-toast, .ui-modal, .ui-modal-overlay { animation: none; }
}

@media (max-width: 680px) {
  .form-grid { grid-template-columns: 1fr; }
}
