/* ahaslope-main.css
 * AhaSlope 主样式表
 * 包含：设计系统 tokens、组件样式、响应式布局
 * 修改时同步更新 Vercel 部署
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 */

/* ════════════════════════════════════════════════════════════════
   DESIGN SYSTEM — MiniMax-inspired (Light)
   Clean white base · Black flat buttons · Generous whitespace
   ════════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── Core Palette (clean light) ───────────────────────────── */
  --bg:           #FFFFFF;
  --bg-2:         #FAFAFA;
  --bg-3:         #F4F4F3;
  --surface:      #FFFFFF;
  --surface-2:    #F7F7F6;
  --surface-3:    #EFEFEE;

  --border:       #ECECEA;
  --border-s:     #DDDDDB;

  /* ── Ink (near-black, MiniMax style) ─────────────────────── */
  --ink:          #1A1A1A;
  --ink-soft:     #2C2C2C;

  /* ── Accent ──────────────────────────────────────────────── */
  --pri:          #2B8FD9;
  --pri-hover:    #1F7CC2;
  --pri-light:    #E4F2FC;
  --pri-glow:     rgba(43,143,217,.18);

  /* ── Semantic ─────────────────────────────────────────────── */
  --amber:        #C2740A;
  --amber-light:  #FBF3E4;
  --green:        #0A8754;
  --green-light:  #E8F6EF;
  --red:          #D6453D;

  /* ── Text ─────────────────────────────────────────────────── */
  --text-1:       #1A1A1A;
  --text-2:       #6B6B68;
  --text-3:       #9C9C98;

  /* ── Shadow (soft, light) ─────────────────────────────────── */
  --sh-xs: 0 1px 2px rgba(0,0,0,.04);
  --sh-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --sh-md: 0 6px 24px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.04);
  --sh-lg: 0 20px 48px rgba(0,0,0,.12), 0 6px 16px rgba(0,0,0,.06);

  /* ── Type ─────────────────────────────────────────────────── */
  --font: 'Inter', -apple-system, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --text-11: 11px;  --text-12: 12px;  --text-13: 13px;
  --text-14: 14px;  --text-15: 15px;  --text-16: 16px;
  --text-18: 18px;  --text-20: 20px;  --text-24: 24px;
  --text-32: 32px;  --text-40: 40px;

  /* ── Radius ──────────────────────────────────────────────── */
  --r-sm:  8px;
  --r-md:  12px;
  --r-lg:  16px;
  --r-xl:  20px;
  --r-2xl: 28px;
  --r-full: 999px;

  /* ── Layout ───────────────────────────────────────────────── */
  --sidebar-w: 272px;
  --max-w: 1440px;
  --min-w: 1280px;

  /* ── Spacing tokens ───────────────────────────────────────── */
  --sp-xs:  4px;
  --sp-sm:  8px;
  --sp-md:  16px;
  --sp-lg:  24px;
  --sp-xl:  40px;
  --sp-2xl: 56px;

  font-family: var(--font);
  font-size: var(--text-14);
  color: var(--text-1);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -.01em;
}

/* body 不锁 min-width，让首页和登录页可以完全响应式 */
html, body { height: 100%; background: var(--bg-2); }
body:has(#auth-screen) { overflow: hidden; }

/* ════ APP SHELL ════════════════════════════════════════════════ */
/* .app 只用于 learn/dashboard，才需要 min-width 保护三栏布局 */
.app {
  display: flex; height: 100vh;
  width: 100%; min-width: var(--min-w);
  overflow: hidden;
  background: var(--bg);
}
/* 首页和生成页：解除 min-width，允许真正响应式 */
.app.view-home, .app.view-generating {
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  flex-direction: column;
}
.app.view-home .main,
.app.view-generating .main {
  min-width: 0;
  overflow: visible;
  height: auto;
}

/* ════ SIDEBAR ══════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-2);
  border-right: none;
  display: flex; flex-direction: column;
  flex-shrink: 0; overflow: hidden;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 11px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}
.logo-icon {
  width: 28px; height: 28px;
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-icon svg { width: 22px; height: 22px; }
.logo-text { font-size: 15px; font-weight: 700; letter-spacing: -.4px; color: var(--text-1); }
.logo-sub  { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.sidebar-scroll {
  flex: 1; overflow-y: auto; padding: 12px 10px;
  scrollbar-width: none;          /* Firefox: 隐藏 */
}
.sidebar-scroll::-webkit-scrollbar { width: 0; background: transparent; }
.sidebar-scroll:hover { scrollbar-width: thin; scrollbar-color: rgba(0,0,0,.15) transparent; }
.sidebar-scroll:hover::-webkit-scrollbar { width: 3px; }
.sidebar-scroll:hover::-webkit-scrollbar-track { background: transparent; }
.sidebar-scroll:hover::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 4px; }

.sb-label {
  font-size: 10px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .9px;
  padding: 10px 10px 6px;
}

/* Course items */
.sb-course {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--r-md);
  cursor: pointer; user-select: none; transition: all .15s;
  margin-bottom: 2px; border: 1px solid transparent;
}
.sb-course:hover { background: var(--surface-2); }
.sb-course.active {
  background: var(--surface-2);
  border-color: var(--border);
}
.sb-course-dot {
  width: 7px; height: 7px; border-radius: 50%;
  flex-shrink: 0;
}
.sb-course-info { flex: 1; min-width: 0; }
.sb-course-name {
  font-size: var(--text-13); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text-2); line-height: 1.35;
}
.sb-course.active .sb-course-name { color: var(--text-1); font-weight: 600; }
.sb-course-meta { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* Sub-nav */
.sb-subnav { padding: 2px 0 4px 18px; }
.sb-subnav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: var(--r-sm);
  cursor: pointer; font-size: var(--text-13); color: var(--text-3);
  transition: all .12s; user-select: none; margin-bottom: 1px;
  border-left: 2px solid transparent;
}
.sb-subnav-item:hover { background: var(--surface-2); color: var(--text-1); }
.sb-subnav-item.active {
  color: var(--ink); font-weight: 600;
  border-left-color: var(--ink);
  background: var(--surface-2);
}
.sb-subnav-icon { font-size: 13px; width: 16px; text-align: center; flex-shrink: 0; }

.sb-divider { height: 1px; background: var(--border); margin: 8px 6px; }

.sb-nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: var(--r-md);
  cursor: pointer; font-size: var(--text-13); font-weight: 500;
  color: var(--text-2); transition: all .12s; user-select: none;
  margin-bottom: 2px;
}
.sb-nav-item:hover { background: var(--surface-2); color: var(--text-1); }
.sb-nav-item.active { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.sb-nav-icon { font-size: 14px; width: 16px; text-align: center; flex-shrink: 0; }

/* Sidebar footer */
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.sb-stats { display: flex; gap: 6px; margin-bottom: 12px; }
.sb-stat {
  flex: 1; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 8px 4px; text-align: center;
}
.sb-stat-v { font-size: 14px; font-weight: 700; line-height: 1; color: var(--text-1); }
.sb-stat-l { font-size: 10px; color: var(--text-3); margin-top: 3px; }
.sb-provider {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;
}
.sb-provider-badge {
  font-size: 11px; font-weight: 600; cursor: pointer;
  border-radius: var(--r-full); padding: 3px 10px;
  transition: opacity .12s; border: 1px solid var(--border);
}
.sb-provider-badge:hover { opacity: .8; }
.prog-label { font-size: 11px; color: var(--text-3); margin-bottom: 6px; }
.prog-bar { height: 3px; background: var(--surface-3); border-radius: 2px; overflow: hidden; }
.prog-fill { height: 100%; background: var(--ink); border-radius: 2px; transition: width .5s; }

/* ════ MAIN ══════════════════════════════════════════════════════ */
.main { flex: 1; overflow: auto; background: var(--bg); display: flex; flex-direction: column; min-width: 0; }

/* ════ PRIMITIVES ════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--sh-xs);
}

.badge {
  display: inline-flex; align-items: center;
  border-radius: var(--r-full); padding: 3px 10px;
  font-size: 11px; font-weight: 600; letter-spacing: .1px;
}
.badge-pri   { background: var(--pri-light); color: var(--pri); border: 1px solid rgba(43,143,217,.25); }
.badge-aha   { background: var(--amber-light); color: var(--amber); border: 1px solid rgba(194,116,10,.2); }
.badge-gr    { background: var(--green-light); color: var(--green); border: 1px solid rgba(10,135,84,.2); }
.badge-gray  { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }

/* ── Buttons (MiniMax: black flat primary, ghost secondary) ───── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: none; border-radius: var(--r-full);
  padding: 10px 22px; font-size: var(--text-14); font-weight: 600;
  font-family: var(--font); cursor: pointer; transition: all .15s;
  line-height: 1.3; letter-spacing: -.01em; white-space: nowrap;
}
/* Primary: black flat + large radius */
.btn-pri {
  background: var(--ink); color: #FFFFFF;
  box-shadow: none;
}
.btn-pri:hover { background: #000000; transform: translateY(-1px); box-shadow: var(--sh-sm); }

/* CTA: same black flat (all primary buttons are black) */
.btn-cta {
  background: var(--ink); color: #FFFFFF;
  box-shadow: none;
}
.btn-cta:hover { background: #000000; transform: translateY(-1px); box-shadow: var(--sh-md); }

/* Ghost / secondary: outlined */
.btn-sec {
  background: transparent; color: var(--ink);
  border: 1.5px solid var(--border-s);
}
.btn-sec:hover { border-color: var(--ink); background: var(--surface-2); }

.btn-ghost { background: transparent; color: var(--text-2); border: none; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text-1); }
.btn:disabled { opacity: .35; cursor: default; pointer-events: none; }

/* ── Concept rows ─────────────────────────────────────────────── */
.concept-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--surface);
  border-radius: var(--r-lg); border: 1px solid var(--border);
  cursor: pointer; margin-bottom: 8px; transition: all .15s;
}
.concept-row:hover { border-color: var(--border-s); box-shadow: var(--sh-sm); transform: translateX(2px); }
.concept-row.locked { opacity: .4; cursor: default; }
.concept-icon { width: 32px; height: 32px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }

/* ════ HOME ══════════════════════════════════════════════════════ */
.home-topbar {
  max-width: var(--max-w); margin: 0 auto; width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 40px; box-sizing: border-box;
}
.home-brand { display: flex; align-items: center; gap: 9px; }
.home-brand-name { font-size: 19px; font-weight: 700; letter-spacing: -.3px; color: var(--ink); font-family: Georgia, 'Times New Roman', serif; }
.home-wrap {
  max-width: 1440px; margin: 0 auto;
  padding: 56px 48px 52px;
  width: 100%;
  box-sizing: border-box;
  animation: fadeUp .35s ease;
}
/* hero 内容区单独限宽，居中对齐 */
.home-hero {
  text-align: center; margin-bottom: 48px;
  max-width: 900px; width: 100%;
  margin-left: auto; margin-right: auto;
}
.home-input-wrap {
  max-width: 900px; width: 100%;
  margin: 0 auto 16px;
}
.chips-wrap {
  max-width: 900px; width: 100%;
  margin: 0 auto 8px;
}
.home-eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-full); padding: 6px 16px; margin-bottom: 24px;
  font-size: var(--text-13); font-weight: 600; color: var(--text-2);
}
.home-title {
  font-size: clamp(38px, 5vw, 54px); font-weight: 700;
  letter-spacing: -1px; line-height: 1.08;
  color: var(--ink); margin-bottom: 18px;
}
.home-title span { color: var(--pri); }
.home-sub {
  font-size: var(--text-16); color: var(--text-2);
  line-height: 1.75; max-width: 560px; margin: 0 auto;
}

/* Input bar */
.input-bar {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1.5px solid var(--border-s);
  border-radius: var(--r-2xl); padding: 14px 18px;
  box-shadow: var(--sh-sm); margin-bottom: 16px;
  transition: border .15s, box-shadow .15s;
}
.input-bar:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(0,0,0,.05), var(--sh-sm);
}
.input-icon { color: var(--text-3); flex-shrink: 0; }

/* 附件 + 按钮 */
.attach-btn {
  width: 30px; height: 30px; border-radius: 50%;
  border: none; background: transparent;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: background .15s; user-select: none;
}
.attach-btn:hover { background: var(--surface-2); }
.attach-btn.active { background: var(--surface-2); }

/* 来源预览标签 */
.source-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 8px; border-radius: var(--r-full);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12px; color: var(--text-2); margin-bottom: 10px;
  animation: fadeUp .2s ease;
}
.source-chip-icon { font-size: 14px; }
.source-chip-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.source-chip-remove { cursor: pointer; color: var(--text-3); font-size: 13px; padding: 0 2px; border-radius: 3px; }
.source-chip-remove:hover { color: var(--red); background: var(--surface-3); }

/* 附件菜单 */
.attach-menu {
  position: absolute; top: calc(100% + 8px); left: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-md);
  width: 220px; z-index: 100; overflow: hidden;
  animation: fadeUp .15s ease;
}
.attach-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; cursor: pointer; font-size: 13.5px;
  color: var(--text-1); transition: background .1s;
}
.attach-menu-item:hover { background: var(--surface-2); }
.attach-menu-item-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.attach-menu-item-sub { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.home-input {
  flex: 1; border: none; background: transparent; outline: none;
  font-size: var(--text-16); font-family: var(--font); color: var(--text-1);
}
.home-input::placeholder { color: var(--text-3); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 8px; }
.chip {
  background: var(--surface); border: 1px solid var(--border-s);
  border-radius: var(--r-full); padding: 7px 16px;
  font-size: var(--text-13); color: var(--text-2);
  cursor: pointer; user-select: none; transition: all .15s;
}
.chip:hover { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Protocol warning */
.proto-warn {
  background: var(--amber-light);
  border: 1px solid rgba(194,116,10,.2);
  border-left: 3px solid var(--amber);
  border-radius: var(--r-md); padding: 14px 18px; margin-bottom: 24px; text-align: left;
}

/* ── Recent courses grid ─────────────────────────────────────── */
.recent-label {
  font-size: var(--text-16); font-weight: 700; color: var(--text-1);
  margin-bottom: 16px; padding-top: 40px;
  border-top: 1px solid var(--border);
}
.courses-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; padding: 4px; }

/* Course card with abstract gradient pattern */
.course-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); overflow: hidden;
  cursor: pointer; transition: all .2s;
  box-shadow: none; position: relative;
}
.course-card:hover { box-shadow: var(--sh-md); border-color: var(--border-s); transform: translateY(-2px); }
.course-card-header {
  height: 116px; position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.course-card-mark {
  width: 56px; height: 56px; border-radius: var(--r-lg);
  background: rgba(255,255,255,.55);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.course-card-body { padding: 18px 20px 20px; }
.cc-subject { font-size: var(--text-15); font-weight: 700; margin-bottom: 5px; color: var(--text-1); line-height: 1.3; }
.cc-desc { font-size: var(--text-13); color: var(--text-2); line-height: 1.5; margin-bottom: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cc-footer { display: flex; align-items: center; justify-content: space-between; }
.cc-prog-wrap { flex: 1; margin-right: 10px; }
.cc-prog-bar { height: 3px; background: var(--surface-3); border-radius: 2px; overflow: hidden; }
.cc-prog-fill { height: 100%; background: var(--ink); border-radius: 2px; }
.cc-pct { font-size: 11px; color: var(--text-3); white-space: nowrap; font-weight: 600; }
.cc-aha { font-size: 11px; color: var(--amber); font-weight: 600; margin-top: 6px; }

/* Features row */
.features-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 40px; }
.feature-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: 24px;
  transition: border .15s;
}
.feature-card:hover { border-color: var(--border-s); }
.feature-icon {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.feature-icon svg { width: 40px; height: 40px; }
.feature-title { font-size: var(--text-15); font-weight: 700; margin-bottom: 7px; color: var(--text-1); }
.feature-desc { font-size: var(--text-13); color: var(--text-2); line-height: 1.65; }

/* ════ GENERATING ════════════════════════════════════════════════ */
.gen-wrap { max-width: 520px; margin: 80px auto 0; padding: 0 32px; animation: fadeUp .3s ease; }
.gen-step {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; font-size: var(--text-14); color: var(--text-3);
  line-height: 1.5; border-bottom: 1px solid var(--border);
}
.gen-step:last-child { border-bottom: none; }
.gen-step.done  { color: var(--green); }
.gen-step.active{ color: var(--text-1); font-weight: 500; }
.sd { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.sd.done   { background: var(--green); }
.sd.active { background: var(--ink); animation: pulse 1s infinite; }
.sd.wait   { background: var(--surface-3); }

/* ════ DASHBOARD ════════════════════════════════════════════════ */
.dash-wrap { padding: 0 40px 36px; max-width: 1080px; margin: 0 auto; width: 100%; }
.dash-header { margin-bottom: 24px; padding-top: 4px; }
.dash-title { font-size: var(--text-24); font-weight: 700; letter-spacing: -.5px; margin-bottom: 6px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; color: var(--text-1); }
.dash-desc { font-size: var(--text-15); color: var(--text-2); line-height: 1.6; margin-bottom: 20px; }
/* 内联编辑：空值时显示 placeholder */
.dash-desc[data-empty="1"]::before,
.dash-desc:empty::before {
  content: attr(data-placeholder);
  color: var(--text-3);
  pointer-events: none;
}
/* 编辑提示光标 */
[contenteditable="true"]:hover { cursor: text; }
[contenteditable="true"]:focus { cursor: text; }

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.metric-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: 20px; box-shadow: var(--sh-xs);
  display: flex; gap: 16px; align-items: center;
}
.metric-icon {
  width: 44px; height: 44px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.metric-icon svg { width: 22px; height: 22px; }
.metric-val { font-size: 22px; font-weight: 800; line-height: 1; }
.metric-sub { font-size: var(--text-12); color: var(--text-3); margin-top: 3px; }

.dash-grid { display: grid; grid-template-columns: 1fr 340px; gap: 20px; }

/* ════ LEARN ════════════════════════════════════════════════════ */
.learn-layout { display: flex; height: 100%; overflow: hidden; }
.lesson-area { flex: 1; padding: 36px 40px; overflow-y: auto; }
.lesson-inner { max-width: 640px; }

.insight-box {
  background: var(--amber-light);
  border: 1px solid rgba(194,116,10,.18);
  border-left: 3px solid var(--amber);
  border-radius: var(--r-md); padding: 16px 18px; margin-bottom: 18px;
}
.insight-label { font-size: 10px; font-weight: 700; color: var(--amber); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .6px; }
.insight-text  { font-size: var(--text-15); color: var(--text-2); line-height: 1.85; }

.project-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--ink);
  border-radius: var(--r-md); padding: 16px 18px;
}
.project-label { font-size: 10px; font-weight: 700; color: var(--ink); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .6px; }
.project-text  { font-size: var(--text-15); color: var(--text-2); line-height: 1.75; margin-bottom: 14px; }

.code-preview { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; margin-bottom: 18px; box-shadow: var(--sh-xs); }
.code-preview-bar { display: flex; align-items: center; gap: 6px; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.traffic-dot { width: 10px; height: 10px; border-radius: 50%; }
.code-preview-body { padding: 14px 18px; overflow-y: auto; overflow-x: auto; max-height: 92px; }
pre.code-block { font-family: var(--mono); font-size: 13px; line-height: 1.75; white-space: pre; }

/* ── Chat panel ─────────────────────────────────────────────── */
.chat-panel {
  width: var(--chat-w, 360px);
  min-width: 360px;
  max-width: 600px;
  background: var(--bg-2);
  border-left: none;
  display: flex; flex-direction: column;
  flex-shrink: 0;
  position: relative;
}
.chat-panel::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  cursor: col-resize; z-index: 10;
  background: var(--border);
  transition: background .12s;
}
.chat-panel:hover::before { background: var(--border-s); }
.chat-panel.chat-resizing::before { background: var(--pri); opacity: .6; }
#sandbox-chat { height: 100%; }
#sandbox-chat .chat-panel { height: 100%; border-left: none; }
.chat-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; background: var(--surface); }
.chat-body { flex: 1; padding: 16px; overflow-y: auto; }
.chat-body::-webkit-scrollbar { width: 0; background: transparent; }
.chat-body:hover { scrollbar-width: thin; scrollbar-color: rgba(0,0,0,.12) transparent; }
.chat-body:hover::-webkit-scrollbar { width: 3px; }
.chat-body:hover::-webkit-scrollbar-thumb { background: rgba(0,0,0,.12); border-radius: 4px; }
.msg { margin-bottom: 14px; }
.msg-u { display: flex; justify-content: flex-end; }
.msg-a { display: flex; gap: 10px; align-items: flex-start; }
.bub-u { background: var(--ink); border-radius: 18px 18px 4px 18px; padding: 11px 15px; font-size: var(--text-13); line-height: 1.7; max-width: 80%; color: #fff; }
.bub-a { background: var(--surface); border: 1px solid var(--border); border-radius: 18px 18px 18px 4px; padding: 11px 15px; font-size: var(--text-13); line-height: 1.7; max-width: 80%; color: var(--text-1); box-shadow: var(--sh-xs); }
.ai-av { width: 30px; height: 30px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 2px; }
.ai-av svg { width: 15px; height: 15px; }
.chat-foot { padding: 14px 16px; border-top: 1px solid var(--border); background: var(--surface); }
.hint-bar { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.hint { font-size: 11px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-full); padding: 4px 11px; color: var(--text-2); cursor: pointer; transition: all .12s; user-select: none; }
.hint:hover { border-color: var(--ink); color: var(--ink); }
.chat-row { display: flex; gap: 8px; align-items: flex-end; }
.chat-ta {
  flex: 1; background: var(--surface); border: 1.5px solid var(--border-s);
  border-radius: var(--r-lg); padding: 10px 13px;
  font-size: var(--text-13); font-family: var(--font);
  resize: none; outline: none; line-height: 1.65;
  min-height: 76px; max-height: 200px; overflow-y: auto;
  transition: border .12s; color: var(--text-1);
}
.chat-ta:focus { border-color: var(--ink); box-shadow: 0 0 0 2px rgba(0,0,0,.04); }
.chat-send { align-self: flex-end; height: 40px; padding: 0 16px; flex-shrink: 0; border-radius: var(--r-full) !important; }

/* ════ PRACTICE ═════════════════════════════════════════════════ */
.practice-layout { display: flex; height: 100%; overflow: hidden; }
.task-col { width: 260px; background: var(--bg-2); border-right: 1px solid var(--border); padding: 20px; overflow-y: auto; flex-shrink: 0; }
.editor-wrap { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.editor-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.code-editor { flex: 1; background: var(--bg-2); border: none; color: var(--text-1); font-size: 13.5px; line-height: 1.75; padding: 18px 20px; resize: none; outline: none; font-family: var(--mono); min-height: 0; tab-size: 4; }
.text-editor { flex: 1; background: var(--surface); border: none; font-size: var(--text-15); line-height: 1.85; padding: 28px 32px; resize: none; outline: none; font-family: var(--font); min-height: 0; color: var(--text-1); }
.terminal { height: 200px; background: var(--bg-2); border-top: 1px solid var(--border); display: flex; flex-direction: column; }
.term-bar { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.term-out { flex: 1; margin: 0; padding: 12px 18px; font-size: 13px; color: var(--green); line-height: 1.7; overflow-y: auto; font-family: var(--mono); white-space: pre-wrap; word-break: break-word; }
.term-out.idle { color: var(--text-3); }
.term-out.err  { color: var(--red); }

/* Lang selector */
/* ── Interactive Explorer ── */
.interactive-frame { width: 100%; border: none; border-radius: var(--r-md); background: #fff; display: block; }
.interactive-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; margin-bottom: 16px; box-shadow: var(--sh-xs); }
.interactive-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.ix-feedback { background: var(--pri-light); border: 1px solid rgba(43,143,217,.2); border-left: 3px solid var(--pri); border-radius: var(--r-md); padding: 14px 18px; margin: 0 0 14px; font-size: var(--text-13); line-height: 1.75; color: var(--text-1); }
.ix-feedback-label { font-size: 10.5px; font-weight: 700; color: var(--pri); margin-bottom: 5px; display: flex; align-items: center; gap: 5px; }

/* ════ COVER IMAGE ═══════════════════════════════════════════ */
.cover-wrap {
  position: relative; width: 100%; height: 220px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  overflow: hidden; margin-bottom: 28px;
  background: var(--surface-2); cursor: default;
}
.cover-overlay {
  position: absolute; inset: 0; pointer-events: none;
}
.cover-overlay button,
.cover-overlay a { pointer-events: auto; }
.cover-empty {
  width: 100%; height: 56px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: linear-gradient(135deg, var(--pri-light), var(--surface-2));
  display: flex; align-items: center; justify-content: flex-end;
  padding: 0 16px; margin-bottom: 20px;
}
.ix-feedback-label { font-size: 10.5px; font-weight: 700; color: var(--pri); margin-bottom: 5px; display: flex; align-items: center; gap: 5px; }

/* ════ TEACHING STATE CLASSES ════════════════════════════════ */
/* 教学状态语义 class — 全局复用，不用内联 color */
.state-mastered  { color: var(--green); }
.state-inprogress{ color: var(--pri); }
.state-aha       { color: var(--amber); }
.state-locked    { color: var(--text-3); }

/* ════ LESSON CONTENT BLOCKS ═════════════════════════════════ */
/* 三层表达 + 顿悟 + 为什么 的统一区块样式，替代 renderLearn 里的内联样式 */

/* 直觉层 — 温暖琥珀色，直觉感知 */
.lesson-block {
  border-radius: var(--r-md);
  padding: var(--sp-md) 18px;
  margin-bottom: var(--sp-md);
  border-left: 3px solid transparent;
}
.lesson-block--label {
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px;
  margin-bottom: var(--sp-sm);
}
.lesson-block--text {
  font-size: 14.5px; line-height: 1.85;
}

/* 直觉层 */
.lesson-block--intuition {
  background: var(--amber-light);
  border-color: var(--amber);
  border: 1px solid rgba(194,116,10,.18);
  border-left: 3px solid var(--amber);
}
.lesson-block--intuition .lesson-block--label { color: var(--amber); }
.lesson-block--intuition .lesson-block--text  { color: #5c5c6e; }

/* 机制层 */
.lesson-block--mechanism {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--ink);
}
.lesson-block--mechanism .lesson-block--label { color: var(--ink); }
.lesson-block--mechanism .lesson-block--text  { color: var(--text-2); font-size: 14px; }

/* 为什么需要它 */
.lesson-block--why {
  background: var(--amber-light);
  border-left: 3px solid var(--amber);
}
.lesson-block--why .lesson-block--label { color: var(--amber); }
.lesson-block--why .lesson-block--text  { color: var(--text-2); font-size: 13.5px; }

/* 顿悟问题 */
.lesson-block--aha {
  background: linear-gradient(135deg, var(--amber-light) 0%, var(--pri-light) 100%);
  border: 1px solid rgba(43,143,217,.15);
  border-left: 3px solid var(--pri);
}
.lesson-block--aha .lesson-block--label { color: var(--pri); }
.lesson-block--aha .lesson-block--text  { color: var(--text-1); font-size: var(--text-15); font-weight: 500; line-height: 1.7; }

/* 动手构建 */
.lesson-block--build {
  background: var(--pri-light);
  border: 1px solid rgba(43,143,217,.2);
  border-left: 3px solid var(--pri);
}
.lesson-block--build .lesson-block--label { color: var(--pri); }
.lesson-block--build .lesson-block--text  { color: var(--text-2); }

/* 构建步骤列表 */
.build-steps { margin: var(--sp-sm) 0 var(--sp-md); }
.build-step  { display: flex; gap: 10px; align-items: flex-start; margin-bottom: var(--sp-sm); }
.build-step-num {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--pri); color: #fff;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
}
.build-step-text { font-size: 13.5px; color: var(--text-2); line-height: 1.6; }

/* ════ FINAL PROJECT BANNER ══════════════════════════════════ */
/* 终点作品牵引 banner — Dashboard 顶部 */
.fp-banner {
  background: linear-gradient(135deg, var(--pri-light) 0%, #f0f9ff 100%);
  border: 1px solid rgba(43,143,217,.3);
  border-radius: var(--r-lg);
  padding: var(--sp-md) 20px;
  margin-bottom: var(--sp-md);
  display: flex; align-items: flex-start; gap: 14px;
}
.fp-banner-icon {
  width: 44px; height: 44px; border-radius: var(--r-md);
  background: rgba(43,143,217,.12);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.fp-banner-label {
  font-size: 10.5px; font-weight: 700; color: var(--pri);
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px;
}
.fp-banner-title {
  font-size: var(--text-15); font-weight: 700;
  color: var(--text-1); line-height: 1.3; margin-bottom: 6px;
}
.fp-banner-items {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px;
}
.fp-banner-item {
  font-size: 11.5px; color: var(--pri);
  background: rgba(43,143,217,.1);
  border-radius: var(--r-full);
  padding: 2px 10px;
}

/* ════ FEYNMAN MODE BANNER ═══════════════════════════════════ */
.feynman-banner {
  background: linear-gradient(135deg, #FFFDF5 0%, #FBF3DC 100%);
  border: 1px solid #F0D98C;
  border-radius: var(--r-md);
  padding: 10px 14px;
  margin: 0 0 10px;
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px; color: #92700A; font-weight: 500;
}
.feynman-banner-icon { font-size: 18px; flex-shrink: 0; }

/* ════ GEN PHASES ════════════════════════════════════════════ */
/* 两阶段生成进度 */
.gen-phase {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: var(--r-sm);
  font-size: 12px; color: var(--text-3); margin-bottom: 4px;
}
.gen-phase.done   { color: var(--green); background: var(--green-light); }
.gen-phase.active { color: var(--pri);   background: var(--pri-light);   font-weight: 500; }
.gen-phase.wait   { color: var(--text-3); }
.gen-phase-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; background: currentColor; }

/* 精品课标签筛选 */
.featured-tag-chip {
  font-size: 12px; padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--border-s); background: var(--surface);
  color: var(--text-2); cursor: pointer;
  transition: all .15s; font-family: var(--font);
}
.featured-tag-chip:hover { border-color: var(--text-2); color: var(--text-1); }
.featured-tag-chip.active {
  background: var(--ink); color: #fff; border-color: var(--ink);
}

/* 费曼测试模式样式 */
.bub-a.feynman { background: #FBF3DC; border: 1px solid #F0D98C; }

/* ════ CHAT CHOICE OPTIONS ═══════════════════════════════════ */
.chat-choice-group { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.chat-choice-hint  { font-size: 11px; color: var(--text-3); margin-bottom: 2px; }
.chat-choice-btn   {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--r-md);
  border: 1.5px solid var(--border-s);
  background: var(--surface); color: var(--text-1);
  font-size: 13px; text-align: left; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.chat-choice-btn:hover { border-color: var(--pri); background: var(--pri-light); }
.chat-choice-btn.selected { border-color: var(--pri); background: var(--pri-light); color: var(--pri); font-weight: 500; }
.chat-choice-key   {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border-s);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
  color: var(--text-2);
}

/* ════ RESIZE HANDLES ════════════════════════════════════════ */
.resize-handle {
  width: 1px; flex-shrink: 0; cursor: col-resize;
  background: var(--border); position: relative;
  z-index: 10; transition: background .15s; user-select: none; overflow: visible;
}
.resize-handle::before {
  content: ''; position: absolute; top: 0; bottom: 0; left: -5px; right: -5px; cursor: col-resize;
}
.rh-dot { display: none; }
.resize-handle:hover  { background: var(--border-s); }
.resize-handle.dragging { background: var(--border-s); }

.chat-panel::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 1px;
  cursor: col-resize; z-index: 10; background: var(--border); transition: background .15s;
}
.chat-panel:hover::before       { background: var(--border-s); }
.chat-panel.chat-resizing::before { background: var(--border-s); }
.msg-a.feynman .ai-av { background: #D4A017; color: #fff; }
.feynman-label { font-size: 10.5px; font-weight: 700; color: #92700A; margin-bottom: 5px; display: flex; align-items: center; gap: 5px; }
.chat-ta.feynman-mode { border-color: #F0D98C; background: #FFFDF5; }
.feynman-mode::placeholder { color: #B8960A; }
/* ── Sandbox Extras ── */
.lang-select { background: var(--surface); border: 1px solid var(--border-s); border-radius: var(--r-full); padding: 4px 10px; font-size: var(--text-12); font-family: var(--font); outline: none; cursor: pointer; color: var(--text-1); }
.lang-select:focus { border-color: var(--ink); }
.lang-badge { display: inline-flex; align-items: center; gap: 5px; border-radius: var(--r-full); padding: 3px 10px; font-size: 11px; font-weight: 700; letter-spacing: .2px; }
.exec-notice { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 16px; margin: 0 0 1px; font-size: var(--text-13); line-height: 1.55; color: var(--text-2); }

/* ════ MAP ══════════════════════════════════════════════════════ */
.map-wrap { padding: 36px 40px; display: flex; flex-direction: column; align-items: center; }

/* ════ HISTORY ══════════════════════════════════════════════════ */
.history-wrap { padding: 36px 40px; max-width: 900px; margin: 0 auto; width: 100%; }

/* ════ REPORT ═══════════════════════════════════════════════════ */
.report-wrap { padding: 36px 40px; max-width: 860px; margin: 0 auto; width: 100%; }
.report-body { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 36px 40px; box-shadow: var(--sh-sm); line-height: 1.85; color: var(--text-2); font-size: var(--text-14); }
.report-body h1 { font-size: var(--text-24); font-weight: 700; letter-spacing: -.4px; color: var(--text-1); margin: 0 0 6px; }
.report-body h2 { font-size: var(--text-18); font-weight: 700; color: var(--text-1); margin: 32px 0 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.report-body h3 { font-size: var(--text-16); font-weight: 600; color: var(--text-1); margin: 22px 0 10px; }
.report-body p  { margin: 0 0 16px; }
.report-body ul, .report-body ol { padding-left: 22px; margin: 0 0 16px; }
.report-body li { margin-bottom: 7px; }
.report-body blockquote { border-left: 3px solid var(--ink); padding: 10px 18px; margin: 16px 0; background: var(--surface-2); border-radius: 0 var(--r-md) var(--r-md) 0; font-style: italic; }
.report-body strong { color: var(--text-1); font-weight: 600; }
.report-body hr { border: none; border-top: 1px solid var(--border); margin: 28px 0; }
.report-body code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 1px 6px; }
.aha-chip { display: inline-flex; align-items: center; gap: 5px; background: var(--amber-light); border: 1px solid rgba(194,116,10,.2); border-radius: var(--r-full); padding: 4px 12px; font-size: 11px; font-weight: 600; color: var(--amber); margin: 4px 4px 4px 0; }

/* ════ REPORT COMPONENTS ════════════════════════════════════════ */
/* 统计卡片 [STATS] */
.rpt-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin: 18px 0 28px;
}
.rpt-stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 16px 18px;
}
.rpt-stat-label {
  font-size: 11px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px;
}
.rpt-stat-value {
  font-size: 22px; font-weight: 700; color: var(--text-1);
  line-height: 1.2; margin-bottom: 4px; letter-spacing: -.3px;
}
.rpt-stat-sub {
  font-size: 11.5px; color: var(--text-3); line-height: 1.5;
}

/* 顿悟卡片 [AHA] */
.rpt-aha {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--amber);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  padding: 18px 22px; margin: 16px 0;
}
.rpt-aha-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
}
.rpt-aha-icon {
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
  background: var(--amber-light); color: var(--amber);
  border-radius: 6px; font-size: 13px; flex-shrink: 0;
}
.rpt-aha-title {
  font-size: 15px; font-weight: 600; color: var(--text-1);
}
.rpt-aha-quote {
  font-size: 14px; font-style: italic; color: var(--text-1);
  background: var(--surface-2); border-radius: var(--r-sm);
  padding: 10px 14px; margin-bottom: 12px; line-height: 1.6;
}
.rpt-aha-why, .rpt-aha-impl {
  font-size: 13px; color: var(--text-2); line-height: 1.65;
  margin-bottom: 8px;
}
.rpt-aha-why:last-child, .rpt-aha-impl:last-child { margin-bottom: 0; }
.rpt-label {
  display: inline-block; font-size: 10.5px; font-weight: 700;
  color: var(--text-3); text-transform: uppercase; letter-spacing: .4px;
  margin-right: 8px;
}

/* 洞见卡片 [INSIGHT] */
.rpt-insight {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--pri);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  padding: 16px 20px; margin: 14px 0;
}
.rpt-insight-num {
  font-size: 10.5px; font-weight: 700; color: var(--pri);
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 5px;
}
.rpt-insight-title {
  font-size: 15px; font-weight: 600; color: var(--text-1);
  margin-bottom: 8px; line-height: 1.4;
}
.rpt-insight-body {
  font-size: 13.5px; color: var(--text-2); line-height: 1.7;
}

/* ════ TOAST ════════════════════════════════════════════════════ */
.toast {
  position: fixed; top: 20px; right: 20px; z-index: 9999;
  background: var(--surface); border: 1px solid rgba(194,116,10,.25);
  border-left: 3px solid var(--amber); border-radius: var(--r-xl);
  padding: 16px 18px; max-width: 320px; box-shadow: var(--sh-lg);
  animation: slideIn .25s ease;
}

/* ════ SETTINGS MODAL ═══════════════════════════════════════════ */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  animation: fadeUp .15s ease; backdrop-filter: blur(4px);
}
.settings-modal {
  background: var(--surface); border-radius: var(--r-xl);
  width: 580px; max-width: 96vw; max-height: 92vh;
  overflow-y: auto; box-shadow: var(--sh-lg);
  border: 1px solid var(--border);
  padding: 20px;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 24px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.modal-body { padding: 24px; }
.provider-card {
  border: 1.5px solid var(--border); border-radius: var(--r-lg);
  padding: 16px 18px; margin-bottom: 10px; cursor: pointer;
  transition: all .15s; position: relative; background: var(--surface);
}
.provider-card:hover { border-color: var(--border-s); background: var(--surface-2); }
.provider-card.selected { border-color: var(--ink); background: var(--surface-2); }
.provider-card .sel-dot { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-s); transition: all .12s; }
.provider-card.selected .sel-dot { background: var(--ink); border-color: var(--ink); }
.field-label { font-size: var(--text-13); font-weight: 600; color: var(--text-2); margin-bottom: 6px; display: block; }
.field-input { width: 100%; background: var(--surface); border: 1.5px solid var(--border-s); border-radius: var(--r-md); padding: 10px 14px; font-size: var(--text-13); font-family: var(--font); outline: none; color: var(--text-1); }
.field-input:focus { border-color: var(--ink); box-shadow: 0 0 0 2px rgba(0,0,0,.04); }
.model-select { width: 100%; background: var(--surface); border: 1.5px solid var(--border-s); border-radius: var(--r-md); padding: 10px 14px; font-size: var(--text-13); font-family: var(--font); outline: none; color: var(--text-1); cursor: pointer; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 5px; }

/* FAB */
.fab { position: fixed; bottom: 24px; right: 24px; z-index: 800; width: 48px; height: 48px; border-radius: 50%; background: var(--ink); border: none; box-shadow: var(--sh-md); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all .15s; }
.fab:hover { box-shadow: var(--sh-lg); transform: translateY(-2px); }
.fab svg { stroke: #fff; }
.pvd-badge { display: inline-flex; align-items: center; gap: 4px; border-radius: var(--r-full); padding: 3px 10px; font-size: 11px; font-weight: 600; cursor: pointer; }

/* Inline code */
code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 1px 6px; color: var(--pri); }

/* ════ ANIMATIONS ════════════════════════════════════════════════ */
@keyframes slideIn  { from { transform: translateX(110%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pulse    { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
@keyframes fadeUp   { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes spin     { to { transform: rotate(360deg); } }
@keyframes scaleIn  { from { opacity: 0; transform: scale(.88); } to { opacity: 1; transform: scale(1); } }
@keyframes fadeOut  { from { opacity: 1; } to { opacity: 0; } }
@keyframes fadeIn   { from { opacity: 0; } to { opacity: 1; } }

/* ════ 庆祝动画（费曼测试通过弹窗）═════════════════════════════════ */
.celebrate-wrap {
  position: relative;
  width: 96px;
  height: 96px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* 允许彩带飞溅到容器外，不被裁剪 */
  overflow: visible;
}
.celebrate-wrap .grad-cap {
  animation: capPop .7s cubic-bezier(.34, 1.56, .64, 1) .1s both;
  position: relative;
  z-index: 2;
}
@keyframes capPop {
  0%   { transform: scale(0) rotate(-30deg); opacity: 0; }
  60%  { transform: scale(1.15) rotate(8deg); opacity: 1; }
  80%  { transform: scale(.95) rotate(-3deg); }
  100% { transform: scale(1) rotate(0); }
}

/* 彩带粒子基础样式（大小、动画曲线） */
.confetti {
  position: absolute;
  top: 50%; left: 50%;
  width: 14px;
  height: 5px;
  border-radius: 1.5px;
  opacity: 0;
  pointer-events: none;
  animation-name: confettiFly;
  animation-timing-function: cubic-bezier(.2, .6, .35, 1);
  animation-fill-mode: forwards;
  z-index: 1;
}
@keyframes confettiFly {
  0%   { opacity: 0; transform: translate(-50%, -50%) rotate(0deg) scale(.4); }
  15%  { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(1); }
}

/* 12 片彩带：360° 均匀分布 + 每片独立的距离/大小/速度/延迟，制造自然爆发感 */
.confetti.c1  { background:#F5A623; --dx:   0px; --dy:-135px; --rot:285deg;  width:16px; animation-duration:1.6s; animation-delay:0.22s; }
.confetti.c2  { background:#2B8FD9; --dx:  68px; --dy:-115px; --rot:155deg;             animation-duration:1.3s; animation-delay:0.38s; }
.confetti.c3  { background:#5A8F3A; --dx: 118px; --dy: -68px; --rot:215deg;  width:13px; animation-duration:1.8s; animation-delay:0.28s; }
.confetti.c4  { background:#F5A623; --dx: 138px; --dy:   8px; --rot:-45deg;             animation-duration:1.45s; animation-delay:0.42s; }
.confetti.c5  { background:#2B8FD9; --dx: 108px; --dy:  72px; --rot:95deg;   width:17px; animation-duration:1.55s; animation-delay:0.3s; }
.confetti.c6  { background:#5A8F3A; --dx:  52px; --dy: 115px; --rot:-95deg;             animation-duration:1.25s; animation-delay:0.48s; }
.confetti.c7  { background:#F5A623; --dx:   8px; --dy: 140px; --rot:215deg;  width:14px; animation-duration:1.75s; animation-delay:0.26s; }
.confetti.c8  { background:#2B8FD9; --dx: -58px; --dy: 108px; --rot:-215deg;            animation-duration:1.4s; animation-delay:0.52s; }
.confetti.c9  { background:#5A8F3A; --dx:-122px; --dy:  62px; --rot:325deg;  width:15px; animation-duration:1.3s; animation-delay:0.36s; }
.confetti.c10 { background:#F5A623; --dx:-138px; --dy: -16px; --rot:65deg;              animation-duration:1.9s; animation-delay:0.22s; }
.confetti.c11 { background:#2B8FD9; --dx:-112px; --dy: -78px; --rot:-65deg;  width:13px; animation-duration:1.5s; animation-delay:0.4s; }
.confetti.c12 { background:#5A8F3A; --dx: -58px; --dy:-118px; --rot:-325deg;            animation-duration:1.65s; animation-delay:0.32s; }

/* ════ SCROLLBAR ════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-s); border-radius: 4px; }

/* ════ RESPONSIVE ════════════════════════════════════════════════ */
@media (max-width: 1400px) {
  :root { --sidebar-w: 248px; }
  .courses-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 1280px) {
  .courses-grid { grid-template-columns: repeat(3, 1fr); }
  .dash-grid { grid-template-columns: 1fr 300px; }
  .chat-panel { width: 320px; }
}
@media (max-width: 900px) {
  .courses-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .home-wrap { padding: 36px 24px 40px; }
  .home-input-wrap, .chips-wrap { max-width: 100%; }
  .app.view-home .main, .app.view-generating .main { width: 100%; }
}
@media (max-width: 600px) {
  .courses-grid { grid-template-columns: 1fr; gap: 12px; }
  .home-wrap { padding: 28px 16px 32px; }
  .home-title { font-size: clamp(28px, 8vw, 40px); }
  .home-sub { font-size: var(--text-14); }
  .chips { gap: 6px; }
  .chip { font-size: 12px; padding: 6px 12px; }
  .home-topbar { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
  .recent-label { padding-top: 28px; }
  .features-row { grid-template-columns: 1fr; gap: 12px; }
  .input-bar { padding: 10px 14px; }
  .home-input { font-size: var(--text-14); }
}

/* ── Auth / Login Screen ── */
.auth-screen {
  position: fixed; inset: 0; background: var(--bg-2);
  display: flex; align-items: center; justify-content: center;
  z-index: 5000; padding: 20px;
  /* 登录页独立适配，不受 body min-width 影响 */
  min-width: 0 !important;
}
.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--sh-lg);
  width: 100%; max-width: 400px; padding: 40px 36px;
}
.auth-logo { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 8px; }
.auth-logo-name { font-size: 22px; font-weight: 700; letter-spacing: -.5px; color: var(--ink); }
.auth-sub { text-align: center; font-size: var(--text-13); color: var(--text-2); margin-bottom: 28px; line-height: 1.6; }
.auth-tabs { display: flex; gap: 4px; background: var(--surface-2); border-radius: var(--r-md); padding: 4px; margin-bottom: 22px; }
.auth-tab { flex: 1; text-align: center; padding: 9px; border-radius: var(--r-sm); font-size: var(--text-13); font-weight: 600; cursor: pointer; color: var(--text-2); transition: all .15s; user-select: none; }
.auth-tab.active { background: var(--surface); color: var(--ink); box-shadow: var(--sh-xs); }
.auth-field { margin-bottom: 14px; }
.auth-label { font-size: var(--text-12); font-weight: 600; color: var(--text-2); margin-bottom: 6px; display: block; }
.auth-input { width: 100%; background: var(--surface); border: 1.5px solid var(--border-s); border-radius: var(--r-md); padding: 11px 14px; font-size: var(--text-14); font-family: var(--font); outline: none; color: var(--text-1); transition: border .12s; }
.auth-input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(0,0,0,.04); }
.auth-btn { width: 100%; background: var(--ink); color: #fff; border: none; border-radius: var(--r-full); padding: 12px; font-size: var(--text-14); font-weight: 600; cursor: pointer; margin-top: 8px; transition: all .15s; font-family: var(--font); }
.auth-btn:hover { background: #000; transform: translateY(-1px); }
.auth-btn:disabled { opacity: .5; cursor: default; transform: none; }
.auth-msg { font-size: var(--text-12); text-align: center; margin-top: 14px; line-height: 1.5; min-height: 16px; }
.auth-msg.err { color: var(--red); }
.auth-msg.ok { color: var(--green); }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--text-3); font-size: var(--text-12); }

/* ── 登录页移动端适配 ─────────────────────────────────────────── */
@media (max-width: 480px) {
  /* 卡片从底部弹出（sheet 模式），更符合手机交互习惯） */
  .auth-screen { padding: 0; align-items: flex-end; }
  .auth-card {
    max-width: 100%;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    padding: 32px 24px max(40px, env(safe-area-inset-bottom));
    box-shadow: var(--sh-lg);
    border-bottom: none;
  }
  /* 防止 iOS Safari 输入框自动缩放（字号需 ≥ 16px）*/
  .auth-input { font-size: 16px; padding: 13px 14px; }
  .auth-logo-name { font-size: 20px; }
  .auth-sub { font-size: 12px; margin-bottom: 20px; }
  .auth-tab { font-size: 12px; padding: 8px; }
  .auth-btn { padding: 14px; font-size: 15px; }
}
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-oauth { width: 100%; background: var(--surface); color: var(--text-1); border: 1.5px solid var(--border-s); border-radius: var(--r-full); padding: 11px; font-size: var(--text-14); font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 9px; transition: all .15s; font-family: var(--font); }
.auth-oauth:hover { border-color: var(--ink); background: var(--surface-2); }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 10px; }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.user-email { flex: 1; font-size: var(--text-12); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-logout { font-size: 11px; color: var(--text-3); cursor: pointer; padding: 3px 8px; border-radius: var(--r-sm); }
.user-logout:hover { color: var(--red); background: var(--surface-3); }

/* ── Account Menu (always visible) ── */
.acct-btn { position: fixed; top: 16px; right: 20px; z-index: 900; width: 38px; height: 38px; border-radius: 50%; background: var(--ink); color: #fff; border: 2px solid var(--surface); box-shadow: var(--sh-md); display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; cursor: pointer; transition: all .15s; }
.acct-btn:hover { transform: translateY(-1px); box-shadow: var(--sh-lg); }
.acct-menu { position: fixed; top: 62px; right: 20px; z-index: 901; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-lg); width: 260px; overflow: hidden; animation: fadeUp .15s ease; }
.acct-head { padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 11px; }
.acct-head-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700; flex-shrink: 0; }
.acct-head-info { min-width: 0; }
.acct-head-email { font-size: var(--text-13); font-weight: 600; color: var(--text-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-head-label { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.acct-item { display: flex; align-items: center; gap: 10px; padding: 11px 18px; font-size: var(--text-13); color: var(--text-1); cursor: pointer; transition: background .12s; }
.acct-item:hover { background: var(--surface-2); }
.acct-item.danger:hover { color: var(--red); }
.acct-item-icon { width: 16px; text-align: center; color: var(--text-3); }
