:root {
  --bg: #f6f7fb; --surface: #ffffff; --surface-2: #eef1f7; --text: #18202f; --muted: #5d6779;
  --line: #dde2ec; --brand: #c8102e; --brand-ink: #ffffff; --navy: #1f2a44;
  --ok: #157a46; --ok-bg: #e5f5ec; --bad: #b42318; --bad-bg: #fdecea; --focus: #2f6fed;
  --radius: 14px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 16px rgba(16,24,40,.05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f131b; --surface: #171c27; --surface-2: #1f2633; --text: #e8ebf2; --muted: #9aa4b6;
    --line: #2b3343; --navy: #c9d3ea; --ok: #4fd18b; --ok-bg: #12301f; --bad: #ff8a80; --bad-bg: #3a1714;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f131b; --surface: #171c27; --surface-2: #1f2633; --text: #e8ebf2; --muted: #9aa4b6;
  --line: #2b3343; --navy: #c9d3ea; --ok: #4fd18b; --ok-bg: #12301f; --bad: #ff8a80; --bad-bg: #3a1714;
  --shadow: none;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 Inter, system-ui, sans-serif; }
a { color: inherit; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 12px 20px;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; color: var(--navy); white-space: nowrap; }
.mark { background: var(--brand); color: var(--brand-ink); border-radius: 8px; padding: 3px 7px; font-size: 13px; letter-spacing: .5px; }
#crumbs { flex: 1; min-width: 0; color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#crumbs a { text-decoration: none; } #crumbs a:hover { text-decoration: underline; }

main { max-width: 860px; margin: 0 auto; padding: 28px 16px 60px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 24px 16px 40px; }
h1 { font-size: 28px; line-height: 1.2; margin: 0 0 6px; color: var(--navy); }
h2 { font-size: 20px; margin: 28px 0 10px; color: var(--navy); }
.muted { color: var(--muted); } .center { text-align: center; } .small { font-size: 13px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); margin-top: 20px; }
.tile { display: block; text-decoration: none; transition: transform .12s ease, border-color .12s ease; }
.tile:hover { transform: translateY(-2px); border-color: var(--brand); }
.tile .lv { font-size: 30px; font-weight: 700; color: var(--brand); line-height: 1; }
.tile .name { font-weight: 600; margin: 8px 0 4px; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 12px; }
.bar > span { display: block; height: 100%; background: var(--ok); border-radius: 99px; }

.btn { background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 10px; padding: 11px 18px; font-weight: 600; }
.btn:hover { filter: brightness(1.07); }
.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 9px 14px; }
.ghost:hover { border-color: var(--muted); }
.ghost.small { padding: 6px 10px; font-size: 13px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }

.login { max-width: 420px; margin: 8vh auto 0; }
.login input { width: 100%; font: 600 18px/1.2 Inter, sans-serif; letter-spacing: 2px; text-transform: uppercase; padding: 13px 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--text); margin: 14px 0 12px; }
.err { color: var(--bad); font-size: 14px; min-height: 20px; }

.doc { font-family: "Source Serif 4", Georgia, serif; font-size: 17.5px; line-height: 1.7; background: var(--surface-2);
  border-radius: 12px; padding: 18px 20px; white-space: pre-wrap; margin: 14px 0; }
.doc .title { font-family: Inter, sans-serif; font-weight: 700; font-size: 16px; display: block; margin-bottom: 8px; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--brand); }
.q { margin-top: 22px; }
.q .stem { font-weight: 600; margin-bottom: 10px; }
.opt { display: flex; gap: 12px; width: 100%; text-align: left; align-items: flex-start; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px; margin: 7px 0; }
.opt:hover:not([disabled]) { border-color: var(--focus); }
.opt .k { font-weight: 700; min-width: 18px; color: var(--muted); }
.opt.right { background: var(--ok-bg); border-color: var(--ok); } .opt.right .k { color: var(--ok); }
.opt.wrong { background: var(--bad-bg); border-color: var(--bad); } .opt.wrong .k { color: var(--bad); }
.opt[disabled] { cursor: default; }
.expl { border-left: 3px solid var(--ok); padding: 8px 14px; margin-top: 10px; font-size: 15px; }
.expl.badx { border-left-color: var(--bad); }
.expl p { margin: 4px 0; }

table.vocab { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
.vocab th, .vocab td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.vocab th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.vocab td:first-child { font-weight: 600; }
.speak { border: 0; background: none; padding: 0 4px; color: var(--muted); }

details { margin-top: 16px; } summary { cursor: pointer; font-weight: 600; color: var(--navy); }
.pager { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; margin-top: 24px; border-top: 1px solid var(--line); }
.pager select { font: inherit; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); max-width: 46vw; }
.score { font-weight: 600; }
textarea { width: 100%; min-height: 200px; font: 16px/1.6 "Source Serif 4", Georgia, serif; padding: 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); margin-top: 8px; }
.dialog p { margin: 6px 0; } .dialog b { color: var(--brand); }
ul.points { padding-left: 20px; } ul.points li { margin: 4px 0; }
.listen { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 14px 0; padding: 14px; border-radius: 12px; background: var(--surface-2); }
.listen label { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; }

@media (max-width: 560px) {
  h1 { font-size: 23px; } .top { padding: 10px 12px; gap: 10px; } .brand span:last-child { display: none; }
  .doc { font-size: 16.5px; padding: 14px; }
}
@media (prefers-reduced-motion: reduce) { .tile { transition: none; } .tile:hover { transform: none; } }
.pager { flex-wrap: nowrap; }
.pager select { flex: 1; min-width: 0; }
@media (max-width: 560px) { .pager .ghost, .pager .btn { padding: 9px 11px; font-size: 14px; } }
button.tile { font: inherit; color: var(--text); text-align: left; width: 100%; cursor: pointer; }
button.tile[disabled] { opacity: .6; cursor: progress; }
.brand .leaf { color: var(--brand); flex: none; }
