/* Shared look, copied from DegreeOS (colours, buttons, tutor cards). */
:root {
  --paper: #F4F6FA;
  --surface: #FFFFFF;
  --sunk: #EBEFF6;
  --ink: #17203A;
  --ink-2: #505B76;
  --ink-3: #5F6984;
  --line: #D9DFEA;
  --accent: #2443CF;
  --accent-soft: #E3E8FC;
  --on-accent: #FFFFFF;
  --hl: #FFE45A;
  --hl-ink: #2A2200;
  --ok: #17703F;
  --ok-soft: #E1F3E8;
  --warn: #9A5B00;
  --warn-soft: #FFF1D6;
  --bad: #C0262D;
  --bad-soft: #FDE4E4;
  --pad-paper: #FFFFFF;
  --pad-grid: #DCE6F5;
  --c-calc: #3F51B5; --c-la: #039BE5; --c-chem: #F4511E; --c-graph: #8E24AA;
  --c-prog: #33B679; --c-earth: #0B8043; --c-me: #D50000; --c-sust: #616161;
  --c-study: #F6BF26; --c-startup: #7986CB; --c-routine: #8D96AD;
  --display: "Fredoka", "Rubik", ui-rounded, system-ui, sans-serif;
  --body: "Rubik", system-ui, -apple-system, "Segoe UI", sans-serif;
  --hand: "Caveat", "Rubik", "Comic Sans MS", cursive;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --r: 14px;
  --r-sm: 9px;
  --shadow: 0 1px 2px rgba(23, 32, 58, .06), 0 6px 18px rgba(23, 32, 58, .06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0D1220; --surface: #161D2F; --sunk: #1D2539; --ink: #E8ECF6; --ink-2: #A5AFC8; --ink-3: #7A85A1;
    --line: #2A3450; --accent: #8EA2FF; --accent-soft: #232D52; --on-accent: #0D1220; --hl: #E3C93E; --hl-ink: #1E1900;
    --ok: #63CF92; --ok-soft: #173426; --warn: #F2B65A; --warn-soft: #3A2C12; --bad: #FF8A8A; --bad-soft: #3D1A1D;
    --pad-paper: #FFFFFF; --pad-grid: #DCE6F5;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 22px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0D1220; --surface: #161D2F; --sunk: #1D2539; --ink: #E8ECF6; --ink-2: #A5AFC8; --ink-3: #7A85A1;
  --line: #2A3450; --accent: #8EA2FF; --accent-soft: #232D52; --on-accent: #0D1220; --hl: #E3C93E; --hl-ink: #1E1900;
  --ok: #63CF92; --ok-soft: #173426; --warn: #F2B65A; --warn-soft: #3A2C12; --bad: #FF8A8A; --bad-soft: #3D1A1D;
  --pad-paper: #FFFFFF; --pad-grid: #DCE6F5;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 22px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

html, body { height: 100%; }
body { background: var(--paper); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
* { box-sizing: border-box; }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; line-height: 1.15; margin: 0; text-wrap: balance; letter-spacing: -0.005em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.08rem; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono, .tnum { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.small { font-size: .86rem; }
.crow { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.crow:last-child { border-bottom: 0; }
.crow bdi[dir] { font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.big small { font: 600 1.1rem var(--body); letter-spacing: 0; margin-inline-start: 8px; }
.eyebrow { font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }

/* ---------- app frame ---------- */
.app { display: grid; grid-template-columns: 92px minmax(0, 1fr); min-height: 100%; }
.rail { position: sticky; top: env(safe-area-inset-top, 0px); height: 100vh; height: 100dvh; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 6px; padding-left: max(6px, env(safe-area-inset-left, 0px)); border-right: 1px solid var(--line); background: var(--surface); overflow-y: auto; }
.brand { font-family: var(--display); font-weight: 700; font-size: 1.05rem; line-height: 1; text-align: center; margin: 2px 0 14px; color: var(--ink); }
.brand b { display: grid; place-items: center; width: 44px; height: 44px; margin: 0 auto 6px; border-radius: 13px; background: var(--accent); color: var(--on-accent); font-size: 1.15rem; }
.navbtn { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 78px; padding: 8px 4px; border: 0; border-radius: 12px; background: transparent; color: var(--ink-2); font-size: .74rem; font-weight: 500; cursor: pointer; }
@media (max-height: 900px) and (min-width: 861px) { .navbtn { padding: 5px 4px; } .brand { margin-bottom: 8px; } }
@media (max-height: 790px) and (min-width: 861px) { .navbtn { padding: 3px 4px; } .brand { margin-bottom: 4px; } }
.navbtn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.navbtn:hover { background: var(--sunk); color: var(--ink); }
.navbtn[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.navbtn .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--bad); margin-top: -2px; }
main { min-width: 0; padding-block: 22px 60px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.view { max-width: 1120px; margin: 0 auto; display: grid; gap: 18px; }
.vhead { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 10px 18px; }
.vhead .sub { color: var(--ink-2); margin-top: 4px; }

@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; z-index: 30; top: auto; bottom: 0; left: 0; right: 0; height: auto; flex-direction: row; justify-content: flex-start; gap: 2px; padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px)); border-right: 0; border-top: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; }
  .brand { display: none; }
  .navbtn { width: 64px; flex: 0 0 auto; padding: 6px 2px; font-size: .68rem; }
  main { padding-block: 16px 110px; }
  h1 { font-size: 1.55rem; }
}

/* ---------- shared pieces ---------- */
.stickies { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.stickies .empty { grid-column: 1 / -1; }
.sticky { position: relative; background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); border-radius: 12px; padding: 10px 30px 8px 12px; }
.sticky textarea { width: 100%; min-height: 64px; border: 0; background: transparent; color: var(--ink); font: inherit; line-height: 1.45; resize: none; padding: 0; outline: none; }
.sticky:focus-within { box-shadow: 0 0 0 2px var(--accent); }
#toast-undo { color: var(--paper); text-decoration: underline; margin-inline-start: 6px; }
.sticky .stickydel { position: absolute; top: 4px; inset-inline-end: 4px; padding: 2px 8px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; min-width: 0; }
.card.tight { padding: 14px; }
.card > h2, .card > h3 { margin-bottom: 10px; }
.chead { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px; margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; align-items: start; }
.stack { display: grid; gap: 12px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 15px; border: 1px solid transparent; border-radius: 11px; background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: .92rem; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.quiet { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.quiet:hover { background: var(--sunk); }
.btn.ghost { background: transparent; color: var(--accent); border-color: transparent; padding-inline: 8px; }
.btn.danger { color: var(--bad); }
.btn.big { min-height: 52px; padding: 12px 22px; font-size: 1.02rem; border-radius: 14px; }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: .84rem; border-radius: 9px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--sunk); flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 13px; border-radius: 9px; font-weight: 500; color: var(--ink-2); cursor: pointer; font-size: .9rem; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.field { display: grid; gap: 5px; min-width: 0; }
.field > span { font-size: .82rem; font-weight: 500; color: var(--ink-2); }
input[type="text"], input[type="search"], input[type="date"], input[type="time"], input[type="number"], input[type="datetime-local"], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; line-height: 1.45; }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 600; background: var(--sunk); color: var(--ink-2); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.acc { background: var(--accent-soft); color: var(--accent); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--c, var(--ink-3)); flex: 0 0 auto; }
.cchip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 7px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: color-mix(in srgb, var(--c) 14%, var(--surface)); color: var(--ink); white-space: nowrap; }
.cchip::before { content: ""; width: 9px; height: 9px; border-radius: 3px; background: var(--c); }
.notice { padding: 11px 14px; border-radius: 11px; background: var(--sunk); color: var(--ink); font-size: .92rem; }
.notice.warn { background: var(--warn-soft); }
.notice.bad { background: var(--bad-soft); }
.notice.ok { background: var(--ok-soft); }
.notice strong { font-weight: 600; }
.empty { color: var(--ink-3); font-size: .92rem; padding: 6px 0; }
.thinking { color: var(--ink-3); font-style: italic; }
.thinking::after { content: "…"; animation: blink 1.2s steps(3, end) infinite; }

/* ---------- Tutor: CGP-style revision pages and hint cards ---------- */
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; }
.cgp { --c: var(--accent); background: var(--surface); border: 2px solid color-mix(in srgb, var(--c) 55%, var(--line)); border-radius: 18px; overflow: hidden; line-height: 1.6; }
.cgp .band { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 14px 18px 12px; background: var(--c); color: #fff; }
.cgp .band h2, .cgp .band h3 { color: #fff; font-weight: 700; font-size: 1.45rem; }
.cgp .band .tab { padding: 3px 10px; border-radius: 8px; background: rgba(255, 255, 255, .22); font-size: .78rem; font-weight: 600; letter-spacing: .03em; }
.cgp .pagebody { padding: 20px 18px; display: grid; gap: 22px; }
.cgp .hook { font-size: 1.08rem; font-weight: 500; }
.cgp .hook mark { background: var(--hl); color: var(--hl-ink); padding: 0 3px; border-radius: 3px; }
.cgp h4 { font-family: var(--display); font-size: 1.14rem; font-weight: 700; color: var(--c); display: flex; align-items: center; gap: 8px; }
.cgp h4::before { content: ""; width: 14px; height: 14px; border-radius: 4px; background: var(--c); flex: 0 0 auto; }
.cgp .cg-sec { display: grid; gap: 14px; }
.cgp .cg-body { display: grid; gap: 8px; }
.cgp .cg-body ul, .cgp .cg-body ol { margin: 0; padding-inline-start: 22px; display: grid; gap: 4px; }
.learnbox { position: relative; border: 2.5px dashed color-mix(in srgb, var(--c) 70%, var(--ink)); border-radius: 14px; padding: 16px 14px 12px; background: color-mix(in srgb, var(--c) 6%, var(--surface)); }
.tagl { position: absolute; top: -12px; left: 14px; padding: 1px 10px; border-radius: 7px; font-family: var(--display); font-weight: 700; font-size: .82rem; letter-spacing: .04em; background: var(--c); color: #fff; }
.learnbox .mj { overflow-x: auto; overflow-y: hidden; font-size: 1.08rem; }
.example { position: relative; border: 2px solid var(--ink); border-radius: 14px; padding: 20px 16px 14px; }
.example > .tagl { background: var(--ink); color: var(--paper); }
.example .exq { font-weight: 500; margin-bottom: 12px; }
.steps2 { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; counter-reset: st; }
.steps2 li { display: grid; grid-template-columns: 28px minmax(0, 1fr) minmax(0, .8fr); gap: 4px 12px; align-items: center; counter-increment: st; padding: 10px 0; border-top: 1px dashed var(--line); }
.steps2 li:first-child { border-top: 0; padding-top: 2px; }
.steps2 li::before { content: counter(st); display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--c); color: #fff; font-family: var(--display); font-weight: 700; font-size: .86rem; align-self: start; margin-top: 2px; }
.steps2 li.has-say .say { grid-column: 2 / -1; font-weight: 500; }
.steps2 li.has-say::before { grid-row: 1 / span 2; }
.steps2 .sm { overflow-x: auto; overflow-y: hidden; min-width: 0; }
.hand { font-family: var(--hand); font-size: 1.32rem; line-height: 1.1; color: var(--accent); position: relative; padding-left: 26px; }
.hand::before { content: "\2190"; position: absolute; left: 0; top: -1px; font-family: var(--body); font-size: 1.1rem; }
@media (max-width: 640px) { .steps2 li { grid-template-columns: 24px minmax(0, 1fr); gap: 4px 8px; } .steps2 li::before { width: 22px; height: 22px; font-size: .78rem; } .steps2 .hand, .steps2 li.has-say .say { grid-column: 2; } .cgp .pagebody { padding: 16px 12px; } .example { padding: 18px 10px 12px; } .learnbox { padding: 16px 10px 10px; } .hand { font-size: 1.2rem; } }
.mmore { -webkit-mask-image: linear-gradient(to right, #000 82%, transparent); mask-image: linear-gradient(to right, #000 82%, transparent); }
.answer { display: inline-block; margin-top: 10px; padding: 4px 12px; border: 2px solid var(--ink); border-radius: 10px; font-weight: 600; }
.bubble { position: relative; padding: 12px 16px; border-radius: 16px; background: var(--hl); color: var(--hl-ink); }
.bubble::after { content: ""; position: absolute; left: 26px; bottom: -10px; border: 10px solid transparent; border-top-color: var(--hl); border-bottom: 0; }
.bubble b.lbl { font-family: var(--display); font-weight: 700; margin-right: 6px; }
.watch { position: relative; padding: 14px 14px 12px; border-radius: 12px; background: var(--bad-soft); border: 2px solid var(--bad); }
.watch > .tagl { background: var(--bad); }
.turn { position: relative; padding: 16px 14px 12px; border-radius: 12px; background: var(--ok-soft); border: 2px solid var(--ok); }
.turn > .tagl { background: var(--ok); }
.practice { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; counter-reset: pq; }
.practice li { counter-increment: pq; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; }
.practice li::before { content: counter(pq) ")"; font-family: var(--display); font-weight: 700; color: var(--c); font-size: 1.05rem; }
.practice .ans { margin-top: 6px; padding: 8px 12px; border-radius: 10px; background: var(--sunk); }
.cgp .qrow { display: flex; gap: 10px; justify-content: space-between; align-items: baseline; }
.cgp .marks { flex: 0 0 auto; font-size: .86rem; color: var(--ink-2); white-space: nowrap; }
.cgp .cgfoot { padding: 12px 16px; border-radius: 14px; background: color-mix(in srgb, var(--c) 9%, var(--surface)); }
.cgp .cgfoot b { display: block; font-family: var(--display); font-weight: 700; color: var(--c); }
.source { font-size: .84rem; color: var(--ink-2); border-top: 1px dashed var(--line); padding-top: 10px; }
.source.general::before { content: "General explanation"; margin-right: 8px; padding: 1px 8px; border-radius: 6px; background: var(--sunk); font-weight: 600; color: var(--ink-2); }
.hladder { display: inline-flex; gap: 4px; vertical-align: middle; }
.hladder i { width: 18px; height: 8px; border-radius: 4px; background: var(--sunk); }
.hladder i.on { background: var(--c-study); }

.msg { padding: 12px 14px; border-radius: 12px; background: var(--sunk); }
.msg .who { font-size: .76rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin-bottom: 4px; }
.msg.solution { background: var(--accent-soft); }
.msg .txt ul, .msg .txt ol { margin: 6px 0; padding-left: 22px; }
.fb .verdict { display: inline-flex; margin-bottom: 8px; }
.fb ol.fsteps { margin: 8px 0; padding-left: 0; list-style: none; display: grid; gap: 6px; }
.fb ol.fsteps li { display: flex; gap: 8px; align-items: baseline; }
@keyframes blink { 50% { opacity: .3; } }
