/* Layout: single centered column (max 1080px), app-style top bar, cards only where a block is a separate object. */
:root {
  --paper: #faf7f6;
  --surface: #ffffff;
  --ink: #251b1c;
  --muted: #776765;
  --line: #ebe1de;
  --brand: #a7635e;      /* ENGLISH CARE form theme colour */
  --brand-deep: #7c433e;
  --brand-soft: #f5e8e6;
  --on-brand: #ffffff;
  --good: #3c7a58;
  --good-soft: #e5f1ea;
  --warn: #a66a12;
  --warn-soft: #fbf0dd;
  --bad: #b23b35;
  --w0: #efe6e4; --w1: #e2b9b5; --w2: #c27f79; --w3: #7c433e;
  --shadow: 0 1px 2px rgba(60, 30, 28, .06), 0 8px 24px rgba(60, 30, 28, .06);
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --ipa: "Gentium Book Plus", "Charis SIL", "Doulos SIL", "Lucida Sans Unicode", serif;
  --r: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #161112; --surface: #201a1b; --ink: #f3ebe9; --muted: #ab9b98; --line: #352b2c;
    --brand: #d58f88; --brand-deep: #e9b2ac; --brand-soft: #36211f; --on-brand: #1c1213;
    --good: #72c294; --good-soft: #1d2e24; --warn: #e2a74a; --warn-soft: #33281a; --bad: #ef7a73;
    --w0: #2b2324; --w1: #5a3532; --w2: #a0605a; --w3: #e9b2ac;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #161112; --surface: #201a1b; --ink: #f3ebe9; --muted: #ab9b98; --line: #352b2c;
  --brand: #d58f88; --brand-deep: #e9b2ac; --brand-soft: #36211f; --on-brand: #1c1213;
  --good: #72c294; --good-soft: #1d2e24; --warn: #e2a74a; --warn-soft: #33281a; --bad: #ef7a73;
  --w0: #2b2324; --w1: #5a3532; --w2: #a0605a; --w3: #e9b2ac;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper); color: var(--ink);
  font: 15px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0; text-wrap: balance; letter-spacing: -.01em; }
a { color: inherit; }
.ipa { font-family: var(--ipa); font-weight: 400; letter-spacing: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.wrap {
  max-width: 1080px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

/* ---------- Top bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.bar .wrap { display: flex; align-items: center; gap: 12px; min-height: 60px; padding-block: 8px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.mark { width: 36px; height: 36px; border-radius: 10px; flex: none; object-fit: contain; }
.mark.mono {
  display: grid; place-items: center; background: var(--brand); color: var(--on-brand);
  font: 700 14px/1 var(--display); letter-spacing: .02em;
}
.brand b { font: 700 17px/1.1 var(--display); display: block; }
.brand small { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a {
  text-decoration: none; padding: 7px 12px; border-radius: 999px; color: var(--muted); font-weight: 500;
}
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-deep); }
.spacer { flex: 1; }
.who { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-deep);
  display: grid; place-items: center; font-weight: 600; font-size: 13px; overflow: hidden; flex: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 720px) {
  .bar .wrap { flex-wrap: wrap; }
  .nav { order: 3; width: 100%; margin: 0; overflow-x: auto; }
  .brand small { display: none; }
}

/* ---------- Buttons & inputs ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: 600 14px/1 var(--body); padding: 10px 14px; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 7px 10px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .55; cursor: progress; }
input, select {
  font: 15px var(--body); color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg { display: inline-flex; background: var(--brand-soft); padding: 3px; border-radius: 10px; gap: 2px; }
.seg button {
  border: 0; background: transparent; color: var(--brand-deep); font: 600 13px var(--body);
  padding: 7px 12px; border-radius: 8px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- Generic ---------- */
main { padding-block: 24px 64px; display: grid; gap: 28px; }
main > * { min-width: 0; } /* a wide table scrolls inside its card instead of widening the page */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head h2 { font-size: 20px; }
.eyebrow { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; font-weight: 600; color: var(--muted); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-deep); white-space: nowrap;
}
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.plain { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-left, 0px)); }
.login-card { width: min(420px, 100%); text-align: center; display: grid; gap: 18px; justify-items: center; padding: 36px 28px; box-shadow: var(--shadow); }
.login-card .mark { width: 64px; height: 64px; border-radius: 16px; font-size: 22px; }
.login-card h1 { font-size: 30px; }
.login-ipa { font-size: 22px; color: var(--brand); min-height: 1.5em; transition: opacity .4s; }
.login-error { color: var(--bad); font-size: 14px; min-height: 1.2em; }
.login-form { display: grid; gap: 12px; width: 100%; text-align: left; }
.login-form .btn.primary { justify-content: center; padding: 13px; font-size: 15px; }
.pw { display: flex; gap: 6px; align-items: center; }
.pw input { flex: 1; min-width: 0; }
.creds { display: grid; gap: 8px; }
.creds div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--brand-soft); }
.creds span { font-size: 13px; color: var(--muted); }
.creds b { font: 600 18px/1.2 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--brand-deep); overflow-wrap: anywhere; }
.fine { font-size: 13px; color: var(--muted); max-width: 32ch; }

/* ---------- Student hero ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: 20px; padding: 28px;
  background: var(--brand-deep); color: #fff; display: grid; gap: 16px;
}
:root[data-theme="dark"] .hero { background: #5b2f2b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hero { background: #5b2f2b; } }
.hero .watermark {
  position: absolute; right: -8px; bottom: -18px; font-size: clamp(64px, 13vw, 132px); line-height: 1;
  color: #fff; opacity: .13; pointer-events: none; white-space: nowrap;
}
.hero .eyebrow { color: rgba(255, 255, 255, .75); }
.hero h1 { font-size: clamp(26px, 4.5vw, 40px); max-width: 18ch; }
.hero .meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.hero .pill { background: rgba(255, 255, 255, .16); color: #fff; }
.hero .go {
  justify-self: start; background: #fff; color: #5b2f2b; border: 0; font-size: 16px; padding: 14px 20px; border-radius: 12px;
}
.hero .go:hover { filter: none; transform: translateY(-1px); }
.hero .note { font-size: 13px; color: rgba(255, 255, 255, .8); max-width: 46ch; position: relative; margin: 0; }
.hero .note b { color: #fff; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { padding: 16px; display: grid; gap: 4px; align-content: start; min-width: 0; }
.stat .v { font: 700 28px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.stat .v small { font: 500 14px var(--body); color: var(--muted); white-space: nowrap; }
@media (max-width: 480px) { .ring { width: 40px; height: 40px; } .ringwrap { gap: 8px; } .stat .v { font-size: 24px; } }
.stat .l { font-size: 13px; color: var(--muted); }
.ringwrap { display: flex; align-items: center; gap: 12px; }
.ring { width: 54px; height: 54px; flex: none; }
.ring circle { fill: none; stroke-width: 6; }
.ring .track { stroke: var(--w0); }
.ring .fill { stroke: var(--brand); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset .9s cubic-bezier(.2, .8, .2, 1); }

/* ---------- The wall ---------- */
.wall-card { padding: 18px; }
.wall { display: grid; grid-template-columns: repeat(20, minmax(0, 1fr)); gap: 4px; flex: 1 1 340px; max-width: 560px; min-width: 0; }
.wall a {
  aspect-ratio: 1; border-radius: 3px; background: var(--w0); display: block; max-width: 100%;
  transition: transform .12s;
}
.wall a:hover { transform: scale(1.35); position: relative; z-index: 1; }
.wall a.s1 { background: var(--w1); }
.wall a.s2 { background: var(--w2); }
.wall a.s3 { background: var(--w3); }
.wall a.next { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand); }
.wall-row { display: flex; gap: 28px; align-items: flex-start; flex-wrap: wrap; }
.wall-side { display: grid; gap: 14px; flex: 1; min-width: 220px; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; vertical-align: -1px; margin-right: 5px; background: var(--w0); }
.legend i.s1 { background: var(--w1); } .legend i.s2 { background: var(--w2); } .legend i.s3 { background: var(--w3); }
.levels { display: grid; gap: 8px; }
.lvl { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; font-size: 13px; }
.lvl .track { grid-column: 1 / -1; height: 6px; border-radius: 99px; background: var(--w0); overflow: hidden; }
.lvl .track span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }

/* ---------- Test list ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; min-width: 0; max-width: 100%; }
.toolbar input { max-width: 280px; }
.rows { display: grid; }
.row {
  display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 12px 16px; border-top: 1px solid var(--line);
}
.row:first-child { border-top: 0; }
.badge {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-deep); font: 700 15px var(--display); font-variant-numeric: tabular-nums;
}
.row.done .badge { background: var(--good-soft); color: var(--good); }
.row .t { min-width: 0; }
.row .t b { display: block; font-weight: 600; }
.row .t > span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.row .t b .pill { margin-left: 6px; vertical-align: 1px; }
.row .act { display: flex; gap: 8px; align-items: center; }
/* Phones: the score and buttons move under the test name, which keeps the full width. */
@media (max-width: 560px) { .row { grid-template-columns: 44px minmax(0, 1fr); } .row .act { grid-column: 2; flex-wrap: wrap; } }
.more { padding: 12px; text-align: center; border-top: 1px solid var(--line); }

/* ---------- Owner ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 760px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 860px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
.panel { padding: 18px; display: grid; gap: 14px; align-content: start; min-width: 0; }
.panel h3 { font-size: 17px; }
.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; align-items: end; }
.step { border-radius: 12px; padding: 12px; display: grid; gap: 4px; align-content: end; text-align: center; min-width: 0; }
.step .medal { font: 700 11px var(--body); letter-spacing: .1em; text-transform: uppercase; }
.step .names { font: 700 15px/1.25 var(--display); overflow-wrap: anywhere; }
.step .c { font-size: 13px; }
.step.g1 { background: var(--brand); color: var(--on-brand); min-height: 150px; order: 2; }
.step.g2 { background: var(--brand-soft); color: var(--brand-deep); min-height: 120px; order: 1; }
.step.g3 { background: var(--w0); color: var(--ink); min-height: 96px; order: 3; }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font: 12px var(--body); }
.chart .val { fill: var(--ink); font-weight: 600; }
.chart .bar { fill: var(--brand); }
.chart .bar.now { fill: var(--brand-deep); }
.chart .grid { stroke: var(--line); }
.list { display: grid; }
.list > div { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); min-width: 0; }
.list > div:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .grow b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .grow span { font-size: 13px; color: var(--muted); }
.alert { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); background: var(--warn-soft); }
.alert h3 { color: var(--warn); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
tr:first-child td { border-top: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: var(--brand-soft); }
.prog { display: flex; align-items: center; gap: 10px; min-width: 170px; }
.prog .track { flex: 1; height: 8px; border-radius: 99px; background: var(--w0); overflow: hidden; }
.prog .track span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.banner { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 12px 16px; }

/* ---------- Dialog & toast ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 18px; padding: 0; width: min(460px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(30, 15, 14, .45); }
dialog form { padding: 22px; display: grid; gap: 14px; }
dialog h3 { font-size: 20px; }
dialog .actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
dialog .err { color: var(--bad); font-size: 14px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--paper); padding: 11px 16px; border-radius: 12px; font-weight: 500; font-size: 14px;
  opacity: 0; transition: .25s; z-index: 50; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%); }

.fade { animation: fade .35s ease both; }
@keyframes fade { from { opacity: .001; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Today's 3 + reminders ---------- */
.today { display: flex; flex-wrap: wrap; gap: 8px; position: relative; }
.today-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 7px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, .14); color: #fff; text-decoration: none; font-weight: 600; font-size: 14px;
  border: 1px solid rgba(255, 255, 255, .28);
}
.today-chip:hover { background: rgba(255, 255, 255, .24); }
.today-chip.done { background: #fff; color: #5b2f2b; border-color: #fff; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.remind { display: flex; align-items: center; gap: 16px; padding: 16px 18px; flex-wrap: wrap; }
.remind .grow { flex: 1; min-width: 220px; }
.remind h3 { font-size: 17px; }
.remind p { margin: 4px 0 0; font-size: 14px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; color: var(--ink); cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; flex: none; accent-color: var(--brand); }
.check small { display: block; font-weight: 400; color: var(--muted); margin-top: 2px; }
.bad { color: var(--bad); font-weight: 600; }

/* ---------- Monthly report ---------- */
.report-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.month-pick { display: flex; gap: 6px; align-items: center; }
.month-pick select { width: auto; padding: 7px 10px; font-size: 14px; }
.report { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: clamp(18px, 4vw, 36px); display: grid; gap: 28px; }
.report-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.report-head h1 { font-size: clamp(28px, 5vw, 40px); margin-top: 6px; }
.report-sub { margin: 4px 0 0; color: var(--muted); font-size: 16px; }
.medal-badge {
  width: 96px; height: 96px; border-radius: 50%; display: grid; place-content: center; text-align: center; flex: none;
  font: 700 18px/1.1 var(--display); color: #3d2a12; border: 3px solid rgba(255, 255, 255, .6);
  box-shadow: 0 0 0 1px var(--line), var(--shadow);
}
.medal-badge small { display: block; font: 600 10px/1.2 var(--body); letter-spacing: .04em; margin-top: 4px; max-width: 70px; }
.medal-badge.m-gold { background: radial-gradient(circle at 35% 30%, #fff3c4, #e5b93f 60%, #b8871a); }
.medal-badge.m-silver { background: radial-gradient(circle at 35% 30%, #ffffff, #c9ccd3 60%, #8f949e); color: #2b2e34; }
.medal-badge.m-bronze { background: radial-gradient(circle at 35% 30%, #ffe1c6, #c98a55 60%, #93582b); color: #3b2312; }
.report-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 760px) { .report-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.rstat { background: var(--paper); border-radius: 14px; padding: 16px; display: grid; gap: 2px; align-content: start; min-width: 0; }
.rstat .v { font: 700 32px/1.1 var(--display); }
.rstat .v small { font: 500 15px var(--body); color: var(--muted); }
.rstat .l { font-size: 13px; color: var(--muted); }
.rstat .d { font-size: 13px; margin-top: 6px; color: var(--muted); }
.rstat .d.up { color: var(--good); font-weight: 600; }
.rstat .d.down { color: var(--warn); font-weight: 600; }
.report-block { display: grid; gap: 12px; }
.report-block h2 { font-size: 18px; }
.report-block p { margin: 0; }
.goalbar { height: 12px; border-radius: 99px; background: var(--w0); overflow: hidden; max-width: 520px; }
.goalbar span { display: block; height: 100%; border-radius: 99px; background: var(--good); }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; max-width: 560px; }
.cal-h { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); text-align: center; }
.cal-d {
  aspect-ratio: 1; max-width: 100%; border-radius: 10px; background: var(--w0); min-width: 0;
  display: flex; flex-direction: column; justify-content: space-between; padding: 5px 7px; color: var(--muted);
}
.cal-d span { font-size: 11px; line-height: 1; }
.cal-d b { font: 700 16px/1 var(--display); color: var(--ink); align-self: center; padding-bottom: 4px; }
@media (max-width: 480px) {
  .cal { gap: 4px; }
  .cal-d { padding: 3px 4px; border-radius: 7px; }
  .cal-d span { font-size: 9px; }
  .cal-d b { font-size: 13px; padding-bottom: 1px; }
}
.cal-d.s1 { background: var(--w1); }
.cal-d.s2 { background: var(--w2); } .cal-d.s2 span, .cal-d.s2 b { color: #fff; }
.cal-d.s3 { background: var(--w3); } .cal-d.s3 span, .cal-d.s3 b { color: var(--paper); }
.cal-d.blank { background: transparent; }
.cal-d.future { background: transparent; border: 1px dashed var(--line); }
.facts { display: grid; gap: 0; margin: 0; }
.facts div { display: grid; grid-template-columns: minmax(110px, 160px) minmax(0, 1fr); gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.facts div:first-child { border-top: 0; }
.facts dt { color: var(--muted); font-size: 14px; }
.facts dd { margin: 0; font-weight: 500; }
.report-foot { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 14px; }

@media print {
  :root { --paper: #fff; --surface: #fff; --ink: #1d1516; --muted: #6a5c5a; --line: #e2d8d5; }
  .bar, .report-nav, .toast { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
  .report { border: 0; padding: 0; }
  .cal-d, .rstat, .goalbar, .medal-badge { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

/* ---------- Taking a test (laid out like the ENGLISH CARE Google Form) ---------- */
.test-wrap { max-width: 760px; }
.gf { display: grid; gap: 12px; margin-top: 14px; }
.gf-banner { background: var(--brand); color: var(--on-brand); border-radius: var(--r); padding: 28px 24px; font: 700 clamp(26px, 6vw, 40px)/1 var(--display);
  letter-spacing: .06em; }
.gf-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px 22px; display: grid; gap: 10px; }
.gf-head { border-top: 10px solid var(--brand); }
.gf-head h1 { font: 600 clamp(22px, 4.5vw, 30px)/1.2 var(--display); text-wrap: balance; }
.gf-head p { margin: 0; }
.gf-who { font-size: 14px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; overflow-wrap: anywhere; }
.gf-req { font-size: 14px; color: var(--bad); }
.ipa-chart { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.ipa-chart summary { cursor: pointer; font-weight: 600; color: var(--brand-deep); }
.ipa-chart[open] summary { margin-bottom: 8px; }
.ipa-group h3 { font: 600 13px var(--body); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 10px 0 6px; }
.ipa-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; }
.ipa-grid div { background: var(--brand-soft); border-radius: 8px; padding: 6px 8px; display: grid; }
.ipa-grid .ipa { font-size: 19px; color: var(--brand-deep); }
.ipa-grid small { color: var(--muted); font-size: 12px; }
.gf-q { transition: border-color .15s; }
.gf-q:focus-within { border-color: var(--brand); box-shadow: inset 4px 0 0 var(--brand); }
.gf-qhead { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-weight: 400; }
.gf-qhead .ipa { font-size: clamp(22px, 5vw, 28px); }
.gf-qhead .req { color: var(--bad); }
.gf-qhead .pts { color: var(--muted); font-size: 13px; white-space: nowrap; }
.gf-q input { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; padding: 8px 0; font-size: 17px; width: min(100%, 360px); color: var(--ink); }
.gf-q input:focus { outline: none; box-shadow: none; border-bottom: 2px solid var(--brand); }
.gf-q.bad { border-color: var(--bad); }
.gf-q.bad input { border-bottom-color: var(--bad); }
.gf-err { color: var(--bad); font-size: 13px; }
.gf-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 4px 0 20px; }
.gf-foot #gfClear { margin-left: auto; }
.gf-formerr { color: var(--bad); font-size: 14px; }
.gf-result .gf-score { display: flex; align-items: baseline; gap: 14px; }
.gf-result .gf-score .num { font: 700 48px/1 var(--display); color: var(--brand-deep); }
.gf-result .gf-score small { font-size: 22px; color: var(--muted); }
.gf-today { font-weight: 600; color: var(--good); }
.gf-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.gf-q.ok { box-shadow: inset 4px 0 0 var(--good); }
.gf-q.wrong { box-shadow: inset 4px 0 0 var(--bad); }
.gf-given { font-size: 17px; overflow-wrap: anywhere; }
.gf-q.ok .gf-given span { color: var(--good); }
.gf-q.wrong .gf-given { color: var(--bad); }
.gf-correct { font-size: 15px; }
.gf-correct b { color: var(--good); }

/* ---------- Words to practise (monthly report) ---------- */
.practise { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.practise div { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 2px; min-width: 0; }
.practise b { font-size: 17px; }
.practise .ipa { color: var(--brand-deep); }
.practise small { color: var(--muted); overflow-wrap: anywhere; }

/* ---------- Test editor (teacher) ---------- */
dialog.test-editor { width: min(720px, calc(100vw - 24px)); }
dialog.test-editor form > *, .test-editor .two > * { min-width: 0; }
.test-editor .two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.test-editor input { min-width: 0; width: 100%; }
.test-editor p.pill { white-space: normal; border-radius: 10px; }
.qhead, .qrow { display: grid; grid-template-columns: 26px minmax(0, 1fr) minmax(0, 1.4fr) 34px; gap: 8px; align-items: center; }
.qhead { font-size: 12px; font-weight: 600; color: var(--muted); }
.qhead small { font-weight: 400; }
.qrows { display: grid; gap: 6px; max-height: 46vh; overflow-y: auto; padding-right: 2px; }
.qrow .qn { color: var(--muted); font-size: 13px; text-align: right; }
.qrow input.ipa { font-size: 18px; }
@media (max-width: 520px) { .qhead small { display: none; } .qhead, .qrow { grid-template-columns: 18px minmax(0, 1.25fr) minmax(0, 1fr) 30px; gap: 6px; } .qrow input.ipa { font-size: 16px; } }

/* ---------- Attempt history ---------- */
.row .t > .trail { display: block; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: normal; overflow: visible; }
.trail small, .hist-trail small { color: var(--muted); }
.gf-prev { margin: 0; font-size: 15px; color: var(--muted); }
.gf-prev b { color: var(--ink); font-variant-numeric: tabular-nums; }
.gf-prev .up, .hist-change.up { color: var(--good); }
.gf-prev .down, .hist-change.down { color: var(--bad); }
dialog.hist-dialog { width: min(620px, calc(100vw - 24px)); }
.hist { display: grid; gap: 14px; min-width: 0; padding: 22px; }
.hist-dialog > .empty, .hist-dialog > .err { padding: 22px; }
.hist-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.hist-trail { font: 600 20px/1.3 var(--display); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.hist-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 60vh; overflow-y: auto; }
.hist-list details { border: 1px solid var(--line); border-radius: 10px; }
.hist-list summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 10px 12px; cursor: pointer; }
.hist-n { font-weight: 600; min-width: 80px; }
.hist-when { color: var(--muted); font-size: 14px; flex: 1; }
.hist-score { font-weight: 600; font-variant-numeric: tabular-nums; }
.hist-change { font-size: 13px; color: var(--muted); min-width: 56px; }
.hist-answers { list-style: none; margin: 0; padding: 0 12px 12px; display: grid; gap: 4px; }
.hist-answers li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 10px; font-size: 15px; border-top: 1px solid var(--line); padding-top: 4px; }
.hist-answers li > * { min-width: 0; overflow-wrap: anywhere; }
.hist-answers .ok span:last-child { color: var(--good); }
.hist-answers .wrong span:last-child { color: var(--bad); }
.hist-answers small { color: var(--ink); }
.hist-none { margin: 0; padding: 0 12px 12px; font-size: 14px; }

/* ---------- Letter keyboard on phones and tablets (no word suggestions) ---------- */
.kb { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line);
  box-shadow: 0 -6px 20px rgb(0 0 0 / .08); display: grid; gap: 6px; user-select: none; -webkit-user-select: none;
  padding: 8px max(6px, env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(6px, env(safe-area-inset-left, 0px)); }
.kb-row { display: flex; gap: 5px; justify-content: center; }
.kb button { flex: 1 1 0; max-width: 64px; min-width: 0; height: 46px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
  color: var(--ink); font: 500 20px/1 var(--body); touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.kb button:active { background: var(--brand-soft); border-color: var(--brand); }
.kb .kb-wide { flex-grow: 1.6; max-width: 96px; font-size: 16px; }
.kb .kb-space { flex-grow: 4; max-width: 260px; font-size: 14px; color: var(--muted); }
.kb .kb-next { background: var(--brand); color: var(--on-brand); border-color: var(--brand); font-weight: 600; }
/* Read-only boxes show no caret, so the box being typed into is marked clearly instead. */
body.has-kb .gf-q:focus-within { background: var(--brand-soft); }
body.has-kb .gf-q input:focus { border-bottom-width: 3px; }
body.has-kb main { padding-bottom: calc(250px + env(safe-area-inset-bottom, 0px)); }
@media print { .kb { display: none; } }

/* Corrections can't be selected to copy into another test. */
.no-copy { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
