:root { --bg:#f4f7f2; --card:#fff; --ink:#1d2b22; --muted:#5d6f63; --accent:#2f8a57; --accent-ink:#fff;
        --line:#dde5dc; --good:#2f8a57; --mid:#c58a12; --bad:#c2453a; --bubble:#ffffff; --rec:#d6334a; }
@media (prefers-color-scheme: dark) {
  :root { --bg:#111814; --card:#1a231d; --ink:#e6efe8; --muted:#9fb2a5; --accent:#4fb37a; --accent-ink:#0b130e;
          --line:#2b372f; --good:#4fb37a; --mid:#e0a93a; --bad:#e3685d; --bubble:#223027; --rec:#ff5c72; }
}
* { box-sizing:border-box; }
body { margin:0; background:var(--bg); color:var(--ink); font:17px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
header { display:flex; align-items:center; gap:10px; flex-wrap:wrap; max-width:820px; margin:0 auto; padding:14px 16px 0; }
.back { font-weight:600; }
.brand { font-weight:700; font-size:20px; margin-right:auto; border:none; background:none; padding:4px 0; }
.brand .muted { font-size:16px; font-weight:400; }
main { max-width:820px; margin:0 auto; padding:12px 16px 64px; }
h2 { font-size:17px; margin:0 0 8px; }
.muted { color:var(--muted); font-size:14px; }
.hidden { display:none !important; }
.err { color:var(--bad); }
a { color:var(--accent); }

button { font:inherit; border:1px solid var(--line); background:var(--card); color:var(--ink); border-radius:10px;
         padding:9px 15px; cursor:pointer; }
button.primary { background:var(--accent); color:var(--accent-ink); border-color:var(--accent); font-weight:600; }
button:disabled { opacity:.5; cursor:default; }
.chip { border-radius:999px; padding:7px 13px; font-size:15px; }
.chip.on { background:var(--accent); color:var(--accent-ink); border-color:var(--accent); }

.stage { display:flex; align-items:center; gap:18px; margin:10px 0 16px; }
.avatar { width:170px; flex:0 0 170px; aspect-ratio:1; }
.avatar-svg { width:100%; height:100%; display:block; filter:drop-shadow(0 4px 10px rgba(0,0,0,.12)); }
.bubble { position:relative; flex:1; background:var(--bubble); border:1px solid var(--line); border-radius:16px;
          padding:14px 16px; min-height:64px; font-size:18px; white-space:pre-wrap; }
.bubble::before { content:""; position:absolute; left:-9px; top:28px; width:16px; height:16px; background:var(--bubble);
          border-left:1px solid var(--line); border-bottom:1px solid var(--line); transform:rotate(45deg); }
.bubble:empty { visibility:hidden; }
@media (max-width:600px) {
  /* on a phone the face sits beside the bubble, so the screen below it starts higher up */
  .stage { gap:12px; margin:4px 0 12px; align-items:flex-start; }
  .avatar { width:92px; flex:0 0 92px; }
  .bubble { font-size:16px; padding:10px 12px; }
  .bubble::before { top:22px; }
}

.card { background:var(--card); border:1px solid var(--line); border-radius:14px; padding:18px; margin-bottom:14px; }
.tag { font-size:13px; color:var(--muted); margin-bottom:6px; }
.qhead { display:flex; justify-content:space-between; align-items:flex-start; gap:10px; }
.marks { flex:none; font-size:14px; font-weight:700; padding:3px 11px; border-radius:999px; white-space:nowrap;
         background:color-mix(in srgb, var(--accent) 14%, transparent); color:var(--accent); }
.marks.good { background:color-mix(in srgb, var(--good) 16%, transparent); color:var(--good); }
.marks.mid { background:color-mix(in srgb, var(--mid) 18%, transparent); color:var(--mid); }
.marks.bad { background:color-mix(in srgb, var(--bad) 14%, transparent); color:var(--bad); }
.q { font-size:19px; white-space:pre-wrap; }
.fbq { font-size:16px; color:var(--muted); margin-bottom:8px; }
.bytopic tr.weakest td { font-weight:700; }
.bytopic .start { font-weight:400; font-size:.85em; color:var(--mid); }
.row { display:flex; gap:8px; flex-wrap:wrap; margin-top:12px; }
.opt { display:block; width:100%; text-align:left; margin-top:8px; }
textarea, input[type=text], select { width:100%; font:inherit; padding:9px 11px; border-radius:10px; border:1px solid var(--line);
           background:var(--bg); color:var(--ink); }
textarea { min-height:90px; margin-top:12px; }
.topics { display:grid; grid-template-columns:repeat(auto-fill, minmax(250px,1fr)); gap:6px; margin:8px 0 14px; }
.topics label { display:flex; gap:8px; align-items:flex-start; font-size:15px; }
.mood .emo { font-size:24px; line-height:1; }
.mood button.on { background:var(--accent); color:var(--accent-ink); }
.hint { color:var(--muted); font-style:italic; margin-top:10px; }
.fb.good { border-left:5px solid var(--good); } .fb.mid { border-left:5px solid var(--mid); } .fb.bad { border-left:5px solid var(--bad); }
.meter { height:8px; background:var(--line); border-radius:4px; overflow:hidden; margin-top:10px; }
.meter span { display:block; height:100%; background:var(--accent); transition:width .6s; }
.note { margin-top:8px; }
.progress { margin-top:14px; padding-top:10px; border-top:1px solid var(--line); }
.ptitle { font-size:14px; font-weight:600; }
.ptitle .muted { font-weight:400; font-size:13px; display:block; }
.meter.mastery { position:relative; overflow:visible; }
.meter.mastery span { border-radius:4px; }
.meter.mastery i { position:absolute; left:85%; top:-4px; bottom:-4px; width:2px; background:var(--ink); opacity:.55; }
pre { white-space:pre-wrap; font-size:13px; }
.foot { margin-top:24px; }

.talkrow { margin-top:12px; display:flex; flex-direction:column; gap:8px; }
.mic { display:inline-flex; align-items:center; gap:10px; font-weight:600; padding:12px 18px; border-radius:999px;
       align-self:flex-start; }
.mic .dot { width:12px; height:12px; border-radius:50%; background:var(--muted); }
.mic.listening { border-color:var(--rec); color:var(--rec); }
.mic.listening .dot { background:var(--rec); animation:pulse 1s infinite; }
.mic.small { padding:9px 12px; }
.heard { color:var(--muted); font-style:italic; min-height:1.5em; }
@keyframes pulse { 50% { transform:scale(1.5); opacity:.5; } }
.askrow { display:flex; gap:8px; }
.askrow input { flex:1; }

dialog { border:none; border-radius:18px; padding:0; width:min(900px, calc(100% - 32px)); background:var(--card); color:var(--ink); }
dialog::backdrop { background:rgba(0,0,0,.45); }
.custom-head { display:flex; justify-content:space-between; align-items:center; padding:16px 18px; border-bottom:1px solid var(--line); }
.custom-head h2 { margin:0; font-size:20px; }
.custom-body { display:flex; gap:20px; padding:18px; max-height:75vh; overflow:auto; }
.preview { flex:0 0 240px; display:flex; flex-direction:column; align-items:center; gap:10px; position:sticky; top:0; align-self:flex-start; }
.preview .avatar { width:240px; flex-basis:auto; }
.controls { flex:1; display:flex; flex-direction:column; gap:12px; }
dialog.narrow { width:min(480px, calc(100% - 32px)); }
.profile-body { padding:18px; }
.profile-body p { margin:0; }
.field { display:flex; flex-direction:column; gap:4px; font-size:14px; color:var(--muted); }
.check { font-size:14px; display:flex; gap:8px; align-items:center; }
.group h3 { font-size:14px; color:var(--muted); margin:6px 0; font-weight:600; }
.swatches, .choices { display:flex; flex-wrap:wrap; gap:6px; }
.swatch { width:32px; height:32px; border-radius:50%; padding:0; border:2px solid var(--line); }
.swatch.on { outline:3px solid var(--accent); outline-offset:2px; }
.choices button { padding:6px 11px; font-size:14px; border-radius:999px; }
.choices button.on { background:var(--accent); color:var(--accent-ink); border-color:var(--accent); }
@media (max-width:640px) {
  .custom-body { flex-direction:column; }
  .preview { position:static; flex-basis:auto; align-self:center; }
  .preview .avatar { width:180px; }
}

/* home page */
.small { font-size:14px; }
button.small { padding:6px 12px; }
.view { animation:fade .25s ease; }
@keyframes fade { from { opacity:0; transform:translateY(6px); } }
/* the menu button: About me, Customise, Finish, Reports */
.menuwrap { position:relative; }
#menuBtn { font-size:18px; padding:5px 13px; }
.menu { position:absolute; right:0; top:calc(100% + 6px); z-index:20; min-width:210px; display:flex; flex-direction:column;
        background:var(--card); border:1px solid var(--line); border-radius:12px; padding:6px;
        box-shadow:0 8px 24px rgba(0,0,0,.14); }
.menu button { border:none; background:none; text-align:left; padding:10px 12px; border-radius:8px; }
.menu button:hover, .menu button:focus-visible { background:var(--bg); }
@media (max-width:420px) { header .wide, .brand .muted { display:none; } header { gap:6px; } }

.mood { display:flex; justify-content:center; gap:8px; margin:0 0 14px; }
.mood button { flex:0 1 64px; padding:6px 0; border-radius:999px; }
.wish { margin-bottom:14px; }
#topicSel { margin-bottom:12px; }
.tiles { display:grid; grid-template-columns:repeat(3, 1fr); gap:10px; }
.tile { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:6px; text-align:center;
        padding:16px 8px; border-radius:14px; border:1px solid var(--line); background:var(--card); cursor:pointer;
        position:relative; transition:transform .12s, border-color .12s; }
.tile:hover { transform:translateY(-2px); border-color:var(--accent); }
.tile .ico { font-size:28px; line-height:1.1; }
.tile b { font-size:16px; }
.tile.wide { grid-column:1 / -1; flex-direction:row; gap:10px; padding:12px; }
.tile.wide .ico { font-size:22px; }
.tile.quiet { grid-column:1 / -1; border:none; background:none; color:var(--muted); font-size:15px; padding:8px; }
.tile.quiet:hover { transform:none; color:var(--ink); }
.topicpicks { display:grid; grid-template-columns:1fr; gap:2px; max-height:220px; overflow:auto; margin-top:6px; }
.topicpicks label { display:flex; gap:6px; align-items:flex-start; font-size:13px; }
.papernote { font-size:14px; color:var(--muted); }
.papernote a { color:var(--accent); }
.stem { border-left:4px solid var(--accent); }
.datatable { border-collapse:collapse; margin:10px 0; font-size:14px; }
.datatable th, .datatable td { border:1px solid var(--line); padding:4px 10px; text-align:center; }
.datatable th { background:color-mix(in srgb, var(--accent) 10%, transparent); }
.bytopic { width:100%; border-collapse:collapse; margin-top:12px; font-size:14px; }
.bytopic td { padding:4px 6px; border-top:1px solid var(--line); }
.bytopic td.n { text-align:right; white-space:nowrap; }
.bytopic .meter { min-width:80px; }
.tile.rec { border:2px solid var(--accent); box-shadow:0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.tile.rec::after { content:"Suggested"; position:absolute; top:-9px; right:50%; transform:translateX(50%); white-space:nowrap; font-size:11px; font-weight:700;
        background:var(--accent); color:var(--accent-ink); padding:2px 8px; border-radius:999px; }

/* plan */
.planbar { display:flex; align-items:center; gap:8px; flex-wrap:wrap; background:var(--card); border:1px solid var(--accent);
        border-radius:12px; padding:8px 12px; margin-bottom:14px; }
.planbar span { flex:1; font-weight:600; }
.steps { list-style:none; padding:0; margin:0; counter-reset:step; }
.steps li { display:flex; gap:12px; align-items:flex-start; padding:10px 0; border-bottom:1px solid var(--line); }
.steps li:last-child { border-bottom:none; }
.steps .ico { font-size:24px; }

/* overview and chat */
.md h3 { font-size:17px; margin:14px 0 4px; color:var(--accent); }
.md p { margin:6px 0; }
.md ul { margin:4px 0; padding-left:22px; }
.chat { display:flex; flex-direction:column; gap:8px; margin-bottom:12px; max-height:55vh; overflow:auto; }
.msg { padding:9px 13px; border-radius:14px; max-width:88%; }
.msg p { margin:4px 0; }
.msg.me { align-self:flex-end; background:var(--accent); color:var(--accent-ink); }
.msg.tutor { align-self:flex-start; background:var(--bg); border:1px solid var(--line); }
.askmark { margin-top:10px; }
.askmark .askbody { margin-top:8px; display:flex; flex-direction:column; gap:8px; }
.askmark .askbody.hidden { display:none; }
.askthread { display:flex; flex-direction:column; gap:8px; }
.askthread:empty { display:none; }
.remark { margin-top:6px; font-weight:700; color:var(--good); }

/* mini exam */
.timer { position:sticky; top:8px; z-index:2; display:flex; align-items:center; gap:14px; padding:10px 16px; }
.timer #clock { font-size:26px; font-weight:700; font-variant-numeric:tabular-nums; min-width:80px; }
.timer .meter { flex:1; margin:0; }
.timer.low #clock { color:var(--bad); }
.timer.low .meter span { background:var(--bad); }
.radios { display:flex; flex-direction:column; gap:6px; margin-top:10px; }
.radios label { display:flex; gap:8px; align-items:flex-start; padding:8px 10px; border:1px solid var(--line); border-radius:10px; cursor:pointer; }
.radios label:has(input:checked) { border-color:var(--accent); background:color-mix(in srgb, var(--accent) 10%, transparent); }
.score { font-size:40px; font-weight:800; }
.score span { font-size:22px; color:var(--muted); margin-left:8px; }
#resList .card > div { margin-top:6px; }
.rating button, #rating button { font-size:18px; }
@media (max-width:600px) {
  .tile { padding:12px 4px; }
  .tile b { font-size:14px; }
}

/* stop / waiting */
.stoprow { display:flex; align-items:center; justify-content:flex-end; gap:10px; margin:-6px 0 12px; }
.stoprow #waitText::before { content:""; display:inline-block; width:8px; height:8px; border-radius:50%;
        background:var(--accent); margin-right:7px; animation:pulse 1s infinite; vertical-align:middle; }
#stopBtn { border-color:var(--bad); color:var(--bad); font-weight:600; }

/* diagrams */
.pic { margin:12px 0; background:#fbfdf8; border:1px solid var(--line); border-radius:12px; padding:8px; cursor:zoom-in;
       text-align:center; color:#1d2b22; }
.pic img, .pic svg { display:block; width:100%; height:auto; max-height:460px; margin:0 auto; }
.pic.flow svg { max-width:640px; overflow:visible; }
.pic.steps { cursor:default; text-align:left; padding:10px 12px; }
.pic.steps ol { list-style:none; margin:0; padding:0; }
.pic.steps li { position:relative; display:flex; gap:10px; align-items:center; background:#e3f1e6; border:1.5px solid #2f8a57;
                border-radius:10px; padding:9px 12px; margin:0 0 22px; line-height:1.35; }
.pic.steps li:last-child { margin-bottom:0; }
.pic.steps li:not(:last-child)::after { content:'↓'; position:absolute; left:50%; bottom:-21px; transform:translateX(-50%);
                color:#2f3d34; font-size:16px; line-height:20px; }
.pic.steps .n { flex:none; width:24px; height:24px; border-radius:50%; background:#2f8a57; color:#fff; font-weight:700;
                font-size:13px; display:flex; align-items:center; justify-content:center; }
.pic.steps .again { margin:8px 0 0; font-size:14px; color:#2f3d34; text-align:center; }
.pic figcaption { font-size:12px; color:#5d6f63; margin-top:4px; }
.pic.drawing { padding:18px; cursor:default; }
.pic.zoom { position:fixed; inset:0; z-index:50; margin:0; border-radius:0; display:flex; flex-direction:column;
            justify-content:center; cursor:zoom-out; padding:16px; }
.pic.zoom img, .pic.zoom svg { max-height:calc(100vh - 60px); max-width:100%; }
.msg.tutor .pic { max-width:520px; }
.msg.tutor .pic.zoom { max-width:none; }  /* full screen means full screen, in the chat too */
.pic.zoom::after { content:'✕  tap or press Esc to close'; position:absolute; top:10px; right:16px; font-size:14px; color:#5d6f63; }
details summary { cursor:pointer; color:var(--accent); font-weight:600; margin-top:10px; }

/* "Something's wrong" and the grown-ups' page */
button.wrong { border:none; background:none; color:var(--muted); font-size:14px; padding:6px 8px; margin-left:auto; }
button.wrong:hover { color:var(--bad); }
button.wrong.done { color:var(--good); }
.msg.tutor button.wrong { display:block; margin:4px 0 0 auto; padding:2px 4px; font-size:13px; }
.toast { position:fixed; left:50%; bottom:16px; transform:translateX(-50%); z-index:40; width:min(560px, calc(100% - 32px));
         background:var(--card); border:1px solid var(--line); border-radius:14px; padding:12px 14px;
         box-shadow:0 8px 24px rgba(0,0,0,.18); display:flex; flex-direction:column; gap:8px; }
.reports { list-style:none; padding:0; margin:8px 0; }
.reports li { padding:8px 0; border-top:1px solid var(--line); font-size:15px; }
.reports li.new { border-left:4px solid var(--mid); padding-left:8px; }
.reports .about { color:var(--ink); }
.reports details { margin-top:6px; }
.reports summary { cursor:pointer; color:var(--accent); font-size:14px; }
.reports dl { margin:6px 0 0; }
.reports dt { font-size:12px; font-weight:700; color:var(--muted); margin-top:8px; text-transform:uppercase; letter-spacing:.03em; }
.reports dd { margin:2px 0 0; white-space:pre-wrap; overflow-wrap:anywhere; }

/* exams */
.tabs { display:flex; gap:8px; margin-bottom:10px; }
#exams h3 { font-size:15px; margin:14px 0 6px; }
#exams .choices button { display:flex; flex-direction:column; align-items:center; line-height:1.2; padding:7px 13px; }
#exams .choices small { font-size:11px; opacity:.8; }
#exams .topicpicks { grid-template-columns:repeat(auto-fill, minmax(230px, 1fr)); max-height:260px; }
.row.tight { margin-top:0; align-items:center; }

/* each mark point: got it, nearly, missing */
.points { list-style:none; padding:0; margin:10px 0 4px; display:flex; flex-direction:column; gap:6px; }
.points li { display:flex; gap:10px; align-items:flex-start; padding:6px 10px; border-radius:10px; font-size:15px;
             border-left:4px solid var(--line); background:var(--bg); }
.points li.got { border-left-color:var(--good); }
.points li.nearly { border-left-color:var(--mid); }
.points li.missing { border-left-color:var(--bad); }
.points .flag { flex:none; font-weight:700; font-size:13px; white-space:nowrap; min-width:84px; }
.points li.got .flag { color:var(--good); } .points li.nearly .flag { color:var(--mid); } .points li.missing .flag { color:var(--bad); }
.pnote { display:block; color:var(--muted); font-size:14px; }
.legend { font-size:12px; color:var(--muted); margin-top:6px; }
.passage { max-height:46vh; overflow-y:auto; margin:6px 0 12px; padding:10px 14px; border:1px solid var(--line);
  border-radius:10px; background:var(--bg); font-size:16px; line-height:1.55; }
.passage p { margin:0 0 8px; }
.cmdword { margin-top:8px; font-size:14px; color:var(--muted); background:var(--bg); border-radius:10px; padding:6px 10px; }

/* labelling */
.labelpic { cursor:default; }
.labelpic svg { max-height:520px; }
.labelpic text.letter { font-size:20px; font-weight:800; fill:#2f8a57; }
.labelpic g.lbl.right text { fill:#2f8a57; } .labelpic g.lbl.missed text { fill:#c2453a; font-weight:700; }
.lblinputs { display:grid; grid-template-columns:repeat(auto-fill, minmax(220px, 1fr)); gap:8px; margin-top:10px; }
.lblinputs label { display:flex; gap:8px; align-items:center; }
.lblinputs label b { min-width:18px; }
.lblinputs label.got, .lblinputs label.missing { padding:6px 10px; border-radius:10px; background:var(--bg); border-left:4px solid var(--good); }
.lblinputs label.missing { border-left-color:var(--bad); }
.sure { display:flex; flex-wrap:wrap; align-items:center; gap:6px; margin-top:10px; font-size:14px; color:var(--muted); }

/* homework: her own work, with her rubric if she has one */
#homework h3 { font-size:16px; margin:16px 0 6px; }
#homework .field { margin-bottom:10px; }
#homework textarea { min-height:120px; }
#hwFile, #hwRubricFile { flex:1; padding:8px; }
.hwlist { margin:14px 0 0; }
.hwlist h4 { font-size:15px; margin:0 0 4px; }
.hwlist ul { margin:0; padding-left:20px; }
.hwlist li { margin-bottom:5px; }
.hwlist.errors h4 { color:var(--bad); }
.hwnext { margin-top:14px; border-left:4px solid var(--accent); padding:6px 0 6px 12px; font-weight:600; }
/* feedback written for a mark that has since been changed on a re-mark */
.superseded { opacity:.7; margin-top:6px; }
.superseded summary { cursor:pointer; font-size:12px; font-weight:700; color:var(--muted); }

.consent { max-height: 46vh; overflow-y: auto; padding: 4px 12px; border: 1px solid var(--line); border-radius: 10px; outline: none; }
.consent:focus-visible { outline: 2px solid var(--accent); }
.consent h4 { margin: 10px 0 2px; }
.consent p { margin: 0 0 6px; }
button.danger { background: var(--bad); color: #fff; border-color: var(--bad); }

/* ===== Comic panels (the "C3" look Tom chose) =====================================================
   Inked outlines, offset shadows and square-cut panels, a cyan highlight and a yellow caption box.
   It sits on top of everything above: the tokens below re-colour the page, and the rules after them
   give the shared pieces (buttons, cards, tiles, the stage) their outlines. Fonts are bundled in
   static/fonts (SIL Open Font License), so it looks the same offline. */
@font-face { font-family:"Archivo"; font-weight:400; font-style:normal; font-display:swap; src:url(fonts/archivo-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family:"Archivo"; font-weight:600; font-style:normal; font-display:swap; src:url(fonts/archivo-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family:"Archivo"; font-weight:800; font-style:normal; font-display:swap; src:url(fonts/archivo-latin-800-normal.woff2) format("woff2"); }
@font-face { font-family:"Archivo"; font-weight:800; font-style:italic; font-display:swap; src:url(fonts/archivo-latin-800-italic.woff2) format("woff2"); }
@font-face { font-family:"DM Mono"; font-weight:400; font-style:normal; font-display:swap; src:url(fonts/dm-mono-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family:"DM Mono"; font-weight:500; font-style:normal; font-display:swap; src:url(fonts/dm-mono-latin-500-normal.woff2) format("woff2"); }

:root { --bg:#ffffff; --card:#ffffff; --ink:#15202b; --muted:#516170; --accent:#0e7bab; --accent-ink:#ffffff;
        --line:#c9d3db; --good:#2c8a4f; --mid:#b57a0c; --bad:#c2453a; --bubble:#ffffff; --rec:#d6334a;
        --edge:#15202b; --shadow:#15202b; --hi:#4cc9f0; --hi-ink:#15202b; --sun:#ffcf3f; --sky:#e4f4fb; --dot:#15202b1f;
        --r:4px; --bw:2px; --mono:"DM Mono", ui-monospace, Consolas, monospace; }
@media (prefers-color-scheme: dark) {
  :root { --bg:#161c2c; --card:#222b44; --ink:#f3efe4; --muted:#a9b2c8; --accent:#6fd3f5; --accent-ink:#15202b;
          --line:#3a4566; --good:#5fc786; --mid:#e8b14a; --bad:#ef7468; --bubble:#222b44; --rec:#ff5c72;
          --edge:#f3efe4; --shadow:#05070d; --hi:#4cc9f0; --hi-ink:#15202b; --sun:#ffcf3f; --sky:#1b2a40; --dot:#ffffff17; }
}
body { font-family:"Archivo", system-ui, -apple-system, "Segoe UI", sans-serif; }
h2 { font-weight:800; }
.brand { font-weight:800; font-style:italic; text-transform:uppercase; letter-spacing:.02em; }
.brand .muted { font:500 13px var(--mono); font-style:normal; text-transform:uppercase; letter-spacing:.06em; }
.tag, .legend, .papernote, .ptitle .muted { font-family:var(--mono); }
.tag { text-transform:uppercase; letter-spacing:.05em; font-size:12px; }

button { border:var(--bw) solid var(--edge); border-radius:var(--r); box-shadow:2px 2px 0 var(--shadow); font-weight:600;
         transition:transform .1s, box-shadow .1s; }
button:active:not(:disabled) { transform:translate(2px, 2px); box-shadow:0 0 0 var(--shadow); }
button.primary { background:var(--hi); color:var(--hi-ink); border-color:var(--edge); font-weight:800; }
.chip { border-radius:var(--r); }
.chip.on { background:var(--edge); color:var(--card); border-color:var(--edge); }
.brand, .menu button, button.wrong, .tile.quiet, .msg.tutor button.wrong { box-shadow:none; }
.brand:active, .menu button:active, button.wrong:active { transform:none; }
button.danger { background:#b8372c; color:#fff; border-color:var(--edge); }   /* one red for both modes: white text stays readable */
#stopBtn { border-color:var(--bad); box-shadow:2px 2px 0 var(--bad); }
.mic.listening { box-shadow:2px 2px 0 var(--rec); }

textarea, input[type=text], select { border:var(--bw) solid var(--edge); border-radius:var(--r); background:var(--card); }
#topicSel { font:500 15px var(--mono); }

/* the stage is a comic panel: dotted sky, the tutor in a round frame, a speech balloon, and a caption box */
.stage { position:relative; padding:16px; border:var(--bw) solid var(--edge); border-radius:var(--r); box-shadow:4px 4px 0 var(--shadow);
         background:var(--sky) radial-gradient(circle, var(--dot) 1.2px, transparent 1.6px) 0 0/12px 12px; }
.stage[data-cap] { padding-top:36px; }
.stage[data-cap]::before { content:attr(data-cap); position:absolute; top:calc(-1 * var(--bw)); left:calc(-1 * var(--bw)); max-width:80%;
         overflow:hidden; text-overflow:ellipsis; white-space:nowrap; background:var(--sun); color:#15202b; border:var(--bw) solid var(--edge);
         padding:2px 9px; font:500 11.5px var(--mono); text-transform:uppercase; letter-spacing:.06em; }
.stage .avatar { border:var(--bw) solid var(--edge); border-radius:50%; overflow:hidden; background:var(--card); }
.avatar-svg { filter:none; }
.bubble { border:var(--bw) solid var(--edge); border-radius:20px; font-weight:600; }
.bubble::before { border-left:var(--bw) solid var(--edge); border-bottom:var(--bw) solid var(--edge); left:-10px; }
@media (max-width:600px) { .stage { padding:12px; } .stage[data-cap] { padding-top:32px; } }

.card { border:var(--bw) solid var(--edge); border-radius:var(--r); box-shadow:4px 4px 0 var(--shadow); }
.planbar { border:var(--bw) solid var(--edge); border-radius:var(--r); box-shadow:3px 3px 0 var(--shadow); background:var(--sun); color:#15202b; }
.menu { border:var(--bw) solid var(--edge); border-radius:var(--r); box-shadow:4px 4px 0 var(--shadow); }
dialog { border:var(--bw) solid var(--edge); border-radius:6px; box-shadow:6px 6px 0 var(--shadow); }
.custom-head { border-bottom:var(--bw) solid var(--edge); }
.toast { border:var(--bw) solid var(--edge); border-radius:var(--r); box-shadow:4px 4px 0 var(--shadow); }
.pic { border:var(--bw) solid var(--edge); border-radius:var(--r); }
.msg { border:var(--bw) solid var(--edge); border-radius:16px; }
.msg.me { background:var(--hi); color:var(--hi-ink); border-color:var(--edge); }
.msg.tutor { background:var(--card); border-color:var(--edge); }
.meter { height:10px; border:1.5px solid var(--edge); border-radius:var(--r); background:var(--card); }
.meter span { background:var(--hi); }
.radios label { border:var(--bw) solid var(--edge); border-radius:var(--r); }
.radios label:has(input:checked) { border-color:var(--edge); background:color-mix(in srgb, var(--hi) 35%, transparent); }
.swatch { border:var(--bw) solid var(--edge); box-shadow:none; }
.swatch.on { outline-color:var(--hi); }
.choices button.on, .mood button.on { background:var(--hi); color:var(--hi-ink); border-color:var(--edge); }

/* home: mood row, and the activity tiles as stuck-on panels */
.mood button, .mic, .choices button { border-radius:var(--r); }
.tile { border:var(--bw) solid var(--edge); border-radius:var(--r); box-shadow:3px 3px 0 var(--shadow); color:var(--ink); }
.tile:hover { transform:translate(-1px, -1px); border-color:var(--edge); box-shadow:5px 5px 0 var(--shadow); }
.tile b { font-weight:800; }
.tile .ico svg { width:26px; height:26px; display:block; fill:none; stroke:currentColor; stroke-width:1.9; stroke-linecap:round; stroke-linejoin:round; }
.tile.wide .ico svg { width:22px; height:22px; }
.tile.rec { background:var(--hi); color:var(--hi-ink); border:var(--bw) solid var(--edge); box-shadow:3px 3px 0 var(--shadow); }
.tile.rec::after { background:var(--edge); color:var(--card); border-radius:var(--r); font:500 10.5px var(--mono); text-transform:uppercase;
                   letter-spacing:.06em; top:-10px; }
.tile.quiet { font:500 13px var(--mono); text-transform:uppercase; letter-spacing:.05em; }
.tile.quiet:hover { box-shadow:none; }
@media (prefers-reduced-motion: reduce) { button, .tile { transition:none; } .tile:hover { transform:none; } }

/* Talk mode: whether the tutor is listening, on every screen */
.talkstate { position:sticky; top:8px; display:block; margin:10px auto 0; z-index:40; max-width:100%;
  padding:8px 16px; border-radius:999px; border:2px solid var(--line); background:var(--bubble); color:inherit;
  font:inherit; font-size:15px; box-shadow:2px 2px 0 rgba(0,0,0,.15); cursor:pointer; white-space:nowrap;
  overflow:hidden; text-overflow:ellipsis; }
.talkstate.ts-listening { border-color:var(--rec); color:var(--rec); animation:listenglow 1.4s ease-in-out infinite; }
.talkstate.ts-hearing { border-color:var(--good); color:var(--good); }
.talkstate.ts-idle { opacity:.85; }
@keyframes listenglow { 50% { box-shadow:0 0 0 6px color-mix(in srgb, var(--rec) 25%, transparent); } }
@media (prefers-reduced-motion: reduce) { .talkstate.ts-listening { animation:none; } }

/* Talk mode pill in the comic look: an inked caption tag, coloured by what the tutor is doing (fixed reds and greens, so white text reads in both modes) */
.talkstate { border:var(--bw) solid var(--edge); border-radius:var(--r); background:var(--card); color:var(--ink);
  box-shadow:3px 3px 0 var(--shadow); font:500 13px var(--mono); text-transform:uppercase; letter-spacing:.05em; }
.talkstate.ts-listening { background:#c22a40; border-color:var(--edge); color:#fff; animation:none; }
.talkstate.ts-hearing { background:#23784a; border-color:var(--edge); color:#fff; }
.talkstate.ts-speaking { background:var(--hi); color:var(--hi-ink); }
.talkstate.ts-listening::before { content:""; display:inline-block; width:8px; height:8px; margin-right:8px; border-radius:50%;
  background:#fff; vertical-align:1px; animation:recdot 1.2s steps(2, jump-none) infinite; }
@keyframes recdot { 50% { opacity:.25; } }
@media (prefers-reduced-motion: reduce) { .talkstate.ts-listening::before { animation:none; } }

/* "Something's wrong": one, in the corner of every screen, for finding bugs while the tutor is built */
button.wrong.corner { position:fixed; left:8px; bottom:8px; margin:0; z-index:20; font-size:13px; opacity:.75;
  background:var(--card, #fff); border-radius:8px; }
button.wrong.corner:hover { opacity:1; }
body { padding-bottom:44px; }   /* so the corner button never covers the end of a page */
/* the feedback card's less-used buttons, behind "⋯" */
details.more { position:relative; }
details.more > summary { list-style:none; cursor:pointer; padding:8px 14px; border-radius:10px; font-weight:700;
  border:2px solid currentColor; user-select:none; }
details.more > summary::-webkit-details-marker { display:none; }
details.more .morebody { display:flex; flex-direction:column; gap:8px; align-items:flex-start; margin-top:8px; }
/* "Start here": one suggestion from what the tutor knows about her, above the tiles */
.starthere { display:flex; align-items:center; gap:12px; justify-content:space-between; }
.starthere .shtext b { display:block; font-size:13px; text-transform:uppercase; letter-spacing:.05em; opacity:.7; }
.starthere .shtext span { font-size:18px; font-weight:700; }
.sure .why { flex-basis:100%; font-size:13px; }

/* Maths: a working box, a final answer line, a row of symbols to tap, and maths shown as it is written */
.mathbox textarea { min-height:110px; font-family:inherit; }
.mathbox .field { display:block; margin-top:10px; }
.symbols { display:flex; flex-wrap:wrap; gap:6px; margin:10px 0 2px; }
.symbols button { min-width:40px; padding:6px 10px; font-size:17px; }
.mathpreview { margin-top:8px; font-size:16px; white-space:pre-line; }
.mathpreview:empty { display:none; }
.rad { border-top:1.5px solid currentColor; padding:0 2px; margin-left:1px; }
sup { font-size:0.75em; }
.working { white-space:pre-line; }

/* The subject switcher: one button per subject, the one she is in highlighted */
.subjects { display:flex; align-items:center; gap:8px; margin:0 0 10px; font-weight:600; }
.subjects select { width:auto; min-width:160px; }
.nextrow { display:flex; justify-content:flex-end; margin:-4px 0 12px; }
.subjectpick { border:1px solid var(--line); border-radius:10px; padding:8px 12px; margin:6px 0; }
.subjectpick legend { padding:0 4px; }
.subjectpick label { display:flex; align-items:center; gap:8px; margin:4px 0; font-weight:400; }
.subjectpick input { width:auto; }
/* the Core/Extended box stays beside each subject: a long name wraps onto a second line inside its label instead
   of pushing the box underneath (on a phone "Biology" did and "Maths" didn't) */
.subjectpick .subjectrow { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.subjectpick .subjectrow label { flex:1 1 auto; min-width:0; }
.subjectpick .subjectrow select { width:auto; flex:0 0 auto; }

/* start-up screen: covers everything until the tutor is ready */
.startup { position:fixed; inset:0; z-index:1000; background:var(--bg); display:flex; align-items:center;
           justify-content:center; padding:16px; }
.startup.hidden { display:none; }
.startupCard { background:var(--card); border:1px solid var(--line); border-radius:18px; padding:28px 24px;
               width:min(460px, 100%); text-align:center; }
.startupCard h2 { margin:0 0 8px; }
.startupBar { height:10px; border-radius:6px; background:var(--line); overflow:hidden; margin:14px 0 4px; }
.startupBar i { display:block; height:100%; width:0; background:var(--accent); transition:width .8s; }
.startupBar.hidden { display:none; }
#startupGo { margin-top:14px; min-width:140px; }
#startupText { white-space:pre-line; }
