:root {
  --bg: #0b1020;
  --bg-elev: #121933;
  --bg-soft: #1a2244;
  --panel: #151c38;
  --border: #243056;
  --text: #e7ecff;
  --text-dim: #9aa6d3;
  --text-faint: #6b78a8;
  --accent: #6c8dff;
  --accent-2: #8c5cff;
  --ok: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;
  --kbd-bg: #1f2a4d;
  --kbd-border: #2d3a66;
  --link: #93b4ff;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius: 12px;
  --mono: ui-monospace, "Cascadia Code", "Fira Code", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

html.light {
  --bg: #f5f7ff;
  --bg-elev: #ffffff;
  --bg-soft: #eef1fb;
  --panel: #ffffff;
  --border: #d8defb;
  --text: #0e1430;
  --text-dim: #4b5478;
  --text-faint: #7b85ad;
  --accent: #2d4cff;
  --accent-2: #7a3dff;
  --ok: #059669;
  --warn: #d97706;
  --bad: #dc2626;
  --kbd-bg: #e9edff;
  --kbd-border: #c1c9ee;
  --link: #2447ff;
  --shadow: 0 10px 30px rgba(20,30,80,.10);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--sans); }
body { min-height: 100vh; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

button, .btn {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  transition: background .12s, transform .08s, border-color .12s;
}
button:hover, .btn:hover { background: var(--bg-elev); border-color: var(--accent); }
button:active, .btn:active { transform: scale(.97); }
button.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: white; border: none; }
button.primary:hover { filter: brightness(1.08); }

kbd {
  display: inline-block;
  background: var(--kbd-bg);
  border: 1px solid var(--kbd-border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  min-width: 18px;
  text-align: center;
}

/* ============== TOP BAR ============== */
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: rgba(11,16,32,.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
html.light .topbar { background: rgba(245,247,255,.85); }
.topbar .brand { font-weight: 700; letter-spacing: .3px; display: flex; align-items: center; gap: 8px; }
.topbar .brand .logo { width: 26px; height: 26px; border-radius: 6px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: inline-flex; align-items: center; justify-content: center; color: white; font-family: var(--mono); font-weight: 800; }
.topbar .spacer { flex: 1; }
.topbar .crumb { color: var(--text-dim); font-size: 13px; }
.topbar .crumb b { color: var(--text); font-weight: 600; }
.topbar-link {
  font-size: 13px; font-weight: 600; color: var(--accent); text-decoration: none;
  padding: 5px 10px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--bg-soft); white-space: nowrap; transition: border-color .12s, background .12s;
}
.topbar-link:hover { border-color: var(--accent); background: var(--bg-elev); text-decoration: none; }
.topbar .search {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  width: 220px;
}
.topbar .search:focus { outline: none; border-color: var(--accent); }

/* ============== DASHBOARD ============== */
.container { max-width: 1200px; margin: 0 auto; padding: 16px; }
.hero {
  padding: 28px 24px;
  background: linear-gradient(135deg, rgba(108,141,255,.15), rgba(140,92,255,.10));
  border: 1px solid var(--border);
  border-radius: 16px;
  margin-bottom: 20px;
}
.hero h1 { margin: 0 0 6px 0; font-size: 26px; }
.hero p { margin: 0; color: var(--text-dim); font-size: 14px; }
.hero .hint { margin-top: 12px; font-family: var(--mono); font-size: 12px; color: var(--text-faint); }
.hero-cta { margin-top: 14px; }
.report-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 10px; font-size: 13px; font-weight: 600;
  background: linear-gradient(135deg, rgba(108,141,255,.20), rgba(140,92,255,.14));
  border: 1.5px solid var(--accent); color: var(--text); text-decoration: none;
  transition: transform .12s, filter .12s;
}
.report-link:hover { transform: translateY(-1px); filter: brightness(1.08); text-decoration: none; }

/* ============== HERO STATS ============== */
.hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 16px;
}
.hero-stats:empty { display: none; }
.hero-stats .stat {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 2px;
}
html.light .hero-stats .stat { background: rgba(0,0,0,.025); }
.hero-stats .stat .num {
  font-family: var(--mono); font-weight: 800;
  font-size: 20px; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.hero-stats .stat .num small {
  font-weight: 600; font-size: 12px;
  color: var(--text-faint); margin-left: 3px;
}
.hero-stats .stat .num.good { color: var(--ok); }
.hero-stats .stat .num.mid  { color: var(--warn); }
.hero-stats .stat .num.bad  { color: var(--bad); }
.hero-stats .stat .lbl {
  font-family: var(--mono); font-size: 10.5px;
  color: var(--text-faint); text-transform: uppercase; letter-spacing: .6px;
}

/* ============== CONTINUE TILE ============== */
.continue-tile {
  display: flex; align-items: center; gap: 10px;
  margin-top: 12px; padding: 10px 14px;
  background: linear-gradient(135deg, rgba(108,141,255,.18), rgba(140,92,255,.12));
  border: 1.5px solid var(--accent); border-radius: 10px;
  text-decoration: none; color: var(--text);
  transition: transform .12s, box-shadow .12s, filter .12s;
  font-size: 14px;
}
.continue-tile:hover { transform: translateY(-1px); box-shadow: var(--shadow); text-decoration: none; filter: brightness(1.05); }
.continue-tile .play { color: var(--accent); font-size: 16px; font-weight: 800; }
.continue-tile .ct-label { font-family: var(--mono); font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .8px; }
.continue-tile .ct-name { font-weight: 700; }
.continue-tile .ct-sub  { font-family: var(--mono); font-size: 12px; color: var(--text-dim); margin-left: auto; }
.continue-tile .ct-sub small { color: var(--text-faint); }
.continue-tile .ct-key  { font-family: var(--mono); }

/* ============== WEAK MODULES STRIP ============== */
.weak-strip { max-width: 1200px; margin: 4px auto 0; padding: 0 16px; }
.weak-strip h4 { margin: 0 0 8px; font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .8px; }
.weak-list { display: grid; gap: 6px; }
.weak-item {
  display: grid;
  grid-template-columns: 1fr auto 140px 48px;
  gap: 12px; align-items: center;
  padding: 8px 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  text-decoration: none; color: var(--text); font-size: 13px;
  transition: border-color .12s, transform .08s;
}
.weak-item:hover { border-color: var(--warn); transform: translateX(2px); text-decoration: none; }
.weak-item .wi-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.weak-item .wi-meta { font-family: var(--mono); font-size: 11px; color: var(--text-faint); }
.weak-item .wi-bar { height: 6px; background: var(--bg-soft); border-radius: 3px; overflow: hidden; }
.weak-item .wi-bar > span { display: block; height: 100%; border-radius: 3px; }
.weak-item .wi-bar > span.good { background: linear-gradient(90deg, var(--ok), #34d399); }
.weak-item .wi-bar > span.mid  { background: linear-gradient(90deg, var(--warn), #fbbf24); }
.weak-item .wi-bar > span.bad  { background: linear-gradient(90deg, var(--bad), #f87171); }
.weak-item .wi-pct { font-family: var(--mono); font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.weak-item .wi-pct.good { color: var(--ok); }
.weak-item .wi-pct.mid  { color: var(--warn); }
.weak-item .wi-pct.bad  { color: var(--bad); }

@media (max-width: 700px) {
  .weak-item { grid-template-columns: 1fr 56px; }
  .weak-item .wi-meta, .weak-item .wi-bar { display: none; }
  .continue-tile .ct-sub { display: none; }
}

/* ============== WEAKNESS ANALYSIS OVERLAY ============== */
.overlay .analysis-panel {
  max-width: 880px;
}
.analysis-head h3 { margin: 0; border: none; padding: 0; }
.analysis-head .analysis-sub {
  margin-top: 4px; color: var(--text-dim); font-size: 12px; font-family: var(--mono);
}
.analysis-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 12px 0 10px; padding-bottom: 10px;
  border-bottom: 1.5px solid var(--accent);
  flex-wrap: wrap;
}
.analysis-bar .tabs { display: flex; gap: 6px; }
.analysis-bar .tab {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 12px;
  font-family: inherit; font-size: 13px; color: var(--text-dim);
  cursor: pointer; transition: all .12s;
}
.analysis-bar .tab kbd { margin-right: 4px; }
.analysis-bar .tab.active { color: var(--text); border-color: var(--accent); background: var(--bg-elev); }
.analysis-bar .filter { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-dim); font-family: var(--mono); }
.analysis-bar .filter select {
  background: var(--bg-soft); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 3px 6px; font-family: var(--mono); font-size: 12px;
}
.analysis-bar .filter .count { color: var(--text-faint); }

.analysis-list {
  display: flex; flex-direction: column; gap: 4px;
  max-height: 58vh; overflow-y: auto;
  padding-right: 4px;
}
.analysis-row {
  display: grid;
  grid-template-columns: 1fr auto 120px 48px 110px;
  gap: 10px; align-items: center;
  padding: 8px 12px;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px;
  text-decoration: none; color: var(--text); font-size: 13px;
  transition: border-color .12s, transform .08s, background .12s;
}
.analysis-row:hover { border-color: var(--accent); text-decoration: none; }
.analysis-row.focused { background: var(--bg-elev); border-color: var(--accent); box-shadow: 0 0 0 2px rgba(108,141,255,.25); }
.analysis-row .ar-main { min-width: 0; }
.analysis-row .ar-title { font-weight: 700; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.analysis-row .ar-sub { font-family: var(--mono); font-size: 11px; color: var(--text-faint); margin-top: 1px; }
.analysis-row .ar-counts { display: flex; gap: 8px; font-family: var(--mono); font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.analysis-row .ar-counts .ar-of { color: var(--text-faint); }
.analysis-row .ar-bar { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.analysis-row .ar-bar > span { display: block; height: 100%; border-radius: 3px; }
.analysis-row .ar-bar > span.good { background: linear-gradient(90deg, var(--ok), #34d399); }
.analysis-row .ar-bar > span.mid  { background: linear-gradient(90deg, var(--warn), #fbbf24); }
.analysis-row .ar-bar > span.bad  { background: linear-gradient(90deg, var(--bad), #f87171); }
.analysis-row .ar-pct { font-family: var(--mono); font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.analysis-row .ar-pct.good { color: var(--ok); }
.analysis-row .ar-pct.mid  { color: var(--warn); }
.analysis-row .ar-pct.bad  { color: var(--bad); }
.analysis-row .ar-action { font-family: var(--mono); font-size: 11px; color: var(--text-faint); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.analysis-row:hover .ar-action,
.analysis-row.focused .ar-action { color: var(--accent); }

@media (max-width: 700px) {
  .analysis-row { grid-template-columns: 1fr 56px; }
  .analysis-row .ar-counts, .analysis-row .ar-bar, .analysis-row .ar-action { display: none; }
}

.semester { margin: 24px 0; }
.semester-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; padding: 4px 4px; border-bottom: 1px dashed var(--border); }
.semester-head .tag {
  font-family: var(--mono); font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white; padding: 2px 8px; border-radius: 6px; font-size: 12px;
}
.semester-head .name { color: var(--text-dim); font-size: 13px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none; color: var(--text);
  transition: transform .12s, border-color .12s, box-shadow .12s;
  position: relative;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow); text-decoration: none; }
.card .num {
  position: absolute; top: 8px; right: 10px;
  font-family: var(--mono); font-size: 11px;
  color: var(--accent); font-weight: 700;
}
.card .card-reset, .card .card-report, .exam-tile .tile-reset {
  position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-faint);
  font-size: 13px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: 0; transform: scale(.92);
  transition: opacity .12s, color .12s, border-color .12s, background .12s, transform .12s;
  padding: 0;
  z-index: 2;
}
.card .card-reset { right: 30px; }   /* leave room for the "num" badge */
.card .card-report { right: 54px; }  /* sits left of the reset button */
.card:hover .card-reset, .card.focused .card-reset,
.card:hover .card-report, .card.focused .card-report,
.exam-tile:hover .tile-reset, .exam-tile:focus .tile-reset, .exam-tile.focused .tile-reset {
  opacity: 1; transform: scale(1);
}
.card .card-reset:hover, .exam-tile .tile-reset:hover {
  color: var(--warn); border-color: var(--warn); background: rgba(245,158,11,.12);
}
.card .card-report:hover {
  color: var(--accent); border-color: var(--accent); background: rgba(108,141,255,.14);
}
.card .card-reset.armed, .exam-tile .tile-reset.armed {
  color: white; background: var(--bad); border-color: var(--bad);
  opacity: 1; transform: scale(1.1);
  box-shadow: 0 0 0 3px rgba(239,68,68,.25);
  animation: qe-armed-pulse .8s ease-in-out infinite;
}
@keyframes qe-armed-pulse { 50% { transform: scale(1.18); } }
.card .title { font-weight: 600; font-size: 15px; line-height: 1.25; padding-right: 24px; }
.card .meta { font-size: 12px; color: var(--text-dim); font-family: var(--mono); }
.card.focused { outline: 2px solid var(--accent); outline-offset: 2px; }
.card .progress { height: 4px; background: var(--bg-soft); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.card .progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); width: 0%; }

/* ============== VIEWER ============== */
.viewer {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 16px;
  padding: 16px;
  max-width: 1400px;
  margin: 0 auto;
}
.viewer.no-sidebar { grid-template-columns: 1fr; }
.sidebar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  position: sticky; top: 64px;
}
.sidebar h3 { margin: 4px 6px 8px; font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .8px; }
.sidebar .exam-group { margin-bottom: 6px; }
.sidebar .exam-name {
  font-size: 12px; color: var(--text-dim); padding: 5px 6px;
  font-family: var(--mono); display: flex; gap: 6px; align-items: center;
  cursor: pointer; user-select: none; border-radius: 6px;
  transition: background .12s, color .12s;
}
.sidebar .exam-name:hover { background: var(--bg-soft); color: var(--text); }
.sidebar .exam-name.current { color: var(--accent); font-weight: 700; background: rgba(108,141,255,.08); cursor: default; }
.sidebar .exam-name.current:hover { background: rgba(108,141,255,.12); }
.sidebar .exam-name .chev {
  font-size: 10px; line-height: 1; flex-shrink: 0;
  display: inline-block; width: 10px; text-align: center;
  color: var(--text-faint);
  transition: transform .15s ease, color .15s;
}
.sidebar .exam-name.current .chev { color: var(--accent); }
.sidebar .exam-group.collapsed .exam-name .chev { transform: rotate(-90deg); }
.sidebar .exam-name .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.sidebar .exam-name .stats { color: var(--text-faint); font-size: 11px; flex-shrink: 0; }
.sidebar .exam-name .stats b { color: var(--ok); }

/* Collapsible body — display:none keeps it simple (and avoids tall q-list overflow surprises) */
.sidebar .exam-group.collapsed .q-list { display: none; }
.sidebar .q-list { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 2px 4px 8px; }
.sidebar .q-chip {
  display: flex; align-items: center; justify-content: center;
  height: 28px; border-radius: 6px;
  background: transparent;
  border: 1.5px solid var(--border);
  cursor: pointer; font-family: var(--mono); font-size: 11px;
  color: var(--text-faint);
  transition: transform .12s, box-shadow .12s, background .12s, color .12s, border-color .12s;
  position: relative;
}
.sidebar .q-chip:hover { color: var(--text); border-color: var(--accent); transform: translateY(-1px); }
.sidebar .q-chip.picked  { background: rgba(108,141,255,.12); color: var(--text); border-color: var(--accent-2); border-style: dashed; }
.sidebar .q-chip.correct { background: rgba(16,185,129,.18); color: var(--ok); border-color: var(--ok); font-weight: 700; }
.sidebar .q-chip.partial { background: rgba(245,158,11,.18); color: var(--warn); border-color: var(--warn); font-weight: 700; }
.sidebar .q-chip.wrong   { background: rgba(239,68,68,.18); color: var(--bad); border-color: var(--bad); font-weight: 700; }
.sidebar .q-chip.flagged::after {
  content: ""; position: absolute; top: 2px; right: 2px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--warn);
}
/* CURRENT always wins — ring on top of any state color */
.sidebar .q-chip.current {
  box-shadow: 0 0 0 2px var(--accent), 0 0 0 4px rgba(108,141,255,.35);
  transform: scale(1.08);
  z-index: 2;
  border-color: var(--accent) !important;
}
.sidebar .q-chip.current:not(.correct):not(.wrong):not(.partial) {
  background: var(--accent); color: white;
}

.qpane {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  min-height: 70vh;
}
.qhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.qhead .qmeta { font-family: var(--mono); font-size: 12px; color: var(--text-dim); }
.qhead .qmeta b { color: var(--text); }
.qhead .qtopic { font-family: var(--mono); font-size: 11px; background: var(--bg-soft); padding: 2px 8px; border-radius: 5px; color: var(--text-dim); }
.qhead .qexam { font-size: 12px; color: var(--text-faint); font-family: var(--mono); }

/* ============== LESSON FILTER (curriculum tags, C key) ============== */
.sidebar .q-chip.out { opacity: .28; }
.sidebar .q-chip.out:hover { opacity: .8; }
.controls button.active { border-color: var(--accent); color: var(--accent); background: rgba(108,141,255,.12); }
.lf-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: -4px 0 12px; padding: 6px 8px; border: 1px dashed var(--accent); border-radius: 8px;
  background: rgba(108,141,255,.07); font-size: 12px;
}
.lf-bar-pos { font-family: var(--mono); color: var(--text-dim); white-space: nowrap; }
.lf-bar-tags { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; min-width: 0; }
.lf-tag { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 5px; padding: 1px 7px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lf-tag.more { color: var(--text-dim); }
.lf-bar .mini, .lf-actions .mini {
  font-size: 11px; padding: 3px 8px; background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-dim); cursor: pointer;
}
.lf-bar .mini:hover, .lf-actions .mini:hover { border-color: var(--accent); color: var(--text); }
.overlay .panel.lf-panel { max-width: 720px; display: flex; flex-direction: column; overflow: hidden; }
.lf-cur { color: var(--text-dim); font-weight: 400; }
.lf-search {
  width: 100%; box-sizing: border-box; padding: 9px 12px; margin-bottom: 10px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg-soft); color: var(--text); font-size: 14px;
}
.lf-search:focus { outline: none; border-color: var(--accent); }
.lf-list { overflow-y: auto; min-height: 120px; flex: 1; padding-right: 2px; }
.lf-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px;
  cursor: pointer; border: 1px solid transparent; font-size: 14px; user-select: none;
}
.lf-row:hover, .lf-row.focused { background: var(--bg-soft); border-color: var(--border); }
.lf-row.focused { border-color: var(--accent); }
.lf-row.lf-group { margin-top: 10px; font-weight: 700; color: var(--accent); text-transform: uppercase; font-size: 12px; letter-spacing: .5px; }
.lf-row.lf-child { padding-left: 22px; }
.lf-row .label { flex: 1; min-width: 0; }
.lf-row .right { font-family: var(--mono); font-size: 11px; color: var(--text-faint); white-space: nowrap; text-transform: none; letter-spacing: 0; font-weight: 400; }
.lf-row .right.good { color: var(--ok); }
.lf-row .right.mid  { color: var(--warn); }
.lf-row .right.weak { color: var(--bad); }
.lf-check {
  width: 16px; height: 16px; flex-shrink: 0; border: 1.5px solid var(--border); border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 11px; color: white;
}
.lf-row.on .lf-check { background: var(--accent); border-color: var(--accent); }
.lf-row.on .lf-check::after { content: "✓"; }
.lf-row.via .lf-check { border-color: var(--accent); }
.lf-row.via .lf-check::after { content: "•"; color: var(--accent); }
.lf-row.empty { cursor: default; opacity: .4; }
.lf-row.empty:hover { background: none; border-color: transparent; }
.lf-panel.hide-empty .lf-row.empty { display: none; }
.lf-row[hidden], .lf-others[hidden] { display: none; }
@media (pointer: coarse) { .lf-keys { display: none; } }
.lf-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.lf-summary { flex: 1; font-family: var(--mono); font-size: 12px; color: var(--text-dim); min-width: 160px; }
@media (max-width: 640px) {
  .lf-bar-tags { order: 5; flex-basis: 100%; }
  .lf-bar-pos { flex: 1; }
  .overlay .panel.lf-panel { padding: 14px; max-height: 92vh; }
  .lf-row { padding: 10px 8px; }
  .lf-row .right { font-size: 10px; }
  .lf-actions button { min-height: 40px; }
}

.qtext { font-size: 17px; line-height: 1.55; margin: 10px 0 18px; white-space: pre-wrap; }
.options { display: flex; flex-direction: column; gap: 8px; }
.opt {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px;
  background: var(--bg-soft);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all .12s;
  user-select: none;
}
.opt:hover { border-color: var(--accent); }
.opt .letter {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--mono); font-weight: 800; font-size: 13px;
  flex-shrink: 0;
}
.opt .text { flex: 1; font-size: 14.5px; line-height: 1.45; }
.opt.selected { border-color: var(--accent); background: linear-gradient(135deg, rgba(108,141,255,.18), rgba(140,92,255,.10)); }
.opt.selected .letter { background: var(--accent); color: white; border-color: var(--accent); }
.opt.correct  { border-color: var(--ok); background: rgba(16,185,129,.10); }
.opt.correct .letter { background: var(--ok); color: white; border-color: var(--ok); }
.opt.wrong    { border-color: var(--bad); background: rgba(239,68,68,.10); }
.opt.wrong .letter { background: var(--bad); color: white; border-color: var(--bad); }
.opt.missed   { border-color: var(--warn); background: rgba(245,158,11,.10); border-style: dashed; }
.opt.missed .letter { background: var(--warn); color: white; border-color: var(--warn); }

.controls { margin-top: 18px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.controls .progress {
  flex: 1; min-width: 140px; height: 6px; background: var(--bg-soft); border-radius: 3px; overflow: hidden;
}
.controls .progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .25s; }
/* Button groups: invisible on desktop (one row, as before); on touch screens
   they become separate rows — see TOUCH UI below. */
.ctl-nav, .ctl-more { display: contents; }
.feedback { margin-top: 12px; padding: 10px 14px; border-radius: 10px; font-size: 14px; font-weight: 600; display: none; }
.feedback.show { display: block; }
.feedback.ok { background: rgba(16,185,129,.12); color: var(--ok); border: 1px solid var(--ok); }
.feedback.bad { background: rgba(239,68,68,.10); color: var(--bad); border: 1px solid var(--bad); }
.feedback.partial { background: rgba(245,158,11,.10); color: var(--warn); border: 1px solid var(--warn); }
.feedback small { display: block; margin-top: 4px; font-weight: 400; color: var(--text-dim); }
.prob-tag { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .02em; vertical-align: middle; background: rgba(245,158,11,.16); color: var(--warn); border: 1px solid var(--warn); }

/* ============== DYNAMIC ISLAND TIMER ============== */
#qe-island {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%) scale(.85);
  min-width: 180px; height: 42px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 21px; z-index: 9999;
  display: none; align-items: center; justify-content: center; padding: 0 18px;
  color: white; font-family: var(--sans); font-weight: 600; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
  transition: all .35s cubic-bezier(.4,0,.2,1);
  opacity: 0; pointer-events: none; user-select: none;
}
#qe-island.show { opacity: 1; transform: translateX(-50%) scale(1); display: flex; }
#qe-island.low { background: linear-gradient(135deg, #ef4444, #dc2626); }
#qe-island .num { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 30px; text-align: center; margin-left: 8px; }

@keyframes qe-pulse { 0%,100% { transform: translateX(-50%) scale(1); } 50% { transform: translateX(-50%) scale(1.06); } }
#qe-island.pulse { animation: qe-pulse 1s infinite; }

/* ============== TOAST ============== */
#qe-toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--panel); color: var(--text);
  border: 1.5px solid var(--accent);
  padding: 10px 16px; border-radius: 10px;
  z-index: 100000; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow);
  transform: translateX(420px); opacity: 0;
  transition: transform .3s, opacity .3s;
  max-width: 360px;
}
#qe-toast.show { transform: translateX(0); opacity: 1; }
#qe-toast.ok   { border-color: var(--ok); }
#qe-toast.warn { border-color: var(--warn); }
#qe-toast.bad  { border-color: var(--bad); }

/* ============== POMODORO ============== */
#qe-pomo {
  background: none; border: none; padding: 0;
  width: 34px; height: 34px; position: relative; cursor: pointer; flex-shrink: 0;
}
#qe-pomo svg { width: 100%; height: 100%; transform: rotate(-90deg); display: block; overflow: visible; }
#qe-pomo .pomo-text { font-family: var(--mono); font-weight: 700; }

/* ============== OVERLAYS ============== */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 200000; backdrop-filter: blur(6px);
  padding: 16px;
}
.overlay .panel {
  background: var(--panel); color: var(--text);
  border: 2px solid var(--accent); border-radius: 16px;
  padding: 22px; max-width: 640px; width: 100%; max-height: 88vh; overflow-y: auto;
  box-shadow: var(--shadow);
}
.overlay h3 { margin: 0 0 14px; font-size: 18px; border-bottom: 1.5px solid var(--accent); padding-bottom: 8px; }
.overlay .row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer; margin-bottom: 6px;
  transition: background .12s, border-color .12s;
}
.overlay .row:hover { background: var(--bg-soft); border-color: var(--accent); }
.overlay .row .num { font-family: var(--mono); color: var(--accent); font-weight: 700; min-width: 24px; }
.overlay .row .label { flex: 1; }
.overlay .row .right { color: var(--text-dim); font-family: var(--mono); font-size: 12px; }
.overlay table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 13px; }
.overlay table th, .overlay table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.overlay table tr.selected td { background: var(--bg-soft); }
.overlay .esc-hint { margin-top: 14px; text-align: center; color: var(--text-faint); font-size: 12px; }
.overlay .group-title { margin: 14px 0 6px; font-size: 12px; color: var(--accent); text-transform: uppercase; letter-spacing: .7px; }

.help-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; align-items: center; }
.help-grid .keys { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

/* ============== EMPTY STATE ============== */
.empty { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.empty .ico { font-size: 48px; margin-bottom: 10px; }

/* ============== MODE PILL ============== */
.mode-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px;
  background: var(--bg-soft); border: 1.5px solid var(--border);
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  color: var(--text); cursor: pointer; user-select: none;
  transition: all .12s;
}
.mode-pill:hover { border-color: var(--accent); }
.mode-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.mode-pill.exam { border-color: var(--warn); }
.mode-pill.exam .dot { background: var(--warn); }
.mode-pill .label { letter-spacing: .3px; }

/* ============== EXAM PICKER ============== */
.exam-picker {
  max-width: 900px; margin: 0 auto; padding: 16px;
}
.exam-picker .head {
  padding: 22px 24px; margin-bottom: 18px;
  background: linear-gradient(135deg, rgba(245,158,11,.15), rgba(239,68,68,.08));
  border: 1.5px solid var(--warn); border-radius: 16px;
}
.exam-picker .head h2 { margin: 0 0 6px; font-size: 22px; }
.exam-picker .head p { margin: 0; color: var(--text-dim); font-size: 13px; }
.exam-picker .head .hint { margin-top: 8px; font-family: var(--mono); font-size: 11px; color: var(--text-faint); }
.exam-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.exam-tile {
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px 16px;
  background: var(--panel); border: 1.5px solid var(--border); border-radius: 12px;
  cursor: pointer; transition: transform .12s, border-color .12s, box-shadow .12s;
  text-decoration: none; color: var(--text);
  position: relative;
}
.exam-tile:hover { transform: translateY(-2px); border-color: var(--warn); box-shadow: var(--shadow); text-decoration: none; }
.exam-tile.focused { outline: 2px solid var(--accent); outline-offset: 2px; }
.exam-tile .name { font-weight: 700; font-size: 15px; }
.exam-tile .meta { font-family: var(--mono); font-size: 12px; color: var(--text-dim); }
.exam-tile .num  { position: absolute; top: 8px; right: 12px; font-family: var(--mono); font-size: 11px; color: var(--accent); font-weight: 700; }
.exam-tile .status { font-family: var(--mono); font-size: 11px; margin-top: 4px; }
.exam-tile .status.done   { color: var(--ok); }
.exam-tile .status.draft  { color: var(--warn); }
.exam-tile .status.fresh  { color: var(--text-faint); }
.exam-tile .progress { height: 4px; background: var(--bg-soft); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.exam-tile .progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* ============== EXAM RUNNING — minimal feedback ============== */
.exam-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; margin-bottom: 12px;
  background: linear-gradient(135deg, rgba(245,158,11,.18), rgba(239,68,68,.10));
  border: 1.5px solid var(--warn); border-radius: 10px;
  font-family: var(--mono); font-size: 13px;
}
.exam-banner .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); animation: qe-blink 1.8s infinite; }
.exam-banner .label { font-weight: 700; }
.exam-banner .timer { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.exam-banner .timer.low { color: var(--bad); }
@keyframes qe-blink { 50% { opacity: .35; } }

/* ============== REVIEW SCREEN ============== */
.review-head {
  padding: 22px 24px; margin-bottom: 14px;
  background: linear-gradient(135deg, rgba(108,141,255,.15), rgba(140,92,255,.08));
  border: 1.5px solid var(--accent); border-radius: 16px;
  display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center;
}
.review-head h2 { margin: 0 0 4px; font-size: 22px; }
.review-head .sub { color: var(--text-dim); font-size: 13px; }
.review-head .score {
  text-align: right; font-family: var(--mono);
  font-size: 36px; font-weight: 800; line-height: 1;
}
.review-head .score small { display: block; font-size: 12px; opacity: .7; font-weight: 500; margin-top: 4px; }
.review-head .score.good { color: var(--ok); }
.review-head .score.mid { color: var(--warn); }
.review-head .score.bad { color: var(--bad); }
.review-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.review-item {
  background: var(--panel); border: 1.5px solid var(--border); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 10px;
  border-left-width: 4px;
}
.review-item.correct { border-left-color: var(--ok); }
.review-item.partial { border-left-color: var(--warn); }
.review-item.wrong   { border-left-color: var(--bad); }
.review-item.skipped { border-left-color: var(--text-faint); }
.review-item.unknown { border-left-color: var(--accent-2); }
/* Keyboard-focused correction card (↑↓ / J K). Hover gets the same hint so it's
   clear Alt+C will copy whichever card you're on. */
.review-item.focused { outline: 2px solid var(--accent); outline-offset: 2px; }
.review-item:hover { border-color: var(--accent); }
.review-item .ri-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.review-item .ri-head .ri-spacer { flex: 1 1 auto; }
.review-item .ri-head .ri-copy {
  font-family: var(--mono); font-size: 11px; font-weight: 700; line-height: 1.4;
  padding: 3px 9px; border-radius: 7px; cursor: pointer; white-space: nowrap;
  background: var(--bg-soft); border: 1.5px solid var(--border); color: var(--text-dim);
  transition: color .15s, border-color .15s;
}
.review-item .ri-head .ri-copy:hover { color: var(--text); border-color: var(--accent); }
.review-item .ri-head .ri-copy.copied { color: var(--ok); border-color: var(--ok); }
.review-item .ri-head .qn  { font-family: var(--mono); font-weight: 800; color: var(--accent); }
.review-item .ri-head .verdict { font-family: var(--mono); font-size: 12px; font-weight: 700; }
.review-item .ri-head .verdict.correct { color: var(--ok); }
.review-item .ri-head .verdict.partial { color: var(--warn); }
.review-item .ri-head .verdict.wrong   { color: var(--bad); }
.review-item .ri-head .verdict.skipped { color: var(--text-faint); }
.review-item .ri-head .verdict.unknown { color: var(--accent-2); }
.review-item .ri-head .topic { font-family: var(--mono); font-size: 11px; color: var(--text-dim); margin-left: auto; }
.review-item .ri-q { font-size: 14px; line-height: 1.5; margin: 4px 0 8px; white-space: pre-wrap; }
.review-item .ri-opts { display: flex; flex-direction: column; gap: 4px; }
.review-item .ri-opt {
  display: flex; gap: 8px; padding: 6px 10px; border-radius: 7px;
  background: var(--bg-soft); font-size: 13px; line-height: 1.4;
  border: 1px solid var(--border);
}
.review-item .ri-opt .letter { font-family: var(--mono); font-weight: 800; width: 18px; flex-shrink: 0; }
.review-item .ri-opt.correct  { background: rgba(16,185,129,.14); border-color: var(--ok); }
.review-item .ri-opt.correct .letter { color: var(--ok); }
.review-item .ri-opt.picked-wrong { background: rgba(239,68,68,.14); border-color: var(--bad); }
.review-item .ri-opt.picked-wrong .letter { color: var(--bad); }
.review-item .ri-opt.picked-correct { background: rgba(16,185,129,.22); border-color: var(--ok); font-weight: 600; }
.review-item .ri-opt.missed { border-style: dashed; }

.review-filters { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.review-filters .chip {
  padding: 4px 10px; border-radius: 999px; cursor: pointer; user-select: none;
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  background: var(--bg-soft); border: 1.5px solid var(--border); color: var(--text-dim);
}
.review-filters .chip:hover { color: var(--text); }
.review-filters .chip.active { color: var(--text); border-color: var(--accent); background: var(--bg-elev); }
.review-filters .chip[data-f="correct"].active { border-color: var(--ok); color: var(--ok); }
.review-filters .chip[data-f="wrong"].active   { border-color: var(--bad); color: var(--bad); }
.review-filters .chip[data-f="partial"].active { border-color: var(--warn); color: var(--warn); }

/* Exam-review footer: jump to the previous / next exam straight from the
   correction screen (shown only in exam-review). */
.review-nav {
  display: flex; align-items: stretch; gap: 12px;
  margin: 24px 0 8px; padding-top: 16px;
  border-top: 1.5px solid var(--border);
}
.review-nav .rn-btn {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; gap: 3px;
  padding: 10px 14px; text-align: left;
  background: var(--panel); border: 1.5px solid var(--border); border-radius: 12px;
}
.review-nav .rn-btn.rn-next { text-align: right; align-items: flex-end; }
.review-nav .rn-btn:not([disabled]):hover { border-color: var(--accent); background: var(--bg-elev); }
.review-nav .rn-btn[disabled] { opacity: .4; cursor: not-allowed; }
.review-nav .rn-btn .rn-dir {
  font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--text-dim);
}
.review-nav .rn-btn .rn-name {
  font-size: 14px; font-weight: 600; color: var(--text);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.review-nav .rn-pos {
  flex: 0 0 auto; align-self: center; white-space: nowrap;
  font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--text-dim);
}
@media (max-width: 560px) {
  .review-nav { flex-wrap: wrap; }
  .review-nav .rn-pos { order: -1; width: 100%; text-align: center; }
}

/* ============== AI REPORT PAGE ============== */
.report-hero h1 { font-size: 22px; }
.report-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  align-items: start;
}
.report-pick {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; position: sticky; top: 64px; max-height: calc(100vh - 96px); overflow-y: auto;
}
.report-pick .rp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.report-pick .rp-head h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-dim); }
.rp-bulk { display: flex; gap: 4px; }
.rp-bulk .mini, .report-toolbar .mini {
  font-size: 11px; padding: 3px 8px; background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-dim); cursor: pointer;
}
.rp-bulk .mini:hover { border-color: var(--accent); color: var(--text); }
.rp-sem { margin-bottom: 10px; }
.rp-sem-head { font-family: var(--mono); font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .6px; margin: 6px 2px 4px; }
.rp-mod {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px;
  cursor: pointer; font-size: 13px; transition: background .12s;
}
.rp-mod:hover { background: var(--bg-soft); }
.rp-mod input { width: 16px; height: 16px; accent-color: var(--accent); flex-shrink: 0; cursor: pointer; }
.rp-mod-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-mod-meta { font-family: var(--mono); font-size: 11px; color: var(--text-faint); flex-shrink: 0; }
.rp-mod-meta.has { color: var(--bad); font-weight: 700; }

.report-main { min-width: 0; }
.report-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 12px; position: sticky; top: 64px; z-index: 5;
}
.rt-summary { font-size: 14px; color: var(--text-dim); min-width: 0; }
.rt-summary b { color: var(--text); font-variant-numeric: tabular-nums; }
.rt-chars { font-family: var(--mono); font-size: 12px; color: var(--text-faint); }
.rt-actions { display: flex; gap: 8px; flex-shrink: 0; }
.report-output { display: flex; flex-direction: column; gap: 12px; }
.report-loading, .report-empty {
  padding: 40px 20px; text-align: center; color: var(--text-dim);
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
}
.report-empty .ico { font-size: 32px; margin-bottom: 8px; }
.report-empty small { color: var(--text-faint); }
.ro-plan { background: linear-gradient(135deg, rgba(108,141,255,.12), rgba(140,92,255,.07)); border: 1.5px solid var(--accent); border-radius: var(--radius); padding: 16px; }
.ro-plan-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ro-plan-head h3 { margin: 0; font-size: 16px; }
.ro-plan-badge { font-size: 11px; font-family: var(--mono); color: var(--text-faint); background: var(--bg-soft); border: 1px solid var(--border); border-radius: 999px; padding: 3px 9px; white-space: nowrap; }
.ro-plan-sub { margin: 6px 0 12px; color: var(--text-dim); font-size: 13px; }
.ro-plan-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ro-plan-list .pi { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; padding: 8px 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; border-left: 3px solid var(--border); }
.ro-plan-list .pi.gap   { border-left-color: var(--bad); }
.ro-plan-list .pi.close { border-left-color: var(--warn); }
.pi-rank { font-family: var(--mono); font-weight: 800; color: var(--accent); font-size: 15px; min-width: 18px; }
.pi-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pi-top { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.pi-count { font-family: var(--mono); font-size: 11px; color: var(--text-faint); }
.pi-action { font-size: 12.5px; color: var(--text-dim); }
.ro-plan-tips { margin-top: 12px; display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--text-dim); }
.ro-plan-tips b { color: var(--text); }
.ro-stats { background: var(--panel); border: 1px solid var(--accent); border-radius: var(--radius); padding: 14px; }
.ro-stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-bottom: 12px; }
.ro-stat { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; }
.ro-stat b { font-family: var(--mono); font-size: 22px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.ro-stat span { font-size: 11px; color: var(--text-faint); }
.ro-stat.bad b { color: var(--bad); }
.ro-stat.mid b { color: var(--warn); }
.ro-stats-lbl { font-size: 12px; font-weight: 700; color: var(--text-dim); margin-bottom: 8px; }
.ro-topic { display: grid; grid-template-columns: minmax(90px, 1fr) 2fr auto; gap: 10px; align-items: center; padding: 3px 0; font-size: 13px; }
.ro-topic .rt-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ro-topic .rt-bar { height: 8px; background: var(--bg-soft); border-radius: 4px; overflow: hidden; }
.ro-topic .rt-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--bad), var(--warn)); border-radius: 4px; }
.ro-topic .rt-n { font-family: var(--mono); font-weight: 800; color: var(--bad); font-variant-numeric: tabular-nums; }
.ro-stats-foot { margin-top: 10px; font-size: 11px; color: var(--text-faint); font-style: italic; }
.ro-mod { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.ro-mod.empty, .ro-mod.error { color: var(--text-faint); font-size: 13px; padding: 8px 12px; }
.ro-mod.error { color: var(--bad); }
.ro-mod-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 14px; }
.ro-mod-head span { font-family: var(--mono); font-size: 11px; color: var(--bad); }
.ro-item { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 5px 0; border-top: 1px solid var(--border); font-size: 13px; }
.ro-item .ro-qn { font-family: var(--mono); font-weight: 700; color: var(--text-dim); }
.ro-item.wrong .ro-qn { color: var(--bad); }
.ro-item.partial .ro-qn { color: var(--warn); }
.ro-item .ro-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-dim); }
.ro-item .ro-corr { font-family: var(--mono); font-size: 11px; color: var(--ok); flex-shrink: 0; }
.ro-more { font-size: 12px; color: var(--text-faint); padding-top: 6px; }

@media (max-width: 760px) {
  .report-grid { grid-template-columns: 1fr; }
  .report-pick { position: static; max-height: 320px; }
  .report-toolbar { position: sticky; top: 56px; }
  .ro-item { grid-template-columns: auto 1fr; }
  .ro-item .ro-corr { grid-column: 2; text-align: right; }
}

/* ============== UTIL ============== */
.hidden { display: none !important; }
.right { float: right; }

/* ============== HIGH-YIELD ANALYSIS PAGE ============== */
.hero-cta { display: flex; flex-wrap: wrap; gap: 8px; }
.report-link.alt { background: linear-gradient(135deg, rgba(16,185,129,.18), rgba(108,141,255,.10)); border-color: var(--ok); }
/* Android app only: "⬇ Mettre à jour l'app" (opens the latest APK in the browser). */
.report-link.app-update { background: linear-gradient(135deg, rgba(245,158,11,.18), rgba(108,141,255,.10)); border-color: var(--warn); }
.report-link .app-ver { font-family: var(--mono); font-size: 11px; color: var(--text-dim); margin-left: 4px; }
.hy-hero h1 { font-size: 22px; }
.hy-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.hy-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.hy-card.has { border-left: 3px solid var(--ok); }
.hy-card.empty { opacity: .72; border-style: dashed; }
.hy-title { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.hy-badge { font-family: var(--mono); font-size: 11px; font-weight: 800; color: var(--ok); background: rgba(16,185,129,.12); border-radius: 999px; padding: 1px 8px; }
.hy-meta { font-family: var(--mono); font-size: 11px; color: var(--text-faint); }
.hy-meta a { color: var(--accent); text-decoration: none; }
.hy-meta a:hover { text-decoration: underline; }
.hy-soon { margin-top: 4px; font-size: 12px; color: var(--text-faint); font-style: italic; }
.hy-docs { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.hy-doc { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
.hy-doc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.hy-doc-act { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }
.hy-doc-act .mini, .hy-prev {
  font-size: 11px; padding: 3px 9px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg-soft); color: var(--text-dim); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.hy-doc-act .mini:hover, .hy-prev:hover { border-color: var(--accent); color: var(--text); }
.hy-prev.on { border-color: var(--accent); color: var(--accent); background: rgba(108,141,255,.1); }
.hy-preview:empty { display: none; }
.hy-frame { width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: 10px; margin-top: 8px; background: #fff; }

/* ============== CURRICULUM PAGE (curriculum.html) ============== */
.cur-hero h1 { font-size: 22px; }
.cur-dl-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 14px; }
.cur-dl-bottom { justify-content: center; margin: 30px 0 12px; }
.cur-dl-all {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 18px; border-radius: 12px; font-weight: 700; font-size: 15px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  text-decoration: none; border: none; box-shadow: 0 4px 14px rgba(108,141,255,.3);
  transition: filter .12s, transform .08s;
}
.cur-dl-all:hover { filter: brightness(1.08); }
.cur-dl-all:active { transform: scale(.98); }
.cur-dl-all.disabled { opacity: .5; pointer-events: none; background: var(--bg-soft); color: var(--text-dim); box-shadow: none; }
.cur-tools { display: inline-flex; gap: 6px; }
.cur-tools .mini {
  font-size: 12px; padding: 5px 10px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--bg-soft); color: var(--text-dim); cursor: pointer;
}
.cur-tools .mini:hover { border-color: var(--accent); color: var(--text); }

.cur-year { margin-top: 26px; }
.cur-year-title {
  font-family: var(--mono); font-size: 13px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-dim);
  margin: 0 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.cur-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.cur-sem { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 10px 12px; }
.cur-sem.missing { border-style: dashed; }

.cur-sem-head {
  display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text);
  padding: 10px 8px; margin: 0 -2px; border-radius: 10px;
  position: sticky; top: 58px; z-index: 5; background: var(--panel);
  border-bottom: 1px solid var(--border);
}
a.cur-sem-head { cursor: pointer; }
a.cur-sem-head:hover { background: var(--bg-elev); }
a.cur-sem-head:hover .cur-sem-tag { color: var(--accent-2); }
.cur-sem-tag { font-family: var(--mono); font-weight: 800; font-size: 18px; color: var(--accent); }
.cur-sem-dl { color: var(--accent); font-size: 15px; opacity: .4; transition: opacity .15s, transform .15s; }
a.cur-sem-head:hover .cur-sem-dl,
a.cur-sem-head:focus-visible .cur-sem-dl { opacity: 1; transform: translateY(1px); }
.cur-sem-meta { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--text-dim); }
.cur-sem-head.is-missing .cur-sem-tag { color: var(--text-faint); }
.cur-empty { padding: 14px 10px; color: var(--text-dim); font-size: 13px; font-style: italic; }

.cur-list { list-style: none; margin: 0; padding: 0; }
.cur-list .cur-list { padding-left: 14px; margin: 2px 0 4px; border-left: 1px solid var(--border); }
.cur-leaf {
  position: relative; font-size: 13px; line-height: 1.5; color: var(--text-dim);
  padding: 2px 0 2px 16px;
}
.cur-leaf::before { content: "·"; position: absolute; left: 5px; color: var(--text-faint); font-weight: 700; }
.cur-branch > details > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  padding: 4px 6px; border-radius: 7px; font-size: 13.5px; font-weight: 600; color: var(--text);
}
.cur-branch > details > summary::-webkit-details-marker { display: none; }
.cur-branch > details > summary::before {
  content: "▸"; flex: 0 0 auto; color: var(--text-faint); font-size: 11px; transition: transform .12s;
}
.cur-branch > details[open] > summary::before { transform: rotate(90deg); }
.cur-branch > details > summary:hover { background: var(--bg-soft); }
.cur-d0 > .cur-branch > details > summary { font-size: 14.5px; font-weight: 700; }
.cur-name { flex: 1 1 auto; min-width: 0; }
.cur-count {
  flex: 0 0 auto; font-family: var(--mono); font-size: 11px; color: var(--text-dim);
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 999px; padding: 0 7px;
}

@media (max-width: 720px) {
  .cur-cols { grid-template-columns: 1fr; }
  .cur-sem-head { position: static; }
}

/* ============== RESPONSIVE: TABLET & MOBILE ============== */

/* Tablet & small laptop (≤ 900px): collapse the viewer to one column, let the
   sidebar sit on top as a horizontally-scrolling strip, ease the topbar. */
@media (max-width: 900px) {
  .viewer { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
  .sidebar { position: static; max-height: 32vh; }
  /* Stacked sidebar is full-width: pack the chips instead of 5 giant columns. */
  .sidebar .q-list { grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); }
  .topbar { gap: 8px; padding: 8px 12px; }
  .topbar .crumb { font-size: 12px; }
  .review-head { grid-template-columns: 1fr; }
  .review-head .score { text-align: left; }
}

/* Portrait tablets (≤ 1100px): the nav links + controls no longer fit on one
   line — wrap instead of overflowing off the right edge. */
@media (max-width: 1100px) {
  .topbar { flex-wrap: wrap; row-gap: 8px; }
}

/* Phone (≤ 600px): single-column everything, bigger tap targets, no hover-only
   reveals, wrap the topbar so its controls never overflow off-screen. */
@media (max-width: 600px) {
  .container { padding: 12px; }
  .hero { padding: 18px 16px; border-radius: 12px; }
  .hero h1 { font-size: 21px; }
  .hero .hint { display: none; }                 /* keyboard hints are desktop-only */

  /* Topbar: brand + actions wrap to a tidy second row instead of clipping. */
  .topbar { flex-wrap: wrap; row-gap: 8px; position: sticky; }
  .topbar .crumb { order: 5; flex-basis: 100%; }
  .topbar .spacer { display: none; }
  .topbar .search { width: 100%; order: 6; }
  .topbar button, .topbar .cmdk-btn { min-height: 38px; min-width: 38px; }

  /* Module grid → single column; bump card padding for thumbs. */
  .grid { grid-template-columns: 1fr; }
  .card { padding: 16px; }

  /* Viewer: roomy options with comfortable touch targets. */
  .qtext { font-size: 16px; }
  .opt { padding: 12px; gap: 12px; }
  .opt .letter { width: 30px; height: 30px; flex-shrink: 0; }
  .controls { gap: 6px; }
  .controls button { min-height: 40px; flex: 1 1 auto; }
  .controls .progress { order: 99; flex-basis: 100%; }

  /* Sidebar question chips: a touch larger so they're tappable. */
  .sidebar .q-list { grid-template-columns: repeat(6, 1fr); gap: 5px; }
  .sidebar .q-chip { height: 32px; font-size: 12px; }

  /* Exam mode + review fit a phone. */
  .exam-list { grid-template-columns: 1fr; }
  .exam-banner { flex-wrap: wrap; font-size: 12px; }
  .review-head { padding: 16px; }
  .review-head h2 { font-size: 19px; }

  /* Overlays (palette, settings, analysis) go near-fullscreen on phones. */
  .overlay { padding: 8px; align-items: flex-start; }
  .overlay .panel { max-height: 92vh; padding: 16px; }
  .cmdk-panel { max-width: 100%; }

  /* Report page tools stack and stay reachable. */
  .report-toolbar { flex-direction: column; align-items: stretch; }
  .rt-actions { justify-content: stretch; }
  .rt-actions button { flex: 1; min-height: 42px; }
}

/* Tiny phones (≤ 380px): trim the chrome a little more. */
@media (max-width: 380px) {
  .hero-stats { grid-template-columns: 1fr 1fr; }
  .sidebar .q-list { grid-template-columns: repeat(5, 1fr); }
  .topbar .brand span:not(.logo) { display: none; }   /* keep just the logo */
}

/* Coarse-pointer (touch) devices: kill hover lifts that "stick" after a tap,
   and guarantee a 40px minimum tap target on interactive bits. */
@media (hover: none) and (pointer: coarse) {
  .card:hover, .exam-tile:hover, .continue-tile:hover, .weak-item:hover,
  .report-link:hover { transform: none; }
  .opt, .q-chip, .exam-tile, .tab, .review-filters .chip { touch-action: manipulation; }
}

/* ============== TOUCH UI (html.touch-ui: phones, tablets, Android app) ============== */
/* Built against mis-taps (app.js sets the class). The buttons used on every
   question get their own big row; everything else — 🎯 Focus included — sits
   in a smaller row well below, out of reach of a thumb aiming for Next. (In
   1.3 🎯 Focus sat right under Next and got hit by mistake; 1.4 hid it; 1.5
   brought it back in this lower row.) */
html.touch-ui .controls { flex-direction: column; align-items: stretch; gap: 0; margin-top: 20px; }
html.touch-ui .controls .ctl-nav { order: 1; display: flex; gap: 14px; }
html.touch-ui .controls .ctl-nav button { flex: 1 1 0; min-height: 52px; font-size: 16px; }
html.touch-ui .controls .ctl-nav #btn-check { flex-grow: 2; }
html.touch-ui .controls .progress { order: 2; flex: 0 0 6px; min-width: 0; margin-top: 14px; }
html.touch-ui .controls .ctl-more {
  order: 3; display: flex; flex-wrap: wrap; justify-content: center; gap: 12px;
  margin-top: 30px; padding-top: 14px; border-top: 1px dashed var(--border);
}
html.touch-ui .controls .ctl-more button { flex: 0 1 auto; min-height: 40px; min-width: 64px; font-size: 13px; }
html.touch-ui .focus-exit { min-height: 36px; padding: 6px 12px; }
html.touch-ui.focus-mode .qhead { padding-right: 96px; }   /* keep the topic tag clear of the floating ✕ Focus */
html.touch-ui.focus-mode .hero > h1, html.touch-ui.focus-mode .hero > p { padding-right: 92px; }   /* same, dashboard */

/* ============== ACCESSIBILITY & READABILITY ============== */
/* Visible keyboard focus everywhere (mouse clicks stay clean via :focus-visible). */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
.opt:focus-visible, .card:focus-visible, .exam-tile:focus-visible,
.q-chip:focus-visible, .cmdk-item:focus-visible, .reminder:focus-visible,
.analysis-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }
/* Cap line length on long-form text so it stays readable on wide screens. */
.qtext { max-width: 72ch; }
.options { max-width: 880px; }
/* Respect reduced-motion: speed > effects. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============== COMMAND PALETTE (⌘K) ============== */
.cmdk-btn { display: inline-flex; align-items: center; gap: 2px; padding: 5px 8px; }
.cmdk-btn kbd { min-width: 0; padding: 0 4px; border-bottom-width: 2px; font-size: 11px; }
.overlay.cmdk { align-items: flex-start; padding-top: 11vh; }
.cmdk-panel { max-width: 600px; padding: 0; overflow: hidden; }
.cmdk-input-wrap { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.cmdk-prompt { font-family: var(--mono); font-weight: 800; color: var(--accent); font-size: 12px; background: var(--bg-soft); padding: 3px 7px; border-radius: 6px; }
.cmdk-input { flex: 1; background: transparent; border: none; outline: none; color: var(--text); font-family: var(--sans); font-size: 16px; }
.cmdk-input::placeholder { color: var(--text-faint); }
.cmdk-list { max-height: 52vh; overflow-y: auto; padding: 6px; }
.cmdk-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; cursor: pointer; }
.cmdk-item .ci-ico { width: 22px; text-align: center; font-size: 15px; flex-shrink: 0; }
.cmdk-item .ci-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cmdk-item .ci-title { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-item .ci-sub { font-family: var(--mono); font-size: 11px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-item .ci-tag { font-family: var(--mono); font-size: 10px; color: var(--text-faint); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; flex-shrink: 0; }
.cmdk-item kbd { flex-shrink: 0; }
.cmdk-item.sel { background: var(--bg-elev); box-shadow: inset 0 0 0 1.5px var(--accent); }
.cmdk-empty { padding: 26px; text-align: center; color: var(--text-faint); font-size: 13px; }
.cmdk-foot { padding: 8px 14px; border-top: 1px solid var(--border); font-family: var(--mono); font-size: 11px; color: var(--text-faint); display: flex; gap: 6px; align-items: center; }

/* ============== FOCUS MODE (distraction-free) ============== */
html.focus-mode .topbar,
html.focus-mode .sidebar,
html.focus-mode #qe-island,
html.focus-mode .qhead .qexam,
html.focus-mode .controls #btn-toggle-side,
html.focus-mode .controls #btn-loadout,
html.focus-mode .controls #btn-mod { display: none !important; }
html.focus-mode .viewer { grid-template-columns: 1fr; max-width: 800px; padding-top: 30px; }
html.focus-mode .qpane { border: none; background: transparent; min-height: 84vh; padding-top: 6px; }
html.focus-mode .qtext { font-size: 19px; }
.focus-exit {
  display: none; position: fixed; top: 12px; right: 14px; z-index: 99998;
  align-items: center; gap: 6px; font-family: var(--mono); font-size: 12px;
  background: var(--panel); border: 1px solid var(--border); color: var(--text-dim);
}
.focus-exit:hover { border-color: var(--accent); color: var(--text); }
html.focus-mode .focus-exit { display: inline-flex; }

/* ============== STUDY COACH ============== */
#qe-coach:empty { display: none; }
.coach { display: grid; grid-template-columns: 230px 1fr; gap: 12px; margin: 4px 0 0; }
.coach-trend, .coach-reminders { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.coach-trend { display: flex; flex-direction: column; gap: 8px; }
.coach-trend .ct-top { display: flex; align-items: baseline; gap: 6px; }
.coach-trend .ct-streak { font-family: var(--mono); font-weight: 800; font-size: 24px; color: var(--warn); font-variant-numeric: tabular-nums; }
.coach-trend .ct-lbl { font-size: 12px; color: var(--text-dim); }
.coach-trend .spark { display: flex; align-items: flex-end; gap: 3px; height: 46px; }
.coach-trend .spark .sp { flex: 1; background: linear-gradient(180deg, var(--accent), var(--accent-2)); border-radius: 2px 2px 0 0; min-height: 4px; }
.coach-trend .spark .sp.empty { background: var(--bg-soft); padding: 0; }   /* not the generic .empty state box */
.coach-trend .ct-foot { font-family: var(--mono); font-size: 11px; color: var(--text-faint); }
.coach-reminders h4 { margin: 0 0 8px; font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .7px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.coach-reminders h4 a { font-size: 11px; text-transform: none; letter-spacing: 0; white-space: nowrap; }
.reminders { display: flex; flex-direction: column; gap: 6px; }
.reminder { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; background: var(--bg-soft); border: 1px solid var(--border); color: var(--text); font-size: 13px; text-decoration: none; transition: border-color .12s, transform .08s; }
a.reminder:hover { border-color: var(--accent); text-decoration: none; transform: translateX(2px); }
.reminder .rm-ico { flex-shrink: 0; }
.reminder .rm-text { flex: 1; }
.reminder .rm-text b { color: var(--text); font-weight: 700; }
.reminder .rm-go { color: var(--accent); font-weight: 700; }
.reminder.weak { border-left: 3px solid var(--bad); }
.reminder.module { border-left: 3px solid var(--warn); }
.reminder.stale { border-left: 3px solid var(--accent-2); }
.reminder.streak { border-left: 3px solid var(--warn); }
.reminder.strength { border-left: 3px solid var(--ok); }
@media (max-width: 700px) { .coach { grid-template-columns: minmax(0, 1fr); } }
.coach > * { min-width: 0; }   /* long reminder text must wrap, not widen the page */

/* ============== ANALYSIS REMINDERS BAND ============== */
.analysis-reminders { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.analysis-reminders .ana-rem { font-size: 12px; padding: 4px 9px; border-radius: 999px; background: var(--bg-soft); border: 1px solid var(--border); color: var(--text-dim); }
.analysis-reminders .ana-rem b { color: var(--text); }

/* ============== MODULE ERROR REPORT (overlay) ============== */
.report-panel .report-loading,
.report-panel .report-error { padding: 20px; text-align: center; color: var(--text-dim); line-height: 1.6; }
.report-panel .report-error { color: var(--bad); }
.report-summary { display: flex; gap: 10px; margin-bottom: 14px; }
.report-summary .rs-stat { flex: 1; text-align: center; padding: 10px 8px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; }
.report-summary .rs-stat b { display: block; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.report-summary .rs-stat span { font-size: 11px; color: var(--text-dim); font-family: var(--mono); }
.report-summary .rs-stat.bad b { color: var(--bad); }
.report-summary .rs-stat.mid b { color: var(--warn); }
.report-note { font-size: 13px; color: var(--text-dim); margin-bottom: 10px; line-height: 1.5; }
.report-note code { font-family: var(--mono); background: var(--bg-soft); padding: 1px 5px; border-radius: 4px; }
.report-empty { padding: 22px; text-align: center; color: var(--text-dim); line-height: 1.6; }
.report-preview { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; margin-bottom: 14px; }
.report-preview .rp-item { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-soft); font-size: 12px; }
.report-preview .rp-item.wrong { border-left: 3px solid var(--bad); }
.report-preview .rp-item.partial { border-left: 3px solid var(--warn); }
.report-preview .rp-qn { font-family: var(--mono); font-weight: 700; color: var(--accent); }
.report-preview .rp-text { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.report-preview .rp-corr { font-family: var(--mono); color: var(--ok); white-space: nowrap; }
.report-preview .rp-pick { font-family: var(--mono); color: var(--bad); white-space: nowrap; }
.report-preview .rp-more { text-align: center; font-size: 12px; color: var(--text-faint); padding: 4px; }
.report-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.report-actions .rep-danger { border-color: var(--bad); color: var(--bad); }
.report-actions .rep-danger:hover { background: var(--bad); color: #fff; border-color: var(--bad); }
.report-actions .rep-danger.armed { background: var(--bad); color: #fff; border-color: var(--bad); animation: qe-armed-pulse .8s ease-in-out infinite; }
.report-actions button:disabled { opacity: .45; cursor: not-allowed; }
.report-actions button:disabled:hover { background: var(--bg-soft); border-color: var(--border); filter: none; }

/* ============== EXAM VERDICT + ANSWER SHEET (FMPM) ============== */
.exam-verdict { display: flex; align-items: center; gap: 16px; padding: 14px 18px; border-radius: 12px; margin: 14px 0; border: 1.5px solid var(--border); }
.exam-verdict.ok { background: rgba(16,185,129,.10); border-color: var(--ok); }
.exam-verdict.no { background: rgba(239,68,68,.08); border-color: var(--bad); }
.exam-verdict .ev-grade { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; white-space: nowrap; }
.exam-verdict.ok .ev-grade { color: var(--ok); }
.exam-verdict.no .ev-grade { color: var(--bad); }
.exam-verdict .ev-grade small { font-size: 15px; opacity: .7; font-weight: 600; }
.exam-verdict .ev-title { font-weight: 800; font-size: 17px; }
.exam-verdict .ev-sub { font-size: 12.5px; color: var(--text-dim); font-family: var(--mono); margin-top: 3px; }

.answer-sheet { margin: 8px 0 18px; }
.answer-sheet .as-paper { position: relative; overflow: hidden; background: var(--bg-soft); border: 1.5px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.answer-sheet .as-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; border-bottom: 1.5px solid var(--border); padding-bottom: 10px; margin-bottom: 12px; position: relative; }
.answer-sheet .as-univ { font-size: 12.5px; line-height: 1.5; color: var(--text); }
.answer-sheet .as-fields { font-size: 12px; font-family: var(--mono); color: var(--text-dim); display: flex; flex-direction: column; gap: 2px; text-align: right; }
.answer-sheet .as-fields span { color: var(--text-faint); }
.answer-sheet .as-stamp { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-11deg); font-size: 24px; font-weight: 800; letter-spacing: 3px; color: rgba(239,68,68,.18); border: 3px solid rgba(239,68,68,.18); padding: 2px 12px; border-radius: 6px; pointer-events: none; white-space: nowrap; }
.answer-sheet .as-grids { display: flex; gap: 18px; flex-wrap: wrap; }
.answer-sheet .as-col { flex: 1; min-width: 220px; }
.answer-sheet .as-table { width: 100%; border-collapse: separate; border-spacing: 3px; font-family: var(--mono); }
.answer-sheet .as-table th { color: var(--text-faint); font-weight: 700; font-size: 11px; text-align: center; padding: 0 0 2px; }
.answer-sheet .as-qn { text-align: left; color: var(--text-dim); font-size: 11px; padding-right: 6px; white-space: nowrap; }
.answer-sheet .as-cell { width: 24px; height: 19px; border: 1px solid var(--border); border-radius: 4px; color: transparent; font-weight: 800; font-size: 12px; line-height: 1; text-align: center; vertical-align: middle; }
.answer-sheet .as-cell.na { border-style: dashed; opacity: .35; }
.answer-sheet .as-cell.picked { border-color: var(--accent); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.answer-sheet .as-cell.got { background: var(--ok); border-color: var(--ok); color: #fff; }
.answer-sheet .as-cell.missed { border-color: var(--ok); color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok); }
.answer-sheet .as-cell.wrong { background: var(--bad); border-color: var(--bad); color: #fff; }
.answer-sheet .as-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 14px; font-size: 11.5px; font-family: var(--mono); color: var(--text-dim); }
.answer-sheet .as-legend .lg::before { content: ''; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -2px; box-sizing: border-box; }
.answer-sheet .as-legend .lg.got::before { background: var(--ok); }
.answer-sheet .as-legend .lg.missed::before { border: 2px solid var(--ok); }
.answer-sheet .as-legend .lg.wrong::before { background: var(--bad); }
@media (max-width: 560px) { .answer-sheet .as-grids { flex-direction: column; } .exam-verdict { flex-wrap: wrap; gap: 10px; } }
.analysis-bar .tab[data-tab="strengths"].active { border-color: var(--ok); }

/* ============== PLAYLIST FMPM PAGE ============== */
.pl-hero h1 { font-size: 22px; }
.pl-hero p { line-height: 1.6; }
.pl-table {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 20px;
  background: var(--panel);
}
.pl-row {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.pl-row:last-child { border-bottom: none; }
html:not(.light) .pl-row:nth-child(even) { background: rgba(255,255,255,.02); }
html.light .pl-row:nth-child(even) { background: rgba(0,0,0,.018); }
.pl-sem {
  flex-shrink: 0;
  font-family: var(--mono);
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  background: linear-gradient(135deg, #e06010, #c84000);
  padding: 3px 9px;
  border-radius: 6px;
  text-align: center;
  min-width: 36px;
  align-self: flex-start;
  margin-top: 2px;
}
.pl-modules {
  flex: 1;
  font-size: 13.5px;
  line-height: 1.75;
}
.pl-dot { color: var(--text-faint); }
.pl-bar {
  color: var(--border);
  margin: 0 8px;
  font-weight: 300;
}
.pl-link {
  color: var(--link);
  text-decoration: none;
  transition: color .12s;
}
.pl-link:hover { color: var(--accent); text-decoration: underline; }
.pl-teams-link { color: var(--accent-2); }
.pl-teams-link:hover { color: var(--accent); }
.pl-tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  border-radius: 4px;
  padding: 0 5px;
  margin-left: 4px;
  vertical-align: middle;
  letter-spacing: .2px;
  line-height: 1.6;
}
.pl-tag.yt  { color: #ff4040; background: rgba(255,64,64,.12); border: 1px solid rgba(255,64,64,.3); }
.pl-tag.tms { color: var(--accent-2); background: rgba(140,92,255,.12); border: 1px solid rgba(140,92,255,.3); }
.pl-badge-row {
  display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px;
}
.pl-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  padding: 4px 10px; border-radius: 7px;
  border: 1px solid var(--border); color: var(--text-dim);
}
.pl-badge.yt    { color: #ff4040; border-color: rgba(255,64,64,.4); background: rgba(255,64,64,.08); }
.pl-badge.drive { color: #1a73e8; border-color: rgba(26,115,232,.4); background: rgba(26,115,232,.08); }
.pl-nolink { color: var(--text-dim); font-style: italic; }
.pl-backup {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}
.pl-backup-main { flex: 1 1 320px; min-width: 0; }
.pl-backup-title {
  margin: 0 0 6px;
  font-size: 14.5px;
  font-weight: 800;
}
.pl-backup-desc {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-dim);
}
.pl-backup-desc code {
  font-family: var(--mono);
  font-size: .95em;
}
.pl-backup-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  flex-shrink: 0;
}
.pl-backup-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 8px;
  text-decoration: none;
  color: #1a73e8;
  border: 1px solid rgba(26,115,232,.4);
  background: rgba(26,115,232,.08);
  transition: background .12s, border-color .12s;
}
.pl-backup-btn:hover {
  background: rgba(26,115,232,.16);
  border-color: rgba(26,115,232,.65);
}
.pl-backup-alt {
  font-size: 11.5px;
  text-align: center;
  color: var(--text-faint);
  text-decoration: none;
}
.pl-backup-alt:hover { color: var(--link); text-decoration: underline; }
.pl-foot {
  margin-top: 20px;
  padding-bottom: 8px;
  text-align: right;
  color: var(--text-faint);
  font-style: italic;
  font-size: 12px;
  font-family: var(--mono);
}
@media (max-width: 600px) {
  .pl-row { gap: 10px; padding: 10px 12px; flex-wrap: wrap; }
  .pl-sem { font-size: 11px; padding: 2px 7px; min-width: 30px; align-self: auto; margin-top: 0; }
  .pl-modules { font-size: 12.5px; flex-basis: 100%; }
  .pl-backup { padding: 14px; gap: 14px; }
  .pl-backup-actions { width: 100%; }
}

/* ============== DATA / USEFUL LINKS PAGE (data.html) ============== */
.dl-hero h1 { font-size: 22px; }
.dl-hero p { line-height: 1.6; }
.dl-group { margin-top: 26px; }
.dl-group-title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 800;
}
.dl-group-note {
  margin: 0 0 12px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-dim);
}
.dl-cards { display: flex; flex-direction: column; gap: 10px; }
.dl-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  transition: border-color .12s;
}
.dl-card:hover { border-color: var(--accent); }
.dl-card-main { flex: 1 1 320px; min-width: 0; }
.dl-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dl-title {
  font-size: 14.5px;
  font-weight: 800;
  color: var(--link);
  text-decoration: none;
}
.dl-title:hover { color: var(--accent); text-decoration: underline; }
.dl-tag {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .3px;
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--accent-2);
  background: rgba(140,92,255,.12);
  border: 1px solid rgba(140,92,255,.3);
}
.dl-desc {
  margin: 5px 0 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-dim);
}
.dl-url {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dl-card-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  flex-shrink: 0;
}
.dl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 8px;
  text-decoration: none;
  color: #1a73e8;
  border: 1px solid rgba(26,115,232,.4);
  background: rgba(26,115,232,.08);
  transition: background .12s, border-color .12s;
}
.dl-btn:hover {
  background: rgba(26,115,232,.16);
  border-color: rgba(26,115,232,.65);
}
.dl-copy {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border);
  transition: color .12s, border-color .12s;
}
.dl-copy:hover { color: var(--link); border-color: var(--accent); }
.dl-copy.done { color: var(--ok); border-color: var(--ok); }
.dl-alt {
  font-size: 11.5px;
  text-align: center;
  color: var(--text-faint);
  text-decoration: none;
}
.dl-alt:hover { color: var(--link); text-decoration: underline; }
.dl-foot {
  margin-top: 24px;
  padding-bottom: 8px;
  text-align: right;
  color: var(--text-faint);
  font-style: italic;
  font-size: 12px;
  font-family: var(--mono);
}
@media (max-width: 600px) {
  .dl-card { gap: 12px; padding: 12px; }
  .dl-card-actions { flex-direction: row; flex-wrap: wrap; width: 100%; }
  .dl-btn, .dl-copy { flex: 1 1 auto; }
  .dl-alt { flex-basis: 100%; text-align: left; }
}
.dl-tag.yt {
  color: #ff4040;
  background: rgba(255,64,64,.12);
  border-color: rgba(255,64,64,.3);
}

/* ===== Planner page ===== */
.pl-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-top: 18px;
}
.pl-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.pl-card-head h2 { margin: 0; font-size: 16px; }
.pl-sub { color: var(--text-faint); font-size: 12px; font-family: var(--mono); }

/* Activity calendar heatmap */
.cal-heatmap { display: grid; grid-auto-rows: 12px; gap: 3px; overflow-x: auto; padding-top: 16px; }
.cal-month { font-size: 10px; color: var(--text-faint); grid-row: 1; align-self: end; margin-bottom: 2px; }
.cal-cell { width: 12px; height: 12px; border-radius: 3px; background: var(--bg-soft); border: 1px solid var(--border); }
.cal-cell.lvl-future { background: transparent; border-color: transparent; }
.cal-cell.lvl0 { background: var(--bg-soft); }
.cal-cell.lvl1 { background: color-mix(in srgb, var(--accent) 25%, var(--bg-soft)); border-color: transparent; }
.cal-cell.lvl2 { background: color-mix(in srgb, var(--accent) 50%, var(--bg-soft)); border-color: transparent; }
.cal-cell.lvl3 { background: color-mix(in srgb, var(--accent) 75%, var(--bg-soft)); border-color: transparent; }
.cal-cell.lvl4 { background: var(--accent); border-color: transparent; }
.cal-legend { display: flex; align-items: center; gap: 4px; margin-top: 10px; font-size: 11px; color: var(--text-faint); }
.cal-legend .cal-cell { width: 10px; height: 10px; }

/* Module × semester heatmap */
.mxs-heatmap { display: flex; flex-direction: column; gap: 8px; }
.mxs-row { display: flex; align-items: center; gap: 10px; }
.mxs-sem { width: 42px; flex-shrink: 0; font-family: var(--mono); font-size: 11px; color: var(--text-faint); font-weight: 700; }
.mxs-cells { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.mxs-cell {
  display: flex; flex-direction: column; gap: 2px; min-width: 130px; flex: 1 1 130px;
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); text-decoration: none;
  background: color-mix(in srgb, var(--bad) calc(var(--heat, 0) * 65%), var(--bg-soft));
  transition: border-color .12s;
}
.mxs-cell:hover { border-color: var(--accent); text-decoration: none; }
.mxs-cell.unstarted { background: var(--bg-soft); opacity: .6; }
.mxs-name { font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mxs-meta { font-family: var(--mono); font-size: 11px; color: var(--text-dim); }

/* Daily scheduler */
.pl-goal {
  padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-soft);
  font-size: 13px; margin-bottom: 12px;
}
.pl-goal.done { border-color: var(--ok); color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--bg-soft)); }
.pl-picks { display: flex; flex-direction: column; gap: 8px; }
.pl-pick {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  border: 1.5px solid var(--accent); text-decoration: none; color: var(--text);
}
.pl-pick:hover { background: var(--bg-soft); text-decoration: none; }
.pl-pick-sem { font-family: var(--mono); font-size: 11px; color: var(--text-faint); flex-shrink: 0; }
.pl-pick-name { flex: 1; font-weight: 600; }
.pl-pick-go { color: var(--accent); font-size: 12px; font-weight: 700; flex-shrink: 0; }
.pl-empty { color: var(--text-faint); font-size: 13px; padding: 8px 0; }
.pl-focus { margin-top: 14px; }
.pl-focus summary { cursor: pointer; font-size: 12px; color: var(--text-dim); }
.pl-focus-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px; margin-top: 10px; }
.pl-focus-item { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.pl-focus-item:hover { background: var(--bg-soft); }
.pl-focus-item input { accent-color: var(--accent); }

/* Data health */
.pl-health { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 10px; }
.pl-health-stat { font-size: 13px; color: var(--text-dim); }
.pl-health-stat b { color: var(--text); }
.pl-health-warn { flex-basis: 100%; color: var(--warn); font-size: 12px; }
.pl-health-warn code { font-family: var(--mono); background: var(--bg-soft); padding: 1px 5px; border-radius: 4px; }
#pl-export {
  font-size: 12px; padding: 6px 12px; background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-dim); cursor: pointer;
}
#pl-export:hover { border-color: var(--accent); color: var(--text); }
@media (max-width: 600px) {
  .mxs-row { flex-direction: column; align-items: stretch; }
  .mxs-sem { width: auto; }
}
