/* ===========================================================
   K53 Learners Testing — design system
   Sophisticated emerald + gold palette, serif display headings.
   =========================================================== */
:root {
  --bg: #f5f3ee;            /* warm ivory */
  --bg-2: #efece4;
  --card: #ffffff;
  --ink: #1a2b2a;           /* deep slate-green */
  --muted: #65726f;
  --line: #e6e2d8;          /* warm hairline */
  --line-strong: #d8d3c6;

  --brand: #0c6157;         /* deep emerald */
  --brand-2: #0a4f47;
  --brand-ink: #ffffff;
  --brand-soft: #e8f0ed;

  --gold: #b08643;          /* refined gold accent */
  --gold-soft: #f2ead8;

  --ok: #1f8a55;
  --ok-bg: #e7f4ec;
  --bad: #c2483f;
  --bad-bg: #f8e9e7;

  --radius: 16px;
  --radius-sm: 11px;
  --shadow-sm: 0 1px 2px rgba(18,40,34,.05), 0 1px 3px rgba(18,40,34,.04);
  --shadow: 0 6px 20px rgba(18,40,34,.07), 0 2px 6px rgba(18,40,34,.05);
  --shadow-lg: 0 16px 40px rgba(18,40,34,.13);

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
}
:root[data-theme="dark"] {
  --bg: #0e1614;
  --bg-2: #121c19;
  --card: #16211e;
  --ink: #e9efec;
  --muted: #9aaaa4;
  --line: #243330;
  --line-strong: #2e403c;
  --brand: #18b89f;
  --brand-2: #0f8e7b;
  --brand-soft: #142a26;
  --gold: #d2a861;
  --gold-soft: #2a2418;
  --ok-bg: #11301f;
  --bad-bg: #331a18;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow: 0 6px 22px rgba(0,0,0,.45);
  --shadow-lg: 0 18px 44px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  background-image: radial-gradient(1200px 500px at 50% -200px, var(--bg-2), transparent);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: var(--brand-ink);
  box-shadow: var(--shadow);
  border-bottom: 1px solid rgba(0,0,0,.08);
}
.brandlink { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--brand-ink); }
.emblem {
  font-family: var(--serif); font-weight: 700; font-size: 15px; letter-spacing: .5px;
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 11px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.28);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25);
  color: #fff;
}
.wordmark { font-family: var(--serif); font-weight: 600; font-size: 19px; letter-spacing: .2px; }
.badge {
  background: rgba(255,255,255,.14); padding: 5px 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; letter-spacing: .3px;
  border: 1px solid rgba(255,255,255,.25);
}

main { max-width: 740px; margin: 0 auto; padding: 22px 18px 8px; }
.screen { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Typography ---------- */
h1 { font-family: var(--serif); font-weight: 600; font-size: 30px; line-height: 1.15; margin: 2px 0 6px; letter-spacing: .2px; }
h2 { font-family: var(--serif); font-weight: 600; font-size: 23px; line-height: 1.2; margin: 6px 0 16px; }
h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: 1px; color: var(--gold); font-weight: 700; margin: 26px 0 10px; }
.muted { color: var(--muted); }
small { color: var(--muted); }

/* ---------- Hero ---------- */
.hero {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.hero::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--gold));
}
.hero p { color: var(--muted); margin: 4px 0 18px; font-size: 15px; }

.codepick label { display: block; font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-bottom: 8px; }
.seg { display: flex; gap: 6px; background: var(--bg); padding: 5px; border-radius: 13px; border: 1px solid var(--line); }
.seg button {
  flex: 1; padding: 11px 8px; border: 1px solid transparent; background: transparent;
  border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer;
  transition: all .16s ease; font-size: 14px;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--card); color: var(--brand); border-color: var(--line); box-shadow: var(--shadow-sm); }
.codepick small { display: block; margin-top: 10px; }

/* ---------- Tiles ---------- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.tile {
  text-align: left; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; cursor: pointer; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 5px; color: var(--ink);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--line-strong); }
.tile:active { transform: translateY(-1px); }
.tile b { font-size: 16px; font-weight: 600; }
.tile span { color: var(--muted); font-size: 13px; line-height: 1.4; }
.tile.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; border-color: transparent; grid-column: 1 / -1;
  box-shadow: 0 10px 26px rgba(12,97,87,.28);
}
.tile.primary::after {
  content: "›"; position: absolute; right: 20px; font-size: 26px; opacity: .55; font-weight: 400;
}
.tile.primary { position: relative; }
.tile.primary b { font-size: 18px; }
.tile.primary span { color: rgba(255,255,255,.85); }
.tile.primary:hover { box-shadow: 0 16px 36px rgba(12,97,87,.36); }

.lastrun { text-align: center; margin-top: 18px; color: var(--muted); font-size: 14px; }
.pass { color: var(--ok); font-weight: 700; }
.fail { color: var(--bad); font-weight: 700; }

/* ---------- Buttons ---------- */
button { font: inherit; }
.primary, .ghost, .back { border-radius: var(--radius-sm); cursor: pointer; border: 1px solid transparent; transition: all .16s ease; }
.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border: none;
  padding: 13px 18px; font-weight: 600; letter-spacing: .2px;
  box-shadow: 0 6px 16px rgba(12,97,87,.24);
}
.primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(12,97,87,.32); }
.primary:active { transform: translateY(0); }
.primary:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; transform: none; }
.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line-strong); padding: 12px 18px; font-weight: 600; }
.ghost:hover { border-color: var(--brand); color: var(--brand); }
.big { display: block; width: 100%; margin-top: 14px; padding: 15px; font-size: 16px; }
.back { background: none; border: none; color: var(--brand); font-weight: 600; padding: 6px 0; margin-bottom: 6px; font-size: 14.5px; }
.back:hover { opacity: .75; }

/* ---------- Form fields ---------- */
.fld { display: block; margin: 16px 0; font-weight: 600; font-size: 14px; }
.fld select, .fld input {
  display: block; width: 100%; margin-top: 8px; padding: 12px 13px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--card); color: var(--ink); font: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.fld select:focus, .fld input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.row { display: flex; align-items: center; gap: 11px; margin: 16px 0; font-weight: 600; }
.row input { width: 19px; height: 19px; accent-color: var(--brand); }

/* ---------- List rows ---------- */
.rowbtn {
  display: flex; justify-content: space-between; align-items: center; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 15px 16px; margin-bottom: 9px; cursor: pointer; color: var(--ink);
  box-shadow: var(--shadow-sm); transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}
.rowbtn:hover { transform: translateX(3px); border-color: var(--brand); box-shadow: var(--shadow); }
.rowbtn span { font-weight: 600; }
.rowbtn small { background: var(--bg); padding: 3px 11px; border-radius: 999px; font-weight: 600; }

/* ---------- Question / flash / review cards ---------- */
.qcard, .flash, .reviewcard {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}
.sign { display: flex; justify-content: center; margin-bottom: 18px; }
.sign svg { width: auto; height: 140px; max-width: 100%; }
.sign .signimg {
  height: 140px; width: auto; max-width: 100%; object-fit: contain;
  padding: 12px; background: #fff; border-radius: 14px; box-shadow: var(--shadow-sm);
}
.reviewcard .sign .signimg { height: 92px; }
.opt .optsign { height: 62px; width: auto; max-width: 100%; }
.yours .optsign, .answer .optsign { height: 50px; width: auto; vertical-align: middle; background:#fff; border-radius:8px; padding:4px; }
.qprompt { font-size: 19px; font-weight: 600; margin-bottom: 16px; line-height: 1.4; }
.hint { color: var(--muted); font-size: 13px; margin-bottom: 10px; font-style: italic; }
.options { display: flex; flex-direction: column; gap: 11px; }
.opt {
  display: flex; align-items: center; gap: 13px; text-align: left;
  padding: 14px 16px; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: var(--card); color: var(--ink); cursor: pointer;
  transition: border-color .14s ease, background .14s ease, transform .1s ease;
}
.opt:hover:not(:disabled) { border-color: var(--brand); }
.opt:active:not(:disabled) { transform: scale(.992); }
.opt .dot { flex: 0 0 19px; width: 19px; height: 19px; border-radius: 50%; border: 2px solid var(--line-strong); transition: all .14s ease; }
.opt.sel { border-color: var(--brand); background: var(--brand-soft); }
.opt.sel .dot { border-color: var(--brand); background: var(--brand); box-shadow: inset 0 0 0 3px var(--card); }
.opt.correct { border-color: var(--ok); background: var(--ok-bg); }
.opt.correct .dot { border-color: var(--ok); background: var(--ok); box-shadow: inset 0 0 0 3px var(--ok-bg); }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt.wrong .dot { border-color: var(--bad); background: var(--bad); box-shadow: inset 0 0 0 3px var(--bad-bg); }
.opt:disabled { cursor: default; }

.feedback { margin-top: 16px; padding: 14px 16px; border-radius: var(--radius-sm); border: 1px solid transparent; }
.feedback.ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 22%, transparent); }
.feedback.bad { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 22%, transparent); }
.feedback strong { font-family: var(--serif); }
.feedback p { margin: 6px 0 0; color: var(--ink); font-size: 14px; }

/* ---------- Flashcards ---------- */
.flash .answer { margin: 12px 0; padding: 12px 14px; background: var(--brand-soft); border-radius: var(--radius-sm); font-size: 15px; }
.navrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
.navrow #counter { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- Exam ---------- */
.examhead { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.progbar { flex: 1; height: 9px; background: var(--line); border-radius: 999px; overflow: hidden; box-shadow: inset 0 1px 2px rgba(0,0,0,.06); }
.progbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--gold)); width: 0; transition: width .25s ease; border-radius: 999px; }
#timer, #pc { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--muted); }
#timer.low { color: var(--bad); }
.pager { display: flex; flex-wrap: wrap; gap: 7px; margin: 18px 0; }
.pg { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: var(--card); color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 600; transition: all .12s ease; }
.pg:hover { border-color: var(--brand); }
.pg.done { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.pg.cur { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: var(--shadow-sm); }
.pg.flag { box-shadow: inset 0 0 0 2px var(--gold); }
#flag.on { border-color: var(--gold); color: var(--gold); }

/* ---------- Section banner & briefing ---------- */
.secbanner {
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--gold);
  color: var(--ink); border-radius: var(--radius-sm); padding: 11px 14px; margin-bottom: 14px;
  font-size: 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  box-shadow: var(--shadow-sm);
}
.secbanner b { font-weight: 600; }
.secbanner .sb-pos { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.brief { list-style: none; padding: 0; margin: 16px 0; }
.brief li { padding: 12px 15px; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 9px; background: var(--card); font-size: 14px; box-shadow: var(--shadow-sm); }
.brief li b { color: var(--brand); }

/* ---------- Tables ---------- */
.spec { width: 100%; border-collapse: collapse; margin: 14px 0; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line); }
.spec th, .spec td { padding: 13px 14px; text-align: left; border-bottom: 1px solid var(--line); font-size: 14px; }
.spec th { background: var(--bg); color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .8px; font-weight: 700; }
.spec tr:last-child td { border-bottom: none; }
.spec tr.totrow td { background: var(--gold-soft); }
.spec tr.rp td { background: var(--ok-bg); }
.spec tr.rf td { background: var(--bad-bg); }

/* ---------- Results ---------- */
.result { text-align: center; }
.verdict {
  font-family: var(--serif); font-size: 46px; font-weight: 700; letter-spacing: 2px; margin: 14px 0 6px;
  display: inline-block;
}
.verdict.pass { color: var(--ok); }
.verdict.fail { color: var(--bad); }
.verdict-msg { font-weight: 600; font-size: 16px; margin: 6px 0 14px; }
.bigscore { font-family: var(--serif); font-size: 52px; font-weight: 700; color: var(--brand); }
.spec { text-align: left; }
.allright { color: var(--ok); font-weight: 600; }
.reviewcard { margin-bottom: 12px; text-align: left; }
.reviewcard .sign svg { width: 92px; height: 92px; }
.yours { padding: 9px 12px; border-radius: 9px; margin: 7px 0; font-size: 14px; }
.yours.ok { background: var(--ok-bg); }
.yours.bad { background: var(--bad-bg); }

/* ---------- Topic progress ---------- */
.tprog { display: grid; grid-template-columns: 1fr 110px 46px; align-items: center; gap: 12px; margin: 10px 0; font-size: 14px; }
.tprog .bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.tprog .bar i { display: block; height: 100%; border-radius: 999px; transition: width .3s ease; }
.tprog .bar i.low { background: var(--bad); }
.tprog .bar i.mid { background: var(--gold); }
.tprog .bar i.hi { background: var(--ok); }
.tprog b { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Ads ---------- */
.adbox { display: block; width: 100%; margin: 20px 0; min-height: 90px; border-radius: var(--radius-sm); }
.adbox.placeholder {
  display: flex; align-items: center; justify-content: center; min-height: 100px;
  background: var(--bg); border: 1px dashed var(--line-strong); color: var(--muted);
}
.adbox.placeholder span {
  background: var(--card); padding: 5px 14px; border-radius: 999px;
  font-size: 11px; letter-spacing: 1px; text-transform: uppercase; box-shadow: var(--shadow-sm);
}

/* ---------- Section test tiles ---------- */
.sectiles { display: flex; flex-direction: column; gap: 11px; margin: 16px 0; }
.sectile { padding: 17px 16px; }
.examtitle { font-weight: 700; color: var(--muted); font-size: 14px; }

/* ---------- Footer ---------- */
footer { text-align: center; color: var(--muted); font-size: 12.5px; padding: 30px 18px; line-height: 1.7; }
footer a { color: var(--brand); font-weight: 600; }
.seoline { max-width: 620px; margin: 0 auto 14px; font-size: 13px; line-height: 1.6; }
.seoline strong { color: var(--ink); }

/* Star rating */
.ratebox { margin: 18px 0 6px; }
.rate-prompt { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.stars { display: inline-flex; gap: 4px; }
.star { background: none; border: none; cursor: pointer; font-size: 30px; line-height: 1; padding: 0 2px; color: var(--line-strong); transition: color .1s ease, transform .1s ease; }
.star:hover { transform: scale(1.12); }
.star.on { color: var(--gold); }
.rated { font-weight: 600; color: var(--gold); font-size: 15px; }
