:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-alt: #faf8f4;
  --border: #e5e0d5;
  --text: #1c1e24;
  --text-muted: #626773;
  --primary: #b91c1c;
  --primary-hover: #991b1b;
  --primary-soft: rgba(185, 28, 28, 0.08);
  --amber: #b45309;
  --amber-soft: rgba(180, 83, 9, 0.1);
  --green: #059669;
  --green-soft: rgba(5, 150, 105, 0.1);
  --indigo: #4338ca;
  --indigo-soft: rgba(67, 56, 202, 0.08);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --topbar-h: 60px;
}

[data-theme="dark"] {
  --bg: #0f141b;
  --surface: #171e29;
  --surface-alt: #1d2634;
  --border: #2a3444;
  --text: #e6ebf2;
  --text-muted: #9aa5b5;
  --primary: #ef4444;
  --primary-hover: #dc2626;
  --primary-soft: rgba(239, 68, 68, 0.14);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.14);
  --green: #10b981;
  --green-soft: rgba(16, 185, 129, 0.14);
  --indigo: #818cf8;
  --indigo-soft: rgba(129, 140, 248, 0.14);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font-family: inherit;
  color: inherit;
}

button,
.cloze-blank,
.search-hit {
  touch-action: manipulation;
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-alt);
  color: var(--text-muted);
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: 12.5px;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.brand-badge {
  background: linear-gradient(135deg, var(--primary), #d97706);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  padding: 5px 9px;
  border-radius: 8px;
  letter-spacing: 0.5px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-text strong {
  font-size: 15px;
}

.brand-text small {
  font-size: 11px;
  color: var(--text-muted);
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
}

.nav-tab {
  border: none;
  background: transparent;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  transition: all 0.16s ease;
}

.nav-tab:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.nav-tab.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-trigger {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
}

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

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.mobile-only {
  display: none;
}

/* Views & Containers */
.view {
  display: none;
}

.view.active {
  display: block;
}

.container {
  max-width: 1260px;
  margin: 0 auto;
  padding: 22px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Buttons */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-xs {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

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

.btn-outline {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

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

.btn-amber {
  background: var(--amber-soft);
  border-color: rgba(180, 83, 9, 0.3);
  color: var(--amber);
}

.btn-amber.active {
  background: var(--amber);
  color: #fff;
}

/* Hero Banner */
.hero-banner {
  background: linear-gradient(125deg, #881313 0%, #b91c1c 55%, #b45309 100%);
  color: #fff;
  padding: 26px 28px;
  border-radius: var(--radius);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-md);
}

.hero-pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.18);
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.hero-banner h1 {
  margin: 0 0 6px;
  font-size: 23px;
  line-height: 1.3;
}

.hero-banner p {
  margin: 0;
  opacity: 0.9;
  font-size: 14px;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-banner .btn-primary {
  background: #fff;
  color: #991b1b;
}

.hero-banner .btn-outline {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.45);
  color: #fff;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kpi-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}

.kpi-val {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.15;
}

.progress-track {
  height: 7px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.progress-fill.green {
  background: var(--green);
}

/* Panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.panel-header h2 {
  margin: 0;
  font-size: 18px;
}

.panel-header p {
  margin: 2px 0 0;
  font-size: 13px;
}

.two-col-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

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

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

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

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

.badge-neutral {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

/* Chapter Pills & Cards on Dashboard */
.chapter-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill-btn {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

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

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

.sec-card {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  transition: border-color 0.15s ease;
}

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

.sec-card-ch {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.sec-card-title {
  font-weight: 700;
  font-size: 14.5px;
  line-height: 1.35;
}

.sec-card-stats {
  display: flex;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.sec-card-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
}

/* Info Lists */
.info-block {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  margin-bottom: 10px;
}

.info-block h4 {
  margin: 0 0 4px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.info-block p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.intro-pages {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 12px;
  max-height: 540px;
  overflow-y: auto;
}

.intro-page-card {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 13px;
}

/* Workspace Layout (Sidebar + Content) */
.workspace-layout {
  display: flex;
  min-height: calc(100vh - var(--topbar-h));
}

.sidebar {
  width: 300px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  display: flex;
  flex-direction: column;
}

.sidebar-head {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-head h3 {
  margin: 0;
  font-size: 15px;
}

.sidebar-divider {
  padding: 8px 14px 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.tree-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.tree-chapter {
  margin-bottom: 10px;
}

.tree-chapter-title {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--primary);
  padding: 6px 8px;
  background: var(--primary-soft);
  border-radius: 6px;
  margin-bottom: 4px;
}

.tree-item {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.tree-item:hover {
  background: var(--surface-alt);
}

.tree-item.active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

.tree-item.active .count-pill {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.count-pill {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text-muted);
  flex-shrink: 0;
}

.workspace-content {
  flex: 1;
  min-width: 0;
  padding: 18px 24px 60px;
}

.sticky-toolbar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 20;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toolbar-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-top h2 {
  margin: 0;
  font-size: 18px;
}

.breadcrumb {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.segmented {
  display: inline-flex;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
  flex-wrap: wrap;
}

.seg-btn {
  border: none;
  background: transparent;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.seg-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.input-sm,
.select-sm {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
}

.input-sm:focus,
.select-sm:focus {
  border-color: var(--primary);
}

.checkbox-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

/* Recitation Cards */
.card-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.subsection-divider {
  font-size: 14px;
  font-weight: 800;
  color: var(--primary);
  padding: 8px 12px;
  background: var(--primary-soft);
  border-left: 4px solid var(--primary);
  border-radius: 4px 8px 8px 4px;
  margin-top: 8px;
}

.recite-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease;
}

.recite-card.mastered {
  border-left: 4px solid var(--green);
}

.recite-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

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

.num-badge {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 6px;
}

.recite-body {
  font-size: 15.5px;
  line-height: 1.75;
}

.kw-highlight {
  background: var(--amber-soft);
  color: var(--amber);
  font-weight: 700;
  padding: 0 3px;
  border-radius: 4px;
}

.cloze-blank {
  display: inline-block;
  min-width: 56px;
  padding: 0 8px;
  margin: 0 2px;
  border-bottom: 2px solid var(--primary);
  background: var(--primary-soft);
  color: transparent;
  border-radius: 4px 4px 0 0;
  cursor: pointer;
  user-select: none;
  font-weight: 700;
  transition: all 0.15s ease;
}

.cloze-blank::before {
  content: "点击背诵";
  color: var(--primary);
  font-size: 12px;
  opacity: 0.7;
}

.cloze-blank.revealed {
  color: var(--primary);
  background: var(--green-soft);
  border-bottom-color: var(--green);
}

.cloze-blank.revealed::before {
  content: none;
}

.recite-details {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--text);
  font-size: 14.5px;
}

.recite-details li {
  margin-bottom: 4px;
}

.callout-box {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}

.callout-contrast {
  background: var(--indigo-soft);
  border-left: 3px solid var(--indigo);
}

.callout-mnemonic {
  background: var(--green-soft);
  border-left: 3px solid var(--green);
}

.recite-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  flex-wrap: wrap;
}

.action-chip {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.action-chip.active-green {
  background: var(--green-soft);
  border-color: var(--green);
  color: var(--green);
}

.action-chip.active-amber {
  background: var(--amber-soft);
  border-color: var(--amber);
  color: var(--amber);
}

.note-editor {
  margin-top: 10px;
}

.note-editor textarea {
  width: 100%;
  min-height: 68px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13.5px;
  resize: vertical;
}

.cloze-controls {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
  flex-wrap: wrap;
}

/* Quiz Mode */
.quiz-mode-list {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mode-item {
  border: none;
  background: transparent;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mode-item:hover {
  background: var(--surface-alt);
}

.mode-item.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.quiz-single-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 16px;
  align-items: start;
}

.quiz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.quiz-stem {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.7;
  margin: 14px 0 20px;
}

.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.quiz-opt-btn {
  border: 2px solid var(--border);
  background: var(--surface-alt);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
}

.quiz-opt-btn:hover:not(:disabled) {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.quiz-opt-btn.opt-correct {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
}

.quiz-opt-btn.opt-wrong {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.quiz-feedback {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-alt);
}

.quiz-feedback.is-right {
  border-color: var(--green);
  background: var(--green-soft);
}

.quiz-feedback.is-wrong {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.quiz-nav-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  position: sticky;
  top: 190px;
}

.panel-subhead {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
  font-weight: 700;
  font-size: 13.5px;
}

.number-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  max-height: 360px;
  overflow-y: auto;
}

.num-dot {
  height: 32px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.num-dot.current {
  outline: 2px solid var(--primary);
}

.num-dot.right {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.num-dot.wrong {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Mindmap Studio */
.deck-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.deck-tab {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.deck-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.mindmap-stage-wrap {
  display: flex;
  flex-direction: column;
}

.mindmap-viewport {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 620px;
  max-height: calc(100vh - 220px);
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 16px;
  position: relative;
}

.mindmap-canvas {
  position: relative;
  display: inline-block;
  transform-origin: top center;
  transition: transform 0.12s ease;
}

.mindmap-canvas img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: var(--shadow-md);
}

.mindmap-curtain {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 55%;
  background: rgba(24, 31, 41, 0.92);
  backdrop-filter: blur(8px);
  border-left: 3px dashed var(--amber);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.mindmap-curtain:active,
.mindmap-curtain.peek {
  opacity: 0.1;
}

.curtain-label {
  color: #fff;
  padding: 14px 18px;
  text-align: center;
  font-size: 13.5px;
  font-weight: 600;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.zoom-label {
  font-size: 12.5px;
  font-weight: 700;
  min-width: 44px;
  text-align: center;
}

/* Search Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 16px 24px;
}

.modal-box {
  width: 100%;
  max-width: 780px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
}

.modal-search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 16px;
}

.modal-search-meta {
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
}

.modal-results {
  overflow-y: auto;
  padding: 10px 10px 16px;
  max-height: calc(80vh - 110px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-hit {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  background: var(--surface);
}

.search-hit:hover {
  border-color: var(--primary);
  background: var(--surface-alt);
}

.search-hit mark {
  background: var(--amber-soft);
  color: var(--amber);
  font-weight: 700;
  padding: 0 2px;
}

/* Hub */
.hub-content {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.file-btn {
  cursor: pointer;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #111827;
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  z-index: 200;
  box-shadow: var(--shadow-md);
}

/* Responsive */
@media (max-width: 980px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .two-col-grid {
    grid-template-columns: 1fr;
  }
  .quiz-single-wrap {
    grid-template-columns: 1fr;
  }
  .quiz-nav-panel {
    position: static;
  }
}

.sidebar-backdrop {
  position: fixed;
  inset: var(--topbar-h) 0 0 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 60;
}

@media (max-width: 780px) {
  .mobile-only {
    display: inline-flex;
  }
  .brand-text small,
  .search-trigger kbd {
    display: none;
  }
  .search-trigger {
    padding: 6px 10px;
    max-width: 148px;
  }
  .search-trigger span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .main-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 55;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    gap: 2px;
    overflow-x: hidden;
    justify-content: space-between;
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.08);
  }
  .nav-tab {
    flex: 1 1 0;
    min-width: 0;
    padding: 6px 2px;
    font-size: 10.5px;
    letter-spacing: -0.2px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .container {
    padding: 16px 14px calc(80px + env(safe-area-inset-bottom));
  }
  .sidebar {
    position: fixed;
    left: -320px;
    top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    z-index: 65;
    transition: left 0.2s ease;
  }
  .sidebar.mobile-open {
    left: 0;
  }
  .workspace-content {
    padding: 12px 12px calc(84px + env(safe-area-inset-bottom));
  }
  .sticky-toolbar {
    position: static;
    padding: 12px;
  }
  .hero-banner {
    padding: 18px 16px;
  }
  .hero-banner h1 {
    font-size: 19px;
  }
  .quiz-options {
    grid-template-columns: 1fr 1fr;
  }
  .mindmap-viewport {
    min-height: 440px;
    padding: 8px;
  }
}
