/* Mechanical Memory · 2026.10
   Presentation layer only. Existing data, controls and handlers stay intact. */
:root {
  --ui-bg: #f5f6f2;
  --ui-panel: #ffffff;
  --ui-soft: #f0f3ee;
  --ui-hover: #e9eee6;
  --ui-ink: #23322b;
  --ui-muted: #5f6c62;
  --ui-line: #dce3d9;
  --ui-accent: #345c40;
  --ui-accent-hover: #284c33;
  --ui-accent-soft: #e7efe3;
  --ui-warm: #99662d;
  --ui-warm-soft: #f7efdf;
  --ui-danger: #a84a3b;
  --ui-blue: #356a83;
  --ui-shadow: 0 6px 24px rgb(30 48 34 / 4%);
  --ui-radius: 18px;
  color-scheme: light;
}
html[data-theme="dark"] {
  --ui-bg: #151c18;
  --ui-panel: #1e2821;
  --ui-soft: #263128;
  --ui-hover: #303e33;
  --ui-ink: #e6ece2;
  --ui-muted: #adb9ac;
  --ui-line: #3c4b3e;
  --ui-accent: #abc99e;
  --ui-accent-hover: #c3dbb9;
  --ui-accent-soft: #2a3b2b;
  --ui-warm: #dec194;
  --ui-warm-soft: #3c3325;
  --ui-danger: #f1a895;
  --ui-blue: #a3c9dc;
  --ui-shadow: 0 6px 24px rgb(0 0 0 / 12%);
  color-scheme: dark;
}
html { scroll-padding-top: 20px; }
html body.ui-refresh {
  --ink: var(--ui-ink); --muted: var(--ui-muted); --paper: var(--ui-panel);
  --line: var(--ui-line); --soft: var(--ui-soft); --border: var(--ui-line);
  --card-bg: var(--ui-panel); --card-subtle: var(--ui-soft);
  --blue: var(--ui-blue); --green: var(--ui-accent); --orange: var(--ui-warm);
  background: var(--ui-bg) !important;
  color: var(--ui-ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
html body.ui-refresh::before { display: none; }
html body.ui-refresh strong { color: inherit; }
html body.ui-refresh :is(button, label, input, select, textarea) { -webkit-tap-highlight-color: transparent; }
html body.ui-refresh :is(button, .file-label, summary) { touch-action: manipulation; }
html body.ui-refresh :is(button, select, input, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--ui-accent); outline-offset: 3px;
}
html body.ui-refresh button { transition: background .16s ease, border-color .16s ease, box-shadow .16s ease; }
html body.ui-refresh button:disabled { cursor: not-allowed; opacity: .55; }
html body.ui-refresh [hidden] { display: none !important; }
html body.ui-refresh #studyArea[hidden] { display: none !important; }
.skip-link { position: fixed; top: -80px; left: 16px; z-index: 100; padding: 12px 20px; border-radius: 12px; background: var(--ui-accent); color: var(--ui-bg); text-decoration: none; }
.skip-link:focus { top: 12px; }
.skip-link:not(:focus) { width: 1px; height: 1px; padding: 0; clip-path: inset(100%); overflow: hidden; }
html body.ui-refresh .app {
  display: grid; grid-template-columns: 286px minmax(0, 1fr); gap: 24px 28px;
  max-width: 1304px; margin: 0 auto; padding: 32px 36px 56px;
  overflow: visible;
}
html body.ui-refresh .app > header {
  grid-column: 1 / -1; display: flex; flex-direction: row; align-items: center;
  padding: 0 0 26px; gap: 24px; background: transparent !important;
  border: 0; border-bottom: 1px solid var(--ui-line); border-radius: 0; box-shadow: none;
}
html body.ui-refresh .brand { position: relative; padding-left: 66px; flex-shrink: 0; text-align: left; }
html body.ui-refresh .brand::before {
  content: ''; position: absolute; top: 7px; left: 0; width: 48px; height: 48px;
  border-radius: 15px; background: #345c40;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48' fill='none'%3E%3Cpath d='M15 16l9-5 9 5v16l-9 5-9-5V16Z' stroke='%23e7efe3' stroke-width='1.6'/%3E%3Cpath d='M15 16l9 5 9-5M24 21v16M15 26l9 5 9-5' stroke='%23e7efe3' stroke-width='1.6'/%3E%3C/svg%3E");
}
html body.ui-refresh .eyebrow { margin: 0 0 6px; color: var(--ui-muted); font-size: 10px; letter-spacing: .14em; font-weight: 650; }
html body.ui-refresh .brand h1 { font-size: 25px; line-height: 1.35; letter-spacing: -.035em; font-weight: 700; color: var(--ui-ink); }
html body.ui-refresh .brand-subtitle { margin: 5px 0 0; color: var(--ui-muted); font-size: 12px; }
html body.ui-refresh .header-side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; min-width: 0; }
html body.ui-refresh .header-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; width: auto; }
html body.ui-refresh .quiet, html body.ui-refresh .file-label {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  min-height: 40px; padding: 9px 13px; border: 1px solid var(--ui-line);
  border-radius: 10px; color: var(--ui-ink) !important; background: var(--ui-panel) !important;
  box-shadow: none; font-size: 13px; line-height: 1.4; font-weight: 550; text-decoration: none;
}
html body.ui-refresh :is(.quiet, .file-label):hover { background: var(--ui-hover) !important; border-color: var(--ui-accent); transform: none; }
html body.ui-refresh .header-actions .quiet { min-height: 38px; white-space: nowrap; }
html body.ui-refresh #syncOpenBtn { border-color: var(--ui-accent); color: var(--ui-accent) !important; background: var(--ui-accent-soft) !important; }
html body.ui-refresh .sync-pill { min-height: 26px; padding: 3px 0; border: 0; background: transparent !important; color: var(--ui-muted) !important; font-size: 11px; box-shadow: none; }
html body.ui-refresh .sync-pill i { box-shadow: none; width: 6px; height: 6px; }
html body.ui-refresh .mode-tabs {
  width: 100%; display: flex; align-self: center; gap: 3px; padding: 4px;
  margin: 0; border: 1px solid var(--ui-line); border-radius: 12px;
  background: var(--ui-soft) !important; box-shadow: none; position: static;
}
html body.ui-refresh .mode-tabs .tab { flex: 1; display: flex; justify-content: center; padding: 10px 8px; margin: 0; min-height: 40px; border: 0; border-radius: 8px; font-size: 14px; color: var(--ui-muted); background: transparent; }
html body.ui-refresh .mode-tabs .tab.active { background: var(--ui-panel) !important; color: var(--ui-accent) !important; box-shadow: 0 1px 4px rgb(24 42 28 / 8%); font-weight: 700; }
html body.ui-refresh .course-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; margin: 0; align-self: center; }
html body.ui-refresh .course-tab {
  min-height: 48px; padding: 10px 8px; border: 1px solid transparent; border-radius: 11px;
  color: var(--ui-muted); background: transparent; font-size: 14px; font-weight: 600;
  box-shadow: none; transform: none; white-space: nowrap;
}
html body.ui-refresh .course-tab:hover { background: var(--ui-hover); }
html body.ui-refresh .course-tab.active { background: var(--ui-accent-soft) !important; border-color: var(--ui-line); color: var(--ui-accent) !important; box-shadow: none !important; }
html body.ui-refresh :is(#studyView, #libraryView) { grid-column: 1 / -1; min-width: 0; }
html body.ui-refresh #studyView {
  display: grid; grid-template-columns: minmax(0, 1fr) 352px; gap: 22px 28px;
  grid-template-areas: 'settings settings' 'metrics metrics' 'progress forecast' 'practice forecast' 'help forecast';
  grid-template-rows: auto auto auto auto minmax(min-content, 1fr);
  align-items: start;
}
html body.ui-refresh .study-settings { grid-area: settings; min-width: 0; }
html body.ui-refresh .study-settings > summary { display: none; }
html body.ui-refresh .toolbar {
  grid-area: settings; display: grid; grid-template-columns: minmax(180px, 1.3fr) minmax(210px, 1.6fr) repeat(3, minmax(90px, .65fr)) auto;
  gap: 12px; align-items: end; padding: 18px; margin: 0; border: 1px solid var(--ui-line);
  border-radius: 14px; background: var(--ui-panel) !important; box-shadow: none;
}
html body.ui-refresh .toolbar :is(label, .chapter-field) { display: flex; flex-direction: column; align-items: stretch; gap: 7px; min-width: 0; font-size: 11px; font-weight: 600; color: var(--ui-muted); }
html body.ui-refresh .chapter-field { grid-column: auto; position: relative; }
html body.ui-refresh :is(select, .chapter-picker-toggle, .sync-code-label input, .ai-question-label textarea) {
  min-height: 42px; min-width: 0; max-width: 100%; padding: 9px 11px; border: 1px solid var(--ui-line);
  border-radius: 9px; background: var(--ui-panel) !important; color: var(--ui-ink) !important;
  box-shadow: none; font-size: 13px; line-height: 1.4; font-weight: 500;
}
html body.ui-refresh .toolbar select { width: 100%; }
html body.ui-refresh .chapter-picker-toggle { justify-content: space-between; text-align: left; }
html body.ui-refresh .chapter-picker-toggle::after { color: var(--ui-muted); }
html body.ui-refresh #resetBtn { min-height: 42px; font-size: 11px; white-space: nowrap; padding: 9px 10px; background: var(--ui-soft) !important; border-color: transparent; }
html body.ui-refresh .chapter-picker-menu { width: min(390px, calc(100vw - 48px)); z-index: 30; border: 1px solid var(--ui-line); border-radius: 14px; background: var(--ui-panel) !important; box-shadow: 0 14px 40px rgb(0 0 0 / 15%); padding: 14px; }
html body.ui-refresh :is(.chapter-menu-head, .chapter-options label) { color: var(--ui-ink); }
html body.ui-refresh .chapter-menu-head { border-color: var(--ui-line); }
html body.ui-refresh .chapter-options label { display: flex; flex-direction: row; align-items: center; padding: 11px 8px; font-size: 13px; font-weight: 500; }
html body.ui-refresh .chapter-options label:hover { background: var(--ui-soft); }
html body.ui-refresh .chapter-options input { accent-color: var(--ui-accent); }
html body.ui-refresh .chapter-menu-hint { color: var(--ui-muted); border-color: var(--ui-line); }
html body.ui-refresh .today-dashboard { grid-area: metrics; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 0; gap: 12px; outline-offset: 4px; }
html body.ui-refresh .today-dashboard > div { grid-column: auto; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 5px; padding: 17px 20px; min-height: 92px; border: 1px solid var(--ui-line); border-radius: 14px; background: var(--ui-panel) !important; box-shadow: none; }
html body.ui-refresh .today-dashboard > div::before, html body.ui-refresh .today-dashboard > div::after { display: none; }
html body.ui-refresh .today-dashboard > div:first-child { border-color: #c4d4bd; background: var(--ui-accent-soft) !important; }
html body.ui-refresh .today-dashboard strong { color: var(--ui-ink); font-size: 26px; font-weight: 650; line-height: 1.25; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
html body.ui-refresh .today-dashboard span { color: var(--ui-muted); font-size: 11px; font-weight: 500; }
html body.ui-refresh .today-dashboard.is-complete { position: relative; display: block; padding: 0; border: 1px solid var(--ui-line); border-radius: 14px; background: var(--ui-accent-soft); box-shadow: none; }
html body.ui-refresh .today-dashboard.is-complete::before { display: block; padding: 16px 58px 16px 16px; color: var(--ui-accent); font-size: 13px; line-height: 1.8; }
html body.ui-refresh .today-dashboard.is-complete::after { position: absolute; top: 19px; right: 16px; margin: 0; color: var(--ui-muted); font-size: 11px; }
html body.ui-refresh .today-dashboard.is-complete:not(.expanded) > div { display: none; }
html body.ui-refresh .today-dashboard.is-complete.expanded { display: grid; padding: 12px; }
html body.ui-refresh .today-dashboard.is-complete.expanded::before { grid-column: 1 / -1; padding: 4px 48px 8px 4px; }
html body.ui-refresh .today-dashboard.is-complete.expanded > div { display: flex; }
html body.ui-refresh .progress-panel { grid-area: progress; margin: 0; padding: 0; background: transparent !important; border: 0; border-radius: 0; box-shadow: none; }
html body.ui-refresh .progress-copy { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; font-size: 12px; }
html body.ui-refresh #progressText { font-size: 13px; font-weight: 650; color: var(--ui-accent); }
html body.ui-refresh #progressHint { color: var(--ui-muted); line-height: 1.6; font-size: 11px; }
html body.ui-refresh .bar { height: 5px; margin-top: 12px; background: var(--ui-line); }
html body.ui-refresh .bar i { background: var(--ui-accent); box-shadow: none; }
html body.ui-refresh #studyArea { grid-area: practice; min-width: 0; display: grid; gap: 14px; }
html body.ui-refresh .study-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
html body.ui-refresh .study-heading h2 { margin: 0; font-size: 17px; letter-spacing: -.02em; font-weight: 650; }
html body.ui-refresh .study-heading p { margin: 0; color: var(--ui-muted); font-size: 11px; }
html body.ui-refresh #card {
  min-height: 330px; padding: 30px; border: 1px solid var(--ui-line); border-radius: 20px;
  background: var(--ui-panel) !important; color: var(--ui-ink); box-shadow: var(--ui-shadow);
  overflow: hidden; text-align: left; width: 100%;
}
html body.ui-refresh #card:hover { border-color: var(--ui-accent); box-shadow: 0 10px 28px rgb(30 48 34 / 7%); transform: none; }
html body.ui-refresh #card::before { display: none; }
html body.ui-refresh #card::after { width: 96px; height: 96px; border-radius: 50%; right: -40px; bottom: -40px; background: var(--ui-accent-soft); opacity: .7; }
html body.ui-refresh .card-side { display: inline-flex; padding: 5px 9px; background: var(--ui-accent-soft); color: var(--ui-accent); border-radius: 6px; font-size: 10px; line-height: 1.5; letter-spacing: .06em; }
html body.ui-refresh .card-content { font-size: clamp(23px, 2.15vw, 29px); line-height: 1.65; font-weight: 650; letter-spacing: -.025em; color: var(--ui-ink); max-width: 100%; padding: 24px 0; overflow-wrap: anywhere; }
html body.ui-refresh .tap { font-size: 11px; color: var(--ui-muted); }
html body.ui-refresh .card-organize { margin: 0; gap: 7px; }
html body.ui-refresh .card-organize .quiet { min-height: 36px; font-size: 12px; background: transparent !important; }
html body.ui-refresh .favorite-btn.active { background: var(--ui-warm-soft) !important; color: var(--ui-warm) !important; border-color: var(--ui-warm); }
html body.ui-refresh :is(.tag-chip, .meta-badge) { background: var(--ui-soft) !important; color: var(--ui-muted) !important; border-color: var(--ui-line) !important; font-size: 10px; }
html body.ui-refresh #answerArea { padding: 26px; background: var(--ui-panel) !important; color: var(--ui-ink); border: 1px solid var(--ui-line); border-radius: 18px; box-shadow: var(--ui-shadow); }
html body.ui-refresh .answer-title-wrap { align-items: center; margin-bottom: 18px; }
html body.ui-refresh .answer-title { color: var(--ui-accent); font-size: 12px; letter-spacing: .05em; }
html body.ui-refresh .cloze-toggle-all { color: var(--ui-accent) !important; background: var(--ui-accent-soft) !important; border-color: var(--ui-line); font-size: 11px; min-height: 34px; }
html body.ui-refresh :is(.answer-content, .answer-rich, .point-answer) { color: var(--ui-ink); font-size: 16px; line-height: 1.9; }
html body.ui-refresh .answer-rich :is(.answer-label, .answer-heading) { color: var(--ui-accent); border-color: var(--ui-accent); }
html body.ui-refresh .answer-rich .answer-key { color: var(--ui-accent) !important; background: var(--ui-accent-soft) !important; }
html body.ui-refresh .answer-rich :is(p, li) { color: var(--ui-ink); }
html body.ui-refresh .answer-rich .katex { color: var(--ui-ink) !important; }
html body.ui-refresh .answer-rich .katex-display { background: var(--ui-soft) !important; border-color: var(--ui-line) !important; box-shadow: none; }
html body.ui-refresh .self-check { color: var(--ui-muted); font-size: 12px; margin: 22px 0 10px; }
html body.ui-refresh .card-memory-status { border-color: var(--ui-line); gap: 6px; }
html body.ui-refresh .card-memory-status span { color: var(--ui-muted); background: var(--ui-soft); border-color: var(--ui-line); font-size: 10px; }
html body.ui-refresh .grade-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
html body.ui-refresh .grade-row button { min-height: 56px; border-radius: 11px; padding: 10px 8px; box-shadow: none; border: 1px solid transparent; transform: none; color: #fff !important; }
html body.ui-refresh .grade-row .again { background: #a95342 !important; border-color: #a95342 !important; }
html body.ui-refresh .grade-row .fuzzy { background: #8d681f !important; border-color: #8d681f !important; }
html body.ui-refresh .grade-row .good { background: #345c40 !important; border-color: #345c40 !important; }
html body.ui-refresh .grade-row button:hover { filter: brightness(1.1); transform: none; }
html body.ui-refresh .grade-row button strong { color: #fff !important; font-size: 14px; font-weight: 650; }
html body.ui-refresh .grade-row button small { color: #fff !important; opacity: .85; font-size: 10px; }
html body.ui-refresh #answerArea .grade-row button { box-shadow: none !important; }
html body.ui-refresh .nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 8px 0 0; border: 0; font-size: 12px; }
html body.ui-refresh .nav .quiet { background: transparent !important; font-size: 12px; min-height: 40px; }
html body.ui-refresh #position { font-variant-numeric: tabular-nums; color: var(--ui-muted); }
html body.ui-refresh #emptyState, html body.ui-refresh #completionPanel { grid-area: practice; border: 1px solid var(--ui-line); border-radius: 18px; background: var(--ui-panel) !important; padding: 30px; color: var(--ui-ink); }
html body.ui-refresh .completion-panel h2 { color: var(--ui-accent); }
html body.ui-refresh .help { grid-area: help; margin: 0; padding: 18px 0; border-top: 1px solid var(--ui-line); font-size: 12px; color: var(--ui-muted); }
html body.ui-refresh .help summary { color: var(--ui-muted); }
/* Forecast retains every chart and pacing control, beside the active card. */
html body.ui-refresh .forecast-panel { grid-area: forecast; margin: 0; border: 1px solid var(--ui-line); border-radius: 18px; background: var(--ui-panel) !important; box-shadow: none; min-width: 0; overflow: hidden; }
html body.ui-refresh .forecast-summary { padding: 18px; align-items: flex-start; gap: 8px; }
html body.ui-refresh .forecast-summary-head { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; }
html body.ui-refresh .forecast-badge { background: transparent; color: var(--ui-ink); padding: 0; font-size: 13px; font-weight: 650; }
html body.ui-refresh .forecast-header-summary { color: var(--ui-muted); font-size: 11px; white-space: normal; overflow: visible; }
html body.ui-refresh .forecast-header-summary strong { color: var(--ui-accent); font-size: 13px; }
html body.ui-refresh .forecast-body { padding: 0 16px 16px; border-color: var(--ui-line); }
html body.ui-refresh .forecast-goal-bar { padding: 14px; border: 1px solid var(--ui-line); background: var(--ui-accent-soft) !important; border-radius: 12px; margin: 14px 0; gap: 12px; }
html body.ui-refresh .goal-info { align-items: flex-start; flex-direction: column; gap: 8px; }
html body.ui-refresh .goal-tag { background: transparent; padding: 0; color: var(--ui-accent); font-size: 11px; }
html body.ui-refresh .goal-desc { color: var(--ui-ink); font-size: 11px; gap: 6px; line-height: 1.8; }
html body.ui-refresh .goal-desc strong { color: var(--ui-accent); }
html body.ui-refresh .goal-advice { color: var(--ui-muted); font-size: 10px; line-height: 1.7; }
html body.ui-refresh .goal-advice strong { color: var(--ui-accent); font-size: 11px; }
html body.ui-refresh .goal-actions { display: flex; flex-wrap: wrap; width: 100%; gap: 6px; }
html body.ui-refresh .goal-apply-btn { flex: 1; background: #345c40 !important; color: #fff !important; border-color: #345c40; min-height: 36px; padding: 7px 9px; font-size: 11px; }
html body.ui-refresh .goal-edit-btn { min-height: 36px; padding: 7px 9px; font-size: 11px; }
html body.ui-refresh .forecast-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0 0 14px; }
html body.ui-refresh .f-metric-card { background: var(--ui-soft) !important; border: 1px solid transparent; border-radius: 10px; padding: 12px 10px; gap: 5px; min-width: 0; }
html body.ui-refresh .f-metric-card.highlight-finish { background: var(--ui-warm-soft) !important; border-color: transparent; }
html body.ui-refresh .f-label { color: var(--ui-muted); font-size: 10px; }
html body.ui-refresh .f-metric-card strong { font-size: 14px; color: var(--ui-ink); letter-spacing: -.02em; overflow-wrap: anywhere; }
html body.ui-refresh .f-sub { font-size: 10px; font-weight: 500; color: var(--ui-muted); }
html body.ui-refresh .forecast-chart-box { padding: 14px 0 0; border: 0; border-top: 1px solid var(--ui-line); border-radius: 0; background: transparent !important; }
html body.ui-refresh .forecast-chart-top { flex-direction: column; align-items: stretch; gap: 12px; margin: 0 0 12px; }
html body.ui-refresh .forecast-chart-title { display: flex; flex-direction: column; gap: 4px; }
html body.ui-refresh .forecast-chart-title strong { font-size: 12px; color: var(--ui-ink); }
html body.ui-refresh .forecast-chart-desc { margin: 0; color: var(--ui-muted); font-size: 10px; }
html body.ui-refresh .forecast-chart-controls { display: flex; flex-wrap: wrap; gap: 6px; }
html body.ui-refresh .smoothing-btn { min-height: 32px; padding: 6px 8px; font-size: 10px; }
html body.ui-refresh .smoothing-btn.active { color: var(--ui-accent) !important; background: var(--ui-accent-soft) !important; border-color: var(--ui-line); }
html body.ui-refresh .forecast-range-toggle { background: var(--ui-soft); gap: 2px; }
html body.ui-refresh .forecast-range-toggle button { padding: 5px 6px; min-height: 26px; font-size: 10px; border: 0; background: transparent !important; color: var(--ui-muted) !important; }
html body.ui-refresh .forecast-range-toggle button.active { background: var(--ui-panel) !important; color: var(--ui-accent) !important; box-shadow: none; }
html body.ui-refresh .forecast-legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; font-size: 9px; color: var(--ui-muted); }
html body.ui-refresh .l-bar { width: 9px; height: 9px; border-radius: 2px; }
html body.ui-refresh .forecast-chart-scroll { overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--ui-line) transparent; padding-bottom: 8px; }
html body.ui-refresh .forecast-bars-wrap { height: 144px; min-width: 460px; gap: 4px; }
html body.ui-refresh .f-bar-track { background: var(--ui-soft); }
html body.ui-refresh .f-bar-total, html body.ui-refresh .f-date { color: var(--ui-ink); font-size: 10px; }
html body.ui-refresh .f-day { color: var(--ui-muted); font-size: 9px; }
html body.ui-refresh .f-bar-col.is-today { background: var(--ui-accent-soft); border-color: var(--ui-accent); box-shadow: none; }
html body.ui-refresh .is-today .f-date { color: var(--ui-accent); }
html body.ui-refresh .forecast-detail-box { background: var(--ui-soft); color: var(--ui-muted); border-left: 2px solid var(--ui-accent); padding: 10px; font-size: 10px; }
html body.ui-refresh .forecast-detail-box strong { color: var(--ui-accent); }
/* Library */
html body.ui-refresh .library-head { padding: 24px; margin: 0 0 18px; background: var(--ui-panel) !important; border: 1px solid var(--ui-line); border-radius: 18px; box-shadow: none; }
html body.ui-refresh .library-head h2 { font-size: 24px; color: var(--ui-ink); letter-spacing: -.03em; }
html body.ui-refresh .library-head p { color: var(--ui-muted); font-size: 12px; }
html body.ui-refresh .pie::after { background: var(--ui-panel); }
html body.ui-refresh .pie-legend { color: var(--ui-muted); font-size: 11px; }
html body.ui-refresh .library-toolbar { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr); padding: 16px 18px; margin: 0 0 20px; gap: 14px; border: 1px solid var(--ui-line); border-radius: 14px; background: var(--ui-panel) !important; position: static; box-shadow: none; }
html body.ui-refresh .library-toolbar label { display: flex; flex-direction: column; align-items: stretch; gap: 7px; color: var(--ui-muted); font-size: 11px; }
html body.ui-refresh .library-toolbar select { width: 100%; }
html body.ui-refresh .card-list { gap: 12px; margin: 0; }
html body.ui-refresh :is(.group-card, .point-card, .mechanism-point, .scan-point, .library-card) { border: 1px solid var(--ui-line); background: var(--ui-panel) !important; color: var(--ui-ink) !important; box-shadow: none; }
html body.ui-refresh .group-card { border-radius: 14px; }
html body.ui-refresh .group-card > summary { padding: 20px; background: transparent !important; color: var(--ui-ink) !important; }
html body.ui-refresh .group-card > summary strong { color: var(--ui-ink) !important; font-size: 16px; line-height: 1.6; }
html body.ui-refresh .group-card > summary :is(small, span) { color: var(--ui-muted) !important; font-size: 11px; }
html body.ui-refresh :is(.group-card, .point-card)[open] > summary { background: var(--ui-soft) !important; border-bottom-color: var(--ui-line) !important; }
html body.ui-refresh :is(.group-card, .point-card) > summary b { background: var(--ui-accent-soft) !important; color: var(--ui-accent) !important; border: 0; border-radius: 7px; padding: 5px 9px; font-size: 10px; box-shadow: none; white-space: nowrap; }
html body.ui-refresh .point-list { padding: 12px; gap: 8px; background: transparent !important; }
html body.ui-refresh .point-card { border-radius: 10px; }
html body.ui-refresh .point-card > summary { padding: 15px; background: transparent !important; grid-template-columns: 8px minmax(0, 1fr) auto; color: var(--ui-ink) !important; }
html body.ui-refresh .point-card > summary :is(.point-title, span) { font-size: 14px; line-height: 1.75; color: var(--ui-ink) !important; }
html body.ui-refresh .point-answer, html body.ui-refresh .mechanism-point .point-answer, html body.ui-refresh .scan-point .point-answer { padding: 20px; background: var(--ui-panel) !important; color: var(--ui-ink) !important; }
html body.ui-refresh .point-answer :is(p, li, div), html body.ui-refresh .point-answer span:not(.cloze-badge):not(.cloze-tag):not(.cloze-content):not(.katex):not(.meta-badge):not(.tag-chip) { color: var(--ui-ink) !important; }
html body.ui-refresh .point-answer :is(strong, .answer-heading) { color: var(--ui-ink) !important; border-color: var(--ui-accent) !important; }
html body.ui-refresh :is(.scan-library-tools, .highlight-tools) { padding: 12px; border: 1px solid var(--ui-line) !important; background: var(--ui-soft) !important; color: var(--ui-ink) !important; border-radius: 10px; }
html body.ui-refresh :is(.scan-library-tools span, .highlight-tools small, .highlight-hint) { color: var(--ui-muted) !important; font-size: 11px; }
html body.ui-refresh .highlight-tools .quiet { min-height: 40px; color: var(--ui-ink) !important; background: var(--ui-panel) !important; border-color: var(--ui-line) !important; font-size: 11px; }
html body.ui-refresh .highlight-tools .ask-ai-btn { color: var(--ui-blue) !important; }
html body.ui-refresh :is(.source-btn, .source-inline) { background: var(--ui-soft) !important; color: var(--ui-muted) !important; border: 1px solid var(--ui-line) !important; border-radius: 9px; box-shadow: none; min-height: 40px; }
html body.ui-refresh .point-answer .source-btn { background: var(--ui-soft) !important; color: var(--ui-muted) !important; border-color: var(--ui-line) !important; }
html body.ui-refresh :is(.answer-source, .library-figure, .scan-figure) { border: 1px solid var(--ui-line) !important; border-radius: 10px; background: #fff !important; box-shadow: none; }
html body.ui-refresh .figure-with-caption figcaption { color: var(--ui-muted); }
html body.ui-refresh :is(.table-scroll, .card-table) { background: var(--ui-panel) !important; color: var(--ui-ink) !important; border-color: var(--ui-line) !important; box-shadow: none !important; }
html body.ui-refresh :is(.table-scroll, .card-table) th { background: var(--ui-soft) !important; color: var(--ui-ink) !important; border-color: var(--ui-line) !important; }
html body.ui-refresh :is(.table-scroll, .card-table) td { background: var(--ui-panel) !important; color: var(--ui-ink) !important; border-color: var(--ui-line) !important; }
html body.ui-refresh .source-sheet, html body.ui-refresh .scan-reader-panel { background: var(--ui-panel) !important; color: var(--ui-ink); border: 1px solid var(--ui-line); }
/* Consistent dialogs, with internal scrolling and visible close controls. */
html body.ui-refresh dialog.sync-dialog { width: min(580px, calc(100vw - 32px)); max-width: none; max-height: calc(100dvh - 40px); margin: auto; padding: 24px; border: 1px solid var(--ui-line); border-radius: 20px; background: var(--ui-panel) !important; color: var(--ui-ink); box-shadow: 0 24px 80px rgb(0 0 0 / 25%); overflow: auto; scrollbar-gutter: auto; }
html body.ui-refresh dialog::backdrop { background: rgb(18 31 22 / 55%) !important; backdrop-filter: blur(5px); }
html body.ui-refresh .sync-dialog .sync-head { position: sticky; top: -24px; margin: -24px -24px 18px; padding: 22px 24px 16px; border-bottom: 1px solid var(--ui-line); background: var(--ui-panel) !important; box-shadow: none; z-index: 4; }
html body.ui-refresh .sync-head h2 { font-size: 20px; line-height: 1.5; color: var(--ui-ink); letter-spacing: -.03em; }
html body.ui-refresh .sync-head .quiet { flex-shrink: 0; min-height: 40px; }
html body.ui-refresh .sync-explain { color: var(--ui-muted); line-height: 1.9; font-size: 13px; }
html body.ui-refresh .sync-code-label { color: var(--ui-ink); font-size: 12px; gap: 8px; margin-top: 14px; }
html body.ui-refresh .sync-code-label input { font-size: 14px; min-height: 46px; letter-spacing: 0; }
html body.ui-refresh #aiModel { width: 100%; min-height: 46px; padding: 10px 11px; border: 1px solid var(--ui-line); border-radius: 9px; background: var(--ui-panel); color: var(--ui-ink); font: inherit; font-size: 14px; }
html body.ui-refresh :is(#aiStatus, #aiSettingsStatus, #aiQuote):empty { display: none; }
html body.ui-refresh .sync-status { background: var(--ui-soft); color: var(--ui-muted); border-radius: 10px; border: 1px solid var(--ui-line); font-size: 12px; line-height: 1.8; }
html body.ui-refresh .sync-status.error { color: var(--ui-danger); background: var(--ui-warm-soft); }
html body.ui-refresh .sync-dialog details { color: var(--ui-muted); font-size: 12px; line-height: 1.8; }
html body.ui-refresh :is(.sync-actions, .import-preview-actions) { gap: 8px; }
html body.ui-refresh :is(.sync-actions, .import-preview-actions) button:not(.quiet) { min-height: 44px; padding: 11px 14px; background: #345c40; color: #fff; border: 1px solid #345c40; border-radius: 10px; font-size: 13px; }
html body.ui-refresh :is(.sync-quick-connect, .import-preview-stats > div, .tag-options label, .tag-card-title, .ai-prof-chip, .ai-benchmark-box, .ai-chip-btn) { background: var(--ui-soft) !important; color: var(--ui-ink) !important; border-color: var(--ui-line) !important; }
html body.ui-refresh .sync-qr-box { background: var(--ui-soft); border-color: var(--ui-line); }
html body.ui-refresh .sync-qr-svg { background: #fff; padding: 8px; border-radius: 10px; }
html body.ui-refresh :is(.tag-hint, .sync-qr-hint, .import-preview-warning) { color: var(--ui-muted); font-size: 12px; }
html body.ui-refresh .danger-text { color: var(--ui-danger) !important; }
html body.ui-refresh .ai-dialog[open] { background: var(--ui-panel) !important; color: var(--ui-ink) !important; border-color: var(--ui-line) !important; max-width: 880px !important; box-shadow: 0 24px 80px rgb(0 0 0 / 25%) !important; }
html body.ui-refresh .ai-dialog.fullscreen[open] { max-width: none !important; }
html body.ui-refresh .ai-dialog .sync-head { background: var(--ui-panel) !important; border-color: var(--ui-line) !important; padding: 16px 20px !important; }
html body.ui-refresh .ai-head-brand .eyebrow { color: var(--ui-muted) !important; }
html body.ui-refresh .ai-head-brand h2 { color: var(--ui-ink) !important; }
html body.ui-refresh .ai-head-actions :is(.icon-btn, .close-btn) { min-width: 40px; min-height: 40px; background: var(--ui-soft) !important; border: 1px solid var(--ui-line) !important; color: var(--ui-ink) !important; }
html body.ui-refresh .ai-dialog-body { background: var(--ui-bg) !important; padding: 20px !important; }
html body.ui-refresh .ai-dialog blockquote#aiQuote { background: var(--ui-accent-soft) !important; color: var(--ui-ink) !important; border-left-color: var(--ui-accent) !important; }
html body.ui-refresh :is(.ai-turn, .ai-user, .ai-dialog-footer, .ai-input-bar) { background: var(--ui-panel) !important; color: var(--ui-ink) !important; border-color: var(--ui-line) !important; box-shadow: none !important; }
html body.ui-refresh .ai-dialog-footer { padding: 12px 20px 18px !important; }
html body.ui-refresh .ai-role { background: var(--ui-soft) !important; color: var(--ui-muted) !important; }
html body.ui-refresh .ai-role-answer { background: var(--ui-accent-soft) !important; color: var(--ui-accent) !important; }
html body.ui-refresh .ai-markdown, html body.ui-refresh .ai-markdown :is(p, li, h2, h3, h4, strong), html body.ui-refresh .ai-user p { color: var(--ui-ink) !important; }
html body.ui-refresh .ai-markdown :is(h2, h3, hr) { border-color: var(--ui-line) !important; }
html body.ui-refresh :is(.ai-model-chip, .ai-quick-pill, .ai-reasoning-box, .ai-reasoning-summary) { background: var(--ui-soft) !important; color: var(--ui-ink) !important; border-color: var(--ui-line) !important; }
html body.ui-refresh .ai-reasoning-content { background: var(--ui-panel) !important; color: var(--ui-muted) !important; border-color: var(--ui-line) !important; }
html body.ui-refresh .ai-input-bar textarea#aiQuestion { color: var(--ui-ink) !important; background: transparent !important; }
html body.ui-refresh .ai-send-btn { background: #345c40 !important; color: #fff !important; }
html body.ui-refresh .ai-dialog :is(.ai-math-block, .katex-display) { background: var(--ui-soft) !important; border-color: var(--ui-line) !important; }
html body.ui-refresh .ai-dialog .katex { color: var(--ui-ink) !important; }
html body.ui-refresh .ai-status-stop-pill { background: var(--ui-warm-soft) !important; color: var(--ui-danger) !important; border-color: var(--ui-line) !important; }
html body.ui-refresh .card-ai-notes-section { background: var(--ui-soft); border-color: var(--ui-line); }
/* Tablet and compact desktop retain readable controls, with the chart below study. */
@media (max-width: 1140px) {
  html body.ui-refresh .toolbar { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.5fr) minmax(0, .8fr); }
  html body.ui-refresh .toolbar > :is(label, .chapter-field, #resetBtn) { grid-column: auto; }
}
@media (max-width: 1023px) {
  html body.ui-refresh .app { grid-template-columns: 250px minmax(0, 1fr); padding: 26px 24px 48px; gap: 20px; }
  html body.ui-refresh .brand { padding-left: 56px; }
  html body.ui-refresh .brand::before { width: 42px; height: 48px; background-position: center; }
  html body.ui-refresh .brand h1 { font-size: 22px; }
  html body.ui-refresh .header-actions { max-width: 270px; }
  html body.ui-refresh #studyView { grid-template-columns: minmax(0, 1fr); gap: 20px; grid-template-areas: 'settings' 'metrics' 'progress' 'practice' 'forecast' 'help'; grid-template-rows: none; }
  html body.ui-refresh .forecast-summary-head { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; }
  html body.ui-refresh .forecast-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  html body.ui-refresh .goal-info { flex-direction: row; align-items: center; }
  html body.ui-refresh .goal-actions { width: auto; }
  html body.ui-refresh .forecast-chart-top { flex-direction: row; align-items: center; }
  html body.ui-refresh .forecast-legend { display: flex; flex-wrap: wrap; gap: 14px; }
  html body.ui-refresh .forecast-bars-wrap { min-width: 580px; }
}
@media (max-width: 767px) {
  html body.ui-refresh .app { display: flex; flex-direction: column; gap: 16px; padding: 20px 16px calc(32px + env(safe-area-inset-bottom)); }
  html body.ui-refresh .app > header { flex-direction: column; align-items: stretch; padding: 0 0 18px; gap: 16px; }
  html body.ui-refresh .brand { padding-left: 57px; }
  html body.ui-refresh .brand::before { width: 43px; height: 45px; top: 6px; border-radius: 13px; }
  html body.ui-refresh .brand h1 { font-size: 22px; }
  html body.ui-refresh .eyebrow { font-size: 9px; }
  html body.ui-refresh .brand-subtitle { font-size: 11px; margin-top: 4px; }
  html body.ui-refresh .header-side { align-items: stretch; gap: 8px; }
  html body.ui-refresh .header-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: none; width: 100%; gap: 6px; }
  html body.ui-refresh .header-actions .quiet { width: 100%; min-height: 42px; padding: 8px 3px; font-size: 11px; }
  html body.ui-refresh .sync-pill { align-self: flex-end; min-height: 22px; padding: 0; font-size: 10px; }
  html body.ui-refresh .mode-tabs { position: sticky; top: 8px; z-index: 15; margin: 0; padding: 4px; width: 100%; background: var(--ui-soft) !important; box-shadow: 0 4px 14px rgb(20 35 25 / 5%); }
  html body.ui-refresh .mode-tabs .tab { min-height: 42px; padding: 9px 8px; font-size: 13px; }
  html body.ui-refresh .course-tabs { width: 100%; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; margin: 0; }
  html body.ui-refresh .course-tab { min-height: 44px; padding: 8px 2px; font-size: 12px; border-radius: 9px; }
  html body.ui-refresh .course-tab:last-child { grid-column: auto; }
  html body.ui-refresh #studyView { width: 100%; gap: 18px; }
  html body.ui-refresh .study-settings { border: 1px solid var(--ui-line); border-radius: 14px; background: var(--ui-panel); }
  html body.ui-refresh .study-settings > summary { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 15px 14px; list-style: none; color: var(--ui-ink); font-size: 12px; font-weight: 600; cursor: pointer; }
  html body.ui-refresh .study-settings > summary::-webkit-details-marker { display: none; }
  html body.ui-refresh .study-settings > summary small { color: var(--ui-muted); font-size: 10px; font-weight: 400; }
  html body.ui-refresh .study-settings > summary::after { content: '⌄'; margin-left: auto; color: var(--ui-muted); font-size: 16px; }
  html body.ui-refresh .study-settings[open] > summary::after { transform: rotate(180deg); }
  html body.ui-refresh .study-settings[open] > summary { border-bottom: 1px solid var(--ui-line); }
  html body.ui-refresh .study-settings > .toolbar { border: 0; border-radius: 0; background: transparent !important; }
  html body.ui-refresh .toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 14px; gap: 12px 10px; }
  html body.ui-refresh .toolbar .chapter-field { grid-column: 1 / -1; }
  html body.ui-refresh .toolbar :is(label, .chapter-field) { display: flex; flex-direction: column; align-items: stretch; gap: 6px; font-size: 11px; }
  html body.ui-refresh .toolbar :is(select, .chapter-picker-toggle) { min-height: 42px; font-size: 12px; padding: 9px; }
  html body.ui-refresh #resetBtn { grid-column: 1 / -1; min-height: 38px; padding: 8px; font-size: 11px; }
  html body.ui-refresh .today-dashboard { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
  html body.ui-refresh .today-dashboard > div { grid-column: span 2; min-height: 78px; padding: 13px 12px; border-radius: 12px; gap: 4px; }
  html body.ui-refresh .today-dashboard > div:nth-child(4), html body.ui-refresh .today-dashboard > div:nth-child(5) { grid-column: span 3; min-height: 65px; }
  html body.ui-refresh .today-dashboard strong { font-size: 22px; }
  html body.ui-refresh .today-dashboard span { font-size: 10px; }
  html body.ui-refresh .progress-copy { gap: 5px; }
  html body.ui-refresh #progressHint { font-size: 10px; }
  html body.ui-refresh #studyArea { gap: 12px; }
  html body.ui-refresh .study-heading h2 { font-size: 15px; }
  html body.ui-refresh .study-heading p { font-size: 10px; }
  html body.ui-refresh #card { min-height: 290px; padding: 24px; border-radius: 18px; }
  html body.ui-refresh .card-content { font-size: 23px; line-height: 1.65; padding: 22px 0; }
  html body.ui-refresh #answerArea { padding: 20px; border-radius: 16px; }
  html body.ui-refresh :is(.answer-content, .answer-rich, .point-answer) { font-size: 15px; line-height: 1.85; }
  html body.ui-refresh .card-memory-status { gap: 4px; }
  html body.ui-refresh .card-memory-status span { font-size: 10px; }
  html body.ui-refresh #answerArea:not([hidden]) .grade-row { position: fixed; bottom: 0; left: 0; right: 0; z-index: 25; display: grid; width: 100%; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--ui-panel) !important; border: 0 !important; border-top: 1px solid var(--ui-line) !important; border-radius: 0; box-shadow: 0 -4px 20px rgb(20 35 25 / 6%) !important; }
  html body.ui-refresh #answerArea:not([hidden]) .grade-row button { min-height: 52px; padding: 8px 4px; border-radius: 10px; }
  html body.ui-refresh #answerArea:not([hidden]) .grade-row .again { background: #a95342 !important; border-color: #a95342 !important; }
  html body.ui-refresh #answerArea:not([hidden]) .grade-row .fuzzy { background: #8d681f !important; border-color: #8d681f !important; }
  html body.ui-refresh #answerArea:not([hidden]) .grade-row .good { background: #345c40 !important; border-color: #345c40 !important; }
  html body.ui-refresh:has(#answerArea:not([hidden])) .app { padding-bottom: calc(108px + env(safe-area-inset-bottom)); }
  html body.ui-refresh .nav { gap: 6px; }
  html body.ui-refresh .nav .quiet { font-size: 11px; padding: 9px; }
  html body.ui-refresh .forecast-summary { padding: 16px; }
  html body.ui-refresh .forecast-summary-head { flex-direction: column; align-items: flex-start; gap: 5px; }
  html body.ui-refresh .forecast-body { padding: 0 14px 14px; }
  html body.ui-refresh .goal-info { flex-direction: column; align-items: flex-start; }
  html body.ui-refresh .goal-actions { width: 100%; }
  html body.ui-refresh .forecast-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  html body.ui-refresh .forecast-chart-top { flex-direction: column; align-items: stretch; }
  html body.ui-refresh .forecast-chart-controls { justify-content: space-between; }
  html body.ui-refresh .forecast-legend { display: grid; gap: 7px; }
  html body.ui-refresh .forecast-bars-wrap { min-width: 460px; }
  html body.ui-refresh #libraryView { width: 100%; }
  html body.ui-refresh .library-head { flex-direction: row; align-items: center; padding: 18px; gap: 14px; margin-bottom: 14px; }
  html body.ui-refresh .library-head h2 { font-size: 22px; }
  html body.ui-refresh .library-head p { font-size: 11px; }
  html body.ui-refresh .pie-wrap { flex-direction: column; gap: 7px; flex-shrink: 0; }
  html body.ui-refresh .pie { width: 66px; height: 66px; }
  html body.ui-refresh .pie::after { width: 46px; height: 46px; }
  html body.ui-refresh .pie span { font-size: 10px; }
  html body.ui-refresh .pie-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px 7px; font-size: 9px; max-width: 108px; }
  html body.ui-refresh .library-toolbar { position: sticky; top: 66px; z-index: 14; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0 0 16px; padding: 12px; background: var(--ui-panel) !important; box-shadow: 0 3px 12px rgb(0 0 0 / 5%); }
  html body.ui-refresh .library-toolbar label:first-child { grid-column: 1 / -1; }
  html body.ui-refresh .library-toolbar label { font-size: 10px; gap: 5px; }
  html body.ui-refresh .library-toolbar select { font-size: 12px; }
  html body.ui-refresh #libraryView .library-toolbar { grid-template-columns: minmax(0, 1.25fr) repeat(2, minmax(0, 1fr)); gap: 8px; }
  html body.ui-refresh #libraryView .library-toolbar label { grid-column: auto !important; min-width: 0; }
  html body.ui-refresh #libraryView .library-toolbar select { min-width: 0; font-size: 11px; padding: 9px 5px; }
  html body.ui-refresh .group-card > summary { padding: 16px; }
  html body.ui-refresh .group-card > summary strong { font-size: 15px; }
  html body.ui-refresh .point-list { padding: 8px; }
  html body.ui-refresh .point-card > summary { padding: 12px; gap: 8px; }
  html body.ui-refresh .point-card > summary :is(.point-title, span) { font-size: 13px; }
  html body.ui-refresh .point-answer { padding: 16px; }
  html body.ui-refresh .highlight-tools { gap: 6px; padding: 10px; }
  html body.ui-refresh .highlight-tools .quiet { padding: 8px; font-size: 11px; }
  html body.ui-refresh dialog.sync-dialog { width: calc(100vw - 24px); max-height: calc(100dvh - 24px); margin: auto; padding: 20px; border-radius: 18px; }
  html body.ui-refresh .sync-dialog .sync-head { top: -20px; margin: -20px -20px 16px; padding: 18px 20px 14px; align-items: center; }
  html body.ui-refresh .sync-head h2 { font-size: 18px; }
  html body.ui-refresh .sync-dialog .sync-head button { min-width: 48px; }
  html body.ui-refresh .sync-actions { display: flex; flex-wrap: wrap; }
  html body.ui-refresh .sync-actions button { flex: 1; min-width: 80px; }
  html body.ui-refresh .sync-actions button:first-child { flex-basis: 100%; }
  html body.ui-refresh .goal-quick-presets { gap: 7px; }
  html body.ui-refresh .preset-btn { font-size: 11px; }
  html body.ui-refresh .ai-dialog[open] { width: calc(100vw - 16px) !important; height: 94dvh !important; max-height: 94dvh !important; border-radius: 18px !important; }
  html body.ui-refresh .ai-dialog.fullscreen[open] { width: 100vw !important; height: 100dvh !important; max-height: 100dvh !important; border-radius: 0 !important; }
  html body.ui-refresh .ai-dialog .sync-head { padding: 12px !important; }
  html body.ui-refresh .ai-head-brand h2 { font-size: 14px !important; }
  html body.ui-refresh .ai-head-actions { gap: 4px !important; }
  html body.ui-refresh .ai-head-actions :is(.icon-btn, .close-btn) { min-width: 34px; min-height: 38px; padding: 6px !important; }
  html body.ui-refresh .ai-dialog-body { padding: 14px !important; }
  html body.ui-refresh .ai-dialog-footer { padding: 10px 12px calc(12px + env(safe-area-inset-bottom)) !important; }
  html body.ui-refresh .ai-quick-pill { min-height: 36px; font-size: 11px !important; }
  html body.ui-refresh .ai-input-bar { padding: 8px !important; gap: 7px !important; }
  html body.ui-refresh .ai-model-chip { max-width: 88px !important; font-size: 11px !important; min-height: 38px; }
  html body.ui-refresh .ai-input-bar textarea#aiQuestion { font-size: 16px !important; }
}
/* Existing mobile rules use !important; keep this compact override explicit. */
@media (max-width: 480px) {
  html body.ui-refresh .app > header { padding: 0 0 18px !important; gap: 16px !important; }
  html body.ui-refresh .brand h1 { font-size: 22px !important; }
  html body.ui-refresh .brand-subtitle { font-size: 11px !important; margin-top: 4px !important; }
  html body.ui-refresh .header-actions { gap: 6px !important; }
  html body.ui-refresh .header-actions :is(button, label) { min-height: 42px !important; padding: 8px 3px !important; font-size: 11px !important; }
  html body.ui-refresh .sync-pill { min-height: 22px !important; padding: 0 !important; font-size: 10px !important; }
  html body.ui-refresh .mode-tabs { margin: 0 !important; padding: 4px !important; }
  html body.ui-refresh .mode-tabs .tab { padding: 9px 8px !important; font-size: 13px !important; }
  html body.ui-refresh .course-tabs { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; gap: 4px !important; margin: 0 !important; }
  html body.ui-refresh .course-tab { min-height: 44px !important; padding: 8px 2px !important; font-size: 12px !important; border-radius: 9px !important; }
  html body.ui-refresh .toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; padding: 14px !important; gap: 12px 10px !important; }
  html body.ui-refresh .toolbar .chapter-field { grid-column: 1 / -1 !important; }
  html body.ui-refresh .toolbar label { gap: 6px !important; font-size: 11px !important; align-items: stretch !important; }
  html body.ui-refresh .toolbar :is(select, .chapter-picker-toggle) { min-height: 42px !important; padding: 9px !important; font-size: 12px !important; }
  html body.ui-refresh #resetBtn { min-height: 38px !important; padding: 8px !important; font-size: 11px !important; }
  html body.ui-refresh #card { padding: 24px !important; min-height: 290px !important; border-radius: 18px !important; }
  html body.ui-refresh .card-content { font-size: 23px !important; line-height: 1.65 !important; }
  html body.ui-refresh #answerArea { padding: 20px !important; border-radius: 16px !important; }
  html body.ui-refresh .grade-row button { font-size: 14px !important; }
}
@media (max-width: 359px) {
  html body.ui-refresh .app { padding-left: 12px; padding-right: 12px; }
  html body.ui-refresh .brand h1 { font-size: 20px !important; }
  html body.ui-refresh .course-tab { font-size: 11px !important; }
  html body.ui-refresh .header-actions .quiet { font-size: 10px !important; }
  html body.ui-refresh #card { padding: 20px !important; }
  html body.ui-refresh .card-content { font-size: 21px !important; }
  html body.ui-refresh .nav .quiet { padding: 8px 7px; font-size: 10px; }
  html body.ui-refresh .ai-head-brand .eyebrow { font-size: 8px !important; letter-spacing: .02em !important; }
}
@media (prefers-reduced-motion: reduce) {
  html body.ui-refresh *, html body.ui-refresh *::before, html body.ui-refresh *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
