:root {
  --bg: #f6f5f1;
  --panel: #ffffff;
  --panel-2: #f0eee8;
  --ink: #1f2328;
  --ink-2: #57606a;
  --ink-3: #8c959f;
  --line: #e3e0d8;
  --accent: #2f6f5e;
  --accent-ink: #ffffff;
  --accent-soft: #e2efe9;
  --good: #1f7a4a;
  --good-soft: #e3f3ea;
  --bad: #b3261e;
  --bad-soft: #fbe9e7;
  --warn: #9a6700;
  --warn-soft: #fff4d6;
  --key: #8a5300;
  --say: rgba(255, 196, 0, .38);
  --high: #b3261e;
  --med: #9a6700;
  --low: #3d7a3d;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 6px 24px rgba(0,0,0,.06);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a; --panel: #1d2024; --panel-2: #24282d; --ink: #e6e8eb; --ink-2: #a8b0b9; --ink-3: #6f7882;
    --line: #2f343a; --accent: #5fb39a; --accent-ink: #0d1f1a; --accent-soft: #1f332d;
    --good: #5cc28a; --good-soft: #1b3226; --bad: #f08a80; --bad-soft: #3a2120; --warn: #e0b34f; --warn-soft: #3a3020; --key: #e3b867; --say: rgba(227, 184, 103, .32);
    --high: #f08a80; --med: #e0b34f; --low: #8fcf8f; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 24px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

#app { display: grid; grid-template-columns: 250px 1fr; height: 100vh; }

/* ---------- sidebar ---------- */
#sidebar {
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 12px; gap: 4px; overflow-y: auto;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 16px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 700; letter-spacing: .5px;
}
.brand-name { font-weight: 700; }
.brand-sub { font-size: 12px; color: var(--ink-3); }
.side-label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); padding: 8px 10px 4px; }
.side-item, .side-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
  padding: 9px 10px; border-radius: 8px; border: 0; background: none; cursor: pointer; text-align: left;
}
.side-item:hover, .side-btn:hover { background: var(--panel-2); }
.side-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-btn { color: var(--ink-2); }
.side-spacer { flex: 1; }
.dot-today { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); }
.count { font-size: 12px; color: var(--ink-3); }

/* ---------- main ---------- */
#main { overflow-y: auto; padding: 28px 36px 60px; }
.page { max-width: 1040px; margin: 0 auto; }
h1 { font-size: 26px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; color: var(--ink-3); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.mt { margin-top: 16px; } .mt-lg { margin-top: 28px; }

.btn {
  border: 1px solid var(--line); background: var(--panel); padding: 9px 16px; border-radius: 9px;
  cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: none; }
.btn.big { padding: 13px 22px; font-size: 16px; border-radius: 11px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font-weight: 600; }

input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 8px 10px; width: 100%;
}
textarea { resize: vertical; min-height: 120px; font-family: Consolas, monospace; font-size: 12.5px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2); }

.stat { display: flex; flex-direction: column; }
.stat b { font-size: 24px; white-space: nowrap; }
.stat span { font-size: 12px; color: var(--ink-3); }

.chip { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.chip.High { background: var(--bad-soft); color: var(--high); }
.chip.Medium { background: var(--warn-soft); color: var(--med); }
.chip.Low { background: var(--good-soft); color: var(--low); }
.chip.core { background: var(--accent-soft); color: var(--accent); }
.chip.supporting { background: var(--panel-2); color: var(--ink-2); }
.chip.ok { background: var(--good-soft); color: var(--good); }
.chip.err { background: var(--bad-soft); color: var(--bad); }
.chip.wait { background: var(--warn-soft); color: var(--warn); }

.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-top: 1px solid var(--line); }
.list-row:first-child { border-top: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* ⋮ menu on the left of a material row */
.row-menu { position: relative; flex: none; }
.menu-btn { width: 34px; height: 34px; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--ink-2);
  font-size: 20px; line-height: 1; cursor: pointer; }
.menu-btn:hover, .menu-btn.open { background: var(--panel-2); border-color: var(--line); color: var(--ink); }
.menu-pop { position: absolute; top: 38px; right: 0; z-index: 30; min-width: 250px; padding: 6px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: 0 12px 32px rgba(0, 0, 0, .28);
  display: flex; flex-direction: column; animation: fade .12s ease; }
.menu-pop.hidden { display: none; }
.menu-item { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; border-radius: 7px; background: none;
  color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap; }
.menu-item:hover, .menu-item:focus-visible { background: var(--panel-2); outline: none; }
.menu-item.danger { color: var(--bad); }
.menu-sep { height: 1px; background: var(--line); margin: 4px 6px; }

.progress { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }

.notice { padding: 12px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 14px; }
.notice.good { background: var(--good-soft); color: var(--good); }
.notice.info { background: var(--accent-soft); color: var(--accent); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }

.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--ink-2);
}
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }

.empty { text-align: center; padding: 60px 20px; color: var(--ink-2); }
.empty .big-emoji { font-size: 44px; }

/* ---------- study session (full screen) ---------- */
#session { position: fixed; inset: 0; background: var(--bg); z-index: 50; display: flex; flex-direction: column; }
.s-top {
  display: flex; align-items: center; gap: 14px; padding: 12px 24px; background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.s-top .grow { flex: 1; min-width: 0; }
.s-body { flex: 1; overflow-y: auto; padding: 28px 24px 80px; }
.s-inner { max-width: 820px; margin: 0 auto; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px; padding: 4px 12px; border-radius: 8px; background: var(--panel-2); }
.timer.low { background: var(--bad-soft); color: var(--bad); }
.phase { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); font-weight: 700; }

.keypoints li { margin: 6px 0; }
.keypoints .kp-core::marker { color: var(--accent); }
.reader { font-size: 16.5px; line-height: 1.75; }
.reader .seg { margin: 0 0 22px; }
.reader .ref { font-size: 12px; font-weight: 700; color: var(--accent); letter-spacing: .04em; text-transform: uppercase;
  border-bottom: 1px solid var(--line); padding-bottom: 4px; margin-bottom: 8px; }
.reader p { margin: 0 0 10px; white-space: pre-wrap; }
/* easier reading: calm colors with good contrast in light and dark mode */
.reader-top { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between;
  font-size: 13px; color: var(--ink-3); margin: -4px 0 16px; padding-bottom: 10px; border-bottom: 1px dashed var(--line); }
.reader-top .legend b { font-weight: 700; }
.reader-top .legend .t-num { color: var(--ink); }
.t-def { color: var(--accent); font-weight: 700; }
.t-key { color: var(--key); font-weight: 700; }
.t-num { font-weight: 700; }
.reader.plain .t-def, .reader.plain .t-key, .reader.plain .t-num { color: inherit; font-weight: inherit; }
/* a word lights up softly when the teacher says it, then fades */
.t-def, .t-key { border-radius: 4px; }
.say { animation: say 2s ease-out; }
@keyframes say {
  0% { background: var(--say); box-shadow: 0 0 0 3px var(--say); }
  60% { background: var(--say); box-shadow: 0 0 0 3px var(--say); }
  100% { background: transparent; box-shadow: 0 0 0 3px transparent; }
}
.r-h { font-weight: 700; font-size: 17px; letter-spacing: .02em; margin: 16px 0 8px; color: var(--ink); }
.seg-text > .r-h:first-child { margin-top: 4px; }
.r-list { margin: 0 0 12px; padding-left: 24px; }
.r-list li { margin: 0 0 6px; padding-left: 2px; }
.r-list li::marker { color: var(--accent); }
/* text the app read inside a picture: folded, so it does not repeat what the picture already shows */
.pic-text { margin: 4px 0 12px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: var(--panel-2); }
.pic-text summary { cursor: pointer; font-size: 14px; color: var(--ink-2); font-weight: 600; }
.pic-text[open] summary { margin-bottom: 8px; }
.pic-text p { font-size: 15px; }
.pic-table { overflow-x: auto; margin: 0 0 10px; }
.pic-table table { border-collapse: collapse; font-size: 14.5px; line-height: 1.45; }
.pic-table th, .pic-table td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; vertical-align: top; }
.pic-table th { background: var(--panel); font-weight: 700; }
.reader img { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); margin-bottom: 10px; }
.reader .figures { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 6px; }
.reader .figure { max-height: 420px; object-fit: contain; background: #fff; cursor: zoom-in; }

.q-card { padding: 28px; }
.q-text { font-size: 20px; font-weight: 600; line-height: 1.45; margin: 8px 0 22px; }
.q-pic { margin: -8px 0 18px; text-align: center; }
.q-pic img { max-width: 100%; max-height: 340px; object-fit: contain; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; cursor: zoom-in; display: block; margin: 0 auto 4px; }
.q-pic.small { margin: 6px 0 10px; text-align: left; }
.q-pic.small img { max-height: 180px; margin: 0; cursor: default; }
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice {
  text-align: left; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
  cursor: pointer; display: flex; gap: 12px; align-items: flex-start; font-size: 16px;
}
.choice:hover { border-color: var(--accent); background: var(--accent-soft); }
.choice .key { font-weight: 700; color: var(--ink-3); min-width: 18px; }
.time-bar { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin-top: 18px; }
.time-bar > div { height: 100%; background: var(--accent); transition: width 1s linear; }
.time-bar.low > div { background: var(--bad); }

.score-ring { font-size: 56px; font-weight: 800; }
.break-clock { font-size: 72px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- modal / pop-up ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(15,18,22,.45); z-index: 100;
  display: grid; place-items: center; padding: 20px; animation: fade .15s ease;
}
.modal {
  background: var(--panel); border-radius: 16px; width: min(620px, 100%); max-height: 90vh; overflow-y: auto;
  padding: 24px 26px; box-shadow: 0 20px 60px rgba(0,0,0,.3); animation: pop .18s ease;
}
.modal.wide { width: min(860px, 100%); }
.fb-head { display: flex; align-items: center; gap: 12px; font-size: 22px; font-weight: 800; margin-bottom: 14px; }
.fb-head.good { color: var(--good); }
.fb-head.bad { color: var(--bad); }
.fb-block { padding: 12px 14px; border-radius: 10px; background: var(--panel-2); margin: 10px 0; }
.fb-block .label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin-bottom: 4px; }
.fb-answer { background: var(--good-soft); }
.fb-answer .val { font-weight: 700; color: var(--good); font-size: 17px; }
.fb-wrong { background: var(--bad-soft); }
.fb-wrong .label { color: var(--bad); }
.fb-given .val { color: var(--bad); font-weight: 600; text-decoration: line-through; }
.fb-source .val { font-weight: 700; color: var(--accent); }
.fb-source blockquote { margin: 6px 0 0; padding-left: 10px; border-left: 3px solid var(--accent); color: var(--ink-2); font-style: italic; }

#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 10px 18px; border-radius: 10px; z-index: 200; font-size: 14px; box-shadow: var(--shadow);
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }

#topbar, #drawer-shade { display: none; }
@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  /* the subjects list slides in from the left (☰ button) */
  #topbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
  #topbar .brand-mark { width: 28px; height: 28px; }
  #btn-drawer { width: 40px; height: 40px; border: 0; border-radius: 8px; background: none; font-size: 22px; cursor: pointer; }
  #sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: min(290px, 85vw); z-index: 60; transform: translateX(-105%);
    transition: transform .2s ease; box-shadow: var(--shadow); }
  body.drawer-open #sidebar { transform: none; }
  body.drawer-open #drawer-shade { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .4); }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  #main { padding: 18px 14px 40px; }
  .s-top { padding-left: 12px; padding-right: 12px; flex-wrap: wrap; row-gap: 6px; }
  .s-top .grow { flex-basis: 100%; }
  .s-body { padding: 16px 12px calc(80px + var(--audio-space, 0px)); }   /* room for the player at the bottom */
  .q-card { padding: 18px 16px; }
  .q-text { font-size: 18px; }
  .btn.big { padding: 12px 16px; }
  .list-row { flex-wrap: wrap; }
  /* the audio player sits at the bottom of a small screen instead of floating */
  #r-audio.audio-float { left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important; width: auto !important;
    height: auto !important; max-height: 45vh; min-width: 0; resize: none; border-radius: var(--radius) var(--radius) 0 0; }
  #r-audio.audio-float .af-bar { cursor: default; }
  #r-audio.audio-float #a-home { display: none; }
}
/* the Android app: only studying here; uploads and AI work are done in the PC app */
.phone .pc-only { display: none !important; }
.phone .menu-item:not([data-newset]):not([data-del]), .phone .menu-sep:first-child, .phone [data-retry], .phone [data-manual] { display: none !important; }
.phone .choice { min-height: 48px; }

/* look back at answers */
.ans-item { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin: 12px 0; }
.ans-q { font-size: 16px; font-weight: 600; margin: 8px 0 10px; }
.ans-choices { display: grid; gap: 6px; margin-bottom: 6px; }
.ans-choice { padding: 8px 12px; border-radius: 8px; background: var(--panel-2); }
.ans-choice.right { background: var(--good-soft); color: var(--good); font-weight: 700; }
.ans-choice.wrong { background: var(--bad-soft); color: var(--bad); text-decoration: line-through; }
.ans-choice .tiny { margin-left: 8px; text-decoration: none; display: inline-block; }

/* the page the audio teacher is talking about */
.seg { scroll-margin-top: 80px; transition: background .4s, box-shadow .4s; border-radius: 10px; }
.seg.now { background: var(--accent-soft); box-shadow: 0 0 0 6px var(--accent-soft); }
/* the audio player floats beside the reading page: drag it by its top bar, resize it from the corner, shrink it */
#r-audio.audio-float { position: fixed; z-index: 50; margin: 0; padding: 0; width: 360px; min-width: 260px; min-height: 120px;
  max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); overflow: auto; resize: both;
  display: flex; flex-direction: column; box-shadow: 0 12px 32px rgba(0, 0, 0, .35); }
#r-audio.audio-float.small { resize: horizontal; min-height: 0; height: auto !important; }
#r-audio.audio-float.small .af-more { display: none; }
.af-bar { display: flex; align-items: center; gap: 6px; padding: 8px 10px 8px 14px; cursor: move; user-select: none;
  border-bottom: 1px solid var(--line); background: var(--accent-soft); border-radius: var(--radius) var(--radius) 0 0; }
.af-bar b { flex: 1; color: var(--accent); }
.af-bar button { width: 28px; height: 28px; padding: 0; border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); cursor: pointer; font-size: 14px; line-height: 1; }
.af-bar button:hover { border-color: var(--accent); }
.af-body { padding: 10px 14px 14px; flex: 1; }
.af-rates { display: flex; gap: 6px; flex-wrap: wrap; }
.af-rates .btn { padding: 4px 10px; font-size: 13px; }
.af-dragging { user-select: none; }
/* extras: pictures & trivia */
.x-pics { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.x-pic { margin: 0; }
.x-pic img { width: 100%; max-height: 320px; object-fit: cover; border-radius: 8px; cursor: zoom-in; display: block; }
.x-pic figcaption { margin-top: 6px; font-size: 14px; }
.x-trivia { background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; }
.x-trivia ul { margin: 6px 0 0; padding-left: 20px; }
.x-trivia li { margin: 4px 0; }

/* folding section header (Study materials) */
.section-toggle { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; padding: 6px 2px;
  color: var(--ink); cursor: pointer; text-align: left; font: inherit; border-radius: 8px; }
.section-toggle h2 { margin: 0; }
.section-toggle:hover h2 { color: var(--accent); }
.section-toggle .caret { display: inline-block; width: 14px; color: var(--ink-3); transition: transform .15s ease; }
.section-toggle.open .caret { transform: rotate(90deg); }

.brand-img { background: none; object-fit: contain; padding: 0; }

/* the letter chosen by voice, before "final answer" */
.choice.picked { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent); }

/* smart problem samples */
.problem-box { margin: 12px 0 4px; padding: 12px 14px; border-radius: 10px; background: var(--accent-soft); border-left: 3px solid var(--accent); line-height: 1.55; }
.problem-head { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.case-box summary { cursor: pointer; margin-bottom: 0; }
.case-box[open] summary { margin-bottom: 6px; }
.case-text { font-size: 14px; white-space: normal; }
.case-box .q-pic img { max-width: 100%; height: auto; }
.ex-case { border: 1px solid var(--accent); }

/* the audio player shrunk to an icon: a round button to drag anywhere; tap it to open the player again */
.af-bar { touch-action: none; }
.af-bubble { display: none; }
#r-audio.audio-float.icon { width: 56px !important; height: 56px !important; min-width: 0 !important; min-height: 0 !important;
  max-height: none !important; padding: 0; border: 0; border-radius: 50% !important; resize: none !important; overflow: visible !important;
  left: var(--ix) !important; top: var(--iy) !important; right: auto !important; bottom: auto !important; background: none; }
#r-audio.audio-float.icon .af-bar, #r-audio.audio-float.icon .af-body { display: none; }
#r-audio.audio-float.icon .af-bubble { display: grid; place-items: center; width: 56px; height: 56px; padding: 0; border: 0;
  border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 24px; cursor: grab; touch-action: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35); }
#r-audio.audio-float.icon.playing .af-bubble { animation: af-pulse 1.6s ease-in-out infinite; }
@keyframes af-pulse { 50% { box-shadow: 0 6px 18px rgba(0, 0, 0, .35), 0 0 0 9px var(--accent-soft); } }

/* ---------- practice exam ---------- */
.side-btn.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.field-label { font-size: 13px; color: var(--ink-2); margin: 10px 0 6px; }
.ex-subjects { display: flex; flex-wrap: wrap; gap: 8px; }
.ex-sub { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer; background: var(--panel-2); }
.ex-sub.empty { opacity: .55; cursor: default; }
.ex-timer { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; padding: 2px 12px; border-radius: 10px;
  background: var(--panel-2); }
.ex-timer.low { background: var(--bad-soft); color: var(--bad); }
.ex-head { position: sticky; top: 0; z-index: 2; }
.ex-nav { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; max-height: 180px; overflow: auto; }
.ex-num { width: 38px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink-2);
  cursor: pointer; font-size: 13px; font-variant-numeric: tabular-nums; }
.ex-num.done { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 700; }
.ex-num.flag { box-shadow: inset 0 -3px 0 var(--warn); }
.ex-q { margin-top: 12px; scroll-margin-top: 150px; }
.ex-text { margin: 6px 0 10px; font-size: 16px; line-height: 1.5; white-space: pre-line; }
.ex-choices { display: flex; flex-direction: column; gap: 6px; }
.ex-choice { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer; background: var(--panel); }
.ex-choice:hover { background: var(--panel-2); }
.ex-choice input { position: absolute; opacity: 0; pointer-events: none; }
.ex-letter { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--ink-3); display: flex;
  align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: var(--ink-2); }
.ex-ctext { padding-top: 3px; line-height: 1.4; }
.ex-choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.ex-choice:has(input:checked) .ex-letter { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ex-choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.ex-flag { color: var(--ink-3); }
.ex-flag.on { color: var(--warn); }
.ex-clear { margin-top: 6px; }
.ex-bar { height: 6px; margin-top: 6px; }
@media (max-width: 860px) {
  .ex-timer { font-size: 18px; }
  .ex-q { scroll-margin-top: 180px; }
  .ex-head { top: -1px; padding: 10px 14px; }
  .ex-head .tiny { display: none; }
}

/* online leaderboard */
.on-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.on-table th, .on-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.on-table th { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.on-table tr.me td { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.on-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--good); margin-right: 6px; vertical-align: middle; }
@media (max-width: 860px) { .on-wide { display: none; } .on-table th, .on-table td { padding: 6px 5px; } }

/* paid features */
.paywall { text-align: center; }
.paywall h2 { margin: 6px 0; }
.pw-lock { font-size: 38px; }
.pw-pay { margin: 14px auto 0; max-width: 520px; padding: 12px 14px; border: 1px dashed var(--line); border-radius: 10px; text-align: left; }
.pw-text { white-space: pre-wrap; margin-top: 6px; font-size: 14px; }
.pw-row { justify-content: center; }
.pw-code { max-width: 230px; text-align: center; font-family: ui-monospace, Consolas, monospace; letter-spacing: 1px; text-transform: uppercase; }
.pw-msg { margin-top: 8px; }
.pw-qr { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 14px auto 0; max-width: 520px; }
.pw-qr-btn { flex: 1 1 180px; max-width: 240px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; color: inherit; font: inherit; }
.pw-qr-btn img { width: 100%; height: 230px; object-fit: contain; border-radius: 8px; background: #fff; }
.pw-form { margin: 14px auto 0; max-width: 560px; text-align: left; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.pw-form h3 { margin: 0 0 10px; }
.pw-f-img { max-height: 160px; max-width: 60%; border-radius: 8px; border: 1px solid var(--line); }
.pw-reqs { max-width: 560px; margin: 0 auto; }
.pw-codebox { max-width: 560px; margin-left: auto; margin-right: auto; }
.pw-codebox summary { cursor: pointer; color: var(--accent); font-size: 14px; }

/* the owner's admin page */
.adm-req { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.adm-receipt { width: 96px; height: 130px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in;
  display: flex; align-items: center; justify-content: center; text-align: center; }
.adm-code { font: 600 14px ui-monospace, Consolas, monospace; letter-spacing: .5px; }
.adm-coderow { flex-wrap: wrap; }
.adm-code { white-space: nowrap; }
@media (max-width: 600px) { .adm-coderow > .grow { flex: 1 1 100%; } }
#btn-admin .count { margin-left: 6px; }

.lib-search input { width: 100%; padding: 10px 12px; font-size: 15px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); }

/* the website (iPhone): loading screen and the audio lesson read by the phone's voice */
#web-boot { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center;
  background: var(--bg); color: var(--ink); padding: 24px; text-align: center; }
#web-boot .wb-box { max-width: 340px; }
#web-boot img { border-radius: 16px; }
#web-boot .wb-title { font-size: 26px; font-weight: 700; margin-top: 10px; }
#web-boot .wb-step { margin-top: 14px; font-size: 16px; }
#web-boot .wb-note { margin-top: 10px; font-size: 13px; color: var(--ink-2); }
#web-boot:not(.failed) .wb-step::after { content: ""; display: inline-block; width: 14px; height: 14px; margin-left: 8px;
  vertical-align: -2px; border: 2px solid var(--accent); border-right-color: transparent; border-radius: 50%; animation: wb-spin .8s linear infinite; }
#web-boot.failed .wb-step { color: var(--bad); }
@keyframes wb-spin { to { transform: rotate(360deg); } }
.web-player .wp-row { display: flex; gap: 8px; align-items: center; }
.web-player .wp-play { flex: 1; }
.web-player .wp-bar { width: 100%; margin-top: 10px; accent-color: var(--accent); }
.web-player .wp-where { margin-top: 2px; }
