/* css/app.css · 沪上高中学习工作台全局视觉规范
 * 风格：现代极简、护眼学术感、自适应深浅色模式、无侵入响应式布局
 */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-serif: "Songti SC", "Noto Serif CJK SC", "Georgia", serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Fira Code", monospace;

  --bg: #f4f6f9;
  --bg-sidebar: #f9fafc;
  --surface: #ffffff;
  --surface-2: #eff3f8;
  --surface-hover: #e9eef5;
  --border: #dce3ec;
  --border-subtle: #e7ecf2;

  --text-main: #1a2433;
  --text-muted: #536276;
  --text-faint: #59697d;

  --primary: #245ba8;
  --primary-hover: #194785;
  --primary-soft: #e7effb;

  --success: #20664c;
  --success-soft: #e9f5ee;
  --warning: #795112;
  --warning-soft: #fcf2df;
  --danger: #a23845;
  --danger-soft: #fbeef0;
  --purple: #634c96;
  --purple-soft: #f1edf8;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.03);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition: background-color .16s ease, color .16s ease, border-color .16s ease;
  --on-primary: #ffffff;
  --on-danger: #ffffff;
  --type-caption: .8125rem;
  --type-meta: .875rem;
  --type-support: .9375rem;
  --type-body: 1rem;
  --type-heading: 1.125rem;
  --type-title: clamp(1.65rem, 1.4rem + 1vw, 2.25rem);
  --read-line: 1.75;
  --space-2: .5rem;
  --space-3: .75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --measure: 54rem;
  --workspace: 76rem;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #121821;
  --bg-sidebar: #151d28;
  --surface: #1b2430;
  --surface-2: #222e3d;
  --surface-hover: #2a3748;
  --border: #344256;
  --border-subtle: #2b3748;

  --text-main: #edf2f7;
  --text-muted: #adbacc;
  --text-faint: #a3b0c3;

  --primary: #a5c8ff;
  --primary-hover: #c3daff;
  --primary-soft: #273a56;

  --success: #91d4b0;
  --success-soft: #223c35;
  --warning: #efca8c;
  --warning-soft: #3b3225;
  --danger: #ffabb3;
  --danger-soft: #432b34;
  --purple: #c8b6f2;
  --purple-soft: #342b49;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
  --on-primary: #152846;
  --on-danger: #3b1822;
  color-scheme: dark;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-main);
  line-height: var(--read-line);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  font-size: var(--type-body);
}

/* 核心布局框架 */
.layout {
  display: flex;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* 统一侧边栏 */
.sidebar {
  width: clamp(13rem, 23vw, 15.5rem);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: none;
  z-index: 50;
}

.brand {
  padding: var(--space-5) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.brand-icon {
  width: 2.5rem;
  height: 2.5rem;
  background: var(--primary-soft);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  box-shadow: none;
  flex: 0 0 auto;
}

.brand-title {
  font-size: var(--type-body);
  font-weight: 700;
  letter-spacing: -.015em;
  line-height: 1.4;
}

.brand-sub {
  font-size: var(--type-caption);
  color: var(--text-muted);
  margin-top: .125rem;
  line-height: 1.45;
}

.nav-container {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3);
  scrollbar-width: thin;
}

.nav-group-title {
  font-size: var(--type-caption);
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: var(--space-4) var(--space-2) var(--space-2);
  letter-spacing: .015em;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  margin-bottom: .125rem;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--type-support);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  min-height: 2.75rem;
  line-height: 1.35;
}

.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text-main);
}

.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.nav-item .nav-badge {
  margin-left: auto;
  font-size: var(--type-caption);
  padding: .125rem .375rem;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--text-muted);
  white-space: nowrap;
}

.nav-item.active .nav-badge {
  background: transparent;
  color: var(--primary);
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--type-meta);
  color: var(--text-muted);
}

/* 主内容区域 */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  min-width: 0;
  min-height: 0;
}

.topbar {
  height: auto;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--gutter);
  gap: var(--space-3);
  flex-shrink: 0;
  min-height: 4rem;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px 14px;
  width: min(100%, 23rem);
  transition: var(--transition);
  min-width: 0;
  min-height: 2.75rem;
  border-color: var(--border-subtle);
}

.search-box:focus-within {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.search-box input {
  border: none;
  background: transparent;
  outline: none;
  color: var(--text-main);
  font-size: var(--type-body);
  width: 100%;
  min-width: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  flex: 0 0 auto;
}

.btn-icon:hover {
  background: var(--surface-hover);
}

.content-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-8) var(--gutter) max(3rem, env(safe-area-inset-bottom));
  scrollbar-gutter: stable;
  overflow-wrap: anywhere;
}

/* 通用设计规范：卡片、标题与排版 */
.page-header {
  margin-bottom: var(--space-6);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.page-title {
  font-size: var(--type-title);
  font-weight: 700;
  letter-spacing: -.025em;
  display: block;
  align-items: center;
  gap: 10px;
  line-height: 1.25;
}

.page-desc {
  font-size: var(--type-support);
  color: var(--text-muted);
  margin-top: var(--space-2);
  max-width: 65ch;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(1rem, 2.5vw, 1.75rem);
  box-shadow: none;
  margin-bottom: var(--space-5);
  min-width: 0;
}

.card-title {
  font-size: var(--type-heading);
  font-weight: 650;
  display: block;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--space-3);
  line-height: 1.4;
}

/* Bento 网格系统 */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.col-12 { grid-column: span 12; }
.col-8 { grid-column: span 8; }
.col-7 { grid-column: span 7; }
.col-6 { grid-column: span 6; }
.col-5 { grid-column: span 5; }
.col-4 { grid-column: span 4; }
.col-3 { grid-column: span 3; }

@media (max-width: 1024px) {
  .col-8, .col-7, .col-5 { grid-column: span 12; }
  .col-3, .col-4 { grid-column: span 6; }
}

/* 按钮与交互元素 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: var(--space-2) var(--space-4);
  font-size: var(--type-support);
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  min-height: 2.75rem;
  max-width: 100%;
  line-height: 1.4;
}

.btn:hover {
  background: var(--surface-hover);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--on-danger);
}

.btn-danger:hover {
  background: var(--danger);
  filter: brightness(.92);
}

.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--type-meta);
}

.btn-lg {
  padding: var(--space-3) var(--space-5);
  font-size: var(--type-body);
  font-weight: 600;
}

/* 标签与徽章 */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: .25rem var(--space-2);
  font-size: var(--type-caption);
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-muted);
  line-height: 1.35;
}

.tag-blue { background: var(--primary-soft); color: var(--primary); }
.tag-green { background: var(--success-soft); color: var(--success); }
.tag-amber { background: var(--warning-soft); color: var(--warning); }
.tag-red { background: var(--danger-soft); color: var(--danger); }
.tag-purple { background: var(--purple-soft); color: var(--purple); }

/* 选项卡式切换 */
.tab-nav {
  display: flex;
  gap: var(--space-2);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-6);
  padding-bottom: 2px;
  overflow-x: auto;
  padding: 0 .25rem .375rem;
  scrollbar-width: thin;
}

.tab-btn {
  padding: var(--space-2) var(--space-3);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--type-support);
  font-weight: 500;
  border-bottom: 0;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  min-height: 2.75rem;
  border-radius: var(--radius-sm);
  flex: 0 0 auto;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: transparent;
  font-weight: 600;
  background: var(--primary-soft);
}

.science-tabs {
  flex-wrap: wrap;
  overflow: visible;
}

.science-tabs .tab-btn { white-space: normal; }

/* 单词背诵闪卡 */
.flashcard-wrapper {
  max-width: 620px;
  margin: 20px auto;
}

.flashcard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-5);
  text-align: center;
  box-shadow: none;
  min-height: 15rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: var(--transition);
}

.flashcard:hover {
  border-color: var(--primary);
}

.flashcard-word {
  font-size: clamp(1.75rem, 1.25rem + 2vw, 2.5rem);
  font-family: var(--font-serif);
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.flashcard-phonetic {
  font-size: 15px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: 16px;
}

.flashcard-meaning {
  font-size: 18px;
  font-weight: 600;
  color: var(--primary);
  margin: 12px 0;
}

.flashcard-example {
  background: var(--surface-2);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: var(--type-support);
  color: var(--text-muted);
  margin-top: 14px;
  text-align: left;
}

.flashcard-example-en {
  font-family: var(--font-serif);
  color: var(--text-main);
  margin-bottom: 4px;
}

/* 艾宾浩斯打分行 */
.grade-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 18px;
}

.btn-grade {
  padding: var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  background: var(--surface);
  color: var(--text-main);
  min-width: 0;
}

.btn-grade b { display: block; font-size: 15px; margin-bottom: 2px; }
.btn-grade small { font-size: 11px; color: var(--text-muted); }

.btn-grade.g-hard:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn-grade.g-medium:hover { background: var(--warning-soft); border-color: var(--warning); color: var(--warning); }
.btn-grade.g-easy:hover { background: var(--success-soft); border-color: var(--success); color: var(--success); }

/* 答题交互系统（11选10、选择题、填空题） */
.quiz-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(1rem, 2.5vw, 1.75rem);
  margin-bottom: var(--space-4);
  min-width: 0;
}

.quiz-passage {
  font-size: var(--type-body);
  line-height: 2;
  color: var(--text-main);
  margin-bottom: 20px;
}

.quiz-blank-input {
  display: inline-block;
  width: 3rem;
  height: 2.75rem;
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 0 8px;
  font-size: var(--type-body);
  font-weight: 600;
  text-align: center;
  background: var(--surface-2);
  color: var(--primary);
  margin: 0 4px;
}

.word-bank-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}

.word-bank-chip {
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: var(--type-meta);
  font-weight: 500;
}

.quiz-feedback {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  margin-top: 14px;
  font-size: var(--type-support);
}
.quiz-feedback.correct { background: var(--success-soft); color: var(--success); }
.quiz-feedback.wrong { background: var(--danger-soft); color: var(--danger); }

/* 番茄时钟专注大圆环 */
.pomodoro-display {
  text-align: center;
  padding: 40px 20px;
}

.pomodoro-timer {
  font-size: clamp(2.5rem, 1.25rem + 5vw, 4rem);
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -2px;
  margin: 16px 0;
}

/* 模态框与 Toast */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 580px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text-main);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  pointer-events: none;
  animation: slideUp 0.25s ease-out;
}

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

/* 进度条 */
.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: var(--surface-2);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* 错题卡片与表格 */
.wrong-item {
  border-left: 3px solid var(--danger);
  padding: 14px 18px;
  background: var(--surface-2);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin-bottom: 12px;
}

/* 阅读布局：工作台适合横向浏览，讲义与练习保持较短的阅读行宽。 */
.content-body > * {
  width: 100%;
  max-width: var(--workspace);
  margin-inline: auto;
}

.content-body:is([data-route="math"], [data-route="physics"], [data-route="chemistry"], [data-route="biology"], [data-route="chinese"]) > *,
#englishTabContent > :is(.quiz-box, .card):not(:has(.bento-grid)) {
  max-width: var(--measure);
  margin-inline: auto;
}

.page-actions, .topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.bento-grid > .card, .reading-stack > :is(.card, .quiz-box) { margin-bottom: 0; }

.subject-link {
  display: grid;
  gap: var(--space-2);
  align-content: start;
  justify-items: start;
  color: inherit;
  background: var(--surface-2);
  text-decoration: none;
  transition: var(--transition);
}

.subject-link:hover { background: var(--primary-soft); }

.search-icon, .search-box kbd { flex: 0 0 auto; color: var(--text-muted); }
.search-box input::placeholder { color: var(--text-muted); opacity: 1; }
.search-box kbd {
  border: 1px solid var(--border);
  border-radius: .25rem;
  padding-inline: .35rem;
  font: var(--type-caption)/1.45 var(--font-mono);
}

:where(button, a, input, select, summary):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.search-box:focus-within {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  box-shadow: none;
}

.page-title:focus { outline: none; }
.nav-toggle { display: none; }

.section-intro { margin-bottom: var(--space-4); }
.section-intro .card-title { margin-bottom: .25rem; }
.section-intro p { color: var(--text-muted); font-size: var(--type-support); }

.reading-stack { display: grid; gap: var(--space-4); }
.lesson-card { padding: clamp(1rem, 3vw, 2rem); }

.lesson-heading {
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: var(--space-4);
}

.lesson-kicker, .study-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.lesson-kicker { margin-bottom: var(--space-2); color: var(--text-muted); font-size: var(--type-meta); }
.lesson-number {
  border-inline-start: 2px solid var(--primary);
  padding-inline-start: var(--space-2);
  color: var(--primary);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.lesson-heading h3 { font-size: clamp(1.25rem, 1.12rem + .55vw, 1.5rem); line-height: 1.4; }
.lesson-block { margin-top: var(--space-5); }
.lesson-block h4 { margin-bottom: var(--space-2); font-size: var(--type-body); font-weight: 650; }
:is(.lesson-block, .study-unit) ul { padding-inline-start: 1.25em; }
:is(.lesson-block, .study-unit) li + li { margin-top: .25rem; }

.lesson-formula, .lesson-note, .ex-ans-box, .study-formula, .study-pitfall {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.lesson-formula li { font-family: var(--font-mono); font-size: var(--type-support); }
.lesson-note, .study-pitfall { color: var(--warning); background: var(--warning-soft); }
.lesson-example { border-top: 1px solid var(--border-subtle); padding-top: var(--space-4); }
.lesson-example .btn, .ex-ans-box, .ex-ans-box p + p { margin-top: var(--space-3); }

.study-unit, .recite-card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  background: var(--surface);
}
.study-heading { justify-content: space-between; margin-bottom: var(--space-3); }
.study-unit h3 { font-size: var(--type-heading); line-height: 1.4; }
.study-unit ul, .study-unit p, .study-formula { margin-top: var(--space-3); }
.study-unit details { margin-top: var(--space-3); border-top: 1px solid var(--border-subtle); }
.study-unit summary { padding-block: var(--space-2); cursor: pointer; color: var(--primary); font-weight: 600; }
.recite-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); gap: var(--space-3); }
.recite-card p { margin-block: var(--space-3); }
.recite-card small { font-size: var(--type-meta); color: var(--text-muted); }
.chinese-section-note { margin-bottom: var(--space-4); color: var(--text-muted); font-size: var(--type-support); }
:is(.recite-card, .poem-book, .poem-entry) > summary {
  padding-block: var(--space-2);
  color: var(--primary);
  cursor: pointer;
  font-weight: 600;
}
.poem-book { border-top: 1px solid var(--border-subtle); }
.poem-entry { margin-inline-start: var(--space-3); }
.poem-entry > summary { color: var(--text-main); }
.poem-author { color: var(--text-muted); font-size: var(--type-meta); font-weight: 400; }
.poem-reading { padding: var(--space-3); background: var(--surface-2); border-radius: var(--radius-md); }
.poem-text { margin-block: var(--space-3); }
.poem-text p + p { margin-top: var(--space-2); }

.quiz-options, .quiz-entry { display: grid; gap: var(--space-3); margin-bottom: var(--space-3); }
.quiz-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.quiz-entry { grid-template-columns: minmax(0, 1fr) auto; }
.quiz-fill-input {
  min-width: 0;
  min-height: 2.75rem;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text-main);
  font: inherit;
}

.btn-grade b { font-size: var(--type-body); }
.btn-grade small { font-size: var(--type-caption); }
button, input, select { font-family: inherit; }

@media (max-width: 48rem) {
  :root { --gutter: var(--space-4); }
  .layout { flex-direction: column; }
  .sidebar { width: 100%; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { padding: max(var(--space-2), env(safe-area-inset-top)) var(--gutter) var(--space-2); border: 0; }
  .nav-toggle { display: inline-flex; margin-inline-start: auto; flex: 0 0 auto; }
  .sidebar-footer, .sidebar:has(.nav-toggle[aria-expanded="false"]) .nav-container { display: none; }
  .nav-container {
    flex: 0 1 auto;
    max-height: 40dvh;
    border-top: 1px solid var(--border-subtle);
  }
  .topbar { flex-wrap: wrap; padding-block: var(--space-2); }
  .search-box { flex: 1 1 12rem; width: auto; }
  .content-body { padding-top: var(--space-5); scrollbar-gutter: auto; }
}

@media (max-width: 34rem) {
  .topbar-actions { width: 100%; }
  .topbar-actions .btn { flex: 1 1 auto; }
  .bento-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .col-12, .col-8, .col-7, .col-6, .col-5, .col-4 { grid-column: span 2; }
  .col-3 { grid-column: span 1; }
  .quiz-options { grid-template-columns: minmax(0, 1fr); }
  .grade-actions { gap: var(--space-2); }
  .btn-grade { padding-inline: var(--space-2); }
}

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

/* ==================== 交互增强与图文样式 ==================== */
.sci-svg {
  width: 100%;
  max-width: 420px;
  height: auto;
  display: block;
  margin: 8px auto;
  background: var(--surface-1);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 6px;
}
.diagram-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
}
.diagram-caption {
  font-size: var(--type-meta);
  color: var(--text-muted);
  line-height: 1.55;
  margin-top: 6px;
}
.mode-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.dictation-mask {
  filter: blur(5px);
  user-select: none;
  transition: filter 0.15s ease;
  cursor: pointer;
  background: var(--border);
  border-radius: 4px;
  padding: 0 4px;
}
.dictation-mask.revealed {
  filter: none;
  background: transparent;
}
.quiz-round-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  margin-top: 16px;
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  border: 1px solid var(--primary);
}
.search-box { position: relative; }
.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: 340px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  z-index: 999;
  padding: 8px;
}
.search-group-hdr {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 6px 10px 4px;
  text-transform: uppercase;
}
.search-hit {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--text-main);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.search-hit:hover, .search-hit:focus-visible {
  background: var(--surface-2);
}
.search-hit-title { font-size: 13px; font-weight: 600; color: var(--primary); }
.search-hit-sub { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-speak-mini {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-main);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  cursor: pointer;
  margin-left: 6px;
}
.btn-speak-mini:hover { border-color: var(--primary); color: var(--primary); }

/* ==================== IELTS-study 听力精听与听写纠错 ==================== */
.listen-cue-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 4px;
}
.listen-cue {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.listen-cue.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.listen-cue-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.listen-word {
  cursor: pointer;
  border-radius: 3px;
  padding: 0 2px;
}
.listen-word:hover {
  background: var(--primary-soft);
  color: var(--primary);
}
.dict-score {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  font-size: 14px;
}
.dict-score.good { background: var(--success-soft); color: var(--success); }
.dict-score.bad { background: var(--danger-soft); color: var(--danger); }
.dict-words { line-height: 2; font-size: 15px; }
.dw { display: inline-block; margin-right: 4px; padding: 1px 4px; border-radius: 4px; }
.dw.ok { color: var(--success); font-weight: 600; }
.dw.spell { background: rgba(245, 166, 35, 0.2); color: #d97706; }
.dw.wrong { background: var(--danger-soft); color: var(--danger); }
.dw.wrong s { opacity: 0.7; margin-right: 4px; }
.dw.miss { border-bottom: 2px dashed var(--danger); color: var(--danger); }
.dict-legend { display: flex; gap: 12px; font-size: 12px; margin-top: 8px; color: var(--text-muted); }
.listen-gloss-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}
.gloss-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  color: var(--text-main);
  cursor: pointer;
}
.gloss-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.gloss-lv {
  font-size: 10px;
  font-weight: 700;
  padding: 0 4px;
  border-radius: 4px;
  color: #fff;
}
.gloss-lv.zk { background: #10b981; }
.gloss-lv.gk { background: var(--primary); }
.gloss-lv.plus { background: #8b5cf6; }
