/* ============================================================================
   agent 控制台 —— 设计令牌 + 组件样式
   设计语言参考 kimi-code 的 vis/web：工业感的深色基线、等宽元信息、
   左侧 3px 分类色条、胶囊徽标、紧凑行高与全等宽数字。
   深色是基线，浅色只覆盖同名变量（:root[data-theme="light"]）。
   ========================================================================== */

:root {
  /* ---- 表面 ---- */
  --surface-0: #0b0d12;
  --surface-1: #12151c;
  --surface-2: #1a1e27;
  --surface-3: #242936;
  --border: #1f2430;
  --border-strong: #2d3342;

  /* ---- 前景 ---- */
  --fg-0: #e4e7ef;
  --fg-1: #a8afc0;
  --fg-2: #6c7488;
  --fg-3: #454c5e;
  --on-accent: #0b0d12;

  /* ---- 分类色 ---- */
  --user: #38bdf8;
  --assistant: #22d3ee;
  --tool: #f59e0b;
  --system: #a78bfa;
  --think: #8b5cf6;
  --turn: #14b8a6;

  /* ---- 语义色 ---- */
  --info: #60a5fa;
  --success: #4ade80;
  --warning: #fbbf24;
  --error: #f87171;

  --accent: #22d3ee;

  /* ---- 字体 ---- */
  --font-ui: "Geist", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", SFMono-Regular, Menlo,
    Consolas, "Cascadia Code", "Liberation Mono", monospace;

  /* ---- 尺寸 ---- */
  --topbar-h: 40px;
  --rail-w: 296px;
  --radius: 2px;
  --measure: 880px;
}

:root[data-theme="light"] {
  color-scheme: light;

  --surface-0: #fafbfc;
  --surface-1: #eef1f6;
  --surface-2: #e4e8f0;
  --surface-3: #d4d9e4;
  --border: #dde1ea;
  --border-strong: #bfc6d4;

  --fg-0: #0f1219;
  --fg-1: #3a4154;
  --fg-2: #616878;
  --fg-3: #9097a8;
  --on-accent: #fafbfc;

  --user: #0369a1;
  --assistant: #0891b2;
  --tool: #b45309;
  --system: #6d28d9;
  --think: #6d28d9;
  --turn: #0d9488;

  --info: #2563eb;
  --success: #15803d;
  --warning: #b45309;
  --error: #b91c1c;

  --accent: #0891b2;
}

:root[data-theme="dark"] { color-scheme: dark; }

/* ============================ 基础 ============================ */

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.5;
  background-color: var(--surface-0);
  color: var(--fg-0);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 深色底加一层极淡噪点，避免大面积纯色显得平板；浅色下会显脏，故不加 */
:root:not([data-theme="light"]) body {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.9  0 0 0 0 0.92  0 0 0 0 0.98  0 0 0 0.035 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-repeat: repeat;
}

/* 等宽字体关闭连字——调试/代码场景必须逐字符可读 */
.mono, code, pre, kbd, .pill, .tabular, input, textarea, select {
  font-family: var(--font-mono);
  font-feature-settings: "liga" 0, "calt" 0;
  font-variant-ligatures: none;
}
.tabular { font-variant-numeric: tabular-nums; }

::selection {
  background-color: color-mix(in oklab, var(--accent) 32%, transparent);
  color: var(--fg-0);
}

*:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }

button { font: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
img { max-width: 100%; }

/* 滚动条 */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 0;
  border: 2px solid transparent; background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--fg-3); background-clip: padding-box; }

.hidden { display: none !important; }
.scroll { overflow: auto; min-height: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--fg-2); }
.dim { color: var(--fg-3); }
.spacer { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.col { display: flex; flex-direction: column; min-width: 0; }
.nowrap { white-space: nowrap; }
.noscript { padding: 24px; font-family: var(--font-mono); color: var(--fg-2); }

/* ============================ 胶囊徽标 ============================ */

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 6px; font-size: 10.5px; font-weight: 500; line-height: 1.4;
  letter-spacing: 0.02em; text-transform: uppercase; white-space: nowrap;
  border-radius: var(--radius);
}
.pill.solid { background: var(--pill-color, var(--fg-2)); color: var(--on-accent); }
.pill.soft {
  background: color-mix(in oklab, var(--pill-color, var(--fg-2)) 18%, transparent);
  color: var(--pill-color, var(--fg-2));
}
.pill.outline { border: 1px solid var(--pill-color, var(--fg-2)); color: var(--pill-color, var(--fg-2)); }
.pill.user { --pill-color: var(--user); }
.pill.assistant { --pill-color: var(--assistant); }
.pill.tool { --pill-color: var(--tool); }
.pill.system { --pill-color: var(--system); }
.pill.think { --pill-color: var(--think); }
.pill.turn { --pill-color: var(--turn); }
.pill.info { --pill-color: var(--info); }
.pill.success { --pill-color: var(--success); }
.pill.warning { --pill-color: var(--warning); }
.pill.error { --pill-color: var(--error); }
.pill.neutral { --pill-color: var(--fg-2); }

/* ============================ 按钮 ============================ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 28px; padding: 0 10px; font-size: 12px; white-space: nowrap;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--fg-1);
  border-radius: var(--radius); transition: border-color .12s, color .12s, background .12s;
}
.btn:hover:not(:disabled) { border-color: var(--border-strong); color: var(--fg-0); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 500;
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); color: var(--on-accent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--fg-2); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--fg-0); border-color: transparent; }
.btn.danger { color: var(--error); border-color: color-mix(in oklab, var(--error) 35%, var(--border)); }
.btn.danger:hover:not(:disabled) { background: color-mix(in oklab, var(--error) 12%, transparent); color: var(--error); }
.btn.sm { height: 22px; padding: 0 7px; font-size: 11px; }
.btn.icon { width: 26px; padding: 0; }
.btn.block { width: 100%; }

/* ============================ 表单 ============================ */

.field {
  height: 28px; width: 100%; padding: 0 8px; font-size: 12px;
  color: var(--fg-0); background: var(--surface-0);
  border: 1px solid var(--border); border-radius: var(--radius);
  outline: none; transition: border-color .12s;
}
.field::placeholder { color: var(--fg-3); }
.field:focus { border-color: var(--border-strong); }
textarea.field { height: auto; padding: 6px 8px; resize: vertical; line-height: 1.5; }
select.field { appearance: none; padding-right: 20px; cursor: pointer; }
label.lbl {
  display: block; margin-bottom: 4px; font-family: var(--font-mono);
  font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-3);
}

/* ============================ 骨架布局 ============================ */

.app { display: flex; flex-direction: column; height: 100%; }

.topbar {
  display: flex; align-items: center; gap: 10px; flex: 0 0 var(--topbar-h);
  height: var(--topbar-h); padding: 0 12px;
  border-bottom: 1px solid var(--border); background: var(--surface-1);
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-name {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--fg-0); white-space: nowrap;
}
.brand-name em { font-style: normal; color: var(--fg-2); }
.brand-sub {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--fg-3);
}

.body { display: flex; flex: 1 1 auto; min-height: 0; }

.rail {
  display: flex; flex-direction: column; flex: 0 0 var(--rail-w); width: var(--rail-w);
  min-height: 0; border-right: 1px solid var(--border); background: var(--surface-1);
}

.main { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; min-height: 0; }

/* ============================ 侧栏 ============================ */

.rail-head { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.acct { display: flex; align-items: center; gap: 8px; min-width: 0; }
.avatar {
  display: flex; align-items: center; justify-content: center; flex: 0 0 26px;
  width: 26px; height: 26px; font-family: var(--font-mono); font-size: 12px;
  color: var(--on-accent); background: var(--accent); border-radius: var(--radius);
}
.acct-name { font-family: var(--font-mono); font-size: 12px; color: var(--fg-0); }
.acct-meta { font-family: var(--font-mono); font-size: 10px; color: var(--fg-3); }

.meter { margin-top: 8px; }
.meter-track { height: 3px; background: var(--surface-3); border-radius: 2px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--accent); transition: width .3s ease; }
.meter-fill.warn { background: var(--warning); }
.meter-fill.over { background: var(--error); }
.meter-line {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  margin-top: 4px; font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-2);
}

.rail-tools { display: flex; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.rail-tools .field { flex: 1 1 auto; }

.rail-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.rail-group {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 4px 12px; font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-3);
  background: var(--surface-1); border-bottom: 1px solid var(--border);
}
.rail-empty { padding: 14px 12px; font-family: var(--font-mono); font-size: 11px; color: var(--fg-3); }

.sess {
  position: relative; display: block; width: 100%; text-align: left;
  padding: 8px 30px 8px 12px; border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.sess:hover { background: var(--surface-2); }
.sess.on { background: var(--surface-2); }
.sess.on::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 2px; background: var(--accent);
}
.sess-top { display: flex; align-items: center; gap: 6px; }
.sess-title { font-size: 12.5px; color: var(--fg-0); }
.sess-time { font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-3); }
.sess-meta {
  display: flex; align-items: center; gap: 8px; margin-top: 2px;
  font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-2);
}
.sess-prev {
  margin-top: 3px; font-size: 11px; color: var(--fg-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sess-del {
  position: absolute; top: 7px; right: 8px; display: flex; align-items: center;
  justify-content: center; width: 18px; height: 18px; color: var(--fg-3);
  border: 1px solid transparent; border-radius: var(--radius); opacity: 0;
  transition: opacity .12s, color .12s, border-color .12s;
}
.sess:hover .sess-del, .sess-del:focus-visible { opacity: 1; }
.sess-del:hover { color: var(--error); border-color: color-mix(in oklab, var(--error) 40%, transparent); }

.rail-foot { padding: 8px 12px; border-top: 1px solid var(--border); }

/* ============================ 主区头部 ============================ */

.main-head {
  display: flex; align-items: center; gap: 10px; flex: 0 0 auto;
  min-height: 44px; padding: 6px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface-1);
}
.main-title {
  font-size: 13.5px; color: var(--fg-0); max-width: 46vw;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.main-sub { display: flex; align-items: center; gap: 8px; margin-top: 2px; font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-3); }

/* ============================ 消息流 ============================ */

.msgs { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 20px 20px 8px; }
.msgs-inner { max-width: var(--measure); margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }

.turn { display: flex; flex-direction: column; gap: 8px; }

.msg {
  position: relative; display: flex; flex-direction: column; gap: 6px;
  padding: 8px 12px; border-left: 3px solid var(--fg-3); background: var(--surface-1);
  animation: fade-in .18s ease-out;
}
.msg.user { border-left-color: var(--user); }
.msg.assistant { border-left-color: var(--assistant); }
.msg.system { border-left-color: var(--system); }
.msg.error { border-left-color: var(--error); background: color-mix(in oklab, var(--error) 8%, var(--surface-1)); }
.msg.cont { margin-top: -8px; }
.msg-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.msg-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; opacity: 0; transition: opacity .12s; }
.msg:hover .msg-actions, .msg-actions:focus-within { opacity: 1; }

.body-text {
  font-size: 13.5px; line-height: 1.68; color: var(--fg-0);
  word-break: break-word; overflow-wrap: anywhere;
}
.body-text > * + * { margin-top: 8px; }
.body-text h1, .body-text h2, .body-text h3, .body-text h4 { margin-top: 14px; line-height: 1.35; }
.body-text h1 { font-size: 17px; }
.body-text h2 { font-size: 15.5px; }
.body-text h3 { font-size: 14.5px; }
.body-text h4, .body-text h5, .body-text h6 { font-size: 13.5px; color: var(--fg-1); }
.body-text ul, .body-text ol { padding-left: 20px; }
.body-text li { margin: 2px 0; }
.body-text li > ul, .body-text li > ol { margin: 2px 0; }
.body-text blockquote {
  padding: 2px 0 2px 10px; border-left: 2px solid var(--border-strong); color: var(--fg-1);
}
.body-text hr { border: none; border-top: 1px solid var(--border-strong); margin: 12px 0; }
.body-text a { color: var(--accent); }
.body-text code {
  padding: 1px 4px; font-size: 12px; background: var(--surface-3);
  border-radius: var(--radius); color: var(--fg-0);
}
.body-text table { border-collapse: collapse; font-size: 12.5px; }
.body-text th, .body-text td { padding: 4px 8px; border: 1px solid var(--border); text-align: left; }
.body-text th { background: var(--surface-2); font-family: var(--font-mono); font-size: 11.5px; }
.body-text del { color: var(--fg-2); }

/* 代码块 */
.code {
  position: relative; border: 1px solid var(--border); background: var(--surface-0);
  border-radius: var(--radius); overflow: hidden;
}
.code-head {
  display: flex; align-items: center; gap: 8px; padding: 3px 8px;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--fg-3);
}
.code-head .code-copy { margin-left: auto; }
.code pre {
  margin: 0; padding: 8px 10px; overflow-x: auto;
  font-size: 12px; line-height: 1.6; color: var(--fg-0);
}
.code pre code { padding: 0; background: none; font-size: inherit; }

/* 语法高亮 */
.tok-kw { color: #c084fc; }
.tok-str { color: #86efac; }
.tok-num { color: #fca5a5; }
.tok-com { color: var(--fg-3); font-style: italic; }
.tok-fn { color: #7dd3fc; }
.tok-type { color: #fbbf24; }
.tok-punc { color: var(--fg-2); }
:root[data-theme="light"] .tok-kw { color: #7c3aed; }
:root[data-theme="light"] .tok-str { color: #15803d; }
:root[data-theme="light"] .tok-num { color: #b91c1c; }
:root[data-theme="light"] .tok-fn { color: #0369a1; }
:root[data-theme="light"] .tok-type { color: #b45309; }

/* 思考过程 */
.think { border: 1px solid var(--border); background: var(--surface-0); border-radius: var(--radius); }
.think-head {
  display: flex; align-items: center; gap: 6px; width: 100%; padding: 4px 8px;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--fg-2);
}
.think-head:hover { color: var(--fg-1); }
.think-body {
  display: none;
  padding: 6px 8px; border-top: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 12px; line-height: 1.6;
  color: var(--fg-1); white-space: pre-wrap; word-break: break-word;
  max-height: 340px; overflow: auto;
}
.think.open .think-body { display: block; }
.chev { transition: transform .12s ease-out; flex: 0 0 auto; }
.open > .tool-head .chev, .think.open .chev { transform: rotate(90deg); }

/* 工具卡片 */
.tool {
  border: 1px solid var(--border); background: var(--surface-0); border-radius: var(--radius);
  border-left: 3px solid var(--tool);
}
.tool.err { border-left-color: var(--error); }
.tool-head {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 5px 8px;
  text-align: left; font-size: 12px; color: var(--fg-1);
}
.tool-head:hover { background: var(--surface-2); }
.tool-name { font-family: var(--font-mono); color: var(--fg-0); }
.tool-args { font-family: var(--font-mono); font-size: 11px; color: var(--fg-3); }
.tool-body { display: none; border-top: 1px solid var(--border); }
.tool.open .tool-body { display: block; }
.tool-sec { padding: 6px 8px; }
.tool-sec + .tool-sec { border-top: 1px dashed var(--border); }
.tool-sec.hidden-sec { display: none; }
.tool-label {
  display: block; margin-bottom: 4px; font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-3);
}
.tool pre {
  margin: 0; padding: 0; max-height: 320px; overflow: auto;
  font-family: var(--font-mono); font-size: 11.5px; line-height: 1.6;
  color: var(--fg-1); white-space: pre-wrap; word-break: break-word;
}
.tool.err .tool pre { color: color-mix(in oklab, var(--error) 75%, var(--fg-0)); }

/* 用量行 */
.usage {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px;
  padding-top: 6px; border-top: 1px dashed var(--border);
  font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-2);
}
.usage b { color: var(--fg-1); font-weight: 500; }

/* 光标 */
.caret {
  display: inline-block; width: 7px; height: 14px; margin-left: 1px;
  vertical-align: -2px; background: var(--accent); animation: blink 1s steps(1) infinite;
}
.body-text.streaming { white-space: pre-wrap; word-break: break-word; }
.wait { color: var(--fg-3); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes fade-in { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }

/* 空状态 */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 56px 16px; text-align: center;
}
.empty-mark { color: var(--border-strong); margin-bottom: 2px; }
.empty-title { font-size: 13.5px; color: var(--fg-1); }
.empty-sub { font-size: 12px; color: var(--fg-3); max-width: 420px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 6px; }
.chip {
  padding: 4px 9px; border: 1px dashed var(--border-strong); border-radius: var(--radius);
  font-family: var(--font-mono); font-size: 11px; color: var(--fg-2);
  transition: color .12s, border-color .12s;
}
.chip:hover { color: var(--fg-0); border-color: var(--accent); }

/* 抽屉小节 */
.card-sec { display: flex; flex-direction: column; }
.sec-title {
  margin-bottom: 8px; padding-bottom: 5px; border-bottom: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--fg-2);
}
.kv-grid { display: grid; grid-template-columns: 1fr; gap: 5px; }
.kv { display: flex; align-items: baseline; gap: 10px; font-size: 12px; }
.kv .k { flex: 0 0 132px; color: var(--fg-2); }
.kv .v { color: var(--fg-0); }
.md-task { font-family: var(--font-mono); color: var(--fg-3); }
.md-task.done { color: var(--success); }

/* ============================ 输入区 ============================ */

.composer { flex: 0 0 auto; padding: 8px 20px 16px; }
.composer-inner { max-width: var(--measure); margin: 0 auto; }
.composer-box {
  display: flex; align-items: flex-end; gap: 8px; padding: 8px;
  border: 1px solid var(--border); background: var(--surface-1); border-radius: var(--radius);
  transition: border-color .12s;
}
.composer-box:focus-within { border-color: var(--border-strong); }
.composer textarea {
  flex: 1 1 auto; min-height: 40px; max-height: 220px; padding: 4px 4px 4px 6px;
  border: none; background: none; color: var(--fg-0); font-family: var(--font-ui);
  font-size: 13.5px; line-height: 1.6; resize: none; outline: none;
}
.composer textarea::placeholder { color: var(--fg-3); }
.composer-hint {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 5px; font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-3);
}
kbd {
  padding: 0 4px; border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: 2px; font-size: 10px; color: var(--fg-2); background: var(--surface-2);
}

/* ============================ 登录视图 ============================ */

.auth { display: flex; align-items: center; justify-content: center; min-height: 100%; padding: 24px; }
.auth-card {
  width: 100%; max-width: 420px; border: 1px solid var(--border);
  background: var(--surface-1); border-radius: var(--radius);
}
.auth-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.auth-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.auth-h1 { font-size: 15px; letter-spacing: 0.02em; }
.auth-sub { margin-top: 3px; font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-3); }
.auth-sec { display: flex; flex-direction: column; gap: 8px; }
.auth-sep { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 10px; color: var(--fg-3); text-transform: uppercase; letter-spacing: 0.1em; }
.auth-sep::before, .auth-sep::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.acct-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-0);
}
.acct-row + .acct-row { margin-top: 6px; }
.auth-msg { font-family: var(--font-mono); font-size: 11px; min-height: 15px; color: var(--fg-2); }
.auth-msg.ok { color: var(--success); }
.auth-msg.err { color: var(--error); }

/* ============================ 浮层：抽屉 / 弹窗 / 提示 ============================ */

.layer { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
.layer > * { pointer-events: auto; }

.scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, .58); animation: fade-in .12s ease-out; }

.drawer {
  position: absolute; inset: 0 0 0 auto; display: flex; flex-direction: column;
  width: min(560px, 100%); background: var(--surface-1); border-left: 1px solid var(--border);
  box-shadow: -12px 0 32px rgba(0, 0, 0, .35); animation: slide-in .16s ease-out;
}
@keyframes slide-in { from { transform: translateX(14px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head {
  display: flex; align-items: center; gap: 8px; flex: 0 0 40px; padding: 0 14px;
  border-bottom: 1px solid var(--border); font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--fg-1);
}
.drawer-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.drawer-foot { flex: 0 0 auto; display: flex; gap: 8px; justify-content: flex-end; padding: 10px 14px; border-top: 1px solid var(--border); }

.modal {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(420px, calc(100% - 32px)); background: var(--surface-1);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .4); animation: fade-in .12s ease-out;
}
.modal-head { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.modal-body { padding: 14px; font-size: 12.5px; color: var(--fg-1); }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 14px; border-top: 1px solid var(--border); }

.toasts {
  position: absolute; right: 14px; bottom: 14px; display: flex; flex-direction: column;
  gap: 8px; align-items: flex-end; max-width: 360px;
}
.toast {
  display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px;
  border: 1px solid var(--border-strong); border-left: 3px solid var(--info);
  background: var(--surface-2); border-radius: var(--radius);
  font-size: 12px; color: var(--fg-1); box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
  animation: slide-in .14s ease-out;
}
.toast.ok { border-left-color: var(--success); }
.toast.warn { border-left-color: var(--warning); }
.toast.err { border-left-color: var(--error); }
.toast-msg { word-break: break-word; }

/* ============================ 响应式 ============================ */

.rail-toggle { display: none; }
.rail-scrim { display: none; }

@media (max-width: 820px) {
  .rail-toggle { display: inline-flex; }
  .brand-sub { display: none; }
  .brand-name { font-size: 11px; letter-spacing: 0.06em; }
  .topbar .cost { display: none; }
  .main-head { flex-wrap: wrap; row-gap: 6px; }
  .main-head .btn span { display: none; }   /* 窄屏只留图标 */
  .main-sub { display: none; }
  .main-title { max-width: 52vw; }
  .rail {
    position: fixed; top: var(--topbar-h); bottom: 0; left: 0; z-index: 30;
    width: min(84vw, var(--rail-w)); flex-basis: auto;
    transform: translateX(-100%); transition: transform .18s ease-out;
    box-shadow: 12px 0 32px rgba(0, 0, 0, .35);
  }
  .app.rail-open .rail { transform: none; }
  .app.rail-open .rail-scrim {
    display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 29;
    background: rgba(0, 0, 0, .5);
  }
  .msgs { padding: 14px 12px 4px; }
  .composer { padding: 6px 12px 12px; }
  .main-head { padding: 6px 12px; }
  .topbar { padding: 0 8px; }
  .msg { padding: 7px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
