:root {
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-2: #e9ede8;
  --text: #1b1f1d;
  --muted: #626a66;
  --line: #dde3dd;
  --accent: #1d6b57;
  --accent-ink: #ffffff;
  --red: #b3261e;
  --good: #2e7d32;
  --warn: #9a6400;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  /* subject colours */
  --s-maths: #2f6fd6; --s-science: #2e8b57; --s-english: #8a4fc7; --s-german: #c2410c; --s-french: #d23f6a;
  --s-pe: #0f8a8a; --s-arts: #b8860b; --s-art: #a0522d; --s-history: #6b6b2a; --s-cs: #475569; --s-other: #8a8f8c;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14181a; --surface: #1d2225; --surface-2: #272d31; --text: #e9ecea; --muted: #a2aaa6;
    --line: #313a3e; --accent: #6fd0b2; --accent-ink: #0b1f19; --red: #ff8a80; --good: #81c784; --warn: #f0b85a;
    --shadow: none;
    --s-maths: #7aa7ff; --s-science: #6fcf97; --s-english: #c39bff; --s-german: #ff9b6a; --s-french: #ff8fb0;
    --s-pe: #5fd3d3; --s-arts: #e8c15a; --s-art: #e0a07a; --s-history: #c9c97a; --s-cs: #a8b4c6; --s-other: #9aa19d;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14181a; --surface: #1d2225; --surface-2: #272d31; --text: #e9ecea; --muted: #a2aaa6;
  --line: #313a3e; --accent: #6fd0b2; --accent-ink: #0b1f19; --red: #ff8a80; --good: #81c784; --warn: #f0b85a;
  --shadow: none;
  --s-maths: #7aa7ff; --s-science: #6fcf97; --s-english: #c39bff; --s-german: #ff9b6a; --s-french: #ff8fb0;
  --s-pe: #5fd3d3; --s-arts: #e8c15a; --s-art: #e0a07a; --s-history: #c9c97a; --s-cs: #a8b4c6; --s-other: #9aa19d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
button, input { font: inherit; color: inherit; }

/* top bar */
.bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px; background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.bar h1 { flex: 1; margin: 0; font-size: 18px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { border: 0; background: none; font-size: 30px; line-height: 1; padding: 0 8px 2px 0; color: var(--accent); cursor: pointer; min-width: 32px; min-height: 36px; }

main { padding: 12px 16px 28px; max-width: 720px; margin: 0 auto; outline: none; }

/* tab bar */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(6, 1fr);
  background: color-mix(in srgb, var(--surface) 94%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 0 6px; font-size: 10.5px; color: var(--muted); min-height: 50px; }
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabs a.on { color: var(--accent); }

/* generic */
h2 { font-size: 22px; margin: 18px 0 8px; }
h3 { font-size: 17px; margin: 20px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin: 10px 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 9px 16px; font-size: 15px; cursor: pointer; min-height: 44px; color: var(--text); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.on { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; }
.chip { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.now { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); color: var(--accent); font-weight: 600; }
.chip.done { color: var(--good); }
.note { font-size: 14px; color: var(--muted); background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.src { font-size: 13px; color: var(--muted); margin-top: 22px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--c, var(--s-other)); }
.warn { color: var(--red); }

/* lists */
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list li + li { border-top: 1px solid var(--line); }
.list a, .list .li { display: flex; align-items: center; gap: 12px; padding: 11px 14px; color: var(--text); min-height: 52px; }
.list .nm { flex: 1; min-width: 0; }
.list .nm b { font-weight: 600; display: block; }
.list .nm .sub { color: var(--muted); font-size: 14px; display: block; }
.list .ic { color: var(--muted); font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.list .chev { color: var(--muted); }

/* today */
.date { font-size: 15px; color: var(--muted); margin: 2px 0 0; }
.hero { display: grid; gap: 10px; margin-top: 10px; }
.now-card { border-left: 5px solid var(--c, var(--accent)); }
.now-card .lbl { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.now-card .subj { font-size: 22px; font-weight: 700; margin: 2px 0; }
.lessons { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.lessons li { display: flex; align-items: center; gap: 12px; padding: 10px 14px; min-height: 48px; }
.lessons li + li { border-top: 1px solid var(--line); }
.lessons .t { width: 98px; flex: none; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
.lessons .s { flex: 1; font-weight: 600; }
.lessons li.past { opacity: .5; }
.lessons li.cur { background: color-mix(in srgb, var(--accent) 9%, var(--surface)); }
.lessons li.brk { min-height: 30px; padding: 4px 14px; font-size: 13px; color: var(--muted); background: var(--surface-2); }
.unit-line { display: flex; align-items: center; gap: 10px; padding: 10px 14px; min-height: 56px; color: var(--text); }
.unit-line .nm { flex: 1; min-width: 0; }
.unit-line .nm b { display: block; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* week */
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg .btn { padding: 8px 12px; min-width: 52px; }

/* practice */
.subj-card { display: flex; flex-direction: column; gap: 4px; border-left: 5px solid var(--c); color: var(--text); }
.subj-card .t { font-size: 20px; font-weight: 700; }
.bar-prog { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.bar-prog i { display: block; height: 100%; background: var(--c, var(--accent)); }
.q-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 14px; }
.q-text { font-size: 19px; line-height: 1.45; margin: 4px 0; }
.passage { font-size: 16px; line-height: 1.55; }
.passage summary { font-weight: 600; cursor: pointer; }
.opts { display: grid; gap: 8px; margin-top: 12px; }
.opt { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px 14px; font-size: 17px; cursor: pointer; min-height: 50px; color: var(--text); }
.opt.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 14%, var(--surface)); }
.opt.wrong { border-color: var(--red); background: color-mix(in srgb, var(--red) 12%, var(--surface)); }
.ans-row { display: flex; gap: 8px; margin-top: 12px; }
.ans-in { flex: 1; min-width: 0; font-size: 20px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-variant-numeric: tabular-nums; }
.ans-in.right { border-color: var(--good); }
.ans-in.wrong { border-color: var(--red); }
.feedback { margin-top: 12px; border-left: 4px solid var(--c, var(--muted)); }
.feedback.ok { --c: var(--good); }
.feedback.no { --c: var(--red); }
.feedback b { display: block; margin-bottom: 4px; }
.score-big { font-size: 44px; font-weight: 750; margin: 6px 0; font-variant-numeric: tabular-nums; }

/* subjects */
.sem h4 { margin: 14px 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sem ul { margin: 4px 0 8px; padding-left: 20px; }
.sem li { margin: 3px 0; }
.sem li.now { font-weight: 650; color: var(--accent); }
.sem .grp { font-weight: 600; margin-top: 8px; }

/* sync + parent view */
.sync .opts .btn { width: 100%; }
.codebox { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }
.codebox code { font: 600 21px/1.2 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .05em; user-select: all; -webkit-user-select: all; word-break: break-all; }
.code-in { width: 100%; font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .05em; text-transform: uppercase; font-size: 17px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.follow-card { display: flex; flex-direction: column; gap: 2px; color: var(--text); border-color: var(--accent); }
.day { margin: 14px 0 4px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.activity { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.activity li { padding: 9px 14px; font-size: 15px; }
.activity li + li { border-top: 1px solid var(--line); }
.activity .tm { display: inline-block; width: 46px; color: var(--muted); font-variant-numeric: tabular-nums; }
select.sel { width: 100%; font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); min-height: 44px; }

.offline { position: fixed; left: 16px; right: 16px; bottom: calc(74px + env(safe-area-inset-bottom)); background: var(--text); color: var(--bg);
  border-radius: 10px; padding: 8px 12px; font-size: 14px; text-align: center; z-index: 6; }
