/* vvis: exercise-book look. Squared paper, subject cover colours, teacher's green pen. */
:root {
  --paper: #f5f7fb;
  --grid: rgba(44, 91, 168, .075);
  --sheet: #ffffff;
  --rule: #dde3ee;
  --ruled: #e3e9f4;
  --ink: #1b2340;
  --ink-soft: #55607a;
  --margin-line: #f2a7ae;
  --pen: #12805c;          /* teacher's green pen: right answers */
  --pen-bg: #e3f4ec;
  --oops: #c43d4f;
  --oops-bg: #fbe8eb;
  --english: #c8323c;
  --humanities: #13877a;
  --maths: #2c5ba8;
  --science: #6e48b5;
  --portuguese: #e39b25;
  --focus: #2c5ba8;
  --radius: 14px;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'Atkinson Hyperlegible', system-ui, sans-serif;
  --hand: 'Gochi Hand', 'Comic Sans MS', cursive;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #131b30; --grid: rgba(255, 255, 255, .035); --sheet: #1b2440; --rule: #2c3658; --ruled: #26304f;
    --ink: #eef1f8; --ink-soft: #a7b0c8; --margin-line: #7a3a48; --pen: #4fd19c; --pen-bg: #173b33;
    --oops: #ff8a98; --oops-bg: #45202c; --focus: #8fb3ff; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #131b30; --grid: rgba(255, 255, 255, .035); --sheet: #1b2440; --rule: #2c3658; --ruled: #26304f;
  --ink: #eef1f8; --ink-soft: #a7b0c8; --margin-line: #7a3a48; --pen: #4fd19c; --pen-bg: #173b33;
  --oops: #ff8a98; --oops-bg: #45202c; --focus: #8fb3ff; color-scheme: dark;
}

* { box-sizing: border-box; }
/* Root size grows with the window: 18px on phones up to 22px on wide screens. Everything sized in rem follows. */
html { -webkit-text-size-adjust: 100%; font-size: clamp(112.5%, 1rem + .4vw, 137.5%); }
body {
  margin: 0; color: var(--ink); font: 400 1.0625rem/1.55 var(--body);
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  min-height: 100vh;
}
/* Side gutters also clear the notch and rounded corners in landscape (index.html sets viewport-fit=cover). */
:root { --gutter-l: max(clamp(16px, 3vw, 48px), env(safe-area-inset-left)); --gutter-r: max(clamp(16px, 3vw, 48px), env(safe-area-inset-right)); }
main { padding: 8px var(--gutter-r) calc(64px + env(safe-area-inset-bottom)) var(--gutter-l); }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; letter-spacing: -.01em; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
a, button, label, summary { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
.booting { text-align: center; padding: 30vh 0; color: var(--ink-soft); }
.hand { font-family: var(--hand); font-size: 1.35em; line-height: 1.2; }
.small { color: var(--ink-soft); font-size: .9rem; }
.lede { color: var(--ink-soft); max-width: 60ch; margin: .25rem 0 1rem; }
.error { color: var(--oops); font-weight: 700; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.section { font-size: 1.3rem; margin: 2.2rem 0 .8rem; }
.page-title { font-size: clamp(2rem, 5vw, 2.8rem); font-weight: 800; margin: .6rem 0 .3rem; }

/* ---------- Header ---------- */
.top { padding: max(14px, env(safe-area-inset-top)) var(--gutter-r) 14px var(--gutter-l); display: flex; align-items: center; gap: 12px; }
.mark { font: 800 1.6rem/1 var(--display); text-decoration: none; letter-spacing: -.04em; color: var(--maths); }
.back { text-decoration: none; color: var(--ink-soft); padding: 6px 10px; border-radius: 999px; white-space: nowrap; }
.back::before { content: '‹ '; }
@media (hover: hover) { .back:hover { background: var(--sheet); color: var(--ink); } }
.spacer { flex: 1; }
.streak { font-weight: 700; white-space: nowrap; }
.who { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--rule); background: var(--sheet); border-radius: 999px; padding: 5px 14px 5px 6px; cursor: pointer; font-weight: 700; }
.who.guest { padding: 8px 14px; color: var(--maths); white-space: nowrap; }
.who .short { display: none; }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--paper); font-size: 1.2rem; }
.avatar.big { width: 56px; height: 56px; font-size: 2rem; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; cursor: pointer; text-decoration: none;
  background: var(--ink); color: var(--paper); font-weight: 700; padding: 11px 20px; border-radius: 999px; box-shadow: 0 3px 0 rgba(0,0,0,.18); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.18); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.big { padding: 14px 26px; font-size: 1.1rem; }
.btn.ghost { background: var(--sheet); color: var(--ink); box-shadow: inset 0 0 0 2px var(--rule); }
.link { background: none; border: 0; padding: 0; color: var(--maths); text-decoration: underline; cursor: pointer; }

/* ---------- Home: year tabs ---------- */
.hello h1 { font-size: clamp(2.2rem, 7vw, 4rem); font-weight: 800; max-width: 16ch; margin: 1.2rem 0 .4rem; letter-spacing: -.03em; }
.years { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: 14px; margin: 1.6rem 0; }
.year-tab { position: relative; display: grid; gap: 2px; padding: 18px 18px 16px; border-radius: var(--radius); text-decoration: none;
  background: var(--sheet); border: 2px dashed var(--rule); color: var(--ink-soft); }
.year-tab .num { font: 800 4.2rem/0.9 var(--display); letter-spacing: -.05em; }
.year-tab .lbl { font-weight: 700; }
.year-tab .sub { font-size: .9rem; }
.year-tab.open { border: 0; background: var(--maths); color: #fff; box-shadow: 0 6px 0 #1d3f78; transition: transform .12s; }
@media (hover: hover) { .year-tab.open:hover { transform: translateY(-3px); } }
.year-tab.open:active { transform: translateY(3px); box-shadow: 0 3px 0 #1d3f78; }
.year-tab.open .sub { opacity: .85; }
.note { background: var(--sheet); border-left: 6px solid var(--portuguese); padding: 14px 18px; border-radius: 0 var(--radius) var(--radius) 0; max-width: 68ch; }

/* ---------- Year page ---------- */
.year-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; margin-top: 1rem; }
.pack-hero { display: grid; gap: 6px; align-content: start; text-decoration: none; padding: 24px; border-radius: var(--radius); background: var(--maths); color: #fff; box-shadow: 0 6px 0 #1d3f78; }
.pack-title { font: 800 2.6rem/1 var(--display); letter-spacing: -.03em; }
.pack-blurb { font-size: 1.1rem; }
.pack-meta { opacity: .85; font-size: .95rem; margin-top: 8px; }
.pack-hero .meter { background: rgba(255,255,255,.25); }
.pack-hero .meter span { background: #fff; }
.pack-hero .meter-label { color: #fff; opacity: .85; }
.review-box { padding: 22px; border-radius: var(--radius); background: var(--sheet); border: 2px solid var(--pen); }
.review-box.quiet { border-color: var(--rule); }
.review-box h2 { margin: 0 0 6px; font-size: 1.5rem; }
.review-box p { margin: 0 0 14px; color: var(--ink-soft); }
.pack-list { display: grid; gap: 8px; }
.pack-list a { background: var(--sheet); padding: 12px 16px; border-radius: 10px; text-decoration: none; font-weight: 700; display: grid; }
.pack-list small { font-weight: 400; color: var(--ink-soft); }
.meter { display: block; height: 10px; border-radius: 999px; background: var(--ruled); overflow: hidden; margin-top: 10px; }
.meter span { display: block; height: 100%; background: var(--pen); border-radius: 999px; }
.meter-label { display: block; font-size: .9rem; color: var(--ink-soft); margin-top: 4px; }

/* ---------- Pack page ---------- */
.pack-head { display: flex; gap: 20px; align-items: end; justify-content: space-between; flex-wrap: wrap; }
.daily { background: var(--sheet); border-radius: var(--radius); padding: 16px 18px; max-width: 26rem; border: 2px solid var(--ink); }
.daily p { margin: 0 0 12px; }

/* ---------- Exercise books (the signature element) ---------- */
.books { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(18rem, 100%), 1fr)); gap: 22px; margin-top: 22px; align-items: start; }
.book { --c: var(--maths); position: relative; background: var(--c); color: #fff; border-radius: 6px 14px 14px 6px; padding: 18px 18px 20px 30px;
  box-shadow: inset 12px 0 0 rgba(0,0,0,.14), 0 5px 0 rgba(0,0,0,.18); }
.book::before { /* stitched spine */ content: ''; position: absolute; left: 14px; top: 10px; bottom: 10px; border-left: 2px dashed rgba(255,255,255,.4); }
.label { background: #fff; color: #1b2340; border-radius: 6px; padding: 8px 12px; display: grid; gap: 2px; margin-bottom: 14px; }
.label-row { display: flex; gap: 10px; align-items: baseline; border-bottom: 1px solid #c9d2e3; min-height: 1.9em; }
.label-row:last-child { border-bottom: 0; }
.label-row i { font-style: normal; font-size: .8rem; color: #6b7590; width: 4.5em; }
.label-row b { font-family: var(--display); font-size: 1.15rem; }
.label-row b.hand { font-family: var(--hand); font-weight: 400; font-size: 1.35rem; color: var(--maths); }
.pills { display: grid; gap: 10px; }

/* Knowledge pill: a capsule that fills up as it's mastered. */
.pill { --fill: 0%; display: flex; justify-content: space-between; align-items: center; gap: 10px; text-decoration: none; color: #1b2340;
  border-radius: 26px; padding: 10px 18px; min-height: 52px;
  background: linear-gradient(90deg, #fff4cf var(--fill), #fff var(--fill)); box-shadow: 0 2px 0 rgba(0,0,0,.2); transition: transform .1s; }
@media (hover: hover) { .pill:hover { transform: translateX(3px); } }
.pill:active { transform: scale(.98); }
.pill-title { font-weight: 700; line-height: 1.25; }
.pill-status { font-size: .85rem; white-space: nowrap; color: #b07a10; }
.pill-status.due { color: #fff; background: var(--pen); padding: 2px 9px; border-radius: 999px; }

.cover-english { --c: var(--english); }
.cover-humanities { --c: var(--humanities); }
.cover-maths { --c: var(--maths); }
.cover-science { --c: var(--science); }
.cover-portuguese { --c: var(--portuguese); }
.book.cover-portuguese .label-row b.hand { color: #a56a08; }

/* ---------- Notes page and quiz sheet: a page from the book ---------- */
.page, .sheet { position: relative; background: var(--sheet); border-radius: 6px var(--radius) var(--radius) 6px; border-top: 10px solid var(--c);
  box-shadow: 0 2px 0 var(--rule), 0 10px 30px -18px rgba(27,35,64,.35); }
.page { padding: 26px clamp(18px, 4vw, 48px) 30px; }
.page-head { border-bottom: 2px solid var(--ruled); padding-bottom: 18px; margin-bottom: 8px; }
.page-head h1 { font-size: clamp(1.8rem, 4.5vw, 2.6rem); margin: .2rem 0; font-weight: 800; }
.subject-tag { font-weight: 700; color: var(--c); }
.cover-portuguese .subject-tag { color: #b47512; }
.pill-facts { color: var(--ink-soft); margin: .2rem 0 1rem; }
.notes { max-width: 70ch; }
.notes h3 { color: var(--c); font-size: 1.3rem; margin: 1.8rem 0 .5rem; }
.cover-portuguese .notes h3 { color: #b47512; }
.notes li { margin-bottom: .3rem; }
.notes .tip { background: var(--paper); padding: 8px 12px; border-radius: 8px; }
.page-foot { margin-top: 28px; }
.big { font-size: 1.2rem; font-weight: 700; letter-spacing: .01em; margin: .6rem 0; }
.quote { background: var(--paper); border-left: 4px solid var(--c, var(--maths)); padding: 10px 14px; border-radius: 6px; margin: 10px 0; font-style: italic; }
table.pv { border-collapse: collapse; margin: 12px 0; display: block; overflow-x: auto; max-width: 100%; }
table.pv th, table.pv td { border: 1px solid var(--rule); padding: 6px 10px; text-align: left; }
table.pv th { background: var(--paper); font-size: .9rem; }

.progress { height: 8px; background: var(--ruled); border-radius: 999px; overflow: hidden; margin: 4px 0 16px; }
.progress span { display: block; height: 100%; background: var(--c, var(--maths)); background: var(--pen); transition: width .3s; }
.sheet { display: grid; grid-template-columns: 56px 1fr; min-height: 340px;
  background-image: linear-gradient(transparent 31px, var(--ruled) 32px); background-size: 100% 32px; background-position: 0 18px; }
.margin { border-right: 2px solid var(--margin-line); display: flex; justify-content: center; padding-top: 22px; }
.sheet-body { padding: 20px clamp(16px, 3vw, 32px) 26px; min-width: 0; }
.q-meta { color: var(--ink-soft); font-size: .9rem; margin: 0 0 8px; }
.q-text { font-size: 1.35rem; line-height: 1.45; margin-bottom: 20px; }
.say { border: 0; background: var(--paper); border-radius: 999px; padding: 2px 10px; cursor: pointer; font-size: 1.1rem; vertical-align: middle; }
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(14rem, 100%), 1fr)); gap: 10px; }
.opt { text-align: left; background: var(--sheet); border: 2px solid var(--rule); border-radius: 12px; padding: 13px 16px; cursor: pointer; font-size: 1.08rem; min-height: 54px; }
@media (hover: hover) { .opt:hover:not(:disabled) { border-color: var(--ink); } }
.opt:active:not(:disabled) { border-color: var(--ink); background: var(--paper); }
.opt:disabled { cursor: default; }
.opt.right, .typed input.right { border-color: var(--pen); background: var(--pen-bg); }
.opt.wrong, .typed input.wrong { border-color: var(--oops); background: var(--oops-bg); }
.typed { display: flex; gap: 10px; }
.typed input { flex: 1; min-width: 0; font-size: 1.4rem; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--rule); background: var(--sheet); }
.tick { font-family: var(--hand); font-size: 3rem; line-height: 1; animation: pen .35s ease-out both; }
.tick.ok { color: var(--pen); }
.tick.no { color: var(--oops); }
@keyframes pen { from { transform: scale(.4) rotate(-20deg); opacity: 0; } to { transform: none; opacity: 1; } }
.fb { margin-top: 18px; padding: 12px 16px; border-radius: 12px; }
.fb.ok { background: var(--pen-bg); }
.fb.ok .hand { color: var(--pen); }
.fb.no { background: var(--oops-bg); }
.fb.no .hand { color: var(--oops); }
.fb p { margin: 4px 0; }
.next { position: relative; margin-top: 14px; width: 100%; }
/* Question transitions: each sheet slides in from the right and out to the left, like turning to the next page. */
main { overflow-x: clip; }
.sheet.enter { animation: q-in .34s cubic-bezier(.2, .8, .2, 1) both; }
.sheet.leave { animation: q-out .22s ease-in both; pointer-events: none; }
.fb, .next { animation: fb-in .28s ease-out both; }
.next { animation-delay: .08s; }
.result { animation: q-in .4s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes q-in { from { opacity: 0; transform: translateX(48px) rotate(.5deg); } }
@keyframes q-out { to { opacity: 0; transform: translateX(-48px) rotate(-.5deg); } }
@keyframes fb-in { from { opacity: 0; transform: translateY(10px); } }
/* Pulse a ring around the button and nudge the chevron so children see where to press next. */
.next::after { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: 0 0 0 0 var(--pen); animation: next-ring 1.8s ease-out .6s infinite; }
.next .chev { font-size: 1.6em; line-height: 0; margin-left: 2px; animation: next-nudge 1.8s ease-in-out .6s infinite; }
@keyframes next-ring { 0% { box-shadow: 0 0 0 0 var(--pen); opacity: .7; } 70%, 100% { box-shadow: 0 0 0 12px var(--pen); opacity: 0; } }
@keyframes next-nudge { 0%, 50%, 100% { transform: none; } 25% { transform: translateX(5px); } }

/* Map grid used by grid-reference questions */
table.grid { border-collapse: collapse; margin: 14px 0 0; font-style: normal; }
table.grid td { width: 52px; height: 52px; border: 2px solid #8fa0bd; text-align: center; font-size: 1.6rem; background: #e7f5d3; }
table.grid th { font-size: .95rem; padding: 4px 8px; color: var(--ink-soft); font-weight: 700; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) table.grid td { background: #2f4a22; } }

/* ---------- Year page extras: dictionary and links ---------- */
.extras { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(17rem, 100%), 1fr)); gap: 14px; margin-top: 16px; }
.extra { display: flex; gap: 14px; align-items: center; padding: 14px 18px; background: var(--sheet); border: 2px solid var(--rule); border-radius: var(--radius); text-decoration: none; }
.extra b { display: block; font-family: var(--display); font-size: 1.15rem; }
.extra small { color: var(--ink-soft); }
.extra-icon { font-size: 2rem; line-height: 1; }
.extra:active { transform: translateY(2px); }
@media (hover: hover) { .extra:hover { border-color: var(--ink); } }
.dict-link { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-weight: 700; padding: 8px 12px; border-radius: 999px; white-space: nowrap; }
@media (hover: hover) { .dict-link:hover { background: var(--sheet); } }

/* ---------- Dictionary words in notes ---------- */
.term { font: inherit; color: inherit; background: none; border: 0; padding: 0 1px; margin: 0; cursor: pointer; border-radius: 4px;
  text-decoration: underline dotted var(--c, var(--maths)); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.term:active { background: var(--paper); }
@media (hover: hover) { .term:hover { background: var(--paper); text-decoration-style: solid; } }
.term-hint { font-size: .9rem; color: var(--ink-soft); margin: 14px 0 0; }
.term-demo { text-decoration: underline dotted var(--c, var(--maths)); text-decoration-thickness: 2px; text-underline-offset: 4px; color: var(--ink); }

/* ---------- Dictionary pane: right side on wide screens, bottom sheet on phones and iPad portrait ---------- */
:root { --pane-w: min(460px, 40vw); }
.dict-pane { position: fixed; z-index: 50; background: var(--sheet); color: var(--ink); overflow-y: auto; overscroll-behavior: contain;
  border-top: 8px solid var(--c, var(--maths)); visibility: hidden;
  transition: transform .32s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .32s; }
.dict-pane.open { visibility: visible; transform: none; transition: transform .32s cubic-bezier(.2, .8, .2, 1); }
.dict-pane:focus { outline: none; }
.dict-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dict-close { border: 0; background: var(--paper); width: 44px; height: 44px; border-radius: 50%; cursor: pointer; font-size: 1.1rem; flex: none; }
.dict-title { font-size: clamp(1.8rem, 3vw, 2.4rem); font-weight: 800; margin: .3rem 0 .2rem; }
.dict-aka { margin: 0 0 .4rem; color: var(--ink-soft); font-size: .95rem; }
.dict-short { font-size: 1.1rem; margin: .4rem 0 0; }
.dict-label { font-weight: 700; margin: 1.2rem 0 .4rem; color: var(--ink-soft); font-size: .9rem; text-transform: uppercase; letter-spacing: .06em; }
.dict-emoji { font-size: 3.4rem; text-align: center; margin: 14px 0; padding: 10px; background: var(--paper); border-radius: var(--radius); }
.dict-more p { margin: .8rem 0 0; }
.dict-foot { margin: 1.6rem 0 0; font-size: .95rem; }
.dict-foot a { color: var(--ink-soft); }
.dict-grab { display: none; }
.dict-backdrop { position: fixed; inset: 0; z-index: 49; background: rgba(12, 18, 36, .45); opacity: 0; pointer-events: none; transition: opacity .3s; }
@media (min-width: 1000px) {
  .dict-pane { top: 0; right: 0; bottom: 0; width: var(--pane-w); border-left: 2px solid var(--rule); box-shadow: -14px 0 34px -24px rgba(27, 35, 64, .45);
    padding: max(20px, env(safe-area-inset-top)) max(26px, env(safe-area-inset-right)) 40px 26px; transform: translateX(100%); }
  main, .top { transition: margin-right .32s cubic-bezier(.2, .8, .2, 1); }
  body.dict-open main, body.dict-open .top { margin-right: var(--pane-w); }
  .dict-backdrop { display: none; }
}
@media (max-width: 999.98px) {
  .dict-pane { left: 0; right: 0; bottom: 0; max-height: 86vh; max-height: 86dvh; border-radius: 22px 22px 0 0; transform: translateY(100%);
    padding: 8px max(20px, env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    box-shadow: 0 -12px 40px rgba(0, 0, 0, .25); }
  .dict-grab { display: block; width: 44px; height: 5px; border-radius: 999px; background: var(--rule); margin: 4px auto 10px; }
  body.dict-open { overflow: hidden; }
  body.dict-open .dict-backdrop { opacity: 1; pointer-events: auto; }
}
@media (min-width: 600px) and (max-width: 999.98px) { .dict-pane { left: 50%; right: auto; width: min(640px, 100%); transform: translate(-50%, 100%); }
  .dict-pane.open { transform: translate(-50%, 0); } }

/* Pictures in the pane. SVG classes are documented in content/dictionary.js. */
.dict-pic { margin: 16px 0 0; padding: 16px; background: var(--paper); border-radius: var(--radius); text-align: center; }
.dict-pic figcaption { font-size: .92rem; color: var(--ink-soft); margin-top: 8px; }
.dict-pic svg { display: block; width: 100%; max-width: 340px; height: auto; margin: 0 auto; color: var(--ink); overflow: visible; }
.dict-pic svg text { fill: currentColor; font: 700 13px var(--body); paint-order: stroke; stroke: var(--paper); stroke-width: 4px; stroke-linejoin: round; }
.dict-pic svg text.sm { font-size: 11.5px; font-weight: 400; }
.dict-pic svg text.big { font: 800 16px var(--display); }
.dict-pic svg text.hl { font: 800 15px var(--display); }
.dict-pic svg text.emo { font-size: 24px; stroke: none; }
.dict-pic svg text.turn { font: 800 34px var(--body); stroke: none; }
.dict-pic svg text.emo-xl { font-size: 76px; stroke: none; }
.dict-pic svg text.on-dark { fill: #fff; stroke: none; }
.dict-pic svg text.no-t { fill: var(--oops); }
svg .ln { fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
svg .thin { stroke-width: 1.3; opacity: .75; }
svg .thick { stroke-width: 4; }
svg .dash { stroke-dasharray: 6 5; }
svg .cs { stroke: var(--c); opacity: 1; }
svg .c { fill: var(--c); }
svg .cf { fill: var(--c); fill-opacity: .2; }
svg .s { fill: var(--sheet); }
svg .edge { stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
svg .edge-thin { stroke: currentColor; stroke-width: 1; }
svg .ok { fill: var(--pen); }
svg .no { fill: var(--oops); }
svg .no-s { stroke: var(--oops); }
svg .y { fill: #f5c542; }
svg .ys { stroke: #e0a800; }
svg .g { stroke: #3f9b4b; }
svg .g-dark { stroke: #2a6e34; stroke-width: 2; }
svg .gf { fill: #5cb85c; }
svg .w { fill: #3b8fd9; fill-opacity: .3; }
svg .wl { color: #3b8fd9; }
svg .soil { fill: #9a6b3f; fill-opacity: .35; }
svg .soil-ln { stroke: #8a5a2b; }
svg .arr line { stroke: currentColor; stroke-width: 3; stroke-linecap: round; }
svg .arr polygon { fill: currentColor; }
svg .arr.c { color: var(--c); }
svg .arr.ok { color: var(--pen); }
svg .arr.no { color: var(--oops); }
svg .arr.ys { color: #e0a800; }
.pic-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 10px 16px; }
.pic-item { display: grid; justify-items: center; gap: 4px; max-width: 7.5rem; }
.pic-item small { font-size: .85rem; color: var(--ink-soft); line-height: 1.25; }
.pic-emoji { font-size: 2.2rem; line-height: 1; }
.pic-arrow { color: var(--ink-soft); font-size: 1.3rem; align-self: center; }
.pic-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pic-two > div > b { display: block; margin-bottom: 8px; }
.pic-card { text-align: left; background: var(--sheet); border-radius: 10px; padding: 14px 16px; line-height: 1.7;
  background-image: linear-gradient(transparent calc(1.7em - 1px), var(--ruled) 1.7em); background-size: 100% 1.7em; }
.pic-tag { display: inline-block; min-width: 1.6em; text-align: center; font-size: .8rem; font-weight: 700; color: #fff; background: var(--c); border-radius: 999px; padding: 0 6px; margin-left: 6px; }
.pic-hl { color: var(--c); font-size: 1.2em; }
.pic-dim { color: var(--ink-soft); font-size: .85rem; }
.pic-big { font: 800 1.5rem/1.4 var(--display); color: var(--c); }
.pic-shape { text-align: center; font-family: var(--hand); font-size: 1.2rem; line-height: 1.2; }
table.pic-pv { margin: 0 auto; display: table; }
table.pic-pv td { font: 800 1.4rem var(--display); text-align: center; }
table.pic-pv .hl-cell { background: var(--c); color: #fff; }

/* ---------- Search + subject chips (dictionary, links) ---------- */
.filter-bar { display: grid; gap: 12px; margin: 1rem 0 .4rem; position: sticky; top: 0; z-index: 5; padding: 10px 0; background: var(--paper); }
.filter-bar input { width: 100%; max-width: 34rem; padding: 12px 16px; border-radius: 999px; border: 2px solid var(--rule); background: var(--sheet); font-size: 1.05rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; border: 2px solid var(--rule); background: var(--sheet); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-weight: 700; font-size: .95rem; min-height: 40px; }
.chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip .dot { margin-right: 6px; }
.empty-note { color: var(--ink-soft); padding: 2rem 0; }

/* ---------- Dictionary page ---------- */
.dict-letter { font-size: 1.6rem; margin: 1.6rem 0 .6rem; color: var(--ink-soft); }
.dict-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(16rem, 100%), 1fr)); gap: 10px; }
.dict-entry { text-align: left; display: grid; gap: 4px; padding: 12px 16px; background: var(--sheet); border: 2px solid var(--rule); border-left: 6px solid var(--c); border-radius: 12px; cursor: pointer; }
.dict-entry b { font-family: var(--display); font-size: 1.15rem; }
.dict-entry span { color: var(--ink-soft); font-size: .92rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dict-entry:active { transform: translateY(1px); }
@media (hover: hover) { .dict-entry:hover { border-color: var(--ink); border-left-color: var(--c); } }

/* ---------- Links page ---------- */
.routine { background: var(--sheet); border: 2px solid var(--ink); border-radius: var(--radius); padding: 16px 20px; max-width: 40rem; }
.routine h2 { margin: 0 0 6px; font-size: 1.3rem; }
.routine ol { margin: 0; padding-left: 1.3rem; }
.routine li { margin: 4px 0; }
.links-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(19rem, 100%), 1fr)); gap: 14px; }
.link-card { display: grid; gap: 8px; align-content: start; padding: 16px 18px; background: var(--sheet); border: 2px solid var(--rule); border-top: 6px solid var(--c); border-radius: 12px; text-decoration: none; }
.link-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.link-top b { font-family: var(--display); font-size: 1.15rem; line-height: 1.2; }
.mins { font-size: .85rem; color: var(--ink-soft); white-space: nowrap; }
.link-what { color: var(--ink); }
.link-tip { font-size: .95rem; background: var(--paper); border-radius: 8px; padding: 8px 10px; }
.link-host { font-size: .85rem; color: var(--c); font-weight: 700; }
.link-card:active { transform: translateY(2px); }
@media (hover: hover) { .link-card:hover { border-color: var(--ink); border-top-color: var(--c); } }

/* ---------- Results ---------- */
.result { max-width: 45rem; }
.score { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; margin: 1.4rem 0; }
.big-score { font: 800 6rem/1 var(--display); letter-spacing: -.05em; }
.big-score small { font-size: .4em; color: var(--ink-soft); }
.score .hand { color: var(--pen); font-size: 2rem; }
.missed { background: var(--sheet); border-left: 6px solid var(--oops); border-radius: 0 12px 12px 0; padding: 12px 16px; margin: 10px 0; }
.missed .hand { color: var(--pen); margin: 6px 0 0; }
.missed .explain { color: var(--ink-soft); margin: 4px 0 0; }

/* ---------- Forms, profiles, family ---------- */
.form-page { max-width: 32rem; }
.form-page.wide { max-width: 48rem; }
.stack { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-weight: 700; }
input[type=email], input[name=name], input[name=code], select { padding: 12px 14px; border-radius: 12px; border: 2px solid var(--rule); background: var(--sheet); font-weight: 400; font-size: 1.1rem; }
input.code { font: 800 2rem/1 var(--display); letter-spacing: .3em; text-align: center; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 700; margin-bottom: 6px; }
.avatars { display: flex; flex-wrap: wrap; gap: 6px; }
.avatars label { display: block; }
.avatars input { position: absolute; opacity: 0; }
.avatars span { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 12px; background: var(--sheet); border: 2px solid var(--rule); font-size: 1.6rem; cursor: pointer; }
.avatars input:checked + span { border-color: var(--maths); background: var(--paper); box-shadow: 0 0 0 2px var(--maths); }
.avatars input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.profiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin: 1rem 0 1.4rem; }
.profile { display: grid; justify-items: center; gap: 6px; padding: 18px 12px; background: var(--sheet); border: 2px solid var(--rule); border-radius: var(--radius); cursor: pointer; text-align: center; }
.profile b { font-family: var(--display); font-size: 1.25rem; }
.profile small { color: var(--ink-soft); }
.profile.current { border-color: var(--pen); }
.add { background: var(--sheet); border-radius: var(--radius); padding: 14px 18px; border: 2px solid var(--rule); }
.add summary { font-weight: 700; cursor: pointer; }
.add form { margin-top: 14px; }
.account-actions { margin: 1.4rem 0 .6rem; }
.empty { text-align: center; padding: 10vh 0; }
.child { background: var(--sheet); border-radius: var(--radius); padding: 18px; margin: 18px 0; border: 2px solid var(--rule); }
.child header { display: flex; gap: 14px; align-items: center; }
.child h2 { margin: 0; }
.child header p { margin: 4px 0 0; color: var(--ink-soft); }
.table-wrap { overflow-x: auto; margin-top: 14px; }
.progress-table { border-collapse: collapse; width: 100%; font-size: .95rem; }
.progress-table th { text-align: left; font-size: .85rem; color: var(--ink-soft); padding: 6px 8px; border-bottom: 2px solid var(--rule); white-space: nowrap; }
.progress-table td { padding: 8px; border-bottom: 1px solid var(--ruled); white-space: nowrap; }
.progress-table td:first-child { white-space: normal; min-width: 200px; }
.progress-table tr.due td:last-child { color: var(--pen); font-weight: 700; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-right: 8px; }
.sessions { margin: 8px 0 0; padding-left: 20px; color: var(--ink-soft); }
details summary { cursor: pointer; font-weight: 700; margin-top: 10px; }

.confetti { position: fixed; top: -14px; width: 10px; height: 14px; z-index: 99; animation: fall linear forwards; pointer-events: none; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

@media (max-width: 720px) {
  .top { gap: 8px; }
  .who .long { display: none; }
  .who .short { display: inline; }
  .dict-link .long { display: none; }
  .dict-link { padding: 8px; font-size: 1.3rem; }
  .year-grid { grid-template-columns: 1fr; }
  .sheet { grid-template-columns: 34px 1fr; }
  .margin { padding-top: 18px; }
  .tick { font-size: 2.2rem; }
  .q-text { font-size: 1.18rem; }
  .who span:not(.avatar) { max-width: 7em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  table.grid td { width: 42px; height: 42px; font-size: 1.3rem; }
  .big-score { font-size: 4.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
