/* ═══════════════════════════════════════════════════════════
   MATH · 李老师 — design system
   HUD dashboard · Anthropic dark · 柔和天青 (eye-friendly)
   ═══════════════════════════════════════════════════════════ */

:root {
  /* Surfaces */
  --bg: #0a0a0b;
  --panel: #131316;
  --panel-2: #18181b;
  --panel-3: #1f1f23;
  --hover: #232328;

  /* Lines */
  --border: #26262b;
  --border-strong: #36363d;
  --border-faint: #1c1c20;

  /* Ink */
  --text: #fafafa;
  --text-muted: #a1a1aa;
  --text-faint: #71717a;
  --text-disabled: #3f3f46;

  /* Accent — 柔和天青 */
  --accent: #7dd3fc;
  --accent-hi: #bae6fd;
  --accent-on: #062436;
  --accent-soft: rgba(125,211,252,0.10);
  --accent-glow: rgba(125,211,252,0.30);

  /* Map categories */
  --c-mastered: #4ade80;
  --c-mastered-bg: rgba(74,222,128,0.08);
  --c-mastered-border: rgba(74,222,128,0.30);
  --c-exploring: var(--accent-hi);
  --c-exploring-bg: var(--accent-soft);
  --c-exploring-border: rgba(125,211,252,0.40);
  --c-suggested: #fcd34d;
  --c-suggested-bg: rgba(251,191,36,0.06);
  --c-suggested-border: rgba(251,191,36,0.30);
  --c-distant: var(--text-faint);
  --c-distant-bg: var(--panel-2);
  --c-distant-border: var(--border);

  /* Semantic */
  --ok: #4ade80;
  --warn: #fbbf24;
  --err: #f87171;

  /* Type */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
               "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Mono",
               "Consolas", monospace;
  --font-math: "Cambria Math", "Latin Modern Math", "Times New Roman", serif;

  /* Sizing */
  --radius: 8px;
  --radius-sm: 5px;
  --radius-lg: 12px;

  /* Layout (driven by :has) */
  --nav-width: 220px;
  --side-width: 52px;
}

/* expand sidebar on hover or .pinned */
.app:has(.side:hover) { --side-width: 320px; }
.app:has(.side.pinned) { --side-width: 320px; }

/* hide nav during test mode (#tabs gets .hidden) */
.app:has(#tabs.hidden) { --nav-width: 0px; }
.app:has(#tabs.hidden) .side,
.app:has(#tabs.hidden) .topbar > .brand,
.app:has(#tabs.hidden) .topbar > .topbar-r { visibility: hidden; }

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font-sans);
  font-feature-settings: "cv11", "ss01", "ss03";
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: -0.005em;
}

body { overflow: hidden; }
button { font-family: inherit; cursor: pointer; }
input, textarea, button { font-family: inherit; }
.mono { font-family: var(--font-mono); }
.hidden { display: none !important; }

/* KaTeX dark mode adjustment */
.katex { color: var(--text); }

/* ═══════════════════════════════════════════════
   App Shell
   ═══════════════════════════════════════════════ */
.app {
  height: 100vh;
  display: grid;
  grid-template-rows: 54px 1fr 28px;
  background: var(--bg);
}

/* ═══ Topbar ═══ */
.topbar {
  display: grid;
  grid-template-columns: var(--nav-width) 1fr var(--side-width);
  align-items: stretch;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  transition: grid-template-columns 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px;
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.brand-mark {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #7dd3fc, #0ea5e9);
  color: var(--bg);
  font-family: var(--font-math);
  font-size: 18px;
  font-weight: 600;
  border-radius: 6px;
  box-shadow: 0 0 12px var(--accent-glow);
  flex-shrink: 0;
}
.brand-text {
  font-size: 14px; font-weight: 600;
  letter-spacing: 0.02em;
}
.brand-sub {
  font-family: var(--font-mono);
  font-size: 11px; color: var(--text-faint);
  letter-spacing: 0.04em;
}
.crumb {
  display: flex; align-items: center; gap: 10px;
  padding: 0 22px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  white-space: nowrap;
}
.crumb-cur { color: var(--text); }
.crumb-sep { color: var(--text-disabled); }
.topbar-r {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 0 12px;
  border-left: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  overflow: hidden;
}
.topbar-r .live { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); }

.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }

/* ═══ Body grid ═══ */
.body {
  display: grid;
  grid-template-columns: var(--nav-width) 1fr var(--side-width);
  overflow: hidden;
  transition: grid-template-columns 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 显式绑 grid items 到列号 — 防止 .nav 被 .hidden 移出文档流后,
   .main / .side 自动重排到错的列 (导致测试 view 主区宽度变 0) */
.body > .nav   { grid-column: 1; }
.body > .main  { grid-column: 2; }
.body > .side  { grid-column: 3; }
.topbar > .brand    { grid-column: 1; }
.topbar > .crumb    { grid-column: 2; }
.topbar > .topbar-r { grid-column: 3; }

/* ═══════════════════════════════════════════════
   Left nav
   ═══════════════════════════════════════════════ */
.nav {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 14px 10px 12px;
  display: flex; flex-direction: column;
  gap: 2px;
  overflow: hidden;
}
.nav-section {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--text-faint);
  text-transform: uppercase;
  padding: 12px 12px 6px;
  font-weight: 600;
}
.nav-section:first-child { padding-top: 4px; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px;
  border-radius: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  text-align: left;
  width: 100%;
  transition: all 0.12s;
  position: relative;
  white-space: nowrap;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-hi);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--accent);
  border-radius: 2px;
  box-shadow: 0 0 8px var(--accent-glow);
}
.nav-icon {
  width: 16px; height: 16px;
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 13px;
  opacity: 0.85;
  flex-shrink: 0;
}
.nav-spacer { flex: 1; }

/* 今日小测 nav-item 状态 */
.nav-test-tag {
  margin-left: auto;
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 10px;
  letter-spacing: 0.04em;
  background: var(--panel-3);
  color: var(--text-faint);
  border: 1px solid var(--border);
}
.nav-test[data-test-state="pending"] .nav-test-icon {
  color: var(--accent);
  text-shadow: 0 0 6px var(--accent-glow);
}
.nav-test[data-test-state="pending"] .nav-test-tag {
  background: var(--accent-soft);
  color: var(--accent-hi);
  border-color: rgba(125,211,252,0.30);
}
.nav-test[data-test-state="done"] .nav-test-icon {
  color: var(--ok);
}
.nav-test[data-test-state="done"] .nav-test-tag {
  background: rgba(74,222,128,0.10);
  color: var(--ok);
  border-color: rgba(74,222,128,0.30);
}
.nav-test[data-test-state="admin"] .nav-test-icon {
  color: #fcd34d;
}
.nav-test[data-test-state="admin"] .nav-test-tag {
  background: rgba(251,191,36,0.08);
  color: #fcd34d;
  border-color: rgba(251,191,36,0.30);
}
.nav-test[disabled] { opacity: 0.6; cursor: not-allowed; }

.nav-mini {
  margin: 8px 6px 0;
  padding: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.nav-mini-title {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 4px;
  font-weight: 600;
}
.nav-mini-date {
  font-size: 13px;
  color: var(--text);
}

/* 用户信息 + 退出按钮 (左栏底部, 任何屏宽都可达) */
.nav-user {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.nav-user-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
}
.nav-user-name {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
}
.nav-logout {
  width: 100%;
  text-align: center;
  font-size: 11px;
  padding: 6px 8px;
}

/* ═══════════════════════════════════════════════
   Main content
   ═══════════════════════════════════════════════ */
.main {
  overflow: hidden;        /* 自身不滚，让具体 view 处理 */
  display: flex; flex-direction: column;
  background: var(--bg);
  min-width: 0;
}

.view {
  flex: 1;
  display: flex; flex-direction: column;
  padding: 24px 32px 32px;
  min-height: 0;
  overflow-y: auto;        /* 默认 view 自己滚动 (map / history / test-result) */
}
.view::-webkit-scrollbar { width: 10px; }
.view::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 5px;
  border: 2px solid var(--bg);
}
.view.hidden { display: none !important; }

/* chat 视图: 自身不滚, 只让消息区滚动 */
.chat-view { overflow: hidden; gap: 0; }
.test-view { padding: 0; overflow: hidden; }

.view-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border-faint);
  margin-bottom: 22px;
}
.view-title {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.view-sub {
  font-size: 14px;
  color: var(--text-faint);
  margin-top: 5px;
  font-family: var(--font-mono);
}

/* ═══════════════════════════════════════════════
   Today's challenge proposal card
   ═══════════════════════════════════════════════ */
.proposal {
  background: linear-gradient(135deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  position: relative;
  overflow: hidden;
  margin-bottom: 18px;
}
.proposal::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), #0ea5e9);
  box-shadow: 0 0 14px var(--accent-glow);
}
.proposal::after {
  content: '';
  position: absolute;
  right: -40px; top: -40px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, var(--accent-soft), transparent 70%);
  pointer-events: none;
}
.proposal-row {
  display: flex; justify-content: space-between; align-items: center;
  position: relative;
  z-index: 1;
  gap: 16px;
}
.proposal-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
  display: flex; align-items: center; gap: 8px;
}
.proposal-eyebrow::before {
  content: ''; width: 4px; height: 4px;
  background: var(--accent);
  display: inline-block;
  box-shadow: 0 0 6px var(--accent);
}
.proposal-title {
  font-size: 20px; font-weight: 600;
  letter-spacing: -0.01em;
}
.proposal-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 5px;
  letter-spacing: 0.02em;
}

.proposal-done {
  background: rgba(74,222,128,0.06);
  border: 1px solid rgba(74,222,128,0.20);
  border-radius: var(--radius);
  padding: 12px 18px;
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 18px;
  font-size: 14px;
}
.proposal-done .check-mark {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px;
  background: var(--ok); color: #04210e;
  border-radius: 50%;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
.proposal-done-text { flex: 1; color: var(--text-muted); }
.proposal-done-text .mono { color: var(--text); margin-left: 4px; }

/* ═══════════════════════════════════════════════
   Buttons
   ═══════════════════════════════════════════════ */
.btn-go,
.btn-primary {
  background: var(--accent);
  color: var(--accent-on);
  border: none;
  padding: 10px 24px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-go:hover:not(:disabled),
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hi);
  box-shadow: 0 0 16px var(--accent-glow);
  transform: translateY(-1px);
}
.btn-go:disabled,
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-ghost {
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  transition: all 0.12s;
}
.btn-ghost:hover {
  background: var(--hover);
  border-color: var(--border-strong);
  color: var(--text);
}

/* ═══════════════════════════════════════════════
   Section divider (subtle ─── label ───)
   ═══════════════════════════════════════════════ */
.section-head {
  display: flex; align-items: center; gap: 12px;
  margin: 8px 0 14px;
}
.section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--text-faint);
  text-transform: uppercase;
  font-weight: 600;
  flex-shrink: 0;
}
.section-rule { flex: 1; height: 1px; background: var(--border-faint); }

/* ═══════════════════════════════════════════════
   Mode pill toggle
   ═══════════════════════════════════════════════ */
.chat-toolbar {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.mode-pill {
  display: inline-flex;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px;
}
.mode-opt {
  background: none; border: none;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.12s;
}
.mode-opt.active {
  background: var(--panel-3);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
.mode-opt:not(.active):hover { color: var(--text); }
.mode-hint {
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

/* ═══════════════════════════════════════════════
   Sequence progress
   ═══════════════════════════════════════════════ */
.sequence-progress {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 14px;
}
.sequence-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.sequence-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--accent);
  text-transform: uppercase;
  font-weight: 600;
}
.sequence-text {
  font-size: 13px;
  color: var(--text);
}
.sequence-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.sequence-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #0ea5e9);
  box-shadow: 0 0 10px var(--accent-glow);
  transition: width 0.4s ease;
  border-radius: 2px;
}

/* ═══════════════════════════════════════════════
   Messages (chat)
   ═══════════════════════════════════════════════ */
.messages {
  flex: 1;
  display: flex; flex-direction: column;
  gap: 18px;
  padding: 6px 0 16px;
  min-height: 200px;
  overflow-y: auto;
}
.messages::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 4px;
  border: 2px solid var(--bg);
}

.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 60px 20px;
  text-align: center;
}
.empty-glyph {
  font-family: var(--font-math);
  font-size: 56px;
  color: var(--accent);
  opacity: 0.4;
  margin-bottom: 14px;
  text-shadow: 0 0 24px var(--accent-glow);
}
.empty-text {
  color: var(--text-faint);
  font-size: 15px;
}

.msg { display: flex; gap: 14px; align-items: flex-start; }
.role-label {
  width: 78px;
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding-top: 4px;
}
.msg-coach .role-label {
  color: var(--accent);
  text-shadow: 0 0 8px var(--accent-glow);
}
.bubble {
  flex: 1;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  min-width: 0;
}
.bubble p { margin: 0 0 8px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble strong { color: var(--accent-hi); font-weight: 600; }
.bubble em { color: var(--accent-hi); font-style: italic; }
.bubble code {
  background: var(--panel-2);
  border: 1px solid var(--border-faint);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  color: var(--accent-hi);
}
.bubble pre {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  overflow-x: auto;
  margin: 8px 0;
}
.bubble pre code {
  background: none; border: none; padding: 0;
}
.bubble ul, .bubble ol {
  margin: 4px 0 8px;
  padding-left: 22px;
}
.bubble li { margin: 4px 0; }
.bubble blockquote {
  border-left: 2px solid var(--accent);
  padding: 4px 0 4px 12px;
  margin: 8px 0;
  color: var(--text-muted);
}
.bubble .katex-display {
  margin: 12px 0;
  padding: 10px 16px;
  background: var(--panel);
  border-left: 2px solid var(--accent);
  border-radius: 0 4px 4px 0;
  overflow-x: auto;
}
.bubble.thinking {
  color: var(--text-faint);
  font-style: italic;
  position: relative;
}
.bubble.thinking::before {
  content: '⌬';
  margin-right: 6px;
  color: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}
.bubble.error {
  color: var(--err);
}

/* ═══════════════════════════════════════════════
   Composer
   ═══════════════════════════════════════════════ */
.composer {
  margin-top: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: var(--radius);
  display: flex;
  align-items: stretch;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.composer textarea {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  padding: 14px 16px;
  resize: none;
  outline: none;
  min-height: 64px;
  max-height: 240px;
}
.composer textarea::placeholder { color: var(--text-faint); }
.composer textarea:disabled { opacity: 0.6; }
.composer-actions {
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 10px 12px;
  gap: 6px;
}
.send {
  background: var(--accent);
  color: var(--accent-on);
  border: none;
  padding: 8px 18px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  transition: all 0.12s;
}
.send:hover:not(:disabled) {
  background: var(--accent-hi);
  box-shadow: 0 0 14px var(--accent-glow);
}
.send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.composer-hint {
  font-size: 10px;
  color: var(--text-faint);
  text-align: right;
  letter-spacing: 0.04em;
}

/* ═══════════════════════════════════════════════
   Right side panel
   ═══════════════════════════════════════════════ */
.side {
  background: var(--panel);
  border-left: 1px solid var(--border);
  overflow: hidden;
  position: relative;
  transition: background 0.2s;
}
.side:hover, .side.pinned {
  background: var(--panel-2);
  overflow-y: auto;
}
.side::-webkit-scrollbar { width: 8px; }
.side::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 4px;
  border: 2px solid var(--panel);
}

/* Collapsed strip */
.side-collapsed {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center;
  padding: 20px 0 14px;
  gap: 22px;
  pointer-events: none;
  transition: opacity 0.18s;
}
.side:hover .side-collapsed,
.side.pinned .side-collapsed { opacity: 0; }
.side-collapsed-icon {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-faint);
  position: relative;
}
.side-collapsed-icon.live {
  color: transparent;
}
.side-collapsed-icon.live::after {
  content: '';
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
  animation: pulse 1.6s ease-in-out infinite;
}
.side-collapsed-divider {
  width: 16px; height: 1px;
  background: var(--border);
}
.side-collapsed-hint {
  margin-top: auto;
  font-size: 9px;
  color: var(--text-faint);
  letter-spacing: 0.18em;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  padding-bottom: 6px;
}

/* Expanded content */
.side-expanded {
  padding: 20px;
  opacity: 0;
  transition: opacity 0.2s 0.08s;
  min-width: 280px;
}
.side:hover .side-expanded,
.side.pinned .side-expanded { opacity: 1; }

.side-block { margin-bottom: 26px; }
.side-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--text-faint);
  text-transform: uppercase;
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
  font-weight: 600;
}
.side-title::before {
  content: ''; width: 5px; height: 5px;
  background: var(--accent);
  display: inline-block;
  box-shadow: 0 0 6px var(--accent);
  flex-shrink: 0;
}
.side-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
}
.side-key { color: var(--text-muted); font-family: var(--font-mono); font-size: 12px; }
.side-val { font-family: var(--font-mono); font-size: 12px; color: var(--text); }

.gains-count-pill {
  margin-left: auto;
  background: var(--accent-soft);
  color: var(--accent-hi);
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
}
.gains-list {
  list-style: none;
  display: flex; flex-direction: column;
  gap: 8px;
}
.gain-item {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--border-faint);
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
  position: relative;
  overflow: hidden;
}
.gain-item.fresh {
  background: var(--accent-soft);
  border-color: rgba(125,211,252,0.30);
  animation: gainPulse 0.8s ease-out;
}
@keyframes gainPulse {
  0%   { transform: scale(0.95); opacity: 0; }
  60%  { transform: scale(1.02); }
  100% { transform: scale(1); opacity: 1; }
}
.gain-check {
  color: var(--ok);
  font-weight: 700;
  margin-top: 1px;
  flex-shrink: 0;
}
.gain-name { color: var(--text); font-weight: 600; }
.gain-note { color: var(--text-muted); }
.gain-time {
  display: block;
  font-size: 10px;
  color: var(--text-faint);
  margin-top: 2px;
  letter-spacing: 0.05em;
}

/* Recent sessions */
.recent-list { display: flex; flex-direction: column; gap: 2px; }
.recent {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  margin: 0 -6px;
}
.recent:hover { background: var(--hover); color: var(--text); }
.recent-id { color: var(--text-faint); font-size: 11px; }
.recent-empty { color: var(--text-faint); font-size: 12px; padding: 6px; }

/* ═══════════════════════════════════════════════
   Map view
   ═══════════════════════════════════════════════ */
.map-content {
  flex: 1;
  overflow-y: auto;
}
.map-section { margin-bottom: 28px; }
.map-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: -0.005em;
}
.section-desc {
  font-size: 13px;
  color: var(--text-faint);
  margin-bottom: 14px;
  font-family: var(--font-mono);
}

.peak-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.peak {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
  display: flex; flex-direction: column; gap: 4px;
  color: var(--text);
}
.peak:hover {
  background: var(--panel-3);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.peak-name { font-size: 14px; font-weight: 600; }
.peak-note {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  line-height: 1.5;
}

/* category tints */
.peak.mastered {
  border-color: var(--c-mastered-border);
  background: var(--c-mastered-bg);
}
.peak.mastered .peak-name { color: var(--c-mastered); }

.peak.exploring {
  border-color: var(--c-exploring-border);
  background: var(--c-exploring-bg);
  box-shadow: 0 0 12px rgba(125,211,252,0.15);
}
.peak.exploring .peak-name { color: var(--c-exploring); }

.peak.suggested {
  border-color: var(--c-suggested-border);
  background: var(--c-suggested-bg);
}
.peak.suggested .peak-name { color: var(--c-suggested); }

.peak.distant {
  border-color: var(--c-distant-border);
  background: var(--c-distant-bg);
  opacity: 0.7;
}
.peak.distant .peak-name { color: var(--c-distant); }

.peak-grid.suggested { /* "推荐探索" 区强调 */
}

/* Atlas 节点卡 — peak-state 状态标 */
.peak-state {
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.10em;
  margin-top: 4px;
}
.peak.atlas-draft {
  border-style: dashed;
  opacity: 0.8;
}
.atlas-draft-tag {
  font-size: 9px;
  background: rgba(251,191,36,0.10);
  color: #fcd34d;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 6px;
  letter-spacing: 0.10em;
}

/* Atlas 节点详情 modal (复用 dialog#profile-modal 样式) */
dialog#atlas-node-modal {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: 760px;
  width: 92%;
  max-height: 86vh;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  margin: auto;
}
dialog#atlas-node-modal::backdrop {
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}

/* "先讲讲这个" 大弹窗 — 比 atlas-node 大一档, 让讲解能完整呼吸 */
/* 注: 不要用 display:flex 在 dialog 上, 会破坏浏览器默认的 margin:auto 居中 */
dialog#explain-modal {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: 920px;
  width: 94%;
  max-height: 90vh;
  box-shadow: 0 24px 72px rgba(0,0,0,0.55);
  overflow: hidden;
  margin: auto;  /* 覆盖全局 * { margin: 0 } 让浏览器居中 dialog */
}
dialog#explain-modal::backdrop {
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
}
.explain-status {
  padding: 12px 24px;
  color: var(--text-faint);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 20px;
}
.explain-status:empty { padding: 0; min-height: 0; }
.explain-content {
  overflow-y: auto;
  max-height: calc(90vh - 230px);
  padding: 0 24px 12px;
  font-size: 15px;
  line-height: 1.7;
}
.explain-content p { margin-bottom: 12px; }
.explain-content h2,
.explain-content h3 {
  margin-top: 18px;
  margin-bottom: 10px;
  font-size: 17px;
  color: var(--accent);
}
.explain-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  color: var(--text-soft);
  margin: 10px 0;
}
.explain-content code {
  background: rgba(255,255,255,0.06);
  padding: 1px 5px;
  border-radius: 3px;
}
/* 追问对话: Jack 提问 / 李老师答 风格分隔 */
.explain-turn-user {
  margin: 18px 0 8px;
  padding: 10px 14px;
  background: rgba(75, 200, 230, 0.10);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
}
.explain-turn-user::before {
  content: "你问 · ";
  font-weight: 600;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.5px;
}
.explain-turn-assistant {
  margin: 8px 0 12px;
  padding-left: 4px;
}
.explain-turn-assistant::before {
  content: "李老师";
  display: block;
  font-weight: 600;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.explain-modal-foot {
  padding: 12px 24px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
  background: rgba(0, 0, 0, 0.15);
}
.explain-followup-input {
  flex: 1 1 auto;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
}
.explain-followup-input:focus {
  outline: none;
  border-color: var(--accent);
}
.explain-followup-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.explain-modal-foot .btn-ghost,
.explain-modal-foot .btn-primary {
  flex: 0 0 auto;
}

/* ═══════════════════════════════════════════════
   History view
   ═══════════════════════════════════════════════ */
.history-content { display: flex; flex-direction: column; gap: 10px; }
.history-empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-faint);
}
.history-empty-glyph {
  font-family: var(--font-math);
  font-size: 56px;
  color: var(--accent);
  opacity: 0.4;
  margin-bottom: 14px;
  text-shadow: 0 0 24px var(--accent-glow);
}

.history-day {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  transition: all 0.12s;
}
.history-day:hover {
  border-color: var(--border-strong);
  background: var(--panel-3);
}
.history-day-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 12px;
}
.history-date {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
}
.history-day-stats {
  display: flex; gap: 14px;
  font-size: 12px;
  color: var(--text-muted);
}
.history-stat-num { color: var(--accent-hi); }

.history-day-body { display: flex; flex-direction: column; gap: 8px; }
.history-test-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px;
  padding: 6px 0;
}
.history-test-score {
  background: var(--accent-soft);
  color: var(--accent-hi);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}
.history-test-headline { color: var(--text-muted); }

.history-gain-list {
  list-style: none;
  display: flex; flex-direction: column;
  gap: 4px;
  padding: 0;
}
.history-gain-item {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: 13px;
  line-height: 1.5;
}

/* ═══════════════════════════════════════════════
   Test view (takeover)
   ═══════════════════════════════════════════════ */
.test-view { padding: 0; }

.test-topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 28px 14px;
  border-bottom: 1px solid var(--border);
}
.test-topbar-text { flex: 1; min-width: 0; }
.test-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.test-headline {
  font-size: 13px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  margin-top: 2px;
}
.test-step {
  font-size: 14px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 4px;
}

.test-progress-bar {
  height: 3px;
  background: var(--border);
  width: 100%;
}
.test-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #0ea5e9);
  box-shadow: 0 0 10px var(--accent-glow);
  transition: width 0.4s ease;
}

.test-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 40px;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}

.test-q-eyebrow {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 14px;
}
.test-q-type {
  background: var(--accent-soft);
  color: var(--accent-hi);
  padding: 3px 10px;
  border-radius: 3px;
  font-weight: 600;
}
.test-q-stem {
  font-size: 17px;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 14px;
}
.test-q-stem p { margin-bottom: 6px; }
.test-q-stem .katex-display {
  margin: 12px 0;
  padding: 10px 16px;
  background: var(--panel-2);
  border-left: 2px solid var(--accent);
  border-radius: 0 4px 4px 0;
}
.test-q-form {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 18px;
  padding: 8px 12px;
  background: var(--panel-2);
  border: 1px dashed var(--border);
  border-radius: 4px;
}

.test-answer-area { margin-top: 14px; }
.test-answer-area label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 6px;
}
.test-answer-input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.6;
  padding: 12px 14px;
  border-radius: var(--radius);
  resize: vertical;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.test-answer-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.test-action-row {
  display: flex; align-items: center; gap: 14px;
  margin-top: 14px;
}

.test-feedback {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-top: 18px;
}
.test-feedback.correct {
  background: rgba(74,222,128,0.08);
  border: 1px solid rgba(74,222,128,0.30);
  color: var(--ok);
}
.test-feedback.wrong {
  background: rgba(248,113,113,0.06);
  border: 1px solid rgba(248,113,113,0.25);
  color: var(--err);
}

.test-hint {
  margin-top: 14px;
  padding: 14px 16px;
  background: var(--panel-2);
  border-left: 2px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.test-hint-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 8px;
  font-weight: 600;
}

.test-explanation {
  margin-top: 14px;
  padding: 14px 16px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
/* 讲评 block — 答完题/跳过后展示, 让 Jack 看到这道题背后的洞察 */
.test-commentary {
  margin-top: 12px;
  padding: 12px 14px;
  background: rgba(75, 200, 230, 0.06);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  max-height: 400px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.65;
}
.test-commentary-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 6px;
  font-weight: 600;
}
.test-commentary p { margin-bottom: 8px; }
.test-explanation-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 8px;
  font-weight: 600;
}
.test-explanation-answer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  display: flex; gap: 10px; align-items: baseline;
  flex-wrap: wrap;
}
.test-explanation-answer .label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

/* 先讲讲这个 卡片 */
.test-explain-card {
  margin-top: 16px;
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 16px 20px;
  position: relative;
}
.test-explain-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}
.test-explain-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 10px;
}
.test-explain-key {
  font-size: 16px;
  color: var(--accent-hi);
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--accent-soft);
  border-radius: 5px;
  border-left: 2px solid var(--accent);
}
.test-explain-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 12px;
}
.test-explain-body p { margin-bottom: 8px; }
.test-explain-pitfalls {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(251,191,36,0.06);
  border-left: 2px solid #fbbf24;
  border-radius: 0 4px 4px 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* Test result view */
.test-result-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px 28px 40px;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}
.test-result-summary {
  display: flex; flex-direction: column;
  align-items: center;
  padding: 32px 0;
  border-bottom: 1px solid var(--border-faint);
  margin-bottom: 24px;
}
.test-result-score {
  font-size: 56px;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 0 24px var(--accent-glow);
  letter-spacing: -0.02em;
}
.test-result-score-total {
  font-size: 28px;
  color: var(--text-faint);
  margin-left: 4px;
  font-weight: 500;
}
.test-result-headline {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
}

.test-result-list { display: flex; flex-direction: column; gap: 8px; }
.test-result-item {
  display: grid;
  grid-template-columns: 36px 1fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 12px 16px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}
.test-result-item.correct { border-left: 3px solid var(--ok); }
.test-result-item.wrong   { border-left: 3px solid var(--err); }
.test-result-item.skipped { border-left: 3px solid var(--text-faint); opacity: 0.75; }
.test-result-item.skipped .mark { color: var(--text-faint); }

/* 测试复盘卡 (test-result view 底部) */
.test-review-card {
  margin-top: 28px;
  background: linear-gradient(135deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 26px;
  position: relative;
  overflow: hidden;
}
.test-review-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), #0ea5e9);
  box-shadow: 0 0 14px var(--accent-glow);
}
.test-review-head {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-faint);
}
.test-review-body {
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
}
.test-review-body p { margin: 0 0 10px; }
.test-review-body p:last-child { margin-bottom: 0; }
.test-review-body strong { color: var(--accent-hi); }
.test-review-body em { color: var(--accent-hi); font-style: italic; }
.test-review-body .katex { font-size: 1em; }
.test-result-item .num { color: var(--text-faint); }
.test-result-item .topic { color: var(--text); font-weight: 500; }
.test-result-item .type-badge {
  background: var(--panel-3);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-family: var(--font-mono);
}
.test-result-item .mark {
  font-size: 16px;
  font-weight: 700;
}
.test-result-item.correct .mark { color: var(--ok); }
.test-result-item.wrong .mark { color: var(--err); }

/* ═══════════════════════════════════════════════
   Loading / spinner / error
   ═══════════════════════════════════════════════ */
.loading {
  display: flex; align-items: center; gap: 10px;
  padding: 20px;
  color: var(--text-muted);
  font-size: 14px;
}
.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-msg {
  color: var(--err);
  background: rgba(248,113,113,0.06);
  border: 1px solid rgba(248,113,113,0.25);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
}

/* ═══════════════════════════════════════════════
   Profile modal (preserved structure)
   ═══════════════════════════════════════════════ */
dialog#profile-modal {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: 720px;
  width: 92%;
  max-height: 86vh;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  margin: auto;
}
dialog#profile-modal::backdrop {
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}
.dialog-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}
.dialog-header h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  width: 32px; height: 32px;
  border-radius: 6px;
  display: grid; place-items: center;
  transition: all 0.12s;
}
.close-btn:hover { background: var(--hover); color: var(--text); }
.profile-content {
  padding: 22px 28px 28px;
  overflow-y: auto;
  max-height: calc(86vh - 64px);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
}
.profile-content h1, .profile-content h2, .profile-content h3 {
  margin-top: 18px;
  margin-bottom: 8px;
  font-weight: 600;
}
.profile-content h1 { font-size: 22px; }
.profile-content h2 { font-size: 18px; color: var(--accent-hi); }
.profile-content h3 { font-size: 16px; }
.profile-content p { margin: 6px 0 10px; }
.profile-content ul, .profile-content ol { padding-left: 24px; margin: 6px 0 10px; }
.profile-content li { margin: 4px 0; }
.profile-content strong { color: var(--accent-hi); }
.profile-content code {
  background: var(--panel-2);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.9em;
  color: var(--accent-hi);
}

/* ═══════════════════════════════════════════════
   Status bar (bottom)
   ═══════════════════════════════════════════════ */
.statusbar {
  display: flex; align-items: center;
  border-top: 1px solid var(--border);
  background: var(--panel);
  padding: 0 18px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
  gap: 18px;
}
.statusbar-item { display: flex; align-items: center; gap: 6px; }
.statusbar-spacer { flex: 1; }

/* ═══════════════════════════════════════════════
   Login overlay
   ═══════════════════════════════════════════════ */
.login-overlay {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at top, #14141a 0%, var(--bg) 60%);
  display: grid; place-items: center;
  z-index: 1000;
  padding: 20px;
}
.login-overlay[hidden] { display: none !important; }
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 30px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 80px rgba(125,211,252,0.05);
}
.login-brand {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 24px;
}
.login-brand .brand-mark {
  width: 36px; height: 36px;
  font-size: 22px;
}
.login-brand .brand-text { font-size: 18px; }
.login-brand .brand-sub  { font-size: 12px; }

.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; }
.login-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--text-faint);
  text-transform: uppercase;
  font-weight: 600;
}
.login-form input {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 14px;
  font-size: 15px;
  border-radius: 6px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.login-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-error {
  background: rgba(248,113,113,0.06);
  border: 1px solid rgba(248,113,113,0.30);
  color: var(--err);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
}

.login-btn {
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  font-size: 15px;
}

.login-hint {
  margin-top: 18px;
  font-size: 11px;
  color: var(--text-faint);
  text-align: center;
  letter-spacing: 0.04em;
}

/* ═══════════════════════════════════════════════
   Role badge / logout
   ═══════════════════════════════════════════════ */
.role-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  padding: 3px 8px;
  border-radius: 3px;
  background: var(--panel-3);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.role-badge[data-role="admin"] {
  background: rgba(251,191,36,0.10);
  border-color: rgba(251,191,36,0.40);
  color: #fcd34d;
  text-shadow: 0 0 8px rgba(251,191,36,0.30);
}
.role-badge[data-role="child"] {
  background: var(--accent-soft);
  border-color: rgba(125,211,252,0.30);
  color: var(--accent-hi);
}

.btn-tiny {
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 4px;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 5px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.12s;
  padding: 0;
}
.icon-btn:hover {
  background: var(--hover);
  color: var(--text);
  border-color: var(--border-strong);
}

/* ═══════════════════════════════════════════════
   Monitor view (admin)
   ═══════════════════════════════════════════════ */
.monitor-content { display: flex; flex-direction: column; gap: 18px; }
.monitor-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.kpi {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
}
.kpi-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  font-weight: 600;
}
.kpi-val {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin-top: 4px;
}

.monitor-tests {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}
.monitor-test-row {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px;
}

.monitor-days { display: flex; flex-direction: column; gap: 8px; }
.monitor-day {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap;
}
.monitor-day:hover { border-color: var(--border-strong); background: var(--panel-3); }
.monitor-day-head {
  flex: 1; min-width: 200px;
  display: flex; flex-direction: column; gap: 4px;
}
.monitor-day-date { font-size: 14px; color: var(--text); font-weight: 600; }
.monitor-day-stats {
  display: flex; gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}
.monitor-day-actions { display: flex; gap: 6px; }

.monitor-detail {
  margin-top: 24px;
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  max-height: 60vh;
  overflow-y: auto;
}
.monitor-detail-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.monitor-detail-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}
.monitor-detail-body h1 { font-size: 18px; margin: 14px 0 8px; }
.monitor-detail-body h2 { font-size: 16px; margin: 12px 0 6px; color: var(--accent-hi); }
.monitor-detail-body h3 { font-size: 15px; margin: 10px 0 4px; }
.monitor-detail-body p { margin: 4px 0 8px; }
.monitor-detail-body strong { color: var(--accent-hi); }
.monitor-detail-body hr { border: 0; border-top: 1px dashed var(--border); margin: 12px 0; }
.monitor-detail-body code {
  background: var(--panel); padding: 1px 6px; border-radius: 3px; color: var(--accent-hi);
}

/* ═══════════════════════════════════════════════
   触屏 / iPad / 响应式
   ═══════════════════════════════════════════════ */

/* 触屏设备 (no hover): 用 .pinned 切换替代 :hover */
@media (hover: none) and (pointer: coarse) {
  .side:hover { background: var(--panel); overflow: hidden; }
  .side:hover .side-collapsed { opacity: 1; }
  .side:hover .side-expanded { opacity: 0; }
  .app:has(.side:hover) { --side-width: 52px; }
  .app:has(.side.pinned) { --side-width: 320px; }
  .side.pinned { background: var(--panel-2); overflow-y: auto; }
  .side.pinned .side-collapsed { opacity: 0; }
  .side.pinned .side-expanded { opacity: 1; }
  .side { cursor: pointer; }
}

/* iPad 竖屏 / 窄屏: 隐藏右栏 */
@media (max-width: 900px) {
  .app { --side-width: 0px !important; }
  .side { display: none; }
  /* 顶栏右侧只隐藏 live 时钟, 保留角色徽章 + 退出按钮可达 (iPad 必需) */
  .topbar-r .live { display: none; }
  /* 顶栏全屏按钮也可省, 节省空间 */
  .topbar-r #fullscreen-btn { display: none; }
}

/* monitor kpi grid 响应式 */
@media (max-width: 760px) {
  .monitor-kpis { grid-template-columns: repeat(2, 1fr); }
}

/* 手机 / 极窄: 左栏图标化 */
@media (max-width: 600px) {
  .app { --nav-width: 56px !important; }
  .nav { padding: 10px 6px; }
  .nav-label { display: none; }
  .nav-section, .nav-mini { display: none; }
  .brand-text, .brand-sub { display: none; }
  .crumb { padding: 0 12px; font-size: 12px; }
  .view { padding: 18px 16px; }
  .view-title { font-size: 22px; }
  .role-label { width: 60px; font-size: 11px; }
  .bubble { font-size: 15px; }
  .proposal { padding: 14px 16px; }
  .proposal-title { font-size: 17px; }
  .proposal-row { flex-direction: column; align-items: flex-start; }
  .test-result-score { font-size: 44px; }
}

/* 触屏: 加大可点击区域 */
@media (pointer: coarse) {
  .nav-item { padding: 12px 12px; }
  .mode-opt { padding: 8px 16px; }
  .btn-go, .btn-primary { padding: 12px 26px; }
  .send { padding: 10px 22px; }
  .peak { padding: 16px 18px; }
  .composer textarea { font-size: 16px; /* 防 iOS auto-zoom */ }
  .test-answer-input { font-size: 16px; }
}
