:root {
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-2: #edf2ec;
  --text: #121826;
  --muted: #4b5565;
  --border: #dbe3d9;
  --accent: #15803d;
  --accent-strong: #166534;
  --accent-soft: #dcfce7;
  --on-accent: #ffffff;
  --spin: #16a34a;
  --spin-strong: #15803d;
  --ok: #157f3b;
  --danger: #b42318;
  --shadow: 0 1px 2px rgba(18, 24, 38, .05), 0 8px 24px rgba(18, 24, 38, .07);
  --radius: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b120e;
    --surface: #121c16;
    --surface-2: #1a281f;
    --text: #e8ecf5;
    --muted: #a3adc2;
    --border: #2a3a2f;
    --accent: #4ade80;
    --accent-strong: #86efac;
    --accent-soft: #123020;
    --on-accent: #04130a;
    --spin: #22c55e;
    --spin-strong: #4ade80;
    --ok: #4ade80;
    --danger: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b120e;
  --surface: #121c16;
  --surface-2: #1a281f;
  --text: #e8ecf5;
  --muted: #a3adc2;
  --border: #2a3a2f;
  --accent: #4ade80;
  --accent-strong: #86efac;
  --accent-soft: #123020;
  --on-accent: #04130a;
  --spin: #22c55e;
  --spin-strong: #4ade80;
  --ok: #4ade80;
  --danger: #f87171;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 var(--font); overflow-x: hidden; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr-only, .skip { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip:focus { position: fixed; left: 12px; top: 12px; width: auto; height: auto; clip: auto; z-index: 50; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 780px; }

/* Header */
.site-header { position: sticky; top: 0; z-index: 20; background: var(--bg); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.site-header .wrap { display: flex; align-items: center; gap: 12px; min-height: 58px; }
.logo { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 1.15rem; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.logo svg { width: 30px; height: 30px; flex: none; }
.nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav-links { display: none; gap: 2px; }
.nav-links a { padding: 8px 10px; border-radius: 10px; color: var(--text); text-decoration: none; font-size: .95rem; white-space: nowrap; }
.nav-links a:hover, .nav-links a[aria-current="page"] { background: var(--surface-2); }
.menu, .langs { position: relative; }
.menu > summary, .langs > summary { list-style: none; cursor: pointer; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-size: .92rem; display: flex; align-items: center; gap: 6px; min-height: 40px; }
.menu > summary::-webkit-details-marker, .langs > summary::-webkit-details-marker { display: none; }
.dropdown { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; min-width: 220px; display: grid; z-index: 30; max-height: 70vh; overflow: auto; }
.dropdown a { padding: 9px 12px; border-radius: 8px; color: var(--text); text-decoration: none; }
.dropdown a:hover, .dropdown a[aria-current="page"] { background: var(--surface-2); }
@media (min-width: 1180px) {
  .nav-links { display: flex; }
}
/* Very small phones (320 px): the menu keeps its icon and its name stays readable by screen readers. */
@media (max-width: 359.98px) {
  .site-header .wrap { gap: 8px; }
  .menu > summary, .langs > summary { padding: 8px 10px; }
  .menu > summary span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* Hero */
main { padding-bottom: 40px; }
.hero { padding: 22px 0 4px; max-width: 780px; }
.hero h1 { font-size: clamp(1.55rem, 4.2vw, 2.25rem); line-height: 1.15; margin: 0 0 8px; letter-spacing: -.02em; }
.hero p { margin: 0; color: var(--muted); font-size: 1.05rem; }
.crumbs { font-size: .85rem; color: var(--muted); margin: 14px 0 -8px; }
.crumbs a { color: var(--muted); }

/* Content */
.content { margin-top: 34px; max-width: 780px; }
.content h2 { font-size: 1.3rem; line-height: 1.3; margin: 28px 0 10px; letter-spacing: -.01em; }
.content p { margin: 0 0 12px; }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.steps li { counter-increment: step; position: relative; padding: 12px 14px 12px 50px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.steps li::before { content: counter(step); position: absolute; left: 12px; top: 11px; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 800; font-size: .9rem; }
.entry-list { columns: 2 180px; column-gap: 24px; padding-left: 18px; margin: 0; }
.entry-list li { break-inside: avoid; padding: 2px 0; }
.more-entries > summary { cursor: pointer; color: var(--accent); font-weight: 650; margin-bottom: 8px; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0 14px; margin-bottom: 8px; }
.faq summary { cursor: pointer; padding: 13px 0; font-weight: 650; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--accent); font-weight: 800; }
.faq details[open] summary::after { content: "–"; }
.faq details p { margin: 0 0 13px; color: var(--muted); }
.related { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; list-style: none; padding: 0; margin: 0; }
.related a { display: block; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; text-decoration: none; color: var(--text); font-weight: 600; height: 100%; }
.related a:hover { border-color: var(--accent); }
.ad-slot { margin: 26px 0; min-height: 100px; }
.privacy-note { display: flex; gap: 8px; align-items: flex-start; font-size: .88rem; color: var(--muted); margin-top: 18px; }
.to-top { display: inline-block; margin-top: 24px; font-size: .9rem; }

/* Static pages */
.prose { max-width: 700px; overflow-wrap: anywhere; }
.prose h1 { font-size: clamp(1.6rem, 4vw, 2.1rem); margin: 26px 0 14px; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); margin-top: 40px; padding: 28px 0 40px; background: var(--surface); font-size: .92rem; }
.foot-grid { display: grid; gap: 22px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .foot-grid { grid-template-columns: 1.6fr 1fr 1fr 1fr; } }
.foot-grid h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; }
.foot-grid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.foot-wheels ul { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.foot-grid a { color: var(--text); text-decoration: none; }
.foot-grid a:hover { color: var(--accent); text-decoration: underline; }
.foot-brand p { color: var(--muted); margin: 8px 0 0; }
.foot-brand .foot-sisters-title { margin-top: 18px; }
.foot-sisters li { display: grid; gap: 0; }
.foot-sisters a { font-weight: 700; }
.foot-sisters span { color: var(--muted); font-size: .86rem; }
.copyright { color: var(--muted); margin-top: 22px; font-size: .85rem; }

/* Toast, language bar, confetti */
.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px); width: max-content; background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 90; display: flex; gap: 12px; align-items: center; max-width: calc(100vw - 32px); }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast.has-action.is-on { pointer-events: auto; }
.toast-action { border: 0; background: transparent; color: var(--accent-soft); font-weight: 800; text-decoration: underline; cursor: pointer; padding: 4px; }
.lang-bar { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 8px 44px 8px 16px; background: var(--accent-soft); color: var(--text); font-size: .9rem; position: relative; flex-wrap: wrap; }
.lang-bar-go { font-weight: 700; }
.lang-bar-close { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; font-size: 1.4rem; cursor: pointer; width: 36px; height: 36px; }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 85; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}



/* ---------- Worksheet tool ---------- */
.tool { margin-top: 18px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); border-radius: 11px; padding: 0 14px; cursor: pointer; font-size: .92rem; min-height: 42px; text-decoration: none; color: var(--text); }
.btn:hover { border-color: var(--accent); }
.btn svg { width: 17px; height: 17px; flex: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-quiet { background: transparent; }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); font-weight: 700; }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: .95rem; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.seg button { border: 0; background: transparent; border-radius: 9px; min-height: 36px; padding: 0 11px; font-weight: 700; cursor: pointer; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.seg button:disabled { opacity: .35; cursor: not-allowed; }

.tool-grid { display: grid; gap: 18px; }
/* Phones and tablets: the main settings first, compact, then the sheet; the other settings fold away. */
@media (max-width: 919.98px) {
  .panel { box-shadow: none; padding: 12px 14px; gap: 11px; }
  .panel-title { display: none; }
}
@media (min-width: 920px) {
  .only-narrow { display: none; }
  .tool-grid { grid-template-columns: 310px minmax(0, 1fr); align-items: start; }
  .panel { position: sticky; top: 74px; max-height: calc(100vh - 90px); overflow: auto; }
}
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px 16px; box-shadow: var(--shadow); display: grid; gap: 13px; align-content: start; }
.panel-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0; }
.field-label { margin: 0 0 6px; font-weight: 700; font-size: .92rem; }
.panel-note { margin: 0; color: var(--muted); font-size: .9rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; width: 100%; height: 100%; }
.chip span { display: grid; place-items: center; min-width: 38px; height: 36px; padding: 0 8px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface-2); font-weight: 750; font-variant-numeric: tabular-nums; }
.chip input:checked + span { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.chip input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.chip-op span { font-size: 1.25rem; min-width: 46px; }
.mini-actions { display: flex; gap: 14px; margin-top: 7px; }
.link-btn { border: 0; background: none; color: var(--accent); font-weight: 650; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

.stage { min-width: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.btn-print { min-height: 46px; padding: 0 20px; font-size: 1rem; }
.codebar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 14px; font-size: .9rem; color: var(--muted); }
.code-now { margin: 0; display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.code-now .link-btn { display: inline-flex; align-items: center; gap: 4px; font-size: .9rem; }
.code-now .link-btn svg { width: 15px; height: 15px; }
.code-help { flex-basis: 100%; margin: 0; font-size: .85rem; }
.codebar strong { color: var(--text); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .05em; }
.code-form { display: flex; gap: 6px; }
.code-form input::placeholder { text-transform: none; font-family: var(--font); }
.code-form input { width: 160px; min-height: 40px; border: 1px solid var(--border); border-radius: 10px; padding: 0 10px; background: var(--surface); text-transform: uppercase; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.checkbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 12px 0 0; }
.score { margin: 0; font-weight: 800; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.preview { background: var(--surface-2); border: 1px solid var(--border); border-radius: 16px; padding: clamp(8px, 2.6vw, 22px); overflow-x: auto; }
.preview .paper-sheet { max-width: 780px; margin: 0 auto; }
.sheet-skeleton { aspect-ratio: 190 / 276; display: grid; place-items: center; color: #6b7280; }

.converter { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 18px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.conv-label { font-weight: 750; }
.conv-row { display: flex; gap: 8px; }
.conv-row input { flex: 1; width: 0; min-width: 0; min-height: 46px; font-size: 1.15rem; border: 2px solid var(--border); border-radius: 12px; padding: 0 14px; background: var(--bg); color: var(--text); }
.conv-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.conv-out { display: block; min-height: 1.6em; font-size: 1.3rem; font-weight: 800; overflow-wrap: anywhere; }
.conv-out.is-bad { font-size: .95rem; font-weight: 600; color: var(--danger); }

/* ---------- The sheet: sizes in cqw, so the preview and the paper match ---------- */
.paper-sheet { background: #fff; color: #111; box-shadow: 0 2px 10px rgba(0, 0, 0, .13); padding: 4.6%; border-radius: 3px; }
.sheet { container-type: inline-size; position: relative; width: 100%; aspect-ratio: 190 / 276; display: flex; flex-direction: column; overflow: hidden; color: #111; background: #fff; font-family: "Helvetica Neue", Arial, "Liberation Sans", system-ui, sans-serif; line-height: 1.2; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
[data-paper="letter"] .sheet { aspect-ratio: 195.9 / 258.4; }
.sh-head { height: 19cqw; flex: none; display: flex; flex-direction: column; }
.sh-who { display: flex; gap: 5cqw; font-size: 2.2cqw; color: #374151; }
.sh-who span { flex: 1; border-bottom: .2cqw solid #9ca3af; padding-bottom: .9cqw; }
.sh-who span:last-child { flex: 0 0 32%; }
.sh-title { font-size: var(--tfs, 4.2cqw); line-height: 1.15; margin: 3.2cqw 0 1cqw; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sh-key { display: inline-block; color: #dc2626; font-size: .62em; border: .25cqw solid currentColor; border-radius: 1cqw; padding: .1em .45em; vertical-align: .2em; letter-spacing: .02em; }
.sh-inst { font-size: 2.3cqw; margin: 0; color: #374151; }
.sh-note { color: #6b7280; }
.sh-body { flex: 1; min-height: 0; position: relative; }
.sh-foot { height: 4.6cqw; flex: none; display: flex; justify-content: space-between; align-items: flex-end; gap: 3cqw; font-size: 1.5cqw; color: #6b7280; border-top: .15cqw solid #e5e7eb; }
.sh-foot span:last-child { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .05em; }

/* Solving on a phone: one long column, the sheet grows with it */
.sheet.is-flow { aspect-ratio: auto; }
.sheet.is-flow .sh-body { flex: none; }
.sheet.is-flow .sh-foot { margin-top: 3cqw; }
.sheet.is-flow .ch-wrap { height: auto; }

/* Problems on a line */
.ex-grid { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); grid-template-rows: repeat(var(--rows), var(--rowh)); column-gap: 4cqw; font-size: var(--fs); align-content: start; }
.ex { display: flex; align-items: center; gap: .3em; white-space: nowrap; min-width: 0; }
.ex-n { font-size: .48em; color: #9ca3af; min-width: 2.3em; text-align: right; font-variant-numeric: tabular-nums; flex: none; }
.ex-q { display: inline-flex; align-items: baseline; gap: .28em; font-variant-numeric: tabular-nums; }
.sg { color: #374151; }
.rem { font-size: .8em; }
.bl { display: inline-block; border-bottom: .08em solid #1f2937; min-height: 1.2em; text-align: center; line-height: 1.2; }
.is-key .bl, .is-key .is-a { color: #dc2626; font-weight: 700; }
.bl-in { font: inherit; border: 0; border-bottom: .08em solid #1f2937; background: #eef6ff; text-align: center; padding: 0; border-radius: .12em .12em 0 0; color: #111; min-width: 2ch; }
.bl-in:focus { outline: .1em solid #15803d; background: #fff; }
.bl-in.is-ok, .ch-in.is-ok { background: #dcfce7; border-color: #15803d; }
.bl-in.is-bad, .ch-in.is-bad { background: #fee2e2; border-color: #dc2626; color: #b91c1c; }

/* Column problems on squared paper */
.cg { display: grid; grid-template-columns: repeat(var(--nc), var(--cell)); grid-template-rows: repeat(var(--nr), var(--cell)); width: calc(var(--nc) * var(--cell)); height: calc(var(--nr) * var(--cell)); margin: 0 auto; font-size: calc(var(--cell) * .64); line-height: 1; font-variant-numeric: tabular-nums; }
.cg.has-grid { background-image: linear-gradient(to right, #cdd6e2 .11cqw, transparent .11cqw), linear-gradient(to bottom, #cdd6e2 .11cqw, transparent .11cqw); background-size: var(--cell) var(--cell); box-shadow: inset -.11cqw -.11cqw 0 #cdd6e2; }
.cg-d { display: grid; place-items: center; font-weight: 600; }
.cg-d.is-op { font-weight: 700; color: #374151; }
.cg-d.is-a { color: #dc2626; }
.cg-n { font-size: .48em; color: #9ca3af; display: grid; place-items: start end; padding: .2em .25em 0 0; }
.cg-l { pointer-events: none; }
.cg-l.is-bottom { border-bottom: .3cqw solid #111; }
.cg-l.is-top { border-top: .3cqw solid #111; }
.cg-l.is-left { border-left: .3cqw solid #111; }
.cg-l.is-a { border-color: #dc2626; }

/* Multiplication chart */
.ch-wrap { height: 100%; display: grid; justify-items: center; align-content: start; }
.ch { border-collapse: collapse; font-size: calc(var(--cs) * .4); font-variant-numeric: tabular-nums; }
.ch th, .ch td { width: var(--cs); height: var(--cs); border: .15cqw solid #4b5563; text-align: center; padding: 0; }
.ch th { background: #eef2ed; font-weight: 800; }
.ch-corner { color: #6b7280; }
.ch td.is-a { color: #dc2626; font-weight: 700; }
.ch-in { width: 100%; height: 100%; border: 0; text-align: center; font: inherit; background: #eef6ff; padding: 0; color: #111; }

/* Numbers in words */
.wd { list-style: none; margin: 0; padding: 0; counter-reset: wd; font-size: var(--fs); }
.wd li { height: var(--rowh); display: flex; flex-direction: column; justify-content: center; gap: .35em; counter-increment: wd; position: relative; padding-left: 2.1em; }
.wd li { justify-content: center; }
.wd-q::before { content: counter(wd); position: absolute; left: 0; font-size: .5em; line-height: 2.4; color: #9ca3af; }
.wd-q { font-weight: 700; }
.wd-line { display: block; border-bottom: .07em solid #374151; min-height: 1.35em; white-space: nowrap; overflow: hidden; }

/* Clocks and fractions */
.clk-grid, .fr-grid { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); grid-auto-rows: var(--rowh); }
.clk-item, .fr-item { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.4cqw; }
.clk-item .ex-n, .fr-item .ex-n { position: absolute; left: 0; top: 1.2cqw; font-size: 1.8cqw; min-width: 0; }
.clk { width: var(--size); height: var(--size); display: block; }
.clk-face { fill: #fff; stroke: #111; stroke-width: 2.2; }
.clk-t1 { stroke: #6b7280; stroke-width: .8; }
.clk-t5 { stroke: #111; stroke-width: 2; }
.clk-num { font-size: 9px; font-weight: 700; text-anchor: middle; dominant-baseline: central; fill: #111; font-family: "Helvetica Neue", Arial, sans-serif; }
.clk-h { stroke: #111; stroke-width: 4.4; stroke-linecap: round; }
.clk-m { stroke: #111; stroke-width: 2.6; stroke-linecap: round; }
.clk-h.is-a, .clk-m.is-a { stroke: #dc2626; }
.clk-c { fill: #111; }
.clk-cap { font-size: 3.4cqw; font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: .15em; }
.clk-time { font-weight: 800; }
.frc { width: min(17cqw, calc(var(--rowh) - 15cqw)); height: auto; display: block; }
.frc-bar { width: min(21cqw, calc((var(--rowh) - 15cqw) * 2.3)); }
.fr-on { fill: #93c5fd; stroke: #111; stroke-width: 1.4; }
.fr-on.is-a { fill: #fca5a5; }
.fr-off { fill: #fff; stroke: #111; stroke-width: 1.4; }
.fr-cap { font-size: 3.4cqw; }
.frac { display: inline-grid; justify-items: center; line-height: 1.15; font-variant-numeric: tabular-nums; }
.frac > span:first-child { border-bottom: .25cqw solid #111; padding: 0 .35em .1em; }
.frac > span:last-child { padding-top: .1em; }
.frac .bl { border: .18cqw solid #9ca3af; border-radius: .2em; min-width: 1.8em; min-height: 1.3em; }
.is-key .frac .bl { border-color: #fca5a5; }

/* Grade sheets */
.gr { display: flex; flex-direction: column; }
.gr-sec { flex: none; overflow: hidden; }
.gr-title { font-size: 2.2cqw; margin: 0; height: 4.2cqw; display: flex; align-items: center; color: #166534; font-weight: 800; border-bottom: .15cqw solid #e5e7eb; }

/* Paper */
.ppr { width: 100%; height: 100%; display: block; }

/* ---------- Home: every worksheet ---------- */
.catalog { margin-top: 36px; }
.catalog h2 { font-size: 1.35rem; margin: 0 0 4px; }
.catalog h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 20px 0 8px; }
.tiles { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.tile { display: grid; gap: 4px; align-content: start; height: 100%; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; text-decoration: none; color: var(--text); }
.tile:hover { border-color: var(--accent); }
.tile-title { font-weight: 800; }
.tile-text { color: var(--muted); font-size: .9rem; }
.dropdown-wide { min-width: 270px; }
.dropdown-title { margin: 8px 12px 2px; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 750; }

/* ---------- Printing: only the sheets ---------- */
#print-area { display: none; }
@media print {
  #print-area[data-kind="certificate"] .cert { width: 277mm; height: 190mm; aspect-ratio: auto; box-shadow: none; }
  #print-area[data-kind="certificate"][data-paper="letter"] .cert { width: 259.4mm; height: 195.9mm; }
  html, body { background: #fff !important; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; }
  #print-area .paper-sheet { box-shadow: none; padding: 0; margin: 0; border-radius: 0; width: 190mm; break-after: page; page-break-after: always; }
  #print-area .paper-sheet:last-child { break-after: auto; page-break-after: auto; }
  #print-area .sheet { width: 190mm; height: 276mm; aspect-ratio: auto; }
  #print-area[data-paper="letter"] .paper-sheet { width: 195.9mm; }
  #print-area[data-paper="letter"] .sheet { width: 195.9mm; height: 258.4mm; }
}

/* ---------- More options, home catalog, times-table facts ---------- */
.more { border-top: 1px solid var(--border); padding-top: 10px; }
.more > summary { cursor: pointer; font-weight: 700; color: var(--accent); list-style: none; display: flex; align-items: center; gap: 6px; min-height: 32px; }
.more > summary::-webkit-details-marker { display: none; }
.more > summary::before { content: "+"; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: var(--accent-soft); font-weight: 800; }
.more[open] > summary::before { content: "–"; }
.more-body { display: grid; gap: 13px; margin-top: 10px; }
@media (min-width: 920px) { .more { border: 0; padding: 0; } .more > summary { display: none; } .more-body { margin: 0; } }
.text-in { width: 100%; min-height: 44px; border: 1px solid var(--border); border-radius: 10px; padding: 0 12px; background: var(--bg); color: var(--text); font-size: 1rem; }
.text-in:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.quick-title { font-size: 1.35rem; margin: 36px 0 12px; }
.catalog { margin-top: 18px; }
.catalog .group-title { font-size: 1.1rem; margin: 22px 0 10px; }
.tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
@media (max-width: 559.98px) { .tile { padding: 10px 12px; } .tile.has-img img { height: 104px; } .tile-text { font-size: .84rem; } .tile.has-img .tile-title, .tile.has-img .tile-text { padding: 0 10px; } }
.tile.has-img { padding: 0 0 12px; overflow: hidden; }
.tile.has-img img { width: 100%; height: 150px; object-fit: cover; object-position: top; display: block; background: #fff; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.tile.has-img .tile-title, .tile.has-img .tile-text { padding: 0 14px; }
.facts { list-style: none; padding: 0; margin: 0 0 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.facts li { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }

/* ---------- Certificates (landscape, sized in cqw like the sheets) ---------- */
.preview-cert { padding: clamp(8px, 2.6vw, 22px); }
.cert { container-type: inline-size; width: 100%; max-width: 900px; margin: 0 auto; aspect-ratio: 277 / 190; background: #fff; color: #1f2937; box-shadow: 0 2px 10px rgba(0, 0, 0, .13); padding: 2.4cqw; font-family: Georgia, "Times New Roman", serif; -webkit-print-color-adjust: exact; print-color-adjust: exact; --c: #1d4ed8; --c2: #93c5fd; }
.cert[data-paper="letter"] { aspect-ratio: 259.4 / 195.9; }
.cert-green { --c: #15803d; --c2: #86efac; }
.cert-orange { --c: #c2410c; --c2: #fdba74; }
.cert-purple { --c: #7e22ce; --c2: #d8b4fe; }
.cert-frame { position: relative; height: 100%; border: .9cqw double var(--c); outline: .25cqw solid var(--c2); outline-offset: -2.2cqw; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 3cqw 8cqw; gap: .4cqw; }
.cert-medal { position: absolute; top: 3.2cqw; right: 4.2cqw; width: 9cqw; height: auto; }
.cert-medal .ribbon { fill: var(--c2); }
.cert-medal .disc { fill: var(--c); }
.cert-medal .ring { fill: none; stroke: #fff; stroke-width: 2; stroke-dasharray: 3 3; }
.cert-medal .star { fill: #facc15; }
.cert-title { margin: 0; font-size: 6.4cqw; letter-spacing: .08em; text-transform: uppercase; color: var(--c); font-weight: 700; line-height: 1.05; }
.cert-sub { margin: 0 0 1.6cqw; font-size: 2.3cqw; letter-spacing: .3em; text-transform: uppercase; color: #4b5563; }
.cert-presented { margin: auto 0 0; font-size: 2.2cqw; font-style: italic; color: #4b5563; }
.cert-name { margin: .6cqw 0; min-width: 52cqw; font-size: 5.6cqw; font-style: italic; font-weight: 700; border-bottom: .2cqw solid #9ca3af; line-height: 1.25; overflow-wrap: anywhere; }
.cert-for { margin: .4cqw 0 auto; font-size: 2.6cqw; max-width: 70cqw; }
.cert-foot { margin-top: 2cqw; width: 100%; display: flex; justify-content: space-between; gap: 8cqw; padding: 0 4cqw; }
.cert-foot > div { flex: 1; display: grid; gap: .5cqw; }
.cert-line { border-bottom: .15cqw solid #6b7280; font-size: 2cqw; min-height: 2.8cqw; padding-bottom: .3cqw; }
.cert-label { font-size: 1.5cqw; text-transform: uppercase; letter-spacing: .12em; color: #6b7280; font-family: "Helvetica Neue", Arial, sans-serif; }
.cert-site { position: absolute; bottom: 1.4cqw; left: 0; right: 0; margin: 0; font-size: 1.2cqw; color: #9ca3af; font-family: "Helvetica Neue", Arial, sans-serif; }
