/* ==========================================================================
   "Nebula" — PDF 题库平台 design system
   Modern, student-friendly. Dark mode via prefers-color-scheme / [data-theme].
   ========================================================================== */

/* ---- design tokens ------------------------------------------------------ */
:root {
  /* brand */
  --accent: #6366f1;
  --accent-strong: #4f46e5;
  --accent-soft: #eef2ff;
  --accent-glow: rgba(99, 102, 241, 0.25);
  --accent2: #14b8a6;
  --accent2-soft: #ecfdf5;

  /* surface */
  --bg: #f8fafc;
  --bg-soft: #f1f5f9;
  --surface: #ffffff;
  --surface-hover: #f8fafc;
  --surface-elevated: #ffffff;

  /* text */
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  /* border */
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --border-focus: #a5b4fc;

  /* semantic */
  --green: #10b981;
  --green-soft: #ecfdf5;
  --green-border: #a7f3d0;
  --amber: #f59e0b;
  --amber-soft: #fffbeb;
  --amber-border: #fcd34d;
  --red: #ef4444;
  --red-soft: #fef2f2;
  --red-border: #fecaca;
  --blue: #3b82f6;
  --blue-soft: #eff6ff;

  /* radius */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 999px;

  /* shadows — layered for depth */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 6px rgba(15, 23, 42, 0.04), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 10px 15px rgba(15, 23, 42, 0.06), 0 4px 6px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 25px rgba(15, 23, 42, 0.06), 0 8px 10px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 25px 50px rgba(15, 23, 42, 0.12);

  /* glass */
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(226, 232, 240, 0.8);
  --glass-blur: saturate(180%) blur(20px);

  /* spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* animation */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 150ms;
  --duration: 250ms;
  --duration-slow: 400ms;
}

/* ---- dark theme --------------------------------------------------------- */
[data-theme="dark"] {
  --bg: #1a2236;
  --bg-soft: #222b42;
  --surface: #263148;
  --surface-hover: #2d3a54;
  --surface-elevated: #2d3a54;

  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0f172a;

  --border: #334155;
  --border-light: #1e293b;
  --border-focus: #6366f1;

  --accent-soft: #1e1b4b;
  --accent2-soft: #022c22;

  --green-soft: #022c22;
  --green-border: #065f46;
  --amber-soft: #451a03;
  --amber-border: #78350f;
  --red-soft: #450a0a;
  --red-border: #7f1d1d;
  --blue-soft: #172554;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.25), 0 2px 4px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 10px 15px rgba(0, 0, 0, 0.3), 0 4px 6px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 20px 25px rgba(0, 0, 0, 0.35), 0 8px 10px rgba(0, 0, 0, 0.2);
  --shadow-xl: 0 25px 50px rgba(0, 0, 0, 0.5);

  --glass-bg: rgba(30, 41, 59, 0.75);
  --glass-border: rgba(51, 65, 85, 0.8);

  --accent-glow: rgba(99, 102, 241, 0.35);
}

/* ---- reset & base ------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font: 14px/1.6 system-ui, -apple-system, "Segoe UI", "Inter", "Microsoft YaHei", sans-serif;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--duration) var(--ease-out), color var(--duration) var(--ease-out);
}

button, input, textarea, select { font: inherit; }

button { cursor: pointer; }

button:disabled, input:disabled, textarea:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

a { color: var(--accent); text-decoration: none; transition: color var(--duration-fast) var(--ease-out); }
a:hover { color: var(--accent-strong); }

/* ---- scrollbar (Webkit) ------------------------------------------------ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---- selection ---------------------------------------------------------- */
::selection { background: var(--accent-soft); color: var(--accent-strong); }

/* ---- focus ring --------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   Topbar — glass-morphism sticky header
   ========================================================================== */

.topbar-spa {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: 10px 20px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: 60px;
  transition: background var(--duration) var(--ease-out), border-color var(--duration) var(--ease-out);
}

.brand-link {
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.brand-link h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent) 0%, #8b5cf6 50%, var(--accent2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.3px;
}

.brand-link p {
  margin: 0;
  color: var(--text-muted);
  font-size: 11px;
  display: none;
}

@media (min-width: 640px) {
  .brand-link p { display: block; }
}

/* ---- primary nav (pill tabs) -------------------------------------------- */
.primary-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1 1 auto;
  justify-content: center;
}

.nav-link {
  text-decoration: none;
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--duration-fast) var(--ease-out);
  position: relative;
}

.nav-link:hover {
  color: var(--text);
  background: var(--bg-soft);
}

.nav-link.active {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: var(--border-focus);
  font-weight: 600;
}

/* ---- user chip ---------------------------------------------------------- */
.user-chip {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.user-chip .role-badge {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- theme toggle ------------------------------------------------------- */
.theme-toggle {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  font-size: 16px;
  transition: all var(--duration-fast) var(--ease-out);
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: var(--bg-soft);
  color: var(--text);
  border-color: var(--border-focus);
}

/* ==========================================================================
   Role badge
   ========================================================================== */

.role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-secondary);
  font-size: 13px;
  white-space: nowrap;
  transition: all var(--duration-fast) var(--ease-out);
}

body[data-role="user"] .role-badge {
  color: var(--green);
  border-color: var(--green-border);
  background: var(--green-soft);
}

body[data-role="super_root"] .role-badge,
body[data-role="subject_root"] .role-badge {
  color: var(--accent-strong);
  border-color: var(--border-focus);
  background: var(--accent-soft);
}

body[data-role="invalid"] .role-badge {
  color: var(--red);
  border-color: var(--red-border);
  background: var(--red-soft);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 16px;
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap;
  text-decoration: none;
}

.btn:hover:not(:disabled) {
  background: var(--bg-soft);
  border-color: var(--border-focus);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: none;
}

.btn.primary {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 100%);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.btn.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--accent-strong) 0%, #6d28d9 100%);
  box-shadow: 0 4px 16px var(--accent-glow);
  transform: translateY(-2px);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
}

.btn.ghost:hover:not(:disabled) {
  background: var(--bg-soft);
}

.btn.danger {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
  font-weight: 600;
}

.btn.danger:hover:not(:disabled) {
  background: #dc2626;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}

/* ==========================================================================
   Buttons — size variants
   ========================================================================== */

.btn-sm {
  min-height: 32px;
  padding: 5px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-lg {
  min-height: 46px;
  padding: 10px 24px;
  font-size: 15px;
  border-radius: var(--radius-lg);
}

/* ==========================================================================
   Form controls
   ========================================================================== */

input, textarea, select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  padding: 10px 12px;
  outline: none;
  transition: all var(--duration-fast) var(--ease-out);
  font-size: 14px;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

label { display: grid; gap: var(--space-xs); }
label > span { color: var(--text-secondary); font-size: 13px; font-weight: 500; }

.form-grid {
  display: grid;
  gap: var(--space);
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.form-grid > .form-row { grid-column: 1 / -1; }

.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
}

/* ---- check row ---------------------------------------------------------- */
.check-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.check-row input { width: auto; }

/* ==========================================================================
   Page shell
   ========================================================================== */

.page {
  padding: var(--space-lg);
  /* New shell (issue #47 step 1): main column is laid out by body grid;
     the page should fill it (no centered max-width creating right-side
     empty space on wide screens). */
  max-width: none;
  margin: 0;
  display: grid;
  gap: var(--space-md);
  animation: pageIn var(--duration-slow) var(--ease-out);
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  transition: all var(--duration) var(--ease-out);
}

.card:hover {
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 var(--space) 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.card .muted {
  color: var(--text-muted);
  font-size: 13px;
}

.card hr {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: var(--space-md) 0;
}

/* ---- card variants ------------------------------------------------------ */
.card-glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
}

.card-accent {
  border-left: 3px solid var(--accent);
}

/* ==========================================================================
   Tiles (subject-home dashboard)
   ========================================================================== */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
}

.tile {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--duration) var(--ease-spring);
  position: relative;
  overflow: hidden;
}

.tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent) 0%, #8b5cf6 100%);
  opacity: 0;
  transition: opacity var(--duration) var(--ease-out);
  border-radius: var(--radius-lg);
}

.tile:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-focus);
}

.tile:hover::before {
  opacity: 0.03;
}

.tile h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  position: relative;
  z-index: 1;
}

.tile-num {
  font-size: 36px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent) 0%, #8b5cf6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: var(--space-sm) 0;
  position: relative;
  z-index: 1;
  line-height: 1.2;
}

.tile p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  position: relative;
  z-index: 1;
}

/* ==========================================================================
   Paper list & hit cards
   ========================================================================== */

.paper-list, .history-list, .result-list {
  display: grid;
  gap: var(--space-sm);
  margin-top: var(--space);
}

.paper-item, .history-item, .hit {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px 14px;
  transition: all var(--duration-fast) var(--ease-out);
  text-decoration: none;
  color: inherit;
  display: block;
}

.paper-item:hover, .hit:hover {
  border-color: var(--border-focus);
  background: var(--accent-soft);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.paper-item.active {
  border-color: var(--border-focus);
  background: var(--accent-soft);
  box-shadow: var(--shadow-sm);
}

.item-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 700;
  font-size: 14px;
}

.item-meta {
  margin-top: var(--space-xs);
  color: var(--text-muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

/* ---- hit card (search results) ----------------------------------------- */
.hit {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.hit.clickable { cursor: pointer; }

.hit img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  background: var(--bg-soft);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  transition: transform var(--duration-fast) var(--ease-out);
}

.hit:hover img { transform: scale(1.05); }

.hit-main { min-width: 0; }

.hit-main strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.hit-sub {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: var(--space-xs);
}

/* ==========================================================================
   Badges
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--duration-fast) var(--ease-out);
}

.badge.matched, .badge.ok, .badge.user {
  background: var(--green-soft);
  color: var(--green);
}

.badge.ambiguous, .badge.warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge.no_match {
  background: var(--red-soft);
  color: var(--red);
}

.badge.root {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

/* ==========================================================================
   Status pills & lines
   ========================================================================== */

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-full);
  padding: 3px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--duration-fast) var(--ease-out);
}

.status-pill.ok    { color: var(--green); background: var(--green-soft); }
.status-pill.error { color: var(--red);   background: var(--red-soft); }
.status-pill.warn  { color: var(--amber); background: var(--amber-soft); }

.status-line {
  display: flex;
  align-items: center;
  min-height: 44px;
  margin-bottom: var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px 14px;
  color: var(--text-secondary);
  font-size: 13px;
  transition: all var(--duration-fast) var(--ease-out);
}

.status-line.ok {
  color: var(--green);
  background: var(--green-soft);
  border-color: var(--green-border);
}

.status-line.warn {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: var(--amber-border);
}

.status-line.error {
  color: var(--red);
  background: var(--red-soft);
  border-color: var(--red-border);
}

/* ---- page alerts -------------------------------------------------------- */
.page-error {
  border: 1px solid var(--red-border);
  background: var(--red-soft);
  color: var(--red);
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 13px;
}

.page-warning {
  border: 1px solid var(--amber-border);
  background: var(--amber-soft);
  color: var(--amber);
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 13px;
}

/* ==========================================================================
   Empty state
   ========================================================================== */

.empty-state {
  display: grid;
  place-items: center;
  min-height: 200px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-soft);
  color: var(--text-muted);
  text-align: center;
  padding: var(--space-lg);
  font-size: 14px;
}

/* ==========================================================================
   Image viewer — zoom/pan replacement for static images
   ========================================================================== */

.image-panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-soft);
  transition: all var(--duration) var(--ease-out);
  position: relative;
}

.image-panel h3 {
  margin: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.image-panel.empty {
  min-height: 240px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* zoomable container */
.zoom-container {
  position: relative;
  overflow: hidden;
  cursor: zoom-in;
  background: var(--bg-soft);
  display: grid;
  place-items: center;
  min-height: 200px;
  max-height: 72vh;
  touch-action: none;
}

.zoom-container img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 72vh;
  object-fit: contain;
  transition: transform var(--duration-fast) var(--ease-out);
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.zoom-container.zoomed {
  cursor: grab;
  overflow: auto;
}

.zoom-container.zoomed:active {
  cursor: grabbing;
}

.zoom-container.zoomed img {
  max-height: none;
  width: auto;
  min-width: 100%;
}

/* zoom controls */
.zoom-controls {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
  z-index: 10;
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out);
}

.image-panel:hover .zoom-controls,
.zoom-container.zoomed .zoom-controls {
  opacity: 1;
}

.zoom-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  box-shadow: var(--shadow-sm);
}

.zoom-btn:hover {
  background: var(--bg-soft);
  border-color: var(--border-focus);
  transform: scale(1.05);
}

/* ==========================================================================
   Lightbox overlay
   ========================================================================== */

.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: var(--space-lg);
  animation: fadeIn var(--duration) var(--ease-out);
  cursor: zoom-out;
}

.lightbox-overlay img {
  max-width: 95vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: var(--shadow-xl);
  cursor: grab;
  user-select: none;
  -webkit-user-drag: none;
  transition: transform var(--duration-fast) var(--ease-out);
}

.lightbox-overlay img:active {
  cursor: grabbing;
}

.lightbox-close {
  position: fixed;
  top: var(--space-md);
  right: var(--space-md);
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-full);
  background: rgba(30, 41, 59, 0.8);
  color: #fff;
  font-size: 22px;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 1001;
  transition: all var(--duration-fast) var(--ease-out);
  backdrop-filter: blur(12px);
}

.lightbox-close:hover {
  background: rgba(239, 68, 68, 0.8);
  border-color: rgba(239, 68, 68, 0.5);
  transform: scale(1.08);
}

.lightbox-info {
  position: fixed;
  bottom: var(--space-md);
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-full);
  padding: 6px 16px;
  backdrop-filter: blur(12px);
  z-index: 1001;
}

/* ==========================================================================
   Viewer grid
   ========================================================================== */

.viewer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-md);
}

.viewer-grid.four {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 1024px) {
  .viewer-grid.four {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* ==========================================================================
   Workspace (legacy split-pane)
   ========================================================================== */

.shell {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  min-height: calc(100vh - 60px);
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow: auto;
  max-height: calc(100vh - 60px);
  transition: background var(--duration) var(--ease-out);
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 12px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border);
}

.tab {
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 8px 10px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 500;
  transition: all var(--duration-fast) var(--ease-out);
}

.tab.active {
  color: var(--text);
  background: var(--bg-soft);
  border-color: var(--border);
  font-weight: 600;
}

.tab:hover:not(.active) {
  color: var(--text);
  background: var(--surface-hover);
}

.panel {
  display: none;
  padding: 14px;
}

.panel.active {
  display: grid;
  gap: 14px;
}

.workspace {
  min-width: 0;
  padding: var(--space-md);
  overflow: auto;
  max-height: calc(100vh - 60px);
}

/* ---- tool blocks -------------------------------------------------------- */
.tool-block {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
  transition: all var(--duration) var(--ease-out);
}

.block-title, .pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space);
  margin-bottom: var(--space);
  flex-wrap: wrap;
}

.block-title h2, .pane-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.block-title span, .pane-head span {
  color: var(--text-muted);
  font-size: 12px;
}

/* ---- paper summary ------------------------------------------------------ */
.paper-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  padding: 14px;
  flex-wrap: wrap;
}

/* ---- question buttons --------------------------------------------------- */
.question-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: var(--space-sm);
}

.question-button {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  min-height: 44px;
  font-weight: 600;
  font-size: 13px;
  transition: all var(--duration-fast) var(--ease-out);
}

.question-button:hover {
  background: var(--accent-soft);
  border-color: var(--border-focus);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.question-button.no-answer {
  background: var(--amber-soft);
  border-color: var(--amber-border);
}

/* ---- drop zone (ingest) ------------------------------------------------ */
.drop-zone {
  position: relative;
  min-width: 0;
  display: grid;
  place-items: center;
  min-height: 200px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-soft);
  padding: var(--space-lg);
  outline: none;
  cursor: pointer;
  transition: all var(--duration) var(--ease-out);
}

.drop-zone:hover {
  border-color: var(--border-focus);
  background: var(--accent-soft);
}

.drop-zone.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.drop-zone input { display: none; }

.drop-copy {
  display: grid;
  gap: var(--space-xs);
  text-align: center;
  color: var(--text-muted);
  pointer-events: none;
}

.drop-copy strong {
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
}

.drop-zone.has-image .drop-copy { display: none; }

#imagePreview {
  display: block;
  max-width: 100%;
  max-height: 280px;
  object-fit: contain;
  background: var(--surface);
  border-radius: var(--radius-sm);
}

#imagePreview[hidden] { display: none !important; }

/* ==========================================================================
   Pill tabs (search mode switcher etc.)
   ========================================================================== */

.tabs.three {
  display: inline-flex;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 4px;
  background: var(--bg-soft);
}

.tabs.three .tab {
  border: none;
  border-radius: var(--radius-full);
  padding: 7px 18px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13px;
  transition: all var(--duration-fast) var(--ease-out);
}

.tabs.three .tab.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.tabs.three .tab:hover:not(.active) {
  color: var(--text);
}

/* ==========================================================================
   Data table
   ========================================================================== */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th, .data-table td {
  border-bottom: 1px solid var(--border-light);
  padding: 10px 14px;
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  background: var(--bg-soft);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table tbody tr {
  transition: background var(--duration-fast) var(--ease-out);
}

.data-table tbody tr:hover {
  background: var(--surface-hover);
}

/* ---- bar cell (trends chart) ------------------------------------------- */
.bar-cell {
  position: relative;
  height: 22px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
  min-width: 80px;
}

.bar-cell .bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, #8b5cf6 100%);
  border-radius: var(--radius-sm);
  transition: width var(--duration-slow) var(--ease-out);
}

.bar-cell span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 11px;
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Point tree
   ========================================================================== */

.tree, .tree ul {
  list-style: none;
  padding-left: 20px;
  margin: 0;
}

.tree > li {
  padding: 5px 0;
  font-size: 14px;
}

.point-tree details > summary {
  cursor: pointer;
  padding: 6px 0;
  font-weight: 500;
  color: var(--text);
  transition: color var(--duration-fast) var(--ease-out);
}

.point-tree details > summary:hover {
  color: var(--accent);
}

.point-tree details > summary code {
  font-weight: 700;
  color: var(--accent-strong);
  background: var(--accent-soft);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

/* ==========================================================================
   KV list
   ========================================================================== */

.kv {
  display: grid;
  gap: var(--space-sm);
  margin: var(--space-sm) 0;
  font-size: 13px;
}

.kv strong {
  color: var(--text-secondary);
}

/* ==========================================================================
   JSON / code output
   ========================================================================== */

.json-output {
  margin: 0;
  max-height: 500px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px;
  font-size: 12px;
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
  line-height: 1.7;
}

[data-theme="dark"] .json-output {
  background: #020617;
  color: #cbd5e1;
}

/* ==========================================================================
   Spinner
   ========================================================================== */

.spinner {
  width: 20px;
  height: 20px;
  display: inline-block;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: var(--radius-full);
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---- skeleton loading --------------------------------------------------- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-soft) 25%, var(--border-light) 50%, var(--bg-soft) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 14px;
  margin-bottom: var(--space-sm);
}

.skeleton-title {
  height: 22px;
  width: 60%;
  margin-bottom: var(--space);
}

.skeleton-card {
  height: 80px;
  border-radius: var(--radius);
}

.skeleton-img {
  height: 200px;
  border-radius: var(--radius);
}

/* ==========================================================================
   Actions row
   ========================================================================== */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space);
}

.actions.compact {
  margin-top: 0;
  justify-content: flex-end;
}

/* ---- file row ----------------------------------------------------------- */
.file-row {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.file-row span {
  color: var(--text-muted);
  font-size: 12px;
}

/* ---- history ------------------------------------------------------------ */
.history-item {
  display: grid;
  gap: var(--space-sm);
}

.history-actions {
  display: flex;
  justify-content: flex-end;
}

/* ---- root lock ---------------------------------------------------------- */
.root-lock {
  display: none;
  border: 1px solid var(--amber-border);
  border-radius: var(--radius);
  background: var(--amber-soft);
  color: #92400e;
  padding: 14px;
  font-size: 13px;
}

body:not([data-role="super_root"]):not([data-role="subject_root"]) .root-lock {
  display: block;
}

body:not([data-role="super_root"]):not([data-role="subject_root"]) .root-only {
  display: none;
}

/* ---- subject banner ----------------------------------------------------- */
.subject-banner h2 {
  margin-bottom: var(--space-xs);
}

/* ==========================================================================
   Login page — full-viewport image background, floating glass card.
   ========================================================================== */

body.on-login-page {
  background: #e8e0d0; /* arm3 cream fallback */
}

body.on-login-page .topbar-spa,
body.on-login-page .topbar-lang {
  display: none;
}

/* cnb#16:登录页 topbar 工具栏全隐(用户:登录页不要 tools,只有进去才发现)*/
body.on-login-page .topbar-cmdk-trigger,
body.on-login-page .topbar-tools-slot,
body.on-login-page .topbar-icon-btn,
body.on-login-page .topbar-bell,
body.on-login-page .topbar-help,
body.on-login-page .topbar-burger {
  display: none !important;
}

/* ===== 登录页美化 - arm3 风格 (2026-05-13 feat/login-beautify) ============
   layers (bottom→top):
     sky-bg (cream gradient) → paper-texture → clouds → canvas particles
     → lanterns → mascots → form
   References: /home/oracle/workspace/global/video/promo.html on arm3
================================================================== */
.login-sky-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: linear-gradient(180deg,#fef9ee 0%,#faf4e6 15%,#f5ecda 50%,#efe4cf 85%,#e8dcc4 100%);
}
.login-paper-texture {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 20% 80%,rgba(139,100,40,0.06) 0%,transparent 50%),
    radial-gradient(ellipse at 80% 20%,rgba(139,100,40,0.04) 0%,transparent 50%),
    radial-gradient(ellipse at 50% 50%,rgba(200,180,140,0.04) 0%,transparent 70%);
}
[data-theme="dark"] .login-sky-bg {
  background: linear-gradient(180deg,#1a1408 0%,#221a0c 50%,#2a2010 100%);
}
[data-theme="dark"] .login-paper-texture {
  background:
    radial-gradient(ellipse at 20% 80%,rgba(180,140,80,0.08) 0%,transparent 50%),
    radial-gradient(ellipse at 80% 20%,rgba(180,140,80,0.06) 0%,transparent 50%);
}

/* ---- 粒子 canvas (arm3 风:formulas + sparks 上升,代替气泡) ------------- */
.login-particles-canvas {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* ---- 飘云(arm3 cream)--------------------------------------------------- */
.login-cloud {
  position: fixed;
  z-index: 2;
  border-radius: 50%;
  background: rgba(220,210,180,0.25);
  box-shadow:
    30px -10px 0 rgba(220,210,180,0.2),
    55px 0 0 rgba(220,210,180,0.18),
    35px 15px 0 rgba(220,210,180,0.22),
    18px 10px 0 rgba(220,210,180,0.25);
  animation: cloudDriftArm3 22s ease-in-out infinite;
  pointer-events: none;
}
.login-cloud-1 { width: 60px; height: 28px; top: 8%;  left: 5%;   animation-delay: 0s; }
.login-cloud-2 { width: 75px; height: 32px; top: 14%; right: 12%; animation-delay: -8s; }
.login-cloud-3 { width: 50px; height: 22px; top: 38%; left: 18%;  animation-delay: -14s; }
@keyframes cloudDriftArm3 {
  0%   { transform: translateX(0) scale(1); }
  50%  { transform: translateX(25px) scale(1.06); }
  100% { transform: translateX(0) scale(1); }
}

/* ---- 顶部两侧红灯笼 (arm3 尺寸:小巧 11x16px,但放大到 28x40 用于桌面) ----- */
.login-lantern {
  position: fixed;
  z-index: 4;
  width: 28px; height: 40px;
  background: radial-gradient(ellipse at 50% 40%, #e85d5d, #c43a3a);
  border-radius: 50% 50% 45% 45%;
  box-shadow: 0 0 18px rgba(196,58,58,0.35);
  transform-origin: top center;
  pointer-events: none;
}
.login-lantern::before {
  content: ""; position: absolute;
  top: -12px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 14px; background: #b8861e;
}
.login-lantern::after {
  content: ""; position: absolute;
  bottom: -8px; left: 50%; transform: translateX(-50%);
  width: 10px; height: 5px; background: #b8861e;
  border-radius: 2px;
}
.login-lantern-l1 {
  top: 4%; left: 3%;
  animation: lanternSway 3s ease-in-out infinite;
}
.login-lantern-l2 {
  top: 4%; right: 3%;
  animation: lanternSway 3s ease-in-out infinite -1.5s;
}
@keyframes lanternSway {
  0%, 100% { transform: rotate(-5deg); }
  50%      { transform: rotate(5deg); }
}

/* ---- 三动物 mascots(panda + monkey + fox)on the LEFT half ------------- */
.login-hero {
  position: relative;
  z-index: 3;
}
.login-mascot {
  position: absolute;
  /* 垂直对齐右侧登录框中心(viewport 中线) */
  top: 50%;
  margin-top: -90px; /* SVG 高度的一半,做视觉居中 */
  filter: drop-shadow(0 8px 18px rgba(0,0,0,0.18));
  animation: mascotBounce 2.5s ease-in-out infinite;
  pointer-events: none;
}
/* 三只动物 SVG 放大到 ~150px 宽 */
.login-mascot svg {
  width: 150px;
  height: 175px;
}
/* 紧贴 hero 右边缘(贴近右侧登录框),从右到左依次:fox → monkey → panda */
.login-fox    { right:  20px; animation-delay: -0.8s; }
.login-monkey { right: 190px; animation-delay: -0.4s; }
.login-panda  { right: 360px; animation-delay: 0s; }
@keyframes mascotBounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-12px); }
}

/* ---- 对话气泡:三只动物轮流说话(panda→monkey→fox 一个 9s 循环)----- */
.login-speech {
  position: absolute;
  bottom: 100%;
  margin-bottom: 8px;
  left: 50%;
  background: #fff;
  color: #2c2416;
  padding: 8px 14px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(139,100,40,0.18);
  border: 1px solid rgba(184,134,30,0.2);
  opacity: 0;
  transform: translateX(-50%) scale(0.92);
  animation: speechTakeTurn 9s ease-in-out infinite;
  pointer-events: none;
}
.login-speech::after {
  content: "";
  position: absolute;
  bottom: -7px; left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 9px solid #fff;
}
/* 三只动物错峰:每只各说 3s,无重叠 */
.login-speech-panda  { animation-delay: 0s;  }
.login-speech-monkey { animation-delay: -6s; }
.login-speech-fox    { animation-delay: -3s; }
@keyframes speechTakeTurn {
  0%        { opacity: 0; transform: translateX(-50%) scale(0.92); }
  4%        { opacity: 1; transform: translateX(-50%) scale(1.04); }
  8%, 28%   { opacity: 1; transform: translateX(-50%) scale(1); }
  33%, 100% { opacity: 0; transform: translateX(-50%) scale(0.92); }
}

/* ---- arm3 风四角金色 L 装饰 -------------------------------------------- */
.login-corner-accent {
  position: fixed;
  width: 32px;
  height: 32px;
  z-index: 4;
  pointer-events: none;
  border-color: rgba(184,134,30,0.45);
  border-style: solid;
}
.login-corner-tl { top: 14px;    left: 14px;    border-width: 2px 0 0 2px; }
.login-corner-tr { top: 14px;    right: 14px;   border-width: 2px 2px 0 0; }
.login-corner-bl { bottom: 14px; left: 14px;    border-width: 0 0 2px 2px; }
.login-corner-br { bottom: 14px; right: 14px;   border-width: 0 2px 2px 0; }
[data-theme="dark"] .login-corner-accent {
  border-color: rgba(212,168,67,0.55);
}

/* ---- SVG transform 修正:CSS transform-origin 在 SVG 元素上需要 fill-box -
   否则 'center' 会指向 SVG 根原点,scaleY 眨眼会变成整张脸跳动。
   ---------------------------------------------------------------------- */
.panda-ear-left, .panda-ear-right,
.panda-eye-left, .panda-eye-right,
.panda-arm-left,
.monkey-tail, .monkey-ear-left, .monkey-ear-right,
.monkey-head, .monkey-eye-left, .monkey-eye-right, .monkey-arm-right,
.fox-tail, .fox-ear-left, .fox-ear-right,
.fox-eye-left, .fox-eye-right, .fox-nose {
  transform-box: fill-box;
  transform-origin: center;
}

/* ---- 熊猫子部件动画 ----------------------------------------------------- */
.panda-ear-left  { animation: earWiggleL 3.5s ease-in-out infinite; }
.panda-ear-right { animation: earWiggleR 3.5s ease-in-out infinite -1s; }
@keyframes earWiggleL { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-8deg); } }
@keyframes earWiggleR { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(8deg); } }
.panda-eye-left, .panda-eye-right { animation: pandaBlink 4s ease-in-out infinite; }
.panda-eye-right { animation-delay: -0.15s; }
@keyframes pandaBlink {
  0%, 92%, 100% { transform: scaleY(1); }
  94%, 98%      { transform: scaleY(0.1); }
}
.panda-arm-left { animation: pandaWave 2s ease-in-out infinite; }
@keyframes pandaWave {
  0%, 100% { transform: rotate(0); }
  25%      { transform: rotate(-25deg); }
  75%      { transform: rotate(15deg); }
}

/* ---- 金丝猴子部件动画 --------------------------------------------------- */
.monkey-tail { animation: monkeyTailCurl 2.5s ease-in-out infinite; }
@keyframes monkeyTailCurl {
  0%, 100% { transform: rotate(-2deg); }
  50%      { transform: rotate(6deg); }
}
.monkey-ear-left  { animation: monkeyEarFlick 3.5s ease-in-out infinite; }
.monkey-ear-right { animation: monkeyEarFlick 3.5s ease-in-out infinite -1.5s; }
@keyframes monkeyEarFlick {
  0%, 100% { transform: rotate(0); }
  50%      { transform: rotate(5deg); }
}
.monkey-head { animation: monkeyHeadTilt 4s ease-in-out infinite; }
@keyframes monkeyHeadTilt {
  0%, 100% { transform: rotate(-2deg); }
  50%      { transform: rotate(2deg); }
}
.monkey-eye-left, .monkey-eye-right { animation: monkeyBlink 3.8s ease-in-out infinite; }
.monkey-eye-right { animation-delay: -0.1s; }
@keyframes monkeyBlink {
  0%, 92%, 100% { transform: scaleY(1); }
  94%, 98%      { transform: scaleY(0.1); }
}
.monkey-arm-right { animation: monkeyArmSwing 3s ease-in-out infinite; }
@keyframes monkeyArmSwing {
  0%, 100% { transform: rotate(0); }
  50%      { transform: rotate(-15deg); }
}

/* ---- 狐狸子部件动画 ----------------------------------------------------- */
.fox-tail { animation: tailWag 0.8s ease-in-out infinite; }
@keyframes tailWag {
  0%, 100% { transform: rotate(-8deg); }
  50%      { transform: rotate(15deg); }
}
.fox-ear-left  { animation: foxEarTwitch 3s ease-in-out infinite; }
.fox-ear-right { animation: foxEarTwitch 3s ease-in-out infinite -1.5s; }
@keyframes foxEarTwitch {
  0%, 100% { transform: rotate(0); }
  50%      { transform: rotate(6deg); }
}
.fox-eye-left, .fox-eye-right { animation: foxBlink 4.5s ease-in-out infinite; }
.fox-eye-right { animation-delay: -0.12s; }
@keyframes foxBlink {
  0%, 90%, 100% { transform: scaleY(1); }
  93%, 97%      { transform: scaleY(0.1); }
}
.fox-nose { animation: foxSniff 2s ease-in-out infinite; }
@keyframes foxSniff {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(0.5px); }
}

/* ---- 移动端:动物缩小,只留两只(panda + fox);灯笼缩小 -------------- */
@media (max-width: 800px) {
  .login-mascot svg { width: 90px; height: 105px; }
  .login-monkey { display: none; }
  .login-fox    { right: 8px; }
  .login-panda  { right: 110px; }
  .login-speech { font-size: 11px; padding: 5px 10px; bottom: 110px; }
  .login-lantern { width: 20px; height: 28px; }
}

/* ---- arm3 peek-monkey:小金丝猴趴登录框右上角探头(参照 promo.html)------ */
.peek-monkey {
  position: absolute;
  top: -30px;
  right: -18px;
  width: 72px;
  height: 68px;
  z-index: 5;
  pointer-events: none;
  animation: peekBounce 2.2s ease-in-out infinite;
}
@keyframes peekBounce {
  0%, 100% { transform: translateY(0); }
  40%      { transform: translateY(-6px); }
  60%      { transform: translateY(-3px); }
}
.peek-arm,
.peek-eye-left,
.peek-eye-right,
.peek-monkey .sparkle {
  transform-box: fill-box;
}
.peek-arm {
  transform-origin: center bottom;
  animation: peekWave 1.5s ease-in-out infinite;
}
@keyframes peekWave {
  0%, 100% { transform: rotate(0); }
  30%      { transform: rotate(-30deg); }
  55%      { transform: rotate(-30deg); }
  80%      { transform: rotate(-5deg); }
}
.peek-eye-left,
.peek-eye-right {
  transform-origin: center;
  animation: peekBlink 3.2s ease-in-out infinite;
}
.peek-eye-right { animation-delay: -0.1s; }
@keyframes peekBlink {
  0%, 92%, 100% { transform: scaleY(1); }
  95%           { transform: scaleY(0.1); }
}
.peek-monkey .sparkle {
  transform-origin: center;
  animation: sparklePop 1.8s ease-in-out infinite;
}
.peek-monkey .sparkle:nth-of-type(2) { animation-delay: -0.6s; }
.peek-monkey .sparkle:nth-of-type(3) { animation-delay: -1.2s; }
@keyframes sparklePop {
  0%, 100% { opacity: 0; transform: scale(0); }
  50%      { opacity: 1; transform: scale(1); }
}

/* ===== 登录页美化 END ================================================== */

body.on-login-page .page {
  padding: 0;
  max-width: none;
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  position: relative;
  overflow: hidden;
}

/* ---- hero panel (left) — brand text over the image --------------------- */
.login-hero {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
}

.login-hero-content {
  text-align: center;
  color: #0f172a;
  padding: var(--space-xl);
  max-width: 480px;
  animation: heroFadeIn 1.2s var(--ease-out) 0.3s both;
  /* leave space for mascots at the bottom */
  padding-bottom: 220px;
}
[data-theme="dark"] .login-hero-content { color: #f1f5f9; }

@keyframes heroFadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-hero-content h1 {
  margin: 0 0 var(--space-md) 0;
  font-size: 36px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.5px;
  text-shadow: 0 2px 12px rgba(255,255,255,0.5);
}
[data-theme="dark"] .login-hero-content h1 { text-shadow: 0 2px 24px rgba(0,0,0,0.5); }

.login-hero-content p {
  margin: 0;
  font-size: 16px;
  opacity: 0.92;
  line-height: 1.6;
  text-shadow: 0 1px 4px rgba(255,255,255,0.4);
}
[data-theme="dark"] .login-hero-content p { text-shadow: 0 1px 8px rgba(0,0,0,0.4); }

.login-hero-content .hero-logo {
  font-size: 52px;
  margin-bottom: var(--space-lg);
  display: inline-block;
  animation: logoFloat 3s var(--ease-in-out) infinite;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.3));
}

/* ---- right panel — glass form floating over the image ------------------ */
.login-form-panel {
  display: grid;
  place-items: center;
  padding: var(--space-xl);
  /* 整体下移 — 用户:登录卡太高,往下挪 */
  padding-top: 18vh;
  z-index: 3;
  position: relative;
}

body.on-login-page .login-card {
  z-index: 1;
  position: relative;
  /* peek-monkey 头要伸出登录框外 — 覆盖基类的 overflow:hidden */
  overflow: visible;
  max-width: 420px;
  width: 100%;
  animation: heroFadeIn 0.8s var(--ease-out) 0.5s both;
  /* glass — semi-transparent so the image shows through subtly */
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.12), 0 2px 8px rgba(15, 23, 42, 0.06);
}

[data-theme="dark"] body.on-login-page .login-card {
  background: rgba(30, 41, 59, 0.68);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* fade out the card's own star BG when over the full-page image */
body.on-login-page .login-card::before { opacity: 0.3; }
body.on-login-page .login-card .login-glow { opacity: 0.5; }

/* ---- shooting stars overlay (both panels) ------------------------------ */
.login-particles {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.login-particles .shooting-star {
  position: fixed;
}

/* ---- login utilities bar ----------------------------------------------- */
.login-utils {
  position: fixed;
  top: var(--space-md);
  right: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  z-index: 10;
}

.login-theme-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  font-size: 15px;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.login-theme-btn:hover {
  background: var(--bg-soft);
  border-color: var(--border-focus);
  color: var(--text);
}

/* ---- responsive — stack on mobile -------------------------------------- */
@media (max-width: 800px) {
  body.on-login-page .page {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .login-hero {
    min-height: 180px;
    max-height: 260px;
  }

  .login-hero-content h1 {
    font-size: 22px;
  }

  .login-hero-content p {
    font-size: 13px;
    display: none;
  }

  .login-hero-content .hero-logo {
    font-size: 32px;
    margin-bottom: var(--space-sm);
  }

  .login-form-panel {
    padding: var(--space-md);
    align-items: start;
    padding-top: var(--space-lg);
  }
}

/* ---- keep old card styles (non-login pages) ---------------------------- */
.login-card {
  max-width: 420px;
  width: 100%;
  padding: var(--space-xl) var(--space-lg);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  isolation: isolate;
}

/* ---- starry sky inside the card ---------------------------------------- */
.login-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    /* bright white-blue stars */
    radial-gradient(1px 1px at 8% 12%, rgba(203,213,225,0.9) 50%, transparent 50%),
    radial-gradient(0.7px 0.7px at 15% 22%, rgba(226,232,240,0.75) 50%, transparent 50%),
    radial-gradient(1.1px 1.1px at 22% 8%,  rgba(255,255,255,0.85) 50%, transparent 50%),
    radial-gradient(0.6px 0.6px at 28% 32%, rgba(203,213,225,0.7) 50%, transparent 50%),
    radial-gradient(0.9px 0.9px at 35% 15%, rgba(226,232,240,0.8) 50%, transparent 50%),
    radial-gradient(0.5px 0.5px at 42% 28%, rgba(255,255,255,0.7) 50%, transparent 50%),
    radial-gradient(1px 1px at 50% 5%,  rgba(203,213,225,0.85) 50%, transparent 50%),
    radial-gradient(0.8px 0.8px at 58% 18%, rgba(226,232,240,0.75) 50%, transparent 50%),
    radial-gradient(1.1px 1.1px at 65% 35%, rgba(255,255,255,0.8) 50%, transparent 50%),
    radial-gradient(0.6px 0.6px at 72% 12%, rgba(203,213,225,0.7) 50%, transparent 50%),
    radial-gradient(0.9px 0.9px at 78% 25%, rgba(226,232,240,0.8) 50%, transparent 50%),
    radial-gradient(0.5px 0.5px at 85% 8%,  rgba(255,255,255,0.7) 50%, transparent 50%),
    radial-gradient(1px 1px at 92% 30%, rgba(203,213,225,0.85) 50%, transparent 50%),
    radial-gradient(0.7px 0.7px at 95% 18%, rgba(226,232,240,0.75) 50%, transparent 50%),
    radial-gradient(0.6px 0.6px at 18% 38%, rgba(203,213,225,0.7) 50%, transparent 50%),
    radial-gradient(0.9px 0.9px at 55% 38%, rgba(226,232,240,0.7) 50%, transparent 50%),
    radial-gradient(0.7px 0.7px at 82% 38%, rgba(203,213,225,0.65) 50%, transparent 50%),
    radial-gradient(0.5px 0.5px at 3% 5%,   rgba(255,255,255,0.75) 50%, transparent 50%),
    radial-gradient(0.8px 0.8px at 48% 35%, rgba(226,232,240,0.7) 50%, transparent 50%),
    /* colored accent stars */
    radial-gradient(1.2px 1.2px at 40% 10%,  rgba(99,102,241,0.7) 50%, transparent 50%),
    radial-gradient(1.2px 1.2px at 70% 20%,  rgba(139,92,246,0.65) 50%, transparent 50%),
    radial-gradient(1px 1px at 88% 15%, rgba(20,184,166,0.6) 50%, transparent 50%),
    radial-gradient(1.2px 1.2px at 12% 25%,  rgba(99,102,241,0.6) 50%, transparent 50%),
    radial-gradient(0.9px 0.9px at 33% 30%,  rgba(139,92,246,0.5) 50%, transparent 50%),
    radial-gradient(1px 1px at 90% 35%,  rgba(20,184,166,0.55) 50%, transparent 50%);
  animation: starsTwinkle 3s ease-in-out infinite;
}

@keyframes starsTwinkle {
  0%, 100% { opacity: 0.75; }
  33% { opacity: 1; }
  66% { opacity: 0.82; }
}

/* ---- shooting stars — DOM elements (multiple, continuous) -------------- */
.shooting-star {
  position: absolute;
  z-index: 0;
  pointer-events: none;
  height: 1.5px;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0) 15%, rgba(226,232,240,0.9) 35%, rgba(255,255,255,1) 50%, rgba(226,232,240,0.6) 65%, transparent 100%);
  border-radius: 1px;
  transform: rotate(-28deg);
  box-shadow: 0 0 8px 2px rgba(226,232,240,0.3), 0 0 16px 4px rgba(203,213,225,0.18);
}

.shooting-star:nth-child(1) { top: 15%; left: -10%; width: 90px; animation: shoot1 3.5s linear infinite; }
.shooting-star:nth-child(2) { top: 5%;  left: -10%; width: 70px; animation: shoot2 4.2s linear infinite; animation-delay: 1.8s; }
.shooting-star:nth-child(3) { top: 30%; left: -10%; width: 100px; animation: shoot3 5s linear infinite; animation-delay: 3s; }

.shooting-star::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 45%;
  width: 4px;
  height: 4px;
  background: rgba(255,255,255,0.95);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 10px 3px rgba(226,232,240,0.5);
}

@keyframes shoot1 {
  0%   { transform: rotate(-28deg) translate(0, 0); opacity: 0; }
  3%   { opacity: 1; }
  18%  { transform: rotate(-28deg) translate(550px, 280px); opacity: 0; }
  100% { transform: rotate(-28deg) translate(550px, 280px); opacity: 0; }
}
@keyframes shoot2 {
  0%   { transform: rotate(-28deg) translate(0, 0); opacity: 0; }
  3%   { opacity: 1; }
  16%  { transform: rotate(-28deg) translate(520px, 220px); opacity: 0; }
  100% { transform: rotate(-28deg) translate(520px, 220px); opacity: 0; }
}
@keyframes shoot3 {
  0%   { transform: rotate(-28deg) translate(0, 0); opacity: 0; }
  2%   { opacity: 1; }
  14%  { transform: rotate(-28deg) translate(480px, 260px); opacity: 0; }
  100% { transform: rotate(-28deg) translate(480px, 260px); opacity: 0; }
}

/* remove old single shooting star pseudo-element */
.login-card::after { display: none; }

/* soft radial glow behind the form — AI ambient feel */
.login-card .login-glow {
  content: "";
  position: absolute;
  top: -60%;
  left: -30%;
  width: 160%;
  height: 160%;
  background: radial-gradient(ellipse at 50% 0%, var(--accent-soft) 0%, transparent 70%);
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
  transition: opacity var(--duration-slow) var(--ease-out);
}

[data-theme="dark"] .login-card .login-glow {
  background: radial-gradient(ellipse at 50% 0%, rgba(99,102,241,0.1) 0%, transparent 70%);
  opacity: 0.7;
}

/* ---- language switch --------------------------------------------------- */
.lang-switch {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin-bottom: var(--space-sm);
  position: relative;
  z-index: 1;
}

.lang-btn {
  width: 36px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.lang-btn:hover {
  color: var(--text);
  border-color: var(--border-focus);
}

.lang-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---- brand lockup ------------------------------------------------------ */
.login-brand {
  text-align: center;
  margin-bottom: var(--space-lg);
  position: relative;
  z-index: 1;
}

.login-logo {
  font-size: 48px;
  margin-bottom: var(--space-sm);
  line-height: 1;
  display: inline-block;
  animation: logoFloat 3s var(--ease-in-out) infinite;
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.login-brand h2 {
  margin: 0 0 var(--space-xs) 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.3px;
  background: linear-gradient(135deg, var(--accent) 0%, #8b5cf6 50%, var(--accent2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.login-brand .muted {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ---- AI tag ------------------------------------------------------------ */
.login-ai-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: var(--space-sm);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-full);
  padding: 4px 12px;
  position: relative;
  z-index: 1;
}

.login-ai-tag .ai-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: aiPulse 1.8s ease-in-out infinite;
}

@keyframes aiPulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.4); }
}

/* ---- fields ------------------------------------------------------------ */
.login-fields {
  display: grid;
  gap: var(--space-md);
  position: relative;
  z-index: 1;
}

.field {
  display: grid;
  gap: var(--space-xs);
}

.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: baseline;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.field-hint {
  font-weight: 400;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.field input {
  width: 100%;
  padding: 11px 14px;
  font-size: 14px;
  border-radius: var(--radius);
  transition: all var(--duration-fast) var(--ease-out);
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow), 0 0 20px rgba(99,102,241,0.08);
}

.totp-row {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.totp-row input {
  flex: 1;
  min-width: 0;
}

.btn-text {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 0;
  white-space: nowrap;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--duration-fast) var(--ease-out);
}

.btn-text:hover {
  color: var(--accent-strong);
}

/* ---- submit button ----------------------------------------------------- */
.login-submit {
  width: 100%;
  margin-top: var(--space-xs);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 2px;
  position: relative;
  z-index: 1;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.login-submit:hover:not(:disabled) {
  box-shadow: 0 6px 28px rgba(99,102,241,0.4);
  transform: translateY(-2px);
}

/* ---- feedback ---------------------------------------------------------- */
.login-feedback {
  min-height: 22px;
  font-size: 13px;
  text-align: center;
  padding: var(--space-xs) 0;
  color: var(--text-muted);
  transition: color var(--duration-fast) var(--ease-out);
  position: relative;
  z-index: 1;
}

.login-feedback.is-error {
  color: var(--red);
  font-weight: 500;
}

.login-feedback.is-ok {
  color: var(--green);
  font-weight: 500;
}

/* ---- help text --------------------------------------------------------- */
.login-help {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin: var(--space-md) 0 0;
  position: relative;
  z-index: 1;
}

.login-help .btn-text {
  font-size: 13px;
}

/* ---- divider & details in login card ----------------------------------- */
.login-card hr { position: relative; z-index: 1; }
.login-card details { position: relative; z-index: 1; }

/* ---- legacy overrides --------------------------------------------------- */
.login-form .form-row { justify-content: flex-start; }
.login-card .login-form .form-row { justify-content: flex-start; }

/* ==========================================================================
   Token field & legacy auth
   ========================================================================== */

.token-field {
  display: grid;
  gap: var(--space-xs);
  min-width: 280px;
  max-width: 520px;
  flex: 1;
}

.token-field span {
  color: var(--text-muted);
  font-size: 12px;
}

.authbar {
  flex: 1;
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: var(--space-sm);
  min-width: 0;
}

.local-auth {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
  color: var(--text-muted);
  font-size: 12px;
}

.local-auth strong { color: var(--text); }

.local-auth code {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  padding: 5px 8px;
}

/* ==========================================================================
   Utility: link highlight
   ========================================================================== */

body[data-role="anonymous"] .nav-link { display: none; }
body[data-role="anonymous"] .user-chip { display: none; }

/* ---- topbar language switch -------------------------------------------- */
.topbar-lang { margin-right: 2px; }
.topbar-lang .lang-btn { width: 32px; height: 28px; font-size: 11px; }

/* ==========================================================================
   Skip to main content (accessibility)
   ========================================================================== */

.skip-link {
  position: absolute;
  top: -100%;
  left: 12px;
  z-index: 100;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

/* ==========================================================================
   Responsive — tablet
   ========================================================================== */

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

  .sidebar {
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .workspace {
    max-height: none;
  }
}

/* ==========================================================================
   Responsive — mobile
   ========================================================================== */

@media (max-width: 820px) {
  .topbar-spa {
    flex-wrap: wrap;
    gap: var(--space-sm);
    padding: 10px 14px;
  }

  .primary-nav {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: var(--space-xs);
  }

  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar, .panel, .workspace {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .panel, .workspace {
    padding: 12px;
  }

  .block-title, .pane-head {
    align-items: flex-start;
    flex-direction: column;
    gap: var(--space-xs);
  }

  .block-title span, .pane-head span {
    text-align: left;
  }

  .workspace-grid, .viewer-grid, .viewer-grid.four {
    grid-template-columns: 1fr;
  }

  .page {
    padding: var(--space);
  }

  .tiles {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .hit {
    grid-template-columns: 56px minmax(0, 1fr);
    gap: var(--space-sm);
    padding: 10px;
  }

  .hit img {
    width: 56px;
    height: 56px;
  }

  .tabs.three {
    flex-wrap: wrap;
  }

  .user-chip .role-badge {
    max-width: 180px;
    font-size: 12px;
  }
}

/* ==========================================================================
   Filter bar — inline filter row (papers, audit)
   ========================================================================== */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
}

.filter-field {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.filter-field span {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}

.filter-field select,
.filter-field input {
  width: auto;
  min-width: 80px;
  padding: 7px 10px;
  font-size: 13px;
}

.filter-bar > input[type="search"] {
  flex: 1;
  min-width: 160px;
  max-width: 280px;
  padding: 7px 12px;
  font-size: 13px;
}

/* ==========================================================================
   Ingest — full-width two-column layout
   ========================================================================== */

.ingest-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 0;
  min-height: calc(100vh - 60px - 48px);
  margin: -18px;
}

.ingest-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px;
  overflow-y: auto;
}

.ingest-main {
  padding: 20px;
  overflow-y: auto;
  background: var(--bg-soft);
}

.ingest-main {
  background: var(--surface);
  display: flex;
  flex-direction: column;
}

.ingest-main .json-output {
  max-height: none;
  min-height: 300px;
  margin: 0;
  flex: 1;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.ingest-main .empty-state {
  flex: 1;
  margin: 0;
}

.file-pick {
  display: grid;
  gap: 6px;
  padding: 16px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  margin-bottom: var(--space);
  text-align: center;
}

.file-pick:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.file-pick input { display: none; }

.file-pick-icon {
  font-size: 24px;
  color: var(--accent);
  font-weight: 300;
}

.file-pick-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.file-pick-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================================================================
   Admin panel — tab panel visibility
   ========================================================================== */

.admin-panel { display: none; }
.admin-panel.active { display: block; }

@media (max-width: 800px) {
  .ingest-shell {
    grid-template-columns: 1fr;
    margin: -12px;
  }
  .ingest-sidebar { border-right: none; border-bottom: 1px solid var(--border); }
}

/* ==========================================================================
   Motion — reduced motion preference
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   AI Chat standalone page (#/ai/chat)
   ========================================================================== */
.ai-chat-shell {
  max-width: 880px; margin: 0 auto; padding: 16px;
  display: flex; flex-direction: column; height: calc(100vh - 140px);
  background: var(--surface-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.ai-chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border-light);
  background: linear-gradient(180deg, var(--accent-soft) 0%, var(--surface) 100%);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.ai-chat-head h2 { margin: 0; font-size: 17px; }
.ai-chat-head-actions { display: flex; align-items: center; gap: 8px; }
.ai-chat-msgs {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.ai-chat-msgs .ai-msg { /* same styles as widget */ }

/* ----- AI assistant rendered markdown (issue: chat-output reading mode) ----
   `.ai-msg-rich` is the container for marked + KaTeX rendered HTML.
   Tight, readable, "Google AI / ChatGPT" style — narrow vertical rhythm,
   no monospace bleed, tables scroll horizontally on mobile, code chips
   subtle, math inherits text size.
   ------------------------------------------------------------------------ */
.ai-msg.assistant { white-space: normal; }
.ai-msg-rich { line-height: 1.7; font-size: 15px; word-break: break-word; }
.ai-msg-rich > *:first-child { margin-top: 0; }
.ai-msg-rich > *:last-child { margin-bottom: 0; }
.ai-msg-rich p { margin: 0.55em 0; }
.ai-msg-rich h1, .ai-msg-rich h2, .ai-msg-rich h3, .ai-msg-rich h4 {
  margin: 1.1em 0 0.4em; line-height: 1.35; font-weight: 650;
}
.ai-msg-rich h1 { font-size: 1.32rem; font-weight: 700; }
.ai-msg-rich h2 { font-size: 1.22rem; }
.ai-msg-rich h3 { font-size: 1.08rem; }
.ai-msg-rich h4 { font-size: 1rem;  color: var(--text-muted, #555); }
.ai-msg-rich ul, .ai-msg-rich ol { padding-left: 1.4em; margin: 0.5em 0; }
.ai-msg-rich li { margin: 0.2em 0; }
.ai-msg-rich li > p { margin: 0.2em 0; }
.ai-msg-rich blockquote {
  border-left: 3px solid var(--border, #d0d7de);
  margin: 0.7em 0; padding: 0.1em 0 0.1em 0.9em;
  color: var(--text-muted, #555);
}
.ai-msg-rich hr {
  border: 0; border-top: 1px solid var(--border-light, #eaeef2);
  margin: 0.9em 0;
}
.ai-msg-rich code {
  background: var(--surface-alt, #f3f4f6); padding: 0.1em 0.35em;
  border-radius: 4px; font-size: 0.92em;
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
}
.ai-msg-rich pre {
  background: var(--surface-alt, #f6f8fa); padding: 0.7em 0.9em;
  border-radius: 6px; overflow-x: auto;
  font-size: 0.92em; margin: 0.7em 0;
}
.ai-msg-rich pre code { background: transparent; padding: 0; border-radius: 0; }
.ai-msg-rich table {
  display: block; max-width: 100%; overflow-x: auto;
  border-collapse: collapse; margin: 0.7em 0; font-size: 0.95em;
}
.ai-msg-rich th, .ai-msg-rich td {
  border: 1px solid var(--border-light, #e5e7eb);
  padding: 0.45em 0.65em; vertical-align: top; text-align: left;
}
.ai-msg-rich th { background: var(--surface-alt, #f9fafb); font-weight: 600; }
.ai-msg-rich a { color: var(--accent, #2563eb); text-decoration: underline; }
.ai-msg-rich a:hover { text-decoration: none; }
.ai-msg-rich img { max-width: 100%; height: auto; border-radius: 4px; }
.ai-msg-rich strong { font-weight: 650; }
.ai-msg-rich em { font-style: italic; }
/* KaTeX inline: keep at the same size as surrounding text */
.ai-msg-rich .katex { font-size: 1em; }
.ai-msg-rich .katex-display { margin: 0.6em 0; overflow-x: auto; overflow-y: hidden; }
.ai-chat-input {
  border-top: 1px solid var(--border-light);
  padding: 8px 12px 12px;
  background: var(--surface);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.ai-pending-img {
  position: relative; display: inline-block; margin-bottom: 8px;
}
.ai-pending-img img {
  max-height: 120px; max-width: 200px; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.ai-img-x {
  position: absolute; top: -8px; right: -8px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--text); color: var(--text-inverse);
  border: 2px solid var(--surface); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0;
}
.ai-msg-img {
  display: block; max-width: 220px; max-height: 160px;
  border-radius: var(--radius-sm); margin-bottom: 6px;
}
.ai-status {
  font-size: 12px; color: var(--text-muted); min-height: 16px;
  margin-bottom: 4px; padding: 0 4px;
}
.ai-tool-btn {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: var(--surface-hover); border: 1px solid var(--border);
  color: var(--text-secondary); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s var(--ease-out), color 0.15s var(--ease-out);
}
.ai-tool-btn:hover { background: var(--accent-soft); color: var(--accent-strong); }
.ai-voice-btn.recording {
  background: #fee2e2; color: #dc2626; border-color: #fca5a5;
  animation: ai-pulse 1.2s ease-in-out infinite;
}
@keyframes ai-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
  50%      { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}

/* M1-#5: image crop modal — user-controllable crop after upload/camera/paste */
.ai-crop-modal {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(15, 23, 42, 0.72);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.ai-crop-panel {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 16px; max-width: 92vw; max-height: 92vh;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}
.ai-crop-head { display: flex; justify-content: space-between; align-items: baseline; }
.ai-crop-head h3 { margin: 0; font-size: 16px; }
.ai-crop-hint { font-size: 12px; color: var(--text-muted); }
.ai-crop-stage {
  position: relative; user-select: none;
  background: #f1f5f9; border-radius: var(--radius-sm);
  overflow: hidden; touch-action: none;
}
.ai-crop-stage img {
  display: block; max-width: 80vw; max-height: 60vh; pointer-events: none;
}
.ai-crop-box {
  position: absolute; box-sizing: border-box;
  border: 2px solid #ef4444;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.45);
  cursor: move; touch-action: none;
}
.ai-crop-handle {
  position: absolute; width: 14px; height: 14px;
  background: #ef4444; border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  touch-action: none;
}
.ai-crop-handle.nw { top: -8px;  left: -8px;  cursor: nw-resize; }
.ai-crop-handle.ne { top: -8px;  right: -8px; cursor: ne-resize; }
.ai-crop-handle.sw { bottom: -8px; left: -8px;  cursor: sw-resize; }
.ai-crop-handle.se { bottom: -8px; right: -8px; cursor: se-resize; }
.ai-crop-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 4px; flex-wrap: wrap;
}
.ai-crop-actions .btn { min-width: 96px; }

/* M1-#5: model indicator pill in chat head — text by default,
   flips to "vision (this turn)" while a pendingImage is queued. */
.ai-model-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; line-height: 1;
  background: var(--surface-hover); color: var(--text-secondary);
  border: 1px solid var(--border);
  transition: background 0.18s var(--ease-out), color 0.18s var(--ease-out),
              border-color 0.18s var(--ease-out);
}
.ai-model-pill.is-vision {
  background: #fff7ed; color: #c2410c; border-color: #fdba74;
}

/* M1-#5 polish: single paperclip button opens a small popover that
   lets the user pick 拍照 / 上传. Avoids the visual noise of two
   parallel buttons sitting in the input row. */
.ai-attach-wrap { position: relative; }
.ai-attach-menu {
  position: absolute; bottom: calc(100% + 6px); left: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.15);
  padding: 4px; min-width: 130px;
  z-index: 50;
  display: flex; flex-direction: column;
}
.ai-attach-menu[hidden] { display: none; }
.ai-attach-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border: 0; background: transparent;
  color: var(--text); cursor: pointer; font-size: 13px;
  border-radius: var(--radius-xs);
  text-align: left;
}
.ai-attach-item:hover { background: var(--accent-soft); color: var(--accent-strong); }
.ai-attach-icon { font-size: 16px; }

/* M2: thinking-mode toggle — same shape as voice/attach but flips to
   accent state when on, so user can see at a glance which turn will
   route to deepseek-reasoner (slower, more tokens). */
.ai-thinking-btn.is-on {
  background: var(--accent); color: var(--text-inverse);
  border-color: var(--accent);
}
.ai-thinking-btn.is-on:hover {
  background: var(--accent-strong); color: var(--text-inverse);
}

/* M3 super_root force-route toggle — same shape as thinking, but
   a different active color so the two pinned states are visually
   distinct (purple-ish, matches debug semantics). */
.ai-route-btn.is-on {
  background: #7c3aed; color: #fff; border-color: #7c3aed;
}
.ai-route-btn.is-on:hover { background: #6d28d9; color: #fff; }

/* M2: reasoning <details> in the assistant bubble — quieter than the
   main reply, monospace, indented so it reads as a side-channel. */
.ai-msg-reasoning {
  margin-bottom: 8px;
  padding: 4px 8px;
  border-left: 3px solid var(--accent);
  background: var(--surface-hover);
  border-radius: var(--radius-xs);
}
.ai-msg-reasoning > summary {
  cursor: pointer; font-size: 12px;
  color: var(--text-secondary); user-select: none;
  padding: 2px 0;
}
.ai-msg-reasoning[open] > summary { margin-bottom: 4px; }
.ai-msg-reasoning-body {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.55;
  color: var(--text-secondary);
  white-space: pre-wrap; word-break: break-word;
  padding: 4px 2px;
}

/* M2: 👍/👎 feedback footer on assistant bubbles. The buttons sit
   inline at the bottom-right of the bubble; active state uses accent
   color to mirror the model-pill / thinking-toggle visual language. */
.ai-msg-feedback {
  display: flex; gap: 4px; margin-top: 6px;
  justify-content: flex-end;
}
.ai-fb-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer;
  font-size: 14px; line-height: 1;
  padding: 2px 8px; border-radius: var(--radius-full);
  transition: background 0.15s var(--ease-out),
              color 0.15s var(--ease-out),
              border-color 0.15s var(--ease-out);
}
.ai-fb-btn:hover:not(.is-active):not(:disabled) {
  background: var(--surface-hover); color: var(--text);
}
.ai-fb-btn.up.is-active {
  background: #ecfdf5; color: #047857; border-color: #6ee7b7;
}
.ai-fb-btn.down.is-active {
  background: #fef2f2; color: #b91c1c; border-color: #fca5a5;
}
.ai-fb-btn:disabled { opacity: 0.5; cursor: wait; }

/* M2: super_root admin trends panel (#/admin/ai-feedback) */
.aifb-overview {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin: 16px 0;
}
.aifb-tile {
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.aifb-tile-value {
  font-size: 28px; font-weight: 600; color: var(--text);
  line-height: 1.1;
}
.aifb-tile-label {
  font-size: 12px; color: var(--text-muted); margin-top: 4px;
}
.aifb-tile.is-up   .aifb-tile-value { color: #047857; }
.aifb-tile.is-down .aifb-tile-value { color: #b91c1c; }

.aifb-h3 { font-size: 14px; color: var(--text); margin: 22px 0 8px; }

.aifb-bars { display: flex; flex-direction: column; gap: 8px; }
.aifb-bar-row {
  display: flex; flex-direction: column; gap: 4px;
}
.aifb-bar-label {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text-secondary);
}
.aifb-bar-meta { color: var(--text-muted); }
.aifb-bar {
  height: 12px; background: var(--surface-hover);
  border-radius: var(--radius-xs);
  display: flex; overflow: hidden;
}
.aifb-bar-up   { background: #34d399; }
.aifb-bar-down { background: #f87171; }

.aifb-worst td.aifb-content {
  max-width: 360px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-size: 12px;
}

/* M2 super_root: per-message debug log table (#/admin/ai-debug) */
.aidbg-table th, .aidbg-table td { font-size: 12px; }
.aidbg-row { cursor: pointer; }
.aidbg-row:hover { background: var(--surface-hover); }
.aidbg-num { font-variant-numeric: tabular-nums; text-align: right; }
.aidbg-num.is-mid  { color: #b45309; }
.aidbg-num.is-slow { color: #b91c1c; font-weight: 600; }
.aidbg-cache {
  font-variant-numeric: tabular-nums;
  padding: 1px 6px; border-radius: 4px; font-size: 11px;
  font-weight: 600;
}
.aidbg-cache.is-hot  { background: #d1fae5; color: #065f46; }  /* 60%+ 命中 = 绿 */
.aidbg-cache.is-warm { background: #fef3c7; color: #92400e; }  /* 30-59% = 黄 */
.aidbg-cache.is-cold { background: #fee2e2; color: #991b1b; }  /* <30% = 红 */
.aidbg-internal { font-size: 11px; line-height: 1.3; }
.aidbg-content {
  max-width: 320px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
}
.aidbg-rating.up   { color: #047857; }
.aidbg-rating.down { color: #b91c1c; }
.badge.is-non-model { background: #fef3c7; color: #92400e; }

.aidbg-detail > td { padding: 0; background: var(--surface-hover); }
.aidbg-detail-body {
  padding: 12px 16px;
  border-left: 4px solid var(--accent);
  display: flex; flex-direction: column; gap: 12px;
}
.aidbg-block h4 {
  margin: 0 0 6px; font-size: 12px; color: var(--text-secondary);
}
.aidbg-pre {
  margin: 0; padding: 8px 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 12px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
  max-height: 320px; overflow-y: auto;
}
.aidbg-fb-list {
  margin: 0; padding-left: 16px; font-size: 12px;
  color: var(--text-secondary);
}
.aidbg-fb-list li { margin: 4px 0; }

/* M2 Phase-2: injected ctx + retrieval sources blocks in drill-down */
.aidbg-mat-line {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
}
.badge.aidbg-mat-approved { background: #ecfdf5; color: #047857; border: 1px solid #6ee7b7; }
.badge.aidbg-mat-pending  { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.badge.aidbg-mat-rejected { background: #fef2f2; color: #b91c1c; border: 1px solid #fca5a5; }
.aidbg-inj {
  margin: 0; display: flex; flex-direction: column; gap: 6px;
}
.aidbg-inj-row {
  display: grid; gap: 6px;
  grid-template-columns: 160px 1fr;
  align-items: start;
}
.aidbg-inj-row dt { font-size: 11px; color: var(--text-secondary); }
.aidbg-inj-row dd { margin: 0; }
.aidbg-inj-row details summary { font-size: 11px; cursor: pointer; }
.aidbg-src-list {
  margin: 0; padding-left: 16px; font-size: 12px;
  color: var(--text-secondary);
}
.aidbg-src-list li {
  margin: 4px 0;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}

/* M3 lesson debug: P5 corpus inspector (#/admin/lesson-debug) */
.aildbg-meta {
  display: grid; gap: 8px 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 16px 0;
  font-size: 12px;
}
.aildbg-meta code { word-break: break-all; font-size: 11px; }
.aildbg-sections {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.aildbg-section-row {
  display: grid; gap: 10px;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
}
.aildbg-section-row:last-child { border-bottom: 0; }
.aildbg-section-row:hover { background: var(--surface-hover); }
.aildbg-sec-marker {
  font-size: 10px; color: var(--text-muted);
  border: 1px solid var(--border); padding: 2px 6px;
  border-radius: var(--radius-xs); text-align: center;
}
.aildbg-sec-title { font-size: 13px; color: var(--text); }
.aildbg-sec-title.is-h2 { font-weight: 600; }
.aildbg-sec-meta { font-size: 11px; }
.aildbg-tip-panel {
  border-bottom: 1px solid var(--border-light);
  border-left: 4px solid var(--accent);
  padding: 12px 16px;
  background: var(--surface-hover);
  display: flex; flex-direction: column; gap: 10px;
}
.aildbg-tip-meta {
  display: flex; gap: 8px; align-items: center;
  font-size: 11px;
}
.aildbg-tip-seg-head {
  font-size: 11px; font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.05em;
  margin-bottom: 3px;
}
.aildbg-pre {
  margin: 0; padding: 8px 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 12px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
  max-height: 320px; overflow-y: auto;
}

.aildbg-rag-block { margin-top: 28px; }
.aildbg-rag-list { padding-left: 18px; }
.aildbg-rag-list li { margin: 10px 0; }
.aildbg-rag-hdr {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 4px; font-size: 11px;
}

/* Phase-4 D1 (#152): override marker on a tip section row + edit toolbar */
.aildbg-override-line {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 6px 8px; background: #ecfdf5;
  border-left: 3px solid #047857;
  border-radius: var(--radius-xs);
  font-size: 12px;
}
.aildbg-override-line .btn { margin-left: auto; }
.aildbg-tip-meta button[data-act="edit-tip"] { margin-left: auto; }

/* ==========================================================================
   AI suggestion chips on question detail page
   ========================================================================== */
.ai-suggest-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(135deg, var(--accent-soft) 0%,
                                       var(--accent2-soft) 100%);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
}
.ai-chip {
  padding: 6px 12px; font-size: 13px;
  background: var(--surface); color: var(--accent-strong);
  border: 1px solid var(--border); border-radius: var(--radius-full);
  cursor: pointer; transition: transform 0.15s var(--ease-out),
                                background 0.15s var(--ease-out);
}
.ai-chip:hover {
  transform: translateY(-1px);
  background: var(--accent); color: var(--text-inverse);
  border-color: var(--accent);
}

/* ==========================================================================
   AI Material Library admin page
   ========================================================================== */
.ai-mat-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
  background: var(--surface);
}
.ai-mat-card header {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 8px; font-size: 12px;
}
.ai-mat-card .badge.pending    { background: #fef3c7; color: #92400e; }
.ai-mat-card .badge.approved   { background: #d1fae5; color: #065f46; }
.ai-mat-card .badge.rejected   { background: #fee2e2; color: #991b1b; }
.ai-mat-card .badge.superseded { background: #e5e7eb; color: #4b5563; }
/* #156 T2 source badges */
.ai-mat-card .badge.am-src-question { background: #fef3c7; color: #92400e; }
.ai-mat-card .badge.am-src-lesson   { background: #dbeafe; color: #1e40af; }
.ai-mat-card .badge.am-src-point    { background: #ede9fe; color: #5b21b6; }
.ai-mat-card .badge.am-src-chat     { background: #ecfdf5; color: #047857; }
.ai-mat-card .badge.am-src-unknown  { background: #f3f4f6; color: #6b7280; }
.am-src-link {
  font-size: 11px; color: #4338ca; text-decoration: none;
  background: #eef2ff; padding: 2px 8px; border-radius: 999px;
  margin-left: 4px; white-space: nowrap;
}
.am-src-link:hover { background: #c7d2fe; }
.ai-mat-ctxline {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 4px 12px 0;
  font-size: 12px;
}
.am-ctx-link {
  text-decoration: none; color: #4338ca;
  background: #eef2ff; padding: 2px 8px; border-radius: 999px;
  white-space: nowrap;
}
.am-ctx-link:hover { background: #c7d2fe; }
.am-ctx-link.primary {
  background: #4338ca; color: white; font-weight: 600;
}
.am-ctx-link.primary:hover { background: #3730a3; }
/* #156 T3: dim operation buttons when no subject picked */
button.dim-no-subject, .btn.dim-no-subject {
  opacity: 0.42; cursor: not-allowed;
  filter: grayscale(0.7);
}
/* #157 T2 / T3 q-text override modal */
.am-qtext-loading { padding: 20px; color: var(--text-muted, #64748b); text-align: center; }
.am-qtext-body    { display: flex; flex-direction: column; gap: 10px; }
.am-qtext-pane    { flex: 1; }
.am-qtext-pane[hidden] { display: none; }
.am-qtext-pane textarea {
  font: 13px/1.55 ui-monospace, "SF Mono", Menlo, monospace;
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border, #d1d5db); border-radius: 6px;
  background: var(--surface, #fff);
  resize: vertical; min-height: 280px;
}
.am-affected-list {
  list-style: none; padding: 0; margin: 8px 0;
  max-height: 55vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
}
.am-aff-li {
  padding: 8px 10px;
  border: 1px solid var(--border-light, #e5e7eb);
  border-radius: 6px;
  background: white;
}
.am-aff-li:hover { background: var(--bg-soft, #f8fafc); }
.am-aff-label {
  display: flex !important; gap: 10px; align-items: flex-start;
  cursor: pointer; font-size: 12px; width: 100%;
}
.am-aff-label > input[type="checkbox"] {
  margin-top: 3px; flex-shrink: 0;
}
.am-aff-meta {
  flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.am-aff-row-1 {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.am-aff-ctx {
  font-size: 11px;
}
.am-aff-head {
  font-family: ui-monospace, Menlo, monospace; font-size: 11px;
  color: var(--text-secondary, #475569);
  word-break: break-word; line-height: 1.45;
  background: var(--bg-soft, #f8fafc);
  padding: 4px 6px; border-radius: 4px;
}
.am-aff-hint {
  padding: 10px 12px;
  background: #fffbeb; border: 1px solid #fde68a;
  border-radius: 6px; margin: 4px 0 8px;
  font-size: 12px; color: #92400e;
}
.am-aff-hint p { margin: 0 0 6px; font-weight: 500; }
.am-aff-legend {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.am-aff-legend li { font-size: 12px; }
.am-edit-msg.is-warn {
  color: #92400e; font-size: 12px;
}
/* P4: 编辑窗左侧 vertical field tab nav */
.am-field-tabs {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--bg-soft, #f8fafc);
  padding: 8px; border-bottom: 1px solid var(--border-light, #e5e7eb);
}
.am-field-tab {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 6px;
  background: transparent; border: 1px solid transparent;
  cursor: pointer; font-size: 12px; text-align: left;
  color: var(--text-secondary, #475569);
}
.am-field-tab:hover { background: white; border-color: var(--border, #d1d5db); }
.am-field-tab.active {
  background: white; border-color: #4338ca; color: #3730a3;
  font-weight: 600; box-shadow: 0 1px 3px rgba(67,56,202,0.08);
}
.am-field-tab-icon { font-size: 14px; }
.am-field-tab-label { flex: 1; }
.am-field-tab-dirty {
  color: #f59e0b; font-size: 14px; font-weight: bold;
}
.am-field-editor {
  flex: 1; display: flex; flex-direction: column;
  background: var(--surface, #fff);
}
.am-field-hint {
  flex: 1; text-align: right; font-size: 11px;
  font-style: italic;
}
.am-field-loading {
  padding: 20px; text-align: center;
  color: var(--text-muted, #94a3b8);
  background: var(--bg-soft, #f8fafc);
}
#amFieldArea {
  flex: 1; width: 100%; min-height: 320px;
  font: 13px/1.55 ui-monospace, "SF Mono", Menlo, monospace;
  padding: 10px 12px;
  border: 0; resize: none;
  background: var(--surface, #fff);
}
/* #158 T3 bullet mapping page */
.bm-meta { display: flex; gap: 16px; flex-wrap: wrap; padding: 10px 0;
            font-size: 12px; color: var(--text-secondary, #475569); }
.bm-actions { display: flex; align-items: center; gap: 8px;
              padding: 8px 0; flex-wrap: wrap; }
.bm-table {
  width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px;
}
.bm-table th, .bm-table td {
  text-align: left; padding: 6px 10px;
  border-bottom: 1px solid var(--border-light, #eee);
}
.bm-table thead th { background: var(--bg-soft, #f8fafc); font-weight: 600; }
.bm-table tr:hover { background: var(--bg-soft, #f8fafc); }
.bm-table th.num, .bm-table td.num { text-align: right; }
/* #155 bullet-mapping 双向浏览 — tabs + 展开行 */
.bm-tabs {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0 12px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border-light, #eee);
}
.bm-pipeline-hint {
  font-size: 12px; cursor: help;
  background: var(--bg-soft, #f8fafc);
  padding: 4px 8px; border-radius: 6px;
}
.bm-uid {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11px; color: #4338ca;
  word-break: break-all;
}
.bm-expand-btn {
  background: transparent; border: 0; cursor: pointer;
  font-size: 14px; padding: 0 4px;
  color: var(--text-secondary, #475569);
}
.bm-expand-btn:hover { color: #4338ca; }
.bm-expand-row > td {
  background: var(--bg-soft, #f8fafc);
  padding: 12px 16px; border-top: 0;
}
.bm-sub-empty {
  padding: 8px 0; font-size: 12px;
  color: var(--text-muted, #94a3b8); font-style: italic;
}
.bm-sub-actions {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap; padding: 4px 0 8px;
}
.bm-sub-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
  background: white;
}
.bm-sub-table th, .bm-sub-table td {
  padding: 5px 8px; border-bottom: 1px solid var(--border-light, #eee);
  text-align: left;
}
.bm-sub-table th.num, .bm-sub-table td.num { text-align: right; }
.bm-sub-table thead th {
  background: white; font-weight: 600;
  border-bottom: 2px solid var(--border-light, #e5e7eb);
}
.bm-sub-msg {
  margin-top: 8px; font-size: 12px;
}
.bm-add-row {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px;
  padding-top: 10px; border-top: 1px dashed var(--border-light, #e5e7eb);
}
.bm-add-row input.bm-new-bullet {
  flex: 1; padding: 5px 10px; font-size: 12px;
  border: 1px solid var(--border, #d1d5db); border-radius: 4px;
  font-family: ui-monospace, Menlo, monospace;
}
.badge.override {
  background: #fef3c7; color: #92400e;
  border: 1px solid #fde68a;
}
/* #159 学科考务 */
.seo-qbank-meta, .seo-prompt-meta {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 0; font-size: 13px;
}
.ai-mat-card.is-superseded {
  /* visually dim a stale cache row but keep it readable */
  opacity: 0.78;
  border-left: 3px solid #9ca3af;
}
.ai-mat-superseded-line {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 12px 6px;
  font-size: 12px;
}
.ai-mat-superseded-line .badge.superseded {
  background: #fef3c7; color: #92400e; font-weight: 600;
}
.ai-mat-body { display: grid; gap: 10px;
               grid-template-columns: 1fr 1fr; margin-bottom: 10px; }
@media (max-width: 720px) { .ai-mat-body { grid-template-columns: 1fr; } }
.ai-mat-q, .ai-mat-a {
  background: var(--bg-soft); padding: 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}
/* #154 #9 lazy-render placeholders */
.ai-mat-md-defer {
  /* truncated preview shown until IntersectionObserver swaps to rich */
  opacity: 0.65;
}
.ai-mat-md-preview {
  font: inherit; font-size: 12.5px; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
  color: var(--text-muted, #64748b);
  margin: 0;
}
.ai-mat-md-rendered {
  font-size: 13.5px; line-height: 1.55;
}
.ai-mat-md-rendered p:first-child { margin-top: 0; }
.ai-mat-md-rendered p:last-child  { margin-bottom: 0; }
.ai-mat-md-rendered pre {
  background: var(--surface); padding: 6px 8px; border-radius: 4px;
  font-size: 12px; overflow-x: auto;
}
.ai-mat-md-rendered code {
  background: var(--surface); padding: 1px 4px; border-radius: 3px;
  font-size: 0.9em;
}
.ai-mat-q pre, .ai-mat-a pre {
  font: inherit; font-size: 13px; line-height: 1.5; white-space: pre-wrap;
  margin: 4px 0 0; max-height: 240px; overflow: auto;
}

/* Phase-4-1 (#152): super_root cached-response edit modal */
.am-edit-modal {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(15, 23, 42, 0.6);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.am-edit-panel {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 16px 20px; max-width: 900px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}
.am-edit-head {
  display: flex; justify-content: space-between; align-items: center;
}
.am-edit-head h3 { margin: 0; font-size: 16px; }
.am-edit-tabs { display: flex; gap: 6px; }
.am-edit-body { display: flex; flex-direction: column; gap: 10px; }
.am-edit-body textarea {
  width: 100%; font: inherit; font-size: 13px; line-height: 1.55;
  padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface-hover);
  resize: vertical;
}
.am-edit-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  border-top: 1px solid var(--border-light); padding-top: 10px;
}
.am-history { padding-left: 18px; }
.am-history li { margin: 8px 0; font-size: 12px; }
.am-hist-pair {
  display: grid; gap: 8px; grid-template-columns: 1fr 1fr;
  margin-top: 4px;
}
.am-hist-pair pre {
  font: inherit; font-size: 11px; line-height: 1.5;
  padding: 6px 8px; background: var(--bg-soft);
  border: 1px solid var(--border-light); border-radius: var(--radius-xs);
  white-space: pre-wrap; max-height: 200px; overflow: auto;
}

/* Phase-4 v2: redesigned super_root edit modal — left editor / right
   live preview + diff. Wider panel, less likely to feel cramped. */
.am-edit-modal-v2 .am-edit-panel-v2 {
  max-width: min(1280px, 96vw);
  width: 100%;
  display: flex; flex-direction: column; gap: 12px;
  max-height: 92vh; overflow: hidden;
}
.am-edit-sub { font-weight: normal; margin-left: 8px; }
.am-edit-q {
  display: flex; flex-direction: column; gap: 4px;
  border: 1px solid var(--border-light); border-radius: var(--radius-sm);
  background: var(--surface-hover); padding: 8px 12px;
}
.am-edit-q-label { font-size: 11px; color: var(--text-muted); }
.am-edit-q textarea {
  font: inherit; font-size: 13px; line-height: 1.5;
  background: transparent; border: 0; resize: none;
  width: 100%;
}
.am-edit-grid {
  display: grid; gap: 12px;
  grid-template-columns: 1fr 1fr;
  min-height: 380px; flex: 1; overflow: hidden;
}
.am-edit-grid-left, .am-edit-grid-right {
  display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; min-height: 0;
}
.am-edit-pane-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 10px; font-size: 12px; color: var(--text-secondary);
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border-light);
}
.am-edit-grid-left textarea {
  flex: 1; width: 100%; resize: none;
  font: 13px / 1.55 ui-monospace, "SF Mono", Menlo, monospace;
  padding: 10px 12px;
  border: 0; background: var(--surface);
  outline: none;
}
.am-edit-rtabs { padding: 6px 8px; gap: 4px; background: var(--bg-soft);
                 border-bottom: 1px solid var(--border-light); }
.am-edit-rpane { flex: 1; overflow: auto; }
.am-edit-rpane[hidden] { display: none; }
.am-edit-preview {
  padding: 12px 16px;
  font-size: 14px; line-height: 1.65;
}
.am-edit-preview .katex { font-size: 1em; }

.am-diff {
  font: 12px / 1.55 ui-monospace, "SF Mono", Menlo, monospace;
  padding: 6px 0;
}
.am-diff-line { padding: 1px 12px; display: flex; gap: 6px; white-space: pre-wrap; word-break: break-word; }
.am-diff-marker { width: 12px; flex-shrink: 0; opacity: 0.6; }
.am-diff-same { color: var(--text-secondary); }
.am-diff-add  { background: #ecfdf5; color: #047857; }
.am-diff-del  { background: #fef2f2; color: #b91c1c; text-decoration: line-through; opacity: 0.85; }
.am-diff-empty { padding: 24px; text-align: center; }

.am-edit-note-row {
  display: flex; gap: 12px; align-items: center;
}
.am-edit-msg { font-size: 12px; padding: 4px 10px; border-radius: var(--radius-xs); min-width: 200px; text-align: right; }
.am-edit-msg.is-loading { color: var(--text-muted); }
.am-edit-msg.is-ok  { background: #ecfdf5; color: #047857; }
.am-edit-msg.is-err { background: #fef2f2; color: #b91c1c; }

@media (max-width: 720px) {
  .am-edit-grid { grid-template-columns: 1fr; }
}

/* ai-materials edit modal — source badge + mini-chat preview (v3) */
.am-edit-source-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 6px 10px;
  background: var(--bg-soft); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.am-source-badge {
  background: #eef2ff; color: #4338ca;
  border: 1px solid #c7d2fe; font-weight: 600;
}
.am-source-ctx {
  margin-left: auto; font-size: 11px; color: var(--text-muted);
  background: var(--surface); padding: 2px 8px; border-radius: var(--radius-xs);
}
.am-preview-bubble {
  border-radius: 10px; padding: 10px 14px; margin: 8px 0;
  border: 1px solid var(--border-light);
}
.am-preview-q {
  background: #f8fafc;
  border-left: 3px solid #6366f1;
}
.am-preview-a {
  background: var(--surface);
  border-left: 3px solid #10b981;
}
.am-preview-role {
  font-size: 10px; letter-spacing: 1px; font-weight: 700;
  margin-bottom: 4px;
}

/* ==========================================================================
   Notifications admin — iPhone-inspired
   ========================================================================== */

.notify-page {
  max-width: 600px;
  margin: 0 auto;
  display: grid;
  gap: 20px;
  padding: 8px 0;
}

.notify-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 20px 22px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.notify-title {
  margin: 0 0 2px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.notify-hint {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.4;
}

.notify-subtitle {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
}

.notify-error {
  color: var(--red);
  font-size: 13px;
  text-align: center;
  padding: 24px;
}

/* ---- form ---------------------------------------------------------------- */

.notify-form {
  display: grid;
  gap: 12px;
}

/* Kind chips — horizontal scrollable segmented control */
.notify-kinds {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.notify-kind-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--bg-soft);
  border: 1.5px solid transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  white-space: nowrap;
  flex-shrink: 0;
  user-select: none;
}

.notify-kind-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.notify-kind-chip:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.notify-kind-chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
  font-weight: 600;
}

.notify-kind-icon {
  font-size: 16px;
  line-height: 1;
}

/* Row fields — audience + expiry side by side */
.notify-row-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.notify-input,
.notify-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
  box-sizing: border-box;
}

.notify-input:focus,
.notify-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.notify-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.notify-textarea {
  resize: vertical;
  min-height: 64px;
  font: inherit;
}

/* Form footer — msg + submit */
.notify-form-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 4px;
}

.notify-msg {
  flex: 1;
  font-size: 12px;
  color: var(--text-muted);
}

.notify-msg--ok    { color: var(--green); }
.notify-msg--error { color: var(--red); }

.notify-submit {
  padding: 10px 24px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
}

.notify-submit:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--accent-glow);
}

/* ---- history rows -------------------------------------------------------- */

.notify-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.15s var(--ease-out);
}

.notify-row:last-child {
  border-bottom: none;
}

.notify-row-icon {
  font-size: 18px;
  flex-shrink: 0;
  width: 28px;
  text-align: center;
}

.notify-row-body {
  flex: 1;
  min-width: 0;
}

.notify-row-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notify-row-preview {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notify-row-aud {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent-strong);
  background: var(--accent-soft);
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.notify-row-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.notify-row-del {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s var(--ease-out);
  flex-shrink: 0;
}

.notify-row-del:hover {
  background: var(--red-soft);
  color: var(--red);
}

.notify-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 20px 0;
}

/* ---- responsive ---------------------------------------------------------- */

@media (max-width: 640px) {
  .notify-card {
    padding: 16px;
    border-radius: 12px;
  }

  .notify-row-fields {
    grid-template-columns: 1fr;
  }

  .notify-row-aud {
    display: none;
  }

  .notify-row-time {
    font-size: 10px;
  }
}

/* ==========================================================================
   Sidebar shell (issue #47 step 1) — left primary nav + top utility row
   Replaces the old .topbar-spa horizontal layout; iPhone-simple style.
   ========================================================================== */

body {
  display: grid;
  grid-template-columns: var(--sb-w, 248px) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
  min-height: 100dvh;
  transition: grid-template-columns 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

body.sidebar-collapsed { --sb-w: 56px; }

body.on-login-page {
  grid-template-columns: 1fr;
  grid-template-areas:
    "topbar"
    "main";
}
body.on-login-page .sidebar { display: none; }

/* ---- sidebar ---- */
.sidebar {
  grid-area: sidebar;
  background: var(--surface, #fff);
  border-right: 1px solid var(--border-light, #e5e7eb);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 30;
}

.sidebar-brand {
  padding: 18px 16px 12px;
  border-bottom: 1px solid var(--border-light, #e5e7eb);
}
.sidebar-brand-link {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: inherit;
}
.sidebar-brand-icon {
  font-size: 22px; color: var(--accent, #6366f1); flex-shrink: 0;
  width: 28px; text-align: center;
}
.sidebar-brand-text {
  display: flex; flex-direction: column; gap: 1px;
  overflow: hidden; min-width: 0;
  transition: opacity 0.22s ease;
}
.sidebar-brand-title {
  font-size: 14px; font-weight: 700;
  color: var(--text, #111827);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-brand-tag {
  font-size: 11px; color: var(--text-muted, #6b7280);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

body.sidebar-collapsed .sidebar-brand-text {
  opacity: 0; pointer-events: none;
}

/* ---- sidebar sections ---- */
.sidebar-section {
  padding: 8px 8px;
  border-bottom: 1px solid var(--border-light, #e5e7eb);
}
.sidebar-section:last-of-type { border-bottom: none; }

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 4px 8px;
  transition: opacity 0.22s ease;
}
body.sidebar-collapsed .sidebar-section-label { opacity: 0; }

/* ---- subject list / nav items / tools items — uniform sizing ---- */
.sidebar-subject-list,
.sidebar-nav,
.sidebar-tools-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 2px;
}

.sidebar-link,
.sidebar-tools-toggle {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-secondary, #4b5563);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none; background: none;
  width: 100%;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-link:hover,
.sidebar-tools-toggle:hover {
  background: var(--surface-hover, #f3f4f6);
  color: var(--text, #111827);
}
.sidebar-link.active {
  background: var(--accent-soft, #eef2ff);
  color: var(--accent-strong, #4f46e5);
  font-weight: 600;
}

.sidebar-link-icon {
  flex-shrink: 0;
  width: 20px;
  text-align: center;
  font-size: 15px;
}
.sidebar-link-label {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: opacity 0.22s ease;
}
body.sidebar-collapsed .sidebar-link-label,
body.sidebar-collapsed .sidebar-tools-label,
body.sidebar-collapsed .sidebar-tools-chevron {
  /* 不能只 opacity:0 — label flex:1 + chevron 14px 还占着 layout
     空间,图标会偏左。collapsed 用 display:none 真正抹掉布局。 */
  display: none;
}
body.sidebar-collapsed .sidebar-link,
body.sidebar-collapsed .sidebar-tools-toggle {
  justify-content: center;
  padding: 9px 8px;
  gap: 0;   /* gap=10 给 label 留的间距,collapsed 也清掉,让 icon 居中 */
}
/* 统一 icon 视觉:link 和 tools-toggle 用同一字号 + 同一宽度,collapsed
   后 3 类 section(link / exam toggle / tools toggle / lesson link / feedback
   link)纵向严格对齐。 */
body.sidebar-collapsed .sidebar-link-icon,
body.sidebar-collapsed .sidebar-tools-icon {
  font-size: 18px;
  width: 24px;
  line-height: 1;
}

/* ---- tools dropdown ---- */
.sidebar-tools-toggle {
  justify-content: space-between;
}
.sidebar-tools-toggle .sidebar-tools-icon {
  flex-shrink: 0;
  width: 20px;
  text-align: center;
  font-size: 14px;
}
.sidebar-tools-toggle .sidebar-tools-label {
  flex: 1;
}
.sidebar-tools-chevron {
  flex-shrink: 0;
  transition: transform 0.18s ease;
}
.sidebar-tools-toggle[aria-expanded="true"] .sidebar-tools-chevron {
  transform: rotate(180deg);
}

.sidebar-tools-list {
  padding: 4px 0 4px 0;
  margin-left: 0;
  animation: sidebarToolsSlide 0.22s ease;
}
.sidebar-tools-list .sidebar-link {
  padding-left: 36px;
  font-size: 12.5px;
  color: var(--text-muted, #6b7280);
}

@keyframes sidebarToolsSlide {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

body.sidebar-collapsed .sidebar-tools-list { display: none !important; }

/* ---- sidebar footer + collapse button ---- */
.sidebar-footer {
  margin-top: auto;
  padding: 8px;
  border-top: 1px solid var(--border-light, #e5e7eb);
  display: flex;
  justify-content: flex-end;
}
.sidebar-collapse-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border: none; background: none; cursor: pointer;
  border-radius: 8px;
  color: var(--text-muted, #6b7280);
  transition: background 0.15s ease, color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-collapse-btn:hover {
  background: var(--surface-hover, #f3f4f6);
  color: var(--text, #111827);
}
.sidebar-collapse-icon { transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1); }
body.sidebar-collapsed .sidebar-collapse-icon { transform: rotate(180deg); }
body.sidebar-collapsed .sidebar-footer { justify-content: center; }

/* ==========================================================================
   Topbar — minimal utility row (issue #47 step 1)
   ========================================================================== */

.topbar {
  grid-area: topbar;
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  background: var(--surface, #fff);
  border-bottom: 1px solid var(--border-light, #e5e7eb);
  min-height: 48px;
  box-sizing: border-box;
  position: sticky; top: 0; z-index: 20;
}

.topbar-burger {
  display: none;     /* visible on mobile only */
  align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border: none; background: none; cursor: pointer;
  border-radius: 8px;
  color: var(--text-muted, #6b7280);
  -webkit-tap-highlight-color: transparent;
}
.topbar-burger:hover { background: var(--surface-hover, #f3f4f6); }

.topbar-spacer { flex: 1; }

.topbar-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 36px;
  padding: 0 8px;
  border: none; background: none; cursor: pointer;
  border-radius: 8px;
  color: var(--text-muted, #6b7280);
  font-size: 13px; font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.topbar-icon-btn:hover {
  background: var(--surface-hover, #f3f4f6);
  color: var(--text, #111827);
}

/* topbar-tools-slot is filled by tools.js with its 📖 toggle + input row */
.topbar-tools-slot { display: inline-flex; align-items: center; }

/* lang single-button popover (中/EN with horizontal options) */
.topbar-lang-wrap { position: relative; display: inline-flex; }

.topbar-lang-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  display: flex;
  background: var(--surface-elevated, #fff);
  border: 1px solid var(--border-light, #e5e7eb);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15,23,42,0.12);
  padding: 4px;
  gap: 2px;
  z-index: 50;
  animation: topbarLangPop 0.16s ease;
}
@keyframes topbarLangPop {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.topbar-lang-option {
  border: none; background: none; cursor: pointer;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px; color: var(--text, #111827);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.topbar-lang-option:hover { background: var(--surface-hover, #f3f4f6); }
.topbar-lang-option.active {
  background: var(--accent-soft, #eef2ff);
  color: var(--accent-strong, #4f46e5);
  font-weight: 600;
}

/* main content area */
.page {
  grid-area: main;
  padding: 16px 20px;
  overflow-x: hidden;
}

/* ==========================================================================
   Mobile (≤ 720px) — sidebar slides over content; topbar burger visible
   ========================================================================== */

@media (max-width: 720px) {
  body {
    grid-template-columns: 1fr;
    grid-template-areas: "topbar" "main";
  }
  .sidebar {
    position: fixed; top: 0; left: 0;
    width: 248px; height: 100vh; height: 100dvh;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 12px 32px rgba(15,23,42,0.18);
  }
  body.sidebar-mobile-open .sidebar {
    transform: translateX(0);
  }
  .topbar-burger { display: inline-flex; }

  .sidebar-scrim {
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.32);
    z-index: 25;
    animation: scrimFadeIn 0.22s ease;
  }
  @keyframes scrimFadeIn {
    from { opacity: 0; } to { opacity: 1; }
  }
  /* mobile: ignore desktop collapsed state, sidebar is full-width slide */
  body.sidebar-collapsed { --sb-w: 248px; }
  body.sidebar-collapsed .sidebar-link-label,
  body.sidebar-collapsed .sidebar-tools-label,
  body.sidebar-collapsed .sidebar-tools-chevron {
    /* desktop 用 display:none 抹掉布局,mobile 要展开式恢复 */
    display: inline;
    opacity: 1;
  }
  body.sidebar-collapsed .sidebar-section-label,
  body.sidebar-collapsed .sidebar-brand-text {
    opacity: 1;
  }
  body.sidebar-collapsed .sidebar-link,
  body.sidebar-collapsed .sidebar-tools-toggle {
    justify-content: flex-start;
    padding: 9px 12px;
    gap: 10px;
  }
}

/* ==========================================================================
   UI v3 step 1 fixes — page width / sidebar-page height consistency
   (issue #47 follow-up: 左右一致, 不要居中留白)
   ========================================================================== */

/* Make the main column at least as tall as the sidebar so the
   border-right line and the content area visually end at the same Y.
   Topbar is ~48px so we subtract that. */
.page {
  min-height: calc(100vh - 48px);
  min-height: calc(100dvh - 48px);
  align-content: start;
}

/* Sidebar bottom: don't push collapse btn far away from content.
   `margin-top: auto` is fine but the section gap was too generous —
   shrink the gap by tightening section padding. */
.sidebar-section { padding: 6px 8px; }
.sidebar-footer  { padding: 6px 8px; }

/* ---- card defaults: full width inside the column ---- */
.card,
.section.card,
section.card {
  width: 100%;
  max-width: none;
  box-sizing: border-box;
}

/* ---- admin/subjects: clickable subject cards (issue 1+6) ---- */
.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.subject-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  transition: all 0.18s ease;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  cursor: pointer;
}
.subject-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.08);
}
.subject-card-icon {
  width: 42px; height: 42px;
  flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-radius: 10px;
  font-size: 22px;
}
.subject-card-body { flex: 1; min-width: 0; }
.subject-card-title { font-size: 15px; font-weight: 600; }
.subject-card-meta  { font-size: 12px; color: var(--text-muted); margin-top: 2px;
                       white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.subject-card-arrow {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.18s ease;
}
.subject-card:hover .subject-card-arrow {
  color: var(--accent);
  transform: translateX(2px);
}

/* ---- ingest: rebalance left/right widths + single result frame ---- */
.ingest-shell {
  grid-template-columns: 280px minmax(0, 1fr) !important;
  margin: 0 !important;            /* override negative margin from old shell */
  min-height: calc(100vh - 96px);
}
.ingest-sidebar { padding: 18px; }
.ingest-main {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 0;                          /* result is one box, not two */
}
.ingest-main .json-output { flex: 1; margin: 0; }
.ingest-main .empty-state { flex: 1; display: grid; place-items: center; }

/* ---- review: full layout, no inner shrink ---- */
.review-card { width: 100%; }

/* ---- ai/chat tip area: don't wrap, ellipsis instead ---- */
.ai-chat-tip,
.ai-chat-foot .muted {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
  font-size: 12px;
}

/* ---- admin/users: proportional grid for the form-grid sections ---- */
.card .form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.card .form-grid label { display: flex; flex-direction: column; gap: 4px; }
.card .form-grid label > span:first-child {
  font-size: 12px; color: var(--text-muted);
}
.card .form-grid .form-row,
.card .form-grid label.check-row {
  grid-column: 1 / -1;
}

/* ---- admin/audit: border alignment + table fills column ---- */
.audit-table { width: 100%; }
.audit-table .table-wrap { width: 100%; }

/* ---- admin/ai-materials: gentler empty state instead of red 404 ---- */
.ai-mat-empty {
  padding: 28px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---- admin/notifications: top border alignment fix ---- */
.notify-admin-layout > .notify-left,
.notify-admin-layout > .notify-right {
  align-self: stretch;
}
.notify-admin-layout .notify-card { box-sizing: border-box; }

/* ==========================================================================
   UI v3 step 2 — exam login / lesson plan / feedback / admin tweaks
   (issue #47 follow-up batch 2)
   ========================================================================== */

/* ---- Sidebar: collapse btn integrated with brand row, no footer gap ---- */
.sidebar { height: auto; min-height: 100vh; min-height: 100dvh; }
.sidebar-brand {
  display: flex; align-items: center; gap: 8px;
  justify-content: space-between;
}
.sidebar-brand .sidebar-brand-link {
  flex: 1; min-width: 0;
}
.sidebar-collapse-btn {
  width: 28px; height: 28px;
  border: none; background: none; cursor: pointer;
  border-radius: 8px;
  color: var(--text-muted, #6b7280);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.sidebar-collapse-btn:hover { background: var(--surface-hover, #f3f4f6); }
.sidebar-collapse-icon { transition: transform 0.32s cubic-bezier(0.4,0,0.2,1); }
body.sidebar-collapsed .sidebar-collapse-icon { transform: rotate(180deg); }
body.sidebar-collapsed .sidebar-collapse-btn { margin: 0 auto; }

/* sidebar bottom no longer has empty footer area; sections flow top→down */

/* ---- exam login page: A-level style ---- */
.exam-login {
  min-height: calc(100vh - 96px);
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.exam-login-card {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 4px 16px rgba(15,23,42,0.06);
}
.exam-login-head {
  text-align: center;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 18px;
  margin-bottom: 22px;
}
.exam-login-emblem {
  display: inline-grid; place-items: center;
  width: 52px; height: 52px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent2, #8b5cf6));
  color: #fff;
  font-weight: 700; font-size: 16px;
  margin-bottom: 10px;
  letter-spacing: 1px;
}
.exam-login-head h1 {
  margin: 0; font-size: 18px; font-weight: 600;
  color: var(--text);
}
.exam-login-sub {
  margin: 6px 0 0; font-size: 13px; color: var(--text-muted);
}
.exam-login-form { display: grid; gap: 14px; }
.exam-field {
  display: flex; flex-direction: column; gap: 4px;
}
.exam-field span {
  font-size: 12px; color: var(--text-muted); font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.exam-field input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: var(--surface);
  transition: border-color 0.15s ease;
}
.exam-field input:focus {
  outline: none;
  border-color: var(--accent);
}
.exam-login-actions { margin-top: 4px; }
.exam-login-btn {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font: inherit; font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.exam-login-btn:hover { background: var(--accent-strong); }
.exam-login-foot {
  text-align: center; font-size: 11px; margin: 14px 0 0;
}

/* ---- lesson plan tree ---- */
.lesson-page { display: grid; gap: 16px; }
.lesson-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.lesson-badge {
  background: var(--accent-soft); color: var(--accent-strong);
  padding: 4px 10px; border-radius: 9999px;
  font-size: 12px; font-weight: 600;
}
.lesson-tree {
  list-style: none; padding: 0; margin: 0;
}
.lesson-tree > li { margin: 0; }
.lesson-tree > li + li { margin-top: 4px; }
.lesson-tree summary {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  list-style: none;
  font-weight: 500;
  transition: background 0.15s ease;
}
.lesson-tree summary::-webkit-details-marker { display: none; }
.lesson-tree summary:hover { background: var(--surface-hover); }
.lesson-tree-icon {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-strong);
  border-radius: 8px; font-size: 16px;
  flex-shrink: 0;
}
.lesson-tree-name { flex: 1; }
.lesson-tree-units {
  list-style: none;
  margin: 4px 0 8px 44px;
  padding: 0;
  display: grid; gap: 2px;
}
.lesson-unit {
  display: flex; align-items: baseline; gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none; color: var(--text-secondary);
  font-size: 13px;
  transition: background 0.15s ease, color 0.15s ease;
}
.lesson-unit:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.lesson-unit code {
  font-size: 11px;
  padding: 2px 6px;
  background: var(--bg-soft);
  border-radius: 4px;
  color: var(--text-muted);
}

/* ---- feedback board ---- */
.feedback-page { display: grid; gap: 16px; }
.feedback-form { display: grid; gap: 12px; }
.feedback-form label {
  display: flex; flex-direction: column; gap: 4px;
}
.feedback-form label > span {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
}
.feedback-form input,
.feedback-form select,
.feedback-form textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: var(--surface);
}
.feedback-form textarea { resize: vertical; min-height: 120px; }
.feedback-list { display: grid; gap: 10px; }
.feedback-item {
  padding: 12px 14px;
  background: var(--bg-soft);
  border-radius: 10px;
  border-left: 3px solid var(--accent);
}
.feedback-item-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 4px;
}
.feedback-item-kind {
  font-size: 12px; font-weight: 500; color: var(--text);
}
.feedback-item-title { font-weight: 600; font-size: 14px; }
.feedback-item-body {
  font-size: 13px; color: var(--text-secondary); margin-top: 4px;
  white-space: pre-wrap;
}

/* ---- admin/users compactness ---- */
.admin-users-grid .card {
  padding: 14px 16px;        /* tighter than default */
}
.admin-users-grid .card h2 {
  font-size: 14px;
  margin: 0 0 10px;
}
.admin-users-grid .form-grid label {
  font-size: 12px;
}

/* ---- ai chat fill the page area ---- */
.ai-chat-shell {
  width: 100%;
  min-height: calc(100vh - 96px);
  display: flex;
  flex-direction: column;
  padding: 0;
}
.page > .ai-chat-shell {
  margin: 0 -4px;     /* tiny breathing room left/right */
}

/* ---- admin/notifications: text no-wrap + balanced height ---- */
.notify-row-title,
.notify-row-preview,
.notify-row-aud,
.notify-row-time {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notify-row-preview { max-width: 360px; }

/* ---- ingest: balance left+right column heights ---- */
.ingest-shell { align-items: stretch !important; }
.ingest-sidebar,
.ingest-main { height: 100%; }

/* ==========================================================================
   UI v3 step 2 batch 2 — exam-stub fullscreen, lesson polish, feedback,
   admin/users form-foot, admin pages full width  (issue #47 follow-up)
   ========================================================================== */

/* exam-stub: full-page centered card */
.exam-stub-page {
  min-height: calc(100vh - 96px);
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.exam-stub-card {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 48px 32px;
  text-align: center;
  box-shadow: 0 4px 16px rgba(15,23,42,0.06);
}
.exam-stub-card h2 { margin: 0 0 12px; font-size: 18px; }
.exam-stub-icon { font-size: 48px; margin-bottom: 12px; }
.exam-stub-msg {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 20px;
}

/* lesson: tighter shell, no color step between sections */
.lesson-shell { padding: 0 !important; overflow: hidden; }
.lesson-shell .lesson-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-light);
}
.lesson-shell .lesson-head h2 { margin: 0; font-size: 16px; }
.lesson-shell .lesson-tree {
  list-style: none; padding: 8px; margin: 0;
}
.lesson-tree summary {
  position: relative;
}
.lesson-tree-count {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-soft);
  padding: 2px 8px;
  border-radius: 9999px;
}
.lesson-tree-chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.18s ease;
}
.lesson-tree details[open] > summary > .lesson-tree-chevron {
  transform: rotate(180deg);
}

/* feedback-board: consistent form alignment */
.feedback-page {
  min-height: calc(100vh - 96px);
}
.feedback-page .card { width: 100%; }
.feedback-title { margin: 0 0 4px; font-size: 16px; }
.feedback-hint { margin: 0 0 16px; color: var(--text-muted); font-size: 13px; }
.feedback-subtitle { margin: 0 0 12px; font-size: 14px; }
.feedback-form .form-row {
  display: flex; align-items: center; gap: 12px;
}
.feedback-response {
  padding: 14px 16px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  white-space: pre-wrap;
  font-size: 13px;
}

/* admin/users form-foot row: TOTP + Create align horizontally */
.form-foot {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
  margin-top: 4px;
}
.form-foot .check-row {
  margin: 0;
  display: flex; align-items: center; gap: 6px;
  font-size: 13px;
}
.form-foot-actions {
  display: flex; align-items: center; gap: 10px;
}

/* admin/* pages: full width inside main column (no centred narrow look) */
#page > section.card,
#page > .feedback-page,
#page > .exam-login,
#page > .exam-stub-page,
#page > .lesson-page,
#page > .ai-chat-shell {
  width: 100%; max-width: none;
}

/* admin/notifications right pane — make textarea use available height */
@media (min-width: 800px) {
  .notify-admin-layout { min-height: calc(100vh - 96px); }
  .notify-admin-layout > .notify-right { display: flex; flex-direction: column; gap: 16px; }
  .notify-admin-layout > .notify-right .notify-card:first-child { flex: 0 0 auto; }
  .notify-admin-layout > .notify-right .notify-card:nth-child(2) { flex: 1; min-height: 0; }
}

/* review page full-size frame */
#page > section.card { min-height: 240px; }
.review-card,
section.card.review { min-height: calc(100vh - 96px); }

/* ==========================================================================
   AI welcome card — first-load onboarding (issue #47 step 2)
   Sparkle ✦ animation + fade-in + tidy bullet list
   ========================================================================== */

.ai-welcome {
  background: linear-gradient(135deg,
              var(--accent-soft, #eef2ff) 0%,
              var(--surface, #fff) 65%);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 24px 26px;
  margin: 8px 0;
  box-shadow: 0 4px 18px rgba(99, 102, 241, 0.08);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  animation: aiWelcomeIn 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

@keyframes aiWelcomeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Subtle gradient bg dots */
.ai-welcome::before,
.ai-welcome::after {
  content: "";
  position: absolute;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent, #6366f1);
  opacity: 0;
  pointer-events: none;
  filter: blur(0.5px);
}
.ai-welcome::before { top: 18px; right: 38px; animation: aiSpark 2.4s ease-in-out infinite; }
.ai-welcome::after  { top: 56px; right: 22px; width: 6px; height: 6px;
                       animation: aiSpark 2.4s ease-in-out infinite 0.8s; }

.ai-welcome-greet {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.ai-welcome-title {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  display: flex; align-items: center; gap: 8px;
}

.ai-welcome-spark {
  display: inline-block;
  color: var(--accent, #6366f1);
  animation: aiSparkRotate 3s ease-in-out infinite;
  filter: drop-shadow(0 0 4px rgba(99,102,241,0.4));
}

@keyframes aiSparkRotate {
  0%, 100% { transform: rotate(0) scale(1);   opacity: 1; }
  50%      { transform: rotate(180deg) scale(1.2); opacity: 0.7; }
}

@keyframes aiSpark {
  0%, 100% { opacity: 0;   transform: scale(0.5); }
  50%      { opacity: 0.6; transform: scale(1); }
}

.ai-welcome-lead,
.ai-welcome-cta {
  margin: 0 0 12px;
  color: var(--text-secondary);
}
.ai-welcome-cta {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

.ai-welcome-list,
.ai-welcome-soon-list {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}
.ai-welcome-list li,
.ai-welcome-soon-list li {
  padding: 4px 0;
  color: var(--text);
  font-size: 13.5px;
}
.ai-welcome-soon-title {
  margin: 16px 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.ai-welcome-soon-list li {
  color: var(--text-muted);
  font-size: 13px;
  position: relative;
  padding-left: 16px;
}
.ai-welcome-soon-list li::before {
  content: "·";
  position: absolute;
  left: 4px;
  color: var(--accent);
}

/* The welcome lives at the top of .ai-chat-msgs and isn't a regular
   .ai-msg bubble — opt out of bubble styling. */
.ai-msg-welcome.ai-msg { all: unset; }

/* ──────────────────────────────────────────────────────────────────────────
   AI chat — background-image controls (issue #47 step 3)
   Two small icon buttons inline in the chat-head action row (next to the
   quota pill and clear-chat button): cycle (⇄) + upload (image-icon).
   At-cap behavior: upload replaces oldest + brief friendly toast appears
   under the chat-head bar.
   ──────────────────────────────────────────────────────────────────────────*/
.ai-chat-shell { position: relative; overflow: hidden; }

/* Bg image lives BEHIND the conversation messages area only — not the
   head bar / input bar.  Sized cover so it fully fills the msgs area
   regardless of the image's aspect ratio.  Opacity is gentle enough
   to keep chat bubbles readable but visible enough that the picture
   actually shows. */
.ai-chat-msgs { position: relative; }
.ai-chat-msgs.has-bg::before {
  content: "";
  position: absolute; inset: 0;
  background-image: var(--ai-bg-image);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.55;
  pointer-events: none;
  z-index: 0;
}
.ai-chat-msgs > * { position: relative; z-index: 1; }

.ai-bg-cycle-btn,
.ai-bg-add-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  padding: 0;
  border-radius: 8px;
  color: var(--text-muted, #6b7280);
}
.ai-bg-cycle-btn:hover,
.ai-bg-add-btn:hover {
  color: var(--accent-strong, #4f46e5);
}

.ai-bg-toast {
  position: absolute;
  top: 100%;
  right: 16px;
  margin-top: 6px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text, #111827);
  background: var(--surface-elevated, #fff);
  border: 1px solid var(--border-light, #e5e7eb);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 5;
  white-space: nowrap;
}
.ai-bg-toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ============ subjects catalog (issue #90) ============ */
.subjects-catalog-card { padding: 24px; max-width: 1200px; margin: 0 auto; }
.catalog-head h2 { margin: 0 0 4px 0; }
.catalog-head .muted { font-size: 13px; }

.board-tabs {
  display: flex; gap: 8px; margin: 16px 0;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 0;
}
.board-tab {
  padding: 8px 16px; font-size: 13px; cursor: pointer;
  background: transparent; border: none; border-bottom: 2px solid transparent;
  color: var(--text-muted); font-weight: 500; transition: all 0.15s;
}
.board-tab:hover { color: var(--text); }
.board-tab.active {
  color: var(--accent-strong); border-bottom-color: var(--accent-strong);
}

.subject-grid { display: flex; flex-direction: column; gap: 24px; }
.board-group { display: flex; flex-direction: column; gap: 10px; }
.board-title {
  margin: 8px 0 0 0; font-size: 14px; font-weight: 600;
  color: var(--text-muted); letter-spacing: 0.04em;
}

.subject-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.subject-card {
  display: block; padding: 16px; background: var(--surface);
  border: 1px solid var(--border-light); border-radius: var(--radius-lg);
  text-decoration: none; color: inherit;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
  position: relative; overflow: hidden;
}
.subject-card.active {
  cursor: pointer;
}
.subject-card.active:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-soft);
  text-decoration: none;
}
.subject-card.placeholder {
  opacity: 0.55; cursor: not-allowed;
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-hover) 100%);
}

.subject-card-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.subject-emoji { font-size: 28px; }
.subject-status {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-strong); font-weight: 500;
}
.subject-card.placeholder .subject-status {
  background: var(--surface-hover); color: var(--text-muted);
}

.subject-name {
  margin: 4px 0 2px 0; font-size: 16px; font-weight: 600;
}
.subject-board {
  font-size: 12px; margin: 0;
}

.subject-stats {
  display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap;
}
.stat-pill {
  font-size: 11px; padding: 3px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-strong);
  font-weight: 500;
}
.stat-pill.placeholder {
  background: var(--surface-hover); color: var(--text-muted);
}

.catalog-footer {
  margin-top: 24px; padding-top: 16px;
  border-top: 1px dashed var(--border-light); font-size: 13px;
  text-align: center;
}

/* chat 顶部 subject 选择器 (issue #90 v2) */
.ai-subject-select {
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  max-width: 220px;
}
.ai-subject-select:hover { border-color: var(--accent); }
.ai-subject-select:focus { outline: none; border-color: var(--accent-strong); }

/* ============================================================
   epic #104 Phase A — 学习阅读器(reader.js)
   ============================================================ */

.reader-page {
  display: flex; flex-direction: column;
  height: calc(100vh - 80px);
  padding: 0;
}

/* reader 学科讲义未上线 - 友好提示卡片 */
.reader-not-ready {
  text-align: center;
  padding: 60px 24px;
  max-width: 480px;
  margin: 24px auto;
}
.reader-not-ready h3 {
  margin: 0 0 12px 0;
  font-size: 20px;
  color: var(--text, #111827);
}
.reader-not-ready p { line-height: 1.6; }

.reader-toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--surface, #fff);
  color: var(--text, #333);
  border-bottom: 1px solid var(--border-light, #ddd);
  flex-wrap: wrap;
}
/* cnb#16:back 单独 bar 不受 toolbar collapse 影响, 永远 可点 */
.reader-back-bar {
  padding: 8px 16px 4px;
  background: var(--surface, #fff);
}
.reader-toolbar label {
  font-size: 0.9em;
  color: var(--text-muted, #666);
  display: flex; align-items: center; gap: 6px;
}
.reader-toolbar select {
  padding: 4px 8px;
  border: 1px solid var(--border-light, #ccc);
  border-radius: 4px;
  background: var(--surface, #fff);
  color: var(--text, #333);
}
.reader-toolbar .btn-back {
  text-decoration: none;
  color: var(--accent, #0066cc);
  padding: 4px 8px;
  border-radius: 4px;
}
.reader-toolbar .btn-back:hover { background: rgba(99, 102, 241, .12); }
.reader-toolbar .reader-subject {
  font-size: 1.1em;
}
.reader-toolbar-spacer { flex: 1; }
.reader-toolbar button {
  padding: 4px 12px;
  border: 1px solid var(--border-light, #ccc);
  border-radius: 4px;
  background: var(--surface, #fff);
  color: var(--text, #333);
  cursor: pointer;
}
.reader-toolbar button:disabled {
  opacity: 0.4; cursor: not-allowed;
}
.reader-toolbar button:hover:not(:disabled) {
  background: var(--accent, #0066cc);
  color: white;
  border-color: var(--accent, #0066cc);
}

.reader-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  flex: 1;
  overflow: hidden;
}

.reader-outline {
  background: var(--bg-soft, #f7f7f8);
  border-right: 1px solid var(--border, #ddd);
  padding: 16px 12px;
  overflow-y: auto;
  font-size: 0.9em;
}
.reader-subj-info {
  padding: 8px 4px 14px;
  border-bottom: 1px solid var(--border, #e2e2e2);
  margin-bottom: 8px;
}
.reader-subj-info h4 { margin: 0 0 4px 0; font-size: 1em; }
.reader-subj-info p.muted { margin: 2px 0; font-size: 0.8em; }

.reader-outline-list {
  list-style: none;
  padding: 0; margin: 0;
}
.reader-outline-list li { padding: 2px 0; }
/* heading 层级 → outline 缩进:H2 一级 / H3 二级 / H4 三级 / H5+ 四级.
   cnb#145 Phase 6:之前只覆盖 H2/H3,H4+ 跑到左侧 0px,
   sprint_review (### Unit / #### topic) 视觉倒挂. */
.reader-outline-list li.lvl-2 { font-weight: 600; padding-left: 4px; }
.reader-outline-list li.lvl-3 { padding-left: 18px; font-weight: 500; }
.reader-outline-list li.lvl-4 { padding-left: 32px; font-weight: 400; font-size: 13px; }
.reader-outline-list li.lvl-5,
.reader-outline-list li.lvl-6 { padding-left: 46px; font-weight: 400; font-size: 12px; color: #64748b; }
.reader-outline-list li a {
  display: block;
  text-decoration: none;
  color: var(--text, #333);
  padding: 3px 6px;
  border-radius: 4px;
  line-height: 1.4;
}
.reader-outline-list li a:hover {
  background: rgba(0,102,204,.08);
  color: var(--accent, #0066cc);
}
.reader-outline-list li a.active {
  background: var(--accent, #0066cc);
  color: white;
}
/* === cnb#143 outline 已读章节标记(默认开启,toolbar 👁 toggle 控制) === */
.reader-outline-list li.done > a { color: var(--emerald-600, #059669); }
.reader-outline-list li.done > a::before {
  content: "✓"; display: inline-block; margin-right: 6px;
  color: var(--emerald-500, #10b981); font-weight: 600;
}
/* hide-progress 关闭已读差异:恢复默认色,隐藏 ✓ 前缀 */
.reader-outline.hide-progress .reader-outline-list li.done > a { color: inherit; }
.reader-outline.hide-progress .reader-outline-list li.done > a::before { display: none; }
[data-theme="dark"] .reader-outline-list li.done > a,
.theme-dark .reader-outline-list li.done > a { color: #6ee7b7; }
[data-theme="dark"] .reader-outline-list li.done > a::before,
.theme-dark .reader-outline-list li.done > a::before { color: #6ee7b7; }
/* toggle btn off 状态视觉 */
.reader-toolbar .rd-action.rd-action-off { opacity: 0.55; }

.reader-content {
  padding: 20px 32px;
  overflow-y: auto;
  line-height: 1.7;
}
.reader-content h1 { font-size: 1.8em; margin: 24px 0 16px; }
.reader-content h2 { font-size: 1.4em; margin: 22px 0 12px; padding-bottom: 4px;
  border-bottom: 1px solid var(--border, #eee); }
.reader-content h3 { font-size: 1.15em; margin: 18px 0 10px; }
.reader-content h4 { font-size: 1em; margin: 14px 0 8px; color: var(--muted, #555); }
.reader-content p { margin: 8px 0; }
.reader-content blockquote {
  margin: 12px 0;
  padding: 8px 16px;
  border-left: 4px solid var(--accent, #0066cc);
  background: rgba(0,102,204,.04);
  color: var(--muted, #555);
}
.reader-content blockquote p { margin: 4px 0; }
.reader-content pre {
  background: #f4f4f4;
  padding: 12px;
  overflow-x: auto;
  border-radius: 4px;
  border: 1px solid var(--border, #e2e2e2);
}
.reader-content code {
  background: #f4f4f4;
  padding: 1px 6px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.9em;
}
.reader-content pre code {
  background: transparent;
  padding: 0;
}
.reader-content table.reader-table {
  border-collapse: collapse;
  margin: 12px 0;
  width: 100%;
}
.reader-content table.reader-table th,
.reader-content table.reader-table td {
  border: 1px solid var(--border, #ddd);
  padding: 6px 10px;
  text-align: left;
}
.reader-content table.reader-table th {
  background: var(--bg-soft, #f7f7f8);
  font-weight: 600;
}
.reader-content ul, .reader-content ol {
  margin: 8px 0; padding-left: 28px;
}
.reader-content img {
  max-width: 100%; height: auto;
  border-radius: 4px;
  display: block;
  margin: 12px auto;
}

@media (max-width: 768px) {
  .reader-layout { grid-template-columns: 1fr; }
  .reader-outline { display: none; }
}

/* ============================================================
   epic #104 Phase B — 笔记 + 书签
   ============================================================ */

.reader-layout { position: relative; }

.reader-panel {
  background: var(--bg-card, #fff);
  border-left: 1px solid var(--border, #ddd);
  width: 320px;
  display: flex; flex-direction: column;
  overflow: hidden;
  position: absolute;
  right: 0; top: 0; bottom: 0;
  z-index: 10;
  box-shadow: -4px 0 12px rgba(0,0,0,0.06);
}
.reader-panel-head {
  display: flex;
  border-bottom: 1px solid var(--border, #ddd);
  background: var(--bg-soft, #f7f7f8);
}
.panel-tab {
  flex: 1;
  padding: 10px 0;
  border: none; background: transparent;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  color: var(--muted, #666);
}
.panel-tab.active {
  color: var(--accent, #0066cc);
  border-bottom-color: var(--accent, #0066cc);
  font-weight: 600;
}
.panel-close {
  border: none; background: transparent;
  cursor: pointer;
  font-size: 1.3em;
  padding: 0 16px;
  color: var(--muted, #888);
}
.panel-close:hover { color: #b91c1c; }

.reader-panel-body {
  overflow-y: auto;
  padding: 12px;
  flex: 1;
}

.note-card, .bookmark-card {
  background: var(--bg-soft, #fafafa);
  border: 1px solid var(--border, #e2e2e2);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 10px;
  font-size: 0.9em;
}
.note-card-head, .bookmark-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85em;
  margin-bottom: 6px;
}
.note-del, .bookmark-del {
  border: none; background: transparent;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
}
.note-del:hover, .bookmark-del:hover { background: rgba(185,28,28,0.1); }
.note-quote {
  font-style: italic;
  color: var(--muted, #666);
  border-left: 2px solid var(--accent, #0066cc);
  padding-left: 8px;
  margin: 4px 0;
}
.note-text {
  white-space: pre-wrap;
  line-height: 1.5;
  margin: 4px 0;
}
.note-jump, .bookmark-jump {
  font-size: 0.85em;
  color: var(--accent, #0066cc);
  text-decoration: none;
  cursor: pointer;
  display: inline-block;
  margin-top: 4px;
}
.note-jump:hover, .bookmark-jump:hover { text-decoration: underline; }

/* Note floater (划词 → 弹笔记编辑框)*/
.note-floater {
  position: fixed;
  right: 30px;
  width: 340px;
  background: white;
  border: 1px solid var(--border, #ccc);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.12);
  padding: 12px;
  z-index: 100;
}
.note-floater-head {
  font-weight: 600;
  margin-bottom: 8px;
}
.note-floater-quote {
  font-style: italic;
  color: var(--muted, #555);
  background: var(--bg-soft, #f7f7f8);
  border-left: 3px solid var(--accent, #0066cc);
  padding: 6px 10px;
  font-size: 0.85em;
  margin-bottom: 8px;
  border-radius: 3px;
  max-height: 80px;
  overflow-y: auto;
}
.note-floater textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border, #ccc);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.95em;
  box-sizing: border-box;
  resize: vertical;
}
.note-floater-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.note-floater-actions button {
  padding: 6px 14px;
  border: 1px solid var(--border, #ccc);
  border-radius: 4px;
  background: white;
  cursor: pointer;
}
.note-floater-actions button.primary {
  background: var(--accent, #0066cc);
  color: white;
  border-color: var(--accent, #0066cc);
}
.note-floater-actions button.primary:hover {
  background: var(--accent-strong, #004999);
}

/* ───────── reader toolbar polish (epic #104 UI revamp) ───────── */

.reader-toolbar {
  align-items: center;
  flex-wrap: wrap;
  row-gap: 8px;
}
.reader-toolbar .btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text, #333);
  background: var(--surface-2, #f0f2f5);
  font-weight: 500;
}
.reader-toolbar .btn-back:hover { background: var(--surface-3, #e1e5eb); }
.reader-toolbar .rd-ico { font-size: 1.05em; line-height: 1; }
.reader-toolbar .rd-selector {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-2, #f0f2f5);
  border-radius: 6px;
  padding: 0 4px 0 8px;
  height: 32px;
}
.reader-toolbar .rd-selector select {
  background: transparent;
  border: none;
  height: 28px;
  padding: 0 4px;
  font: inherit;
  cursor: pointer;
  outline: none;
  color: inherit;
  min-width: 80px;
}
.reader-toolbar .rd-selector select:focus-visible {
  outline: 2px solid var(--accent, #0066cc);
  outline-offset: 2px;
  border-radius: 4px;
}
.reader-toolbar .rd-pager {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-2, #f0f2f5);
  border-radius: 6px;
  padding: 2px 6px;
}
.reader-toolbar .rd-icon-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 4px;
  font-size: 1em;
  line-height: 1;
}
.reader-toolbar .rd-icon-btn:hover:not(:disabled) { background: var(--surface-3, #e1e5eb); }
.reader-toolbar .rd-icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.reader-toolbar .rd-progress {
  font-variant-numeric: tabular-nums;
  font-size: 0.85em;
  padding: 0 4px;
  white-space: nowrap;
}
.reader-toolbar .rd-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border, #d0d4da);
  background: var(--surface, white);
  color: var(--text, #333);
  cursor: pointer;
  font: inherit;
  white-space: nowrap;
}
.reader-toolbar .rd-action:hover { background: var(--surface-2, #f0f2f5); }
.reader-toolbar .rd-action.rd-ok { background: var(--ok-soft, #d1fae5); border-color: var(--ok, #16a34a); }
.reader-toolbar .rd-action-primary {
  background: var(--accent, #0066cc);
  color: white;
  border-color: var(--accent, #0066cc);
}
.reader-toolbar .rd-action-primary:hover { background: var(--accent-strong, #004999); }
.reader-toolbar .rd-action .rd-label { font-weight: 500; }
.reader-toolbar .rd-action .rd-badge {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 0 8px;
  font-size: 0.78em;
  font-variant-numeric: tabular-nums;
  min-width: 18px;
  text-align: center;
}
.reader-toolbar .rd-action:not(.rd-action-primary) .rd-badge {
  background: var(--surface-3, #e1e5eb);
  color: var(--text, #333);
}

/* 折叠按钮 — 嵌在工具栏右端,弱化样式 */
.reader-toolbar .rd-collapse {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  padding: 0; margin-left: 4px;
  background: transparent;
  border: 1px solid var(--border-light, #e3e8ef);
  border-radius: 50%;
  color: var(--text-muted, #6b7280);
  font-size: 14px; line-height: 1;
  cursor: pointer;
}
.reader-toolbar .rd-collapse:hover {
  background: var(--surface-2, #f3f4f6);
  color: var(--text, #1f2937);
}
/* 工具栏收起后浮出的展开按钮 — 顶部固定,小箭头吸引点击 */
.rd-expand-floating {
  position: fixed;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  width: 56px; height: 22px;
  padding: 0; line-height: 1;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--border-light, #e3e8ef);
  border-radius: 0 0 12px 12px;
  border-top: none;
  color: var(--text-muted, #6b7280);
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
.rd-expand-floating:hover {
  background: var(--accent, #2563eb);
  color: #fff;
}

/* dark-mode toolbar surfaces — app uses [data-theme="dark"] attr,不是
   class [data-theme="dark"]。之前选择器永远不匹配,导致暗色模式下 toolbar 用浅
   色 surface + 白底,字几乎看不见。2026-05-13 修。 */
[data-theme="dark"] .reader-toolbar .btn-back,
[data-theme="dark"] .reader-toolbar .rd-selector,
[data-theme="dark"] .reader-toolbar .rd-pager,
[data-theme="dark"] .reader-toolbar .rd-action:not(.rd-action-primary) {
  background: rgba(255,255,255,0.08);
  color: var(--text, #e5e7eb);
}
[data-theme="dark"] .reader-toolbar .rd-action:not(.rd-action-primary) {
  border-color: rgba(255,255,255,0.18);
}
[data-theme="dark"] .reader-toolbar .btn-back:hover,
[data-theme="dark"] .reader-toolbar .rd-icon-btn:hover:not(:disabled),
[data-theme="dark"] .reader-toolbar .rd-action:not(.rd-action-primary):hover {
  background: rgba(255,255,255,0.14);
}
[data-theme="dark"] .reader-toolbar .rd-selector select,
[data-theme="dark"] .reader-toolbar .rd-selector select option {
  color: var(--text, #e5e7eb);
  background-color: var(--surface, #263148);
}
[data-theme="dark"] .reader-toolbar .rd-progress { color: var(--text-muted, #d1d5db); }
/* 翻页 ↑↓ 按钮在 dark 下也得有边框 + 亮 hover */
[data-theme="dark"] .reader-toolbar .rd-icon-btn {
  color: var(--text, #e5e7eb);
}
/* primary action(标记/Marks 按钮)dark 下保持 accent 紫色 */
[data-theme="dark"] .reader-toolbar .rd-action-primary {
  background: var(--accent, #6366f1);
  color: #fff;
  border-color: var(--accent, #6366f1);
}
[data-theme="dark"] .reader-toolbar .rd-action-primary:hover {
  background: var(--accent-strong, #4f46e5);
}
[data-theme="dark"] .reader-toolbar select {
  color: var(--text, #e5e7eb);
  background: var(--surface, #263148);
  border-color: rgba(255,255,255,0.18);
}

/* ─── long-table scroll wrap + sticky header ─── */
.reader-content .reader-table-wrap {
  position: relative;
  max-width: 100%;
  overflow-x: auto;
  margin: 12px 0;
  border: 1px solid var(--border, #e1e5eb);
  border-radius: 6px;
  -webkit-overflow-scrolling: touch;
}
.reader-content .reader-table {
  border-collapse: collapse;
  width: max-content;     /* shrink-wrap so wrapper scrolls */
  min-width: 100%;
}
.reader-content .reader-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2, #f3f4f6);
  z-index: 1;
  border-bottom: 1px solid var(--border, #d0d4da);
  text-align: left;
  padding: 8px 12px;
  white-space: nowrap;
}
.reader-content .reader-table tbody td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border-soft, #eef0f3);
  vertical-align: top;
  line-height: 1.45;
}
.reader-content .reader-table tbody tr:nth-child(odd) { background: var(--surface-1, #fafbfc); }
.reader-content .reader-table tbody tr:hover { background: var(--surface-3, #eef2f7); }

/* swipe-hint shown only when actually overflowing */
.reader-content .reader-table-wrap::after {
  content: attr(data-hint);
  position: absolute;
  right: 8px;
  bottom: 6px;
  font-size: 0.72em;
  color: var(--muted, #6b7280);
  background: var(--surface-1, #fafbfcdd);
  padding: 2px 8px;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.reader-content .reader-table-wrap.is-overflow::after { opacity: 1; }
[data-theme="dark"] .reader-content .reader-table thead th { background: rgba(255,255,255,0.06); }
[data-theme="dark"] .reader-content .reader-table tbody tr:nth-child(odd) { background: rgba(255,255,255,0.02); }

/* ───────── lesson-plan (考点学习入口) page ───────── */
.lp-page { display: flex; flex-direction: column; gap: 18px; padding: 8px 0; }
.lp-hero h2 { margin: 0 0 4px; }
.lp-hero p { margin: 0; }
.lp-board {
  background: var(--surface, white);
  border: 1px solid var(--border, #e1e5eb);
  border-radius: 10px;
  padding: 16px 18px 18px;
}
.lp-board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.lp-board-head h3 { margin: 0; font-size: 1.05em; }
.lp-board-count {
  background: var(--surface-2, #f0f2f5);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.8em;
  color: var(--muted, #6b7280);
  font-variant-numeric: tabular-nums;
}
.lp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.lp-subject {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border, #e1e5eb);
  border-radius: 8px;
  background: var(--surface-1, #fafbfc);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.lp-subject:hover {
  border-color: var(--accent, #0066cc);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
.lp-subject-icon {
  font-size: 1.8em;
  width: 40px;
  text-align: center;
}
.lp-subject-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
}
.lp-subject-name {
  font-weight: 600;
  font-size: 0.98em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lp-subject-meta {
  font-size: 0.82em;
  color: var(--muted, #6b7280);
}
.lp-subject-badge {
  font-size: 0.72em;
  background: var(--ok-soft, #d1fae5);
  color: var(--ok-strong, #047857);
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.lp-subject-badge-soon {
  background: var(--surface-2, #f0f2f5);
  color: var(--muted, #6b7280);
}
.lp-subject-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}
[data-theme="dark"] .lp-board { background: rgba(255,255,255,0.02); }
[data-theme="dark"] .lp-subject { background: rgba(255,255,255,0.02); }
[data-theme="dark"] .lp-subject-badge { background: rgba(34,197,94,0.18); color: #6ee7b7; }
[data-theme="dark"] .lp-subject-badge-soon { background: rgba(255,255,255,0.06); color: var(--muted, #94a3b8); }

/* ───────── Phase C bubble tips (heading 💡 chip + popover) ───────── */
.reader-content h2,
.reader-content h3 { position: relative; }
.tip-chip {
  margin-left: 8px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--border, #d0d4da);
  border-radius: 50%;
  background: linear-gradient(135deg, #fff7d6 0%, #fde68a 100%);
  cursor: pointer;
  font-size: 0.85em;
  line-height: 22px;
  vertical-align: middle;
  transition: transform 0.12s, box-shadow 0.12s;
}
.tip-chip:hover {
  transform: scale(1.12);
  box-shadow: 0 2px 6px rgba(252, 211, 77, 0.5);
}
/* 右侧固定 tips 侧板:不再追随章节标题定位 — 永远贴右贴满高度,
   内容可滚,× 关闭 / Esc 关闭。AI dock 折叠时 bottom 留 48px,展开时 reader.js
   会加 .dock-expanded 让 bottom 退到 380px。 */
.tip-bubble {
  position: fixed;
  top: 64px;           /* 留 toolbar 高度 */
  right: 0;
  bottom: 48px;        /* 默认 AI dock 折叠高度 */
  width: min(400px, 92vw);
  background: var(--surface, #fff);
  border: 1px solid var(--border, #d0d4da);
  border-right: none;
  border-radius: 12px 0 0 12px;
  box-shadow: -8px 0 24px rgba(0,0,0,0.18);
  font-size: 0.92em;
  display: flex;
  flex-direction: column;
  z-index: 70;          /* 在 AI dock(60) 之上 */
  transform: translateX(0);
  transition: transform 0.22s ease-out;
}
.tip-bubble[hidden] {
  display: flex !important;
  transform: translateX(100%);
  pointer-events: none;
}
.tip-bubble.dock-expanded {
  bottom: 380px;
}
.tip-bubble-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: linear-gradient(90deg, #fef3c7 0%, #fed7aa 100%);
  border-bottom: 1px solid var(--border, #d0d4da);
  flex: 0 0 auto;
}
.tip-bubble-title {
  flex: 1 1 auto;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tip-bubble-close {
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(0,0,0,0.06);
  border-radius: 50%;
  font-size: 1.1em;
  cursor: pointer;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tip-bubble-close:hover { background: rgba(0,0,0,0.12); }
.tip-bubble-tabs {
  display: flex;
  gap: 4px;
  padding: 6px;
  border-bottom: 1px solid var(--border-soft, #eef0f3);
  background: var(--surface-1, #fafbfc);
  flex: 0 0 auto;
}
.tip-tab {
  flex: 1;
  padding: 7px 4px;
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 0.85em;
  border-radius: 6px;
  white-space: nowrap;
}
.tip-tab.active {
  background: var(--accent, #0066cc);
  color: white;
}
.tip-tab:hover:not(.active) { background: var(--surface-2, #f0f2f5); }
/* 正文区域:flex grow + 自适应 scroll */
.tip-bubble-body {
  padding: 16px 18px;
  line-height: 1.6;
  flex: 1 1 auto;
  overflow-y: auto;
  font-size: 0.95em;
  word-break: break-word;
  white-space: pre-wrap;
}
.tip-bubble-body::-webkit-scrollbar { width: 8px; }
.tip-bubble-body::-webkit-scrollbar-thumb {
  background: var(--border, #d0d4da);
  border-radius: 4px;
}
.tip-bubble-body:empty::before {
  content: "—";
  color: var(--muted, #94a3b8);
}
.tip-bubble-foot {
  padding: 8px 14px;
  font-size: 0.78em;
  border-top: 1px solid var(--border-soft, #eef0f3);
  background: var(--surface-1, #fafbfc);
  flex: 0 0 auto;
}
[data-theme="dark"] .tip-bubble {
  background: #1f2937;
  border-color: rgba(255,255,255,0.12);
  box-shadow: -8px 0 24px rgba(0,0,0,0.45);
}
[data-theme="dark"] .tip-bubble-head {
  background: linear-gradient(90deg, rgba(252,211,77,0.18), rgba(251,146,60,0.18));
}
[data-theme="dark"] .tip-bubble-tabs,
[data-theme="dark"] .tip-bubble-foot { background: rgba(255,255,255,0.04); }
[data-theme="dark"] .tip-bubble-close { background: rgba(255,255,255,0.10); }
[data-theme="dark"] .tip-bubble-close:hover { background: rgba(255,255,255,0.18); }
/* 小屏全宽 */
@media (max-width: 600px) {
  .tip-bubble {
    top: 56px;
    bottom: 48px;
    width: 100vw;
    border-radius: 0;
    border-left: none;
  }
}

/* ───────── 底部 AI 对话栏 (F-lite) ───────── */
.reader-ai-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface, #fff);
  border-top: 1px solid var(--border, #d0d4da);
  box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
  z-index: 60;
  display: flex;
  flex-direction: column;
  transition: max-height 0.25s ease-out;
  max-height: 48px;
}
.reader-ai-dock[data-open="1"] { max-height: 380px; }
.ai-dock-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: linear-gradient(90deg, #dbeafe 0%, #ede9fe 100%);
  border: none;
  cursor: pointer;
  font: inherit;
  width: 100%;
  text-align: left;
}
.ai-dock-title { font-weight: 600; }
.ai-dock-sub { flex: 1; font-size: 0.85em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-dock-chev { font-size: 0.85em; opacity: 0.6; }
.ai-dock-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  padding: 10px 16px 12px;
  overflow: hidden;
}
.reader-ai-dock[data-open="0"] .ai-dock-body { display: none; }
.ai-dock-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.ai-chip {
  padding: 5px 12px;
  border: 1px solid var(--accent, #0066cc);
  color: var(--accent, #0066cc);
  background: white;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 0.85em;
  transition: background 0.1s, color 0.1s;
}
.ai-chip:hover {
  background: var(--accent, #0066cc);
  color: white;
}
.ai-dock-log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 4px 2px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 80px;
}
.ai-bubble {
  max-width: 88%;
  padding: 8px 12px;
  border-radius: 12px;
  line-height: 1.5;
  font-size: 0.92em;
}
.ai-bubble-user {
  background: var(--accent, #0066cc);
  color: white;
  align-self: flex-end;
}
.ai-bubble-bot {
  background: var(--surface-1, #f5f6f8);
  color: var(--text, #333);
  align-self: flex-start;
  border: 1px solid var(--border-soft, #eef0f3);
}
.ai-bubble-foot {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
  font-size: 0.78em;
}
.ai-bubble-ctx { font-style: italic; }
.ai-save-btn {
  padding: 2px 10px;
  border: 1px solid var(--border, #d0d4da);
  background: white;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 0.85em;
}
.ai-save-btn:hover { background: var(--surface-2, #f0f2f5); }
.ai-save-btn:disabled { opacity: 0.55; cursor: default; background: var(--ok-soft, #d1fae5); border-color: var(--ok, #16a34a); }
.ai-bubble-pending .ai-bubble-body::after {
  content: " …";
  animation: ai-bubble-blink 1s linear infinite;
}
.ai-bubble-err { background: #fee2e2; color: #991b1b; }
@keyframes ai-bubble-blink {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}
.ai-dock-actions {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
}
.ai-dock-actions button {
  padding: 4px 10px;
  border: 1px solid var(--border, #d0d4da);
  background: transparent;
  cursor: pointer;
  border-radius: 4px;
  font: inherit;
  font-size: 0.85em;
}
[data-theme="dark"] .reader-ai-dock { background: #1f2937; border-color: rgba(255,255,255,0.12); }
[data-theme="dark"] .ai-dock-head { background: linear-gradient(90deg, rgba(59,130,246,0.18), rgba(167,139,250,0.18)); color: var(--text-dark, #e5e7eb); }
[data-theme="dark"] .ai-bubble-bot { background: rgba(255,255,255,0.05); color: var(--text-dark, #e5e7eb); border-color: rgba(255,255,255,0.10); }
[data-theme="dark"] .ai-chip { background: rgba(0,102,204,0.12); color: #93c5fd; }
[data-theme="dark"] .ai-save-btn { background: rgba(255,255,255,0.05); color: var(--text-dark, #e5e7eb); }

/* leave room at the bottom of content so dock doesn't cover last line */
.reader-content { padding-bottom: 60px; }

/* ============ home 3-card intent hero (issue #118) ============ */
.home-hero {
  max-width: 1100px; margin: 0 auto; padding: 16px;
}
.home-hero-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 12px 8px 28px;
}
.home-greeting {
  margin: 0; font-size: 28px; font-weight: 600;
}
.home-streak {
  font-size: 14px; color: var(--text-muted);
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: 999px; padding: 4px 12px;
}

/* ============ Stage 3:KaTeX formula-input 公共组件 ============ */
.formula-input { display: flex; flex-direction: column; gap: 12px; }
.formula-toolbar {
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}
.formula-toolbar[data-state="loading"] {
  padding: 12px; text-align: center; color: var(--text-muted); font-size: 13px;
}
.formula-toolbar-group {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
}
.formula-toolbar-group:last-child { border-bottom: none; }

/* 折叠模式:一个 select 下拉切类目 (#139) */
.formula-toolbar-group-select {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
}
.formula-toolbar-select {
  width: 100%;
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid var(--border-light, #cbd5e1);
  border-radius: 5px;
  background: #fff;
  color: var(--text, #1f2937);
  cursor: pointer;
}
[data-theme="dark"] .formula-toolbar-select {
  background: #1e293b;
  color: #f1f5f9;
  border-color: rgba(255,255,255,0.15);
}
.formula-toolbar-symbols-body {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 8px 12px;
  min-height: 32px;
}
.formula-toolbar-symbols-body:empty::before {
  content: "↑ 上方选择公式类目";
  color: var(--text-muted, #94a3b8);
  font-size: 12px;
  padding: 4px 0;
}
.formula-toolbar-group-name {
  font-size: 11px; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  min-width: 80px;
}
.formula-toolbar-symbols { display: flex; flex-wrap: wrap; gap: 4px; }
.formula-sym-btn,
.formula-wrap-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px;
  background: var(--surface-hover);
  border: 1px solid var(--border-light);
  border-radius: 5px;
  font-size: 12px; font-family: var(--font-mono, monospace);
  color: var(--text); cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.formula-sym-btn:hover,
.formula-wrap-btn:hover {
  background: var(--accent-soft, #eef2ff);
  border-color: var(--accent);
}
.formula-sym-icon { color: var(--text-muted); display: inline-flex; }
.formula-sym-icon .katex { font-size: 11px; }
.formula-sym-label { color: var(--text-muted); }

.formula-split {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
@media (max-width: 760px) {
  .formula-split { grid-template-columns: 1fr; }
}
.formula-pane-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-muted);
  margin-bottom: 4px;
}
.formula-textarea {
  width: 100%;
  font-family: var(--font-mono, monospace);
  font-size: 14px; line-height: 1.6;
  padding: 10px 12px;
  border: 1px solid var(--border-light); border-radius: 6px;
  background: var(--surface); color: var(--text);
  resize: vertical; min-height: 160px;
}
.formula-preview {
  min-height: 160px;
  padding: 12px 14px;
  border: 1px solid var(--border-light); border-radius: 6px;
  background: var(--surface);
  font-size: 14px; line-height: 1.6;
  overflow-x: auto;
}

[data-theme="dark"] .formula-preview .katex,
[data-theme="dark"] .formula-toolbar .katex { color: #e5e7eb; }

/* 更多公式 折叠区(其他学科)*/
.formula-toolbar-more {
  border-top: 1px solid var(--border-light);
}
.formula-toolbar-more summary {
  cursor: pointer; padding: 8px 12px;
  font-size: 12px; color: var(--text-muted);
  list-style: none;
}
.formula-toolbar-more summary::-webkit-details-marker { display: none; }
.formula-toolbar-more summary:hover { background: var(--surface-hover); }
.formula-toolbar-more[open] summary { background: var(--surface-hover); }

/* Canvas 手写板 */
.hwc-wrap {
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}
.hwc-toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface);
}
.hwc-tool-group { display: flex; align-items: center; gap: 4px; }
.hwc-tool-label { font-size: 12px; color: var(--text-muted); margin-right: 4px; }
.hwc-mode-btn,
.hwc-width-btn {
  padding: 4px 10px;
  background: var(--surface-hover);
  border: 1px solid var(--border-light);
  border-radius: 5px;
  font-size: 12px; cursor: pointer; color: var(--text);
}
.hwc-mode-btn:hover, .hwc-width-btn:hover { background: var(--accent-soft, #eef2ff); }
.hwc-mode-btn.active, .hwc-width-btn.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.hwc-width-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; min-height: 28px; padding: 4px 6px;
}
.hwc-width-dot {
  display: inline-block; border-radius: 50%;
  background: currentColor;
}
.hwc-status { font-size: 12px; margin-left: auto; }

.hwc-canvas {
  display: block;
  width: 100%; height: auto; aspect-ratio: 720 / 320;
  background: #ffffff;
  cursor: crosshair;
  touch-action: none;
}

/* 题图 zoom-canvas overlay(全屏 + 画板叠加,#123 用户最强需求) */
body.body-exam-zc-open { overflow: hidden; }
.exam-zc-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.94);
  z-index: 10000;
  display: flex; flex-direction: column;
}
/* 全屏画板顶部工具栏 — 统一 28px height,统一字号 / padding / 圆角 */
.exam-zc-topbar {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid #e5e7eb;
  font-size: 13px;
}
[data-theme="dark"] .exam-zc-topbar { background: rgba(30, 41, 59, 0.95); }

.exam-zc-label {
  font-family: var(--font-mono, monospace);
  font-size: 12px; font-weight: 600;
  color: var(--text-muted, #6b7280);
  padding: 0 6px;
}

/* 工具组分隔:细灰线 + 间距 */
.exam-zc-tool-group {
  display: inline-flex; gap: 2px;
  padding: 0 6px;
  margin: 0 2px;
  border-left: 1px solid #e5e7eb;
  align-items: center;
}
.exam-zc-tool-group:first-of-type { border-left: none; padding-left: 0; margin-left: 0; }

/* 所有按钮共用 — 统一 size / line-height / 字号 */
.exam-zc-btn,
.exam-zc-save,
.exam-zc-mode-btn,
.exam-zc-width-btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 28px; box-sizing: border-box;
  padding: 0 10px;
  border-radius: 4px;
  background: #f8fafc;
  border: 1px solid #e3e8ef;
  font-size: 13px;
  line-height: 1; color: var(--text, #1f2937);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.exam-zc-btn:hover, .exam-zc-save:hover,
.exam-zc-mode-btn:hover, .exam-zc-width-btn:hover {
  background: #eef2ff; border-color: #c7d2fe;
}
.exam-zc-mode-btn.active, .exam-zc-width-btn.active {
  background: #2563eb; color: #fff; border-color: #1d4ed8;
}
.exam-zc-width-btn { min-width: 28px; padding: 0 6px; }
.exam-zc-dot { display: inline-block; border-radius: 50%; background: currentColor; }

/* 关闭按钮 — 弱化样式(不抢焦点) */
.exam-zc-btn[data-zc-close] {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted, #6b7280);
  padding: 0 6px;
}
.exam-zc-btn[data-zc-close]:hover {
  background: #fee2e2; color: #dc2626; border-color: #fecaca;
}

/* 保存按钮 — 主操作绿,推到最右 */
.exam-zc-save {
  background: #16a34a; color: #fff; border-color: #15803d;
  font-weight: 600; margin-left: auto;
  padding: 0 14px;
}
.exam-zc-save:hover { background: #15803d; }

/* hint — 缩窄,弱化色,desktop only */
.exam-zc-hint {
  font-size: 11px; color: var(--text-muted, #9ca3af);
  margin: 0 6px;
  max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (max-width: 900px) { .exam-zc-hint { display: none; } }

/* Dark 模式适配 — 工具栏按钮在 dark 下也要可读 */
[data-theme="dark"] .exam-zc-btn,
[data-theme="dark"] .exam-zc-mode-btn,
[data-theme="dark"] .exam-zc-width-btn {
  background: #334155;
  color: #f1f5f9;
  border-color: #475569;
}
[data-theme="dark"] .exam-zc-btn:hover,
[data-theme="dark"] .exam-zc-mode-btn:hover,
[data-theme="dark"] .exam-zc-width-btn:hover {
  background: #475569; border-color: #64748b;
}
[data-theme="dark"] .exam-zc-mode-btn.active,
[data-theme="dark"] .exam-zc-width-btn.active {
  background: #2563eb; color: #fff; border-color: #1d4ed8;
}
[data-theme="dark"] .exam-zc-btn[data-zc-close] {
  background: transparent; border-color: transparent; color: #94a3b8;
}
[data-theme="dark"] .exam-zc-btn[data-zc-close]:hover {
  background: rgba(220, 38, 38, 0.2); color: #fca5a5; border-color: #dc2626;
}
[data-theme="dark"] .exam-zc-save {
  background: #16a34a; color: #fff; border-color: #15803d;
}
[data-theme="dark"] .exam-zc-label { color: #94a3b8; }
[data-theme="dark"] .exam-zc-hint { color: #64748b; }

/* inline canvas 工具栏 dark 也要适配 */
[data-theme="dark"] .exam-ic-toolbar {
  background: rgba(30, 41, 59, 0.95);
  border-color: #475569;
}
[data-theme="dark"] .exam-ic-mode-btn,
[data-theme="dark"] .exam-ic-width-btn {
  background: #334155; color: #f1f5f9; border-color: #475569;
}
[data-theme="dark"] .exam-ic-mode-btn:hover,
[data-theme="dark"] .exam-ic-width-btn:hover {
  background: #475569;
}
[data-theme="dark"] .exam-ic-mode-btn.active,
[data-theme="dark"] .exam-ic-width-btn.active {
  background: #2563eb; color: #fff; border-color: #1d4ed8;
}
[data-theme="dark"] .exam-ic-toolbar .btn {
  background: #334155; color: #f1f5f9; border-color: #475569;
}
[data-theme="dark"] .exam-ic-toolbar .btn:hover { background: #475569; }
[data-theme="dark"] .exam-ic-toolbar .btn-primary {
  background: #16a34a; color: #fff; border-color: #15803d;
}
[data-theme="dark"] .exam-ic-hint { color: #94a3b8; }
.exam-zc-scroll {
  flex: 1; overflow: auto;
  display: flex; justify-content: center; align-items: flex-start;
  padding: 16px;
}
.exam-zc-stage {
  position: relative;
  width: 100%; max-width: 1100px;
  background: #ffffff;
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
  border-radius: 6px;
}
.exam-zc-img {
  display: block; width: 100%; height: auto;
  user-select: none;
}
.exam-zc-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  cursor: default;
  /* 默认 idle:穿透事件 → 题图区域可以滚动/滑动 (#139 用户反馈) */
  pointer-events: none;
  touch-action: auto;
}
.exam-zc-overlay.zc-tool-active .exam-zc-canvas {
  /* 工具激活时才拦截事件,允许 draw / erase */
  pointer-events: auto;
  touch-action: none;
  cursor: crosshair;
}

/* zoom canvas text layer — 完全无框 */
.exam-zc-text-layer {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 2;
}
.exam-zc-text-wrap {
  position: absolute;
  right: 18px;
  min-width: 80px;
  padding: 8px 0;
  margin-top: -8px;
  pointer-events: none;
}
.exam-zc-text-layer.zc-text-mode .exam-zc-text-wrap {
  pointer-events: auto;
}
.exam-zc-text-box {
  display: block;
  width: 100%; box-sizing: border-box;
  background: transparent;
  border: none;
  padding: 0 4px;
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: #1f2937;
  outline: none;
  resize: none;
  overflow: hidden;
  caret-color: #2563eb;
  white-space: pre-wrap;
  word-break: break-word;
}
.exam-zc-text-layer.zc-text-mode .exam-zc-text-box {
  cursor: text;
}
.exam-zc-text-del,
.exam-zc-text-strike {
  position: absolute; top: -10px;
  display: none;
  width: 20px; height: 20px; line-height: 1;
  font-size: 11px; padding: 0;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}
.exam-zc-text-del { right: -10px; color: #ef4444; border: 1px solid #fecaca; }
.exam-zc-text-strike { right: 14px; color: #b91c1c; border: 1px solid #fecaca; font-weight: 600; }
.exam-zc-text-wrap.strike .exam-zc-text-strike { background: #fee2e2; }
.exam-zc-text-layer.zc-text-mode .exam-zc-text-wrap:hover .exam-zc-text-del,
.exam-zc-text-layer.zc-text-mode .exam-zc-text-wrap:focus-within .exam-zc-text-del,
.exam-zc-text-layer.zc-text-mode .exam-zc-text-wrap:hover .exam-zc-text-strike,
.exam-zc-text-layer.zc-text-mode .exam-zc-text-wrap:focus-within .exam-zc-text-strike {
  display: block;
}
.exam-zc-text-wrap.strike .exam-zc-text-box {
  text-decoration: line-through;
  text-decoration-color: #dc2626;
  text-decoration-thickness: 2px;
  color: #9ca3af;
}
.exam-zc-loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 14px;
  background: rgba(255,255,255,0.9);
}
@media (max-width: 760px) {
  .exam-zc-topbar { gap: 6px; padding: 8px; }
  .exam-zc-tool-group { padding-left: 6px; }
  .exam-zc-hint { display: none; }
  .exam-zc-scroll { padding: 8px; }
}

/* Canvas tab 预览(替代旧 inline canvas)*/
.exam-canvas-preview-body { padding: 8px 0; }
.exam-canvas-preview-wrap {
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: #ffffff;
  padding: 8px; margin-bottom: 12px;
  display: flex; justify-content: center;
}
.exam-canvas-preview {
  max-width: 100%; max-height: 320px; object-fit: contain;
}
.exam-canvas-preview-empty {
  padding: 32px 12px; text-align: center;
  border: 2px dashed var(--border-light);
  border-radius: 6px; margin-bottom: 12px;
}
.exam-canvas-preview-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* 题图 zoom 触发按钮(右下角浮按钮) */
.exam-q-img-wrap { position: relative; }
.exam-q-img-zoomable { cursor: zoom-in; }
.exam-q-img-zoom-btn {
  position: absolute; bottom: 8px; right: 8px;
  background: rgba(0,0,0,0.55);
  color: #fff; border: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.exam-q-img-zoom-btn:hover { background: rgba(0,0,0,0.75); }

/* ============ AI 熙学考试系统 (#123 — Stage 2 bludebook 风) ============ */

/* Landing 页(选学科) — 居中卡片 */
.exam-landing { max-width: 920px; margin: 0 auto; padding: 8px; }
.exam-landing-head { margin-bottom: 16px; }
.exam-landing-head h1 { margin: 0 0 4px 0; font-size: 24px; }

.exam-sessions-list { list-style: none; margin: 0; padding: 0; }
.exam-sessions-list li { margin: 6px 0; }
.exam-sessions-list li a {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-radius: 8px; background: var(--surface);
  border: 1px solid var(--border-light);
  text-decoration: none; color: inherit;
  transition: background 0.15s, transform 0.15s;
}
.exam-sessions-list li a:hover { background: var(--surface-hover); transform: translateX(2px); }
.exam-sessions-list .exam-when { margin-left: auto; font-size: 12px; }
.exam-action-pill {
  background: var(--accent, #6366f1); color: #fff;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
}

.exam-subject-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.exam-subject-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  padding: 16px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border-light);
  cursor: pointer; text-align: left;
  transition: background 0.15s, transform 0.15s, border-color 0.15s;
}
.exam-subject-card:hover {
  background: var(--surface-hover); border-color: var(--accent);
  transform: translateY(-1px);
}
.exam-subject-emoji { font-size: 28px; }
.exam-subject-name { font-weight: 700; font-size: 15px; }

/* Answer 模式 — 全屏沉浸 bludebook 风 ----------------------------------*/
body.body-exam-active { overflow: hidden; }
body.body-exam-active .sidebar,
body.body-exam-active .topbar,
body.body-exam-active .global-toast-stack { /* 保留 toast */ }
body.body-exam-active .sidebar { display: none; }
body.body-exam-active .topbar { display: none; }
body.body-exam-active .app-grid,
body.body-exam-active main#page { padding: 0; margin: 0; max-width: none; }

.exam-full {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
  z-index: 100;
}

/* Top bar */
.exam-top-bar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}
.exam-top-back {
  background: none; border: 1px solid var(--border-light);
  padding: 6px 12px; border-radius: 6px;
  font-size: 14px; cursor: pointer; color: var(--text);
}
.exam-top-back:hover { background: var(--surface-hover); }
.exam-top-info { flex: 1; font-size: 14px; color: var(--text); }
.exam-saving {
  margin-left: 12px; font-size: 12px;
  padding: 2px 8px; border-radius: 999px;
}
.exam-saving-saved { background: rgba(34,197,94,0.15); color: #16a34a; }
.exam-saving-saving { background: rgba(245,158,11,0.15); color: #d97706; }
.exam-saving-error { background: rgba(220,38,38,0.15); color: #b91c1c; }
.exam-top-timer {
  font-family: var(--font-mono, monospace);
  font-weight: 700; font-size: 18px;
  background: var(--surface-hover);
  padding: 6px 14px; border-radius: 999px;
  color: var(--text);
}
.exam-top-timer-low {
  background: rgba(220,38,38,0.18); color: #b91c1c;
  animation: examTimerPulse 1s ease-in-out infinite;
}
@keyframes examTimerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
.exam-top-stats { font-size: 13px; }

/* Body = sidebar + main */
.exam-body { flex: 1; display: flex; overflow: hidden; }

/* Left sidebar — question grid */
.exam-sidebar {
  width: 260px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border-light);
  display: flex; flex-direction: column;
  overflow-y: auto;
  overflow-x: visible; /* edge toggle 浮出来 */
  transition: width 0.18s ease;
  position: relative;
}
.exam-sidebar-title {
  margin: 14px 16px 10px; font-size: 12px;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-muted); font-weight: 600;
}
/* 边线小箭头折叠按钮 — 像 VSCode 边栏 (#139 用户反馈) */
.exam-sidebar-edge-toggle {
  position: absolute;
  top: 50%;
  right: -12px;     /* 浮在 sidebar 右边线外侧 */
  transform: translateY(-50%);
  width: 24px; height: 56px;
  background: rgba(0,0,0,0.04);
  border: 1px solid var(--border-light, #e2e8f0);
  border-radius: 0 6px 6px 0;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  z-index: 5;
  opacity: 0.4;
  transition: opacity 0.15s, background 0.15s;
}
.exam-sidebar-edge-toggle:hover { opacity: 1; background: rgba(0,0,0,0.08); }
[data-theme="dark"] .exam-sidebar-edge-toggle {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.1);
}
[data-theme="dark"] .exam-sidebar-edge-toggle:hover { background: rgba(255,255,255,0.12); }
.exam-sidebar-edge-toggle .edge-arrow {
  width: 0; height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-right: 6px solid var(--text-muted, #94a3b8);
}
.exam-sidebar.collapsed .exam-sidebar-edge-toggle .edge-arrow {
  border-right: none;
  border-left: 6px solid var(--text-muted, #94a3b8);
}
/* 折叠状态:仅 edge toggle 可见,其他全部 hidden */
.exam-sidebar.collapsed {
  width: 12px;     /* 收成一条边线 */
}
.exam-sidebar.collapsed .exam-sidebar-title,
.exam-sidebar.collapsed .exam-q-grid,
.exam-sidebar.collapsed .exam-sidebar-legend {
  display: none;
}
.exam-q-grid {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 6px; padding: 0 14px;
}
.exam-q-btn {
  aspect-ratio: 1 / 1;
  border: 2px solid transparent;
  background: var(--surface-hover);
  color: var(--text);
  border-radius: 6px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s;
}
.exam-q-btn:hover { transform: scale(1.05); }
.exam-q-btn.answered { background: rgba(59,130,246,0.18); border-color: #60a5fa; color: #1d4ed8; }
.exam-q-btn.flagged  { background: rgba(245,158,11,0.18); border-color: #fbbf24; color: #b45309; }
.exam-q-btn.current  { background: var(--accent, #6366f1); border-color: var(--accent-strong); color: #fff; }

.exam-sidebar-legend {
  margin: 18px 16px; font-size: 11px;
  display: flex; flex-direction: column; gap: 6px;
}
.legend-swatch {
  display: inline-block; width: 14px; height: 14px; border-radius: 3px;
  margin-right: 6px; vertical-align: middle;
  border: 1px solid;
}
.swatch-answered    { background: rgba(59,130,246,0.18); border-color: #60a5fa; }
.swatch-flagged     { background: rgba(245,158,11,0.18); border-color: #fbbf24; }
.swatch-unanswered  { background: var(--surface-hover); border-color: var(--border-light); }

/* Main answer area */
.exam-main { flex: 1; overflow-y: auto; padding: 24px 32px; }
.exam-q-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.exam-q-num { font-weight: 600; color: var(--text-muted); font-size: 14px; }
.exam-q-node { background: var(--surface-hover); padding: 2px 8px; border-radius: 4px;
  margin-left: 10px; font-size: 12px; }
.exam-flag-btn {
  background: none; border: 1px solid var(--border-light);
  padding: 6px 12px; border-radius: 6px;
  font-size: 13px; cursor: pointer; color: var(--text);
}
.exam-flag-btn.active {
  background: rgba(245,158,11,0.15); color: #b45309;
  border-color: #fbbf24;
}
.exam-flag-btn:hover { background: var(--surface-hover); }

.exam-q-card { padding: 18px; max-width: 920px; margin: 0 auto 14px; }
.exam-q-img-wrap { text-align: center; }
.exam-q-img {
  max-width: 100%; max-height: 520px; object-fit: contain;
  background: #fff; border: 1px solid var(--border-light); border-radius: 6px;
}
.exam-ans-card { padding: 14px 18px; max-width: 920px; margin: 0 auto 14px; }

.exam-tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 10px;
}
.exam-tab {
  border: none; background: none; padding: 8px 16px;
  font-size: 14px; font-weight: 500; color: var(--text-muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.exam-tab:hover { color: var(--accent); }
.exam-tab.active { color: var(--accent-strong); border-bottom-color: var(--accent); }
.exam-tab-body { padding: 10px 0; }

.exam-textarea {
  width: 100%;
  font-family: var(--font-mono, monospace);
  font-size: 14px; line-height: 1.6;
  padding: 10px 12px; border: 1px solid var(--border-light);
  border-radius: 6px;
  background: var(--surface); color: var(--text);
  resize: vertical; min-height: 160px;
}

.exam-mcq-row { display: flex; gap: 12px; flex-wrap: wrap; }
.exam-mcq-btn {
  flex: 1; min-width: 80px; max-width: 160px;
  font-size: 18px; font-weight: 700; padding: 16px;
  border: 2px solid var(--border-light);
}
.exam-mcq-btn.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}

.exam-nav {
  display: flex; gap: 10px; justify-content: space-between; align-items: center;
  max-width: 920px; margin: 16px auto;
}
.exam-nav-mid { flex: 1; text-align: center; font-size: 12px; }

/* Review 模式 — bludebook 风 score 卡 + 可展开列表 ------------------------*/
.exam-review { max-width: 1000px; margin: 0 auto; padding: 12px; }
.exam-review-head {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 16px;
}
.exam-review-head h2 { margin: 0; font-size: 18px; flex: 1; }
.exam-status-pill {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.exam-status-submitted { background: rgba(34,197,94,0.15); color: #16a34a; border: 1px solid #16a34a40; }

.exam-review-score {
  display: flex; align-items: center; gap: 28px;
  padding: 24px 32px; margin-bottom: 16px;
}
.exam-review-score-circle {
  width: 96px; height: 96px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.exam-review-score-circle.ok  { background: rgba(34,197,94,0.18); }
.exam-review-score-circle.mid { background: rgba(245,158,11,0.18); }
.exam-review-score-circle.low { background: rgba(220,38,38,0.18); }
.exam-review-pct {
  font-size: 28px; font-weight: 700;
}
.exam-review-score-circle.ok .exam-review-pct  { color: #16a34a; }
.exam-review-score-circle.mid .exam-review-pct { color: #d97706; }
.exam-review-score-circle.low .exam-review-pct { color: #b91c1c; }

.exam-review-stats {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 14px;
}

.exam-review-list { padding: 18px 20px; }
.exam-review-questions { list-style: none; margin: 12px 0 0; padding: 0; }
.exam-review-q { margin: 6px 0; border-radius: 8px; overflow: hidden;
  border: 2px solid var(--border-light); background: var(--surface); }
/* v2: emerald 成功 / amber 友好(代替红色) — 不羞辱性的视觉 */
.exam-review-q.correct { background: rgba(16,185,129,0.06); border-color: rgba(110,231,183,0.40); }
.exam-review-q.wrong   { background: rgba(245,158,11,0.06); border-color: rgba(252,211,77,0.40); }
.exam-review-q.skipped { background: var(--surface-hover); }
.exam-review-q-head {
  display: flex; align-items: center; gap: 10px;
  width: 100%; border: none; background: none;
  padding: 14px 18px; text-align: left;
  cursor: pointer; color: inherit;
  font-size: 14px;
}
.exam-review-q-head:hover { background: rgba(0,0,0,0.03); }
.exam-review-q-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.exam-review-q.correct .exam-review-q-icon { background: var(--emerald-500, #10b981); color: #fff; }
.exam-review-q.wrong   .exam-review-q-icon { background: var(--amber-500, #f59e0b); color: #fff; }
.exam-review-q.skipped .exam-review-q-icon { background: var(--border-light); color: var(--text-muted); }
.exam-review-q.unmarked .exam-review-q-icon { background: var(--accent); color: #fff; }
.exam-review-q-label { font-weight: 600; }
.exam-review-q-flag { color: #b45309; }
.exam-review-q-toggle { margin-left: auto; color: var(--text-muted); }
.exam-review-q-body {
  padding: 12px 18px 18px;
  border-top: 1px solid var(--border-light);
  background: var(--surface);
}
.exam-review-q-imgs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  margin-bottom: 14px;
}
@media (max-width: 760px) {
  .exam-review-q-imgs { grid-template-columns: 1fr; }
}
.exam-review-q-imgs h5,
.exam-review-q-your h5 { margin: 0 0 6px; font-size: 13px; color: var(--text-muted); }
.exam-review-q-your { margin-bottom: 12px; }
.exam-review-text {
  background: var(--surface-hover); padding: 10px 14px; border-radius: 6px;
  white-space: pre-wrap; font-family: var(--font-mono, monospace);
  font-size: 13px; margin: 6px 0;
}
.exam-self-mark {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--border-light);
}
.exam-self-mark-btn[data-mark="correct"].active { background: #16a34a; color: #fff; border-color: #16a34a; }
.exam-self-mark-btn[data-mark="wrong"].active   { background: #b91c1c; color: #fff; border-color: #b91c1c; }

/* dark mode 微调 */
[data-theme="dark"] .exam-q-img { background: #fff; }  /* 题图本来就是浅底 — 保留以保证学生看清 */
[data-theme="dark"] .exam-q-btn { background: rgba(255,255,255,0.05); color: var(--text); }
[data-theme="dark"] .exam-q-btn.answered { background: rgba(59,130,246,0.25); color: #93c5fd; }
[data-theme="dark"] .exam-q-btn.flagged  { background: rgba(245,158,11,0.25); color: #fcd34d; }
[data-theme="dark"] .exam-q-btn.current { background: var(--accent); color: #fff; }

@media (max-width: 760px) {
  .exam-body { flex-direction: column; }
  .exam-sidebar { width: 100%; max-height: 200px; }
  .exam-q-grid { grid-template-columns: repeat(8, 1fr); }
  .exam-main { padding: 14px; }
}

/* Home Mission 入口 — 3 个独立 chip 一行,统一尺寸/字重/边框,
   只用填充色区分主次。outline = secondary, solid-fill = primary action. */
.home-mission-row {
  display: flex; align-items: stretch; gap: 10px; flex-wrap: wrap;
  margin: 0 0 18px;
}
.home-mission-chip {
  display: inline-flex; align-items: center;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  border: 1px solid #06b6d4;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  background: #ecfeff;
  color: #0e7490;
}
.home-mission-chip-sub {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.home-mission-chip-cta {
  background: #0891b2;
  color: #fff;
}
.home-mission-chip:hover:not(.home-mission-chip-static) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.18);
}
.home-mission-chip-cta:hover { background: #0e7490; }
.home-mission-chip-static { cursor: default; }

/* 空状态(新用户没数据)— amber 同款 outline + solid */
.home-mission-row-empty .home-mission-chip {
  border-color: #f59e0b;
  background: #fff7ed;
  color: #92400e;
}
.home-mission-row-empty .home-mission-chip-cta {
  background: #d97706;
  color: #fff;
}
.home-mission-row-empty .home-mission-chip-cta:hover { background: #b45309; }

@media (max-width: 720px) {
  .home-mission-chip { font-size: 13px; padding: 8px 14px; }
  .home-mission-chip-sub { white-space: normal; flex-basis: 100%; }
}

/* 暗色模式 — 浅 cyan/amber 背景在深色页面上突兀,改成半透明 tint + 亮色字 */
[data-theme="dark"] .home-mission-chip {
  background: rgba(6, 182, 212, 0.14);
  color: #67e8f9;
  border-color: rgba(6, 182, 212, 0.45);
}
[data-theme="dark"] .home-mission-chip-sub {
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
  border-color: rgba(255, 255, 255, 0.14);
}
[data-theme="dark"] .home-mission-chip-cta {
  background: #0891b2;
  color: #fff;
  border-color: #0891b2;
}
[data-theme="dark"] .home-mission-chip-cta:hover { background: #0e7490; }
[data-theme="dark"] .home-mission-chip:hover:not(.home-mission-chip-static) {
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.35);
}

[data-theme="dark"] .home-mission-row-empty .home-mission-chip {
  background: rgba(245, 158, 11, 0.14);
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.45);
}
[data-theme="dark"] .home-mission-row-empty .home-mission-chip-sub {
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
  border-color: rgba(255, 255, 255, 0.14);
}
[data-theme="dark"] .home-mission-row-empty .home-mission-chip-cta {
  background: #d97706;
  color: #fff;
  border-color: #d97706;
}
[data-theme="dark"] .home-mission-row-empty .home-mission-chip-cta:hover {
  background: #b45309;
}

.home-cards {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 18px; margin-bottom: 32px;
}
@media (max-width: 720px) {
  .home-cards { grid-template-columns: 1fr; gap: 14px; }
}

.home-card {
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 22px 20px; min-height: 180px;
  background: var(--surface);
  border: 1px solid var(--border-light); border-radius: var(--radius-lg);
  text-decoration: none; color: inherit;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.home-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
}
.home-card-icon  { font-size: 32px; margin-bottom: 6px; }
.home-card-title { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.home-card-desc  { font-size: 13px; color: var(--text-muted); line-height: 1.5; flex: 1; }
.home-card-meta  {
  font-size: 12px; color: var(--accent-strong); margin-top: 12px;
  font-weight: 500;
}

.home-recent {
  padding: 20px;
}
.home-recent-title {
  margin: 0 0 12px 0; font-size: 15px; font-weight: 600;
}
.home-recent-empty {
  padding: 14px 4px; font-size: 13px;
}
.home-recent-list {
  list-style: none; margin: 0; padding: 0;
}
.home-recent-list { padding: 0; }
.home-recent-item { list-style: none; }
.home-recent-item a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--border-light);
}
.home-recent-item:last-child a { border-bottom: none; }
.home-recent-item a:hover {
  background: var(--surface-hover, rgba(0,0,0,0.04));
  border-radius: 6px;
}

/* badge ✓✗ — 圆形 18px,inline 三色 */
.home-recent-badge {
  display: inline-flex;
  width: 18px; height: 18px;
  align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  border-radius: 50%;
  flex-shrink: 0;
}
.home-recent-badge-ok  { background: #dcfce7; color: #15803d; }
.home-recent-badge-err { background: #fee2e2; color: #b91c1c; }
.home-recent-badge-skip{ background: var(--border-light); color: var(--text-muted); }

/* paper · qid 在中间一段,字号统一 */
.home-recent-main {
  flex: 1;
  font-size: 13px;
  display: flex; gap: 6px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
}
.home-recent-paper {
  font-family: ui-monospace, monospace;
  overflow: hidden; text-overflow: ellipsis;
}
.home-recent-sep { color: var(--text-muted); }
.home-recent-qid { color: var(--text-muted); }

/* 时间右对齐 */
.home-recent-when {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
/* ============ Concept Mission (issue #119) ============ */
.mission-page { max-width: none; margin: 0; padding: 0; }

/* Mission 进阶训练 CTA(放在 head 下方,显眼按钮) */
.mission-practice-cta {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px;
  background: linear-gradient(90deg, #ecfeff, #cffafe);
  border-left: 4px solid #06b6d4;
  margin-bottom: 16px;
}
.mission-practice-cta h3 { color: #0e7490; }
.mission-practice-cta .btn-primary { white-space: nowrap; }

/* Mission 进阶训练 — 答题主视图 */
.mission-practice { display: flex; flex-direction: column; gap: 16px; }
.mission-practice-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px;
}
.mission-practice-progress { display: flex; gap: 10px; align-items: center; }
.mission-practice-meter {
  height: 8px; background: var(--border-light); border-radius: 999px;
  overflow: hidden; margin-bottom: 4px;
}
.mission-practice-meter-fill {
  height: 100%; background: linear-gradient(90deg, #06b6d4, #3b82f6);
  transition: width 0.3s ease;
}
.mission-practice-q {
  padding: 18px 24px;
  text-align: center;
}
.mission-practice-img {
  max-width: 100%; max-height: 480px; object-fit: contain;
  border: 1px solid var(--border-light); border-radius: 6px;
  background: #fff;
}
.mission-practice-actions {
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
  margin-top: 4px;
}
.mission-practice-actions .three-way-btn {
  flex: 1; min-width: 130px; max-width: 220px;
  font-size: 15px; padding: 10px 14px;
}

/* Mission 训练总结卡 */
.mission-practice-summary { display: flex; justify-content: center; padding: 24px 0; }
.mission-practice-summary-card {
  max-width: 480px; text-align: center; padding: 28px 32px;
}
.mission-practice-summary-emoji { font-size: 48px; margin-bottom: 8px; }
.mission-practice-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  margin: 18px 0;
}
.mission-practice-stat {
  padding: 10px; border-radius: 8px; font-size: 14px;
}
.mission-practice-stat strong { display: block; font-size: 22px; }
.mission-practice-stat.correct { background: #ecfdf5; color: #15803d; }
.mission-practice-stat.wrong   { background: #fef3c7; color: #c2410c; }
.mission-practice-stat.skip    { background: var(--border-light); color: var(--text-muted); }
.mission-practice-pct {
  font-size: 18px; font-weight: 600; color: var(--accent-strong);
  margin: 8px 0 18px;
}
.mission-practice-summary-actions {
  display: flex; gap: 12px; justify-content: center; flex-wrap: wrap;
}

/* 总结卡:不会题 → 错题本复盘 link */
.mission-practice-mistakes-link {
  display: inline-block;
  margin: 0 0 14px;
  padding: 8px 16px;
  background: #fef3c7;
  border: 1px solid #f59e0b80;
  border-radius: 999px;
  color: #92400e;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}
.mission-practice-mistakes-link:hover { background: #fde68a; }

/* 答案展开后底部 详细分析 link */
.mission-practice-detail-link {
  margin-top: 14px; text-align: center;
}
.mission-practice-detail-link a {
  display: inline-block;
  padding: 8px 16px;
  background: linear-gradient(90deg, #fef9c3, #fde68a);
  border: 1px solid #f59e0b80;
  border-radius: 999px;
  color: #92400e;
  font-size: 14px;
  text-decoration: none;
  font-weight: 500;
}
.mission-practice-detail-link a:hover {
  background: linear-gradient(90deg, #fef3c7, #fcd34d);
}

/* question.js 顶部"返回 Mission 训练"按钮(从 practice 跳过来时) */
.q-back-to-mission {
  display: inline-block;
  margin: 0 0 14px;
  padding: 8px 14px;
  background: #ecfeff;
  border: 1px solid #06b6d480;
  border-radius: 999px;
  color: #0e7490;
  font-weight: 600;
  text-decoration: none;
  font-size: 14px;
}
.q-back-to-mission:hover { background: #cffafe; }
.mission-crumbs { font-size: 13px; margin: 8px 0 16px; }
.mission-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.mission-title { margin: 0; font-size: 22px; font-weight: 600; }
.mission-badges { display: flex; gap: 6px; }
.badge-tier {
  font-size: 13px; padding: 4px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border-light);
}
.badge-done { color: #16a34a; border-color: #16a34a40; }
.badge-open { color: var(--accent-strong); border-color: var(--accent); }
.badge-lock { color: var(--text-muted); opacity: 0.55; }

.mission-progress { margin-bottom: 22px; }
.mission-progress-label { font-size: 12px; margin-bottom: 6px; }
.mission-progress-bar {
  height: 6px; background: var(--border-light); border-radius: 3px;
  overflow: hidden;
}
.mission-progress-fill {
  height: 100%; background: var(--accent-strong);
  transition: width 0.3s ease;
}

.mission-question { padding: 24px; min-height: 320px; }
.mission-q-empty { padding: 60px 0; text-align: center; font-size: 14px; }

.mission-hint {
  margin-top: 16px; padding: 18px;
  border-left: 3px solid #f59e0b;
  background: #fef3c7;
}
:root[data-theme="dark"] .mission-hint {
  background: rgba(245, 158, 11, 0.12);
}

/* ============ 错题与考点(#115 P0-2 + #112 S2/S4 重构) ============ */
.mistakes-page { max-width: none; margin: 0; padding: 0; }
.mistakes-header { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.mistakes-header h2 { margin: 0; }

.mistakes-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
}
@media (max-width: 768px) {
  .mistakes-grid { grid-template-columns: 1fr; }
}
.mistakes-aside { padding: 16px; }
.mistakes-aside-list { list-style: none; padding: 0; margin: 0; }
.mistakes-aside-link {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  text-decoration: none; color: inherit;
  font-size: 13px;
}
.mistakes-aside-link:hover { background: var(--surface-hover, rgba(0,0,0,0.04)); }
.mistakes-aside-link.active { background: var(--accent); color: var(--accent-strong); }

.mistakes-main { padding: 16px; }
.mistakes-list { list-style: none; padding: 0; margin: 0; }
.mistakes-item { list-style: none; }
.mistakes-item a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 8px;
  text-decoration: none; color: inherit;
  border-bottom: 1px solid var(--border-light);
}
.mistakes-item:last-child a { border-bottom: none; }
.mistakes-item a:hover { background: var(--surface-hover, rgba(0,0,0,0.04)); border-radius: 6px; }

/* 色差柔和:✗ 不再强红,微暖色 */
.mistakes-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}
.mistakes-badge-err  { background: #fef3c7; color: #c2410c; }  /* 浅琥珀,不再亮红 */
.mistakes-badge-skip { background: var(--border-light); color: var(--text-muted); }
.mistakes-badge-ok   { background: #ecfdf5; color: #15803d; }

/* 加入次数小 chip(>1 才显示) */
.mistakes-count {
  display: inline-flex; align-items: center;
  padding: 1px 8px;
  background: #fef3c7;
  border: 1px solid #f59e0b80;
  border-radius: 999px;
  color: #92400e;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.mistakes-paper { font-family: ui-monospace, monospace; font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.mistakes-sep   { color: var(--text-muted); }
.mistakes-qid   { font-size: 12px; }
.mistakes-when  { font-size: 12px; color: var(--text-muted); margin-left: auto; flex-shrink: 0; }
.mistakes-node-chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface-hover, rgba(0,0,0,0.04));
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--border-light);
}
.mistakes-node-chip:hover { border-color: var(--accent); }

/* ============ 学习进度可视化(#115 P1-1 + #112 S3) ============ */
.progress-page { max-width: none; margin: 0; padding: 0; }
.progress-grid {
  display: flex; flex-direction: column; gap: 18px;
}

/* 等级勋章墙顶部的小横幅 tip(学习时长 + 升级 tip) */
.progress-levels-tip {
  margin: 6px 0 10px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.5;
  color: #92400e;
  background: linear-gradient(90deg, #fff7ed, #fef3c7);
  border-left: 3px solid #f59e0b;
  border-radius: 6px;
}
.progress-levels-tip strong { color: #b45309; font-weight: 700; }
/* Row 1: 3 列 streak | week | levels */
.progress-row-1 {
  display: grid;
  grid-template-columns: 180px 1fr 1.5fr;
  gap: 24px;
  padding: 24px;
  align-items: stretch;
}
.progress-cell-streak {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-right: 1px solid var(--border-light);
  padding-right: 16px;
}
.progress-streak-num {
  font-size: 56px; font-weight: 800;
  background: linear-gradient(135deg, #f97316, #ef4444);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  line-height: 1;
}
.progress-streak-unit { font-size: 18px; font-weight: 600; margin-top: 4px; }
.progress-streak-label { font-size: 12px; margin-top: 4px; }

.progress-cell-week {
  border-right: 1px solid var(--border-light);
  padding-right: 16px;
}
.progress-week-title { font-size: 12px; margin-bottom: 10px; }
.progress-week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.progress-day {
  display: flex; flex-direction: column; align-items: center;
  padding: 4px 2px;                /* 用户:左侧日期框上下变矮(宽度不变) */
  border: 1px solid var(--border-light); border-radius: 6px;
  background: var(--surface);
  min-width: 0;
}
.progress-day.hit {
  background: #dcfce7; border-color: #86efac;
}
.progress-day.today {
  border-color: #f97316; border-width: 2px;
}
.progress-day-date { font-size: 12px; font-weight: 600; line-height: 1.2; }
.progress-day-dot { font-size: 14px; line-height: 1; margin: 2px 0; }
.progress-day.hit .progress-day-dot { color: #16a34a; }
.progress-day:not(.hit) .progress-day-dot { color: var(--border-light); }
.progress-day-wd { font-size: 10px; line-height: 1.1; }

.progress-cell-levels { display: flex; flex-direction: column; gap: 10px; }
.progress-levels-grid {
  display: grid;
  /* auto-fit minmax 让窄屏自动换行(平板 5×2 / 桌面 10×1)— 用户反馈右侧
     等级显示不全。同时 box-sizing 保证内边距不溢出。*/
  grid-template-columns: repeat(auto-fit, minmax(54px, 1fr));
  gap: 4px;
}
.progress-level {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center;
  padding: 6px 2px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
  min-width: 0;
}
.progress-level.owned {
  border-color: var(--lv-color, var(--accent));
  background: color-mix(in srgb, var(--lv-color) 8%, var(--surface));
}
.progress-level.lock {
  opacity: 0.35; filter: grayscale(0.6);
}
.progress-level.current {
  transform: scale(1.08);
  box-shadow: 0 0 0 2px var(--lv-color, var(--accent)),
              0 0 14px var(--lv-color, var(--accent));
  z-index: 2;
}
.progress-level-emoji {
  /* 用户:右侧等级图标大小不一 — 固定高度框 + flex 居中,emoji 字体差异不影响
     卡片整体一致性 */
  display: flex; align-items: center; justify-content: center;
  height: 28px; width: 100%;
  font-size: 22px; line-height: 1;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji",
               "Twemoji Mozilla", sans-serif;
}
.progress-level-name { font-size: 11px; margin-top: 2px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.progress-level-num {
  font-size: 9px; color: var(--text-muted);
  position: absolute; top: 2px; right: 4px;
}
.progress-xp { font-size: 12px; text-align: center; margin-top: 4px; }
.progress-tip {
  padding: 8px 12px;
  background: linear-gradient(90deg, rgba(249,115,22,0.08), rgba(239,68,68,0.04));
  border-left: 3px solid #f97316;
  border-radius: 0 6px 6px 0;
  text-align: left;
  font-size: 12px;
}
.progress-tip strong { color: #ea580c; }
.progress-tip-hint {
  margin-top: 6px;
  padding: 6px 10px;
  font-size: 11px;
  font-style: italic;
}

@media (max-width: 1100px) {
  .progress-row-1 { grid-template-columns: 1fr; }
  .progress-cell-streak, .progress-cell-week {
    border-right: none; padding-right: 0;
    border-bottom: 1px solid var(--border-light); padding-bottom: 16px;
  }
}

/* Row 2: 学科通关 折叠下拉 */
.progress-subjects summary,
.progress-badges summary {
  cursor: pointer; padding: 8px 0;
  list-style: none;
}
.progress-subjects summary::-webkit-details-marker,
.progress-badges summary::-webkit-details-marker { display: none; }
.progress-subjects summary h3,
.progress-badges summary h3 { display: inline; margin: 0; font-size: 16px; }
.progress-subjects summary::after,
.progress-badges summary::after { content: " ▾"; color: var(--text-muted); }
.progress-subjects[open] summary::after,
.progress-badges[open] summary::after { content: " ▴"; }

/* 我的考试 — progress 页 #123 露出 exam_sessions */
.progress-exam { padding: 16px 24px; }
.progress-exam-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.progress-exam-head h3 { margin: 0; font-size: 16px; }
.prog-exam-stats {
  margin: 0 0 12px;
  font-size: 14px; color: var(--text-muted);
}
.prog-exam-stats strong { color: var(--text); font-size: 18px; margin: 0 2px; }
.prog-exam-list { list-style: none; margin: 0; padding: 0; }
.prog-exam-item a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-radius: 6px;
  text-decoration: none; color: inherit;
  margin: 4px 0;
  background: var(--surface-hover);
}
.prog-exam-item a:hover { background: var(--accent-soft, #eef2ff); }
.prog-exam-paper {
  font-family: var(--font-mono, monospace);
  font-size: 13px; font-weight: 600;
}
.prog-exam-status { margin-left: auto; font-size: 12px;
  padding: 2px 10px; border-radius: 999px; }
.prog-exam-status-done { background: rgba(34,197,94,0.18); color: #16a34a; }
.prog-exam-status-active { background: rgba(6,182,212,0.18); color: #0e7490; }

/* Concept Mission 徽章墙 */
.progress-badges { padding: 16px 24px; }
.badge-tier-row { margin-top: 12px; }
.badge-tier-head {
  font-size: 14px; font-weight: 600; margin-bottom: 6px;
}
.badge-tier-chips {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.badge-chip {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  text-decoration: none;
  border: 1px solid;
  font-family: var(--font-mono, monospace);
}
.badge-chip.badge-gold   { background: #fef9c3; color: #854d0e; border-color: #facc15; }
.badge-chip.badge-silver { background: #f1f5f9; color: #475569; border-color: #94a3b8; }
.badge-chip.badge-bronze { background: #fed7aa; color: #9a3412; border-color: #fb923c; }
.badge-chip:hover { transform: translateY(-1px); }

/* Global toast stack(右下角)— badge earn / 后续轻量提示 共用 */
.global-toast-stack {
  position: fixed;
  right: 20px;
  bottom: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.global-toast {
  pointer-events: auto;
  min-width: 220px; max-width: 360px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #fef9c3, #fef3c7);
  border-left: 4px solid #f59e0b;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  font-size: 14px;
  color: #78350f;
  display: flex; align-items: center; gap: 10px;
  opacity: 0;
  transform: translateX(40px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.global-toast.show { opacity: 1; transform: translateX(0); }
.global-toast-icon { font-size: 28px; line-height: 1; }
.global-toast-title { font-weight: 700; font-size: 15px; }
.global-toast-body { font-size: 13px; color: #92400e; margin-top: 2px; }

/* Tier-specific palettes */
.global-toast-gold   { background: linear-gradient(135deg, #fef3c7, #facc15); border-left-color: #ca8a04; }
.global-toast-silver { background: linear-gradient(135deg, #f1f5f9, #cbd5e1); border-left-color: #64748b; color: #334155; }
.global-toast-bronze { background: linear-gradient(135deg, #fed7aa, #fb923c); border-left-color: #9a3412; color: #7c2d12; }

/* Row 3: 弱项考点 — 大块 */
.progress-mistakes-big { padding: 24px; }
.progress-mistakes-big h3 { margin: 0 0 14px 0; }
.prog-rows-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0 24px;
}
@media (max-width: 900px) {
  .progress-row-1 { grid-template-columns: 1fr; }
  .progress-col-badges { border-left: none; border-top: 1px solid var(--border-light); padding-left: 0; padding-top: 16px; }
  .prog-rows-grid { grid-template-columns: 1fr; }
}
.progress-streak-big {
  font-size: 42px; font-weight: 700;
  background: linear-gradient(135deg, #f97316, #ef4444);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  line-height: 1;
}
.progress-week { display: flex; gap: 10px; flex: 1; justify-content: flex-end; }
.progress-day {
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 6px; min-width: 36px;
  border: 1px solid var(--border-light); border-radius: 8px;
  background: var(--surface);
}
.progress-day.hit { background: #dcfce7; border-color: #16a34a40; }
.progress-day-label { font-size: 11px; color: var(--text-muted); }
.progress-day-dot { font-size: 16px; line-height: 1; margin-top: 2px; }
.progress-day.hit .progress-day-dot { color: #16a34a; }
.progress-day:not(.hit) .progress-day-dot { color: var(--border-light); }

.prog-row {
  display: grid;
  grid-template-columns: 140px 1fr 110px;
  align-items: center; gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}
.prog-row:last-child { border-bottom: none; }
.prog-label {
  font-size: 13px; font-family: ui-monospace, monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
a.prog-label { color: var(--accent-strong); text-decoration: none; }
a.prog-label:hover { text-decoration: underline; }
.prog-bar {
  height: 8px; background: var(--border-light); border-radius: 4px; overflow: hidden;
}
.prog-bar-fill { height: 100%; background: #16a34a; transition: width 0.3s; }
.prog-bar-fill.err { background: #dc2626; }
.prog-meta { font-size: 12px; text-align: right; }

.badge-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}
.badge-cell {
  text-align: center; padding: 14px 8px;
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: 8px;
}
.badge-emoji { font-size: 30px; line-height: 1; margin-bottom: 4px; }
.badge-node { font-size: 12px; font-family: ui-monospace, monospace; word-break: break-all; }
.badge-tier-label { font-size: 11px; margin-top: 2px; }

@media (max-width: 560px) {
  .progress-head { flex-direction: column; align-items: flex-start; gap: 16px; }
  .progress-week { justify-content: flex-start; }
  .prog-row { grid-template-columns: 100px 1fr 80px; gap: 8px; }
}

/* ============ 题目页三联(#115 P0-3 / #120) ============ */
.q-three-way {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 0;
  border-top: 1px solid var(--border-light);
}
.three-way-btn {
  padding: 8px 16px; font-size: 13px;
  border-radius: 6px;
  border: 1px solid var(--border-light);
  background: var(--surface);
}
.three-way-btn:hover:not(:disabled) {
  border-color: var(--accent);
  transform: translateY(-1px);
  transition: all 0.15s;
}
.three-way-btn-correct { color: #15803d; border-color: #16a34a40; }
.three-way-btn-correct:hover:not(:disabled) { background: #dcfce7; }
.three-way-btn-wrong { color: #b91c1c; border-color: #dc262640; }
.three-way-btn-wrong:hover:not(:disabled) { background: #fee2e2; }
.ai-explain-panel {
  margin-top: 12px; padding: 16px;
  border-left: 3px solid #f59e0b;
  background: #fef3c7;
  border-radius: 0 6px 6px 0;
}
:root[data-theme="dark"] .ai-explain-panel { background: rgba(245, 158, 11, 0.12); }

/* ===================================================================
   Onboarding tour — 三只动物宝宝介绍 5 个核心功能
   (issue: post-login tutorial, 2026-05-13 feat/onboarding-tour)
=================================================================== */
.pdfqa-tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.28s ease-out;
  pointer-events: none;
}
.pdfqa-tour-overlay.is-open    { opacity: 1; pointer-events: auto; }
.pdfqa-tour-overlay.is-leaving { opacity: 0; pointer-events: none; }

.tour-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.tour-card {
  position: relative;
  margin: max(20px, 5vh) auto 20px;
  max-width: 640px;
  width: calc(100% - 32px);
  max-height: 90vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #fef9ee 0%, #faf4e6 100%);
  border: 1px solid rgba(184,134,30,0.3);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
  padding: 24px 24px 18px;
  transform: translateY(20px) scale(0.96);
  transition: transform 0.32s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.pdfqa-tour-overlay.is-open .tour-card { transform: translateY(0) scale(1); }

[data-theme="dark"] .tour-card {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border-color: rgba(212, 168, 67, 0.4);
  color: #f1f5f9;
}

.tour-close {
  position: absolute;
  top: 8px; right: 12px;
  width: 32px; height: 32px;
  border: none;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  color: #6b5e3f;
  cursor: pointer;
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: background 0.15s;
}
.tour-close:hover { background: rgba(184,134,30,0.12); }

.tour-stage {
  height: 220px;
  display: grid;
  place-items: center;
  position: relative;
}
.tour-stage.is-entering .tour-svg {
  animation: tourEntry 0.45s cubic-bezier(0.22, 0.61, 0.36, 1) both,
             tourBounce 2.5s ease-in-out 0.45s infinite;
}
@keyframes tourEntry {
  0%   { opacity: 0; transform: translateX(60px) scale(0.85); }
  100% { opacity: 1; transform: translateX(0)    scale(1); }
}
@keyframes tourBounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-12px); }
}

/* ---- SVG transform-box fix(same trick as login mascots) -------------- */
.tour-svg .tour-panda-ear-l, .tour-svg .tour-panda-ear-r,
.tour-svg .tour-eye-l, .tour-svg .tour-eye-r,
.tour-svg .tour-arm,
.tour-svg .tour-monkey-tail, .tour-svg .tour-monkey-ear-l, .tour-svg .tour-monkey-ear-r,
.tour-svg .tour-monkey-head,
.tour-svg .tour-fox-tail, .tour-svg .tour-fox-ear-l, .tour-svg .tour-fox-ear-r {
  transform-box: fill-box;
  transform-origin: center;
}
.tour-svg .tour-eye-l, .tour-svg .tour-eye-r {
  animation: tourBlink 3.6s ease-in-out infinite;
}
.tour-svg .tour-eye-r { animation-delay: -0.12s; }
@keyframes tourBlink {
  0%, 92%, 100% { transform: scaleY(1); }
  94%, 98%      { transform: scaleY(0.1); }
}
.tour-svg .tour-panda-ear-l { animation: tourPandaEarL 3.5s ease-in-out infinite; }
.tour-svg .tour-panda-ear-r { animation: tourPandaEarR 3.5s ease-in-out infinite -1s; }
@keyframes tourPandaEarL { 0%,100%{transform:rotate(0)} 50%{transform:rotate(-8deg)} }
@keyframes tourPandaEarR { 0%,100%{transform:rotate(0)} 50%{transform:rotate(8deg)} }
.tour-svg.tour-panda .tour-arm { animation: tourPandaWave 2s ease-in-out infinite; }
@keyframes tourPandaWave {
  0%,100% { transform: rotate(0); }
  25%     { transform: rotate(-25deg); }
  75%     { transform: rotate(15deg); }
}
.tour-svg .tour-monkey-tail { animation: tourMonkeyTail 2.5s ease-in-out infinite; }
@keyframes tourMonkeyTail { 0%,100%{transform:rotate(-2deg)} 50%{transform:rotate(6deg)} }
.tour-svg .tour-monkey-head { animation: tourMonkeyHead 4s ease-in-out infinite; }
@keyframes tourMonkeyHead { 0%,100%{transform:rotate(-2deg)} 50%{transform:rotate(2deg)} }
.tour-svg .tour-fox-tail { animation: tourFoxTail 0.8s ease-in-out infinite; }
@keyframes tourFoxTail { 0%,100%{transform:rotate(-8deg)} 50%{transform:rotate(15deg)} }

.tour-content {
  text-align: center;
  padding: 4px 8px 0;
}
.tour-title {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 700;
  color: #2c2416;
}
[data-theme="dark"] .tour-title { color: #f1f5f9; }

.tour-body {
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
  color: #4b3f25;
  min-height: 64px;
}
[data-theme="dark"] .tour-body { color: #cbd5e1; }

.tour-progress {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 18px 0 16px;
}
.tour-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: rgba(184, 134, 30, 0.25);
  transition: all 0.25s ease;
}
.tour-dot.is-done   { background: rgba(184, 134, 30, 0.65); }
.tour-dot.is-active {
  background: #b8861e;
  width: 22px;
  border-radius: 4px;
}

.tour-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.tour-btn-skip {
  background: transparent;
  color: #6b5e3f;
  font-size: 13px;
  border: none;
}
.tour-btn-skip:hover { color: #2c2416; text-decoration: underline; }
.tour-btn-prev:disabled { opacity: 0.4; cursor: not-allowed; }
.tour-btn-next {
  min-width: 110px;
}

@media (max-width: 480px) {
  .tour-card    { padding: 18px 16px 14px; }
  .tour-stage   { height: 180px; }
  .tour-svg     { width: 150px; height: 175px; }
  .tour-title   { font-size: 17px; }
  .tour-body    { font-size: 13px; }
}

/* ===================================================================
   Onboarding tour — 菜单(picker)+ play 模式增强
   (feat/onboarding-tour, 增加 14 个功能 + 三档可选)
=================================================================== */
.tour-menu-hero {
  text-align: center;
  padding-bottom: 12px;
}
.tour-menu-trio {
  display: flex;
  justify-content: center;
  align-items: end;
  gap: 4px;
  margin-bottom: 10px;
}
.tour-menu-trio .tour-svg {
  width: 90px;
  height: 105px;
  animation: tourBounce 2.5s ease-in-out infinite;
  filter: drop-shadow(0 6px 14px rgba(139,100,40,0.18));
}
.tour-menu-trio .tour-svg:nth-child(2) { animation-delay: -0.4s; }
.tour-menu-trio .tour-svg:nth-child(3) { animation-delay: -0.8s; }
.tour-menu-title {
  margin: 4px 0 6px;
  font-size: 20px;
  font-weight: 700;
  color: #2c2416;
}
[data-theme="dark"] .tour-menu-title { color: #f1f5f9; }
.tour-menu-sub {
  margin: 0 0 12px;
  font-size: 13px;
  color: #6b5e3f;
  line-height: 1.55;
}
[data-theme="dark"] .tour-menu-sub { color: #cbd5e1; }

.tour-menu-presets {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 6px 0 16px;
}
.tour-preset {
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(184,134,30,0.10);
  border: 1px solid rgba(184,134,30,0.3);
  color: #4b3f25;
  cursor: pointer;
  transition: all 0.15s;
}
.tour-preset:hover { background: rgba(184,134,30,0.18); }
[data-theme="dark"] .tour-preset {
  background: rgba(212,168,67,0.10);
  border-color: rgba(212,168,67,0.35);
  color: #f1f5f9;
}

.tour-menu-groups {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 18px;
}
.tour-tier {
  border-top: 1px dashed rgba(184,134,30,0.25);
  padding-top: 12px;
}
.tour-tier-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.tour-tier-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #2c2416;
}
[data-theme="dark"] .tour-tier-title { color: #f1f5f9; }
.tour-tier-toggle {
  background: transparent;
  border: none;
  color: #b8861e;
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
}
.tour-tier-toggle:hover { color: #8b6414; }

.tour-feature-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}
.tour-feature-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(184,134,30,0.18);
  border-radius: 10px;
  background: rgba(255,255,255,0.5);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 13px;
  color: #4b3f25;
}
.tour-feature-label:hover {
  border-color: rgba(184,134,30,0.45);
  background: rgba(255,255,255,0.85);
}
[data-theme="dark"] .tour-feature-label {
  background: rgba(255,255,255,0.05);
  border-color: rgba(212,168,67,0.25);
  color: #cbd5e1;
}
[data-theme="dark"] .tour-feature-label:hover {
  background: rgba(255,255,255,0.1);
}
.tour-feature-check {
  accent-color: #b8861e;
  cursor: pointer;
}
.tour-feature-icon {
  font-size: 18px;
  flex-shrink: 0;
}
.tour-feature-text { line-height: 1.3; }

.tour-feature-label:has(.tour-feature-check:checked) {
  border-color: #b8861e;
  background: rgba(184,134,30,0.10);
}

.tour-menu-count {
  font-size: 12px;
  color: #6b5e3f;
  align-self: center;
  flex: 1;
  text-align: center;
}
[data-theme="dark"] .tour-menu-count { color: #94a3b8; }

.tour-btn-back-menu {
  background: transparent;
  border: 1px solid rgba(184,134,30,0.3);
  color: #6b5e3f;
  font-size: 13px;
}
.tour-btn-back-menu:hover { background: rgba(184,134,30,0.08); }
[data-theme="dark"] .tour-btn-back-menu { color: #cbd5e1; border-color: rgba(212,168,67,0.3); }

.tour-btn-start { min-width: 130px; }
.tour-btn-start:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* topbar help button */
.topbar-help { /* uses .topbar-icon-btn base styles */ }

@media (max-width: 480px) {
  .tour-feature-grid {
    grid-template-columns: 1fr 1fr;
  }
  .tour-menu-trio .tour-svg { width: 70px; height: 80px; }
}

/* topbar help button — 熊猫头顶问号(可爱版)*/
.topbar-help .topbar-help-icon { display: block; }
.topbar-help .th-qmark {
  transform-origin: 14px 4.2px;
  transform-box: fill-box;
  animation: thQmarkBob 1.6s ease-in-out infinite;
}
@keyframes thQmarkBob {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50%      { transform: translateY(-1.5px) rotate(4deg); }
}
.topbar-help:hover .th-qmark {
  animation-duration: 0.7s;
}

/* ===================================================================
   exam-zoom-canvas — 双模式画板(issue #128:overlay + local)
=================================================================== */
.exam-zc-mode-group {
  /* mode toggle 与画笔/橡皮区分:左边一点点空气 */
  border-left: 1px solid rgba(255,255,255,0.15);
  padding-left: 10px;
}
.exam-zc-mode-group .exam-zc-mode-btn[data-zc-stage] {
  /* 突出当前激活模式 */
  font-weight: 500;
}
.exam-zc-mode-group .exam-zc-mode-btn[data-zc-stage].active {
  background: var(--accent, #b8861e);
  color: #fff;
  border-color: var(--accent, #b8861e);
}

/* local 模式的画板卡片:居中白底,不覆盖任何题图 */
.exam-zc-stage-local {
  /* 复用 .exam-zc-stage 的 max-width / shadow,但不 absolute 任何东西 */
  padding: 0;
}
.exam-zc-local-card {
  background: #ffffff;
  width: 100%;
  /* 保持画板比例 ~4:3 (LOCAL_W:LOCAL_H = 1200:900) */
  aspect-ratio: 4 / 3;
  position: relative;
  border-radius: 6px;
  overflow: hidden;
}
.exam-zc-canvas-local {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  background:
    /* 浅灰 grid 辅助网格,1cm 大致(~38px in canvas px),给学生定位用 */
    linear-gradient(rgba(120,120,120,0.08) 1px, transparent 1px) 0 0 / 100% 38px,
    linear-gradient(90deg, rgba(120,120,120,0.08) 1px, transparent 1px) 0 0 / 38px 100%,
    #ffffff;
}

/* stage 切换:hidden 隐藏,但保留 canvas 在 DOM 里持续可读 */
.exam-zc-stage[hidden] { display: none; }

@media (max-width: 760px) {
  .exam-zc-mode-group {
    border-left: none;
    padding-left: 4px;
  }
}

/* ===================================================================
   exam-inline-canvas — 就地展开画板(issue #128 增量)
=================================================================== */
.exam-ic-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* popup absolute 锚到 wrap;不加 relative 会跑到 viewport 外不可见 (#139 平板 bug) */
  position: relative;
}
/* icon vs label 拆分:小屏 icon-only,大屏 icon+label */
.exam-ic-mode-btn .ic-icon,
.exam-zc-mode-btn .zc-icon { font-weight: 600; }
.exam-ic-mode-btn .ic-label,
.exam-zc-mode-btn .zc-label { margin-left: 4px; }
@media (max-width: 1024px) {
  .exam-ic-mode-btn .ic-label,
  .exam-zc-mode-btn .zc-label { display: none; }
  .exam-ic-mode-btn,
  .exam-zc-mode-btn { padding: 6px 10px; min-width: 36px; justify-content: center; }
}
.exam-ic-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 5px 6px;
  background: rgba(0,0,0,0.04);
  border-radius: 6px;
  /* 单栏紧凑布局 — 去 tool-group 分栏感 (#139) */
}
.exam-ic-tool-group {
  border-right: none !important;
  padding-right: 0 !important;
}
[data-theme="dark"] .exam-ic-toolbar { background: rgba(255,255,255,0.05); }

.exam-ic-tool-group {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-right: 8px;
  border-right: 1px solid rgba(0,0,0,0.08);
}
[data-theme="dark"] .exam-ic-tool-group { border-right-color: rgba(255,255,255,0.1); }
.exam-ic-tool-group:last-of-type { border-right: none; }

.exam-ic-mode-btn,
.exam-ic-width-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.exam-ic-mode-btn.active,
.exam-ic-width-btn.active {
  background: var(--accent, #b8861e);
  color: #fff;
  border-color: var(--accent, #b8861e);
}
.exam-ic-mode-btn:hover:not(.active),
.exam-ic-width-btn:hover:not(.active) {
  background: rgba(0,0,0,0.06);
}
[data-theme="dark"] .exam-ic-mode-btn:hover:not(.active),
[data-theme="dark"] .exam-ic-width-btn:hover:not(.active) { background: rgba(255,255,255,0.08); }

.exam-ic-dot {
  display: inline-block;
  border-radius: 50%;
  background: currentColor;
}

.exam-ic-hint {
  flex: 1;
  font-size: 11px;
  color: var(--text-muted);
  min-width: 0;
}

.exam-ic-card {
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 6px;
  /* 默认高度,可拖底部右下角调 */
  width: 100%;
  height: 480px;
  min-height: 240px;
  max-height: 80vh;
  resize: vertical;       /* 浏览器原生 resize handle 出现在右下角 */
  overflow: hidden;
  position: relative;
}
[data-theme="dark"] .exam-ic-card { border-color: rgba(255,255,255,0.15); }

.exam-ic-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: default;
  /* 默认 idle:穿透事件,allow 页面滚动 (#139) */
  pointer-events: none;
  touch-action: auto;
  background:
    /* 浅灰辅助网格 ~1cm(38px in CSS) */
    linear-gradient(rgba(120,120,120,0.08) 1px, transparent 1px) 0 0 / 100% 38px,
    linear-gradient(90deg, rgba(120,120,120,0.08) 1px, transparent 1px) 0 0 / 38px 100%,
    #ffffff;
}
.exam-ic-wrap.ic-tool-active .exam-ic-canvas {
  /* 工具激活时才拦截事件 */
  pointer-events: auto;
  touch-action: none;
  cursor: crosshair;
}

/* ── Text-box layer(打字段落 #139)─────────────────────────────────────
   覆盖在 canvas 之上。默认 pointer-events: none(让画笔工作);只有 T mode
   class `ic-text-mode` 时整层 capture pointer 来 spawn 新 box。
   每个 box 自己始终能 hover(显示 ×),但 mousedown/click 在 pen mode 下
   穿透到 canvas(用户原地继续画笔)。 */
.exam-ic-card { position: relative; }
.exam-ic-text-layer {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 2;
}
/* wrap 是定位容器(left/top%,right 16px 拉到画板右边);textarea 全宽 */
.exam-ic-text-wrap {
  position: absolute;
  right: 16px;
  min-width: 80px;
  /* 上下加 padding 扩大可点击区域 — autosize 后 textarea 高度只有几行,
     用户在文字行末空白点击想继续编辑,padding 让 click 仍 hit 这个 wrap
     而不穿透到 canvas 创建新 box。 */
  padding: 8px 0;
  margin-top: -8px;
  pointer-events: none;
}
.exam-ic-text-layer.ic-text-mode .exam-ic-text-wrap {
  pointer-events: auto;
}
.exam-ic-text-box {
  display: block;
  width: 100%; box-sizing: border-box;
  background: transparent;
  border: none;
  padding: 0 4px;
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: #1f2937;
  outline: none;
  resize: none;                /* 不要 textarea 默认 grip */
  overflow: hidden;            /* 配合 autosize */
  caret-color: #2563eb;
  white-space: pre-wrap;
  word-break: break-word;
}
.exam-ic-text-layer.ic-text-mode .exam-ic-text-box {
  cursor: text;
}
.exam-ic-text-del,
.exam-ic-text-strike {
  position: absolute; top: -10px;
  display: none;
  width: 20px; height: 20px; line-height: 1;
  font-size: 11px; padding: 0;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}
.exam-ic-text-del { right: -10px; color: #ef4444; border: 1px solid #fecaca; }
.exam-ic-text-strike { right: 14px; color: #b91c1c; border: 1px solid #fecaca; font-weight: 600; }
.exam-ic-text-wrap.strike .exam-ic-text-strike { background: #fee2e2; }
.exam-ic-text-layer.ic-text-mode .exam-ic-text-wrap:hover .exam-ic-text-del,
.exam-ic-text-layer.ic-text-mode .exam-ic-text-wrap:focus-within .exam-ic-text-del,
.exam-ic-text-layer.ic-text-mode .exam-ic-text-wrap:hover .exam-ic-text-strike,
.exam-ic-text-layer.ic-text-mode .exam-ic-text-wrap:focus-within .exam-ic-text-strike {
  display: block;
}
/* 作废态:textarea 加红色 strikethrough,字变灰 */
.exam-ic-text-wrap.strike .exam-ic-text-box {
  text-decoration: line-through;
  text-decoration-color: #dc2626;
  text-decoration-thickness: 2px;
  color: #9ca3af;
}

/* ── Σ 公式编辑器浮窗(Phase 2 #139)────────────────────────────────
   挂 formula-input.js 完整 widget(LaTeX 输入 + 实时预览 + 200 符号工具栏)。
   编辑完点"插入答案"把 LaTeX 转 unicode 插到 textarea 光标。 */
.exam-ic-formula-popup {
  position: absolute;
  left: 12px;        /* 左下角 — 用户反馈右边按不到关闭 #139 */
  bottom: 60px;
  right: auto;
  width: min(480px, calc(100% - 24px));
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  z-index: 10;
  font-size: 13px;
}
.exam-ic-fp-popup-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid #eef2f7;
}
.exam-ic-fp-popup-title {
  flex: 1; font-size: 13px; color: #1f2937; font-weight: 600;
}
.exam-ic-fp-popup-clear {
  padding: 4px 10px;
  background: #f8fafc; color: #6b7280;
  border: 1px solid #e3e8ef; border-radius: 4px;
  font-size: 12px; cursor: pointer;
}
.exam-ic-fp-popup-clear:hover { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.exam-ic-fp-popup-insert {
  padding: 4px 12px;
  background: #16a34a; color: #fff;
  border: 1px solid #15803d; border-radius: 4px;
  font-size: 13px; cursor: pointer; font-weight: 600;
}
.exam-ic-fp-popup-insert:hover { background: #15803d; }
.exam-ic-fp-popup-close {
  width: 24px; height: 24px; padding: 0;
  background: transparent; border: 1px solid #e5e7eb; border-radius: 50%;
  color: #6b7280; cursor: pointer; line-height: 1; font-size: 14px;
}
.exam-ic-fp-popup-close:hover { background: #fee2e2; color: #ef4444; }
.exam-ic-fp-popup-body {
  padding: 8px 12px 12px;
  max-height: 60vh;
  overflow-y: auto;
}

/* Zoom canvas (全屏画板) Σ 公式 popup — 浮在 overlay 内,跟 inline 同设计 */
.exam-zc-formula-popup {
  position: fixed;
  left: 24px;        /* 左下角 #139 */
  bottom: 80px;
  width: min(540px, calc(100vw - 48px));
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.32);
  z-index: 10001;
  font-size: 13px;
}
.exam-zc-fp-popup-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid #eef2f7;
}
.exam-zc-fp-popup-title {
  flex: 1; font-size: 13px; color: #1f2937; font-weight: 600;
}
.exam-zc-fp-popup-clear {
  padding: 4px 10px;
  background: #f8fafc; color: #6b7280;
  border: 1px solid #e3e8ef; border-radius: 4px;
  font-size: 12px; cursor: pointer;
}
.exam-zc-fp-popup-clear:hover { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.exam-zc-fp-popup-insert {
  padding: 4px 12px;
  background: #16a34a; color: #fff;
  border: 1px solid #15803d; border-radius: 4px;
  font-size: 13px; cursor: pointer; font-weight: 600;
}
.exam-zc-fp-popup-insert:hover { background: #15803d; }
.exam-zc-fp-popup-close {
  width: 24px; height: 24px; padding: 0;
  background: transparent; border: 1px solid #e5e7eb; border-radius: 50%;
  color: #6b7280; cursor: pointer; line-height: 1; font-size: 14px;
}
.exam-zc-fp-popup-close:hover { background: #fee2e2; color: #ef4444; }
.exam-zc-fp-popup-body {
  padding: 8px 12px 12px;
  max-height: 65vh;
  overflow-y: auto;
}
[data-theme="dark"] .exam-zc-formula-popup {
  background: #1e293b; border-color: #475569;
}
[data-theme="dark"] .exam-zc-fp-popup-title { color: #f1f5f9; }
[data-theme="dark"] .exam-zc-fp-popup-clear {
  background: #334155; color: #cbd5e1; border-color: #475569;
}

@media (max-width: 760px) {
  .exam-ic-tool-group { padding-right: 4px; }
  .exam-ic-card { height: 380px; }
}
/* 平板 (≤1024px) 也隐藏 hint — 不然 toolbar 还是会撑成多行 (#139) */
@media (max-width: 1024px) {
  .exam-ic-hint, .exam-zc-hint, .exam-zc-label { display: none; }
  .exam-ic-tool-group, .exam-zc-tool-group { border-right-width: 0; padding-right: 6px; }
  .exam-ic-toolbar { gap: 4px; padding: 6px; }
  .exam-zc-topbar { gap: 4px; padding: 6px 8px; }
}

/* 平板 (≤1024px) 公式 popup:fixed 左下角,默认小窗 (#139) */
@media (max-width: 1024px) {
  .exam-ic-formula-popup {
    position: fixed;
    left: 12px; bottom: 12px;
    right: auto; top: auto;
    transform: none;
    width: min(82vw, 440px);
    max-height: 60vh;
    overflow: hidden;
    display: flex; flex-direction: column;
    z-index: 10002;
    box-shadow: 0 12px 32px rgba(0,0,0,0.28);
  }
  .exam-ic-fp-popup-body { flex: 1; max-height: none; overflow-y: auto; }

  .exam-zc-formula-popup {
    left: 12px; bottom: 12px;
    right: auto; top: auto;
    transform: none;
    width: min(82vw, 440px);
    max-height: 60vh;
    overflow: hidden;
    display: flex; flex-direction: column;
  }
  .exam-zc-fp-popup-body { flex: 1; max-height: none; overflow-y: auto; }
}

/* 粗细下拉 select (#139) — 收窄不抢空间 */
.exam-ic-width-select {
  padding: 2px 4px;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 4px;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  color: var(--text, #1f2937);
  height: 26px;
  max-width: 90px;
}
[data-theme="dark"] .exam-ic-width-select {
  background: #1e293b;
  border-color: rgba(255,255,255,0.15);
  color: #f1f5f9;
}

/* ============ 拍照上传 + 全屏裁剪 overlay (#139) ============ */
body.exam-crop-active { overflow: hidden; }
.exam-crop-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.96);
  z-index: 10001;
  display: flex; flex-direction: column;
  -webkit-user-select: none; user-select: none;
}
.exam-crop-topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 8px 12px;
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid #e5e7eb;
  font-size: 13px;
}
[data-theme="dark"] .exam-crop-topbar { background: rgba(30, 41, 59, 0.95); }
.exam-crop-title {
  font-size: 14px; font-weight: 600; color: #1f2937;
  flex: 1; text-align: center;
}
[data-theme="dark"] .exam-crop-title { color: #f1f5f9; }
.exam-crop-btn {
  background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 6px;
  padding: 6px 14px; font-size: 13px; font-weight: 500;
  color: #1f2937; cursor: pointer;
}
.exam-crop-btn:hover { background: #e2e8f0; }
.exam-crop-btn.exam-crop-save {
  background: #2563eb; color: #fff; border-color: #2563eb;
}
.exam-crop-btn.exam-crop-save:hover { background: #1d4ed8; }
[data-theme="dark"] .exam-crop-btn {
  background: #334155; color: #f1f5f9; border-color: #475569;
}
[data-theme="dark"] .exam-crop-btn:hover { background: #475569; }

.exam-crop-stage {
  position: relative; flex: 1;
  overflow: hidden;
  touch-action: none;
}
.exam-crop-loading {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: #cbd5e1; font-size: 14px;
}
.exam-crop-img {
  position: absolute;
  pointer-events: none;
  -webkit-user-drag: none; user-select: none;
}
.exam-crop-mask {
  position: absolute;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: none;
}
.exam-crop-box {
  position: absolute;
  border: 2px solid #2563eb;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.5) inset;
  cursor: move;
  box-sizing: border-box;
}
.exam-crop-h {
  position: absolute;
  background: #2563eb;
  border: 2px solid #fff;
  border-radius: 50%;
  width: 14px; height: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
/* 4 corners */
.exam-crop-h-tl { left: -8px; top: -8px; cursor: nwse-resize; }
.exam-crop-h-tr { right: -8px; top: -8px; cursor: nesw-resize; }
.exam-crop-h-bl { left: -8px; bottom: -8px; cursor: nesw-resize; }
.exam-crop-h-br { right: -8px; bottom: -8px; cursor: nwse-resize; }
/* 4 edges — 矩形 */
.exam-crop-h-t {
  left: 50%; top: -6px; transform: translateX(-50%);
  width: 28px; height: 8px; border-radius: 4px; cursor: ns-resize;
}
.exam-crop-h-b {
  left: 50%; bottom: -6px; transform: translateX(-50%);
  width: 28px; height: 8px; border-radius: 4px; cursor: ns-resize;
}
.exam-crop-h-l {
  left: -6px; top: 50%; transform: translateY(-50%);
  width: 8px; height: 28px; border-radius: 4px; cursor: ew-resize;
}
.exam-crop-h-r {
  right: -6px; top: 50%; transform: translateY(-50%);
  width: 8px; height: 28px; border-radius: 4px; cursor: ew-resize;
}
.exam-crop-hint {
  text-align: center; padding: 6px 12px;
  color: #cbd5e1; font-size: 12px;
  background: rgba(15, 23, 42, 0.7);
}

@media (max-width: 760px) {
  .exam-crop-h { width: 18px; height: 18px; }
  .exam-crop-h-tl { left: -10px; top: -10px; }
  .exam-crop-h-tr { right: -10px; top: -10px; }
  .exam-crop-h-bl { left: -10px; bottom: -10px; }
  .exam-crop-h-br { right: -10px; bottom: -10px; }
  .exam-crop-title { font-size: 13px; }
  .exam-crop-btn { padding: 6px 10px; font-size: 12px; }
}

/* ====================================================================
   home v2 (cnb#143 Stage 3) — home.js render 用 .hv-* namespace
   ==================================================================== */

.home-v2 { max-width: 1200px; margin: 0 auto; padding: 0 var(--ui-sp-6); }

/* ── Hero ── */
.hv-hero {
  position: relative; overflow: hidden;
  padding: var(--ui-sp-12) 0 var(--ui-sp-10);
}
.hv-hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(800px 400px at 80% -10%, rgba(59,130,246,0.10), transparent 60%),
    radial-gradient(600px 300px at 20% 100%, rgba(16,185,129,0.07), transparent 60%);
}
.hv-hero-greet {
  font-size: var(--ui-text-sm); color: var(--text-muted);
  margin-bottom: var(--ui-sp-2);
  display: flex; align-items: center; gap: var(--ui-sp-2);
}
.hv-dot { width: 8px; height: 8px; border-radius: var(--ui-r-full); background: var(--emerald-500); }
.hv-hero-title {
  font-size: var(--ui-text-4xl); font-weight: 700;
  margin: 0 0 var(--ui-sp-3); letter-spacing: -0.02em;
  color: var(--text);
}
.hv-streak-pill {
  display: inline-flex; align-items: center; gap: var(--ui-sp-2);
  padding: var(--ui-sp-2) var(--ui-sp-4);
  background: linear-gradient(135deg, #fff7ed, #ffedd5);
  border: 1px solid #fed7aa; border-radius: var(--ui-r-full);
  font-size: var(--ui-text-sm); font-weight: 600; color: #c2410c;
}
.hv-streak-pill-empty { background: linear-gradient(135deg, #eff6ff, #dbeafe); border-color: #bfdbfe; color: #1e40af; }
.hv-fire { font-size: 18px; animation: hvFire 1.6s ease-in-out infinite alternate; }
@keyframes hvFire { 0% { transform: translateY(0) scale(1); } 100% { transform: translateY(-1px) scale(1.05); } }

.hv-resume {
  margin-top: var(--ui-sp-8); padding: var(--ui-sp-6);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--ui-r-2xl); box-shadow: var(--shadow-md);
  display: flex; align-items: center; gap: var(--ui-sp-6);
  max-width: 720px;
  text-decoration: none; color: inherit;
  transition: transform var(--ui-t-norm), box-shadow var(--ui-t-norm);
}
.hv-resume:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.hv-resume-thumb {
  width: 72px; height: 72px; flex-shrink: 0;
  border-radius: var(--ui-r-lg);
  background: linear-gradient(135deg, var(--subj-mathematics), var(--blue-700));
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: white;
}
.hv-resume-info { flex: 1; min-width: 0; }
.hv-resume-label { font-size: var(--ui-text-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.hv-resume-title { font-size: var(--ui-text-lg); font-weight: 600; margin-top: var(--ui-sp-1); color: var(--text); }
.hv-resume-cta {
  padding: var(--ui-sp-3) var(--ui-sp-6);
  background: var(--blue-600); color: white;
  border: none; border-radius: var(--ui-r-lg);
  font-size: var(--ui-text-base); font-weight: 600; cursor: pointer;
  min-height: 44px; transition: var(--ui-t-fast);
  white-space: nowrap;
}
.hv-resume-cta:hover { background: var(--blue-700); transform: translateX(2px); }

/* ── Section ── */
.hv-section { margin-top: var(--ui-sp-10); }
.hv-section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: var(--ui-sp-5); }
.hv-section-title { font-size: var(--ui-text-2xl); font-weight: 700; margin: 0 0 var(--ui-sp-5); color: var(--text); }

/* ── 3 大功能卡 ── */
.hv-cards { display: grid; gap: var(--ui-sp-4); grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1200px) { .hv-cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .hv-cards { grid-template-columns: 1fr; } }
.hv-card-sprint .hv-card-icon { color: var(--blue-600, #2563eb); }
.hv-card {
  position: relative; overflow: hidden;
  padding: var(--ui-sp-6); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--ui-r-xl);
  text-decoration: none; color: inherit;
  transition: transform var(--ui-t-norm), box-shadow var(--ui-t-norm), border-color var(--ui-t-norm);
}
.hv-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: transparent; }
.hv-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--card-accent, var(--blue-500));
  transform: scaleX(0); transform-origin: left;
  transition: transform var(--ui-t-norm);
}
.hv-card:hover::before { transform: scaleX(1); }
.hv-card-icon {
  width: 56px; height: 56px; border-radius: var(--ui-r-lg);
  background: var(--card-accent-soft, var(--blue-50));
  color: var(--card-accent, var(--blue-600));
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; margin-bottom: var(--ui-sp-4);
}
.hv-card-title { font-size: var(--ui-text-lg); font-weight: 600; margin: 0 0 var(--ui-sp-2); color: var(--text); }
.hv-card-desc { font-size: var(--ui-text-sm); color: var(--text-muted); margin: 0 0 var(--ui-sp-3); line-height: 1.6; }
.hv-card-stat { font-family: var(--ui-font-mono); font-size: var(--ui-text-xl); font-weight: 600; color: var(--card-accent, var(--blue-600)); }
.hv-card-lesson { --card-accent: var(--blue-600); --card-accent-soft: var(--blue-50); }
.hv-card-exam   { --card-accent: var(--amber-600); --card-accent-soft: var(--amber-50); }
.hv-card-ai     { --card-accent: var(--emerald-600); --card-accent-soft: var(--emerald-50); }

/* ── Timeline ── */
.hv-timeline { display: flex; flex-direction: column; gap: var(--ui-sp-1);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--ui-r-xl); padding: var(--ui-sp-3); }
.hv-timeline-item {
  display: flex; align-items: center; gap: var(--ui-sp-4);
  padding: var(--ui-sp-3) var(--ui-sp-4); border-radius: var(--ui-r-md);
  text-decoration: none; color: inherit;
  transition: background var(--ui-t-fast);
  min-height: 56px;
}
.hv-timeline-item:hover { background: var(--surface-hover); }
.hv-timeline-status {
  width: 32px; height: 32px; border-radius: var(--ui-r-full); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 600;
}
.hv-timeline-status-ok   { background: var(--emerald-50); color: var(--emerald-600); }
.hv-timeline-status-warn { background: var(--amber-50);   color: var(--amber-600); }
.hv-timeline-status-err  { background: var(--rose-50);    color: var(--rose-600); }
.hv-timeline-body { flex: 1; min-width: 0; }
.hv-timeline-title { font-weight: 500; font-size: var(--ui-text-base); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hv-timeline-sub { font-size: var(--ui-text-sm); color: var(--text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hv-timeline-time { font-family: var(--ui-font-mono); font-size: var(--ui-text-xs); color: var(--text-muted); flex-shrink: 0; }

.hv-empty {
  padding: var(--ui-sp-8); text-align: center;
  background: var(--surface); border: 1px dashed var(--border);
  border-radius: var(--ui-r-xl); color: var(--text-muted);
}

/* ── Dark mode ── */
[data-theme="dark"] .hv-streak-pill { background: linear-gradient(135deg, #451a03, #78350f); border-color: #92400e; color: #fde68a; }
[data-theme="dark"] .hv-streak-pill-empty { background: linear-gradient(135deg, #1e1b4b, #312e81); border-color: #4338ca; color: #c7d2fe; }
[data-theme="dark"] .hv-card { background: var(--surface); }
[data-theme="dark"] .hv-card-lesson .hv-card-icon { background: rgba(37,99,235,0.15); }
[data-theme="dark"] .hv-card-exam   .hv-card-icon { background: rgba(217,119,6,0.15); }
[data-theme="dark"] .hv-card-ai     .hv-card-icon { background: rgba(5,150,105,0.15); }
[data-theme="dark"] .hv-timeline-status-ok   { background: rgba(16,185,129,0.15); }
[data-theme="dark"] .hv-timeline-status-warn { background: rgba(245,158,11,0.15); }
[data-theme="dark"] .hv-timeline-status-err  { background: rgba(244,63,94,0.15); }

/* ── Mobile ── */
@media (max-width: 640px) {
  .hv-hero { padding: var(--ui-sp-8) 0; }
  .hv-hero-title { font-size: var(--ui-text-3xl); }
  .hv-resume { flex-direction: column; align-items: flex-start; gap: var(--ui-sp-4); }
  .hv-resume-cta { width: 100%; }
  .hv-section { margin-top: var(--ui-sp-8); }
}

/* ====================================================================
   subject-home v2 (cnb#143 Stage 3.2) — .shv-* namespace
   响应式 (#16):宽屏几乎吃满,padding 用 clamp 自适应,
   两边窄白边即可,不再 hardcode 上限
   ==================================================================== */
.sh-v2 { width: 100%; max-width: none; margin: 0; }

/* ── Hero (学科色 gradient) ── */
.shv-hero {
  position: relative; overflow: hidden;
  padding: clamp(var(--ui-sp-8), 5vw, var(--ui-sp-16)) clamp(var(--ui-sp-4), 3vw, var(--ui-sp-12));
  color: white;
  --shv-color: var(--subj-physics);
  background: linear-gradient(135deg, var(--shv-color) 0%, #1e1b4b 100%);
}
.shv-hero[data-subj="physics"]    { --shv-color: var(--subj-physics); }
.shv-hero[data-subj="chemistry"]  { --shv-color: var(--subj-chemistry); }
.shv-hero[data-subj="biology"]    { --shv-color: var(--subj-biology); }
.shv-hero[data-subj="mathematics"]{ --shv-color: var(--subj-mathematics); }
.shv-hero[data-subj="economics"]  { --shv-color: var(--subj-economics); }
.shv-hero::before {
  content: ""; position: absolute; inset: 0; z-index: 0;
  background: radial-gradient(800px 400px at 90% 30%, rgba(255,255,255,0.15), transparent 50%);
}
.shv-hero-inner { position: relative; z-index: 1; max-width: min(2000px, 100%); margin: 0 auto; display: flex; gap: var(--ui-sp-8); align-items: center; }
@media (max-width: 760px) { .shv-hero-inner { flex-direction: column; align-items: flex-start; gap: var(--ui-sp-5); } }
.shv-hero-icon { width: 96px; height: 96px; flex-shrink: 0; border-radius: var(--ui-r-2xl); background: rgba(255,255,255,0.15); display: flex; align-items: center; justify-content: center; font-size: 56px; }
.shv-hero-info { flex: 1; }
.shv-hero-board { display: inline-block; padding: 4px 12px; background: rgba(255,255,255,0.2); border-radius: var(--ui-r-full); font-size: var(--ui-text-xs); font-weight: 600; letter-spacing: 0.05em; margin-bottom: var(--ui-sp-3); }
.shv-hero-name { font-size: var(--ui-text-4xl); font-weight: 700; margin: 0 0 var(--ui-sp-2); letter-spacing: -0.02em; color: white; }
.shv-hero-code { font-family: var(--ui-font-mono); font-size: var(--ui-text-base); opacity: 0.8; }
.shv-hero-tagline { font-size: var(--ui-text-base); margin-top: var(--ui-sp-4); opacity: 0.9; }

.shv-progress-card { display: flex; align-items: center; gap: var(--ui-sp-4); margin-top: var(--ui-sp-6); padding: var(--ui-sp-4); background: rgba(255,255,255,0.1); border-radius: var(--ui-r-lg); max-width: 540px; backdrop-filter: blur(10px); }
.shv-ring { position: relative; width: 72px; height: 72px; flex-shrink: 0; }
.shv-ring svg { transform: rotate(-90deg); }
.shv-ring circle { fill: none; stroke-width: 8; }
.shv-ring-bg { stroke: rgba(255,255,255,0.2); }
.shv-ring-fg { stroke: white; stroke-linecap: round; transition: stroke-dashoffset var(--ui-t-slow); }
.shv-ring-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--ui-font-mono); font-weight: 600; font-size: var(--ui-text-lg); color: white; }
.shv-progress-info { flex: 1; }
.shv-progress-label { font-size: var(--ui-text-xs); opacity: 0.8; text-transform: uppercase; letter-spacing: 0.05em; }
.shv-progress-text { font-size: var(--ui-text-base); font-weight: 500; margin-top: 2px; }

/* sh-section:宽屏吃满,padding 用 clamp,两边只留窄 margin */
.sh-section { width: 100%; max-width: none; margin: 0; box-sizing: border-box; padding: clamp(20px, 3vw, 48px) clamp(16px, 3vw, 64px); }
/* auto-fit:大屏拉宽自动 6 列;1280px 以下 3 列;640px 以下 2 列 */
.shv-stats { display: grid; gap: var(--ui-sp-4); grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
@media (max-width: 1280px) { .shv-stats { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); } }
@media (max-width: 640px) { .shv-stats { grid-template-columns: repeat(2, 1fr); } }

.shv-tile { position: relative; overflow: hidden; padding: var(--ui-sp-5); background: var(--surface); border: 1px solid var(--border); border-radius: var(--ui-r-xl); text-decoration: none; color: inherit; transition: transform var(--ui-t-norm), box-shadow var(--ui-t-norm), border-color var(--ui-t-norm); min-height: 130px; }
.shv-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: transparent; }
.shv-tile::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--tile-color); transform: scaleX(0); transform-origin: left; transition: transform var(--ui-t-norm); }
.shv-tile:hover::before { transform: scaleX(1); }
.shv-tile-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--ui-sp-3); }
.shv-tile-icon { width: 40px; height: 40px; border-radius: var(--ui-r-md); background: var(--tile-soft); color: var(--tile-color); display: flex; align-items: center; justify-content: center; font-size: 20px; }
.shv-tile-arrow { color: var(--text-soft); opacity: 0; transition: var(--ui-t-fast); }
.shv-tile:hover .shv-tile-arrow { opacity: 1; transform: translateX(2px); }
.shv-tile-num { font-family: var(--ui-font-mono); font-weight: 600; font-size: var(--ui-text-4xl); line-height: 1; color: var(--text); }
.shv-tile-num-icon { font-family: var(--ui-font-sans); font-size: var(--ui-text-2xl); }
.shv-tile-label { font-size: var(--ui-text-sm); color: var(--text-muted); margin-top: var(--ui-sp-2); }
.shv-tile-t1 { --tile-color: var(--blue-600); --tile-soft: var(--blue-50); }
.shv-tile-t2 { --tile-color: var(--amber-600); --tile-soft: var(--amber-50); }
.shv-tile-t3 { --tile-color: var(--emerald-600); --tile-soft: var(--emerald-50); }
.shv-tile-t4 { --tile-color: var(--rose-600); --tile-soft: var(--rose-50); }

.shv-rec { background: var(--surface); border: 1px solid var(--border); border-radius: var(--ui-r-xl); padding: var(--ui-sp-6); }
.shv-rec-head { display: flex; align-items: center; gap: var(--ui-sp-3); margin-bottom: var(--ui-sp-5); }
.shv-rec-head h3 { margin: 0; font-size: var(--ui-text-xl); color: var(--text); }
.shv-rec-badge { font-size: var(--ui-text-xs); padding: 2px 8px; background: var(--blue-50); color: var(--blue-700); border-radius: var(--ui-r-full); font-weight: 600; }
.shv-rec-list { display: flex; flex-direction: column; gap: var(--ui-sp-3); }
.shv-rec-item { display: flex; align-items: center; gap: var(--ui-sp-4); padding: var(--ui-sp-4); border: 1px solid var(--border); border-radius: var(--ui-r-lg); text-decoration: none; color: inherit; transition: var(--ui-t-fast); min-height: 64px; }
.shv-rec-item:hover { border-color: var(--blue-600); background: var(--blue-50); }
.shv-rec-num { width: 28px; height: 28px; border-radius: var(--ui-r-full); background: var(--blue-100); color: var(--blue-700); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: var(--ui-text-sm); flex-shrink: 0; }
.shv-rec-body { flex: 1; }
.shv-rec-title { font-weight: 500; color: var(--text); }
.shv-rec-sub { font-size: var(--ui-text-sm); color: var(--text-muted); margin-top: 2px; }
.shv-rec-time { font-family: var(--ui-font-mono); color: var(--text-soft); }
.shv-rec-empty { padding: var(--ui-sp-6); text-align: center; color: var(--text-muted); border: 1px dashed var(--border); border-radius: var(--ui-r-lg); }

/* ====================================================================
   subjects-catalog v2 视觉升级 (cnb#143 Stage 3.3)
   ==================================================================== */
.subject-card {
  transition: transform var(--ui-t-norm), box-shadow var(--ui-t-norm), border-color var(--ui-t-norm);
}
.subject-card.active:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: transparent; }
.subject-card .subject-emoji { transition: transform var(--ui-t-fast); }
.subject-card:hover .subject-emoji { transform: scale(1.1) rotate(-4deg); }

/* ====================================================================
   mobile bottom tab bar (cnb#143 Stage 6.1) — only ≤768px
   ==================================================================== */
.mobile-tab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  display: none;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--border);
  padding: var(--ui-sp-1) var(--ui-sp-1) calc(var(--ui-sp-1) + env(safe-area-inset-bottom));
  transition: transform var(--ui-t-norm);
}
[data-theme="dark"] .mobile-tab-bar { background: rgba(15,23,42,0.92); border-color: var(--gray-800); }
.mobile-tab-bar.hidden-tab { transform: translateY(100%); }
.mobile-tab-bar > nav { display: flex; align-items: stretch; gap: 2px; max-width: 600px; margin: 0 auto; }
.mobile-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: var(--ui-sp-2) 4px; min-height: 56px;
  background: transparent; border: none; cursor: pointer;
  text-decoration: none; color: var(--text-muted);
  font-size: 11px; font-weight: 500;
  border-radius: var(--ui-r-md);
  transition: var(--ui-t-fast);
}
.mobile-tab:active { background: var(--surface-hover); }
.mobile-tab.active { color: var(--blue-600); }
[data-theme="dark"] .mobile-tab.active { color: var(--blue-500); }
.mobile-tab-icon { font-size: 22px; line-height: 1; }
.mobile-tab-label { font-size: 10px; letter-spacing: 0.02em; }

@media (max-width: 768px) {
  .mobile-tab-bar { display: block; }
  body { padding-bottom: 72px; }
  /* hide sidebar on mobile (let bottom tab take over) */
  .sidebar, [data-sidebar] { display: none; }
}

/* ====================================================================
   平板 split-view (cnb#143 Stage 6.2) — 769-1023px adaptive
   ==================================================================== */
@media (min-width: 769px) and (max-width: 1023px) {
  .reader-layout { grid-template-columns: 240px minmax(0, 1fr) 0px; }
  .content { max-width: 100% !important; padding: var(--ui-sp-6); }
}

/* ====================================================================
   暗色全 audit — v2 namespace 补全 (cnb#143 Stage 6.2)
   ==================================================================== */
[data-theme="dark"] .hv-resume { background: var(--gray-900); border-color: var(--gray-800); }
[data-theme="dark"] .hv-card    { background: var(--gray-900); border-color: var(--gray-800); }
[data-theme="dark"] .hv-empty   { color: var(--gray-500); border-color: var(--gray-800); }
[data-theme="dark"] .hv-timeline{ background: var(--gray-900); border-color: var(--gray-800); }

[data-theme="dark"] .shv-tile { background: var(--gray-900); border-color: var(--gray-800); }
[data-theme="dark"] .shv-rec  { background: var(--gray-900); border-color: var(--gray-800); }
[data-theme="dark"] .shv-rec-item { border-color: var(--gray-800); }
[data-theme="dark"] .shv-rec-item:hover { background: rgba(37,99,235,0.15); border-color: var(--blue-600); }
[data-theme="dark"] .shv-tile-t1 { --tile-soft: rgba(37,99,235,0.15); }
[data-theme="dark"] .shv-tile-t2 { --tile-soft: rgba(217,119,6,0.15); }
[data-theme="dark"] .shv-tile-t3 { --tile-soft: rgba(5,150,105,0.15); }
[data-theme="dark"] .shv-tile-t4 { --tile-soft: rgba(225,29,72,0.15); }

/* ====================================================================
   progress.js v2 增量 — 阅读进度 list (cnb#143 Stage 5.1)
   ==================================================================== */
.pgv-reading {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--ui-r-xl); padding: var(--ui-sp-6); margin-top: var(--ui-sp-6);
}
.pgv-reading h3 { margin: 0 0 var(--ui-sp-3); font-size: var(--ui-text-xl); color: var(--text); }
.pgv-reading .pgv-sub { margin: 0 0 var(--ui-sp-4); color: var(--text-muted); font-size: var(--ui-text-sm); }
.pgv-reading-list { display: flex; flex-direction: column; gap: var(--ui-sp-3); }
.pgv-reading-item {
  display: flex; align-items: center; gap: var(--ui-sp-4);
  padding: var(--ui-sp-3) var(--ui-sp-4); border: 1px solid var(--border);
  border-radius: var(--ui-r-lg); text-decoration: none; color: inherit;
  transition: var(--ui-t-fast);
}
.pgv-reading-item:hover { background: var(--surface-hover); border-color: var(--border-strong); }
[data-theme="dark"] .pgv-reading { background: var(--gray-900); border-color: var(--gray-800); }
[data-theme="dark"] .pgv-reading-item { border-color: var(--gray-800); }
.pgv-reading-thumb {
  width: 48px; height: 48px; flex-shrink: 0; border-radius: var(--ui-r-md);
  display: flex; align-items: center; justify-content: center; font-size: 22px;
  background: var(--thumb-bg, var(--blue-50)); color: var(--thumb-color, var(--blue-600));
}
.pgv-reading-item[data-s="physics"]    { --thumb-bg: rgba(139,92,246,0.15); --thumb-color: var(--subj-physics); }
.pgv-reading-item[data-s="chemistry"]  { --thumb-bg: rgba(244,63,94,0.15);  --thumb-color: var(--subj-chemistry); }
.pgv-reading-item[data-s="biology"]    { --thumb-bg: rgba(16,185,129,0.15); --thumb-color: var(--subj-biology); }
.pgv-reading-item[data-s="mathematics"]{ --thumb-bg: rgba(59,130,246,0.15); --thumb-color: var(--subj-mathematics); }
.pgv-reading-item[data-s="economics"]  { --thumb-bg: rgba(249,115,22,0.15); --thumb-color: var(--subj-economics); }
.pgv-reading-body { flex: 1; min-width: 0; }
.pgv-reading-title { font-weight: 600; font-size: var(--ui-text-base); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pgv-reading-meta { display: flex; align-items: center; gap: var(--ui-sp-3); margin-top: var(--ui-sp-2); font-size: var(--ui-text-xs); color: var(--text-muted); }
.pgv-reading-bar { flex: 1; max-width: 200px; height: 4px; background: var(--surface-hover); border-radius: 2px; overflow: hidden; }
[data-theme="dark"] .pgv-reading-bar { background: var(--gray-800); }
.pgv-reading-bar > div { height: 100%; background: var(--thumb-color, var(--blue-500)); border-radius: 2px; }
.pgv-reading-pct { font-family: var(--ui-font-mono); font-weight: 600; color: var(--text); }
.pgv-reading-empty { padding: var(--ui-sp-6); text-align: center; color: var(--text-muted); border: 1px dashed var(--border); border-radius: var(--ui-r-lg); }

/* ====================================================================
   exam amber feedback (cnb#143 Stage 5.2) — 答错友善 hint
   ==================================================================== */
.exam-feedback {
  margin-top: var(--ui-sp-4); padding: var(--ui-sp-5);
  border-radius: var(--ui-r-xl); border: 1px solid;
  display: flex; align-items: flex-start; gap: var(--ui-sp-4);
  animation: examFbIn 400ms cubic-bezier(0.4,0,0.2,1);
}
@keyframes examFbIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; } }
.exam-feedback.success { background: var(--emerald-50); border-color: #6ee7b7; }
.exam-feedback.warn { background: var(--amber-50); border-color: #fcd34d; }
[data-theme="dark"] .exam-feedback.success { background: rgba(16,185,129,0.1); border-color: rgba(110,231,183,0.3); }
[data-theme="dark"] .exam-feedback.warn { background: rgba(245,158,11,0.1); border-color: rgba(252,211,77,0.3); }
.exam-feedback-icon {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: var(--ui-r-full);
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.exam-feedback.success .exam-feedback-icon { background: var(--emerald-500); color: white; }
.exam-feedback.warn .exam-feedback-icon { background: var(--amber-500); color: white; }
.exam-feedback-title { font-weight: 600; font-size: var(--ui-text-base); margin: 0 0 var(--ui-sp-2); }
.exam-feedback.success .exam-feedback-title { color: var(--emerald-600); }
.exam-feedback.warn .exam-feedback-title { color: var(--amber-600); }
.exam-feedback-body { font-size: var(--ui-text-sm); color: var(--text-muted); line-height: 1.6; margin: 0; }
/* === tipPanel v7 (issue #134) — bottom-sheet / right-drawer auto adaptive === */
#tipPanel.tip-panel {
  position: fixed;
  background: var(--bg, #fff);
  color: var(--fg, #111);
  display: flex; flex-direction: column;
  z-index: 1000; overflow: hidden;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.18);
  border: 1px solid #d6dee6;
}
#tipPanel[hidden] { display: none !important; }
#tipPanelMask { position: fixed; inset: 0; background: rgba(0,0,0,0.25); z-index: 999; }
#tipPanelMask[hidden] { display: none !important; }
@media (max-width: 1023px) {
  #tipPanel.tip-panel { bottom: 0; left: 0; right: 0; top: auto; max-height: 72vh; border-radius: 16px 16px 0 0; }
}
@media (min-width: 1024px) {
  #tipPanel.tip-panel {
    top: 60px; right: 0; bottom: 0;
    left: auto !important;               /* 强制贴右侧,防 grid layout 影响 (#143 fix 4) */
    width: min(560px, 45vw);
    border-radius: 16px 0 0 16px;
  }
}
/* 暗色补:用 surface 而不是 bg 防 transparent  */
#tipPanel.tip-panel { background: var(--surface, #fff); color: var(--text, #111); border-color: var(--border, #d6dee6); }
[data-theme="dark"] #tipPanel.tip-panel { background: var(--gray-900, #111827); color: var(--gray-50, #f9fafb); border-color: var(--gray-800, #1f2937); }

#tipPanel .tip-panel-handle { width: 44px; height: 5px; background: #c9d2db; border-radius: 3px; margin: 8px auto; }
@media (min-width: 1024px) { #tipPanel .tip-panel-handle { display: none; } }

#tipPanel .tip-panel-head { padding: 10px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e5ebf2; gap: 8px; }
#tipPanel .tip-panel-title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#tipPanel .tip-panel-close { background: transparent; border: none; font-size: 24px; line-height: 1; cursor: pointer; color: #5a6573; padding: 4px 8px; }
#tipPanel .tip-panel-close:hover { color: #111; }

#tipPanel .tip-panel-tabs { display: flex; gap: 4px; padding: 8px 12px; overflow-x: auto; border-bottom: 1px solid #e5ebf2; scrollbar-width: thin; }
#tipPanel .tip-tab { white-space: nowrap; padding: 6px 12px; border: 1px solid #d6dee6; border-radius: 14px; background: #f4f7fa; color: #2a3441; cursor: pointer; font-size: 13px; flex-shrink: 0; }
#tipPanel .tip-tab:hover { background: #e8eef4; }
#tipPanel .tip-tab.active { background: #2563eb; color: #fff; border-color: #2563eb; }

#tipPanel .tip-panel-body { padding: 14px 18px; overflow-y: auto; flex: 1; font-size: 14px; line-height: 1.6; }
#tipPanel .tip-panel-body h1, #tipPanel .tip-panel-body h2, #tipPanel .tip-panel-body h3, #tipPanel .tip-panel-body h4 { margin: 12px 0 6px; }
#tipPanel .tip-panel-body .table-wrap { width: 100%; overflow-x: auto; margin: 8px 0; border: 1px solid #e5ebf2; border-radius: 6px; }
#tipPanel .tip-panel-body .table-wrap table { margin: 0; min-width: 100%; border: none; }
#tipPanel .tip-panel-body .table-wrap th, #tipPanel .tip-panel-body .table-wrap td { padding: 8px 12px; border: none; border-bottom: 1px solid #eef1f5; vertical-align: top; font-size: 13px; line-height: 1.5; white-space: normal; }
#tipPanel .tip-panel-body .table-wrap th { background: #f4f7fa; font-weight: 600; font-size: 12px; position: sticky; top: 0; z-index: 1; border-bottom: 2px solid #d6dee6; }
#tipPanel .tip-panel-body .table-wrap tr:last-child td { border-bottom: none; }
#tipPanel .tip-panel-body code { background: #f4f7fa; padding: 1px 6px; border-radius: 3px; font-family: ui-monospace, monospace; font-size: 0.92em; }
#tipPanel .tip-panel-body blockquote { border-left: 3px solid #2563eb; padding-left: 12px; margin: 8px 0; color: #4a5566; }

#tipPanel .tip-panel-foot { padding: 8px 18px; border-top: 1px solid #e5ebf2; font-size: 11px; color: #6b7480; }

/* dark mode */
[data-theme="dark"] #tipPanel.tip-panel, .theme-dark #tipPanel.tip-panel { background: #1f2733; color: #d9e1ea; border-color: #2c3744; }
[data-theme="dark"] #tipPanel .tip-panel-head, [data-theme="dark"] #tipPanel .tip-panel-tabs, [data-theme="dark"] #tipPanel .tip-panel-foot,
.theme-dark #tipPanel .tip-panel-head, .theme-dark #tipPanel .tip-panel-tabs, .theme-dark #tipPanel .tip-panel-foot { border-color: #2c3744; }
[data-theme="dark"] #tipPanel .tip-tab, .theme-dark #tipPanel .tip-tab { background: #2a3441; color: #c0c8d2; border-color: #3a4554; }
[data-theme="dark"] #tipPanel .tip-tab.active, .theme-dark #tipPanel .tip-tab.active { background: #3b82f6; }

/* Hide legacy tipBubble — replaced by tipPanel v7 */
#tipBubble { display: none !important; }
/* === end tipPanel v7 === */

/* === cnb#145 Stage 4: 趋势页 v2(Linear/Stripe 风格)=== */
.tr-page { padding: 0 4px; }
.tr-hero { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 12px; margin-bottom: 20px; }
@media (max-width: 900px) { .tr-hero { grid-template-columns: 1fr 1fr; } }
.tr-hero-card {
  background: var(--surface, white);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 16px;
  padding: 18px;
}
.tr-hero-card.main {
  background: linear-gradient(135deg, rgba(99,102,241,0.06), rgba(16,185,129,0.04));
  border-color: rgba(59,130,246,0.18);
}
.tr-hero-label { font-size: 11px; color: var(--text-muted, #64748b); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.tr-hero-value { font-size: 28px; font-weight: 700; margin-top: 4px; color: var(--text, #1e293b); }
.tr-hero-value small { font-size: 14px; color: var(--text-muted, #64748b); font-weight: 400; margin-left: 4px; }
.tr-hero-meta { font-size: 11px; color: var(--text-muted, #64748b); margin-top: 4px; }

.tr-chart-card, .tr-rank-card {
  background: var(--surface, white);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 16px;
  padding: 22px 26px;
  margin-bottom: 20px;
}
.tr-chart-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; gap: 16px; flex-wrap: wrap; }
.tr-chart-head h3 { margin: 0; font-size: 18px; }
.tr-chart-head .sub { font-size: 12px; color: var(--text-muted, #64748b); margin-top: 2px; }
.tr-chart-toggle {
  display: flex; gap: 4px; padding: 3px;
  background: var(--surface-hover, #f1f5f9);
  border-radius: 12px; border: 1px solid var(--border, #e2e8f0);
}
.tr-chart-toggle button {
  padding: 4px 12px; border: none; background: transparent;
  font-size: 12px; cursor: pointer; border-radius: 8px;
  color: var(--text-muted, #64748b);
}
.tr-chart-toggle button.active { background: var(--surface, white); color: var(--text, #1e293b); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

.tr-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 12px; }
.tr-legend-item {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text, #1e293b);
  cursor: pointer; transition: opacity .15s;
}
.tr-legend-item.off { opacity: 0.35; }
.tr-legend-dot { width: 10px; height: 10px; border-radius: 50%; }

.tr-svg-wrap {
  position: relative; width: 100%; height: 320px;
  background: linear-gradient(180deg, rgba(99,102,241,0.02), rgba(99,102,241,0.01));
  border-radius: 12px;
}
.tr-svg { width: 100%; height: 100%; display: block; }
.tr-grid line { stroke: var(--border, #e2e8f0); stroke-width: 1; stroke-dasharray: 3,3; }
.tr-axis text { fill: var(--text-soft, #94a3b8); font-size: 11px; font-family: var(--ui-font-mono, monospace); }
.tr-line { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; transition: opacity .15s; }
.tr-line.dim { stroke-width: 1.5; opacity: 0.5; }
.tr-dot { stroke: white; stroke-width: 1.5; cursor: pointer; transition: r .15s; }
.tr-dot:hover { r: 5; }
.tr-tooltip {
  position: absolute; padding: 8px 10px;
  background: var(--gray-900, #111827); color: white;
  border-radius: 8px; font-size: 12px;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 10;
}
.tr-tooltip strong { display: block; font-size: 11px; font-weight: 500; opacity: 0.7; margin-bottom: 2px; }

.tr-rank-card h3 { margin: 0 0 6px; font-size: 18px; }
.tr-rank-card .sub { font-size: 12px; color: var(--text-muted, #64748b); margin-bottom: 16px; }
.tr-rank-table { width: 100%; border-collapse: collapse; }
.tr-rank-table th {
  text-align: left; padding: 8px 12px;
  font-size: 11px; color: var(--text-muted, #64748b);
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border, #e2e8f0);
}
.tr-rank-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  font-size: 14px;
}
.tr-rank-table tr:hover td { background: var(--surface-hover, #f1f5f9); }
.tr-rank-table .rank-n { font-family: var(--ui-font-mono, monospace); color: var(--text-muted, #64748b); width: 30px; }
.tr-rank-table .rank-code {
  font-family: var(--ui-font-mono, monospace);
  background: rgba(59,130,246,0.1); color: var(--blue-700, #1d4ed8);
  padding: 2px 8px; border-radius: 9999px;
  font-size: 11px; text-decoration: none;
  display: inline-block;
}
.tr-rank-table .rank-code:hover { background: rgba(59,130,246,0.18); }
.tr-rank-trend {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; padding: 2px 8px;
  border-radius: 9999px;
}
.tr-rank-trend.up { background: rgba(16,185,129,0.1); color: var(--emerald-600, #059669); }
.tr-rank-trend.stable { background: var(--surface-hover, #f1f5f9); color: var(--text-muted, #64748b); }
.tr-rank-trend.down { background: rgba(244,63,94,0.1); color: var(--rose-600, #e11d48); }
.tr-rank-spark { width: 80px; height: 24px; }

[data-theme="dark"] .tr-hero-card, .theme-dark .tr-hero-card,
[data-theme="dark"] .tr-chart-card, .theme-dark .tr-chart-card,
[data-theme="dark"] .tr-rank-card, .theme-dark .tr-rank-card { background: #1e293b; border-color: rgba(255,255,255,0.1); }
[data-theme="dark"] .tr-grid line, .theme-dark .tr-grid line { stroke: rgba(255,255,255,0.08); }
[data-theme="dark"] .tr-rank-table th, .theme-dark .tr-rank-table th { color: rgba(255,255,255,0.5); border-color: rgba(255,255,255,0.08); }
[data-theme="dark"] .tr-rank-table td, .theme-dark .tr-rank-table td { border-color: rgba(255,255,255,0.08); }
[data-theme="dark"] .tr-rank-table tr:hover td, .theme-dark .tr-rank-table tr:hover td { background: rgba(255,255,255,0.04); }

/* === cnb#145 Stage 4: 考点详情 v2 === */
.pd-page { padding: 0 4px; }
.pd-hero {
  background: linear-gradient(135deg, rgba(59,130,246,0.06), rgba(16,185,129,0.04));
  border: 1px solid rgba(59,130,246,0.18);
  border-radius: 24px;
  padding: 28px 32px;
  margin-bottom: 24px;
  display: flex; gap: 32px; align-items: center;
}
.pd-hero[data-subj="physics"]     { background: linear-gradient(135deg, rgba(139,92,246,0.08), rgba(59,130,246,0.04)); border-color: rgba(139,92,246,0.22); }
.pd-hero[data-subj="chemistry"]   { background: linear-gradient(135deg, rgba(244,63,94,0.08), rgba(245,158,11,0.04));  border-color: rgba(244,63,94,0.22); }
.pd-hero[data-subj="biology"]     { background: linear-gradient(135deg, rgba(16,185,129,0.08), rgba(59,130,246,0.04));  border-color: rgba(16,185,129,0.22); }
.pd-hero[data-subj="mathematics"] { background: linear-gradient(135deg, rgba(59,130,246,0.08), rgba(99,102,241,0.04));  border-color: rgba(59,130,246,0.22); }

.pd-hero-info { flex: 1; min-width: 0; }
.pd-code-badge {
  display: inline-flex; gap: 6px; align-items: center;
  font-family: var(--ui-font-mono, monospace); font-size: 12px;
  background: rgba(255,255,255,0.6); padding: 4px 10px;
  border: 1px solid rgba(59,130,246,0.3); border-radius: 9999px;
  color: var(--blue-700, #1d4ed8); margin-bottom: 8px;
}
.pd-code-badge code { font-family: inherit; font-weight: 600; }
.pd-title {
  font-size: 22px; font-weight: 700; margin: 0 0 6px;
  line-height: 1.35; color: var(--text, #1e293b);
}
.pd-topic { font-size: 14px; color: var(--text-muted, #64748b); margin-bottom: 12px; }
.pd-keywords { display: flex; flex-wrap: wrap; gap: 6px; }
.pd-keywords span {
  font-size: 11px; padding: 2px 8px;
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 9999px; color: var(--text-muted, #64748b);
}

.pd-cp-badge {
  display: inline-flex; gap: 4px; padding: 4px 10px;
  background: rgba(245,158,11,0.1); color: var(--amber-600, #d97706);
  border-radius: 9999px; font-size: 11px; font-weight: 600;
  border: 1px solid #fcd34d; margin-left: 8px; vertical-align: middle;
}

.pd-stats-ring { flex-shrink: 0; width: 168px; text-align: center; }
.pd-ring-svg { width: 120px; height: 120px; margin: 0 auto 8px; }
.pd-ring-svg circle { fill: none; stroke-width: 8; }
.pd-ring-bg { stroke: rgba(255,255,255,0.4); }
.pd-ring-fg {
  stroke: var(--emerald-500, #10b981); stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: center;
  transition: stroke-dashoffset 600ms ease-out;
}
.pd-ring-num { font-size: 24px; font-weight: 700; fill: var(--text, #1e293b); }
.pd-ring-sub { font-size: 11px; color: var(--text-muted, #64748b); margin-top: 2px; }

.pd-main { display: grid; grid-template-columns: 1fr 320px; gap: 24px; }
@media (max-width: 900px) { .pd-main { grid-template-columns: 1fr; } }

.pd-section {
  background: var(--surface, white);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 16px;
  padding: 20px 24px;
  margin-bottom: 18px;
}
.pd-section h3 { margin: 0 0 14px; font-size: 18px; }
.pd-explain { font-size: 15px; line-height: 1.75; color: var(--text, #1e293b); }
.pd-explain p { margin: 0 0 10px; }
.pd-explain ul, .pd-explain ol { padding-left: 22px; margin: 0 0 10px; }
.pd-explain li { margin-bottom: 4px; }
.pd-explain code {
  font-family: var(--ui-font-mono, monospace);
  background: var(--surface-hover, #f1f5f9);
  padding: 1px 6px; border-radius: 4px; font-size: 13px;
}

.pd-ai-rewrite {
  margin-top: 14px;
  background: linear-gradient(180deg, rgba(99,102,241,0.04), rgba(99,102,241,0.01));
  border: 1px solid rgba(99,102,241,0.18);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex; align-items: center; gap: 14px;
}
.pd-ai-rewrite-head { font-size: 14px; color: var(--text-muted, #64748b); flex: 1; }
.pd-ai-rewrite .btn-primary {
  background: var(--blue-500, #3b82f6); color: white; border: none;
  border-radius: 8px; padding: 6px 14px; cursor: pointer; font-size: 14px;
}

.pd-papers-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 12px; flex-wrap: wrap; }
.pd-papers-filter { display: flex; gap: 6px; font-size: 12px; }
.pd-papers-filter button {
  padding: 3px 10px; border: 1px solid var(--border, #e2e8f0);
  background: var(--surface, white); border-radius: 9999px; cursor: pointer; font-size: 12px;
}
.pd-papers-filter button.active { background: var(--blue-50, #eff6ff); border-color: var(--blue-500, #3b82f6); color: var(--blue-700, #1d4ed8); }

.pd-paper-item {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  text-decoration: none; color: inherit;
  cursor: pointer; transition: background .15s;
}
.pd-paper-item:hover { background: var(--surface-hover, #f1f5f9); }
.pd-paper-item:last-child { border-bottom: none; }
.pd-paper-ico {
  width: 36px; height: 36px; flex-shrink: 0;
  background: rgba(245,158,11,0.1); color: var(--amber-600, #d97706);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.pd-paper-body { flex: 1; min-width: 0; }
.pd-paper-title { font-size: 14px; font-weight: 500; }
.pd-paper-meta { font-size: 11px; color: var(--text-muted, #64748b); margin-top: 2px; }
.pd-conf {
  font-size: 10px; padding: 1px 8px; border-radius: 9999px;
  background: rgba(16,185,129,0.1); color: var(--emerald-600, #059669);
  flex-shrink: 0;
}
.pd-conf.medium { background: rgba(245,158,11,0.1); color: var(--amber-600, #d97706); }

/* 侧栏 */
.pd-side { display: flex; flex-direction: column; gap: 16px; }
.pd-side .card-mini { background: var(--surface, white); border: 1px solid var(--border, #e2e8f0); border-radius: 12px; padding: 16px; }
.pd-side h4 { font-size: 12px; margin: 0 0 12px; color: var(--text-muted, #64748b); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }

.pd-sparkline { width: 100%; height: 60px; display: block; }
.pd-sparkline-path { fill: none; stroke: var(--emerald-500, #10b981); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pd-sparkline-area { fill: rgba(16,185,129,0.15); stroke: none; }
.pd-sparkline-dot { fill: var(--emerald-500, #10b981); }
.pd-spark-years { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-soft, #94a3b8); margin-top: 4px; }

.pd-conf-row { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 6px; }
.pd-conf-bar { flex: 1; height: 4px; background: var(--surface-hover, #f1f5f9); border-radius: 2px; overflow: hidden; }
.pd-conf-bar-fill { height: 100%; }
.pd-conf-bar-fill.high   { background: var(--emerald-500, #10b981); }
.pd-conf-bar-fill.medium { background: var(--amber-500, #f59e0b); }
.pd-conf-bar-fill.review { background: var(--rose-500, #f43f5e); }
.pd-conf-row .label { width: 60px; color: var(--text-muted, #64748b); }
.pd-conf-row .num { width: 24px; text-align: right; color: var(--text, #1e293b); font-weight: 500; }

.pd-ai-mini {
  background: linear-gradient(180deg, rgba(99,102,241,0.06), rgba(99,102,241,0.01));
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  transition: all .15s;
}
.pd-ai-mini:hover { border-color: var(--blue-500, #3b82f6); transform: translateY(-1px); }
.pd-ai-mini-title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.pd-ai-mini-sub { font-size: 11px; color: var(--text-muted, #64748b); }

[data-theme="dark"] .pd-section, .theme-dark .pd-section,
[data-theme="dark"] .pd-side .card-mini, .theme-dark .pd-side .card-mini { background: #1e293b; border-color: rgba(255,255,255,0.1); }
[data-theme="dark"] .pd-hero, .theme-dark .pd-hero { background: linear-gradient(135deg, rgba(129,140,248,0.12), rgba(110,231,183,0.08)); border-color: rgba(129,140,248,0.25); }
[data-theme="dark"] .pd-code-badge, .theme-dark .pd-code-badge { background: rgba(255,255,255,0.06); }
[data-theme="dark"] .pd-keywords span, .theme-dark .pd-keywords span { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.1); }

.pd-sprint-link {
  background: linear-gradient(180deg, rgba(245,158,11,0.06), rgba(245,158,11,0.01)) !important;
  border-color: rgba(245,158,11,0.22) !important;
  text-decoration: none; color: inherit; display: block;
}
.pd-sprint-link:hover {
  border-color: var(--amber-500, #f59e0b) !important;
  transform: translateY(-1px);
}

/* cnb#16:考点详情 教材 跳转 link (替换 删除的 AI 重讲/帮我 按钮) */
.pd-lesson-link {
  display: flex; align-items: center; gap: 14px;
  margin-top: 14px; padding: 14px 16px;
  background: linear-gradient(180deg, rgba(99,102,241,0.05), rgba(99,102,241,0.01));
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 10px;
  text-decoration: none; color: inherit;
  transition: border-color 0.15s, transform 0.15s;
}
.pd-lesson-link:hover {
  border-color: var(--accent, #6366f1);
  transform: translateY(-1px);
}
.pd-lesson-ico { font-size: 24px; }
.pd-lesson-body { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.pd-lesson-title { font-size: 15px; font-weight: 600; color: var(--text, #1f2937); }
.pd-lesson-sub   { font-size: 12px; color: var(--text-muted, #64748b); }
.pd-lesson-arrow { font-size: 20px; color: var(--accent, #6366f1); font-weight: 600; }
[data-theme="dark"] .pd-lesson-link, .theme-dark .pd-lesson-link {
  background: linear-gradient(180deg, rgba(99,102,241,0.1), rgba(99,102,241,0.04));
  border-color: rgba(99,102,241,0.3);
}
[data-theme="dark"] .pd-lesson-title, .theme-dark .pd-lesson-title { color: var(--text, #e5e7eb); }

/* === cnb#145 sprint-review iframe page === */
.sr-page { padding: 0 4px; }
.sr-page .pane-head { margin-bottom: 12px; }
.sr-actions { display: flex; gap: 8px; }
.sr-frame-wrap {
  min-height: 80vh;
  height: 80vh;
  background: white;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  overflow: hidden;
}
.sr-frame { width: 100%; height: 100%; border: 0; display: block; background: white; }
[data-theme="dark"] .sr-frame-wrap, .theme-dark .sr-frame-wrap {
  background: #f9fafb;  /* iframe 内 zip pandoc html 是 light theme,wrap 保持 light bg 不打架 */
}

/* === cnb#145 考点目录 v2(Unit 分组 + 题数 chip + Core Practical badge)=== */
.pt-page { padding: 0; }
.pt-meta {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 0 0 18px;
  padding: 0 4px;
}
.pt-meta-chip {
  display: inline-flex; gap: 4px; align-items: center;
  padding: 4px 12px;
  background: var(--blue-50, #eff6ff);
  border: 1px solid rgba(59,130,246,0.2);
  border-radius: 9999px;
  font-size: 12px;
  color: var(--blue-700, #1d4ed8);
}
.pt-meta-chip.pt-meta-chip-hot {
  background: rgba(245,158,11,0.1);
  border-color: rgba(245,158,11,0.3);
  color: var(--amber-600, #d97706);
}
.pt-meta-chip.muted {
  background: var(--surface-hover, #f1f5f9);
  border-color: var(--border, #e2e8f0);
  color: var(--text-muted, #64748b);
}

.pt-tree { display: flex; flex-direction: column; gap: 12px; }
.pt-unit {
  background: var(--surface, white);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  overflow: hidden;
}
.pt-unit-head {
  list-style: none;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px;
  cursor: pointer;
  user-select: none;
  transition: background .15s;
}
.pt-unit-head::-webkit-details-marker { display: none; }
.pt-unit-head::before {
  content: "▸";
  color: var(--text-muted, #64748b);
  font-size: 12px;
  transition: transform .15s;
}
.pt-unit[open] .pt-unit-head::before { transform: rotate(90deg); }
.pt-unit-head:hover { background: var(--surface-hover, #f1f5f9); }
.pt-unit-n {
  font-family: var(--ui-font-mono, monospace);
  font-weight: 600;
  font-size: 13px;
  color: var(--blue-700, #1d4ed8);
  background: var(--blue-50, #eff6ff);
  padding: 2px 10px;
  border-radius: 6px;
}
.pt-unit-topic { flex: 1; font-size: 14px; color: var(--text, #1e293b); font-weight: 500; }
.pt-unit-meta { font-size: 11px; }

.pt-rows {
  display: flex; flex-direction: column;
  border-top: 1px solid var(--border, #e2e8f0);
}
.pt-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 18px 8px 38px;
  text-decoration: none; color: inherit;
  font-size: 13px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  transition: background .15s;
}
.pt-row:last-child { border-bottom: none; }
.pt-row:hover { background: rgba(99,102,241,0.04); }
.pt-row.has-q { /* 有题命中 */ }
.pt-row.no-q  { opacity: 0.85; }
.pt-code {
  font-family: var(--ui-font-mono, monospace);
  font-size: 11px;
  background: rgba(59,130,246,0.08);
  color: var(--blue-700, #1d4ed8);
  padding: 2px 8px;
  border-radius: 6px;
  flex-shrink: 0;
  min-width: 50px;
  text-align: center;
}
.pt-text { flex: 1; color: var(--text, #1e293b); line-height: 1.5; }
.pt-cp {
  font-size: 14px;
  flex-shrink: 0;
}
.pt-nq {
  font-size: 11px;
  background: rgba(245,158,11,0.1);
  color: var(--amber-600, #d97706);
  padding: 1px 8px;
  border-radius: 9999px;
  flex-shrink: 0;
  font-weight: 600;
}
[data-theme="dark"] .pt-unit, .theme-dark .pt-unit { background: #1e293b; border-color: rgba(255,255,255,0.1); }
[data-theme="dark"] .pt-rows, .theme-dark .pt-rows { border-color: rgba(255,255,255,0.08); }
[data-theme="dark"] .pt-row, .theme-dark .pt-row { border-color: rgba(255,255,255,0.06); }

/* === cnb#145 R6 text-only 题面 + mark scheme 排版 === */
.q-text-only {
  background: var(--surface, white);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  padding: 18px 22px;
  margin-bottom: 8px;
}
.q-text-only-hint {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px;
  padding: 6px 10px;
  background: rgba(245, 158, 11, 0.06);
  border-left: 3px solid var(--amber-500, #f59e0b);
  border-radius: 6px;
  color: var(--amber-600, #d97706);
  font-size: 12px;
}
.q-text-only-h {
  font-size: 15px; font-weight: 600;
  margin: 0 0 10px;
  color: var(--text, #1e293b);
  display: flex; align-items: center; gap: 6px;
}
.q-text-only-body {
  font-size: 14px; line-height: 1.85;
  color: var(--text, #1e293b);
  white-space: pre-wrap;
  font-family: var(--ui-font-sans, system-ui);
  word-break: break-word;
}
.q-text-only-body.q-text-only-ans {
  font-size: 13px;
  color: var(--text-muted, #64748b);
  background: var(--surface-hover, #f1f5f9);
  padding: 12px 14px;
  border-radius: 8px;
  white-space: pre-wrap;
}
.q-mark-list {
  list-style: none;
  counter-reset: mp-counter;
  padding-left: 0;
  margin: 0;
}
.q-mark-list li {
  counter-increment: mp-counter;
  position: relative;
  padding: 10px 14px 10px 42px;
  margin-bottom: 8px;
  background: linear-gradient(180deg, rgba(16,185,129,0.05), rgba(16,185,129,0.02));
  border: 1px solid rgba(16,185,129,0.18);
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text, #1e293b);
}
.q-mark-list li::before {
  content: counter(mp-counter);
  position: absolute;
  left: 12px; top: 9px;
  width: 22px; height: 22px;
  background: var(--emerald-500, #10b981);
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}
[data-theme="dark"] .q-text-only, .theme-dark .q-text-only { background: #1e293b; border-color: rgba(255,255,255,0.1); }
[data-theme="dark"] .q-text-only-hint, .theme-dark .q-text-only-hint { background: rgba(245,158,11,0.1); }
[data-theme="dark"] .q-text-only-body.q-text-only-ans, .theme-dark .q-text-only-body.q-text-only-ans { background: rgba(255,255,255,0.05); }

/* cnb#16 Step D:多关联考点 panel + OCR 不可用 警告 */
.q-points-panel {
  margin-top: 14px;
  padding: 12px 14px;
  background: rgba(99, 102, 241, 0.04);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 8px;
}
.q-points-head { font-weight: 600; margin-bottom: 8px; color: var(--accent, #4f46e5); }
.q-points-list { list-style: none; padding: 0; margin: 0; }
.q-points-list li { padding: 4px 0; }
.q-points-link {
  color: var(--text, #1f2937);
  text-decoration: none;
  display: inline-block; padding: 2px 8px; border-radius: 4px;
}
.q-points-link:hover { background: rgba(99, 102, 241, 0.1); text-decoration: underline; }
.q-points-link code { background: rgba(99, 102, 241, 0.12); padding: 1px 6px; border-radius: 3px; font-size: 0.9em; }
.q-ocr-warn {
  padding: 8px 12px;
  background: rgba(245, 158, 11, 0.1);
  border-left: 3px solid #f59e0b;
  border-radius: 4px;
  font-size: 0.9em;
  color: #92400e;
  margin-bottom: 10px;
}
[data-theme="dark"] .q-points-panel, .theme-dark .q-points-panel { background: rgba(99, 102, 241, 0.08); border-color: rgba(99, 102, 241, 0.3); }
[data-theme="dark"] .q-ocr-warn, .theme-dark .q-ocr-warn { color: #fbbf24; background: rgba(245, 158, 11, 0.15); }

/* === cnb#145 Stage 4: 题详情三 AI 按钮 + R6 spec_chips === */
.q-spec-chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 14px 0;
  align-items: center;
}
.spec-chip-label {
  font-size: 11px; color: var(--text-soft, #94a3b8);
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
}
.spec-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: var(--blue-50, #eff6ff);
  border: 1px solid rgba(59,130,246,0.3);
  border-radius: 9999px;
  font-size: 14px;
  color: var(--blue-700, #1d4ed8);
  text-decoration: none;
  transition: all .15s;
  max-width: 100%;
}
.spec-chip:hover { background: rgba(59,130,246,0.18); transform: translateY(-1px); }
.spec-chip.secondary { background: var(--surface-hover, #f1f5f9); color: var(--text-muted, #64748b); border-color: var(--border, #e2e8f0); }
.spec-chip.medium { background: var(--amber-50, #fffbeb); border-color: rgba(245,158,11,0.3); color: var(--amber-600, #d97706); }
.spec-chip code {
  font-family: var(--ui-font-mono, monospace);
  font-size: 12px;
  background: rgba(255,255,255,0.5);
  padding: 1px 5px;
  border-radius: 4px;
}
.spec-chip .conf {
  font-size: 10px; padding: 1px 6px; border-radius: 9999px;
  background: rgba(16,185,129,0.15); color: var(--emerald-600, #059669);
}
.spec-chip.medium .conf { background: rgba(245,158,11,0.15); color: var(--amber-600, #d97706); }
[data-theme="dark"] .spec-chip,
.theme-dark .spec-chip { background: rgba(129,140,248,0.12); color: #a5b4fc; }
[data-theme="dark"] .spec-chip.secondary,
.theme-dark .spec-chip.secondary { background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.6); }

/* 三 AI 按钮 */
.q-ai-triple-wrap { position: relative; padding-top: 22px; }
.q-ai-triple-label {
  position: absolute; top: 0; left: 0;
  font-size: 11px; color: var(--text-muted, #64748b); font-weight: 500;
  display: inline-flex; gap: 4px;
}
.q-ai-triple {
  display: flex; gap: 12px;
  padding: 16px;
  background: var(--surface, white);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 16px;
}
/* cnb#145 Phase 7:AI 三按钮 + 错题本 改 pill 风格,平行排成一行(用户报 Q4 太大太突兀)*/
.q-action-row {
  margin-top: 14px;
  display: flex; flex-wrap: wrap;
  align-items: center; gap: 6px 8px;
  padding: 8px 0;
}
.q-action-row .q-action-label {
  font-size: 13px;
  color: var(--text-muted, #64748b);
  font-weight: 500;
}
.q-action-row .q-action-sep {
  color: var(--text-muted, #cbd5e1);
  margin: 0 4px;
}
.q-ai-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 12px;
  font-size: 13px; font-weight: 500;
  border-radius: 9999px;
  border: 1px solid rgba(99,102,241,0.22);
  background: rgba(99,102,241,0.06);
  color: var(--blue-700, #1d4ed8);
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .08s;
}
.q-ai-pill:hover {
  background: rgba(99,102,241,0.15);
  border-color: var(--blue-500, #3b82f6);
  transform: translateY(-1px);
}
.q-ai-pill:active { transform: translateY(0); }
.q-ai-pill.active {
  background: var(--blue-500, #3b82f6);
  color: white;
  border-color: var(--blue-500, #3b82f6);
}
.q-ai-pill.q-pill-mistake {
  background: rgba(239,68,68,0.06);
  border-color: rgba(239,68,68,0.25);
  color: var(--red-600, #dc2626);
}
.q-ai-pill.q-pill-mistake:hover {
  background: rgba(239,68,68,0.12);
  border-color: var(--red-500, #ef4444);
}
/* Phase-4 (#152): vision pill — distinct orange tone so students see
   it's a special "look at the figure" mode, separate from the 3 text
   pills. */
.q-ai-pill.q-pill-vision {
  background: rgba(249,115,22,0.06);
  border-color: rgba(249,115,22,0.30);
  color: #c2410c;
}
.q-ai-pill.q-pill-vision:hover {
  background: rgba(249,115,22,0.14);
  border-color: #f97316;
}
.q-ai-pill.q-pill-vision.active {
  background: #f97316; color: #fff; border-color: #f97316;
}
[data-theme="dark"] .q-ai-pill,
.theme-dark .q-ai-pill {
  background: rgba(129,140,248,0.08);
  border-color: rgba(129,140,248,0.3);
  color: #93c5fd;
}

/* ─ 旧 .q-ai-btn 保留(其他地方可能引用),但默认 tile-style 改成 hidden 不再渲染 ─ */
.q-ai-btn {
  flex: 1;
  background: linear-gradient(180deg, rgba(99,102,241,0.04), rgba(99,102,241,0.01));
  border: 1px solid rgba(99,102,241,0.18);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all .15s;
  text-align: left;
  position: relative;
}
.q-ai-btn:hover {
  border-color: var(--blue-500, #3b82f6);
  background: rgba(99,102,241,0.08);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(99,102,241,0.12);
}
.q-ai-btn .ico { font-size: 22px; display: block; margin-bottom: 4px; }
.q-ai-btn .title { font-size: 14px; font-weight: 600; color: var(--text, #1e293b); }
.q-ai-btn .sub { font-size: 11px; color: var(--text-muted, #64748b); margin-top: 4px; }
.q-ai-btn .sparkle { position: absolute; top: 10px; right: 12px; font-size: 12px; color: var(--blue-500, #3b82f6); opacity: 0.6; }
@media (max-width: 640px) {
  .q-ai-triple { flex-direction: column; padding: 12px; }
}
[data-theme="dark"] .q-ai-triple,
.theme-dark .q-ai-triple { background: #1e293b; border-color: rgba(255,255,255,0.1); }
[data-theme="dark"] .q-ai-btn,
.theme-dark .q-ai-btn { background: rgba(129,140,248,0.08); border-color: rgba(129,140,248,0.2); }

/* cnb#145 Phase 7:AI 输出区域,有内容时有明显边框,空时不占视觉 */
.ai-stream-host { margin-top: 12px; min-height: 0; transition: min-height .2s; }
.ai-stream-host:not(:empty) {
  min-height: 80px;
  border-left: 3px solid var(--blue-500, #3b82f6);
  padding: 4px 0 4px 12px;
  background: linear-gradient(90deg, rgba(99,102,241,0.04) 0%, transparent 80%);
}
.ai-similar-host { margin-top: 12px; }
.ais-similar-list {
  display: flex; flex-direction: column;
  gap: 6px;
  background: var(--surface, white);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  padding: 8px;
}
.ais-similar-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px;
  text-decoration: none; color: inherit;
  border-radius: 8px;
  font-size: 13px;
  transition: background .15s;
}
.ais-similar-item:hover { background: var(--surface-hover, #f1f5f9); }
.ais-similar-paper { font-family: var(--ui-font-mono, monospace); font-weight: 500; color: var(--blue-700, #1d4ed8); }
.ais-similar-q { color: var(--text, #1e293b); font-weight: 500; }
.ais-similar-item .pd-conf {
  margin-left: auto;
  font-size: 10px; padding: 1px 8px; border-radius: 9999px;
  background: rgba(16,185,129,0.1); color: var(--emerald-600, #059669);
}
.ais-empty {
  padding: 16px;
  text-align: center; color: var(--text-muted, #64748b);
  font-size: 13px;
  background: var(--surface-hover, #f1f5f9);
  border-radius: 8px;
  margin-top: 8px;
}

/* === cnb#145 Stage 4: AI Stream 共用组件 === */
.ais-card {
  background: linear-gradient(180deg, rgba(99,102,241,0.04), rgba(99,102,241,0.01));
  border: 1px solid rgba(99,102,241,0.18);
  border-radius: 16px;
  padding: 16px 18px;
  margin-top: 12px;
  position: relative;
}
.ais-card[data-conf="R6-medium"] { background: linear-gradient(180deg, rgba(245,158,11,0.04), rgba(245,158,11,0.01)); border-color: rgba(245,158,11,0.22); }
.ais-card[data-conf="R6-review"] { background: linear-gradient(180deg, rgba(244,63,94,0.04), rgba(244,63,94,0.01)); border-color: rgba(244,63,94,0.22); }
.ais-header {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--text-muted, #64748b);
  margin-bottom: 12px;
}
.ais-sparkle { color: var(--blue-600, #2563eb); font-size: 16px; }
.ais-card[data-conf="R6-medium"] .ais-sparkle { color: var(--amber-600, #d97706); }
.ais-card[data-conf="R6-review"] .ais-sparkle { color: var(--rose-600, #e11d48); }
.ais-title { font-weight: 500; color: var(--text, #1e293b); }
.ais-conf {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px;
  background: rgba(16,185,129,0.1); color: var(--emerald-600, #059669);
  padding: 2px 10px;
  border-radius: 9999px;
  font-weight: 500;
}
.ais-conf.warn   { background: rgba(245,158,11,0.1); color: var(--amber-600, #d97706); }
.ais-conf.review { background: rgba(244,63,94,0.1); color: var(--rose-600, #e11d48); }

/* thinking pulse */
.ais-thinking {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-soft, #94a3b8);
  font-size: 14px;
  padding: 12px 0;
}
.ais-thinking .dots { display: inline-flex; gap: 4px; }
.ais-thinking .dot {
  width: 6px; height: 6px;
  background: var(--blue-500, #3b82f6);
  border-radius: 50%;
  animation: aisPulse 1.4s infinite ease-in-out;
}
.ais-thinking .dot:nth-child(2) { animation-delay: 0.2s; }
.ais-thinking .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes aisPulse {
  0%,80%,100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.1); }
}
.ais-card[data-conf="R6-medium"] .ais-thinking .dot { background: var(--amber-500, #f59e0b); }
.ais-card[data-conf="R6-review"] .ais-thinking .dot { background: var(--rose-500, #f43f5e); }

/* answer streaming */
.ais-answer {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text, #1e293b);
  animation: aisFadeIn 300ms ease-out;
}
@keyframes aisFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
.ais-answer p { margin: 0 0 8px; }
.ais-answer ol, .ais-answer ul { margin: 8px 0; padding-left: 22px; }
.ais-answer li { margin-bottom: 4px; }
.ais-answer strong { color: var(--text, #1e293b); font-weight: 600; }
.ais-answer code {
  font-family: var(--ui-font-mono, monospace);
  background: var(--surface-hover, #f1f5f9);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 13px;
}
.ais-cursor::after {
  content: "▍";
  color: var(--blue-500, #3b82f6);
  animation: aisBlink 1s infinite;
  margin-left: 1px;
}
@keyframes aisBlink { 0%,50% { opacity: 1; } 51%,100% { opacity: 0; } }

.ais-error {
  color: var(--rose-600, #e11d48);
  font-size: 13px;
  background: var(--rose-50, #fff1f2);
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #fecdd3;
}

/* source chips */
.ais-sources {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 14px; padding-top: 12px;
  border-top: 1px dashed var(--border, #e2e8f0);
  font-size: 11px;
  color: var(--text-soft, #94a3b8);
  align-items: center;
}
.ais-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  background: var(--surface-hover, #f1f5f9);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 9999px;
  font-size: 11px;
  color: var(--text-muted, #64748b);
}
.ais-chip code {
  font-family: var(--ui-font-mono, monospace);
  color: var(--blue-600, #2563eb);
  font-size: 10px;
  background: none;
  padding: 0;
}

/* feedback bar */
.ais-feedback {
  display: flex; gap: 8px;
  margin-top: 10px;
}
.ais-feedback button {
  background: transparent;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-muted, #64748b);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.ais-feedback button:hover { background: var(--surface-hover, #f1f5f9); color: var(--text, #1e293b); }
.ais-feedback button.active { background: rgba(99,102,241,0.1); color: var(--blue-600, #2563eb); border-color: var(--blue-500, #3b82f6); }
.ais-feedback button:disabled { cursor: not-allowed; opacity: 0.7; }

[data-theme="dark"] .ais-card, .theme-dark .ais-card {
  background: linear-gradient(180deg, rgba(129,140,248,0.08), rgba(129,140,248,0.02));
  border-color: rgba(129,140,248,0.25);
}
[data-theme="dark"] .ais-card[data-conf="R6-medium"], .theme-dark .ais-card[data-conf="R6-medium"] {
  background: linear-gradient(180deg, rgba(245,158,11,0.10), rgba(245,158,11,0.02));
  border-color: rgba(245,158,11,0.3);
}
[data-theme="dark"] .ais-card[data-conf="R6-review"], .theme-dark .ais-card[data-conf="R6-review"] {
  background: linear-gradient(180deg, rgba(244,63,94,0.10), rgba(244,63,94,0.02));
  border-color: rgba(244,63,94,0.3);
}

/* === cnb#143 Stage 6.2: cmd-K palette + topbar trigger === */
.topbar-cmdk-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 10px 0 12px;
  border-radius: 10px; border: 1px solid var(--border, #e2e8f0);
  background: var(--surface-2, rgba(255,255,255,0.6));
  color: var(--text-muted, #64748b);
  font-size: 13px; cursor: pointer;
  margin: 0 8px;
  min-width: 220px; max-width: 320px;
  transition: background .15s, border-color .15s;
}
.topbar-cmdk-trigger:hover {
  background: var(--surface, white);
  border-color: rgba(99, 102, 241, 0.4);
  color: var(--text, #1e293b);
}
.cmdk-trigger-icon { font-size: 14px; }
.cmdk-trigger-text { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmdk-trigger-kbd {
  padding: 2px 6px; font-family: var(--ui-font-mono, monospace); font-size: 10px;
  background: var(--surface-hover, #f1f5f9); border: 1px solid var(--border, #e2e8f0);
  border-radius: 4px; color: var(--text-soft, #94a3b8);
}
@media (max-width: 768px) {
  .topbar-cmdk-trigger { min-width: 0; max-width: 40px; padding: 0 8px; }
  .cmdk-trigger-text, .cmdk-trigger-kbd { display: none; }
}
[data-theme="dark"] .topbar-cmdk-trigger,
.theme-dark .topbar-cmdk-trigger {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.6);
}
[data-theme="dark"] .topbar-cmdk-trigger:hover,
.theme-dark .topbar-cmdk-trigger:hover {
  background: rgba(255,255,255,0.08);
}

/* backdrop */
.cmdk-backdrop {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(15,23,42,0.55);
  backdrop-filter: blur(8px) saturate(120%);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 12vh 16px 16px;
  animation: cmdkFadeIn 200ms ease-out;
}
.cmdk-backdrop[hidden] { display: none; }
@keyframes cmdkFadeIn { from { opacity: 0; } to { opacity: 1; } }

.cmdk-modal {
  width: 100%; max-width: 640px;
  background: var(--surface, white);
  border-radius: 16px;
  box-shadow: 0 24px 64px -8px rgba(0,0,0,0.3), 0 8px 16px -4px rgba(0,0,0,0.15);
  overflow: hidden;
  animation: cmdkSlideDown 250ms cubic-bezier(0.4,0,0.2,1);
}
@keyframes cmdkSlideDown { from { opacity: 0; transform: translateY(-12px) scale(0.98); } to { opacity: 1; } }

.cmdk-input {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border, #e2e8f0);
}
.cmdk-input-ico { font-size: 18px; color: var(--text-muted); }
.cmdk-input input {
  flex: 1; border: none; outline: none; font-size: 17px;
  font-family: var(--ui-font-sans, system-ui); background: transparent;
  color: var(--text, #1e293b);
}
.cmdk-input kbd {
  padding: 3px 7px; font-family: var(--ui-font-mono, monospace); font-size: 11px;
  background: var(--surface-hover, #f1f5f9); border: 1px solid var(--border, #e2e8f0);
  border-radius: 4px; color: var(--text-soft, #94a3b8);
}
/* 触屏 close 按钮(顶部 ✕) — 桌面也可用,移动端必须 */
.cmdk-close-btn {
  width: 36px; height: 36px; min-width: 36px;
  border: none; background: transparent; cursor: pointer;
  border-radius: 8px;
  font-size: 18px; color: var(--text-muted, #64748b);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.cmdk-close-btn:hover, .cmdk-close-btn:active {
  background: var(--surface-hover, #f1f5f9);
  color: var(--text, #1e293b);
}

.cmdk-results { max-height: 60vh; overflow-y: auto; padding: 8px; }
.cmdk-group-head {
  padding: 8px 12px 4px;
  font-size: 11px; font-weight: 600; color: var(--text-soft, #94a3b8);
  text-transform: uppercase; letter-spacing: 0.05em;
  display: flex; align-items: center; gap: 8px;
}
.cmdk-group-head .count {
  padding: 1px 6px; background: var(--surface-hover, #f1f5f9); border-radius: 4px;
  font-size: 10px; color: var(--text-muted, #64748b); font-weight: 500;
}
.cmdk-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px;
  border-radius: 8px; cursor: pointer; transition: background 80ms;
  text-decoration: none; color: inherit;
  min-height: 48px;
}
.cmdk-row:hover, .cmdk-row.active {
  background: rgba(99, 102, 241, 0.08);
}
.cmdk-ico {
  width: 32px; height: 32px; flex-shrink: 0; border-radius: 6px;
  background: rgba(99, 102, 241, 0.1);
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.cmdk-row[data-kind="lesson"] .cmdk-ico { background: rgba(59, 130, 246, 0.1); }
.cmdk-row[data-kind="paper"]  .cmdk-ico { background: rgba(245, 158, 11, 0.1); }
.cmdk-row[data-kind="point"]  .cmdk-ico { background: rgba(16, 185, 129, 0.1); }
.cmdk-row[data-kind="cmd"]    .cmdk-ico { background: rgba(139, 92, 246, 0.1); }
.cmdk-body { flex: 1; min-width: 0; }
.cmdk-title {
  font-size: 14px; color: var(--text, #1e293b); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cmdk-title mark {
  background: rgba(252, 211, 77, 0.4); color: inherit; padding: 0 2px;
  border-radius: 2px; font-weight: 600;
}
.cmdk-sub {
  font-size: 11px; color: var(--text-muted, #64748b); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cmdk-shortcut {
  display: flex; gap: 4px; align-items: center;
  font-family: var(--ui-font-mono, monospace); font-size: 10px; color: var(--text-soft);
}
.cmdk-shortcut kbd {
  padding: 2px 5px; background: var(--surface-hover, #f1f5f9);
  border: 1px solid var(--border, #e2e8f0); border-radius: 3px;
}

.cmdk-foot {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: var(--surface-hover, #f8fafc); border-top: 1px solid var(--border, #e2e8f0);
  font-size: 11px; color: var(--text-muted, #64748b);
}
.cmdk-foot kbd {
  padding: 2px 5px; background: var(--surface, white); border: 1px solid var(--border, #e2e8f0);
  border-radius: 3px; font-family: var(--ui-font-mono, monospace); font-size: 10px;
}
.cmdk-legend { display: flex; align-items: center; gap: 4px; }
.cmdk-empty { padding: 32px 16px; text-align: center; color: var(--text-muted); font-size: 13px; }
/* 移动端 footer:隐藏 keyboard legend,显式 close button */
.cmdk-foot-mobile-hint { display: none; flex: 1; font-size: 12px; color: var(--text-muted); }
.cmdk-foot-close {
  display: none; padding: 8px 16px; min-height: 44px;
  border-radius: 8px;
  background: var(--brand, #6366f1); color: white;
  font-size: 14px; font-weight: 500;
  border: none; cursor: pointer;
}
.cmdk-foot-close:hover, .cmdk-foot-close:active { background: var(--brand-dark, #4f46e5); }
@media (max-width: 768px), (pointer: coarse) {
  .cmdk-legend-desktop { display: none; }
  .cmdk-foot-mobile-hint { display: block; }
  .cmdk-foot-close { display: inline-flex; align-items: center; }
  /* 顶部 ✕ 加大 touch target */
  .cmdk-close-btn { width: 44px; height: 44px; min-width: 44px; font-size: 22px; }
  /* 输入框加大 touch + 避免 iOS auto-zoom */
  .cmdk-input input { font-size: 16px; min-height: 32px; }
  .cmdk-input { padding: 14px 14px 14px 18px; gap: 10px; }
}

@media (max-width: 640px) {
  .cmdk-backdrop { align-items: flex-end; padding: 0; }
  .cmdk-modal {
    max-width: 100%; border-radius: 16px 16px 0 0;
    animation: cmdkSlideUp 300ms cubic-bezier(0.4,0,0.2,1);
  }
  @keyframes cmdkSlideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
}

[data-theme="dark"] .cmdk-modal,
.theme-dark .cmdk-modal { background: #1e293b; }
[data-theme="dark"] .cmdk-input,
.theme-dark .cmdk-input { border-bottom-color: rgba(255,255,255,0.1); }
[data-theme="dark"] .cmdk-foot,
.theme-dark .cmdk-foot { background: rgba(255,255,255,0.04); border-top-color: rgba(255,255,255,0.1); }
[data-theme="dark"] .cmdk-row:hover,
[data-theme="dark"] .cmdk-row.active,
.theme-dark .cmdk-row:hover,
.theme-dark .cmdk-row.active { background: rgba(129, 140, 248, 0.15); }

/* === cnb#143 Stage 6.3: search v2 — cmd-K hero + advanced fold === */
.srch-hero {
  display: flex; align-items: center; gap: 20px;
  margin: 8px 0 28px;
  padding: 24px;
  background: linear-gradient(135deg, rgba(99,102,241,0.06), rgba(16,185,129,0.06));
  border: 1px solid rgba(99,102,241,0.15);
  border-radius: 16px;
}
.srch-hero-emoji { font-size: 56px; flex-shrink: 0; }
.srch-hero-body { flex: 1; min-width: 0; }
.srch-hero-body h3 { margin: 0 0 6px; font-size: 17px; font-weight: 600; }
.srch-hero-body p { margin: 0 0 14px; font-size: 13px; line-height: 1.55; }
.srch-advanced { padding-top: 8px; border-top: 1px solid var(--border, #e2e8f0); }
.srch-advanced-head { margin: 16px 0 0; font-size: 14px; font-weight: 600; color: var(--text); }
[data-theme="dark"] .srch-hero,
.theme-dark .srch-hero {
  background: linear-gradient(135deg, rgba(129,140,248,0.10), rgba(110,231,183,0.08));
  border-color: rgba(129,140,248,0.25);
}
@media (max-width: 640px) {
  .srch-hero { flex-direction: column; text-align: center; gap: 12px; padding: 20px 16px; }
  .srch-hero-emoji { font-size: 40px; }
}

/* === cnb#143 通用页面返回按钮 (papers / points / question / lesson-plan / subject-home) === */
/* === subjects-catalog cap chips(教材/考点/冲刺/真题/趋势 能力可视化)=== */
.cap-chips {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 10px;
}
.cap-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 9999px;
  border: 1px solid var(--border, #e2e8f0);
}
.cap-chip.on {
  background: rgba(16,185,129,0.08);
  color: var(--emerald-600, #059669);
  border-color: rgba(16,185,129,0.3);
}
.cap-chip.soft {
  background: var(--surface-hover, #f1f5f9);
  color: var(--text-soft, #94a3b8);
  border-color: var(--border, #e2e8f0);
}
.cap-ico { font-size: 11px; }
.subject-status.r6 {
  background: rgba(99,102,241,0.1);
  color: var(--blue-700, #1d4ed8);
  border: 1px solid rgba(99,102,241,0.3);
  padding: 1px 8px;
  border-radius: 9999px;
  font-size: 10px;
}
.subject-status.partial {
  background: var(--surface-hover, #f1f5f9);
  color: var(--text-muted, #64748b);
  border: 1px solid var(--border, #e2e8f0);
  padding: 1px 8px;
  border-radius: 9999px;
  font-size: 10px;
}
/* 全 active 时去 placeholder 灰 — 全 11 学科都点亮 */
.subject-card.active { opacity: 1; }

.page-back {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 4px 8px 4px 4px;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted, #64748b);
  font-size: 13px;
  font-weight: 400;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: color .12s, background .12s;
  margin-right: 8px;
}
.page-back:hover {
  color: var(--text, #1e293b);
  background: var(--surface-hover, rgba(0,0,0,0.04));
}
.page-back:active { transform: translateX(-1px); }
.page-back .pg-back-ico {
  font-size: 18px; line-height: 1;
  margin-right: 1px;
}
[data-theme="dark"] .page-back,
.theme-dark .page-back {
  background: rgba(129, 140, 248, 0.15);
  color: #a5b4fc;
}
[data-theme="dark"] .page-back:hover,
.theme-dark .page-back:hover {
  background: rgba(129, 140, 248, 0.25);
  border-color: rgba(129, 140, 248, 0.4);
}
/* pane-head 内部排版微调 */
.pane-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pane-head .page-back { margin-right: 4px; }
/* === end page-back === */

/* cnb#16:paper-type badge(complete/selection/whole_only)*/
.paper-type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--ui-r-full);
  font-size: var(--ui-text-xs);
  font-weight: 600;
  margin-left: 8px;
}
.paper-type-badge.whole {
  background: var(--gray-100);
  color: var(--gray-700);
}
.paper-type-badge.selection {
  background: var(--amber-50);
  color: var(--amber-700);
}
.paper-item.paper-type-whole_only {
  background: linear-gradient(90deg, var(--surface) 0%, var(--gray-50) 100%);
}

/* ─── cnb#16 Stage B sprint-review 页 — 抄 reader-page 模式 ───
   fixed-height shell + 内独立 scroll columns(整页不滚,左右各自 overflow-y:auto)
   优点:左栏永不消失,无 sticky 复杂性,无 长内容撑爆 sticky 风险 */
.sr-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 80px);     /* 全屏减去 topbar */
  padding: 0;
}
.sr-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-light, var(--border));
  flex-wrap: wrap;
  flex-shrink: 0;
}
.sr-title {
  margin: 0;
  font-size: 1.1em;
  font-weight: 600;
}
.sr-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.sr-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  flex: 1;
  overflow: hidden;                /* 各 column 独立 scroll;不撑整页横滚 */
  min-height: 0;
}
.sr-left {
  background: var(--bg-soft, var(--surface));
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  overflow-y: auto;                /* 左栏自己滚 */
  font-size: 0.9em;
}
.sr-right {
  padding: 16px 24px;
  overflow-y: auto;                /* 右栏自己滚 */
  overflow-wrap: anywhere;
  word-break: break-word;
}
/* cnb#16:bullet text / 段落 长 token 强制换行,防溢出撑爆右栏 → 拉横向 scroll → sticky 左栏失效 */
.sr-bullet-text, .sr-section-expand p, .sr-section-test p,
.sr-unit-anchor p, .sr-unit-textbook p, .sr-unit-hooks p,
.sr-intro-block p, .sr-intro-block li, .sr-section-bullets li,
.sr-unit-anchor li, .sr-unit-textbook li, .sr-unit-hooks li {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.sr-unit-block, .sr-intro {
  min-width: 0;
  max-width: 100%;
}
.sr-unit-block pre, .sr-section pre, .sr-section code {
  overflow-x: auto;
  max-width: 100%;
  white-space: pre-wrap;
  word-break: break-word;
}
.sr-tree h4 {
  margin: 0 0 10px;
  font-size: 0.95em;
  color: var(--gray-700);
}
.sr-tree ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.sr-unit {
  margin-bottom: 4px;
}
.sr-unit-head {
  display: block;
  padding: 6px 8px;
  border-radius: 4px;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.92em;
}
.sr-unit-head:hover { background: var(--gray-50); }
.sr-unit.active > .sr-unit-head {
  background: var(--blue-50, #e0e7ff);
  color: var(--blue-700, #1e40af);
}
.sr-section-list {
  display: none;
  padding-left: 14px !important;
  margin: 4px 0 !important;
}
.sr-unit.active .sr-section-list { display: block; }
.sr-section-list li a {
  display: flex;
  gap: 6px;
  padding: 4px 6px;
  color: var(--gray-700);
  text-decoration: none;
  font-size: 0.86em;
  border-radius: 3px;
}
.sr-section-list li a:hover { background: var(--gray-50); }
.sr-sec-id {
  flex-shrink: 0;
  color: var(--gray-500);
  font-variant-numeric: tabular-nums;
  min-width: 32px;
}
.sr-sec-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sr-read-mark { color: var(--emerald-600, #059669); flex-shrink: 0; }

.sr-right {
  min-width: 0;
}
.sr-intro {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 20px;
}
.sr-intro-block + .sr-intro-block { margin-top: 14px; }
.sr-intro-block h4 {
  margin: 0 0 8px;
  font-size: 1em;
  color: var(--blue-700, #1e40af);
}

.sr-unit-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 16px;
}
.sr-unit-heading {
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--blue-200, #bfdbfe);
  font-size: 1.15em;
  color: var(--blue-800, #1e3a8a);
}
.sr-unit-preface-note {
  margin: 8px 0 14px;
  padding: 8px 12px;
  background: var(--amber-50, #fef3c7);
  border-left: 3px solid var(--amber-400, #fbbf24);
  border-radius: 4px;
  font-size: 0.88em;
  color: var(--gray-700);
  line-height: 1.55;
}
.sr-unit-anchor, .sr-unit-textbook, .sr-unit-hooks {
  margin: 10px 0;
  padding: 10px 14px;
  background: var(--gray-50);
  border-left: 3px solid var(--blue-400, #60a5fa);
  border-radius: 4px;
}
.sr-unit-anchor h5, .sr-unit-textbook h5, .sr-unit-hooks h5 {
  margin: 0 0 6px;
  font-size: 0.9em;
  color: var(--gray-700);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.sr-unit-anchor p, .sr-unit-textbook p, .sr-unit-hooks p,
.sr-section-expand p, .sr-section-test p {
  margin: 4px 0;
  line-height: 1.6;
}
.sr-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed var(--gray-200);
}
.sr-section-title {
  margin: 0 0 10px;
  font-size: 1em;
  color: var(--gray-800);
}
.sr-section-id {
  display: inline-block;
  min-width: 40px;
  margin-right: 6px;
  padding: 1px 6px;
  background: var(--blue-100, #dbeafe);
  color: var(--blue-700, #1e40af);
  border-radius: 3px;
  font-variant-numeric: tabular-nums;
  font-size: 0.85em;
}
.sr-section-expand, .sr-section-test {
  margin: 8px 0;
  padding: 8px 12px;
  background: var(--amber-50, #fef3c7);
  border-radius: 4px;
}
.sr-section-test { background: var(--emerald-50, #d1fae5); }
.sr-section-expand h5, .sr-section-test h5 {
  margin: 0 0 4px;
  font-size: 0.85em;
  color: var(--gray-700);
}
.sr-section-bullets h5 {
  margin: 12px 0 6px;
  font-size: 0.85em;
  color: var(--gray-600);
  text-transform: uppercase;
}
.sr-bullet-list {
  padding-left: 24px;
  margin: 0;
}
.sr-bullet {
  margin: 6px 0;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.sr-bullet-id {
  flex-shrink: 0;
  min-width: 24px;
  color: var(--gray-500);
  font-variant-numeric: tabular-nums;
}
.sr-bullet-text { flex: 1; line-height: 1.5; }
.sr-bullet-actions {
  flex-shrink: 0;
  display: flex;
  gap: 4px;
}
.sr-bullet-actions button {
  padding: 2px 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 3px;
  cursor: pointer;
  opacity: 0.5;
}
.sr-bullet-actions button:not(:disabled) { opacity: 1; cursor: pointer; }
.sr-bullet-actions button:not(:disabled):hover { background: var(--gray-50); }

@media (max-width: 900px) {
  .sr-layout { grid-template-columns: 1fr; }
  .sr-left {
    position: relative;
    top: 0;
    max-height: 240px;
  }
}

/* ─── cnb#16 Stage C — lesson-plan 学科卡 sprint chip ─── */
.lp-subject-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 8px;
}
.lp-subject-row .lp-subject {
  flex: 1;
  min-width: 0;
}
.lp-subject-sprint {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 12px;
  background: var(--blue-50, #e0e7ff);
  color: var(--blue-700, #1e40af);
  border: 1px solid var(--blue-200, #bfdbfe);
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.85em;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s;
}
.lp-subject-sprint:hover {
  background: var(--blue-100, #dbeafe);
}
.lp-sprint-icon { font-size: 1.1em; }
.lp-sprint-arrow { opacity: 0.7; }
.lp-subject-disabled .lp-subject-sprint { display: none; }
@media (max-width: 600px) {
  .lp-subject-row { flex-direction: column; }
  .lp-subject-sprint { padding: 6px 12px; justify-content: center; }
}

/* ─── ai-explore page (2026-05-20 naotu 5 学科知识图谱) ─── */
.ae-page { padding: 16px 20px; }
.ae-hint { margin: 10px 0 20px; font-size: 13px; }
.ae-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.ae-card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 24px 16px;
  background: var(--surface, #fff);
  border: 1px solid var(--border-light, #e5e7eb);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text, inherit);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.ae-card:hover {
  transform: translateY(-3px);
  border-color: #7df9ff;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
}
.ae-card-emoji { font-size: 42px; line-height: 1; }
.ae-card-name { font-size: 18px; font-weight: 700; margin-top: 6px; }
.ae-card-desc { font-size: 12px; color: var(--text-secondary, #475569); line-height: 1.5; }
.ae-card-meta { font-size: 11px; font-family: ui-monospace, Menlo, monospace; margin-top: 4px; }

.ae-iframe-wrap {
  display: flex; flex-direction: column;
  height: calc(100vh - 60px);
  margin: -10px 0 0;
}
/* 2026-05-20: full-bleed iframe mode — 干掉外层 nav bar 给 iframe 留全空间.
   floating fab 浮在左上,不影响 iframe 内 nav. */
.ae-iframe-wrap-fullbleed {
  position: relative;
  height: calc(100vh - 20px);
  margin: -10px 0 0;
}
.ae-iframe-fab {
  position: absolute;
  /* 放右下角 — 避开 iframe 内部 banner(top)+ 内容(center) */
  bottom: 18px; right: 18px;
  display: flex; align-items: center; gap: 8px;
  z-index: 10;
  pointer-events: none;
  opacity: 0.42;
  transition: opacity .2s ease;
}
.ae-iframe-fab:hover { opacity: 1; }
.ae-iframe-fab > * { pointer-events: auto; }
.ae-fab-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.96);
  color: #0e1218;
  text-decoration: none;
  font-size: 18px; font-weight: 700;
  border: 1px solid rgba(15, 18, 24, 0.18);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(6px);
  transition: background .15s, transform .15s, box-shadow .15s;
}
.ae-fab-btn:hover {
  background: #fff;
  transform: scale(1.08);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.32);
}
.ae-fab-btn-sm { width: 30px; height: 30px; font-size: 14px; }
.ae-fab-chip {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  border-radius: 14px;
  background: linear-gradient(90deg,#fde68a,#fb923c);
  color: #1f2937;
  text-decoration: none;
  font-size: 12px; font-weight: 600;
}
.ae-fab-chip:hover { filter: brightness(1.05); }
.ae-iframe {
  flex: 1;
  width: 100%; height: 100%;
  border: 0;
  background: #0e1218;
}
.ae-card-wrap { position: relative; display: flex; flex-direction: column; }
.ae-card-wrap .ae-card { flex: 1; }
.ae-card-extra {
  display: block;
  margin-top: 8px;
  padding: 8px 12px;
  text-align: center;
  font-size: 12px; font-weight: 600;
  text-decoration: none;
  background: linear-gradient(90deg, #fde68a, #fb923c);
  color: #1f2937;
  border-radius: 8px;
  transition: filter .15s ease;
}
.ae-card-extra:hover { filter: brightness(1.07); }
