/* Titan AI app shell (/app). Linked from templates/status.html; bump ?v= there when this changes. */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
:root {
  --app-gradient: linear-gradient(180deg, #faf9f5 0%, #faf9f5 100%);
  --bg: #faf9f5;
  --sidebar: #f3f1ea;
  --accent-wash: #e9edfb;
  --accent: #2b4fd8;
  --accent-strong: #2341b5;
  --gold: #ffd970;
  --ink: #141413;
  --ink-soft: #3d3d3a;
  --ink-faint: #6b6a65;
  --line: #eae8e1;
  --surface: #fff;
  --surface-soft: #f7f8fa;
  --surface-float: #fff;
  --accent-fill: #2b4fd8;
  --accent-fill-hover: #2341b5;
  /* Added in batch 2 (docs/ui-tokens.md): strong border, chip fill, chip hover, hover wash. */
  --line-strong: #ccd3db;
  --code-bg: #f6f8fa;
  --code-inline: rgba(0, 0, 0, 0.06);
  --chip: #f0eee6;
  --chip-hover: #e8e5db;
  --hover: rgba(20, 20, 19, 0.06);
  --danger-fill: #c0392b;
  --danger-fill-hover: #a93226;
  --ok: #15803d; --ok-bg: rgba(21, 128, 61, 0.1);
  --warn: #b45309; --warn-bg: rgba(180, 83, 9, 0.1);
  --danger: #c0392b; --danger-bg: rgba(192, 57, 43, 0.1);
  /* Family shape steps (docs/ui-tokens.md): controls 10, cards 14, panels 20, pills 999; buttons 36/40/46 high. */
  --r-control: 10px; --r-card: 16px;
  /* Family spacing scale (docs/ui-tokens.md). */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px; --space-7: 48px; --r-panel: 20px; --r-pill: 999px;
  --btn-sm: 36px; --btn-md: 40px; --btn-lg: 46px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 26px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 2px 10px rgba(16, 24, 40, 0.06);
  /* Floating surfaces: a tight contact shadow over a long soft ambient one. */
  --shadow-float: 0 2px 6px rgba(16, 24, 40, 0.08), 0 16px 40px rgba(16, 24, 40, 0.16);
  /* Group 2 visual layer: brand type + a softer accent gradient for
     buttons/hero glow. Existing tokens are untouched; these are additive. */
  --font-display: "Fraunces", "Noto Sans SC", Georgia, "Iowan Old Style", serif;
  --font-sans: "Geist", "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  /* AI answer text. Claude = serif (default), GPT = Geist sans, Kimi = system sans.
     Picked in Settings; html[data-answer-font] swaps the three vars below. */
  --font-answer: "Source Serif 4", "Noto Sans SC", Georgia, "Iowan Old Style", "Songti SC", serif;
  --answer-size: 1.0625rem;
  --answer-lh: 1.7;
  /* Type scale: five steps. Chrome text maps onto these; a few one-off sizes remain. */
  --fs-display: 1.75rem;
  --fs-title: 1rem;
  --fs-body: 0.875rem;
  --fs-small: 0.8125rem;
  --fs-label: 0.75rem;
  --lh-body: 1.55;
  --ls-display: -0.03em;
  --ls-label: 0.08em;
  --accent-grad: #2b4fd8;
  --motion: 0.18s cubic-bezier(0.2, 0.7, 0.3, 1);
  accent-color: var(--accent-fill);
}
/* Dark: the four family layers (page #1f2124, bars #25272a, cards #2a2b2e, floats #323438), so anything drawn
   with the tokens follows the theme instead of keeping its light value. */
body.dark {
  --bg: #1f2124;
  --sidebar: #25272a;
  --surface: #2a2b2e;
  --surface-soft: #25272a;
  --surface-float: #323438;
  --line: #3f4144;
  --ink: #e6e6e6;
  --ink-soft: #cfd2d6;
  --ink-faint: #9aa0a6;
  --accent: #7b93f0;
  --accent-strong: #9db0f5;
  --accent-wash: #232c4a;
  --accent-fill: #4a6ae6;
  --accent-fill-hover: #5b79ec;
  --line-strong: #4a4c50;
  --code-bg: #25272a;
  --code-inline: rgba(255, 255, 255, 0.12);
  --chip: #323438;
  --chip-hover: #3a3c40;
  --hover: rgba(255, 255, 255, 0.07);
  --danger-fill: #c0392b;
  --danger-fill-hover: #a93226;
  --ok: #4ade80; --ok-bg: rgba(74, 222, 128, 0.1);
  --warn: #fbbf24; --warn-bg: rgba(251, 191, 36, 0.1);
  --danger: #f87171; --danger-bg: rgba(248, 113, 113, 0.1);
  color-scheme: dark;
}
.icon-sprite { display: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  font-family: var(--font-sans);
  line-height: var(--lh-body);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
/* The back-button row sits on the body, so it needs the dark base too. */
body.dark { background: var(--bg); }
.sidebar {
  width: 17.5rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.9rem 0.75rem;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}
.brand-icon { width: 1.5rem; height: 1.5rem; border-radius: 0.4rem; display: block; }
/* 产品切换器（Titan AI / Gunn Tools），模仿 ChatGPT/Codex 那种下拉 */
/* 三站统一：顶栏区高 60px（--ux-topbar-h），各站保留自己的主色。 */
/* sticky: 侧边栏整体滚动时（短屏 768px 高），品牌切换器留在顶部 */
.product-switch { position: sticky; top: 0; z-index: 2; background: var(--sidebar); padding: 0.15rem 0 0.6rem; min-height: var(--ux-topbar-h); display: flex; flex-direction: column; justify-content: center; }
.product-switch-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.45rem 0.6rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  background: var(--chip);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color var(--motion);
}
.product-switch-btn:hover { background: var(--hover); }
.product-switch-caret { width: 1rem; height: 1rem; margin-left: auto; opacity: 0.55; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.product-menu {
  position: absolute;
  z-index: 40;
  top: calc(100% - 0.35rem);
  left: 0;
  right: 0;
  padding: 0.4rem;
  background: var(--surface-float);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-float);
}
.product-menu[hidden] { display: none; }
.product-menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.6rem;
  border-radius: 12px;
  text-decoration: none;
  color: var(--ink);
  transition: background-color var(--motion);
}
.product-menu-item:hover { background: var(--hover); }
.product-menu-item .pm-text { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.product-menu-item .pm-title { font-size: 1rem; font-weight: 600; }
.product-menu-item .pm-desc { font-size: 0.8125rem; color: var(--ink-faint); }
.product-menu-item .pm-check { width: 1.15rem; height: 1.15rem; margin-left: auto; fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.product-menu-item .pm-out { width: 1rem; height: 1rem; margin-left: auto; opacity: 0.4; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dark .product-menu { border-color: var(--line)}
.side-btn {
  display: block;
  width: 100%;
  padding: 0.5rem 0.7rem;
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  transition: background-color var(--motion), transform var(--motion);
}
.side-btn:hover { background: var(--hover); }
.side-btn:active { background: var(--chip-hover); transform: scale(0.98); }
.icon-btn { display: flex; align-items: center; gap: 0.55rem; }
.icon-btn svg { width: 1rem; height: 1rem; flex-shrink: 0; opacity: 0.75; }
.side-ico { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dark .side-ico { opacity: 0.85}
.mode-switch {
  position: relative;
  display: flex;
  gap: 0.25rem;
  padding: 0.3rem;
  background: var(--chip);
  border-radius: 999px;
}
/* Sliding thumb: two equal halves, so moving one slot is (half + gap). */
.mode-switch::before {
  content: "";
  position: absolute;
  top: 0.3rem;
  bottom: 0.3rem;
  left: 0.3rem;
  width: calc((100% - 0.6rem - 0.25rem) / 2);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(16, 24, 40, 0.16);
  transition: transform var(--motion);
}
.mode-switch:has(#mode-option-code.active)::before { transform: translateX(calc(100% + 0.25rem)); }
@media (prefers-reduced-motion: reduce) { .mode-switch::before { transition: none; } }
.mode-switch-btn {
  flex: 1;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-faint);
  padding: 0.5rem 0.6rem;
  border-radius: 999px;
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: background-color var(--motion), color var(--motion);
}
.mode-switch-btn:hover:not(.active) { background: var(--hover); }
.mode-switch-btn.active { color: var(--ink); }
.account-row { display: flex; align-items: center; gap: 0.55rem; padding: 0.35rem 0.7rem; }
.side-icon { display: inline-block; }
.account-row .side-email { padding: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--accent-fill);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; display: block; }
.avatar-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.4rem; }
.avatar-choice {
  width: 3rem;
  height: 3rem;
  padding: 0.3rem;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line-strong);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar-choice img { width: 100%; height: 100%; }
.avatar-choice:hover { box-shadow: 0 0 0 2px var(--line-strong); }
.avatar-choice.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.avatar-choice .initial { font-weight: 700; color: var(--accent); font-size: 1rem; }
.side-nav, .side-bottom { display: flex; flex-direction: column; gap: 0.2rem; }
/* Head (product switch) and foot (account, Settings, Sign in) stay put; only the middle scrolls, so opening Fun,
   More and a long Recent list never pushes Settings below the screen. Same in the phone drawer. */
.side-bottom { margin-top: auto; position: sticky; bottom: -0.9rem; z-index: 2; margin-bottom: -0.9rem; padding-bottom: 0.9rem; background: var(--sidebar); }
.side-email { padding: 0.5rem 0.7rem; font-size: 0.8125rem; color: var(--ink-soft); word-break: break-all; }
.side-plan {
  display: block;
  margin: 0 0.7rem 0.25rem;
  padding: 0.25rem 0.55rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 999px;
  text-decoration: none;
  color: var(--accent);
  background: var(--accent-wash);
  width: fit-content;
}
.side-plan.pro { background: var(--accent-wash); color: var(--accent); }
.model-tier-badge {
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0.08rem 0.38rem;
  border-radius: 999px;
  background: var(--accent-wash);
  color: var(--accent);
  flex-shrink: 0;
}
.model-item.locked { opacity: 0.72; }
.model-group {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 0.55rem 0.5rem 0.2rem;
}
.model-auto-badge { background: var(--ok-bg); color: var(--ok); }
.side-chats { flex: 1; min-height: 0; overflow-y: auto; margin-top: 0.4rem; }
.side-chats-title { font-size: 0.6875rem; color: var(--ink-faint); padding: 0 0.7rem 0.25rem; text-transform: uppercase; letter-spacing: var(--ls-label); }
.chat-item { display: flex; align-items: center; gap: 0.1rem; }
.chat-item .chat-open { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.875rem; padding: 0.42rem 0.6rem; }
.chat-del { flex-shrink: 0; border: 0; background: transparent; color: var(--ink-faint); cursor: pointer; font-size: 0.875rem; padding: 0.2rem 0.45rem; border-radius: 6px; }
.chat-del:hover { background: var(--hover); color: var(--danger); }
.chat-ren { flex-shrink: 0; border: 0; background: transparent; color: var(--ink-faint); cursor: pointer; padding: 0.2rem 0.35rem; border-radius: 6px; display: inline-flex; align-items: center; }
.chat-ren svg { width: 0.9rem; height: 0.9rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chat-ren:hover { background: var(--hover); color: var(--ink); }
@media (hover: hover) { .chat-item .chat-ren { opacity: 0; } .chat-item:hover .chat-ren, .chat-ren:focus-visible { opacity: 1; } }
.side-section { border-top: 1px solid var(--line); margin-top: 0.45rem; padding-top: 0.45rem; }
.side-fold .side-chev { margin-left: auto; width: 0.95rem; height: 0.95rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: 0.55; transition: transform var(--motion); }
.side-fold[aria-expanded="true"] .side-chev { transform: rotate(180deg); }
.side-sub { margin-left: 0.55rem; padding-left: 0.3rem; border-left: 1px solid var(--line, var(--line)); }
.side-sub[hidden] { display: none; }
.side-section-title { font-size: 0.6875rem; color: var(--ink-faint); padding: 0.1rem 0.7rem 0.3rem; text-transform: uppercase; letter-spacing: var(--ls-label); }
/* 模型选择器靠右（Send 紧跟其后），和其他 AI 软件的输入栏一致。 */
.model-picker { position: relative; flex-shrink: 0; margin-left: auto; }
.model-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0.3rem 0.2rem;
  max-width: 12rem;
}
.model-btn #model-btn-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-logo { width: 1.05rem; height: 1.05rem; display: block; flex-shrink: 0; }
/* SVG chevron: the ▾ glyph is missing from the UI fonts and rendered as a stray dot. */
.caret { width: 0.7rem; height: 0.7rem; flex-shrink: 0; fill: none; stroke: var(--ink-faint); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.model-menu {
  position: absolute;
  bottom: calc(100% + 0.4rem);
  right: 0;
  min-width: 16.5rem;
  max-width: 20rem;
  max-height: 17rem;
  overflow-y: auto;
  background: var(--surface-float);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  padding: 0.25rem;
  z-index: 20;
}
.model-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  padding: 0.45rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  color: var(--ink);
}
.model-item:hover { background: var(--hover); }
.model-item.active { background: transparent; color: var(--ink); font-weight: 600; }
.model-item .check { margin-left: 0.4rem; color: var(--accent); font-size: 0.875rem; }
.model-speed {
  margin-left: auto;
  padding-left: 0.6rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--ink-faint);
  white-space: nowrap;
}
.speed-dot { width: 0.45rem; height: 0.45rem; border-radius: 50%; background: #b9bec6; }
.speed-dot.good { background: var(--ok); }
.speed-dot.meh { background: #d99a1b; }
.speed-dot.slow { background: #cf5b32; }
.speed-dot.bad { background: #b04848; }
.speed-dot.unknown { background: #c9ced6; }
.model-item img { width: 1.05rem; height: 1.05rem; }
.attach-btn { flex-shrink: 0; border: 0; background: transparent; color: var(--ink-faint); cursor: pointer; padding: 0.3rem 0.4rem; border-radius: 8px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.attach-btn svg { width: 1.1rem; height: 1.1rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.attach-btn:hover { background: var(--hover); }
.attach-btn.recording { background: var(--danger-bg); box-shadow: 0 0 0 2px #f3b4b4; }
.attach-btn.active { background: var(--accent-wash); box-shadow: 0 0 0 2px var(--line-strong); }
.sources { margin-top: 0.45rem; display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; font-size: 0.8125rem; color: var(--ink-faint); }
.sources a { color: var(--accent); text-decoration: none; }
.sources a:hover { text-decoration: underline; }
.switch-note {
  margin-top: 0.45rem;
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--warn);
  background: var(--warn-bg);
  border: 1px solid #f2d9a4;
  border-radius: 12px;
  padding: 0.5rem 0.65rem;
}
.switch-note svg { width: 20px; height: 20px; flex-shrink: 0; margin-top: 0.05rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: 0.8; }
.dark .switch-note { border-color: var(--line-strong)}
/* Shared UX tokens (Group 3): same radius / icon / shimmer as Gunn + IDE. */
:root { --ux-radius: 12px; --ux-topbar-h: 60px; --ux-icon: 20px; }
.ux-notice {
  display: flex; align-items: flex-start; gap: 0.45rem;
  font-size: 0.8125rem; line-height: 1.5;
  color: var(--ink-soft); background: var(--surface-soft); border: 1px solid var(--line);
  border-radius: 12px; padding: 0.5rem 0.65rem; margin-top: 0.45rem;
}
.ux-notice svg { width: 20px; height: 20px; flex-shrink: 0; margin-top: 0.05rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: 0.8; }
.dark .ux-notice { border-color: var(--line)}
.ux-skeleton {
  border-radius: 12px;
  background: linear-gradient(100deg, var(--chip) 30%, var(--surface-soft) 50%, var(--chip) 70%);
  background-size: 200% 100%;
  animation: ux-shimmer 1.2s infinite linear;
  min-height: 2.4rem;
}
.dark .ux-skeleton { background-size: 200% 100%}
@keyframes ux-shimmer { from { background-position: 180% 0; } to { background-position: -20% 0; } }
@media (prefers-reduced-motion: reduce) { .ux-skeleton { animation: none; } }
.persona-select {
  flex-shrink: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--ink-soft);
  max-width: 7.5rem;
  padding: 0.3rem 0;
  outline: none;
}
.persona-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.meta button { border: 0; background: transparent; color: var(--ink-faint); cursor: pointer; font-size: var(--fs-small); padding: 0 0.2rem; display: inline-flex; align-items: center; }
.meta button svg { width: 0.95rem; height: 0.95rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.meta button:hover { color: var(--accent); }
.meta button.saved-on { color: #e8a33d; }
.saved-item { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0.8rem 1rem; margin-top: 0.75rem; }
.saved-item .saved-meta { font-size: 0.8125rem; color: var(--ink-faint); margin-bottom: 0.4rem; }
.saved-item pre { white-space: pre-wrap; word-break: break-word; margin: 0.3rem 0 0.5rem; font: inherit; font-size: 0.875rem; }
.saved-item .saved-actions { display: flex; gap: 0.5rem; }
.saved-item button { border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-soft); font-size: 0.8125rem; padding: 0.25rem 0.7rem; border-radius: 8px; cursor: pointer; }
.saved-item button:hover { background: var(--hover); }
.dark .saved-item { border-color: var(--line)}
.dark .saved-item button { border-color: var(--line-strong)}
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 0.85rem; margin-top: 0.6rem; }
.game-card {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  cursor: pointer;
  text-align: left;
  font: inherit;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  transition: box-shadow var(--motion), transform var(--motion);
}
.game-card-icon { width: 2.6rem; height: 2.6rem; flex-shrink: 0; }
.game-card-text { min-width: 0; }
/* 特异性要高于 `.status-inner button:not(...)` 的通用蓝色按钮样式,否则卡片会变成蓝底深字 */
.status-inner button.game-card:not(.avatar-choice):not(.theme-swatch) {
  margin-top: 0;
  padding: 1rem 1.1rem;
  background: var(--surface);
  color: var(--ink);
  font-size: inherit;
  font-weight: 500;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.status-inner .game-card h3 { color: var(--ink); }
.status-inner .game-card p { color: #64748b; }
.dark .status-inner button.game-card:not(.avatar-choice):not(.theme-swatch) { border-color: var(--line)}
.dark .status-inner .game-card p { color: var(--ink-faint)}
.status-inner .back-btn {
  background: var(--surface);
  color: var(--ink-soft);
  font-weight: 600;
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
}
.status-inner .back-btn:hover { background: var(--hover); }
.dark .status-inner .back-btn { border-color: var(--line-strong)}
.game-card:hover { box-shadow: 0 5px 16px rgba(16, 24, 40, 0.1); transform: translateY(-2px); }
.game-card h3 { margin: 0 0 0.3rem; font-size: 1rem; font-weight: 600; }
.game-card p { margin: 0; font-size: 0.875rem; color: var(--ink-faint); }
.game-topbar { display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap; }
.game-topbar h2 { margin: 0; }
.game-back { margin: 0; }
.play-area { position: relative; display: flex; justify-content: center; margin-top: 1rem; }
/* Cap the height to the window and let width follow the aspect ratio, so the
   tall Tetris board stays fully visible on short screens. */
.game-canvas { display: block; width: auto; height: auto; max-width: 100%; max-height: 70vh; margin: 0 auto; border-radius: 12px; box-shadow: 0 8px 24px rgba(16, 24, 40, 0.18); touch-action: none; }
.game-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  background: rgba(17, 24, 39, 0.72);
  color: #fff;
  border-radius: 12px;
  font-weight: 600;
  text-align: center;
  padding: 1rem;
}
.game-overlay button {
  padding: 0.5rem 1rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent-fill);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.g2048-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  background: #0f172a;
  padding: 0.6rem;
  border-radius: 14px;
  width: min(86vw, 22rem);
  aspect-ratio: 1;
  touch-action: none;
}
.g2048-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  font-weight: 700;
  font-size: 1.25rem;
}
.g2048-cell[data-value] { background: #5b9dff; }
.g2048-cell[data-value="4"] { background: #4d8ef0; }
.g2048-cell[data-value="8"] { background: #3f7fe0; }
.g2048-cell[data-value="16"] { background: #356fd0; }
.g2048-cell[data-value="32"] { background: #2f63c0; }
.g2048-cell[data-value="64"] { background: #2a58b0; }
.g2048-cell[data-value="128"] { background: #ffd970; color: #4a3a00; }
.g2048-cell[data-value="256"] { background: #ffcf4d; color: #4a3a00; }
.g2048-cell[data-value="512"] { background: #ffc32b; color: #4a3a00; }
.g2048-cell[data-value="1024"] { background: #ffb703; color: #4a3a00; }
.g2048-cell[data-value="2048"] { background: #ffaa00; color: #3a2b00; }
.g2048-cell[data-value="super"] { background: #ff9500; color: #3a2b00; }
.dark .game-card { border-color: var(--line)}
.dark .g2048-board { background: var(--sidebar)}
.attachment-row { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.45rem; }
.attachment-chip { background: #eef3fd; border: 1px solid #c9d8f7; color: var(--accent); border-radius: 999px; padding: 0.25rem 0.7rem; font-size: 0.8125rem; }
.attachment-remove { border: 0; background: transparent; color: var(--ink-faint); cursor: pointer; font-size: 0.875rem; padding: 0.1rem 0.35rem; border-radius: 6px; }
.attachment-remove:hover { background: var(--hover); color: var(--danger); }
.msg .body p { margin: 0 0 0.5rem; }
.msg .body p:last-child { margin-bottom: 0; }
.msg .body h2, .msg .body h3, .msg .body h4 { margin: 0.6rem 0 0.35rem; font-size: 1rem; }
.msg .body ul, .msg .body ol { margin: 0.3rem 0 0.5rem; padding-left: 1.3rem; }
.msg .body li { margin-bottom: 0.2rem; }
.msg .body pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: 0.6rem 0.75rem; overflow-x: auto; margin: 0.4rem 0; }
.msg .body code { background: var(--code-inline); border-radius: 4px; padding: 0 0.25rem; font-size: 0.9em; }
.msg .body pre code { background: none; padding: 0; border-radius: 0; }
/* GFM tables (markdown.js wraps each in .table-wrap): the wrapper scrolls sideways on a phone instead of squeezing the columns. */
.msg .body .table-wrap { overflow-x: auto; margin: 0.5rem 0; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); -webkit-overflow-scrolling: touch; }
.msg .body table { width: max-content; min-width: 100%; border: 0; border-radius: 0; background: transparent; border-collapse: collapse; color: var(--ink); }
.msg .body th, .msg .body td { min-width: 6.5rem; max-width: 24rem; padding: 0.5rem 0.75rem; font-size: 0.9em; line-height: 1.45; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); border-right: 0; }
.msg .body th { background: var(--chip); font-weight: 600; white-space: nowrap; }
.msg .body tr:last-child td { border-bottom: 0; }
.msg .body th.ta-center, .msg .body td.ta-center { text-align: center; }
.msg .body th.ta-right, .msg .body td.ta-right { text-align: right; font-variant-numeric: tabular-nums; }
.msg .body blockquote { margin: 0.4rem 0; padding-left: 0.7rem; border-left: 3px solid var(--line-strong); color: var(--ink-soft); }
.msg .body a { color: var(--accent); }
.msg .body pre { position: relative; }
.msg .body .code-copy {
  position: absolute;
  top: 0.35rem;
  right: 0.4rem;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.6875rem;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--motion);
}
.msg .body pre:hover .code-copy { opacity: 1; }
.thinking { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 0.85rem 1rem; }
.thinking-label { font-style: normal; font-size: 0.8125rem; color: var(--ink-faint); margin-left: 0.4rem; }
.thinking span { width: 6px; height: 6px; border-radius: 50%; background: #b6bcc4; animation: pulse 1.2s infinite ease-in-out; }
.thinking span:nth-child(2) { animation-delay: 0.15s; }
.thinking span:nth-child(3) { animation-delay: 0.3s; }
@keyframes pulse {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}
.regen {
  margin-left: 0.4rem;
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  font-size: 0.8125rem;
  padding: 0 0.2rem;
}
.regen:hover { color: var(--accent); }
.msg-row.regen-held { display: none; }
.msg .body hr { border: 0; border-top: 1px solid var(--line, rgba(128, 128, 128, 0.35)); margin: 0.9rem 0; }
.quote-btn {
  position: absolute;
  top: 0.3rem;
  right: 0.35rem;
  border: 0;
  background: transparent;
  color: #9aa0a6;
  font-size: 0.875rem;
  cursor: pointer;
  padding: 0 0.15rem;
  opacity: 0;
  transition: opacity var(--motion);
}
.msg:hover .quote-btn { opacity: 1; }
/* Answer actions were 15-22px targets; keep them big enough to tap. */
.msg .meta button { min-width: 2rem; min-height: 2rem; display: inline-flex; align-items: center; justify-content: center; }
.msg .quote-btn { min-width: 2rem; min-height: 2rem; }
@media (pointer: coarse) {
  .msg .meta button, .msg .quote-btn { min-width: 2.75rem; min-height: 2.75rem; }
}
.quote-btn:hover { color: var(--accent); }
.thinking-block { margin: 0 0 0.55rem; font-size: 0.875rem; }
.thinking-block summary { cursor: pointer; color: var(--ink-faint); font-weight: 600; list-style: none; }
.thinking-block summary::before { content: "▸ "; }
.thinking-block[open] summary::before { content: "▾ "; }
.thinking-text {
  white-space: pre-wrap;
  word-break: break-word;
  background: #fafbfc;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  margin: 0.4rem 0 0;
  color: var(--ink-faint);
  font-size: 0.8125rem;
  line-height: 1.55;
  max-height: 16rem;
  overflow-y: auto;
}
.dark .thinking-text { background: var(--sidebar); border-color: var(--line)}
.announce-banner {
  max-width: 52rem;
  margin: 0.75rem auto 0;
  padding: 0.6rem 0.9rem;
  background: var(--warn-bg);
  border: 1px solid #f2d9a4;
  border-radius: 10px;
  color: #7a5b13;
  font-size: 0.875rem;
}
.dark .announce-banner { border-color: var(--line-strong); color: var(--warn)}
.back-btn {
  align-self: flex-start;
  margin: 0.9rem 0 0 1.1rem;
  padding: 0.4rem 0.85rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.back-btn:hover { background: var(--hover); }
.dark .back-btn { border-color: var(--line-strong)}
/* 右上角浮层：打开积木编程 IDE（Titan IDE，独立子站，积木 → C++/Java/Python） */
.ide-link {
  position: fixed;
  top: 0.7rem;
  right: 0.9rem;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.38rem 0.8rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: #1f2328;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  transition: background var(--motion), border-color var(--motion);
}
.ide-link:hover { background: var(--hover); border-color: var(--line-strong); }
.ide-link .ide-ico { width: 1.05rem; height: 1.05rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dark .ide-link { border-color: var(--line-strong); color: var(--ink)}
@media (max-width: 640px) {
  .ide-link { top: 0.55rem; right: 0.6rem; padding: 0.32rem 0.62rem; font-size: 0.8125rem; }
}
.msg .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; min-width: 0; }
.msg .meta .meta-text { flex: 0 0 auto; white-space: nowrap; font-variant-numeric: tabular-nums; margin-right: 0.15rem; }
.msg .meta .meta-text:empty { display: none; }
.msg .meta img { width: 0.95rem; height: 0.95rem; }
.msg.ai.rendered { white-space: normal; }
/* Provider logos are black-on-transparent SVG files shown through <img> (currentColor cannot reach them): flip them on dark. */
body.dark img[src^="/static/logos/"] { filter: invert(1); }
.check { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; font-weight: 600; margin-top: 1rem; }
.menu-btn { display: none; }
.overlay { display: none; }
.dark { color: #e6e6e6; }
.dark .view { background: var(--bg)}
.dark .sidebar { border-color: var(--line)}
.dark .brand { color: var(--ink)}
.dark .mode-switch::before { box-shadow: none}
.agent-run-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  padding: 0.6rem 0.8rem;
  max-width: 46rem;
  width: 100%;
}
.agent-run-head { font-size: 0.8125rem; color: var(--ink-soft); display: flex; align-items: center; gap: 0.4rem; }
.agent-run-head svg { width: 0.95rem; height: 0.95rem; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.agent-run-card pre {
  margin: 0.45rem 0 0;
  padding: 0.55rem 0.7rem;
  background: #eef2f8;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.8125rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.agent-run-card .agent-output { background: var(--surface); border: 1px solid var(--line); }
.agent-shot { display: block; max-width: 100%; border-radius: 8px; margin-top: 0.5rem; border: 1px solid var(--line); }
.dark .agent-run-card { border-color: var(--line-strong)}
.dark .agent-run-card pre { background: var(--sidebar); color: var(--ink)}
.dark .agent-run-card .agent-output { border-color: var(--line-strong)}
.dark .side-section { border-color: var(--line)}
.dark .composer { border-color: var(--line-strong)}
.dark .composer textarea, .dark .model-btn { color: var(--ink)}
.dark .model-menu { border-color: var(--line)}
.dark .comment-form input, .dark .comment-form textarea { border-color: var(--line-strong); color: var(--ink)}
.dark .attachment-chip { background: var(--accent-wash); border-color: var(--accent)}
.dark .comment, .dark .news-content, .dark pre { background: var(--surface); border-color: var(--line); color: var(--ink)}
.dark table { border-color: var(--line); color: var(--ink)}
.dark th, .dark td { border-color: var(--line)}
.dark .greeting { color: var(--ink)}
.dark .settings-section { border-color: var(--line)}
@media (max-width: 720px) {
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 30;
    width: 16.5rem; flex-direction: column;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.12);
  }
  .sidebar.open { transform: none; }
  .menu-btn {
    display: block; position: fixed; top: 0.7rem; left: 0.7rem; z-index: 40;
    width: 2.4rem; height: 2.4rem; border: 1px solid var(--line-strong); border-radius: 10px;
    background: var(--surface); font-size: 1rem; cursor: pointer; line-height: 1;
  }
  .overlay { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, 0.25); }
  body.drawer-open .menu-btn { display: none; }
  .back-btn { margin-left: 3.6rem; }
  .dark .menu-btn { border-color: var(--line-strong); color: var(--ink)}
  .greeting { font-size: 1.25rem; }
  .messages { padding-top: 4.2rem; }
  .status-inner { padding-top: 4.2rem; }
  /* The phone top bar (menu button, Agent badge, Open IDE) floats over the page; without a surface of its own the
     answer text scrolled underneath and overlapped the icons. This strip is that surface: opaque page colour, a
     hairline under it, and a soft shadow once the content has scrolled. Buttons (z 20/40) sit above it. */
  body::before {
    content: ""; position: fixed; top: 0; left: 0; right: 0; height: 3.7rem; z-index: 18; pointer-events: none;
    background: var(--bg); border-bottom: 1px solid var(--line);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    transition: box-shadow var(--motion);
  }
  body.page-scrolled::before { box-shadow: 0 4px 14px rgba(16, 24, 40, 0.1); }
  .dark.page-scrolled::before { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45); }
}
.nickname-row { display: flex; gap: 0.5rem; margin-top: 0.4rem; }
.nickname-row input {
  width: 14rem;
  padding: 0.5rem 0.65rem;
  font: inherit;
  font-size: 0.875rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
}
.dark .nickname-row input { border-color: var(--line-strong); color: var(--ink)}
/* Language 下拉与 Nickname 输入框同一套样式 */
#lang-select, #answer-font { width: 14rem; padding: 0.5rem 0.65rem; font: inherit; font-size: 0.875rem; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink); }
.dark #lang-select, .dark #answer-font { border-color: var(--line-strong)}
.theme-grid { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 0.75rem; }
.theme-swatch {
  width: 9.5rem;
  padding: 1.2rem 0.6rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  /* The swatches are always light pastels, so the label stays dark in both themes. */
  color: #1f2328;
  border: 0;
  border-radius: 12px;
  box-shadow: 0 0 0 1px var(--line-strong);
  cursor: pointer;
}
.theme-swatch.active { box-shadow: 0 0 0 2px var(--accent); }
.hue-row { display: flex; align-items: center; gap: 0.75rem; margin-top: 1.1rem; }
.settings-section { margin-top: 1.3rem; padding-top: 1.1rem; border-top: 1px solid var(--line); }
.settings-title { margin: 0 0 0.5rem; font-size: 1rem; font-weight: 600; }
.hue-row input[type="range"] { width: 16rem; }
.hue-preview { width: 3rem; height: 1.6rem; border-radius: 8px; box-shadow: 0 0 0 1px var(--line-strong); }
/* The swatch is a very pale tint; deepen it in dark mode so it does not read as an empty white box. */
.dark .hue-preview { filter: brightness(0.5) saturate(2.5)}
main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.view { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--app-gradient); }
.view[hidden] { display: none; }
.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
  max-width: 52rem;
  margin: 0 auto;
  /* Top inset clears the fixed Open IDE pill so the first message is not covered. */
  padding: 3.4rem 1.25rem 1rem;
}
/* Group 2: a soft atmospheric wash behind the chat, layered over the
   existing white so messages still read clearly. */
.messages { background: transparent; }
/* Match the dark .view gradient (line ~653) rather than inventing a flat
   colour, so the chat surface stays in the same family as the shell. */
.dark .messages { background: linear-gradient(135deg, var(--bg) 0%, #241f2a 50%, var(--sidebar) 100%)}
/* Tactile press feedback on the primary chat controls. */
.news-btn:active, .example-chip:active { transform: translateY(1px) scale(0.98); }
.composer { transition: border-color var(--motion), box-shadow var(--motion); }
.hero { margin: auto; text-align: center; }
/* Phone Today: the chat stays in the page (so Titan brings it back) but only the home shows. */
.messages.home-peek .msg-row, .messages.home-peek .msg { display: none !important; }
.hero-icon { width: 3rem; height: 3rem; margin-bottom: 0.5rem; }
.dark .hero-icon { filter: brightness(1.6) saturate(1.15)}
.greeting { margin: 0 0 1rem; color: #2f3338; font-family: var(--font-display); font-size: 1.75rem; font-weight: 500; letter-spacing: var(--ls-display); line-height: 1.15; }
.hero > * { animation: hero-in 0.5s ease-out both; }
@keyframes hero-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .hero > * { animation: none; } }
/* Empty state: greeting, input and suggestions form one column. The hero
   wrapper is flattened so the input sits right under the greeting and the
   suggestion chips drop below it. Once the chat starts, hero is hidden and
   the normal layout (input pinned to the bottom) comes back. */
#chat-view:has(.hero:not([hidden])) .messages,
#chat-view:has(.hero:not([hidden])) .hero { display: contents; }
#chat-view:has(.hero:not([hidden])) .greeting,
#chat-view:has(.hero:not([hidden])) .news-buttons,
#chat-view:has(.hero:not([hidden])) .example-chips,
#chat-view:has(.hero:not([hidden])) .composer-wrap { box-sizing: border-box; width: 100%; max-width: 52rem; margin-inline: auto; padding-inline: 1.25rem; }
#chat-view:has(.hero:not([hidden])) .hero-icon { order: 1; align-self: center; margin: auto 0 0.5rem; }
#chat-view:has(.hero:not([hidden])) .greeting { order: 2; }
#chat-view:has(.hero:not([hidden])) .review-chip { order: 2; align-self: center; margin: -0.35rem auto 0.25rem; }
#chat-view:has(.hero:not([hidden])) .jump-card { order: 2; align-self: center; margin: 0.1rem auto 0.25rem; }
#chat-view:has(.hero:not([hidden])) .composer-wrap { order: 3; padding-top: 0.9rem; }
#chat-view:has(.hero:not([hidden])) .news-buttons { order: 4; margin-top: 0.9rem; }
#chat-view:has(.hero:not([hidden])) .example-chips { order: 5; margin: 0.7rem auto auto; }
.news-buttons { display: flex; flex-wrap: wrap; gap: 0.55rem; justify-content: center; }
.news-buttons[hidden] { display: none; }
/* One suggestion chip style for both rows (news topics and example prompts): quiet outline, ink text, 40px tall. */
.example-chips { display: flex; flex-wrap: wrap; gap: 0.45rem; justify-content: center; margin-top: 0.85rem; }
.news-btn,
.example-chip {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0 0.95rem;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  cursor: pointer;
  box-shadow: none;
  transition: color var(--motion), border-color var(--motion), background-color var(--motion);
}
.news-btn:hover,
.example-chip:hover { color: var(--accent); border-color: var(--line-strong); background: var(--surface); }
.dark .news-btn,
.dark .example-chip { border-color: var(--line-strong)}
.msg-row { display: flex; align-items: flex-start; gap: 0.5rem; width: 100%; animation: msg-in 0.14s ease-out; }
.msg-row.user { justify-content: flex-end; }
.msg-row.ai { justify-content: flex-start; }
.msg-avatar {
  flex-shrink: 0;
  width: 1.9rem;
  height: 1.9rem;
  margin-top: 0.15rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line);
  font-size: 0.875rem;
  color: var(--accent);
}
.msg-avatar img { width: 100%; height: 100%; display: block; }
.msg-avatar.titan svg { width: 1.15rem; height: 1.15rem; display: block; }
.dark .msg-avatar.titan { color: var(--accent)}
@keyframes msg-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .msg-row { animation: none; } }
.stream-live .body::after {
  content: "▍";
  margin-left: 0.12rem;
  color: var(--accent);
  animation: caret-blink 1s steps(2, start) infinite;
}
@keyframes caret-blink { to { visibility: hidden; } }
.msg {
  max-width: 82%;
  padding: 0.65rem 0.9rem;
  border-radius: 16px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.875rem;
  line-height: 1.55;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  position: relative;
}
.msg.user { align-self: flex-end; background: var(--accent-wash); border-bottom-right-radius: 6px; }
.msg.ai { align-self: flex-start; background: var(--surface-soft); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
/* Answers read like typeset text, not a chat bubble; agent cards and the thinking dots keep theirs. */
body:not(.dark) .msg.ai:not(.agent-run-card):not(.thinking) { background: transparent; border: 0; box-shadow: none; padding-inline: 0; }
.msg .meta { margin-top: 0.35rem; font-size: 0.8125rem; color: var(--ink-faint); }
/* AI answers use the reader-chosen face; meta line, buttons and agent cards keep the UI font. */
.msg.ai:not(.agent-run-card):not(.thinking) .body { font-family: var(--font-answer); font-size: var(--answer-size); line-height: var(--answer-lh); }
.msg.ai:not(.agent-run-card):not(.thinking) .body h2 { font-size: 1.25em; }
.msg.ai:not(.agent-run-card):not(.thinking) .body h3, .msg.ai:not(.agent-run-card):not(.thinking) .body h4 { font-size: 1.1em; }
.msg.ai .body pre, .msg.ai .body code { font-family: var(--font-mono); }
.msg.ai .body pre code { font-size: 0.85em; }
html[data-answer-font="gpt"] { --font-answer: "Geist", "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif; --answer-size: 0.97rem; --answer-lh: 1.65; }
html[data-answer-font="kimi"] { --font-answer: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", sans-serif; --answer-size: 0.97rem; --answer-lh: 1.7; }
.composer-wrap { width: 100%; max-width: 52rem; margin: 0 auto; padding: 0 1.25rem 1.1rem; }
.composer {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0.55rem 0.55rem;
  padding: 0.75rem 0.85rem 0.75rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 26px;
  box-shadow: 0 2px 10px rgba(16, 24, 40, 0.06);
  transition: border-color var(--motion), box-shadow var(--motion);
}
.composer:focus-within { border-color: #a9c0f5; box-shadow: 0 2px 14px rgba(43, 79, 216, 0.14); }
.composer textarea {
  /* Input gets its own full-width row so toolbar controls can never squeeze it. */
  flex: 1 1 100%;
  order: -1;
  min-width: 0;
  width: 100%;
  border: 0;
  outline: none;
  resize: none;
  font: inherit;
  font-size: 1rem;
  line-height: 1.5;
  background: transparent;
  min-height: 3.5rem;
  max-height: 14rem;
  overflow-y: auto;
}
.composer #generate-button {
  flex-shrink: 0;
  padding: 0.6rem 1.15rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent-fill);
  border: 0;
  border-radius: var(--r-control);
  min-height: var(--btn-md);
  cursor: pointer;
  transition: background-color var(--motion), transform var(--motion);
}
.composer #generate-button:disabled { opacity: 0.55; cursor: default; }
.composer #generate-button:active:not(:disabled) { transform: scale(0.96); }
.composer #generate-button:hover:not(:disabled) { background: var(--accent-fill-hover); }
.composer #generate-button.stopping { background: #c0392b; }
.composer #generate-button.stopping:hover { background: #a93226; }
/* Narrow screens: toolbar row wraps under the input instead of squeezing it. */
@media (max-width: 620px) {
  .composer { align-items: stretch; }
  .composer .persona-select { max-width: none; }
  .composer #generate-button { width: 100%; padding: 0.65rem 1.15rem; }
}
.messages::-webkit-scrollbar, .sidebar::-webkit-scrollbar, .model-menu::-webkit-scrollbar, .side-chats::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb, .sidebar::-webkit-scrollbar-thumb, .model-menu::-webkit-scrollbar-thumb, .side-chats::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.14); border-radius: 4px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.model-row { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.6rem; font-size: 0.875rem; color: var(--ink-faint); }
.model-row select {
  padding: 0.35rem 0.5rem;
  font: inherit;
  font-size: 0.875rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  max-width: 24rem;
}
.note { margin: 0.55rem 0 0; color: var(--ink-faint); font-size: 0.8125rem; }
.note a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.assignment-card, .upgrade-card { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin: 0 0 0.6rem; padding: 0.7rem 0.85rem; border-radius: var(--radius-md); }
.assignment-card { background: #f6f2ff; border: 1px solid #ddd3fb; }
.ac-main { display: grid; gap: 0.1rem; min-width: 0; flex: 1 1 14rem; }
.ac-label { font-size: var(--fs-label); letter-spacing: var(--ls-label); text-transform: uppercase; color: #5b3fc4; font-weight: 600; }
.ac-title { font-size: var(--fs-body); color: var(--ink); overflow-wrap: anywhere; }
.ac-sub { font-size: var(--fs-small); color: var(--ink-faint); }
.ac-sub.overdue { color: var(--danger); font-weight: 600; }
.ac-actions { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.ac-link, .ac-btn { font: inherit; font-size: var(--fs-small); font-weight: 600; border-radius: 999px; padding: 0.35rem 0.8rem; min-height: 2.25rem; display: inline-flex; align-items: center; cursor: pointer; text-decoration: none; }
.ac-link { color: #5b3fc4; border: 1px solid #ddd3fb; background: var(--surface); }
.ac-btn { color: #fff; background: var(--accent-fill); border: 0; }
.ac-btn:disabled { opacity: 0.6; cursor: default; }
.ac-close { border: 0; background: transparent; color: var(--ink-faint); font-size: 1.25rem; width: 2.25rem; height: 2.25rem; border-radius: 8px; cursor: pointer; }
.ac-close:hover { background: rgba(0,0,0,0.05); }
.dark .assignment-card { background: #241f38; border-color: #3d3366}
.dark .ac-label, .dark .ac-link { color: #c9bbff}
.dark .ac-link { border-color: #3d3366}
.upgrade-card { background: var(--accent-wash); border: 1px solid #c9d4f6; color: var(--ink-soft); font-size: var(--fs-small); }
.upgrade-card > span { flex: 1 1 14rem; }
.uc-actions { display: flex; gap: 0.4rem; align-items: center; }
.uc-cta { background: var(--accent-fill); color: #fff; border-radius: 999px; padding: 0.35rem 0.9rem; font-weight: 600; text-decoration: none; min-height: 2.25rem; display: inline-flex; align-items: center; }
.uc-dismiss { border: 0; background: transparent; color: var(--ink-faint); font: inherit; font-size: var(--fs-small); cursor: pointer; min-height: 2.25rem; padding: 0 0.5rem; }
.dark .upgrade-card { border-color: #33406b}
/* Study cards (static/study.js): quiz questions, worked steps, mistake book. */
.study-pending { color: var(--ink-faint); font-size: var(--fs-small); animation: allowance-pulse 1.2s infinite ease-in-out; }
.qz, .st { display: grid; gap: 0.6rem; margin: 0.35rem 0; max-width: 36rem; }
.qz-q { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 0.9rem; display: grid; gap: 0.7rem; }
.qz-head { display: flex; align-items: center; gap: 0.6rem; font-size: var(--fs-small); color: var(--ink-faint); }
.qz-where { min-width: 0; overflow-wrap: anywhere; }
.qz-report { margin-left: auto; font: inherit; font-size: var(--fs-small); border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft); border-radius: 999px; padding: 0.2rem 0.7rem; min-height: 2rem; cursor: pointer; white-space: nowrap; }
.qz-report:hover:not(:disabled) { border-color: #c2410c; color: var(--warn); }
.qz-report:disabled { opacity: 0.7; cursor: default; }
.qz-head .qz-progress { flex: 0 0 auto; }
.qz-progress { display: flex; gap: 3px; margin-left: auto; flex: 0 1 auto; min-width: 0; max-width: 60%; }
.qz-progress i { flex: 0 1 1.1rem; min-width: 3px; height: 4px; border-radius: 2px; background: var(--line); }
.qz-progress i.now { background: var(--accent-fill); }
.qz-progress i.ok { background: var(--ok); }
.qz-progress i.no { background: var(--danger); }
.qz-progress i.soon { animation: allowance-pulse 1.2s infinite ease-in-out; }
.qz-wait .qz-progress { margin: 0 0 0.6rem; max-width: none; }
.qz-summary .qz-progress { margin-left: 0; }
.qz-text { color: var(--ink); overflow-wrap: anywhere; }
.qz-text p { margin: 0 0 0.3rem; }
.qz-opts { display: grid; gap: 0.4rem; }
.qz-opt { display: flex; align-items: center; gap: 0.6rem; width: 100%; text-align: left; font: inherit; font-size: var(--fs-body); color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0.5rem 0.65rem; min-height: 2.75rem; cursor: pointer; transition: border-color var(--motion), background var(--motion); }
.qz-opt:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-wash); }
.qz-opt:disabled { cursor: default; }
.qz-opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.qz-key { width: 1.5rem; height: 1.5rem; border-radius: 7px; border: 1px solid var(--line); display: grid; place-items: center; font-size: 0.8125rem; font-weight: 600; color: var(--ink-faint); flex: none; }
.qz-label { min-width: 0; overflow-wrap: anywhere; }
.qz-tag { margin-left: auto; font-size: 0.8125rem; font-weight: 600; white-space: nowrap; }
.qz-opt.picked { border-color: var(--accent); }
.qz-opt.right { border-color: var(--ok); background: var(--ok-bg); }
.qz-opt.right .qz-key { background: var(--ok); border-color: transparent; color: #fff; }
.qz-opt.right .qz-tag { color: var(--ok); }
.qz-opt.wrong { border-color: var(--danger); background: var(--danger-bg); }
.qz-opt.wrong .qz-key { background: var(--danger); border-color: transparent; color: #fff; }
.qz-opt.wrong .qz-tag { color: var(--danger); }
.qz-after { display: grid; gap: 0.5rem; }
.qz-verdict { margin: 0; font-weight: 600; font-size: var(--fs-small); }
.qz-verdict.ok { color: var(--ok); }
.qz-verdict.no { color: var(--danger); }
.qz-why { background: var(--warn-bg); border-radius: 10px; padding: 0.55rem 0.7rem; font-size: var(--fs-small); color: var(--ink-soft); }
.qz-why p { margin: 0; }
.qz-foot { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }
.qz-saved { margin-right: auto; font-size: 0.8125rem; color: var(--ink-faint); }
.qz-btn { font: inherit; font-size: var(--fs-small); font-weight: 600; border-radius: 999px; padding: 0.35rem 0.95rem; min-height: 2.25rem; display: inline-flex; align-items: center; cursor: pointer; border: 0; background: var(--accent-fill); color: #fff; text-decoration: none; }
.qz-btn:hover { background: var(--accent-fill-hover); }
/* Buttons inside an answer are UI, not prose: they must not pick up the reader's serif answer face from .body. */
.msg .body button, .msg .body .qz-btn, .msg .body [class^="qz-"], .msg .body [class^="st-"], .msg .body [class^="sp-"] { font-family: var(--font-sans); }
.qz-btn.ghost { background: var(--surface); color: var(--ink-soft); border: 1px solid var(--line); font-weight: 500; }
.qz-btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.qz-error { margin: 0; color: var(--danger); font-size: var(--fs-small); }
.qz-limit { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; background: var(--accent-wash); border-radius: 10px; padding: 0.55rem 0.7rem; font-size: var(--fs-small); color: var(--ink-soft); }
.qz-limit span { flex: 1 1 12rem; }
.qz-score { font-family: var(--font-display); font-size: 1.75rem; font-weight: 600; letter-spacing: var(--ls-display); color: var(--ink); }
.qz-note { margin: 0; color: var(--ink-soft); font-size: var(--fs-small); }
.qz-fallback, .st-fallback { overflow-wrap: anywhere; }
.st-problem, .st-answer { display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0.55rem 0.75rem; }
.st-answer { border-color: var(--ok); background: var(--ok-bg); }
.st-label { font-size: var(--fs-label); letter-spacing: var(--ls-label); text-transform: uppercase; font-weight: 600; color: var(--ink-faint); flex: none; }
.st-answer .st-label { color: var(--ok); }
.st-problem-text, .st-answer-text { min-width: 0; overflow-wrap: anywhere; color: var(--ink); }
.st-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.st-step { display: grid; grid-template-columns: 1.7rem minmax(0, 1fr); gap: 0.6rem; align-items: start; }
.st-num { width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--accent-fill); color: #fff; font-size: 0.8125rem; font-weight: 700; display: grid; place-items: center; }
.st-step.done .st-num { background: var(--ok); }
.st-step.locked .st-num { background: var(--line); color: var(--ink-faint); }
.st-body { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 0.6rem 0.75rem; display: grid; gap: 0.4rem; min-width: 0; }
.st-step.locked .st-body { background: transparent; border-style: dashed; }
.st-title { font-weight: 600; color: var(--ink); }
.st-step.locked .st-title { color: var(--ink-faint); }
.st-content { overflow-x: auto; color: var(--ink-soft); }
.st-content p { margin: 0 0 0.25rem; }
.st-actions { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }
.st-actions:empty { display: none; }
.st-hint { font-size: 0.8125rem; color: var(--ink-faint); margin-right: auto; }
.st-link, .st-expand { font: inherit; font-size: 0.8125rem; color: var(--accent); background: transparent; border: 0; padding: 0.2rem 0; cursor: pointer; min-height: 2rem; justify-self: start; }
.st-link:hover, .st-expand:hover { text-decoration: underline; }
.side-badge { margin-left: auto; min-width: 1.2rem; height: 1.2rem; padding: 0 0.35rem; border-radius: 999px; background: var(--accent-fill); color: #fff; font-size: 0.6875rem; font-weight: 600; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; }
.review-chip { font: inherit; font-size: var(--fs-small); font-weight: 600; color: #5b3fc4; background: #f6f2ff; border: 1px solid #ddd3fb; border-radius: 999px; padding: 0.35rem 0.95rem; min-height: 2.25rem; cursor: pointer; margin: 0.2rem 0 0.4rem; }
.review-chip:hover { background: #ebe4ff; }
.jump-card { display: flex; align-items: center; gap: 0.75rem; box-sizing: border-box; width: 100%; max-width: 30rem; margin: 0.2rem auto 0.5rem; padding: 0.7rem 0.95rem; font: inherit; text-align: left; color: #3b2a00; background: linear-gradient(135deg, #fff6d8, #ffe9b0); border: 1px solid #f1d98f; border-radius: 16px; cursor: pointer; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05); transition: box-shadow var(--motion), transform var(--motion); }
.jump-card[hidden] { display: none; }
.launchpad { box-sizing: border-box; display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; width: 100%; max-width: 34rem; margin: 0.2rem auto 0.6rem; text-align: left; }
.launch-tile { display: flex; align-items: center; gap: 0.7rem; min-width: 0; padding: 0.75rem 0.9rem; color: var(--ink, var(--ink)); text-decoration: none; background: var(--surface, var(--surface)); border: 1px solid var(--line, var(--line)); border-radius: 16px; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05); transition: box-shadow var(--motion), transform var(--motion), border-color var(--motion); }
.launch-tile:hover { box-shadow: 0 5px 16px rgba(16, 24, 40, 0.12); transform: translateY(-1px); }
.launch-tile:focus-visible { outline: 3px solid #9bb0f5; outline-offset: 2px; }
.launch-ico { flex: none; width: 1.55rem; height: 1.55rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.launch-text { display: grid; gap: 0.1rem; min-width: 0; flex: 1; }
.launch-title { font-weight: 700; font-size: var(--fs-body); line-height: 1.25; }
.launch-desc { font-size: var(--fs-small); line-height: 1.35; color: var(--ink-faint, #6b6b6b); }
.launch-go { flex: none; width: 1.1rem; height: 1.1rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: 0.6; }
.launch-tile.primary { grid-column: 1 / -1; padding: 0.95rem 1.1rem; color: #fff; border: 0; background: radial-gradient(420px 200px at 100% -40%, rgba(255, 255, 255, 0.22), transparent 62%), linear-gradient(125deg, #3a5fe6 0%, var(--accent-fill) 50%, #1c3590 100%); box-shadow: 0 2px 4px rgba(28, 53, 144, 0.14), 0 12px 30px rgba(28, 53, 144, 0.22); }
.launch-tile.primary:hover { box-shadow: 0 2px 4px rgba(28, 53, 144, 0.16), 0 16px 38px rgba(28, 53, 144, 0.3); }
.launch-tile.primary .launch-ico { width: 2rem; height: 2rem; }
.launch-tile.primary .launch-title { font-size: 1rem; font-weight: 800; }
.launch-tile.primary .launch-desc { color: #d6defa; }
.launch-tile.primary .launch-go { opacity: 0.9; }
.dark .launch-tile:not(.primary) { background: var(--surface); border-color: var(--line-strong); color: var(--ink)}
.dark .launch-tile:not(.primary) .launch-desc { color: var(--ink-faint)}
#chat-view:has(.hero:not([hidden])) .launchpad { order: 2; align-self: center; }
.jump-card:hover { box-shadow: 0 5px 16px rgba(16, 24, 40, 0.12); transform: translateY(-1px); }
/* The gamepad symbol is a stroke icon: without fill: none it rendered as a solid black block. */
.jump-card-ico { flex-shrink: 0; width: 1.75rem; height: 1.75rem; color: var(--accent); fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.jump-card-text { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.jump-card-title { font-weight: 700; font-size: var(--fs-body); }
.jump-card-tiers { display: flex; flex-wrap: wrap; gap: 0.3rem 0.5rem; font-size: var(--fs-small); color: #6b5410; }
.jump-card-tiers .done { text-decoration: line-through; opacity: 0.65; }
#review-root { display: grid; gap: 1rem; max-width: 40rem; }
.rv-head h2 { margin: 0; }
.rv-head .note { margin: 0.2rem 0 0; }
.rv-body { display: grid; gap: 0.9rem; }
.rv-empty, .rv-today { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 1rem; display: grid; gap: 0.7rem; justify-items: start; }
.rv-empty p { margin: 0; color: var(--ink-soft); }
.rv-big { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.rv-big b { font-family: var(--font-display); font-size: 1.75rem; font-weight: 600; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.rv-big span { color: var(--ink-soft); font-size: var(--fs-small); }
.rv-left { margin: 0; font-size: 0.8125rem; color: var(--ink-faint); }
.rv-sprint { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; background: var(--danger-bg); border: 1px solid #f2cdc5; border-radius: 14px; padding: 0.7rem 0.85rem; }
.rv-sprint-info { display: grid; min-width: 0; flex: 1 1 14rem; }
.rv-sprint-info b { color: var(--ink); overflow-wrap: anywhere; }
.rv-sprint-info span { font-size: var(--fs-small); color: var(--danger); }
.rv-section { display: grid; gap: 0.55rem; }
.rv-section h3 { margin: 0; font-size: var(--fs-label); letter-spacing: var(--ls-label); text-transform: uppercase; color: var(--ink-faint); font-weight: 600; }
.rv-topic { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.2rem 0.6rem; font-size: var(--fs-small); }
.rv-topic-name { color: var(--ink); overflow-wrap: anywhere; }
.rv-pct { color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.rv-bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.rv-bar i { display: block; height: 100%; border-radius: 3px; }
.rv-bar i.good { background: var(--ok); }
.rv-bar i.mid { background: #d4a72c; }
.rv-bar i.low { background: var(--danger); }
.rv-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.rv-list li { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0.55rem 0.75rem; display: grid; gap: 0.15rem; }
.rv-list li.mastered { opacity: 0.65; }
.rv-q { color: var(--ink); overflow-wrap: anywhere; }
.rv-q p { margin: 0; }
.rv-meta { font-size: 0.8125rem; color: var(--ink-faint); }
.rv-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0 0.9rem; }
.rv-actions .st-link:disabled { opacity: 0.5; cursor: default; text-decoration: none; }
.rv-actions-note { font-size: 0.8125rem; color: var(--danger); }
.rv-tip { margin: 0; }
.rv-session-top { display: flex; align-items: center; gap: 0.75rem; justify-content: space-between; flex-wrap: wrap; }
.dark .qz-q, .dark .qz-opt, .dark .st-body, .dark .st-problem, .dark .rv-empty, .dark .rv-today, .dark .rv-list li, .dark .qz-btn.ghost, .dark .qz-report { border-color: var(--line); color: var(--ink)}
.dark .qz-key { border-color: var(--line-strong)}
.dark .qz-progress i:not([class]), .dark .rv-bar { background: var(--chip-hover)}
.dark .review-chip { background: #241f38; border-color: #3d3366; color: #c9bbff}
.dark .jump-card { background: linear-gradient(135deg, var(--warn-bg), var(--warn-bg)); border-color: #5b4f1f; color: var(--warn)}
.dark .jump-card-tiers { color: var(--warn)}
/* Desktop home: the Jump Jump challenge is a slim pill in the top bar, level with Open IDE, and the family
   entries share one row, so the middle keeps only the greeting, the input and the suggestions. */
@media (min-width: 721px) {
  .jump-card { position: fixed; top: 0.7rem; left: 18.5rem; z-index: 20; width: auto; max-width: calc(100vw - var(--ide-w, 7.2rem) - 21rem); margin: 0; padding: 0.38rem 0.8rem; gap: 0.5rem; border-radius: 999px; animation: none; }
  .jump-card:hover { transform: none; }
  .jump-card-ico { width: 1rem; height: 1rem; }
  .jump-card-text { flex-direction: row; align-items: baseline; gap: 0.65rem; min-width: 0; }
  .jump-card-title { font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .jump-card-tiers { flex-wrap: nowrap; gap: 0.5rem; white-space: nowrap; font-size: 0.8125rem; }
  .launchpad { grid-template-columns: 2fr 1fr; max-width: 36rem; margin-bottom: 0.9rem; }
  .launch-tile { padding: 0.7rem 0.9rem; }
  .launch-tile.primary { grid-column: auto; padding: 0.7rem 1rem; }
  .launch-tile.primary .launch-ico { width: 1.6rem; height: 1.6rem; }
  .launch-tile.primary .launch-title { font-size: 1rem; }
  #launch-ide { display: none; }
  #chat-view:has(.hero:not([hidden])) .news-buttons { gap: 0.4rem; margin-top: 0.7rem; }
  #chat-view:has(.hero:not([hidden])) .example-chips { margin-top: 0.5rem; }
}
/* The challenge is a small badge everywhere: just its name; the milestones are in its tooltip and on the game screen. */
.jump-card-tiers { display: none; }
@media (max-width: 720px) {
  #chat-view:has(.hero:not([hidden])) .jump-card { align-self: flex-start; width: auto; padding: 0.4rem 0.85rem; gap: 0.5rem; border-radius: 999px; }
  #chat-view:has(.hero:not([hidden])) .jump-card-ico { width: 1rem; height: 1rem; }
  #chat-view:has(.hero:not([hidden])) .jump-card-title { font-size: 0.875rem; font-weight: 600; }
}
.dark .rv-sprint { border-color: #5c2e25}
.msg .meta button.tutor-reveal { margin-left: 0.4rem; border: 1px solid #ddd3fb; background: #f6f2ff; color: #5b3fc4; border-radius: 999px; font-size: 0.8125rem; font-weight: 600; padding: 0.15rem 0.7rem; min-height: 2rem; }
.msg .meta button.tutor-reveal:hover { background: #ebe4ff; color: #4a2fb0; }
.dark .msg .meta button.tutor-reveal { background: #241f38; border-color: #3d3366; color: #c9bbff}
.error-note[data-tone="neutral"] { color: var(--ink-soft); background: var(--chip); }
.msg .meta button.stop-action { margin-left: 0.25rem; padding: 0.15rem 0.7rem; min-height: 2rem; font-size: 0.8125rem; font-weight: 600; color: var(--ink-soft); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px; }
.msg .meta button.stop-action:hover { color: var(--accent); border-color: var(--accent); }
.error-note { color: var(--danger); background: var(--danger-bg); border-radius: 8px; padding: 0.5rem 0.65rem; margin: 0.55rem 0 0; font-size: 0.875rem; }
/* Remaining-today count sits in the composer's bottom-right corner. */
.allowance-count { align-self: center; padding: 0 0.3rem; font-size: var(--fs-label); color: var(--ink-faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.allowance-count.is-loading { animation: allowance-pulse 1.2s infinite ease-in-out; }
@keyframes allowance-pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
.status-inner { width: 100%; max-width: 46rem; margin: 0 auto; padding: 2rem 1.25rem; overflow-y: auto; }
.status-inner h2 { margin: 0 0 0.75rem; font-size: 1.25rem; font-weight: 600; }
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid #ddd; border-radius: 8px; overflow: hidden; }
th, td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid #eee; font-size: 0.875rem; }
th { background: var(--surface-soft); font-weight: 600; }
tr:last-child td { border-bottom: none; }
.pill { display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.8125rem; background: #eee; color: var(--ink-soft); }
.pill.ok { background: #e6f6ec; color: #1b7a3d; }
.pill.bad { background: var(--danger-bg); color: var(--danger); }
.status-inner button:not(.avatar-choice):not(.theme-swatch):not(.auth-tab):not(.game-card):not([class^="qz-"]):not([class^="st-"]):not([class^="sp-"]) {
  margin-top: 0.85rem;
  padding: 0.5rem 0.9rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent-fill);
  border: 0;
  border-radius: var(--r-control);
  cursor: pointer;
}
.status-inner button:disabled:not([class^="qz-"]) { opacity: 0.55; cursor: default; }
/* Class spaces (static/spaces.js) */
#space-root { display: grid; gap: 1rem; max-width: 40rem; align-content: start; }
#space-root h2 { margin: 0; }
#space-root h3 { margin: 0; font-size: var(--fs-label); letter-spacing: var(--ls-label); text-transform: uppercase; color: var(--ink-faint); font-weight: 600; }
#space-root ul { list-style: none; margin: 0; padding: 0; }
.sp-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.sp-titles { min-width: 0; }
.sp-titles .note { margin: 0.2rem 0 0; }
.sp-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.sp-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 1rem; display: grid; gap: 0.7rem; justify-items: start; }
.sp-card > * { max-width: 100%; }
.sp-card .note, .sp-card p { margin: 0; }
.sp-btn { font: inherit; font-size: var(--fs-small); font-weight: 600; border-radius: 999px; padding: 0.35rem 0.95rem; min-height: 2.25rem; display: inline-flex; align-items: center; cursor: pointer; border: 0; background: var(--accent-fill); color: #fff; text-decoration: none; }
.sp-btn:hover:not(:disabled) { background: var(--accent-fill-hover); }
.sp-btn:disabled { opacity: 0.55; cursor: default; }
.sp-btn.ghost { background: var(--surface); color: var(--ink-soft); border: 1px solid var(--line); font-weight: 500; }
.sp-btn.ghost:hover:not(:disabled) { background: var(--surface); border-color: var(--accent); color: var(--accent); }
.sp-btn.ghost.danger:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); }
.sp-link { color: var(--accent); font-weight: 600; font-size: var(--fs-small); }
.sp-usage { font-size: 0.8125rem; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.sp-drop { width: 100%; display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; border: 1.5px dashed var(--line); border-radius: 12px; padding: 0.8rem 0.9rem; color: var(--ink-soft); font-size: var(--fs-small); }
.sp-drop.over { border-color: var(--accent); background: var(--accent-wash); }
.sp-files, .sp-uploads, .sp-chats, .sp-courses { width: 100%; display: grid; gap: 0.4rem; }
.sp-file { display: flex; align-items: center; gap: 0.5rem; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 10px; padding: 0.45rem 0.7rem; }
.sp-file-text { display: grid; min-width: 0; flex: 1; }
.sp-file-text b { overflow-wrap: anywhere; font-weight: 600; color: var(--ink); }
.sp-file-text span, .sp-none { font-size: 0.8125rem; color: var(--ink-faint); }
.sp-x { flex-shrink: 0; border: 0; background: transparent; color: var(--ink-faint); cursor: pointer; font-size: 1rem; line-height: 1; padding: 0.25rem 0.5rem; border-radius: 6px; min-width: 2rem; min-height: 2rem; }
.sp-x:hover { background: var(--hover); color: var(--danger); }
.sp-upload { font-size: 0.8125rem; color: var(--ink-soft); display: flex; gap: 0.5rem; justify-content: space-between; }
.sp-upload.done span { color: var(--ok); }
.sp-upload.bad { color: var(--danger); }
.sp-chat { width: 100%; text-align: left; font: inherit; font-size: var(--fs-small); color: var(--ink); background: var(--surface-soft); border: 1px solid var(--line); border-radius: 10px; padding: 0.5rem 0.7rem; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-chat:hover { border-color: var(--accent); }
.sp-form { width: 100%; display: grid; gap: 0.5rem; }
.sp-form input[type="text"] { font: inherit; font-size: var(--fs-small); padding: 0.5rem 0.7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); min-height: 2.5rem; }
.sp-form .sp-btn { justify-self: start; }
.sp-import { width: 100%; display: grid; gap: 0.6rem; justify-items: start; }
.sp-course { display: flex; align-items: center; gap: 0.6rem; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 10px; padding: 0.5rem 0.7rem; cursor: pointer; }
.sp-course input { width: 1.1rem; height: 1.1rem; flex-shrink: 0; }
.sp-course-text { display: grid; min-width: 0; flex: 1; }
.sp-course-text b { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.sp-course-text span { font-size: 0.8125rem; color: var(--ink-faint); }
.sp-tag { font-size: 0.8125rem; color: var(--ok); background: var(--ok-bg); border-radius: 999px; padding: 0.1rem 0.55rem; white-space: nowrap; }
.space-item.active { background: var(--accent-wash); color: var(--accent); font-weight: 600; }
.space-item { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.space-add { color: var(--ink-faint); font-size: 0.875rem; }
.space-chip { background: #eefaf3; border-color: #bfe6cf; color: var(--ok); }
.msg .sp-ref { border: 0; background: var(--accent-wash); color: var(--accent); font: inherit; font-size: 0.6875rem; font-weight: 700; line-height: 1; min-width: 1.15rem; height: 1.15rem; padding: 0 0.25rem; border-radius: 999px; margin: 0 0.12rem; vertical-align: 0.15em; cursor: pointer; }
.msg .sp-ref:hover { background: var(--accent-fill); color: #fff; }
.sp-sources { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.sp-chip { font: inherit; font-size: 0.8125rem; color: var(--accent); background: var(--accent-wash); border: 0; border-radius: 999px; padding: 0.2rem 0.65rem; cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-chip:hover { background: var(--accent-fill); color: #fff; }
.sp-pop-overlay { position: fixed; inset: 0; z-index: 60; background: rgba(16, 24, 40, 0.4); display: grid; place-items: center; padding: 1rem; }
.sp-pop { width: min(32rem, 100%); max-height: 80vh; overflow: auto; background: var(--surface); color: var(--ink); border-radius: 16px; box-shadow: var(--shadow-float); padding: 1rem 1.1rem; display: grid; gap: 0.7rem; }
.sp-pop-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.sp-pop-head b { overflow-wrap: anywhere; }
.sp-pop-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-small); line-height: 1.6; background: var(--gold-wash, var(--warn-bg)); border-radius: 10px; padding: 0.7rem 0.8rem; color: #3d3a2a; }
.sp-mx-body { width: 100%; display: grid; gap: 0.7rem; justify-items: start; }
.sp-mx-body > * { max-width: 100%; margin: 0; }
.sp-mx-stats { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; font-size: var(--fs-small); color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.sp-mx-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.sp-mx-label { font-size: var(--fs-label); letter-spacing: var(--ls-label); text-transform: uppercase; color: var(--ink-faint); font-weight: 600; }
.sp-mx-topics { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; margin: 0; padding: 0; }
.sp-mx-topics li { font-size: 0.8125rem; background: var(--danger-bg); color: var(--danger); border-radius: 999px; padding: 0.15rem 0.65rem; overflow-wrap: anywhere; }
.sp-mx-list { width: 100%; list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.sp-mx-list li { background: var(--surface-soft); border: 1px solid var(--line); border-radius: 10px; padding: 0.5rem 0.7rem; display: grid; gap: 0.1rem; min-width: 0; }
.sp-mx-list li.mastered { opacity: 0.65; }
.sp-mx-q { font-size: var(--fs-small); color: var(--ink); overflow-wrap: anywhere; }
.sp-mx-meta { font-size: 0.8125rem; color: var(--ink-faint); }
.rv-scope { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; font-size: var(--fs-small); color: var(--ink-soft); }
.rv-scope b { color: var(--ink); overflow-wrap: anywhere; }
@media (max-width: 620px) { .sp-mx-actions .sp-btn { flex: 1 1 100%; justify-content: center; } }
.dark .sp-mx-list li { border-color: var(--line)}
.dark .sp-card, .dark .sp-pop { border-color: var(--line); color: var(--ink)}
.dark .sp-btn.ghost, .dark .sp-chat, .dark .sp-form input[type="text"] { border-color: var(--line)}
.dark .sp-file, .dark .sp-course, .dark .sp-chat { border-color: var(--line)}
.dark .sp-file-text b, .dark .sp-course-text b, .dark .sp-pop-head b { color: var(--ink)}
.dark .space-chip { background: var(--ok-bg); border-color: #3f8f63}
.dark .sp-pop-text { color: var(--warn)}
.dark .sp-drop { border-color: var(--line-strong)}
.dark .sp-usage, .dark .sp-file-text span, .dark .sp-none, .dark .sp-course-text span, .dark #space-root h3, .dark .sp-card .note { color: var(--ink-faint)}
/* Agent's "Set up" / "Connect" note sits clear of the input's border (its pill used to touch it). */
#bridge-note, #humanizer-note { margin: 0 0 0.6rem; line-height: 1.7; }
#bridge-note button {
  margin-left: 0.5rem;
  padding: 0.2rem 0.7rem;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent-fill);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 20, 30, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.modal-card {
  width: 100%;
  max-width: 34rem;
  background: var(--surface);
  border-radius: 16px;
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow-float);
}
.dark .modal-card { color: var(--ink)}
.terms-card { max-height: calc(100vh - 2.5rem); overflow-y: auto; }
.terms-body { display: grid; gap: 0.65rem; margin: 0.6rem 0 0.9rem; font-size: 0.875rem; line-height: 1.65; }
.terms-body p { margin: 0; }
.terms-agree { display: flex; align-items: flex-start; gap: 0.55rem; font-size: 0.875rem; font-weight: 600; cursor: pointer; }
.terms-agree input { margin-top: 0.2rem; width: 1.05rem; height: 1.05rem; flex-shrink: 0; }
.terms-error { margin: 0.6rem 0 0; font-size: 0.875rem; color: var(--danger); }
.terms-actions { display: flex; justify-content: flex-end; align-items: center; gap: 0.75rem; margin-top: 1rem; }
.terms-decline { background: none; border: 0; font: inherit; font-size: 0.875rem; color: inherit; opacity: 0.7; cursor: pointer; text-decoration: underline; }
.terms-accept { border: 0; border-radius: 8px; padding: 0.5rem 1rem; font: inherit; font-weight: 600; color: #fff; background: var(--accent-fill); cursor: pointer; }
.terms-accept:disabled { opacity: 0.45; cursor: not-allowed; }
.modal-card h3 { margin: 0 0 0.5rem; font-size: 1rem; font-weight: 600; }
.confirm-card { max-width: 22rem; }
.confirm-text { margin: 0; font-size: 0.875rem; line-height: 1.55; }
.confirm-ok { border: 0; border-radius: 10px; min-height: 36px; padding: 0 1rem; font: inherit; font-size: 0.875rem; font-weight: 600; color: #fff; background: var(--danger-fill); cursor: pointer; }
.confirm-ok:hover { background: var(--danger-fill-hover); }
.confirm-ok.primary { background: var(--accent-fill); }
.confirm-ok.primary:hover { background: var(--accent-fill-hover); }
.confirm-input { width: 100%; box-sizing: border-box; margin-top: 0.7rem; padding: 0.55rem 0.7rem; min-height: var(--btn-md); font: inherit; font-size: 0.875rem; color: inherit; background: transparent; border: 1px solid var(--line-strong); border-radius: var(--r-control); }
.confirm-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.setup-command {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.6rem 0;
  padding: 0.55rem 0.7rem;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.dark .setup-command { border-color: var(--line-strong)}
.setup-command code { flex: 1; font-size: 0.8125rem; word-break: break-all; }
.setup-command button, .setup-close {
  flex-shrink: 0;
  border: 0;
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}
.setup-command button { background: var(--accent-fill); color: #fff; }
.setup-close { margin-top: 0.6rem; background: var(--chip); color: var(--ink-soft); }
.approve-row { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.approve-row button {
  border: 0;
  border-radius: 8px;
  padding: 0.4rem 0.9rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}
.approve-run { background: var(--accent-fill); color: #fff; }
.approve-all { background: #dbe7fb; color: var(--accent-strong); }
.approve-skip { background: var(--chip); color: var(--ink-soft); }
.dark .approve-all { background: var(--accent-wash)}
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; padding: 1.4rem 1rem; text-align: center; }
.empty-state .note { margin: 0; }
.empty-ico { width: 2.2rem; height: 2.2rem; opacity: 0.35; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.comment-form { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.75rem 0 0.25rem; }
.comment-form input, .comment-form textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-size: 0.875rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
}
.comment-form textarea { resize: vertical; }
.comment-form button {
  align-self: flex-start;
  margin-top: 0;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent-fill);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}
.comment-form button:disabled { opacity: 0.55; cursor: default; }
.auth-tabs { display: inline-flex; gap: 0.25rem; padding: 0.2rem; margin: 0.25rem 0 0.9rem;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-control); }
.method-tabs { margin-top: 0; }
.auth-tab { border: 0; background: transparent; color: var(--ink-soft); font: inherit; font-size: 0.875rem;
  font-weight: 600; padding: 0 0.95rem; min-height: var(--btn-sm); border-radius: 8px; cursor: pointer; }
.auth-tab[aria-selected="true"] { background: var(--accent-wash); color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.dark .auth-tabs { background: var(--sidebar); border-color: var(--line)}
.auth-more { margin: 0.1rem 0 0.9rem; font-size: 0.8125rem; color: var(--ink-faint); }
.auth-more summary { cursor: pointer; width: fit-content; min-height: 2rem; display: flex; align-items: center; }
.auth-more .note { margin: 0.3rem 0 0; }
.comment { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0.7rem 0.9rem; margin-top: 0.6rem; }
.comment .who { font-size: 0.8125rem; color: var(--ink-faint); margin-bottom: 0.25rem; }
.comment .body { white-space: pre-wrap; word-break: break-word; font-size: 0.875rem; }
.report-btn { margin-top: 0.35rem; border: 0; background: transparent; color: #999; cursor: pointer; font-size: 0.8125rem; padding: 0; }
.report-btn:hover { color: var(--danger); }
.news-content {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface-soft);
  border: 1px solid #eee;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.6;
  margin: 0.5rem 0;
}
.news-list { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 0.5rem; }
.news-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem 1.15rem;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  transition: box-shadow var(--motion), transform var(--motion);
}
.news-item:hover { box-shadow: 0 4px 14px rgba(16, 24, 40, 0.08); transform: translateY(-1px); }
.news-item h3 { margin: 0 0 0.4rem; font-size: 1rem; font-weight: 600; line-height: 1.35; }
.news-item p { margin: 0; color: #4a4f57; font-size: 0.875rem; line-height: 1.6; }
.dark .news-item { border-color: var(--line)}
.dark .news-item p { color: var(--ink-soft)}
/* Humanizer: Generate / Improve switch inside the composer */
.humanizer-toggle {
  display: flex;
  flex-shrink: 0;
  gap: 2px;
  padding: 3px;
  background: #eef1f6;
  border-radius: 999px;
}
.dark .humanizer-toggle { background: var(--chip)}
.humanizer-toggle .ht-opt {
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.4rem 0.62rem;
  color: var(--ink-faint);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--motion), color var(--motion);
}
.humanizer-toggle .ht-opt.active { background: var(--accent-fill); color: #fff; }
.humanizer-toggle .ht-opt:not(.active):hover { background: #e2e7ee; }
.dark .humanizer-toggle .ht-opt:not(.active):hover { background: #3d4046}
#humanizer-note { color: var(--accent); }
#humanizer-note button {
  margin-left: 0.5rem;
  padding: 0.2rem 0.7rem;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent-fill);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}
/* Phones: give the message box its own row so the switch stays reachable. */
@media (max-width: 620px) {
  .composer.humanizer-on { flex-wrap: wrap; row-gap: 0.5rem; }
  .composer.humanizer-on .attach-btn { display: none; }
  .composer.humanizer-on textarea { flex: 1 1 100%; order: -1; min-height: 2.8rem; }
}

/* ---- Phone home (≤720px): what is due tonight, today's review, the last chat; the input bar stays at the bottom. ---- */
.mobile-quota, .mh-hw, .mh-resume, .role-chips, .cam-btn, .talk-btn { display: none; }
@media (max-width: 720px) {
  body { height: 100vh; height: 100dvh; }
  .mobile-quota:not([hidden]) { display: inline-flex; }
  .mobile-quota {
    align-items: center; gap: 0.45rem; position: fixed; top: 0.7rem; left: 3.5rem; z-index: 40;
    height: 2.4rem; padding: 0 0.8rem 0 0.3rem; font: inherit; font-size: 0.8125rem; font-weight: 600;
    color: var(--ink-soft); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px; cursor: pointer;
  }
  .mobile-quota .mq-label { font-weight: 500; color: var(--ink-faint); }
  body.drawer-open .mobile-quota { display: none; }
  /* On a sub-page the "← Back" button takes this spot next to the menu button, so the badge steps aside. */
  body:has(#back-btn:not([hidden])) .mobile-quota { display: none; }
  .mq-avatar { width: 1.8rem; height: 1.8rem; border-radius: 50%; overflow: hidden; flex: none; display: grid; place-items: center; background: var(--accent-wash); color: var(--accent); font-size: 0.8125rem; font-weight: 700; }
  .mq-avatar img { width: 100%; height: 100%; display: block; }
  .mq-avatar:empty { display: none; }
  .mobile-quota:has(.mq-avatar:empty) { padding-left: 0.8rem; }
  .mq-count.low { color: var(--danger); }
  .dark .mobile-quota { border-color: var(--line-strong)}

  /* The hero stays a real scroller, so the input bar below it never moves. */
  #chat-view:has(.hero:not([hidden])) .messages { display: flex; overflow-y: auto; max-width: none; padding: 4rem 1rem 1rem; }
  #chat-view:has(.hero:not([hidden])) .hero { display: flex; flex-direction: column; gap: 0.7rem; width: 100%; max-width: 36rem; margin: 0 auto; text-align: left; }
  #chat-view:has(.hero:not([hidden])) .hero-icon { display: none; }
  #chat-view:has(.hero:not([hidden])) .greeting { order: 1; width: auto; max-width: none; margin: 0 0 0.15rem; padding: 0; font-size: 1.75rem; }
  #chat-view:has(.hero:not([hidden])) .launchpad { order: 2; max-width: none; margin: 0; }
  #chat-view:has(.hero:not([hidden])) .mh-hw { order: 2; }
  #chat-view:has(.hero:not([hidden])) .review-chip { order: 3; }
  #chat-view:has(.hero:not([hidden])) .jump-card { order: 3; max-width: none; margin: 0; }
  #chat-view:has(.hero:not([hidden])) .mh-resume { order: 4; }
  #chat-view:has(.hero:not([hidden])) .example-chips { order: 5; }
  #chat-view:has(.hero:not([hidden])) .news-buttons { display: none; }
  #chat-view:has(.hero:not([hidden])) .example-chips { display: none; width: auto; max-width: none; margin: 0; padding: 0; justify-content: flex-start; }
  #chat-view:has(.hero.mh-empty:not([hidden])) .example-chips { display: flex; }

  .mh-hw:not([hidden]) { display: block; }
  .mh-title { margin: 0 0 0.45rem; font-size: var(--fs-label); font-weight: 600; letter-spacing: var(--ls-label); text-transform: uppercase; color: var(--ink-faint); }
  .mh-hw-list { display: grid; gap: 0.5rem; }
  .mh-link:not([hidden]) { display: grid; gap: 0.6rem; padding: 0.85rem 0.95rem; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
  .mh-link-text { margin: 0; font-size: var(--fs-body); color: var(--ink-soft, var(--ink)); }
  .mh-link-btn { min-height: 2.75rem; padding: 0.6rem 0.9rem; font: inherit; font-weight: 600; color: #fff; background: var(--accent-fill); border: 0; border-radius: 12px; cursor: pointer; }
  .mh-hw-row { display: flex; align-items: center; gap: 0.7rem; width: 100%; min-height: 3.5rem; padding: 0.65rem 0.85rem; font: inherit; text-align: left; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; cursor: pointer; }
  .mh-hw-row:active { background: var(--accent-wash); }
  .mh-hw-main { display: grid; gap: 0.05rem; min-width: 0; flex: 1; }
  .mh-hw-course { font-size: var(--fs-small); color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mh-hw-name { font-size: var(--fs-body); font-weight: 600; overflow-wrap: anywhere; }
  .mh-hw-due { flex: none; font-size: var(--fs-small); color: var(--ink-faint); }
  .mh-hw-due.overdue { color: var(--danger); font-weight: 600; }
  #chat-view:has(.hero:not([hidden])) .review-chip:not([hidden]) { display: flex; align-items: center; justify-content: space-between; align-self: stretch; width: 100%; min-height: 3.5rem; margin: 0; padding: 0.7rem 0.95rem; font-size: var(--fs-body); text-align: left; border-radius: 16px; }
  .review-chip:not([hidden])::after { content: "›"; font-size: 1.25rem; line-height: 1; }
  .mh-resume:not([hidden]) { display: grid; gap: 0.1rem; width: 100%; min-height: 3.5rem; padding: 0.65rem 0.95rem; font: inherit; text-align: left; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; cursor: pointer; }
  .mh-resume:active { background: var(--accent-wash); }
  .mh-resume-label { font-size: var(--fs-label); font-weight: 600; letter-spacing: var(--ls-label); text-transform: uppercase; color: var(--ink-faint); }
  .mh-resume-title { font-size: var(--fs-body); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .dark .mh-hw-row, .dark .mh-resume { background: var(--surface); border-color: var(--line-strong); color: var(--ink)}

  /* Family tab bar (titan-shell.js) sits under everything; the page reserves its height. */
  body.has-titan-shell { padding-bottom: var(--titan-shell-h, 0px); }
  body.drawer-open .titan-shell { display: none; }

  /* Bottom bar: role chips, then [camera] [message] [hold to talk] [send], then the smaller tools. */
  .composer-wrap, #chat-view:has(.hero:not([hidden])) .composer-wrap { order: 0; flex: none; width: 100%; max-width: none; margin: 0; padding: 0.5rem 0.7rem 0.6rem; background: var(--surface); border-top: 1px solid var(--line); }
  .dark .composer-wrap, .dark #chat-view:has(.hero:not([hidden])) .composer-wrap { border-top-color: var(--line)}
  .role-chips:not([hidden]) { display: flex; }
  .role-chips { gap: 0.4rem; margin: 0 -0.7rem 0.5rem; padding: 0 0.7rem; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .role-chips::-webkit-scrollbar { display: none; }
  .role-chip { flex: none; min-height: 2.25rem; padding: 0 0.95rem; font: inherit; font-size: var(--fs-small); font-weight: 600; color: var(--ink-soft); background: var(--surface-soft); border: 1px solid var(--line); border-radius: 999px; cursor: pointer; white-space: nowrap; }
  .role-chip[aria-pressed="true"] { color: #fff; background: var(--accent-fill); border-color: var(--accent-fill); }
  .dark .role-chip { border-color: var(--line-strong)}

  .composer { flex-wrap: wrap; align-items: center; gap: 0.45rem; padding: 0.5rem; border-radius: 28px; }
  .composer::after { content: ""; order: 5; flex: 0 0 100%; height: 0; }
  .composer .cam-btn { order: 1; display: inline-flex; align-items: center; justify-content: center; flex: none; width: 3.5rem; height: 3.5rem; padding: 0; color: #fff; background: var(--accent-fill); border: 0; border-radius: 50%; cursor: pointer; box-shadow: 0 2px 8px rgba(43, 79, 216, 0.3); }
  .composer .cam-btn:active { transform: scale(0.95); }
  .composer .cam-btn svg, .composer .talk-btn svg { width: 1.6rem; height: 1.6rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .composer textarea { order: 2; flex: 1 1 0; width: auto; min-width: 0; min-height: 2.75rem; max-height: 9rem; padding: 0.4rem 0.25rem; font-size: 1rem; }
  .composer .talk-btn { order: 3; display: inline-flex; align-items: center; justify-content: center; flex: none; width: 3rem; height: 3rem; padding: 0; color: var(--accent); background: var(--accent-wash); border: 0; border-radius: 50%; cursor: pointer; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  .composer .talk-btn.recording { color: #fff; background: var(--danger-fill); box-shadow: 0 0 0 5px rgba(192, 57, 43, 0.22); }
  .composer #generate-button { order: 4; width: auto; min-height: 2.75rem; padding: 0.55rem 1rem; }
  .composer #mic-btn, .composer #persona-select, .composer #allowance-count { display: none; }
  .composer #attach-btn { order: 6; } .composer #search-btn { order: 7; } .composer #deep-btn { order: 8; }
  .composer .model-picker { order: 9; margin-left: auto; }
  .composer .humanizer-toggle { order: 10; }
  .composer .attach-btn { min-width: 2.5rem; min-height: 2.5rem; }
  /* Once there is text, the message takes its own row and the buttons sit under it. */
  .composer:has(textarea:not(:placeholder-shown)) textarea { order: 0; flex: 1 1 100%; padding: 0.4rem 0.5rem 0.2rem; }
  .composer:has(textarea:not(:placeholder-shown)) #generate-button { margin-left: auto; }
  .composer.humanizer-on .cam-btn, .composer.humanizer-on .talk-btn { display: none; }
  .composer.humanizer-on textarea { flex: 1 1 100%; order: 2; }

  /* One-line composer: [+] [message] [hold to talk] [send]. Camera, files, web search, deep thinking and the model
     open from "+" as a second row (an active search / deep toggle stays visible so its state is never hidden). */
  .composer .more-tools-btn { order: 1; display: inline-flex; align-items: center; justify-content: center; flex: none; width: 2.75rem; height: 2.75rem; padding: 0; color: var(--ink-soft); background: var(--chip); border: 0; border-radius: 50%; cursor: pointer; transition: transform var(--motion), background var(--motion); }
  .composer .more-tools-btn svg { width: 1.35rem; height: 1.35rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
  .composer.tools-open .more-tools-btn { transform: rotate(45deg); background: var(--chip-hover); }
  .composer .talk-btn { width: 2.75rem; height: 2.75rem; }
  .composer textarea { min-height: 2.75rem; }
  .composer:not(.tools-open) .cam-btn,
  .composer:not(.tools-open) #attach-btn,
  .composer:not(.tools-open) #search-btn:not(.active),
  .composer:not(.tools-open) #deep-btn:not(.active),
  .composer:not(.tools-open) .model-picker { display: none; }
  .composer.tools-open .cam-btn { order: 6; width: 2.5rem; height: 2.5rem; color: var(--ink-soft); background: transparent; box-shadow: none; }
  .composer.tools-open .cam-btn svg { width: 1.25rem; height: 1.25rem; }
  .composer.tools-open #attach-btn { order: 7; } .composer.tools-open #search-btn { order: 8; } .composer.tools-open #deep-btn { order: 9; }
  .composer.tools-open .model-picker { order: 10; }
  .role-chips { margin-bottom: 0.4rem; }
  .role-chip { min-height: 2.5rem; }
}
.more-tools-btn { display: none; }

/* ---- Layout v2 ------------------------------------------------------
   Sidebar: brand, mode, New chat, then the chat list gets all the spare
   height; study tools and Fun sit in one quiet group above the account
   footer (avatar + email, plan, Settings / Sign out side by side).
   Home: greeting, family shortcuts as one slim row, the input, then the
   prompt suggestions. The Jump Jump pill stays in the top bar. */
.side-chats { flex: 1 1 auto; min-height: 7rem; margin-top: 0.15rem; }
.side-tools { margin-top: auto; }
.side-tools .side-section { margin-top: 0.3rem; padding-top: 0.3rem; }
.side-tools .side-section:first-child { border-top: 1px solid var(--line); }
.side-tools .side-section + .side-section { border-top: 0; }
#tools-title, #account-title { display: none; }
#new-chat { justify-content: flex-start; font-weight: 600; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
#new-chat:hover { border-color: #d9d6cb; box-shadow: var(--shadow-md); }
.side-chats-title, .side-section-title { letter-spacing: 0.06em; }
.side-bottom .side-section { display: grid; grid-template-columns: 1fr 1fr; gap: 0.3rem; margin-top: 0.3rem; padding-top: 0.6rem; border-top: 1px solid var(--line); }
.side-bottom .account-row { grid-column: 1 / -1; padding: 0.15rem 0.2rem; min-width: 0; }
.side-bottom .account-row[hidden], .side-bottom .side-plan[hidden] { display: none; }
.side-bottom .side-plan { grid-column: 1 / -1; margin: 0 0 0.2rem 2.4rem; font-size: 0.6875rem; }
.side-bottom .side-btn { justify-content: center; gap: 0.4rem; padding: 0.42rem 0.5rem; font-size: 0.8125rem; border: 1px solid var(--line); border-radius: 10px; background: transparent; }
.side-bottom .side-btn:hover { background: var(--surface); }
.side-bottom .side-btn[hidden] { display: none; }
.side-bottom #signin-btn { grid-column: 2; }
.dark #new-chat { background: var(--surface-float); border-color: var(--line); box-shadow: none}
.dark .side-bottom .side-section, .dark .side-tools .side-section:first-child { border-color: var(--line)}
.dark .side-bottom .side-btn { border-color: var(--line)}

#launch-chat, #launch-ide { display: none; }
.launch-tile, .launch-tile.primary { padding: 0.5rem 0.8rem; border-radius: 12px; gap: 0.6rem; }
.launch-tile.primary .launch-ico, .launch-ico { width: 1.35rem; height: 1.35rem; }
.launch-tile.primary .launch-title, .launch-title { font-size: 0.875rem; }
.launch-desc { font-size: 0.8125rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.launch-text { min-width: 0; }
#launch-fun { grid-column: auto; }
@media (max-width: 720px) { #launch-fun { grid-column: 1 / -1; } }
@media (min-width: 721px) {
  #chat-view:has(.hero:not([hidden])) .hero { max-width: 40rem; gap: 0.85rem; }
  #chat-view:has(.hero:not([hidden])) .greeting { font-size: 1.75rem; text-align: center; margin-bottom: 0.4rem; }
  #chat-view:has(.hero:not([hidden])) .launchpad { order: 3; grid-template-columns: 1.5fr 1fr; gap: 0.5rem; margin-top: 0.35rem; }
  #chat-view:has(.hero:not([hidden])) .composer-wrap { order: 2; }
  #chat-view:has(.hero:not([hidden])) .example-chips { order: 4; margin: 0 auto; }
  #chat-view:has(.hero:not([hidden])) .news-buttons { order: 5; margin: 0 auto; }
  /* One shared column so the input, chips and shortcut tiles line up. */
  #chat-view:has(.hero:not([hidden])) .composer-wrap,
  #chat-view:has(.hero:not([hidden])) .example-chips,
  #chat-view:has(.hero:not([hidden])) .news-buttons,
  #chat-view:has(.hero:not([hidden])) .launchpad { box-sizing: border-box; width: min(44rem, calc(100% - 2rem)); max-width: none; margin-inline: auto; padding-inline: 0; }
  #chat-view:has(.hero:not([hidden])) { justify-content: center; padding-top: 18vh; padding-bottom: 2rem; gap: 0.75rem; }
}

/* ---- Layout v3 (Kimi-style) ------------------------------------------
   Flat icon nav under New chat, Projects/Chats labels in sentence case,
   the page as one inset rounded panel, a bigger input with the shortcut
   tray (Gunn Tools / Titan Fun) tucked under it, prompt pills below. */
.side-tools { margin-top: 0.35rem; display: flex; flex-direction: column; gap: 0.1rem; }
.side-tools .side-btn { display: flex; align-items: center; gap: 0.65rem; padding: 0.55rem 0.75rem; font-size: 0.875rem; }
.side-tools .side-sub { margin-left: 1.15rem; }
#new-chat { padding: 0.6rem 0.75rem; background: rgba(0, 0, 0, 0.05); border: 0; box-shadow: none; }
#new-chat:hover { background: rgba(0, 0, 0, 0.08); box-shadow: none; }
.dark #new-chat { background: rgba(255, 255, 255, 0.08)}
#space-section { border-top: 0; margin-top: 0.5rem; padding-top: 0; }
.side-section-title, .side-chats-title { text-transform: none; letter-spacing: 0; font-size: 0.8125rem; font-weight: 500; padding: 0.4rem 0.75rem 0.25rem; }
.side-chats { margin-top: 0.25rem; }

@media (min-width: 721px) {
  body { background: var(--sidebar); }
  body.dark { background: #25272a; }
  .sidebar { border-right: 0; }
  main { margin: 0.5rem 0.5rem 0.5rem 0; border-radius: 18px; overflow: hidden; border: 1px solid var(--line); box-shadow: 0 1px 3px rgba(16, 24, 40, 0.05); }
  .dark main { border-color: var(--line); box-shadow: none}
  #chat-view:has(.hero:not([hidden])) .hero-icon { display: block; order: 1; align-self: center; margin: 0 0 0.35rem; width: 3.2rem; height: 3.2rem; }
  #chat-view:has(.hero:not([hidden])) .composer-wrap { position: relative; z-index: 2; padding-bottom: 0; }
  #chat-view:has(.hero:not([hidden])) .composer { border-radius: 22px; box-shadow: 0 2px 14px rgba(16, 24, 40, 0.07); }
  #chat-view:has(.hero:not([hidden])) .launchpad { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; width: min(41rem, calc(100% - 3.5rem)); margin: -1.5rem auto 0; padding: 1.8rem 0.5rem 0.4rem; background: var(--surface-soft, var(--surface-soft)); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 18px 18px; }
  #chat-view:has(.hero:not([hidden])) .launchpad .launch-tile,
  #chat-view:has(.hero:not([hidden])) .launchpad .launch-tile.primary { padding: 0.3rem 0.65rem; color: var(--ink, var(--ink)); background: transparent; border: 0; box-shadow: none; border-radius: 10px; }
  #chat-view:has(.hero:not([hidden])) .launchpad .launch-tile:hover { background: rgba(0, 0, 0, 0.05); transform: none; box-shadow: none; }
  #chat-view:has(.hero:not([hidden])) .launchpad .launch-ico { width: 1.15rem; height: 1.15rem; color: var(--accent); }
  #chat-view:has(.hero:not([hidden])) .launchpad .launch-text { display: flex; flex-direction: row; align-items: baseline; gap: 0.5rem; }
  #chat-view:has(.hero:not([hidden])) .launchpad .launch-tile.primary .launch-title,
  #chat-view:has(.hero:not([hidden])) .launchpad .launch-title { font-size: 0.875rem; font-weight: 600; }
  #chat-view:has(.hero:not([hidden])) .launchpad .launch-desc { font-size: 0.8125rem; color: var(--ink-faint); }
  #chat-view:has(.hero:not([hidden])) .launchpad .launch-go { display: none; }
  #chat-view:has(.hero:not([hidden])) .example-chips { margin-top: 0.9rem; }
  /* Chips wrap onto a second line rather than scroll: a sideways-scrolling row hid the end of the longer Agent suggestions. */
  #chat-view:has(.hero:not([hidden])) .example-chips { width: min(52rem, calc(100% - 2rem)); flex-wrap: wrap; justify-content: center; }
  #chat-view:has(.hero:not([hidden])) .example-chip { flex: 0 0 auto; white-space: nowrap; padding: 0.4rem 0.85rem; font-size: 0.875rem; }
  .dark #chat-view:has(.hero:not([hidden])) .launchpad { border-color: var(--line)}
  .dark #chat-view:has(.hero:not([hidden])) .launchpad .launch-tile:hover { background: rgba(255, 255, 255, 0.08)}
}

#delete-account-btn { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
#delete-account-btn:hover:not(:disabled) { background: var(--danger); color: #fff; }
#delete-account-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.auth-forgot { margin: 0.5rem 0 0; font-size: var(--fs-small); }
.auth-forgot a { color: var(--accent); }

/* Buttons: four layers (docs/ui-tokens.md). Primary = filled accent, secondary = surface + line, ghost = no fill with a
   6% wash on hover, danger = filled error red. Controls are 10px radius and 36 / 40 / 46 high. */
.qz-btn, .sp-btn, .terms-accept, .confirm-ok, .terms-decline {
  border-radius: var(--r-control); min-height: var(--btn-md); padding: 0 1rem; font: inherit; font-size: var(--fs-body); font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; cursor: pointer; text-decoration: none;
}
.qz-btn, .sp-btn, .terms-accept { color: #fff; background: var(--accent-fill); border: 0; }
.qz-btn:hover:not(:disabled), .sp-btn:hover:not(:disabled), .terms-accept:hover:not(:disabled) { background: var(--accent-fill-hover); }
.qz-btn.ghost, .sp-btn.ghost { color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); font-weight: 500; }
.qz-btn.ghost:hover:not(:disabled), .sp-btn.ghost:hover:not(:disabled) { background: var(--hover); border-color: var(--line-strong); color: var(--ink); }
.qz-btn.danger:not(.ghost), .sp-btn.danger:not(.ghost) { color: #fff; background: var(--danger-fill); border-color: transparent; }
.qz-btn.ghost.danger, .sp-btn.ghost.danger { color: var(--danger); border-color: var(--danger); }
.terms-decline { color: var(--ink-soft); background: transparent; border: 0; opacity: 1; font-weight: 500; text-decoration: none; }
.terms-decline:hover { background: var(--hover); color: var(--ink); }
.confirm-actions .qz-btn, .confirm-actions button { min-height: var(--btn-md); }

/* Sign-in view: the layout shared with Gunn Tools and Titan Chat (wordmark, 22rem panel, labelled 40px fields, 46px buttons). */
#login-view .status-inner { max-width: 22rem; padding-top: 3rem; }
#login-view .auth-wordmark { display: flex; align-items: center; justify-content: center; gap: 0.6rem; margin-bottom: 1rem; font-family: var(--font-display); font-weight: 600; font-size: 1.25rem; letter-spacing: -0.02em; }
#login-view .auth-wordmark img { width: 28px; height: 28px; border-radius: 8px; }
#login-view .auth-tabs { display: flex; width: 100%; }
/* The Titan sign-in card (same on Gunn Tools and Titan Chat): one surface card, tabs on top, short help text. */
#login-view .auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 1.5rem; }
#login-view .auth-card > .auth-tabs:first-child { margin-top: 0; }
#login-view .auth-card .note { font-size: var(--fs-small); line-height: 1.55; }
#login-view .auth-card .note:empty { display: none; }
@media (max-width: 420px) { #login-view .auth-card { padding: 1.25rem 1rem; } }
#login-view .auth-tab { flex: 1; white-space: nowrap; padding: 0 0.5rem; }
#login-view h2 { font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; }
#login-view .comment-form input { min-height: var(--btn-md); border-radius: var(--r-control); border-color: var(--line-strong); background: var(--surface); }
#login-view .comment-form button { min-height: var(--btn-lg); width: 100%; border-radius: var(--r-control); margin-top: 0.4rem; }

/* Humanizer: no news topics, and no "write me ..." examples while improving pasted text. */
#chat-view:has(.composer.humanizer-on) .news-buttons,
#chat-view:has(.composer.hu-rewrite) .example-chips { display: none !important; }
