/* PrimaryHub
   Tools float as clean white cards on a background the teacher chooses.
   Rounded type (Nunito), soft shadows, one accent colour per tool. */

:root {
  --ink: #1D2233;
  --ink-2: #434A5E;
  --muted: #7B8297;
  --faint: #A9AEBE;
  --line: rgba(22, 32, 64, .09);
  --surface: #FFFFFF;
  --surface-2: #F5F6FA;
  --surface-3: #ECEEF4;

  --sky: #2F7CF6;
  --grass: #12A06C;
  --grape: #6E4CF5;
  --coral: #F04452;
  --pink: #E64A9A;
  --sun: #FFAD1F;
  --sun-ink: #4D3200;
  --teal: #0EA5A0;
  --orange: #F26A1B;
  --azure: #0A8BD0;
  --indigo: #4F46E5;
  --magenta: #C2389E;

  --r-card: 18px;
  --shadow-card: 0 1px 2px rgba(16, 24, 40, .06), 0 10px 28px -8px rgba(16, 24, 40, .18);
  --shadow-lift: 0 2px 4px rgba(16, 24, 40, .08), 0 26px 50px -12px rgba(16, 24, 40, .35);
  --glass: rgba(255, 255, 255, .72);
  --glass-line: rgba(255, 255, 255, .75);
  --font: 'Nunito Variable', 'Nunito', 'Segoe UI Rounded', 'Segoe UI', system-ui, -apple-system, sans-serif;

  /* Backgrounds (chosen from the palette button in the top bar) */
  --wall-sky:
    radial-gradient(1100px 700px at 8% -10%, #CFE2FF 0%, transparent 60%),
    radial-gradient(900px 650px at 100% 0%, #FFD9E8 0%, transparent 58%),
    radial-gradient(1000px 700px at 60% 115%, #FFEBCB 0%, transparent 60%),
    #F1F4FB;
  --wall-meadow:
    radial-gradient(1100px 700px at 0% 0%, #D3F5E1 0%, transparent 60%),
    radial-gradient(900px 650px at 100% 10%, #FFF3BF 0%, transparent 58%),
    radial-gradient(1000px 700px at 50% 120%, #CDEFFF 0%, transparent 60%),
    #F0F7F2;
  --wall-sunset:
    radial-gradient(1100px 700px at 0% 0%, #FFD3BE 0%, transparent 60%),
    radial-gradient(900px 650px at 100% 0%, #FFE6A8 0%, transparent 55%),
    radial-gradient(1000px 750px at 70% 120%, #F3CDF0 0%, transparent 60%),
    #FBF1EE;
  --wall-lilac:
    radial-gradient(1100px 700px at 0% 0%, #E2D9FF 0%, transparent 60%),
    radial-gradient(900px 650px at 100% 0%, #D3ECFF 0%, transparent 58%),
    radial-gradient(1000px 700px at 40% 120%, #FFDDF0 0%, transparent 60%),
    #F4F2FC;
  --wall-plain: linear-gradient(#EEF1F6, #E7EBF2);
  --wall-chalk:
    radial-gradient(1200px 800px at 30% 0%, rgba(255,255,255,.08) 0%, transparent 60%),
    radial-gradient(900px 700px at 100% 100%, rgba(0,0,0,.18) 0%, transparent 60%),
    #2A4A3E;
  --wall-night:
    radial-gradient(1100px 700px at 0% 0%, #34407A 0%, transparent 60%),
    radial-gradient(900px 650px at 100% 10%, #4A2F6E 0%, transparent 55%),
    #171C33;
  --wall: var(--wall-sky);
}
html[data-wall="meadow"] { --wall: var(--wall-meadow); }
html[data-wall="sunset"] { --wall: var(--wall-sunset); }
html[data-wall="lilac"] { --wall: var(--wall-lilac); }
html[data-wall="plain"] { --wall: var(--wall-plain); }
html[data-wall="chalk"] { --wall: var(--wall-chalk); }
html[data-wall="night"] { --wall: var(--wall-night); }
/* Dark backgrounds (pictures, chalkboard, night...: walls.js sets data-tone) get white writing on the board.
   The top bar and the tray stay light on every background, so they read well on pictures too. */
html[data-tone="dark"] { --on-wall: #fff; --on-wall-muted: rgba(255, 255, 255, .78); --grid-dot: rgba(255, 255, 255, .25); }
html[data-tone="dark"] .board-empty-arrow { color: #fff; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--wall); background-attachment: fixed;
  color: var(--ink); font-family: var(--font); font-weight: 600;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .4; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent, var(--sky)) 55%, transparent); outline-offset: 2px; }

.icon { display: inline-flex; width: 1.15em; height: 1.15em; flex: none; }
.icon svg { width: 100%; height: 100%; }
.muted { color: var(--muted); }

/* ---------- Top bar ---------- */
.topbar {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 10px 12px 0; padding: 6px 8px 6px 10px; min-height: 52px;
  background: var(--glass); border: 1px solid var(--glass-line); border-radius: 16px;
  backdrop-filter: blur(20px) saturate(1.6); -webkit-backdrop-filter: blur(20px) saturate(1.6);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 20px -10px rgba(16, 24, 40, .2);
  position: relative; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: inherit; text-decoration: none; border-radius: 10px; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-text { min-width: 0; }
.brand-name { font-size: 17px; font-weight: 900; letter-spacing: -.01em; line-height: 1.1; }
.greeting { font-size: 12.5px; color: var(--muted); font-weight: 700; white-space: nowrap; }
.topbar-controls { display: flex; align-items: center; gap: 4px; }
.tb-sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }
.tb-btn {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 12px;
  border: 0; border-radius: 10px; background: transparent; color: var(--ink-2);
  font-size: 14px; font-weight: 800; white-space: nowrap; font-size: 14px;
}
.tb-btn .icon { font-size: 17px; color: var(--muted); }
.tb-btn:hover:not(:disabled) { background: rgba(22, 32, 64, .06); }
.tb-btn[aria-expanded="true"] { background: rgba(22, 32, 64, .08); }
.tb-icon { width: 36px; padding: 0; justify-content: center; }
.class-select {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 4px 0 11px;
  background: #fff; border-radius: 10px; box-shadow: inset 0 0 0 1px var(--line), 0 1px 2px rgba(16, 24, 40, .05);
  color: var(--muted); cursor: pointer;
}
.class-select select {
  border: 0; background: transparent; color: var(--ink); font-weight: 800; font-size: 14.5px;
  padding: 6px 4px; max-width: 220px; cursor: pointer; outline: none;
}

/* Background menu */
.wall-picker { position: relative; }
.wall-menu {
  position: absolute; right: 0; top: calc(100% + 8px); width: 232px; padding: 12px;
  background: #fff; border-radius: 14px; box-shadow: 0 0 0 1px var(--line), 0 18px 40px -10px rgba(16, 24, 40, .3);
  animation: drop .16s ease-out;
}
@keyframes drop { from { opacity: 0; transform: translateY(-4px); } }
.wall-menu-title { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 0 2px 10px; }
.wall-swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.swatch {
  aspect-ratio: 1; border: 0; border-radius: 10px; background-size: 400% 400% !important;
  box-shadow: inset 0 0 0 1px rgba(22, 32, 64, .12);
}
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--sky); }

/* ---------- Buttons and switches inside tools ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  border: 0; border-radius: .7em; padding: .5em .95em;
  font-weight: 800; line-height: 1.15; white-space: nowrap; font-size: var(--ctl, 15px);
  transition: transform .08s, filter .15s, background .15s;
}
.btn .icon { font-size: 1.05em; }
.btn-primary {
  background: var(--accent, var(--sky)); color: var(--on-accent, #fff);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 2px rgba(16, 24, 40, .15),
    0 6px 14px -4px color-mix(in srgb, var(--accent, var(--sky)) 55%, transparent);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.06) saturate(1.05); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-big { padding: .6em 1.25em; }
.btn-soft { background: var(--surface-2); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line); }
.btn-soft:hover:not(:disabled) { background: var(--surface-3); }
.btn-danger { background: #FFF1F2; color: #C42638; box-shadow: inset 0 0 0 1px #FBD0D5; font-size: 14px; }
.btn-danger:hover { background: #FFE4E7; }

.icon-btn {
  display: grid; place-items: center; width: 34px; height: 34px; flex: none;
  border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 17px;
}
.icon-btn:hover { background: rgba(22, 32, 64, .07); color: var(--ink); }

.chip {
  border: 0; border-radius: .65em; padding: .38em .75em; background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-2);
  font-weight: 800; font-size: var(--ctl, 14px); white-space: nowrap;
}
.chip:hover { background: var(--surface-3); }
.chip[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent) 13%, white);
  color: color-mix(in srgb, var(--accent) 78%, black);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 40%, transparent);
}

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: .8em; background: var(--surface-3); font-size: var(--ctl, 14px); }
.seg button { border: 0; background: none; border-radius: .6em; padding: .32em .75em; font-weight: 800; color: var(--muted); white-space: nowrap; }
.seg button:hover { color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(16, 24, 40, .12), 0 1px 1px rgba(16, 24, 40, .05); }

/* ---------- The board ---------- */
/* isolation keeps the tools' stacking inside the board, so they never cover the top bar's menus. */
.board { position: relative; z-index: 1; isolation: isolate; flex: 1; min-height: 0; margin: 10px 12px 0; }
/* A dot grid shows while moving or resizing, to line things up against. */
.board::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .2s;
  background-image: radial-gradient(var(--grid-dot, rgba(22, 32, 64, .2)) 1.1px, transparent 1.3px);
  background-size: 24px 24px; background-position: -12px -12px;
}
body.is-dragging .board::before { opacity: 1; }
.board-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px; pointer-events: none; color: var(--on-wall-muted, var(--muted));
}
.board-empty-title { font-size: 32px; font-weight: 900; color: var(--on-wall, var(--ink)); letter-spacing: -.01em; margin-bottom: 8px; }
.board-empty p { font-size: 17px; line-height: 1.55; margin: 0 0 18px; max-width: 32em; font-weight: 700; }
.board-empty-arrow { width: 28px; height: 42px; color: var(--on-wall, var(--sky)); animation: nudge 1.4s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(8px); } }

/* ---------- Tool cards ---------- */
.card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-card);
}
.widget { position: absolute; }
.card-head {
  flex: none; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 4px 0 8px;
  background: color-mix(in srgb, var(--accent) 7%, white); border-bottom: 1px solid color-mix(in srgb, var(--accent) 14%, white);
  cursor: grab; touch-action: none; user-select: none;
}
.head-chip {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 7px; font-size: 13px; flex: none;
  color: var(--on-accent);
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 72%, white), var(--accent));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3);
}
.card-head h2 {
  flex: 1; min-width: 0; margin: 0; font-size: 13.5px; font-weight: 800; letter-spacing: .01em;
  color: color-mix(in srgb, var(--accent) 45%, var(--ink)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-head .icon-btn { width: 28px; height: 28px; border-radius: 8px; font-size: 15px; opacity: .5; transition: opacity .15s, background .15s; }
.card:hover .card-head .icon-btn, .card-head .icon-btn:focus-visible { opacity: 1; }
.card-head .del-btn:hover { background: #FFE4E7; color: #C42638; }
@media (hover: none) { .card-head .icon-btn { opacity: .9; } }

.card-body {
  --ctl: clamp(13px, 3cqmin, 28px);
  position: relative; flex: 1; min-height: 0; container-type: size;
  display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 16px;
}
.tool-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.tool-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: var(--ctl); min-height: 1.9em; }

.widget.dragging { box-shadow: var(--shadow-lift); }
.widget.dragging .card-head { cursor: grabbing; }
.widget.resizing { box-shadow: var(--shadow-lift), 0 0 0 2px color-mix(in srgb, var(--accent) 60%, transparent); }
body.is-dragging { user-select: none; }
.board.tidying .widget { transition: left .3s, top .3s, width .3s, height .3s; }
.pop-in { animation: pop-in .28s cubic-bezier(.2, 1.3, .4, 1); }
@keyframes pop-in { from { opacity: 0; transform: scale(.88) translateY(8px); } }

/* Resize handles on every edge and corner */
.rz { position: absolute; z-index: 3; touch-action: none; }
.rz-n, .rz-s { left: 28px; right: 28px; height: 12px; cursor: ns-resize; }
.rz-n { top: 0; height: 5px; }
.rz-s { bottom: 0; }
.rz-e, .rz-w { top: 28px; bottom: 28px; width: 12px; cursor: ew-resize; }
.rz-e { right: 0; }
.rz-w { left: 0; }
.rz-ne, .rz-nw, .rz-se, .rz-sw { width: 26px; height: 26px; }
.rz-ne, .rz-nw { height: 6px; }
.rz-ne { top: 0; right: 0; cursor: nesw-resize; }
.rz-nw { top: 0; left: 0; cursor: nwse-resize; }
.rz-se { bottom: 0; right: 0; cursor: nwse-resize; }
.rz-sw { bottom: 0; left: 0; cursor: nesw-resize; }
.rz-se::after {
  content: ''; position: absolute; right: 6px; bottom: 6px; width: 8px; height: 8px;
  border-right: 2.5px solid var(--surface-3); border-bottom: 2.5px solid var(--surface-3); border-bottom-right-radius: 4px;
  transition: border-color .15s;
}
.widget:hover .rz-se::after { border-color: color-mix(in srgb, var(--accent) 55%, white); }

/* ---------- The drawer ---------- */
.dock-wrap { flex: none; display: flex; justify-content: center; padding: 8px 12px 10px; position: relative; z-index: 30; }
.dock {
  display: flex; align-items: center; gap: 4px; padding: 6px; max-width: 100%;
  background: var(--glass); border: 1px solid var(--glass-line); border-radius: 18px;
  backdrop-filter: blur(20px) saturate(1.6); -webkit-backdrop-filter: blur(20px) saturate(1.6);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 12px 30px -10px rgba(16, 24, 40, .3);
}
.dock-sep { width: 1px; height: 26px; background: rgba(22, 32, 64, .12); margin: 0 4px; flex: none; }
.dock-app { position: relative; display: grid; place-items: center; width: 42px; height: 42px; padding: 0; border: 0; background: none; flex: none; border-radius: 12px; }
.dock-tile {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; font-size: 20px;
  color: var(--on-accent);
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 68%, white) 0%, var(--accent) 55%, color-mix(in srgb, var(--accent) 88%, black) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 3px 8px -2px color-mix(in srgb, var(--accent) 55%, transparent);
  transition: transform .18s cubic-bezier(.2, 1.4, .4, 1);
}
.dock-app:hover .dock-tile, .dock-app:focus-visible .dock-tile { transform: translateY(-3px) scale(1.08); }
.dock-app:active .dock-tile { transform: scale(.94); }
.dock-app:focus-visible { outline: none; }
.dock-label {
  position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translate(-50%, 4px);
  padding: 5px 9px; border-radius: 8px; background: var(--ink); color: #fff;
  font-size: 12.5px; font-weight: 800; white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .12s, transform .12s;
}
.dock-label::after {
  content: ''; position: absolute; top: 100%; left: 50%; margin-left: -5px;
  border: 5px solid transparent; border-top-color: var(--ink);
}
.dock-app:hover .dock-label, .dock-app:focus-visible .dock-label { opacity: 1; transform: translate(-50%, 0); }
.dock-app.on::after {
  content: ''; position: absolute; bottom: -3px; left: 50%; width: 4px; height: 4px; margin-left: -2px;
  border-radius: 50%; background: var(--ink-2);
}

/* ---------- Undo message ---------- */
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 40;
  display: flex; align-items: center; gap: 14px; padding: 8px 8px 8px 18px;
  background: var(--ink); color: #fff; font-size: 14.5px; font-weight: 800; border-radius: 14px;
  box-shadow: 0 18px 40px -10px rgba(0, 0, 0, .45); animation: pop-in .2s ease-out;
}
.toast-undo { border: 0; background: rgba(255, 255, 255, .14); color: #fff; font-weight: 800; border-radius: 9px; padding: 6px 14px; }
.toast-undo:hover { background: rgba(255, 255, 255, .26); }

/* ---------- Show on the board ---------- */
.present-layer { position: fixed; inset: 0; z-index: 50; display: flex; padding: 16px; background: var(--wall); }
.card-placeholder { display: none; }
.card.presenting {
  position: relative !important; left: auto !important; top: auto !important;
  width: 100% !important; height: 100% !important; z-index: auto !important;
}
.card.presenting .card-head { height: 52px; padding: 0 8px 0 14px; gap: 12px; cursor: default; }
.card.presenting .head-chip { width: 32px; height: 32px; border-radius: 10px; font-size: 19px; }
.card.presenting .card-head h2 { font-size: 19px; }
.card.presenting .card-head .icon-btn { width: 40px; height: 40px; font-size: 20px; opacity: 1; }
.card.presenting .card-body { padding: 24px 28px 28px; gap: 18px; }
.card.presenting .rz { display: none; }
.card.presenting .page-close { display: none; }

/* ---------- Clock ---------- */
.clock-display { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; gap: 5cqw; }
.clock-face-wrap { display: flex; }
.clock-face { width: min(76cqh, 46cqw); height: min(76cqh, 46cqw); overflow: visible; filter: drop-shadow(0 6px 14px rgba(16, 24, 40, .14)); }
.cf-rim { fill: none; }
.clock-face.show-mins .cf-rim { fill: color-mix(in srgb, var(--accent) 8%, white); }
.cf-mins { display: none; }
.clock-face.show-mins .cf-mins { display: inline; }
.cf-mins text { font-size: 10px; font-weight: 800; fill: var(--coral); text-anchor: middle; dominant-baseline: central; }
.cf-face { fill: #fff; stroke: color-mix(in srgb, var(--accent) 22%, white); stroke-width: 3; }
.cf-tick { stroke: #C3C7D3; stroke-width: 1.1; }
.cf-tick-h { stroke: var(--ink-2); stroke-width: 2.4; stroke-linecap: round; }
.cf-num { font-size: 16px; font-weight: 800; fill: var(--ink); text-anchor: middle; dominant-baseline: central; }
.cf-hour { stroke: var(--accent); stroke-width: 6.5; stroke-linecap: round; }
.cf-min { stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
.cf-sec { stroke: var(--coral); stroke-width: 1.5; stroke-linecap: round; }
.cf-pin { fill: var(--coral); stroke: #fff; stroke-width: 1.5; }

.clock-digital { min-width: 0; }
.clock-time { font-size: min(11.5cqw, 22cqh); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.clock-sec { font-size: .42em; color: var(--faint); font-weight: 800; }
.clock-ampm { font-size: .36em; color: var(--muted); font-weight: 800; margin-left: .25em; }
.clock-words { font-size: min(4.3cqw, 8cqh); color: var(--accent); font-weight: 800; margin-top: .55em; line-height: 1.2; }
.clock-date { font-size: min(3.4cqw, 6.5cqh); color: var(--muted); font-weight: 700; margin-top: .35em; }

.clock-display[data-mode="face"] .clock-digital { display: none; }
.clock-display[data-mode="face"] .clock-face { width: min(86cqh, 92cqw); height: min(86cqh, 92cqw); }
.clock-display[data-mode="digital"] .clock-face-wrap { display: none; }
.clock-display[data-mode="digital"] .clock-digital { text-align: center; }
.clock-display[data-mode="digital"] .clock-time { font-size: min(22cqw, 38cqh); }
.clock-display[data-mode="digital"] .clock-words { font-size: min(6.5cqw, 11cqh); }
.clock-display[data-mode="digital"] .clock-date { font-size: min(4.6cqw, 8cqh); }

@container (aspect-ratio < 1.1) {
  .clock-display[data-mode="both"] { flex-direction: column; gap: 3cqh; text-align: center; }
  .clock-display[data-mode="both"] .clock-face { width: min(46cqh, 86cqw); height: min(46cqh, 86cqw); }
  .clock-display[data-mode="both"] .clock-time { font-size: min(16cqw, 11cqh); }
}

/* ---------- Timer ---------- */
.timer-dial { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; container-type: size; }
.timer-ring { width: min(100cqh, 100cqw); height: min(100cqh, 100cqw); filter: drop-shadow(0 6px 12px rgba(16, 24, 40, .1)); }
.tr-track { fill: #fff; stroke: var(--surface-3); stroke-width: 9; }
.tr-prog { fill: none; stroke-width: 9; stroke-linecap: round; transition: stroke-dashoffset .12s linear, stroke .4s; }
.timer-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.timer-digits {
  border: 0; background: none; padding: 0 .12em; border-radius: .14em;
  font-size: min(23cqh, 23cqw); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.timer-digits:not(.editable) { cursor: default; }
.timer-digits.editable:hover { background: var(--surface-2); }
.timer-sub { font-size: min(5.5cqh, 5.5cqw); color: var(--muted); font-weight: 800; min-height: 1.3em; margin-top: .35em; text-transform: uppercase; letter-spacing: .08em; }
.timer-edit { display: flex; align-items: center; gap: .15em; font-size: min(12cqh, 12cqw); font-weight: 900; }
.timer-edit input {
  width: 2.3em; text-align: center; font-weight: 900; border: 0; border-radius: .2em; padding: .05em 0;
  background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--line); -moz-appearance: textfield;
}
.timer-edit input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.timer-edit input::-webkit-inner-spin-button { -webkit-appearance: none; }
.timer-edit .btn { font-size: min(5cqh, 5cqw); margin-left: .4em; }
.timer-done .timer-sub { color: var(--coral); font-size: min(7cqh, 7cqw); }
.timer-done .timer-ring { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.04); } }
/* In a small timer, drop the presets so the dial keeps its room (times can still be typed). */
@container (max-height: 330px) { .timer-presets { display: none; } }

/* ---------- Stopwatch ---------- */
.sw-stage { flex: 1; min-height: 0; display: grid; place-items: center; }
.sw-time { font-size: min(18cqw, 30cqh); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.has-laps .sw-time { font-size: min(15cqw, 19cqh); }
.sw-tenths { font-size: .55em; color: var(--faint); }
.sw-laps {
  display: none; margin: 0; padding: 4px; list-style: none; overflow: auto; max-height: 34%;
  font-size: clamp(13px, 3cqmin, 26px); background: var(--surface-2); border-radius: 12px;
}
.has-laps .sw-laps { display: block; }
.sw-laps li { display: grid; grid-template-columns: 1fr 1fr 1fr; padding: .35em .6em; border-radius: 8px; font-variant-numeric: tabular-nums; }
.sw-laps li:first-child { background: #fff; box-shadow: 0 1px 2px rgba(16, 24, 40, .08); }
.sw-lap-no { color: var(--muted); }
.sw-lap-split { font-weight: 900; text-align: center; }
.sw-lap-total { color: var(--muted); text-align: right; }

/* ---------- Name picker ---------- */
.picker-info { color: var(--muted); font-size: calc(var(--ctl) * .95); font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-stage {
  flex: 1; min-height: 0; display: grid; place-items: center; text-align: center; overflow: hidden; container-type: size;
  border-radius: 16px;
  background:
    radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--accent) 12%, white) 0%, transparent 70%),
    var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
.picker-name { font-weight: 900; line-height: 1.1; padding: 0 .3em; white-space: nowrap; letter-spacing: -.01em; }
.picker-name.empty { font-size: min(6cqw, 13cqh); font-weight: 800; color: var(--muted); white-space: normal; letter-spacing: 0; }
.picker-name.spinning { color: var(--faint); }
.picker-name.landed { color: var(--accent); animation: pop .5s cubic-bezier(.2, 1.7, .4, 1); }
@keyframes pop { from { transform: scale(.55); } to { transform: scale(1); } }

/* ---------- Name wheel ---------- */
.wheel-stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; container-type: size; }
.wheel-wrap { position: relative; width: min(94cqh, 94cqw); height: min(94cqh, 94cqw); }
.wheel-canvas {
  display: block; width: 100%; height: 100%; border-radius: 50%; will-change: transform;
  box-shadow: 0 0 0 5px #fff, 0 10px 30px -6px rgba(16, 24, 40, .35);
}
.wheel-wrap.is-empty .wheel-canvas { box-shadow: 0 0 0 5px #fff, 0 4px 14px -4px rgba(16, 24, 40, .2); }
.wheel-pointer {
  position: absolute; z-index: 2; left: 50%; top: -4%; width: 9%; height: 12%; margin-left: -4.5%;
  background: var(--ink); clip-path: polygon(0 0, 100% 0, 50% 100%); border-radius: 3px;
  transform-origin: 50% 10%; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .3));
}
.wheel-pointer.flick { animation: flick .14s ease-out; }
@keyframes flick { 40% { transform: rotate(-14deg); } }
.wheel-hub {
  position: absolute; left: 50%; top: 50%; width: 22%; height: 22%; transform: translate(-50%, -50%);
  border: 0; border-radius: 50%; background: #fff; color: var(--ink);
  font-size: min(4.6cqh, 4.6cqw); font-weight: 900; letter-spacing: .06em;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, .5), 0 4px 14px rgba(16, 24, 40, .3);
  transition: transform .15s;
}
.wheel-hub:hover:not(:disabled) { transform: translate(-50%, -50%) scale(1.06); }
.wheel-hub:disabled { opacity: 1; color: var(--faint); }
.wheel-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .8em;
  text-align: center; font-size: min(5.5cqw, 6.5cqh); font-weight: 900; color: var(--ink-2); padding: 1em;
}
.wheel-empty .btn { font-size: var(--ctl); }
.wheel-winner {
  position: absolute; inset: -4px; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .3em; text-align: center; border-radius: 16px;
  background: rgba(255, 255, 255, .82); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fade .2s ease-out; cursor: pointer;
}
@keyframes fade { from { opacity: 0; } }
.wheel-win-label { font-size: min(5cqw, 6cqh); font-weight: 800; color: var(--muted); }
.wheel-win-name { font-weight: 900; line-height: 1.05; color: var(--accent); letter-spacing: -.01em; white-space: nowrap; animation: pop .55s cubic-bezier(.2, 1.7, .4, 1); }
.wheel-win-note { font-size: min(3.6cqw, 4.5cqh); font-weight: 800; color: var(--muted); min-height: 1.2em; margin-bottom: .6em; }
.wheel-winner .tool-controls { font-size: var(--ctl); }
.wheel-confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }

/* ---------- Visual timetable ---------- */
.tt-top { gap: 6px; }
.tt-top .seg, .tt-edit { flex: none; }
@container (max-width: 360px) { .tt-top .seg button { padding: .32em .5em; } }
.tt-day {
  min-width: 0; border: 0; border-radius: .65em; padding: .38em .5em; cursor: pointer;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
  font-weight: 800; font-size: var(--ctl); color: var(--ink-2); outline: none;
}
.tt-edit { display: inline-flex; align-items: center; gap: .35em; }
@container (max-width: 400px) { .tt-edit span:not(.icon) { display: none; } }
.tt-view { position: relative; flex: 1; min-height: 0; }
.tt-tile {
  display: grid; place-items: center; flex: none; width: var(--icon, 36px); height: var(--icon, 36px); border-radius: 28%;
  color: #fff; background: linear-gradient(160deg, color-mix(in srgb, var(--k) 68%, white), var(--k));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 3px 8px -3px color-mix(in srgb, var(--k) 65%, transparent);
}
.tt-tile svg { width: 62%; height: 62%; }

.tt-list { --cols: 1; --icon: 40px; height: 100%; display: grid; gap: 8px; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }
.tt-item {
  position: relative; min-width: 0; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--icon) * .1);
  padding: calc(var(--icon) * .12); border-radius: calc(var(--icon) * .26 + 6px); text-align: center;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); transition: opacity .3s;
}
.tt-text { min-width: 0; max-width: 100%; }
.tt-label { font-weight: 900; font-size: calc(var(--icon) * .27); line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tt-time { font-weight: 800; color: var(--muted); font-size: calc(var(--icon) * .21); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tt-end { display: none; }
/* As a list (tall tool): picture on the left, name, times on the right. */
.tt-list.as-rows .tt-item { flex-direction: row; justify-content: flex-start; text-align: left; gap: calc(var(--icon) * .32); padding: 0 calc(var(--icon) * .3) 0 calc(var(--icon) * .12); }
.tt-list.as-rows .tt-text { flex: 1; display: flex; align-items: baseline; justify-content: space-between; gap: .8em; }
.tt-list.as-rows .tt-label { font-size: calc(var(--icon) * .48); }
.tt-list.as-rows .tt-time { font-size: calc(var(--icon) * .34); }
.tt-list.as-rows .tt-end { display: inline; }

.tt-item[data-state="past"] { opacity: .42; }
.tt-item[data-state="past"] .tt-tile { filter: grayscale(.75); }
.tt-item[data-state="now"] {
  background: color-mix(in srgb, var(--accent) 10%, white);
  box-shadow: inset 0 0 0 2.5px var(--accent), 0 8px 18px -8px color-mix(in srgb, var(--accent) 60%, transparent);
}
.tt-item[data-state="next"] { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 38%, transparent); }
.tt-badge {
  position: absolute; top: 5px; right: 5px; padding: .15em .5em; border-radius: .5em;
  background: var(--accent); color: var(--on-accent); font-size: clamp(9px, calc(var(--icon) * .17), 18px);
  font-weight: 900; text-transform: uppercase; letter-spacing: .06em;
}
.tt-badge-next { background: #fff; color: color-mix(in srgb, var(--accent) 80%, black); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 38%, transparent); }
.tt-done {
  position: absolute; top: 5px; right: 5px; width: clamp(14px, calc(var(--icon) * .3), 28px); aspect-ratio: 1;
  border-radius: 50%; background: var(--grass);
}
.tt-done::after {
  content: ''; position: absolute; left: 34%; top: 20%; width: 26%; height: 45%;
  border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
.tt-list.as-rows .tt-badge, .tt-list.as-rows .tt-done { position: relative; top: auto; right: auto; flex: none; }
.tt-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: color-mix(in srgb, var(--accent) 16%, white); }
.tt-progress i { display: block; height: 100%; background: var(--accent); transition: width 1s linear; }

.tt-nownext { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tt-nn-card {
  --icon: min(28cqh, 20cqw);
  position: relative; min-height: 0; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2.2cqmin; padding: 3cqmin; border-radius: 18px; text-align: center;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
}
.tt-nn-card.is-now { background: color-mix(in srgb, var(--accent) 9%, white); box-shadow: inset 0 0 0 3px var(--accent); }
.tt-nn-label {
  position: absolute; top: 2.4cqmin; left: 2.4cqmin; padding: .2em .7em; border-radius: .6em;
  background: var(--accent); color: var(--on-accent); font-size: clamp(11px, 3cqmin, 26px); font-weight: 900; text-transform: uppercase; letter-spacing: .08em;
}
.is-next .tt-nn-label { background: #fff; color: var(--ink-2); box-shadow: inset 0 0 0 1.5px var(--line); }
.tt-nn-name { font-size: clamp(16px, 7.5cqmin, 84px); font-weight: 900; line-height: 1.05; letter-spacing: -.01em; }
.tt-nn-note { font-size: clamp(12px, 3.4cqmin, 30px); font-weight: 800; color: var(--muted); }
.tt-nn-msg { font-size: clamp(14px, 5cqmin, 44px); font-weight: 900; color: var(--muted); }
.tt-nn-card .tt-progress { height: clamp(5px, 1.3cqmin, 12px); }
@container (aspect-ratio < 1) {
  .tt-nownext { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .tt-nn-card { --icon: min(15cqh, 30cqw); }
}
.tt-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1em; color: var(--muted); font-size: var(--ctl); font-weight: 800; text-align: center; }

/* Timetable editor */
.tt-editor { width: min(720px, calc(100vw - 32px)); }
.tt-editor-days { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; padding: 14px 24px 6px; font-size: 14px; }
.tt-editor-hint { font-size: 13px; font-weight: 700; }
.tt-rows { display: flex; flex-direction: column; gap: 6px; padding: 8px 24px 16px; max-height: 58vh; overflow: auto; }
.tt-rows-empty { padding: 24px; text-align: center; }
.tt-row { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 6px; border-radius: 12px; background: var(--surface-2); }
.tt-row-tile { border: 0; padding: 0; background: none; border-radius: 10px; transition: transform .12s; }
.tt-row-tile:hover { transform: scale(1.08); }
.tt-row-label, .tt-row input[type="time"] {
  border: 0; border-radius: 9px; padding: 8px 10px; background: #fff; font-weight: 800; font-size: 15px;
  box-shadow: inset 0 0 0 1px var(--line); font-variant-numeric: tabular-nums;
}
.tt-row-label { flex: 1; min-width: 0; }
.tt-row input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--orange); }
.tt-row-del:hover { background: #FFE4E7; color: #C42638; }
.tt-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 4px; padding: 8px; margin-bottom: 4px; border-radius: 12px; background: #fff; box-shadow: inset 0 0 0 1px var(--line); }
.tt-pick-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 7px 4px; border: 0; border-radius: 10px; background: none; font-size: 11.5px; font-weight: 800; color: var(--ink-2); }
.tt-pick-item .tt-tile { --icon: 34px; }
.tt-pick-item:hover { background: var(--surface-2); }
.tt-pick-item.is-on { background: color-mix(in srgb, var(--orange) 12%, white); box-shadow: inset 0 0 0 1.5px var(--orange); }
.tt-editor-foot { justify-content: flex-start; flex-wrap: wrap; }
.tt-editor-foot form { margin: 0; }
@media (max-width: 700px) { .tt-row { flex-wrap: wrap; } .tt-row-label { flex-basis: 60%; } }

/* ---------- Date & weather ---------- */
.td-board { flex: 1; min-height: 0; display: grid; grid-template-columns: 1.15fr 1fr; gap: 4cqw; align-items: stretch; }
.td-info { min-width: 0; align-self: center; }
.td-lead { font-size: clamp(13px, min(5cqh, 3cqw), 38px); font-weight: 800; color: var(--muted); }
.td-day { font-size: clamp(28px, min(17cqh, 9.5cqw), 150px); font-weight: 900; line-height: 1; color: var(--accent); letter-spacing: -.02em; }
.td-date { font-size: clamp(15px, min(7.5cqh, 4.3cqw), 60px); font-weight: 900; margin-top: .15em; }
.td-facts { display: flex; flex-wrap: wrap; gap: .5em; margin-top: .7em; font-size: clamp(11px, min(4.2cqh, 2.4cqw), 30px); }
.td-fact {
  display: flex; flex-direction: column; padding: .35em .75em; border-radius: .7em;
  background: color-mix(in srgb, var(--f) 9%, white); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--f) 22%, white);
}
.td-fact-label { font-size: .7em; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; color: color-mix(in srgb, var(--f) 75%, var(--ink)); }
.td-fact-value { display: inline-flex; align-items: center; gap: .3em; font-size: 1.15em; font-weight: 900; }
.td-fact-value .icon { color: var(--f); }
.td-yt { display: flex; flex-wrap: wrap; gap: .2em 1.2em; margin-top: .8em; font-size: clamp(12px, min(4.4cqh, 2.6cqw), 32px); font-weight: 700; color: var(--ink-2); }
.td-wx {
  min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.6cqmin;
  padding: 2.5cqmin; border-radius: 18px; text-align: center; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
}
.td-wx-pic svg { display: block; width: min(30cqh, 22cqw); height: min(30cqh, 22cqw); }
.td-wx-pic.is-set svg { animation: pop .5s cubic-bezier(.2, 1.7, .4, 1); }
.td-wx-text { font-size: clamp(13px, 3.6cqmin, 36px); font-weight: 800; color: var(--ink-2); }
.td-wx-text b { color: var(--accent); font-weight: 900; }
.td-wx-pick { display: flex; flex-wrap: wrap; justify-content: center; gap: .3em; font-size: clamp(24px, 6.4cqmin, 56px); }
.td-wx-btn {
  display: grid; place-items: center; box-sizing: content-box; width: 1em; height: 1em; padding: .08em;
  border: 0; border-radius: .22em; background: #fff; box-shadow: inset 0 0 0 1px var(--line), 0 1px 2px rgba(16, 24, 40, .06);
  transition: transform .12s;
}
.td-wx-btn svg { width: 100%; height: 100%; }
.td-wx-btn:hover { transform: translateY(-2px); }
.td-wx-btn[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 10%, white); box-shadow: inset 0 0 0 2.5px var(--accent); }
@container (aspect-ratio < 1.25) {
  .td-board { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); gap: 2.5cqh; }
  .td-info { text-align: center; }
  .td-facts, .td-yt { justify-content: center; }
  .td-wx-pic svg { width: min(16cqh, 30cqw); height: min(16cqh, 30cqw); }
}

/* ---------- Class jobs ---------- */
.jb-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.jb-step { width: 2em; height: 2em; font-size: var(--ctl); border-radius: .6em; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-2); }
.jb-grid { --cols: 2; --fs: 18px; flex: 1; min-height: 0; display: grid; gap: 8px; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); font-size: var(--fs); }
.jb-card { display: flex; align-items: center; gap: .6em; min-width: 0; min-height: 0; overflow: hidden; padding: .4em .7em; border-radius: .7em; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.jb-card .tt-tile { --icon: 2.1em; }
.jb-text { min-width: 0; }
.jb-job { font-size: .6em; font-weight: 900; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jb-who { font-size: 1em; font-weight: 900; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jb-note { font-size: .55em; font-weight: 800; color: var(--orange); white-space: nowrap; }
.jb-card.is-cover { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--orange) 45%, transparent); }
.jb-pick { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); }

/* ---------- Birthdays ---------- */
.bd-view { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.bd-party {
  flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3em;
  padding: 2cqmin; border-radius: 16px; text-align: center; overflow: hidden;
  background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--accent) 13%, white), var(--surface-2) 75%);
  box-shadow: inset 0 0 0 1px var(--line);
}
.bd-balloons svg { display: block; width: min(40cqw, 30cqh); }
.bd-party .bd-balloons svg { animation: float 3s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px); } }
.bd-hb { font-size: clamp(13px, 4.6cqmin, 46px); font-weight: 900; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; }
.bd-names { font-size: clamp(20px, 10cqmin, 110px); font-weight: 900; line-height: 1.05; letter-spacing: -.01em; }
.bd-names-small { font-size: clamp(18px, 7cqmin, 80px); }
.bd-weekend { font-size: clamp(14px, 4.5cqmin, 44px); font-weight: 900; margin-top: .4em; }
.bd-weekend-note { font-size: clamp(12px, 3.2cqmin, 30px); font-weight: 800; color: var(--muted); }
.bd-party .btn { margin-top: .6em; flex: none; }
.has-party .bd-party { flex: 1 0 auto; }
.has-party .bd-balloons svg { width: min(40cqw, 22cqh); }
/* On a birthday the celebration comes first; "Coming up" only shows when the tool is tall enough. */
@container (max-height: 460px) { .has-party .bd-soon-title, .has-party .bd-soon { display: none; } }
.bd-none { display: flex; align-items: center; gap: .5em; padding: .6em .8em; border-radius: 14px; background: var(--surface-2); font-size: clamp(14px, 4cqmin, 36px); font-weight: 900; color: var(--muted); }
.bd-none-icon { display: inline-flex; font-size: 1.2em; color: var(--accent); }
.bd-soon-title { font-size: clamp(11px, 2.6cqmin, 22px); font-weight: 900; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.bd-soon { list-style: none; margin: 0; padding: 0; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 4px; font-size: clamp(13px, 3.4cqmin, 30px); }
.bd-soon li { display: flex; justify-content: space-between; gap: 1em; padding: .35em .7em; border-radius: .6em; background: var(--surface-2); }
.bd-soon-name { font-weight: 900; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-soon-when { color: var(--muted); font-weight: 800; white-space: nowrap; }
.bd-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .7em; text-align: center; font-size: var(--ctl); font-weight: 800; color: var(--ink-2); }
.bd-small { font-size: .85em; color: var(--muted); }
.confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 6; }

/* Birthdays tab in Classes */
#classTabs .seg { font-size: 14px; }
.bday-pane { display: flex; flex-direction: column; min-height: 0; }
.bday-intro { margin: 0 0 8px; font-size: 13.5px; font-weight: 700; }
.bday-list { flex: 1; max-height: 300px; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.bday-row { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 12px; border-radius: 10px; background: var(--surface-2); }
.bday-name { flex: 1; min-width: 0; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bday-row select { border: 0; border-radius: 8px; padding: 6px 8px; background: #fff; box-shadow: inset 0 0 0 1px var(--line); font-weight: 700; }

/* ---------- Group maker ---------- */
.stepper { display: inline-flex; align-items: center; background: var(--surface-2); border-radius: .8em; box-shadow: inset 0 0 0 1px var(--line); font-size: var(--ctl); }
.stepper button { border: 0; background: none; padding: .38em .55em; border-radius: .7em; display: grid; place-items: center; color: var(--ink-2); }
.stepper button:hover { background: var(--surface-3); }
.stepper-num { min-width: 1.6em; text-align: center; font-weight: 900; }
.groups-out {
  --cols: 2; --rows: 1; --per: 4;
  flex: 1; min-height: 0; overflow: auto; display: grid; gap: 10px; align-content: start;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  /* Sized so every group fits without scrolling: each group is about (names x 1.3 + 2.2) lines tall. */
  font-size: clamp(12px, min(calc(80cqh / (var(--rows) * (var(--per) * 1.3 + 2.2))), calc(100cqw / (var(--cols) * 7.5))), 46px);
}
.groups-empty { grid-column: 1 / -1; align-self: center; text-align: center; color: var(--muted); font-size: var(--ctl); font-weight: 700; padding: 2em 1em; }
.group {
  min-width: 0; padding: .5em .65em .55em; border-radius: 14px;
  background: color-mix(in srgb, var(--g) 6%, white); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--g) 18%, white);
}
.group-name {
  display: inline-block; max-width: 100%; margin-bottom: .3em; padding: .12em .55em; border-radius: .5em;
  background: var(--g); color: #fff; font-size: .7em; font-weight: 900; letter-spacing: .02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.group ul { margin: 0; padding: 0; list-style: none; }
.group li { line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 800; }

/* ---------- Noise meter ---------- */
.noise-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; gap: 5cqw; }
.noise-face svg { width: min(58cqh, 34cqw); height: min(58cqh, 34cqw); display: block; filter: drop-shadow(0 8px 16px rgba(16, 24, 40, .15)); }
.nf-head { transition: fill .4s; }
.nf-eye { fill: var(--ink); }
.nf-mouth { fill: none; stroke: var(--ink); stroke-width: 5; stroke-linecap: round; transition: d .3s; }
.noise-loud .noise-face { animation: wobble .5s ease-in-out infinite; }
@keyframes wobble { 25% { transform: rotate(-5deg); } 75% { transform: rotate(5deg); } }
.noise-side { flex: 1; max-width: 56cqw; min-width: 0; }
.noise-label { font-size: min(7cqw, 13cqh); font-weight: 900; line-height: 1.1; margin-bottom: .45em; letter-spacing: -.01em; }
.noise-meter { position: relative; height: min(8cqh, 40px); background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.noise-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 999px; transition: background .4s; }
.noise-mark { position: absolute; top: 15%; bottom: 15%; width: 3px; margin-left: -1.5px; background: var(--ink); opacity: .45; border-radius: 2px; }
.noise-note { color: var(--muted); font-size: clamp(12px, 2.5cqmin, 20px); font-weight: 700; margin-top: .7em; line-height: 1.4; }
.noise-strict { display: inline-flex; align-items: center; gap: .5em; font-size: calc(var(--ctl) * .85); color: var(--muted); font-weight: 800; }
.noise-strict input { accent-color: var(--accent); width: 7em; }

/* ---------- Dialogs ---------- */
.dialog {
  width: min(860px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0;
  border: 0; border-radius: 22px; color: var(--ink); background: #fff;
  box-shadow: 0 0 0 1px var(--line), 0 40px 90px -20px rgba(16, 24, 40, .45);
}
.dialog[open] { animation: pop-in .22s cubic-bezier(.2, 1.2, .4, 1); }
.dialog-narrow { width: min(640px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(20, 26, 44, .4); backdrop-filter: blur(3px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 14px 14px 24px; border-bottom: 1px solid var(--line); margin: 0; }
.dialog-head h2 { margin: 0; font-size: 21px; font-weight: 900; letter-spacing: -.01em; }
.dialog .icon-btn-light { background: var(--surface-2); }
.dialog-note { margin: 0; padding: 12px 24px 16px; color: var(--muted); font-size: 13.5px; font-weight: 700; }
.dialog-note.top { padding: 14px 24px 0; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 24px 18px; margin: 0; border-top: 1px solid var(--line); }
.dialog .btn { font-size: 15px; }

.classes-layout { display: grid; grid-template-columns: 230px 1fr; min-height: 430px; }
.classes-side { display: flex; flex-direction: column; gap: 10px; padding: 14px; background: var(--surface-2); border-right: 1px solid var(--line); }
.class-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; overflow: auto; max-height: 360px; }
.class-item {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  border: 0; background: none; border-radius: 10px; padding: 9px 12px; text-align: left; font-weight: 800; color: var(--ink-2);
}
.class-item:hover { background: rgba(22, 32, 64, .05); }
.class-item[aria-current="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(16, 24, 40, .1), inset 0 0 0 1px var(--line); }
.class-item small { color: var(--muted); font-weight: 800; background: var(--surface-3); border-radius: 6px; padding: 1px 7px; }
.classes-main { padding: 18px 24px; display: flex; flex-direction: column; min-width: 0; }
.class-editor { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 900; font-size: 14px; }
.field small { font-weight: 700; color: var(--muted); margin-left: 6px; }
.field-grow { flex: 1; }
.field input, .field textarea {
  border: 0; border-radius: 12px; padding: 10px 12px; font-weight: 700; font-size: 15px; background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
.field input:focus, .field textarea:focus { outline: none; background: #fff; box-shadow: inset 0 0 0 2px var(--sky); }
.field textarea { flex: 1; min-height: 220px; resize: vertical; line-height: 1.55; }
.editor-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; }
#pupilCount.warn { color: #B4560B; }
#awayDialog .btn-primary, #classesDialog .btn-primary { --accent: var(--sky); }

.away-grid { display: flex; flex-wrap: wrap; gap: 8px; padding: 16px 24px 20px; max-height: 55vh; overflow: auto; }
.away-chip { border: 0; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); border-radius: 10px; padding: .5em 1em; font-weight: 800; }
.away-chip:hover { background: var(--surface-3); }
.away-chip[aria-pressed="true"] { background: #FFF1F2; color: #C42638; box-shadow: inset 0 0 0 1.5px #F7B9C1; text-decoration: line-through; }

/* ---------- Narrower screens ---------- */
@media (max-width: 1100px) {
  .tb-btn .lbl { display: none; }
  .tb-btn { width: 36px; padding: 0; justify-content: center; }
}
/* Phones: tools stack in a list instead of floating */
@media (max-width: 700px) {
  .topbar { margin: 8px 8px 0; flex-wrap: wrap; }
  .greeting, .tb-sep { display: none; }
  .class-select select { max-width: 130px; }
  .board { margin: 8px 0 0; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 4px 12px 16px; }
  .board::before { display: none; }
  .widget {
    position: relative !important; left: auto !important; top: auto !important;
    width: auto !important; height: 380px !important; flex: none;
  }
  .rz, #tidyBtn { display: none; }
  .card-head { cursor: default; }
  .dock-wrap { padding: 6px 8px 8px; }
  .dock { overflow-x: auto; }
  .dock-label { display: none; }
  .classes-layout { grid-template-columns: 1fr; }
  .classes-side { border-right: 0; border-bottom: 1px solid var(--line); }
  .class-list { max-height: 140px; }
  .present-layer { padding: 6px; }
  .toast { bottom: 76px; }
}

/* ---------- Maths tools: shared ---------- */
.mx-top { flex-wrap: wrap; gap: 6px; }
.mx-total { min-width: 1.5em; font-size: clamp(20px, min(9cqh, 6cqw), 64px); font-weight: 900; line-height: 1; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.mx-total.is-hidden { color: var(--faint); }
.nl-hint { font-size: clamp(12px, 2.4cqmin, 20px); font-weight: 700; color: var(--muted); text-align: center; }

/* ---------- Number line ---------- */
.nl-top { flex-wrap: wrap; justify-content: flex-start; gap: 6px; }
.nl-custom { display: inline-flex; align-items: center; gap: .35em; font-size: var(--ctl); font-weight: 800; color: var(--muted); }
.nl-num { width: 4.4em; border: 0; border-radius: .5em; padding: .3em .4em; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); font-weight: 800; font-size: var(--ctl); }
.nl-num:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.nl-stage { position: relative; flex: 1; min-height: 0; border-radius: 14px; background: var(--surface-2); cursor: pointer; touch-action: none; }
.nl-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; font-family: var(--font); user-select: none; }
.nl-label { font-variant-numeric: tabular-nums; }
.nl-from { animation: blink 1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .35; } }

/* ---------- Place value chart and Dienes mat ---------- */
.pv-chart, .db-mat { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 6px; }
.pv-col, .db-col {
  position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; border-radius: 12px;
  background: color-mix(in srgb, var(--c) 7%, white); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 24%, white);
}
.pv-head { flex: none; display: flex; flex-direction: column; align-items: center; padding: .35em .3em .3em; background: var(--c); color: #fff; font-size: clamp(11px, 2.4cqmin, 22px); line-height: 1.1; text-align: center; }
.pv-head b { font-size: 1.35em; font-weight: 900; }
.pv-head span { max-width: 100%; font-size: .7em; font-weight: 800; opacity: .92; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; padding: 6px 4px; overflow: hidden; }
.pv-pile { --per: 3; --cs: 40px; display: grid; grid-template-columns: repeat(var(--per), var(--cs)); gap: calc(var(--cs) * .08); justify-content: center; }
.pv-counter {
  width: var(--cs); height: var(--cs); padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c) 55%, white), var(--c) 70%);
  color: #fff; font-weight: 900; font-size: calc(var(--cs) * var(--fsr, .3)); letter-spacing: -.02em;
  box-shadow: inset 0 0 0 calc(var(--cs) * .06) rgba(255, 255, 255, .45), 0 2px 4px rgba(16, 24, 40, .22);
  animation: pop-in .2s ease-out; transition: transform .12s;
}
.pv-counter:hover { transform: scale(1.07); }
.pv-point::after {
  content: ""; position: absolute; right: 3px; bottom: calc(50% - 6px); width: 12px; height: 12px; border-radius: 50%; background: var(--ink); z-index: 2;
}
.pv-group {
  position: absolute; left: 50%; bottom: 6px; z-index: 2; transform: translateX(-50%); max-width: calc(100% - 8px);
  padding: .4em .7em; border: 0; border-radius: .6em; background: var(--ink); color: #fff;
  font-size: clamp(11px, 2.1cqmin, 18px); font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 0 4px 10px rgba(16, 24, 40, .25); animation: pop-in .2s ease-out;
}
.pv-foot { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 2px; padding: 4px; background: rgba(255, 255, 255, .75); border-top: 1px solid color-mix(in srgb, var(--c) 20%, white); }
.pv-step { display: grid; place-items: center; width: clamp(24px, 5cqmin, 44px); aspect-ratio: 1; border: 0; border-radius: 8px; background: #fff; color: var(--c); box-shadow: inset 0 0 0 1px var(--line); font-size: clamp(13px, 2.6cqmin, 24px); }
.pv-step:hover { background: color-mix(in srgb, var(--c) 10%, white); }
.pv-digit { font-size: clamp(16px, 5cqmin, 48px); font-weight: 900; font-variant-numeric: tabular-nums; }
.is-over .pv-digit { color: var(--coral); }
.db-area { position: relative; flex: 1; min-height: 0; }
.db-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.db-block { animation: pop-in .2s ease-out; transform-box: fill-box; transform-origin: center; }
.db-block.can-break { cursor: pointer; }
.db-block.can-break:hover { filter: brightness(1.06) drop-shadow(0 2px 3px rgba(16, 24, 40, .25)); }

/* ---------- Counters ---------- */
.ct-mat { --cs: 40px; position: relative; flex: 1; min-height: 0; overflow: hidden; border-radius: 14px; background: #E7F4EC; box-shadow: inset 0 0 0 1px rgba(18, 160, 108, .18); touch-action: none; }
.ct-frame { position: absolute; inset: 0; pointer-events: none; }
.ct-ten {
  position: absolute; border-radius: 4px; background-color: #fff; outline: 3px solid var(--ink);
  background-image:
    repeating-linear-gradient(to right, transparent 0 calc(var(--cell) - 1.5px), #1D2233 calc(var(--cell) - 1.5px) var(--cell)),
    linear-gradient(to bottom, transparent calc(50% - 1.5px), #1D2233 calc(50% - 1.5px) calc(50% + 1.5px), transparent calc(50% + 1.5px));
}
.ct-counter {
  position: absolute; width: var(--cs); height: var(--cs); margin: calc(var(--cs) / -2) 0 0 calc(var(--cs) / -2);
  border-radius: 50%; cursor: grab; touch-action: none; z-index: 1;
  background: radial-gradient(circle at 35% 30%, #FFE58A, #FFC21A 70%);
  box-shadow: inset 0 0 0 calc(var(--cs) * .07) rgba(255, 255, 255, .35), 0 3px 6px rgba(16, 24, 40, .25);
  transition: left .25s, top .25s;
}
.ct-counter.is-red { background: radial-gradient(circle at 35% 30%, #FF8A8E, #EE3644 70%); }
.ct-counter.is-dragging { z-index: 3; cursor: grabbing; transition: none; box-shadow: inset 0 0 0 calc(var(--cs) * .07) rgba(255, 255, 255, .35), 0 10px 18px rgba(16, 24, 40, .3); }
.ct-counter.flip { animation: flip .3s ease-in-out; }
@keyframes flip { 50% { transform: scaleX(.1); } }
.ct-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; }
.ct-count { display: flex; align-items: center; gap: .8em; font-size: clamp(14px, 4cqmin, 40px); font-weight: 900; }
.ct-part { display: inline-flex; align-items: center; gap: .3em; }
.ct-dot { display: inline-block; width: .8em; height: .8em; border-radius: 50%; background: #FFC21A; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1); }
.ct-dot.is-red { background: #EE3644; }
.ct-sum { color: var(--muted); }
.ct-hidden { color: var(--faint); }
.ct-add { display: inline-flex; align-items: center; gap: .3em; }
.ct-add .ct-dot { width: 1em; height: 1em; }

/* ---------- Rekenrek ---------- */
.rk-frame {
  --rows: 2; --bead: 30px; position: relative; flex: 1; min-height: 0; display: grid; grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
  border-radius: 12px; border-left: 12px solid #9A6545; border-right: 12px solid #9A6545;
  background: linear-gradient(#FBF4EA, #F2E6D6); box-shadow: inset 0 0 0 1px var(--line);
}
.rk-row { position: relative; min-height: 0; }
.rk-rod { position: absolute; left: 0; right: 0; top: 50%; height: max(3px, calc(var(--bead) * .12)); transform: translateY(-50%); border-radius: 3px; background: #8A93A6; }
.rk-bead {
  position: absolute; left: 0; top: 50%; width: var(--bead); height: var(--bead); margin-top: calc(var(--bead) / -2);
  padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, #FFFFFF, #DCE0E8 75%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12), 0 2px 3px rgba(16, 24, 40, .25);
  transition: transform .35s cubic-bezier(.3, 1.2, .5, 1);
}
.rk-bead.is-red { background: radial-gradient(circle at 35% 30%, #FF8A8E, #E2303E 75%); }

/* ---------- A tool on its own page (/tools/<id>/) ---------- */
.tool-title { min-width: 0; }
.tool-title h1 { margin: 0; font-size: 17px; font-weight: 900; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-title p { margin: 0; font-size: 12.5px; color: var(--muted); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.tool-stage { position: relative; z-index: 1; flex: 1; min-height: 0; display: flex; padding: 10px 12px 12px; }
.tool-stage .card { flex: 1; }
.tb-btn.is-main { background: var(--sky); color: #fff; }
.tb-btn.is-main .icon { color: #fff; }
.tb-btn.is-main:hover:not(:disabled) { background: #2468D8; }
a.tb-btn { text-decoration: none; }
@media (max-width: 700px) {
  .tool-title p { display: none; }
  .tool-stage { padding: 8px; }
}
/* Beads only slide once the frame has been laid out (see rekenrek.js). */
.rk-frame:not(.is-ready) .rk-bead { transition: none; }

/* ---------- Place value: dragging counters ---------- */
.pv-counter { touch-action: none; }
.pv-counter.is-lifted { opacity: .25; }
.pv-ghost {
  position: fixed; z-index: 100; margin: 0; pointer-events: none; animation: none;
  transform: translate(-50%, -50%) scale(1.12);
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .45), 0 14px 28px rgba(16, 24, 40, .35);
  transition: background .15s;
}
.pv-ghost.is-away { opacity: .55; }
.pv-col.is-target { background: color-mix(in srgb, var(--c) 18%, white); box-shadow: inset 0 0 0 3px var(--c); }
.tool-placevalue .nl-hint { margin-top: -2px; }

/* ---------- Working-out grid ---------- */
.gd-top { gap: 6px; }
.gd-inks { display: inline-flex; align-items: center; gap: 4px; padding: 3px; border-radius: .8em; background: var(--surface-3); font-size: var(--ctl); }
.gd-ink { width: 1.7em; height: 1.7em; border: 0; border-radius: 50%; background: var(--ink); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .6); }
.gd-ink[aria-pressed="true"] { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink); }
.gd-sheet {
  --sq: 36px; --rule: #C9D6EA; --rule-strong: #A9BCDA;
  position: relative; flex: 1; min-height: 0; overflow: hidden; border-radius: 12px; background-color: #fff;
  box-shadow: inset 0 0 0 1px var(--line); touch-action: none; cursor: crosshair;
}
.gd-sheet[data-paper="squares"] {
  background-image:
    linear-gradient(var(--rule) 1px, transparent 1px),
    linear-gradient(90deg, var(--rule) 1px, transparent 1px);
  background-size: var(--sq) var(--sq);
}
.gd-sheet[data-paper="lines"] {
  background-image:
    linear-gradient(90deg, transparent calc(var(--sq) * 2), #F4A4AC calc(var(--sq) * 2), #F4A4AC calc(var(--sq) * 2 + 2px), transparent calc(var(--sq) * 2 + 2px)),
    linear-gradient(transparent calc(var(--sq) - 1px), var(--rule-strong) calc(var(--sq) - 1px));
  background-size: 100% 100%, 100% var(--sq);
}
.gd-sheet[data-paper="dots"] {
  background-image: radial-gradient(circle, #9DB0CE 1.6px, transparent 2px);
  background-size: var(--sq) var(--sq);
  background-position: calc(var(--sq) / -2) calc(var(--sq) / -2);
}
.gd-sheet.is-rubber { cursor: cell; }
.gd-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- Times table grid ---------- */
.tb-swatch { box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, .12); }
.tb-wrap { flex: 1; min-height: 0; display: grid; place-items: center; container-type: size; }
.tb-grid {
  --n: 13;
  width: min(100cqw, 100cqh); height: min(100cqw, 100cqh);
  display: grid; grid-template-columns: repeat(var(--n), 1fr); grid-template-rows: repeat(var(--n), 1fr);
  gap: 2px; padding: 2px; border-radius: 10px; background: #DCE1EA; touch-action: none; user-select: none;
  font-size: calc(min(100cqw, 100cqh) / var(--n) * .4); font-variant-numeric: tabular-nums;
}
.tb-corner, .tb-head, .tb-cell { display: grid; place-items: center; min-width: 0; min-height: 0; font-weight: 800; }
.tb-corner { background: var(--ink); color: #fff; border-radius: 6px 0 0 0; font-weight: 900; }
.tb-head { border: 0; padding: 0; background: color-mix(in srgb, var(--accent) 14%, white); color: color-mix(in srgb, var(--accent) 75%, black); font-weight: 900; font-size: 1em; cursor: pointer; }
.tb-head:hover, .tb-head.is-lit { background: var(--accent); color: var(--on-accent); }
.tb-cell { background: #fff; color: var(--ink); cursor: pointer; transition: background .12s; }
.tb-cell.is-square:not(.is-marked) { background: #F6F7FB; }
.tb-cell:hover { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 50%, transparent); }

/* ---------- Drawer tabs ---------- */
.dock-tabs { display: flex; flex: none; gap: 2px; padding: 3px; border-radius: 13px; background: rgba(22, 32, 64, .06); }
.dock-tab {
  position: relative; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 11px;
  border: 0; border-radius: 10px; background: none; color: var(--ink-2); font-size: 13.5px; font-weight: 800; white-space: nowrap;
}
.dock-tab .icon { font-size: 16px; color: var(--muted); }
.dock-tab:hover { background: rgba(255, 255, 255, .65); }
.dock-tab[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(16, 24, 40, .12); }
.dock-tab[aria-selected="true"] .icon { color: var(--sky); }
.dock-tab.on::after { content: ""; position: absolute; top: 5px; right: 5px; width: 5px; height: 5px; border-radius: 50%; background: var(--sky); }
.dock-apps { display: flex; align-items: center; justify-content: center; gap: 4px; }
.dock-apps.swap .dock-app { animation: dock-swap .22s ease-out backwards; }
.dock-apps.swap .dock-app:nth-child(2) { animation-delay: .02s; }
.dock-apps.swap .dock-app:nth-child(3) { animation-delay: .04s; }
.dock-apps.swap .dock-app:nth-child(4) { animation-delay: .06s; }
.dock-apps.swap .dock-app:nth-child(5) { animation-delay: .08s; }
.dock-apps.swap .dock-app:nth-child(n+6) { animation-delay: .1s; }
@keyframes dock-swap { from { opacity: 0; transform: translateY(6px); } }
@media (max-width: 900px) { .dock-tab span { display: none; } .dock-tab { padding: 0 10px; } }
@media (max-width: 700px) { .dock-apps { min-width: 0 !important; } }

/* ---------- Hundred square ---------- */
.hs-grid { gap: 3px; padding: 3px; }
.hs-grid .tb-cell:first-child { border-radius: 7px 0 0 0; }
.hs-grid .tb-cell:nth-child(10) { border-radius: 0 7px 0 0; }
.hs-grid .tb-cell:nth-child(91) { border-radius: 0 0 0 7px; }
.hs-grid .tb-cell:last-child { border-radius: 0 0 7px 0; }

/* ---------- Fraction wall ---------- */
.fw-wrap { position: relative; flex: 1; min-height: 0; container-type: size; }
.fw-wall {
  --rows: 12; --tw: 0px;
  position: absolute; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-auto-rows: minmax(0, 1fr);
  row-gap: 3px; touch-action: none; user-select: none;
}
.fw-wall.has-totals { --tw: clamp(34px, 7cqw, 90px); grid-template-columns: minmax(0, 1fr) var(--tw); column-gap: 6px; }
.fw-row { display: flex; min-width: 0; min-height: 0; border-radius: 6px; overflow: hidden; border: 2px solid #1D2233; }
.fw-piece {
  flex: 1; min-width: 0; display: grid; place-items: center; cursor: pointer; overflow: hidden;
  background: var(--tint, #fff); border-right: 2px solid #1D2233; transition: background .12s;
  font-size: min(calc(100cqh / var(--rows) * .36), calc((100cqw - var(--tw)) / var(--d) * .3));
  font-weight: 900; color: var(--ink); line-height: 1;
}
.fw-piece:last-child { border-right: 0; }
.fw-piece:hover { filter: brightness(.96); }
.fw-frac { display: inline-flex; flex-direction: column; align-items: center; font-variant-numeric: tabular-nums; }
.fw-frac i { font-style: normal; display: block; padding: 0 .12em; }
.fw-frac i:first-child { border-bottom: max(1.5px, .08em) solid currentColor; }
.fw-num { font-size: .78em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.fw-whole { font-size: 1.1em; }
.fw-total {
  display: grid; place-items: center; min-height: 0; border-radius: 6px; background: var(--surface-2);
  color: color-mix(in srgb, var(--accent) 80%, black); font-weight: 900;
  font-size: min(calc(100cqh / var(--rows) * .36), calc(var(--tw) * .32)); line-height: 1;
}
.fw-line { position: absolute; width: 0; border-left: 2.5px dashed var(--coral); pointer-events: none; z-index: 2; transform: translateX(-1px); }

/* ---------- Practice clock (hands you move) ---------- */
.pc-face { touch-action: none; cursor: pointer; user-select: none; }
.pc-hand { cursor: grab; }
.pc-face.is-dragging, .pc-face.is-dragging .pc-hand { cursor: grabbing; }
.pc-grip { stroke: transparent; stroke-width: 16; stroke-linecap: round; }
.pc-knob { fill: #fff; stroke-width: 2.5; }
.pc-hour .pc-knob { stroke: var(--accent); }
.pc-min .pc-knob { stroke: var(--ink); }
.pc-hand.is-held .pc-knob { fill: color-mix(in srgb, var(--accent) 30%, white); }
.pc-hour:hover .pc-knob, .pc-hour.is-held .pc-knob { r: 6.5; }
.pc-min:hover .pc-knob, .pc-min.is-held .pc-knob { r: 5.5; }
.pc-pastto { display: none; }
.pc-face.show-pastto .pc-pastto { display: inline; }
.pc-past { fill: color-mix(in srgb, var(--grass) 13%, white); }
.pc-to { fill: color-mix(in srgb, var(--orange) 13%, white); }
.pc-pt { font-size: 9px; font-weight: 900; fill: color-mix(in srgb, var(--grass) 80%, black); text-anchor: middle; dominant-baseline: central; text-transform: uppercase; letter-spacing: .08em; }
.pc-pt-to { fill: color-mix(in srgb, var(--orange) 85%, black); }
.pc-digital .clock-time { font-size: min(13cqw, 24cqh); }
.pc-digital .clock-words { font-size: min(4.8cqw, 9cqh); }
/* A fixed-width column for the time, so the face doesn't shift while its hands are dragged. */
.clock-display[data-mode="both"] .pc-digital { flex: 0 0 40cqw; }
@container (aspect-ratio < 1.1) { .clock-display[data-mode="both"] .pc-digital { flex: none; width: 100%; } }

/* ---------- Number bonds ---------- */
.nb-stage { position: relative; flex: 1; min-height: 0; display: flex; gap: 10px; }
.nb-svg { flex: 1; min-width: 0; height: 100%; display: block; user-select: none; }
.nb-num { font-weight: 900; text-anchor: middle; dominant-baseline: central; font-family: var(--font); font-variant-numeric: tabular-nums; }
.nb-node { cursor: pointer; }
.nb-node:hover circle, .nb-node:hover rect { filter: brightness(.97); }
.nb-node.is-hidden circle, .nb-node.is-hidden rect { stroke-dasharray: 10 7; }
.nb-list {
  flex: none; width: clamp(110px, 18cqw, 200px); overflow: auto; display: flex; flex-direction: column; gap: 3px;
  padding: 8px; border-radius: 12px; background: var(--surface-2); font-size: clamp(13px, 2.6cqmin, 22px);
}
.nb-list-title { font-weight: 900; color: var(--muted); font-size: .8em; text-transform: uppercase; letter-spacing: .06em; padding: 2px 4px 6px; }
.nb-list-note { color: var(--muted); font-weight: 700; font-size: .85em; padding: 4px; }
.nb-bond { border: 0; border-radius: .45em; padding: .2em .5em; background: none; text-align: left; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.nb-bond:hover { background: #fff; }
.nb-bond.is-on { background: var(--accent); color: var(--on-accent); }
.nb-controls { gap: 14px; }
.nb-steps { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.nb-step { display: inline-flex; align-items: center; gap: 6px; font-size: var(--ctl); }
.nb-step-label { font-weight: 900; color: var(--c, var(--muted)); }
.nb-step .pv-step { --c: var(--accent); width: 2em; font-size: var(--ctl); }
.nb-step-num { min-width: 1.6em; text-align: center; font-weight: 900; font-size: 1.15em; }
.nb-whole-in { width: 4em; text-align: center; font-weight: 900; }
.nb-rest { font-weight: 800; color: var(--muted); font-size: var(--ctl); }

/* ---------- Decimal place value grid ---------- */
.dg-read { min-width: 0; }
.dg-num { font-size: clamp(22px, min(10cqh, 7cqw), 72px); }
.dg-words { font-size: clamp(12px, min(3.6cqh, 2.4cqw), 26px); font-weight: 800; color: var(--accent); margin-top: .2em; min-height: 1.2em; }
.dg-grid { position: relative; flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.dg-cell { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; border-radius: 12px; overflow: visible;
  background: color-mix(in srgb, var(--c) 7%, white); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 24%, white); }
.dg-cell .pv-head { border-radius: 12px 12px 0 0; }
.dg-cell .pv-foot { border-radius: 0 0 12px 12px; justify-content: center; gap: 8px; }
.dg-slot { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; }
.dg-card {
  display: grid; place-items: center; width: 76%; aspect-ratio: 3 / 4; max-height: 88%; border-radius: 10px;
  background: #fff; box-shadow: 0 2px 0 rgba(16, 24, 40, .12), 0 6px 14px -6px rgba(16, 24, 40, .3), inset 0 0 0 2px var(--c);
  font-size: min(calc((100cqw - 36px) / 7 * .55), 18cqh); font-weight: 900; color: var(--ink); font-variant-numeric: tabular-nums;
  position: relative; z-index: 1;
}
.dg-card.is-zero { color: var(--faint); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c) 30%, white); background: rgba(255, 255, 255, .6); }
.dg-grid.is-moving .dg-card { transition: transform .5s cubic-bezier(.4, 0, .2, 1); z-index: 3; }
/* The decimal point, fixed between the ones and the tenths */
.dg-ones::after {
  content: ""; position: absolute; right: -9px; top: 58%; width: 12px; height: 12px; border-radius: 50%;
  background: var(--ink); z-index: 4; box-shadow: 0 0 0 3px #fff;
}
.dg-ops { gap: 6px; }
.dg-shift { font-weight: 900; min-width: 4.2em; }
.dg-gap { width: 14px; }
.dg-note { min-height: 1.2em; text-align: center; color: var(--coral); font-weight: 800; font-size: clamp(12px, 2.4cqmin, 18px); }

/* ---------- Arrays ---------- */
.ar-sentence { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 18px; font-size: clamp(16px, min(7cqh, 4.4cqw), 48px); font-weight: 900; font-variant-numeric: tabular-nums; }
.ar-sentence b { color: var(--accent); }
.ar-also { font-size: .62em; color: var(--muted); }
.ar-stage { position: relative; flex: 1; min-height: 0; }
.ar-svg { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; transition: transform .26s ease-in, opacity .26s; }
.ar-svg.is-turning { transform: rotate(90deg) scale(.8); opacity: 0; }
.ar-hint { flex-basis: 100%; }

/* ---------- Dice ---------- */
.dc-tray { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(min(var(--n), 3), auto); grid-auto-rows: minmax(0, 1fr); gap: 4cqmin 6cqmin; place-items: center; place-content: center; padding: 2cqmin; }
.dc-die {
  --size: min(30cqh, calc(80cqw / min(var(--n), 3)), 220px);
  width: var(--size); aspect-ratio: 1; max-height: 100%; border: 0; padding: 9%; border-radius: 20%; cursor: pointer;
  background: linear-gradient(160deg, #fff, #F1F3F8); box-shadow: inset 0 0 0 3px var(--c), 0 4px 0 color-mix(in srgb, var(--c) 45%, #8a8fa0), 0 12px 22px -10px rgba(16, 24, 40, .4);
  display: grid; place-items: center; transition: transform .1s;
}
.dc-die:hover { transform: translateY(-2px); }
.dc-die.is-rolling { animation: tumble .18s ease-in-out; }
@keyframes tumble { 50% { transform: rotate(14deg) scale(.94); } }
.dc-pips { width: 100%; height: 100%; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); place-items: center; }
.dc-pips span { width: 62%; aspect-ratio: 1; border-radius: 50%; }
.dc-pips span.is-on { background: var(--c); }
.dc-n { font-size: calc(var(--size) * .5); font-weight: 900; color: var(--c); line-height: 1; }
.dc-result { text-align: center; min-height: 1.3em; font-size: clamp(16px, min(7cqh, 5cqw), 52px); font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.dc-result b { color: var(--ink); }
.dc-note { font-size: .6em; }

/* ---------- Money ---------- */
.mn-palette { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; padding: 6px; border-radius: 12px; background: var(--surface-2); }
.mn-pick { width: clamp(30px, 6.2cqmin, 54px); aspect-ratio: 1; padding: 0; border: 0; background: none; border-radius: 50%; cursor: pointer; transition: transform .12s; }
.mn-pick.is-note { width: clamp(52px, 11cqmin, 96px); aspect-ratio: 62 / 32; border-radius: 6px; }
.mn-pick:hover { transform: translateY(-2px) scale(1.05); }
.mn-pick svg, .mn-item svg { width: 100%; height: 100%; display: block; overflow: visible; }
.mn-mat { position: relative; flex: 1; min-height: 0; overflow: hidden; border-radius: 14px; background: #E7F0FB; box-shadow: inset 0 0 0 1px rgba(47, 124, 246, .18); touch-action: none; }
.mn-item { position: absolute; transform: translate(-50%, -50%); cursor: grab; touch-action: none; filter: drop-shadow(0 3px 3px rgba(16, 24, 40, .25)); animation: pop-in .2s ease-out; }
.mn-item.is-dragging { cursor: grabbing; z-index: 3; filter: drop-shadow(0 10px 12px rgba(16, 24, 40, .3)); }
.mn-total { font-size: clamp(20px, min(9cqh, 6cqw), 60px); }

/* ---------- Protractor ---------- */
.pr-read { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; min-width: 0; }
.pr-kind { font-size: clamp(14px, min(5cqh, 3.4cqw), 30px); font-weight: 900; color: var(--accent); }
.pr-other { font-size: clamp(12px, min(3.4cqh, 2.4cqw), 20px); font-weight: 700; color: var(--muted); }
.pr-stage { position: relative; flex: 1; min-height: 0; border-radius: 14px; background: var(--surface-2); }
.pr-svg { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; user-select: none; font-family: var(--font); }
.pr-glass { fill: rgba(47, 124, 246, .1); stroke: rgba(47, 124, 246, .55); stroke-width: 2; cursor: grab; }
.pr-svg.is-dragging .pr-glass { cursor: grabbing; }
.pr-inner-ring { fill: none; stroke: rgba(47, 124, 246, .35); stroke-width: 1.5; pointer-events: none; }
.pr-tick { stroke: rgba(29, 34, 51, .55); stroke-width: 1.2; pointer-events: none; }
.pr-tick-10 { stroke: rgba(29, 34, 51, .85); stroke-width: 2; pointer-events: none; }
.pr-ray { stroke: rgba(47, 124, 246, .18); stroke-width: 1; pointer-events: none; }
.pr-num { font-size: 15px; font-weight: 800; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.pr-outer { fill: #1D2233; }
.pr-inner { fill: #C2389E; font-size: 13px; }
.pr-base { stroke: #1D2233; stroke-width: 2; pointer-events: none; }
.pr-centre { fill: #F04452; pointer-events: none; }
.pr-handle { fill: #fff; stroke: #2F7CF6; stroke-width: 3; cursor: grab; }
.pr-handle-arrow { fill: none; stroke: #2F7CF6; stroke-width: 2.2; stroke-linecap: round; pointer-events: none; }
.pr-arm { stroke: #1D2233; stroke-width: 5; stroke-linecap: round; pointer-events: none; }
.pr-arm2 { stroke: var(--accent); }
.pr-sector { fill: color-mix(in srgb, var(--accent) 22%, transparent); stroke: var(--accent); stroke-width: 2.5; pointer-events: none; }
.pr-arc { fill: none; stroke: var(--accent); stroke-width: 3; pointer-events: none; }
.pr-knob { fill: #fff; stroke: #1D2233; stroke-width: 4; cursor: grab; }
.pr-knob2 { stroke: var(--accent); }
.pr-vertex { fill: #1D2233; cursor: move; }
.pr-label { font-size: 30px; font-weight: 900; fill: var(--accent); text-anchor: middle; dominant-baseline: central; pointer-events: none; paint-order: stroke; stroke: #fff; stroke-width: 6px; }

/* ---------- Shapes ---------- */
.sh-ctl { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sh-stage { position: relative; flex: 1; min-height: 0; display: flex; gap: 12px; }
.sh-svg { flex: 1; min-width: 0; height: 100%; display: block; overflow: visible; }
.sh-svg.is-3d { cursor: grab; touch-action: none; }
.sh-turn { transition: transform .45s cubic-bezier(.3, 1.3, .5, 1); transform-origin: 0 0; }
.sh-fill { fill: color-mix(in srgb, var(--accent) 16%, white); stroke: var(--ink); stroke-linejoin: round; }
.sh-tick, .sh-right { fill: none; stroke: var(--coral); stroke-width: .035; stroke-linecap: round; }
.sh-dot { fill: var(--ink); }
.sh-axis { stroke: var(--accent); stroke-width: .03; stroke-dasharray: .12 .08; }
.sh-dim { stroke: var(--sky); stroke-width: .03; }
.sh-radius { stroke: var(--coral); }
.sh-edge { stroke: #1D2233; stroke-width: .03; stroke-linecap: round; }
.sh-edge-hidden { stroke: #1D2233; stroke-width: .022; stroke-dasharray: .07 .06; opacity: .55; }
.sh-facts {
  flex: none; width: clamp(160px, 30cqw, 360px); overflow: auto; align-self: center; padding: 14px 16px; border-radius: 14px;
  background: var(--surface-2); font-size: clamp(13px, 2.6cqmin, 22px);
}
.sh-name { font-size: 1.35em; font-weight: 900; line-height: 1.15; color: var(--ink); }
.sh-also { font-size: .82em; font-weight: 700; color: var(--muted); margin-top: .15em; }
.sh-row { display: flex; justify-content: space-between; gap: 12px; padding: .45em 0; border-top: 1px solid var(--line); font-weight: 700; color: var(--ink-2); }
.sh-row:first-of-type { margin-top: .5em; }
.sh-row b { color: var(--ink); text-align: right; font-weight: 900; }
@container (aspect-ratio < 1.1) { .sh-stage { flex-direction: column; } .sh-facts { width: 100%; align-self: stretch; } }
/* A counter or coin being dragged off the mat fades, to show it will be taken away. */
.ct-counter.is-leaving, .mn-item.is-leaving { opacity: .35; }

/* ---------- Hiding the drawer ---------- */
.dock-hide { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border: 0; border-radius: 10px; background: none; color: var(--muted); font-size: 18px; }
.dock-hide:hover { background: rgba(22, 32, 64, .07); color: var(--ink); }
.dock-wrap.is-collapsed { display: none; }
.dock.rise { animation: dock-rise .22s cubic-bezier(.2, 1.2, .4, 1); }
@keyframes dock-rise { from { opacity: 0; transform: translateY(14px); } }
.dock-reveal {
  position: fixed; left: 50%; bottom: 10px; z-index: 35; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px 0 10px;
  border: 1px solid var(--glass-line); border-radius: 999px; background: var(--glass); color: var(--ink-2);
  backdrop-filter: blur(20px) saturate(1.6); -webkit-backdrop-filter: blur(20px) saturate(1.6);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 10px 24px -10px rgba(16, 24, 40, .35);
  font-size: 13.5px; font-weight: 800; animation: pop-in .2s ease-out;
}
.dock-reveal .icon { font-size: 16px; }
.dock-reveal:hover { background: #fff; color: var(--ink); }
body.is-presenting .dock-reveal { display: none; }


/* ---------- Times Table Rocket ---------- */
.card-body.tool-ttgame { padding: 0; }
.tg-space {
  position: relative; flex: 1; min-height: 0; overflow: hidden; container-type: size; color: #fff;
  border-radius: 0 0 calc(var(--r-card) - 1px) calc(var(--r-card) - 1px);
  background:
    radial-gradient(ellipse 70% 55% at 85% 110%, rgba(196, 72, 255, .45), transparent 70%),
    radial-gradient(ellipse 60% 50% at 0% -10%, rgba(47, 124, 246, .55), transparent 70%),
    radial-gradient(ellipse 40% 35% at 70% 20%, rgba(20, 184, 166, .18), transparent 70%),
    linear-gradient(180deg, #0B1030 0%, #151041 60%, #1E0F45 100%);
}
.card.presenting .tg-space { border-radius: 0 0 var(--r-card) var(--r-card); }
/* Two layers of stars drifting down, faster while flying, so it feels like going up. */
.tg-stars { position: absolute; inset: -50% 0 0; pointer-events: none; background-repeat: repeat; animation: tg-drift 60s linear infinite; }
.tg-stars-far {
  opacity: .7; background-size: 220px 220px;
  background-image:
    radial-gradient(1px 1px at 20px 30px, #fff, transparent), radial-gradient(1px 1px at 90px 120px, #fff, transparent),
    radial-gradient(1.2px 1.2px at 160px 60px, #cfe0ff, transparent), radial-gradient(1px 1px at 200px 180px, #fff, transparent),
    radial-gradient(1px 1px at 60px 200px, #ffe9c4, transparent), radial-gradient(1px 1px at 130px 15px, #fff, transparent);
}
.tg-stars-near {
  background-size: 340px 340px; animation-duration: 30s;
  background-image:
    radial-gradient(1.8px 1.8px at 40px 80px, #fff, transparent), radial-gradient(2px 2px at 250px 40px, #fff, transparent),
    radial-gradient(1.6px 1.6px at 300px 260px, #d9e6ff, transparent), radial-gradient(2.2px 2.2px at 120px 300px, #fff, transparent),
    radial-gradient(1.5px 1.5px at 190px 170px, #ffeacc, transparent);
}
.tg-space.is-flying .tg-stars-far { animation-duration: 14s; }
.tg-space.is-flying .tg-stars-near { animation-duration: 6s; }
@keyframes tg-drift { from { transform: translateY(0); } to { transform: translateY(50%); } }
.tg-screen { position: relative; z-index: 1; height: 100%; display: flex; flex-direction: column; padding: 2.5cqmin 3cqmin; }

/* The rocket */
.tg-rocket { position: relative; aspect-ratio: 100 / 170; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .35)); }
.tg-rocket svg { width: 100%; height: 100%; display: block; overflow: visible; }
.tg-flame { transform-origin: 50px 106px; animation: tg-flicker .12s ease-in-out infinite alternate; }
@keyframes tg-flicker { from { transform: scaleY(.85) scaleX(.95); } to { transform: scaleY(1.08) scaleX(1.04); } }
.tg-eyes-happy, .tg-oh { display: none; }
.tg-rocket.is-happy .tg-eyes, .tg-rocket.is-happy-still .tg-eyes { display: none; }
.tg-rocket.is-happy .tg-eyes-happy, .tg-rocket.is-happy-still .tg-eyes-happy { display: inline; }
.tg-rocket.is-oops .tg-smile { display: none; }
.tg-rocket.is-oops .tg-oh { display: inline; }
.tg-rocket.is-happy svg { animation: tg-hop .5s cubic-bezier(.2, 1.6, .4, 1); }
.tg-rocket.is-happy .tg-flame { animation-duration: .06s; transform: scaleY(1.4); }
.tg-rocket.is-oops svg { animation: tg-wobble .45s ease-in-out; }
@keyframes tg-hop { 40% { transform: translateY(-14%) rotate(-4deg); } }
@keyframes tg-wobble { 25% { transform: rotate(-10deg); } 75% { transform: rotate(10deg); } }
.tg-rocket-hero { width: min(16cqh, 14cqw); animation: tg-bob 2.4s ease-in-out infinite; }
.tg-rocket-ready { width: min(22cqh, 18cqw); animation: tg-shake-up .12s linear infinite; }
.tg-rocket-end { width: min(16cqh, 14cqw); animation: tg-bob 2.4s ease-in-out infinite; }
.tg-rocket-landed { position: absolute; left: 50%; bottom: 62%; width: 46%; transform: translateX(-50%) rotate(8deg); }
@keyframes tg-bob { 50% { transform: translateY(-8%); } }
@keyframes tg-shake-up { 50% { transform: translate(1px, -1px); } }

/* Setup */
.tg-setup, .tg-end { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2.4cqmin; text-align: center; }
.tg-hero { display: flex; align-items: center; gap: 3cqw; }
.tg-hero > div { text-align: left; }
.tg-title {
  font-size: clamp(26px, min(10cqh, 7.5cqw), 80px); font-weight: 900; line-height: 1; letter-spacing: -.02em;
  background: linear-gradient(100deg, #FFE48A, #FFFFFF 40%, #9FD1FF 70%, #E3A6FF); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 18px rgba(130, 160, 255, .45));
}
.tg-tagline { margin-top: .35em; font-size: clamp(13px, min(3.6cqh, 2.6cqw), 26px); font-weight: 800; color: #C9D4FF; }
.tg-panel { display: flex; flex-direction: column; align-items: center; gap: 1.6cqmin; padding: 2.2cqmin 3cqmin; border-radius: 22px; background: rgba(255, 255, 255, .07); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); backdrop-filter: blur(6px); }
.tg-label { font-size: clamp(13px, 3cqmin, 24px); font-weight: 900; color: #C9D4FF; text-transform: uppercase; letter-spacing: .08em; }
.tg-tables { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 90cqw; }
.tg-chip {
  min-width: 2.9em; padding: .5em .6em; border: 0; border-radius: .8em; cursor: pointer; font-size: var(--ctl); font-weight: 900;
  background: rgba(255, 255, 255, .1); color: #E3E9FF; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .18); transition: transform .12s;
}
.tg-chip:hover { transform: translateY(-2px); background: rgba(255, 255, 255, .16); }
.tg-chip[aria-pressed="true"] { background: linear-gradient(160deg, #FFD36B, #FF9F1C); color: #3A2200; box-shadow: 0 0 0 2px rgba(255, 211, 107, .35), 0 6px 16px -6px rgba(255, 170, 40, .8); }
.tg-chip-all { background: rgba(255, 255, 255, .04); }
.tg-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; font-size: var(--ctl); }
.tg-space .seg { background: rgba(255, 255, 255, .1); }
.tg-space .seg button { color: #C9D4FF; }
.tg-space .seg button[aria-pressed="true"] { background: #fff; color: #1D2233; }
.tg-go {
  display: inline-flex; align-items: center; gap: .45em; padding: .6em 1.6em; border: 0; border-radius: 999px; cursor: pointer;
  font-size: clamp(17px, min(5.4cqh, 4cqw), 40px); font-weight: 900; color: #fff;
  background: linear-gradient(160deg, #FF7A59, #F04452 55%, #C2389E);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .3), 0 0 0 4px rgba(255, 122, 89, .2), 0 12px 30px -8px rgba(240, 68, 82, .9);
  transition: transform .12s, filter .12s;
}
.tg-go:hover { transform: translateY(-2px) scale(1.03); filter: brightness(1.08); }
.tg-go .icon { font-size: 1em; }
.tg-best { font-size: clamp(12px, 3cqmin, 24px); font-weight: 800; color: #C9D4FF; }
.tg-best.is-new { color: #7CF3C3; font-size: clamp(16px, 4.6cqmin, 38px); font-weight: 900; animation: pop .5s cubic-bezier(.2, 1.7, .4, 1); }

/* Countdown */
.tg-countdown { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2cqh; }
.tg-count { font-size: clamp(60px, 28cqmin, 240px); font-weight: 900; line-height: 1; color: #FFE48A; text-shadow: 0 0 40px rgba(255, 210, 100, .6); }
.tg-count.tg-pulse { animation: pop .45s cubic-bezier(.2, 1.7, .4, 1); }

/* Playing */
.tg-play { flex: 1; min-height: 0; display: grid; grid-template-columns: clamp(64px, 13cqw, 150px) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); gap: 1.5cqmin 2cqw; }
.tg-hud { display: flex; align-items: center; gap: 2.5cqw; }
.tg-score-wrap { display: flex; align-items: baseline; gap: .4em; }
.tg-score-label { font-size: clamp(11px, 2.6cqmin, 20px); font-weight: 900; color: #9FB2E8; text-transform: uppercase; letter-spacing: .1em; }
.tg-score { font-size: clamp(26px, 9cqmin, 76px); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; color: #FFE48A; text-shadow: 0 0 22px rgba(255, 210, 100, .45); }
.tg-score.tg-bump { animation: pop .3s cubic-bezier(.2, 1.7, .4, 1); }
.tg-time { flex: 1; height: clamp(10px, 2.4cqmin, 20px); border-radius: 999px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.tg-time-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #22D39A, #7CF3C3); box-shadow: 0 0 14px rgba(34, 211, 154, .6); }
.tg-time-fill.is-low { background: linear-gradient(90deg, #FF5A6E, #FF9AA8); box-shadow: 0 0 14px rgba(255, 90, 110, .7); }
.tg-secs { min-width: 3.2em; text-align: right; font-size: clamp(14px, 4cqmin, 32px); font-weight: 900; color: #E3E9FF; font-variant-numeric: tabular-nums; }

/* The climb to the Moon, down the left */
.tg-track { grid-row: 1 / 3; display: flex; flex-direction: column; align-items: center; min-height: 0; }
.tg-moon {
  position: relative; flex: none; width: 74%; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FFFBEA, #E6DEC4 55%, #B9AE90);
  box-shadow: 0 0 0 6px rgba(255, 244, 200, .08), 0 0 34px rgba(255, 240, 190, .55);
}
.tg-moon::before, .tg-moon::after { content: ""; position: absolute; border-radius: 50%; background: rgba(150, 135, 100, .35); }
.tg-moon::before { width: 22%; height: 22%; left: 22%; top: 48%; }
.tg-moon::after { width: 14%; height: 14%; left: 58%; top: 26%; }
.tg-moon-label {
  position: absolute; left: 50%; top: 100%; transform: translate(-50%, 6px); white-space: nowrap; z-index: 2;
  padding: .15em .6em; border-radius: 999px; background: rgba(255, 255, 255, .14); font-size: clamp(11px, 2.4cqmin, 18px); font-weight: 900; color: #FFF4C8;
}
.tg-tube { position: relative; flex: 1; width: 34%; margin: 3.4em 0 2cqmin; border-radius: 999px; background: rgba(255, 255, 255, .08); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .12); }
.tg-fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 0; border-radius: 999px;
  background: linear-gradient(0deg, #2F7CF6, #8B5CF6 50%, #F45DA8 80%, #FFD36B);
  box-shadow: 0 0 22px rgba(139, 92, 246, .7); transition: height .45s cubic-bezier(.2, 1.2, .4, 1);
}
.tg-flyer-lane { position: absolute; left: 50%; bottom: 0; width: 240%; transform: translate(-50%, 42%); transition: bottom .45s cubic-bezier(.2, 1.2, .4, 1); z-index: 3; }
.tg-rocket-flyer { width: 100%; }

/* The question planet and the ring of answers */
.tg-stage { min-height: 0; display: grid; place-items: center; container-type: size; }
.tg-ring { position: relative; width: min(100cqh, 100cqw); height: min(100cqh, 100cqw); }
.tg-planet {
  position: absolute; left: 28%; top: 28%; width: 44%; height: 44%; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 32% 28%, #9FD1FF 0%, #5B6CFF 40%, #3B1C8C 100%);
  box-shadow: inset -10px -14px 30px rgba(20, 0, 60, .55), inset 6px 8px 18px rgba(255, 255, 255, .25), 0 0 50px rgba(110, 120, 255, .55);
}
.tg-planet::after {
  content: ""; position: absolute; left: -16%; right: -16%; top: 42%; height: 18%; border-radius: 50%;
  border: 3px solid rgba(255, 228, 138, .55); border-top-color: transparent; transform: rotate(-14deg); pointer-events: none;
}
.tg-question { position: relative; z-index: 1; font-size: min(8.4cqh, 8.4cqw); font-weight: 900; color: #fff; white-space: nowrap; letter-spacing: -.01em; text-shadow: 0 3px 12px rgba(20, 0, 60, .6); }
.tg-question.tg-pop { animation: tg-qin .32s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes tg-qin { from { opacity: 0; transform: scale(.6); } }
.tg-ans {
  position: absolute; left: var(--x); top: var(--y); width: 16.5%; height: 16.5%; margin: -8.25% 0 0 -8.25%;
  border: 0; border-radius: 50%; padding: 0; cursor: pointer; touch-action: manipulation;
  background: radial-gradient(circle at 35% 28%, #FFFFFF, #E4EAFF 70%, #C7D2FF);
  color: #1D2233; font-size: min(5.4cqh, 5.4cqw); font-weight: 900; font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, .1), 0 0 22px rgba(140, 170, 255, .45), 0 6px 0 rgba(60, 70, 140, .55);
  transition: transform .12s, background .15s, box-shadow .15s;
  animation: tg-in .3s ease-out backwards; animation-delay: calc(var(--i) * 15ms);
}
@keyframes tg-in { from { opacity: 0; transform: scale(.5); } }
.tg-ans:hover { transform: translateY(-3px) scale(1.06); box-shadow: 0 0 0 5px rgba(255, 255, 255, .18), 0 0 30px rgba(160, 190, 255, .75), 0 7px 0 rgba(60, 70, 140, .55); }
.tg-ans:active { transform: scale(.94); }
.tg-ans.is-right { background: radial-gradient(circle at 35% 28%, #B7FFE2, #22D39A 70%); color: #053B2A; box-shadow: 0 0 0 6px rgba(34, 211, 154, .3), 0 0 34px rgba(34, 211, 154, .9); transform: scale(1.1); }
.tg-ans.is-wrong { background: radial-gradient(circle at 35% 28%, #FFD5DB, #FF5A6E 75%); color: #4A0010; animation: tg-shake .35s ease-in-out; }
@keyframes tg-shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
.tg-float { position: absolute; z-index: 4; transform: translate(-50%, -50%); pointer-events: none; font-size: min(5cqh, 5cqw); font-weight: 900; color: #7CF3C3; text-shadow: 0 0 12px rgba(34, 211, 154, .8); animation: tg-float .8s ease-out forwards; }
@keyframes tg-float { to { transform: translate(-50%, -190%); opacity: 0; } }
.tg-streak {
  position: absolute; left: 50%; top: 77%; z-index: 4; transform: translateX(-50%); white-space: nowrap; pointer-events: none; opacity: 0;
  padding: .2em .8em; border-radius: 999px; background: linear-gradient(90deg, #FF9F1C, #F45DA8); color: #fff;
  font-size: min(4.2cqh, 4.2cqw); font-weight: 900; box-shadow: 0 6px 20px -6px rgba(244, 93, 168, .9);
}
.tg-streak.is-on { animation: tg-streak 1.5s ease-out; }
@keyframes tg-streak { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.7); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.08); } 25% { transform: translate(-50%, 0) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -12px); } }

/* The end */
.tg-end-hero { position: relative; flex: none; width: min(20cqh, 22cqw); margin-top: 7cqh; display: grid; place-items: center; }
.tg-moon-big { width: 100%; }
.tg-end-hero .tg-rocket-end { position: absolute; right: -40%; bottom: -10%; }
.tg-headline { font-size: clamp(20px, min(6cqh, 5cqw), 48px); font-weight: 900; color: #FFE48A; text-shadow: 0 0 26px rgba(255, 210, 100, .5); }
.tg-final { display: flex; align-items: baseline; gap: .4em; }
.tg-final span { font-size: clamp(48px, min(15cqh, 14cqw), 140px); font-weight: 900; line-height: 1; color: #fff; text-shadow: 0 0 34px rgba(160, 190, 255, .7); }
.tg-final small { font-size: clamp(14px, 3.6cqmin, 28px); font-weight: 900; color: #C9D4FF; }
.tg-sub { font-size: clamp(12px, 3cqmin, 24px); font-weight: 800; color: #C9D4FF; }
.tg-tricky { max-width: 90%; padding: .5em 1em; border-radius: .9em; background: rgba(255, 255, 255, .08); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14); font-size: clamp(12px, 3cqmin, 24px); font-weight: 700; color: #E3E9FF; }
.tg-tricky b { color: #FFD36B; }
.tg-end-buttons { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; }
.tg-ghost { padding: .7em 1.3em; border: 0; border-radius: 999px; cursor: pointer; font-size: clamp(14px, 3.4cqmin, 26px); font-weight: 900; color: #E3E9FF; background: rgba(255, 255, 255, .1); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .2); }
.tg-ghost:hover { background: rgba(255, 255, 255, .18); }
@container (max-height: 420px) { .tg-hero .tg-rocket-hero { display: none; } .tg-end-hero { display: none; } }
.tg-end { gap: 1.6cqh; }
.tg-end .tg-go, .tg-end .tg-ghost { font-size: clamp(15px, min(4.2cqh, 3.4cqw), 32px); }
.tg-end .tg-best.is-new { font-size: clamp(16px, min(4.2cqh, 4cqw), 34px); }

/* ---------- Arithmetic ---------- */
/* A sheet of questions numbered down each column, sized so the whole sheet fits the card where it can. */
.ar-top { flex-wrap: wrap; justify-content: flex-start; gap: 8px 10px; }
.ar-label { font-weight: 800; color: var(--muted); }
.ar-count { display: inline-flex; align-items: center; gap: .35em; }
.ar-count b { min-width: 1.6em; text-align: center; font-weight: 900; font-variant-numeric: tabular-nums; }
.ar-step { display: grid; place-items: center; padding: .38em .45em; }
.ar-types-btn { padding: .38em .8em; }
@container (max-width: 520px) { .ar-top .ar-label { display: none; } }
@container (max-width: 640px) { .ar-print-main span:not(.icon) { display: none; } }

.ar-sheet {
  --cols: 2; --rows: 10;
  flex: 1; min-height: 0; overflow: auto; padding: 2px 4px;
  display: grid; grid-auto-flow: column; align-content: start; column-gap: 1.4em;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); grid-template-rows: repeat(var(--rows), auto);
  font-size: clamp(14px, min(calc(4.4cqw / var(--cols)), calc(33cqh / var(--rows))), 40px);
}
.ar-row { display: flex; align-items: center; gap: .55em; min-width: 0; min-height: 2.25em; padding: .15em .2em; border-bottom: 1px solid var(--line); }
.ar-n { flex: none; width: 1.6em; text-align: right; font-weight: 900; font-variant-numeric: tabular-nums; color: color-mix(in srgb, var(--accent) 80%, black); }
.ar-q { flex: 1; min-width: 0; white-space: nowrap; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); overflow-x: auto; overflow-y: hidden; padding: .2em 0; }
.ar-q sup, .ar-ex sup { font-size: .62em; }
.ar-in {
  width: 4.6em; padding: .1em .3em; margin: 0 .15em; border: 0; border-radius: .4em; vertical-align: middle;
  font: inherit; font-weight: 800; text-align: center; color: var(--ink);
  background: color-mix(in srgb, var(--accent) 5%, white);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 35%, transparent);
}
.ar-in:focus { outline: none; background: #fff; box-shadow: inset 0 0 0 2px var(--accent), 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.ar-frac .ar-in { width: 2.3em; margin: .1em 0; padding: 0 .1em; }
.ar-frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; font-size: .78em; line-height: 1.2; margin: 0 .12em; }
.ar-frac > span:first-child { border-bottom: .09em solid currentColor; padding: 0 .2em; }
.ar-mixed { display: inline-flex; align-items: center; gap: .08em; vertical-align: middle; }
.ar-ans { display: none; flex: none; padding: .05em .5em; border-radius: .5em; font-weight: 900; white-space: nowrap; font-variant-numeric: tabular-nums;
  color: color-mix(in srgb, var(--grass) 75%, black); background: color-mix(in srgb, var(--grass) 12%, white); }
.ar-sheet.show-answers .ar-ans { display: inline-block; }
.ar-mark { flex: none; display: grid; place-items: center; width: 1.45em; height: 1.45em; border-radius: 50%; font-size: .9em; font-weight: 900; box-shadow: inset 0 0 0 .1em var(--surface-3); }
.ar-row.is-ok .ar-mark { background: var(--grass); color: #fff; box-shadow: none; }
.ar-row.is-no .ar-mark { background: var(--coral); color: #fff; box-shadow: none; }
.ar-row.is-ok .ar-in { box-shadow: inset 0 0 0 2px var(--grass); background: color-mix(in srgb, var(--grass) 8%, white); }
.ar-row.is-no .ar-in { box-shadow: inset 0 0 0 2px var(--coral); background: color-mix(in srgb, var(--coral) 7%, white); }
.ar-empty { grid-row: 1 / -1; grid-column: 1 / -1; align-self: center; text-align: center; padding: 2em 1em; color: var(--muted); font-weight: 800; }

.ar-bottom { justify-content: flex-start; font-size: var(--ctl); }
.ar-timer { font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.ar-score { padding: .25em .7em; border-radius: .6em; font-weight: 900; font-variant-numeric: tabular-nums; color: var(--ink); background: var(--surface-3); }
.ar-print { position: relative; display: inline-flex; }
.ar-print-main { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.ar-print-more { padding-left: .45em; padding-right: .45em; border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: 1px; }
.ar-print-frame { position: fixed; right: 0; bottom: 0; width: 0; height: 0; border: 0; }
.ar-printmenu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 6; display: flex; flex-direction: column; min-width: 13em; padding: 5px; font-size: 14px;
  background: #fff; border-radius: 12px; box-shadow: 0 0 0 1px var(--line), 0 14px 32px -8px rgba(16, 24, 40, .3);
}
.ar-printmenu[hidden] { display: none; }
.ar-printmenu.to-right { right: auto; left: 0; }
.ar-printmenu button { display: flex; align-items: center; gap: .55em; border: 0; background: none; text-align: left; padding: .55em .8em; border-radius: 8px; font-weight: 800; color: var(--ink-2); white-space: nowrap; }
.ar-printmenu button:hover { background: var(--surface-2); color: var(--ink); }

/* The list of question types */
.ar-panel { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 16px; background: var(--surface); font-size: 14px; }
.ar-panel-head { display: flex; align-items: center; gap: 10px; }
.ar-panel-head h3 { margin: 0; font-size: 17px; font-weight: 900; }
.ar-panel-count { font-weight: 800; color: var(--muted); }
.ar-panel-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.ar-panel-note { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); line-height: 1.45; }
.ar-panel-list { flex: 1; min-height: 0; overflow: auto; padding-right: 4px; }
.ar-year { padding: 6px 0 10px; border-top: 1px solid var(--line); }
.ar-year-head { display: flex; align-items: center; gap: 6px; margin: 4px 0 4px; }
.ar-year-head h4 { margin: 0 6px 0 0; font-size: 15px; font-weight: 900; color: var(--ink-2); }
.ar-year.is-current .ar-year-head h4 { color: color-mix(in srgb, var(--accent) 80%, black); }
.ar-year-head .chip { font-size: 12.5px; padding: .25em .6em; }
.ar-type { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 4px 10px; padding: 5px 6px; border-radius: 8px; cursor: pointer; }
.ar-type:hover { background: var(--surface-2); }
.ar-type input { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; }
.ar-type-name { font-weight: 700; color: var(--ink); }
.ar-ex { white-space: nowrap; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.ar-box { display: inline-block; width: 2em; height: 1.1em; vertical-align: middle; border-radius: .25em; box-shadow: inset 0 0 0 1.5px var(--faint); }
.ar-frac .ar-box { width: 1.3em; height: .9em; margin: .1em 0; }
@container (max-width: 520px) { .ar-type { grid-template-columns: auto minmax(0, 1fr); } .ar-ex { grid-column: 2; } }
/* Slimmer controls than other tools: the questions are what matter here. */
.card-body.tool-arithmetic { --ctl: clamp(12px, 1.7cqmin, 15px); gap: 8px; }
.tool-arithmetic .btn { padding: .4em .8em; border-radius: .6em; }
.tool-arithmetic .chip { padding: .3em .65em; }
.tool-arithmetic .seg { padding: 2px; }
.tool-arithmetic .seg button { padding: .25em .65em; }
.tool-arithmetic .ar-step { padding: .3em .35em; }
.tool-arithmetic .ar-print-more { padding-left: .4em; padding-right: .4em; }
/* Picking questions by their numbers */
button.ar-n {
  flex: none; min-width: 1.75em; width: auto; padding: .08em .3em; border: 0; border-radius: .45em; text-align: center;
  font: inherit; font-weight: 900; color: color-mix(in srgb, var(--accent) 80%, black); cursor: pointer;
  background: color-mix(in srgb, var(--accent) 8%, white); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 22%, transparent);
}
button.ar-n:hover { background: color-mix(in srgb, var(--sun) 30%, white); box-shadow: inset 0 0 0 1.5px var(--sun); }
.ar-row.is-picked { background: color-mix(in srgb, var(--sun) 16%, white); border-radius: .5em; }
.ar-row.is-picked button.ar-n { background: var(--sun); color: var(--sun-ink); box-shadow: none; }
.ar-picknote { display: inline-flex; align-items: center; gap: .5em; font-weight: 800; color: var(--ink-2); }
.ar-picknote[hidden] { display: none; }
.ar-picknote.is-tip { font-weight: 700; color: var(--muted); }
.ar-picknote b { color: var(--ink); }
.ar-n-eg { display: inline-block; padding: 0 .35em; border-radius: .4em; font-weight: 900; color: color-mix(in srgb, var(--accent) 80%, black);
  background: color-mix(in srgb, var(--accent) 8%, white); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 22%, transparent); }
@container (max-width: 900px) { .ar-picknote.is-tip { display: none; } }
@container (max-width: 640px) { .ar-reset span:not(.icon) { display: none; } }
/* Timer: count up or count down like a test */
.ar-timerwrap { position: relative; display: inline-flex; align-items: center; gap: 6px; }
.tool-arithmetic .ar-timer { display: inline-flex; align-items: center; gap: .4em; font-weight: 900; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.ar-timer .icon { color: var(--muted); }
.ar-timer.is-running { color: var(--ink); }
.ar-timer.is-warn { background: color-mix(in srgb, var(--sun) 22%, white); box-shadow: inset 0 0 0 1.5px var(--sun); color: var(--sun-ink); }
.ar-timer.is-danger { background: color-mix(in srgb, var(--coral) 14%, white); box-shadow: inset 0 0 0 1.5px var(--coral); color: #B4202F; }
.ar-timer.is-danger.is-running { animation: ar-pulse 1s ease-in-out infinite; }
@keyframes ar-pulse { 50% { box-shadow: inset 0 0 0 1.5px var(--coral), 0 0 0 4px color-mix(in srgb, var(--coral) 25%, transparent); } }
.ar-start[hidden] { display: none; }
.ar-sheet.is-locked .ar-in { background: var(--surface-2); color: var(--ink-2); cursor: not-allowed; }
.ar-timermenu {
  position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 6; width: 21em; padding: 12px; display: flex; flex-direction: column; gap: 10px;
  background: #fff; border-radius: 12px; box-shadow: 0 0 0 1px var(--line), 0 14px 32px -8px rgba(16, 24, 40, .3); font-size: 14px;
}
.ar-timermenu[hidden] { display: none; }
.ar-tm-head { font-weight: 900; font-size: 15px; }
.ar-tm-note { font-size: 13px; font-weight: 600; color: var(--muted); line-height: 1.45; }
.ar-tm-mins { display: flex; flex-wrap: wrap; gap: 6px; }
.ar-tm-mins .chip { font-size: 13px; }
.tool-arithmetic .ar-tm-ks2 { white-space: normal; text-align: left; font-size: 13.5px; padding: .6em .8em; }
/* Real KS2 papers */
.ar-papers { position: relative; }
.ar-papersmenu {
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 6; width: 22em; padding: 12px; display: flex; flex-direction: column; gap: 8px;
  background: #fff; border-radius: 12px; box-shadow: 0 0 0 1px var(--line), 0 14px 32px -8px rgba(16, 24, 40, .3); font-size: 14px;
}
.ar-papersmenu[hidden] { display: none; }
.ar-paper-pick { display: flex; align-items: center; gap: .55em; border: 0; border-radius: 9px; padding: .55em .8em; text-align: left; font-weight: 800; color: var(--ink); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.ar-paper-pick:hover { background: color-mix(in srgb, var(--accent) 10%, white); }
.ar-paper-on .ar-count, .ar-paper-on .ar-types-btn { display: none; }
.ar-paper-on .ar-papers-btn { background: color-mix(in srgb, var(--accent) 13%, white); color: color-mix(in srgb, var(--accent) 78%, black); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 40%, transparent); }
.ar-paper-on button.ar-n { cursor: default; }
.ar-paper-on button.ar-n:hover { background: color-mix(in srgb, var(--accent) 8%, white); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 22%, transparent); }
.ar-marks { flex: none; font-size: .62em; font-weight: 800; color: var(--muted); white-space: nowrap; }
.ar-credit { flex: none; font-size: 11.5px; font-weight: 600; line-height: 1.4; color: var(--muted); }
.ar-credit[hidden] { display: none; }
.ar-credit a { color: inherit; }

/* ---------- The main navigation in the board's and tools' top bars ---------- */
.topbar > .th-nav { margin-right: auto; flex: none; }
.topbar > .brand + .th-nav { margin-left: 4px; }
.tool-title { flex: 1; }

/* =====================================================================
   The dashboard, October 2026 redesign
   Widgets without title bars (a floating bar appears on hover or when selected), a tray of big labelled
   tools, and backgrounds chosen from the tray. These rules come last, so they win over older ones above.
   ===================================================================== */

/* ---------- Top bar: light on every background ---------- */
.topbar { background: rgba(255, 255, 255, .9); border-color: rgba(255, 255, 255, .9); color: var(--ink);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 10px 30px -14px rgba(16, 24, 40, .35); border-radius: 18px; }

/* ---------- Widgets ---------- */
.widget { overflow: visible; border-radius: 22px; box-shadow: 0 1px 2px rgba(16, 24, 40, .07), 0 16px 36px -12px rgba(16, 24, 40, .32); }
.widget > .card-body { border-radius: inherit; overflow: hidden; background: var(--surface); padding-top: 16px; }
.widget.is-selected { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 65%, white), 0 20px 44px -14px rgba(16, 24, 40, .4); }
.widget.dragging { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 65%, white), var(--shadow-lift); }
.widget .tg-space { border-radius: inherit; }
.widget .rz-se::after { opacity: 0; transition: opacity .15s; }
.widget:hover .rz-se::after, .widget.is-selected .rz-se::after { opacity: 1; border-color: color-mix(in srgb, var(--accent) 55%, white); }

/* The bar above a widget: move handle, name, full screen, remove. */
.wbar {
  position: absolute; left: 0; right: 0; bottom: 100%; z-index: 6; display: flex; justify-content: center; padding-bottom: 8px;
  opacity: 0; pointer-events: none; transform: translateY(4px); transition: opacity .15s, transform .15s;
}
.widget:hover .wbar, .widget.is-selected .wbar, .widget:focus-within .wbar { opacity: 1; pointer-events: auto; transform: none; }
.widget.bar-below .wbar { bottom: auto; top: 100%; padding: 8px 0 0; transform: translateY(-4px); }
.widget.bar-below:hover .wbar, .widget.bar-below.is-selected .wbar { transform: none; }
.wbar-inner {
  display: flex; align-items: center; gap: 2px; padding: 4px; border-radius: 14px; background: #fff; max-width: 100%;
  box-shadow: 0 0 0 1px rgba(22, 32, 64, .08), 0 10px 24px -8px rgba(16, 24, 40, .35);
}
.wbar-grip, .wbar-btn {
  display: grid; place-items: center; flex: none; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 10px;
  background: none; color: var(--ink-2); font-size: 17px;
}
.wbar-grip { cursor: grab; touch-action: none; color: var(--muted); }
.wbar-grip:hover, .wbar-btn:hover { background: var(--surface-2); color: var(--ink); }
.wbar .del-btn:hover { background: #FFE4E7; color: #C42638; }
.wbar-name {
  display: flex; align-items: center; gap: 8px; min-width: 0; padding: 0 10px 0 2px; cursor: grab; touch-action: none; user-select: none;
  font-weight: 800; font-size: 13.5px; color: var(--ink); white-space: nowrap;
}
.wbar-name > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.wbar-chip {
  display: grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 8px; font-size: 14px; color: var(--on-accent);
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 70%, white), var(--accent));
}
.wbar-sep { flex: none; width: 1px; height: 20px; margin: 0 3px; background: rgba(22, 32, 64, .1); }
.widget.dragging .wbar-grip, .widget.dragging .wbar-name { cursor: grabbing; }
/* Full screen: just the button to come back, in the corner. */
.widget.presenting { box-shadow: var(--shadow-card); }
.widget.presenting .wbar { top: 14px; right: 14px; bottom: auto; left: auto; padding: 0; opacity: 1; pointer-events: auto; transform: none; }
.widget.presenting .wbar-grip, .widget.presenting .wbar-name, .widget.presenting .wbar-sep, .widget.presenting .del-btn { display: none; }
.widget.presenting > .card-body { padding-top: 28px; }

/* ---------- The tray ---------- */
.tray-wrap { flex: none; position: relative; z-index: 30; display: flex; justify-content: center; padding: 8px 12px 12px; }
.tray-wrap.is-collapsed { display: none; }
.tray {
  display: flex; flex-direction: column; gap: 6px; max-width: 100%; padding: 8px 10px 8px; border-radius: 24px;
  background: rgba(255, 255, 255, .95); box-shadow: 0 0 0 1px rgba(22, 32, 64, .06), 0 20px 46px -16px rgba(16, 24, 40, .45);
  backdrop-filter: blur(18px) saturate(1.5); -webkit-backdrop-filter: blur(18px) saturate(1.5);
}
.tray.rise { animation: dock-rise .22s cubic-bezier(.2, 1.2, .4, 1); }
.tray-top { display: flex; align-items: center; gap: 6px; }
.tray-tabs { display: flex; gap: 2px; padding: 3px; border-radius: 13px; background: #F1F3F8; overflow-x: auto; }
.tray-tab {
  position: relative; display: flex; align-items: center; gap: 6px; flex: none; height: 32px; padding: 0 13px; border: 0; border-radius: 10px;
  background: none; font-weight: 800; font-size: 13.5px; color: var(--ink-2);
}
.tray-tab .icon { font-size: 16px; color: var(--muted); }
.tray-tab:hover { background: rgba(255, 255, 255, .75); }
.tray-tab[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(16, 24, 40, .14); }
.tray-tab[aria-selected="true"] .icon { color: var(--sky); }
.tray-tab.on::after { content: ""; position: absolute; top: 5px; right: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--grass); }
.tray-space { flex: 1; min-width: 12px; }
.tray-btn {
  display: inline-flex; align-items: center; gap: 7px; flex: none; height: 36px; padding: 0 13px; border: 0; border-radius: 11px;
  background: none; font-weight: 800; font-size: 13.5px; color: var(--ink-2);
}
.tray-btn .icon { font-size: 18px; }
.tray-btn:hover, .tray-btn[aria-expanded="true"] { background: #F1F3F8; color: var(--ink); }
.tray-hide { padding: 0 9px; color: var(--muted); }
.tray-apps { display: flex; justify-content: center; gap: 2px; padding-top: 3px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
@media (min-width: 1000px) { .tray-apps { min-width: calc(var(--most, 8) * 86px); } }
.tray-app {
  position: relative; flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 86px;
  padding: 8px 4px 6px; border: 0; border-radius: 16px; background: none;
}
.tray-app:hover { background: #F5F6FA; }
.tray-app:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: -3px; }
.tray-tile {
  display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; font-size: 27px; color: var(--on-accent);
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 64%, white) 0%, var(--accent) 55%, color-mix(in srgb, var(--accent) 86%, black) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 8px 16px -8px color-mix(in srgb, var(--accent) 80%, transparent);
  transition: transform .15s cubic-bezier(.2, 1.4, .4, 1);
}
.tray-app:hover .tray-tile { transform: translateY(-3px) scale(1.06); }
.tray-app:active .tray-tile { transform: scale(.94); }
.tray-name {
  max-width: 100%; font-size: 12.5px; font-weight: 800; line-height: 1.15; color: var(--ink-2); text-align: center;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tray-app.on::after { content: ""; position: absolute; top: 6px; right: 15px; width: 10px; height: 10px; border-radius: 50%; background: var(--grass); box-shadow: 0 0 0 2.5px #fff; }
.tray-apps.swap .tray-app { animation: dock-swap .22s ease-out backwards; }
.tray-apps.swap .tray-app:nth-child(2) { animation-delay: .02s; }
.tray-apps.swap .tray-app:nth-child(3) { animation-delay: .04s; }
.tray-apps.swap .tray-app:nth-child(4) { animation-delay: .06s; }
.tray-apps.swap .tray-app:nth-child(5) { animation-delay: .08s; }
.tray-apps.swap .tray-app:nth-child(n+6) { animation-delay: .1s; }
.dock-reveal { color: var(--ink); background: rgba(255, 255, 255, .92); }
@media (max-width: 900px) { .tray-tab span:not(.icon) { display: none; } .tray-tab { padding: 0 11px; } }
@media (max-width: 700px) {
  .tray-wrap { padding: 6px 8px 8px; }
  .tray { width: 100%; border-radius: 20px; }
  .tray-btn span:not(.icon) { display: none; }
  .tray-tabs { flex: 1 1 auto; min-width: 0; }
  .tray-space { display: none; }
  .tray-apps { justify-content: flex-start; }
  .tray-app { width: 72px; }
  .tray-tile { width: 44px; height: 44px; border-radius: 14px; font-size: 23px; }
  .tray-name { font-size: 11px; }
}

/* ---------- Backgrounds ---------- */
.wall-panel {
  position: absolute; left: 50%; bottom: calc(100% - 2px); z-index: 40; transform: translateX(-50%);
  display: flex; flex-direction: column; width: min(780px, calc(100vw - 24px)); max-height: min(70vh, 640px);
  border-radius: 22px; background: #fff; box-shadow: 0 0 0 1px rgba(22, 32, 64, .07), 0 26px 60px -18px rgba(16, 24, 40, .5);
  animation: wall-in .2s ease-out;
}
.wall-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 4px 22px; }
.wall-head h3 { margin: 0; font-size: 19px; font-weight: 900; }
.wall-scroll { overflow: auto; padding: 0 22px 20px; }
.wall-scroll h4 { margin: 14px 0 8px; font-size: 12px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.wall-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 12px; }
.wall-swatch { display: flex; flex-direction: column; gap: 6px; padding: 0; border: 0; background: none; text-align: left; }
.wall-thumb {
  display: grid; place-items: center; aspect-ratio: 16 / 10; border-radius: 12px; overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(22, 32, 64, .1); transition: transform .12s;
}
.wall-swatch:hover .wall-thumb { transform: translateY(-2px); }
.wall-swatch[aria-pressed="true"] .wall-thumb { box-shadow: 0 0 0 3px #fff, 0 0 0 5.5px var(--sky); }
.wall-name { font-size: 13px; font-weight: 800; color: var(--ink-2); }
.wall-add .wall-thumb { background: var(--surface-2); color: var(--muted); font-size: 28px; box-shadow: inset 0 0 0 2px rgba(22, 32, 64, .14); }
.wall-small, .wall-note { margin: 12px 0 0; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.wall-note { color: var(--ink-2); }
.wall-note:empty { display: none; }
@keyframes wall-in { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---------- The logo hides and shows the top bar (app.js) ---------- */
.brand-toggle { border: 0; background: none; padding: 4px 8px 4px 4px; margin: -4px 0 -4px -4px; text-align: left; font: inherit; cursor: pointer; border-radius: 12px; }
.brand-toggle:hover { background: rgba(22, 32, 64, .05); }
.brand-toggle .brand-mark { transition: transform .2s; }
.brand-toggle:hover .brand-mark { transform: scale(1.06); }
/* Hidden: just the logo, floating in the top left corner over the board, which takes the space. */
body.topbar-min .topbar {
  position: absolute; top: 0; left: 0; z-index: 40; min-height: 0; padding: 5px; margin: 10px 0 0 12px;
  border-radius: 16px; animation: tb-shrink .2s ease-out;
}
body.topbar-min .topbar > :not(.brand) { display: none; }
body.topbar-min .brand-text { display: none; }
body.topbar-min .brand-toggle { margin: 0; padding: 4px; }
body.topbar-min .brand-mark { width: 32px; height: 32px; }
body.topbar-min .board { margin-top: 10px; }
@keyframes tb-shrink { from { opacity: .4; transform: scale(.96); } }
/* No room above or below a tall widget: the bar sits just inside its top edge. */
.widget.bar-inside .wbar { bottom: auto; top: 10px; padding: 0; transform: translateY(-4px); }
.widget.bar-inside:hover .wbar, .widget.bar-inside.is-selected .wbar { transform: none; }
/* Picked up with a double press: the whole widget shows it's being moved. */
.widget.double-drag { cursor: grabbing; }
.widget.double-drag > .card-body { pointer-events: none; }
/* After a double-click: ready to move, so the next press anywhere on the widget drags it. */
.widget.ready-to-move { cursor: grab; }
.widget.ready-to-move > .card-body { pointer-events: none; }
.widget.ready-to-move::after {
  content: 'Drag to move'; position: absolute; left: 50%; top: 50%; z-index: 7; transform: translate(-50%, -50%);
  padding: 8px 16px; border-radius: 999px; background: rgba(29, 34, 51, .86); color: #fff; font-weight: 800; font-size: 14px;
  pointer-events: none; white-space: nowrap; animation: pop-in .2s ease-out;
}
.wall-credit { margin-top: -4px; font-size: 11px; font-weight: 700; color: var(--muted); }

/* =====================================================================
   Draw, stickers and six more tools (October 2026)
   ===================================================================== */

/* ---------- Tray: Draw and Stickers at the front ---------- */
.tray { flex-direction: row; align-items: stretch; gap: 8px; }
.tray-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tray-lead { flex: none; display: flex; align-items: center; gap: 2px; padding-right: 9px; margin: 2px 0; border-right: 1px solid rgba(22, 32, 64, .09); }
.tray-lead-btn {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 7px; width: 84px;
  padding: 10px 4px 8px; border: 0; border-radius: 18px; background: none;
}
.tray-lead-btn:hover { background: #F5F6FA; }
.tray-lead-tile {
  display: grid; place-items: center; width: 62px; height: 62px; border-radius: 20px; font-size: 33px; color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 10px 18px -8px rgba(240, 68, 82, .7);
  transition: transform .15s cubic-bezier(.2, 1.4, .4, 1), box-shadow .15s;
}
.tray-draw .tray-lead-tile { background: linear-gradient(145deg, #FF7AB6 0%, #F04452 48%, #FF9A3D 100%); }
.tray-stickers .tray-lead-tile { background: linear-gradient(145deg, #FFE070 0%, #FFAD1F 55%, #F28C28 100%); color: #5A3500; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), 0 10px 18px -8px rgba(242, 140, 40, .75); }
.tray-lead-btn:hover .tray-lead-tile { transform: translateY(-3px) scale(1.06) rotate(-3deg); }
.tray-lead-btn:active .tray-lead-tile { transform: scale(.94); }
.tray-lead-btn .tray-name { font-size: 13.5px; font-weight: 900; color: var(--ink); }
.tray-draw[aria-pressed="true"] .tray-lead-tile, .tray-stickers[aria-expanded="true"] .tray-lead-tile { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--ink); }
.dock-reveal-wrap { position: fixed; left: 50%; bottom: 10px; z-index: 35; transform: translateX(-50%); display: flex; gap: 8px; }
.dock-reveal-wrap .dock-reveal { position: static; transform: none; }
.dock-reveal-draw .icon { color: #F04452; }
body.is-presenting .dock-reveal-wrap { display: none; }
@media (max-width: 700px) { .tray-lead, .dock-reveal-draw { display: none; } .tray-main { width: 100%; } }

/* ---------- Draw (draw.js) ---------- */
.draw-root { position: fixed; inset: 0; z-index: 45; pointer-events: none; }
.draw-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.draw-root.is-drawing .draw-live { pointer-events: auto; cursor: crosshair; touch-action: none; }
.draw-root.is-drawing .draw-live[data-tool="rub"] { cursor: none; }
.draw-bar {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); pointer-events: auto;
  display: flex; align-items: center; gap: 10px; height: 84px; padding: 0 12px 0 8px; max-width: calc(100vw - 24px);
  border-radius: 22px; background: #fff; box-shadow: 0 0 0 1px rgba(22, 32, 64, .07), 0 22px 50px -16px rgba(16, 24, 40, .5);
}
.draw-bar.rise { animation: draw-rise .22s cubic-bezier(.2, 1.2, .4, 1); }
@keyframes draw-rise { from { opacity: 0; transform: translate(-50%, 14px); } }
.draw-sep { flex: none; width: 1px; height: 46px; background: rgba(22, 32, 64, .1); }
.draw-modes { display: flex; flex-direction: column; gap: 4px; }
.draw-mode { display: grid; place-items: center; width: 42px; height: 35px; border: 0; border-radius: 11px; background: none; color: var(--muted); font-size: 21px; }
.draw-mode:hover { background: var(--surface-2); color: var(--ink); }
.draw-mode[aria-pressed="true"] { background: #EEEBFF; color: var(--grape); }
.draw-tools { position: relative; align-self: stretch; display: flex; align-items: flex-end; gap: 2px; }
.draw-tool { display: flex; align-items: flex-end; justify-content: center; width: 52px; height: 76px; padding: 0; border: 0; border-radius: 15px 15px 0 0; background: none; overflow: hidden; }
.draw-tool svg { width: 34px; height: 60px; overflow: visible; transform: translateY(14px); transition: transform .16s cubic-bezier(.2, 1.3, .4, 1); }
.draw-tool:hover svg { transform: translateY(8px); }
.draw-tool[aria-pressed="true"] { background: #ECEEF4; }
.draw-tool[aria-pressed="true"] svg { transform: translateY(3px); }
.draw-shapes {
  position: absolute; bottom: calc(100% + 14px); left: 50%; transform: translateX(-50%); display: flex; gap: 4px; padding: 6px;
  border-radius: 15px; background: #fff; box-shadow: 0 0 0 1px rgba(22, 32, 64, .08), 0 14px 30px -10px rgba(16, 24, 40, .45);
}
.draw-shape { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 11px; background: none; color: var(--ink-2); }
.draw-shape svg { width: 24px; height: 24px; }
.draw-shape:hover { background: var(--surface-2); }
.draw-shape[aria-pressed="true"] { background: #ECEEF4; color: var(--ink); }
.draw-colours { display: grid; grid-template-columns: repeat(6, 27px); gap: 7px; }
.draw-colour {
  position: relative; width: 27px; height: 27px; padding: 0; border: 0; border-radius: 50%; background: var(--c);
  box-shadow: inset 0 0 0 1.5px rgba(22, 32, 64, .14); transition: transform .1s;
}
.draw-colour:hover { transform: scale(1.1); }
.draw-colour[aria-pressed="true"] { box-shadow: 0 0 0 2.5px #fff, 0 0 0 4.5px var(--c), inset 0 0 0 1.5px rgba(22, 32, 64, .14); }
.draw-colour[data-c="#FFFFFF"][aria-pressed="true"] { box-shadow: 0 0 0 2.5px #fff, 0 0 0 4.5px #A9AEBE, inset 0 0 0 1.5px rgba(22, 32, 64, .14); }
.draw-colour-own { background: conic-gradient(#F04452, #F5C518, #22B573, #4FD8E0, #3D86F5, #8A5CF6, #E64A9A, #F04452); cursor: pointer; }
.draw-colour-own input { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.draw-sizes { display: flex; gap: 2px; }
.draw-size { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 11px; background: none; }
.draw-size span { width: var(--s); height: var(--s); border-radius: 50%; background: var(--ink); }
.draw-size:hover { background: var(--surface-2); }
.draw-size[aria-pressed="true"] { background: #ECEEF4; }
.draw-acts { display: flex; align-items: center; gap: 2px; }
.draw-act { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 11px; background: none; color: var(--ink-2); font-size: 20px; }
.draw-act:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.draw-done {
  display: inline-flex; align-items: center; gap: 6px; height: 42px; margin-left: 4px; padding: 0 16px 0 13px; border: 0; border-radius: 13px;
  background: var(--ink); color: #fff; font-weight: 800; font-size: 14.5px;
}
.draw-done:hover { filter: brightness(1.25); }
@media (max-width: 960px) {
  .draw-bar { gap: 6px; padding: 0 8px 0 6px; }
  .draw-colours { grid-template-columns: repeat(4, 21px); gap: 4px 5px; }
  .draw-colour { width: 21px; height: 21px; }
  .draw-tool { width: 44px; }
  .draw-done span { display: none; }
  .draw-done { padding: 0 11px; }
}
/* Full screen: Draw is in the bar in the corner. */
.wbar .draw-btn { display: none; }
.widget.presenting .wbar .draw-btn { display: grid; }

/* ---------- Stickers (stickers.js) ---------- */
.widget.is-sticker { background: transparent; box-shadow: none; border-radius: 14px; }
.widget.is-sticker > .card-body { padding: 0; background: transparent; overflow: visible; }
.widget.is-sticker.is-selected, .widget.is-sticker.dragging, .widget.is-sticker.resizing { box-shadow: none; outline: 2.5px dashed rgba(29, 34, 51, .38); outline-offset: 3px; }
html[data-tone="dark"] .widget.is-sticker.is-selected, html[data-tone="dark"] .widget.is-sticker.dragging { outline-color: rgba(255, 255, 255, .7); }
.widget.is-sticker.pop-in { animation: none; }
.widget.is-sticker.presenting { background: transparent; box-shadow: none; }
.stk-pic { width: 100%; height: 100%; transform: rotate(var(--turn, 0deg)); cursor: pointer; }
.widget.is-sticker.pop-in .stk-pic { animation: stk-in .55s cubic-bezier(.2, 1.6, .4, 1); }
.stk-pic.wiggle { animation: stk-wiggle .5s ease-in-out; }
@keyframes stk-in { from { opacity: 0; transform: rotate(calc(var(--turn, 0deg) - 28deg)) scale(.2); } }
@keyframes stk-wiggle {
  25% { transform: rotate(calc(var(--turn, 0deg) - 9deg)) scale(1.07); }
  60% { transform: rotate(calc(var(--turn, 0deg) + 6deg)) scale(1.03); }
}
.stk { display: block; width: 100%; height: 100%; overflow: visible; }
.stk text { font-family: var(--font); font-weight: 900; }
.stick-panel { width: min(720px, calc(100vw - 24px)); }
.stk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.stk-choice { aspect-ratio: 1; padding: 13px; border: 0; border-radius: 16px; background: #F3F5F9; transition: transform .14s cubic-bezier(.2, 1.4, .4, 1), background .12s; }
.stk-choice:hover { background: #E9ECF3; transform: translateY(-3px) rotate(-4deg) scale(1.04); }
.stk-own { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.stk-words {
  flex: 1 1 220px; height: 40px; padding: 0 12px; border: 0; border-radius: 11px; background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line); font-weight: 700; font-size: 15px;
}
.stk-words:focus { outline: none; box-shadow: inset 0 0 0 2px var(--sky); }
.stk-dots { display: flex; gap: 7px; }
.stk-dot { width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: var(--c); }
.stk-dot[aria-pressed="true"] { box-shadow: 0 0 0 2.5px #fff, 0 0 0 4.5px var(--c); }

/* ---------- Visual timer ---------- */
.vt-top { justify-content: flex-start; flex-wrap: wrap; }
.vt-swatches { display: flex; gap: .35em; margin-right: auto; font-size: var(--ctl); }
.vt-swatch { width: 1.3em; height: 1.3em; padding: 0; border: 0; border-radius: 50%; background: var(--c); }
.vt-swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--c); }
.vt-stage { flex: 1; min-height: 0; display: grid; place-items: center; container-type: size; }
.vt-dial { width: min(100cqh, 100cqw); height: min(100cqh, 100cqw); overflow: visible; touch-action: none; cursor: pointer; user-select: none; }
.vt-dial:focus { outline: none; }
.vt-dial:focus-visible .vt-plate { stroke: var(--c); stroke-width: 2.5; }
.vt-plate { fill: color-mix(in srgb, var(--c) 10%, white); }
.vt-disc { fill: var(--c); transition: fill .3s; }
.vt-edge { stroke: color-mix(in srgb, var(--c) 70%, black); stroke-width: 1.2; opacity: .5; }
.vt-tick { stroke: #A9AEBE; stroke-width: 1.2; }
.vt-tick-big { stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; }
.vt-num { font-size: 15px; font-weight: 800; fill: var(--ink); text-anchor: middle; dominant-baseline: central; }
.vt-pin { fill: var(--ink); }
.vt-knob { fill: #fff; stroke: var(--c); stroke-width: 4; filter: drop-shadow(0 2px 3px rgba(16, 24, 40, .3)); }
.vt-running .vt-knob { display: none; }
.vt-done .vt-dial { animation: pulse 1s ease-in-out infinite; }
.vt-foot { display: flex; align-items: center; gap: 10px; }
.vt-read { flex: 1; min-width: 0; }
.vt-digits { font-size: min(13cqh, 15cqw); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.vt-status { font-size: calc(var(--ctl) * .9); font-weight: 800; color: var(--muted); }
.vt-status:empty { display: none; }
.vt-done .vt-status { color: var(--coral); font-size: var(--ctl); }
.vt-go {
  display: grid; place-items: center; flex: none; width: 3.3em; height: 3.3em; padding: 0; border: 0; border-radius: 50%;
  background: var(--c, var(--accent)); color: #fff; font-size: var(--ctl);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 8px 16px -6px color-mix(in srgb, var(--c, var(--accent)) 70%, transparent);
}
.vt-go .icon { font-size: 1.45em; }
.vt-go:active:not(:disabled) { transform: scale(.95); }
.vt-reset { width: 2.4em; height: 2.4em; font-size: var(--ctl); }
.vt-reset .icon { font-size: 1.3em; }
@container (max-height: 360px) { .vt-swatches { display: none; } }

/* ---------- Randomiser ---------- */
.rd-space { flex: 1; }
.rd-label { font-size: var(--ctl); font-weight: 800; color: var(--muted); }
.rd-stage { flex: 1; min-height: 0; display: flex; }
.rd-reels { flex: 1; min-width: 0; display: grid; grid-template-columns: 1fr; grid-auto-rows: minmax(0, 1fr); gap: 10px; }
.rd-reels[data-n="2"] { grid-template-columns: 1fr 1fr; }
.rd-reels[data-n="3"] { grid-template-columns: 1fr 1fr 1fr; }
.rd-reels[data-n="4"] { grid-template-columns: 1fr 1fr; }
@container (aspect-ratio < 1.2) { .rd-reels[data-n="2"], .rd-reels[data-n="3"] { grid-template-columns: 1fr; } }
@container (aspect-ratio > 2.4) { .rd-reels[data-n="4"] { grid-template-columns: repeat(4, 1fr); } }
.rd-reel {
  position: relative; min-height: 0; overflow: hidden; container-type: size; border-radius: 16px;
  background: linear-gradient(#E9ECF3, #fff 28%, #fff 72%, #E9ECF3);
  box-shadow: inset 0 0 0 1.5px var(--line), inset 0 12px 16px -12px rgba(16, 24, 40, .3), inset 0 -12px 16px -12px rgba(16, 24, 40, .3);
}
.rd-reel::after {
  content: ''; position: absolute; z-index: 2; left: 5px; right: 5px; top: 33.333%; height: 33.333%; border-radius: 12px; pointer-events: none;
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--accent) 55%, white);
}
.rd-reel.landed::after { animation: rd-flash .6s ease-out; }
@keyframes rd-flash { 30% { box-shadow: inset 0 0 0 5px var(--accent); } }
.rd-strip { will-change: transform; }
/* The rows above and below the window fade away. */
.rd-reel::before {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; border-radius: inherit;
  background: linear-gradient(rgba(233, 236, 243, .97), rgba(255, 255, 255, .55) 30%, transparent 36%, transparent 64%, rgba(255, 255, 255, .55) 70%, rgba(233, 236, 243, .97));
}
.rd-row { display: flex; align-items: center; justify-content: center; height: 33.3333cqh; padding: 0 6px; font-weight: 900; line-height: 1; white-space: nowrap; overflow: hidden; color: var(--ink); letter-spacing: -.01em; }
.rd-row.is-chosen { color: color-mix(in srgb, var(--accent) 85%, black); animation: rd-land .4s cubic-bezier(.2, 1.5, .4, 1); }
@keyframes rd-land { 40% { transform: scale(1.12); } }
.rd-stage.is-empty .rd-row { font-size: var(--ctl) !important; white-space: normal; text-align: center; color: var(--muted); }
.rd-panel { position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; gap: 10px; padding: 16px; background: #fff; border-radius: inherit; font-size: var(--ctl); }
.rd-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rd-panel-head h3 { margin: 0; font-size: 1.2em; font-weight: 900; }
.rd-pane { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.rd-pane-list { flex: 1; }
.rd-list {
  flex: 1; min-height: 80px; resize: none; padding: 10px 12px; border: 0; border-radius: 12px; background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line); font-weight: 700; line-height: 1.5;
}
.rd-range { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.rd-num, .rd-list { font-size: var(--ctl); }
.rd-num { width: 6em; height: 2.2em; padding: 0 10px; border: 0; border-radius: 10px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); font-weight: 800; }
.rd-list:focus, .rd-num:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.rd-hint { margin: 0; font-size: .85em; font-weight: 700; }

/* ---------- Poll ---------- */
.pl-edit { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; overflow: auto; font-size: var(--ctl); }
.pl-field { display: flex; flex-direction: column; gap: 6px; }
.pl-field > span { font-size: .78em; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.pl-q-in, .pl-a input {
  min-width: 0; height: 2.3em; padding: 0 .7em; border: 0; border-radius: 10px; background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line); font-weight: 700;
}
.pl-q-in { font-size: 1.1em; font-weight: 800; }
.pl-q-in:focus, .pl-a input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.pl-a-list { display: flex; flex-direction: column; gap: 6px; }
.pl-a { display: flex; align-items: center; gap: 8px; }
.pl-a input { flex: 1; }
.pl-dot { flex: none; width: 1.6em; height: 1.6em; padding: 0; border: 0; border-radius: 50%; background: var(--c); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15); }
.pl-add { align-self: flex-start; display: inline-flex; align-items: center; gap: .35em; }
.pl-starts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pl-go { margin-top: auto; }
.pl-vote { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.pl-q { font-size: min(6cqw, 8.5cqh); font-weight: 900; line-height: 1.15; text-align: center; letter-spacing: -.01em; }
.pl-rows-wrap { position: relative; flex: 1; min-height: 0; display: flex; }
.pl-rows { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2cqh; container-type: size; }
.pl-row {
  flex: 1; min-height: 0; display: flex; align-items: center; gap: 1.6cqw; padding: 0 2cqw 0 0; border: 0;
  border-left: max(7px, 1.4cqw) solid var(--c); border-radius: 14px; text-align: left; overflow: hidden;
  background: color-mix(in srgb, var(--c) 10%, white); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 28%, white);
  transition: transform .1s;
}
.pl-row:hover { background: color-mix(in srgb, var(--c) 15%, white); }
.pl-row:active { transform: scale(.985); }
.pl-row.bump { animation: pl-bump .35s ease-out; }
@keyframes pl-bump { 35% { transform: scale(1.02); box-shadow: inset 0 0 0 3px var(--c); } }
.pl-label {
  flex: 0 1 auto; min-width: 0; max-width: 45%; padding-left: .7em; color: var(--ink); font-weight: 900;
  font-size: min(4.6cqw, calc(40cqh / var(--n))); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pl-track { flex: 1; align-self: stretch; display: flex; margin: min(1.6cqh, 10px) 0; border-radius: 10px; background: rgba(255, 255, 255, .8); overflow: hidden; }
.pl-fill { width: 0; height: 100%; border-radius: 10px; background: var(--c); transition: width .5s cubic-bezier(.2, 1, .4, 1); }
.pl-count { flex: none; min-width: 3.4em; text-align: right; font-weight: 900; font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: min(3.6cqw, calc(30cqh / var(--n))); }
.pl-row.is-top .pl-count { color: var(--ink); }
.pl-vote.is-hidden .pl-track { background: repeating-linear-gradient(-45deg, rgba(255, 255, 255, .85) 0 10px, rgba(255, 255, 255, .55) 10px 20px); }
.pl-thanks {
  position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; justify-content: center; gap: .5em; border-radius: 16px;
  background: rgba(255, 255, 255, .96); color: var(--grass); font-size: min(5.5cqw, 9cqh); font-weight: 900; animation: pop-in .2s ease-out;
}
.pl-foot { justify-content: flex-start; }
.pl-foot .chip { display: inline-flex; align-items: center; gap: .3em; }
.pl-total { margin-right: auto; font-size: var(--ctl); font-weight: 900; color: var(--ink-2); }

/* ---------- Scoreboard ---------- */
.sb-top { flex-wrap: wrap; }
.sb-teams, .sb-actions { display: flex; align-items: center; gap: 6px; font-size: var(--ctl); }
.sb-top .chip { display: inline-flex; align-items: center; gap: .3em; }
.sb-count { min-width: 1.3em; text-align: center; font-weight: 900; }
.sb-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: minmax(0, 1fr); gap: 10px; }
.sb-grid[data-n="3"], .sb-grid[data-n="5"], .sb-grid[data-n="6"] { grid-template-columns: repeat(3, 1fr); }
.sb-grid[data-n="4"] { grid-template-columns: repeat(4, 1fr); }
@container (aspect-ratio < 1.7) { .sb-grid[data-n="4"] { grid-template-columns: 1fr 1fr; } }
@container (aspect-ratio < 1) { .sb-grid[data-n="2"] { grid-template-columns: 1fr; } .sb-grid[data-n="3"], .sb-grid[data-n="5"], .sb-grid[data-n="6"] { grid-template-columns: 1fr 1fr; } }
.sb-team {
  position: relative; min-height: 0; display: flex; flex-direction: column; padding: .5em; border-radius: 18px; overflow: hidden;
  container-type: size; font-size: var(--ctl);
  background: color-mix(in srgb, var(--c) 10%, white); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c) 26%, white);
  transition: box-shadow .2s;
}
.sb-team.is-leader { box-shadow: inset 0 0 0 3.5px var(--c); }
.sb-team.cheer { animation: sb-cheer .8s ease-in-out; }
@keyframes sb-cheer { 20% { transform: rotate(-2deg) scale(1.03); } 45% { transform: rotate(2deg) scale(1.03); } 70% { transform: rotate(-1deg); } }
.sb-head { display: flex; align-items: center; gap: .35em; }
.sb-dot { flex: none; width: 1.05em; height: 1.05em; padding: 0; border: 0; border-radius: 50%; background: var(--c); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15); }
.sb-name {
  flex: 1; min-width: 0; padding: .1em .25em; border: 0; border-radius: 8px; background: none;
  font-weight: 900; font-size: min(1.15em, 11cqw); color: color-mix(in srgb, var(--c) 72%, black);
}
.sb-name:hover, .sb-name:focus { background: rgba(255, 255, 255, .85); outline: none; }
.sb-score { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; padding: 0; border: 0; border-radius: 14px; background: none; }
.sb-score:hover { background: rgba(255, 255, 255, .5); }
.sb-num { font-size: min(50cqh, 42cqw); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.03em; color: color-mix(in srgb, var(--c) 82%, black); }
.sb-score.bump .sb-num { animation: sb-bump .32s ease-out; }
.sb-score.drop .sb-num { animation: sb-drop .32s ease-out; }
@keyframes sb-bump { 40% { transform: scale(1.18); } }
@keyframes sb-drop { 40% { transform: scale(.88); } }
.sb-crown { position: absolute; top: 2%; right: 4%; font-size: min(16cqh, 16cqw); color: #B07800; opacity: 0; transform: rotate(14deg) scale(.6); transition: opacity .2s, transform .3s cubic-bezier(.2, 1.5, .4, 1); }
.sb-crown svg { fill: #FFD84D; }
.sb-team.is-leader .sb-crown { opacity: 1; transform: rotate(14deg); }
.sb-btns { display: flex; justify-content: center; gap: .5em; }
.sb-btn {
  display: grid; place-items: center; width: 2.4em; height: 2.1em; padding: 0; border: 0; border-radius: .7em;
  background: #fff; color: var(--ink-2); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 30%, white);
}
.sb-plus { width: 3.6em; background: var(--c); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25); }
.sb-btn:active { transform: scale(.94); }

/* ---------- Work symbols ---------- */
.card-body.tool-symbols { align-items: center; gap: 2.5cqh; }
.sy-levels { position: absolute; top: 10px; left: 12px; z-index: 2; font-size: calc(var(--ctl) * .85); opacity: .55; transition: opacity .15s; }
.sy-levels:hover, .sy-levels:focus-visible { opacity: 1; }
.sy-stage { flex: 1; min-height: 0; width: 100%; display: grid; place-items: center; container-type: size; }
.sy-big {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1%;
  width: min(100cqh, 100cqw); height: min(100cqh, 100cqw); border-radius: 50%;
  background: color-mix(in srgb, var(--c) 6%, white);
  box-shadow: inset 0 0 0 max(5px, 2.2cqmin) color-mix(in srgb, var(--c) 80%, white), 0 12px 28px -14px rgba(16, 24, 40, .4);
}
.sy-big.swap { animation: pop-in .26s cubic-bezier(.2, 1.3, .4, 1); }
.sy-big .sy-art { width: 56%; height: 56%; margin-top: 5%; }
.sy-name { max-width: 78%; font-size: min(8.5cqh, 8.5cqw); font-weight: 900; line-height: 1.05; text-align: center; color: var(--ink); }
.sy-badge {
  position: absolute; top: 3%; right: 5%; display: grid; place-items: center; width: 21%; height: 21%; border-radius: 50%;
  background: var(--c); color: #fff; font-weight: 900; font-size: min(12cqh, 12cqw); line-height: 1;
  box-shadow: 0 0 0 max(3px, .9cqmin) #fff, 0 6px 14px -6px rgba(0, 0, 0, .35);
}
.no-levels .sy-badge { display: none; }
.sy-choices { display: flex; justify-content: center; gap: 2.4cqw; width: 100%; }
.sy-choice {
  position: relative; display: grid; place-items: center; width: min(13cqw, 15cqh); aspect-ratio: 1; padding: 0; border: 0; border-radius: 50%;
  background: #fff; box-shadow: inset 0 0 0 2px var(--line), 0 4px 10px -6px rgba(16, 24, 40, .35); transition: transform .12s;
}
.sy-choice:hover { transform: translateY(-2px); }
.sy-choice[aria-pressed="true"] { box-shadow: inset 0 0 0 max(3px, .7cqw) var(--c), 0 6px 14px -6px rgba(16, 24, 40, .4); }
.sy-choice .sy-art { width: 74%; height: 74%; }
.sy-badge-sm { top: -8%; right: -8%; width: 38%; height: 38%; font-size: min(2.8cqw, 3.2cqh); box-shadow: 0 0 0 2px #fff; }
.sy-art { overflow: visible; }
.sy-art * { fill: none; stroke: var(--ink); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.sy-art .sy-head, .sy-art .sy-finger, .sy-art .sy-hand, .sy-art .sy-eye { fill: #fff; }
.sy-art .sy-ink, .sy-art .sy-mouth { fill: var(--ink); stroke: none; }
.sy-art .sy-bubble, .sy-art .sy-iris { fill: var(--c); }
.sy-art .sy-cover, .sy-art .sy-soft { fill: var(--c); stroke: none; }
.sy-art .sy-dot, .sy-art .sy-shine { fill: #fff; stroke: none; }

/* ---------- QR code ---------- */
.qr-top { display: flex; }
.qr-field {
  flex: 1; display: flex; align-items: center; gap: 6px; height: 2.6em; padding: 0 4px 0 12px; border-radius: 12px;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); font-size: var(--ctl); color: var(--muted);
}
.qr-field:focus-within { box-shadow: inset 0 0 0 2px var(--accent); }
.qr-in { flex: 1; min-width: 0; height: 100%; border: 0; background: none; outline: none; font-weight: 700; color: var(--ink); }
.qr-stage { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2cqh; container-type: size; }
.qr-code { display: grid; place-items: center; width: min(86cqh, 100cqw); aspect-ratio: 1; }
.qr-code svg { display: block; width: 100%; height: 100%; border-radius: 10px; box-shadow: 0 0 0 1px var(--line); }
.qr-code.is-empty { padding: 10%; border-radius: 16px; background: var(--surface-2); text-align: center; font-size: var(--ctl); }
.qr-caption { max-width: 100%; font-size: min(5cqh, 6cqw); font-weight: 800; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* =====================================================================
   The tray and top bar, second design (October 2026)
   The tray is tucked into the bottom left corner and opens right across the bottom, with every tool in one
   strip that scrolls sideways. The top bar starts tucked away too. Both are slimmer and more solid.
   ===================================================================== */

/* ---------- The tray ---------- */
.tray-wrap { justify-content: stretch; padding: 0 12px 10px; }
.tray-wrap .tray {
  width: 100%; padding: 6px 8px 3px; gap: 6px; border-radius: 20px;
  background: rgba(255, 255, 255, .98); backdrop-filter: none; -webkit-backdrop-filter: none;
  box-shadow: 0 0 0 1px rgba(22, 32, 64, .07), 0 16px 36px -16px rgba(16, 24, 40, .45);
}
.tray.rise { animation: tray-open .34s cubic-bezier(.2, .9, .3, 1); }
@keyframes tray-open {
  from { clip-path: inset(0 calc(100% - 180px) 0 0 round 20px); opacity: .5; }
  to { clip-path: inset(0 0 0 0 round 20px); opacity: 1; }
}
.tray-main { flex: 1; }
.tray-top { gap: 8px; }
.tray-tabs { flex: 0 1 auto; min-width: 0; padding: 2px; border-radius: 11px; scrollbar-width: none; }
.tray-tabs::-webkit-scrollbar { display: none; }
.tray-tab { height: 28px; padding: 0 11px; font-size: 13px; transition: background .15s, color .15s, box-shadow .15s; }
.tray-search {
  flex: 0 1 210px; min-width: 120px; display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 11px;
  background: #F1F3F8; color: var(--muted); font-size: 15px; cursor: text;
}
.tray-search:focus-within { background: #fff; box-shadow: inset 0 0 0 2px var(--sky); color: var(--sky); }
.tray-search-in { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 13.5px; font-weight: 700; color: var(--ink); }
.tray-search-in::placeholder { color: var(--muted); }
.tray-btn { height: 32px; padding: 0 11px; font-size: 13px; }
.tray-strip { position: relative; min-width: 0; }
.tray-apps {
  position: relative; justify-content: flex-start; min-width: 0 !important; gap: 0; padding: 1px 0 3px; overscroll-behavior-x: contain;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 12px, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to right, transparent, #000 12px, #000 calc(100% - 28px), transparent);
}
.tray-apps.at-start { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
.tray-apps.at-end { -webkit-mask-image: linear-gradient(to right, transparent, #000 12px); mask-image: linear-gradient(to right, transparent, #000 12px); }
.tray-apps.at-start.at-end { -webkit-mask-image: none; mask-image: none; }
.tray-group { flex: none; display: flex; }
.tray-group + .tray-group { margin-left: 6px; padding-left: 6px; border-left: 1px solid rgba(22, 32, 64, .08); }
.tray-app { width: 76px; padding: 6px 2px 4px; gap: 4px; border-radius: 14px; }
.tray-tile { width: 44px; height: 44px; border-radius: 14px; font-size: 23px; }
.tray-app .tray-name { font-size: 12px; }
.tray-app.on::after { top: 3px; right: 12px; width: 9px; height: 9px; }
.tray.is-searching .tray-tab { opacity: .45; }
.tray.is-searching .tray-tab[aria-selected="true"] { background: none; box-shadow: none; }
.tray.is-searching .tray-group + .tray-group { margin-left: 0; padding-left: 0; border-left: 0; }
.tray-none { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; font-size: 14px; font-weight: 800; color: var(--muted); }
.tray-lead { padding-right: 8px; }
.tray-lead-btn { width: 70px; padding: 6px 2px 4px; gap: 5px; border-radius: 15px; }
.tray-lead-tile { width: 52px; height: 52px; border-radius: 17px; font-size: 28px; }
.tray-lead-btn .tray-name { font-size: 12.5px; }
@media (max-width: 700px) { .tray-search { flex-basis: 120px; } .tray-tab { padding: 0 9px; } }

/* Tucked away: Tools (and Draw) in the bottom left corner, and the board takes the space. */
.dock-reveal-wrap { left: 12px; bottom: 10px; transform: none; gap: 6px; }
.dock-reveal-wrap .dock-reveal {
  height: 40px; padding: 0 12px 0 11px; gap: 7px; border-color: rgba(255, 255, 255, .98); background: rgba(255, 255, 255, .98);
  backdrop-filter: none; -webkit-backdrop-filter: none; color: var(--ink); font-size: 14px;
  box-shadow: 0 0 0 1px rgba(22, 32, 64, .07), 0 10px 24px -10px rgba(16, 24, 40, .45);
}
.dock-reveal-wrap .dock-reveal .icon { font-size: 18px; color: var(--sky); }
.dock-reveal-wrap .dock-reveal-draw .icon { color: #F04452; }
.dock-reveal-arrow { display: inline-flex; margin: 0 -3px 0 -1px; }
.dock-reveal-wrap .dock-reveal-arrow .icon { font-size: 15px; color: var(--muted); transition: transform .15s; }
.dock-reveal:hover .dock-reveal-arrow .icon { transform: translateX(2px); }
body:has(.tray-wrap.is-collapsed) .board { margin-bottom: 10px; }

/* ---------- The top bar ---------- */
.topbar {
  min-height: 44px; margin: 8px 12px 0; padding: 3px 6px 3px 8px; gap: 10px; border-radius: 15px;
  background: rgba(255, 255, 255, .98); border-color: rgba(255, 255, 255, .98); backdrop-filter: none; -webkit-backdrop-filter: none;
}
.topbar .brand-mark { width: 26px; height: 26px; }
.topbar .brand-name { font-size: 15.5px; }
.topbar .greeting { font-size: 11.5px; }
.topbar .tb-btn { height: 32px; padding: 0 10px; font-size: 13.5px; }
.topbar .tb-icon { width: 32px; padding: 0; }
.topbar .class-select { height: 32px; }
.topbar .class-select select { padding: 4px; font-size: 13.5px; }
.topbar .th-link { padding: 6px 11px; font-size: 14px; }
.board { margin-top: 8px; }
/* The arrow on the logo: pointing out when the bar is tucked away, back in when it's open. */
.brand-arrow { display: inline-flex; flex: none; width: 15px; height: 15px; margin-left: 2px; color: var(--muted); opacity: .6; transform: rotate(180deg); transition: transform .2s, opacity .15s; }
.brand-arrow svg { width: 100%; height: 100%; }
.brand-toggle:hover .brand-arrow { opacity: 1; }
body.topbar-min .topbar { min-height: 0; margin: 10px 0 0 12px; padding: 4px; border-radius: 15px; }
body.topbar-min .brand-toggle { display: flex; align-items: center; gap: 3px; padding: 3px 4px 3px 3px; }
body.topbar-min .brand-mark { width: 30px; height: 30px; }
body.topbar-min .brand-arrow { width: 16px; height: 16px; opacity: 1; transform: none; color: var(--ink-2); }
body.topbar-min .brand-toggle:hover .brand-arrow { transform: translateX(2px); }

/* ---------- Link ---------- */
.card-body.tool-link { justify-content: center; padding: 12px 14px; }
.lk-view { flex: 1; min-height: 0; display: flex; align-items: center; gap: min(5cqw, 18px); padding: 0 4px; }
.lk-tile {
  display: grid; place-items: center; flex: none; height: min(78cqh, 22cqw); aspect-ratio: 1; border-radius: 22%;
  background: linear-gradient(160deg, color-mix(in srgb, var(--c) 70%, white), var(--c)); color: #fff;
  font-size: min(44cqh, 12cqw); font-weight: 900; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 6px 14px -8px var(--c);
}
.lk-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .2em; padding: 0; border: 0; background: none; text-align: left; }
.lk-name, .lk-url { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lk-name { font-size: min(20cqh, 7cqw); font-weight: 900; color: var(--ink); line-height: 1.15; }
.lk-url { font-size: min(13cqh, 4.6cqw); font-weight: 700; color: var(--muted); }
.lk-text:hover .lk-name { text-decoration: underline; text-underline-offset: .15em; }
.lk-open {
  display: grid; place-items: center; flex: none; height: min(58cqh, 18cqw); aspect-ratio: 1; padding: 0; border: 0; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: min(28cqh, 8cqw);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 8px 16px -8px color-mix(in srgb, var(--accent) 80%, transparent);
  transition: transform .12s;
}
.lk-open:hover { transform: scale(1.06); }
.lk-open .icon { width: 1em; height: 1em; }
.lk-edit { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; font-size: 14px; opacity: 0; transition: opacity .15s; }
.card:hover .lk-edit, .lk-edit:focus-visible { opacity: 1; }
@media (hover: none) { .lk-edit { opacity: .8; } }
.lk-form { display: flex; flex-direction: column; justify-content: center; gap: 8px; flex: 1; min-height: 0; font-size: 14px; }
.lk-row { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.lk-row > .icon { font-size: 18px; }
.lk-in {
  flex: 1; min-width: 0; height: 34px; padding: 0 10px; border: 0; border-radius: 10px; background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line); font-weight: 700; color: var(--ink);
}
.lk-in:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.lk-note { font-size: 12.5px; font-weight: 800; color: var(--coral); }
.lk-note:empty { display: none; }
.lk-form .btn { font-size: 14px; padding: .45em .9em; }

/* ---------- The tray, slimmer and see-through: names show on hover ---------- */
.tray-wrap .tray {
  padding: 5px 8px 2px; border-radius: 18px;
  background: rgba(255, 255, 255, .62); backdrop-filter: blur(22px) saturate(1.7); -webkit-backdrop-filter: blur(22px) saturate(1.7);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .55), 0 14px 34px -16px rgba(16, 24, 40, .5);
}
.tray-tabs, .tray-search { background: rgba(22, 32, 64, .07); }
.tray-tab:hover { background: rgba(255, 255, 255, .6); }
.tray-tab { height: 26px; }
.tray-search, .tray-btn { height: 30px; }
.tray-btn:hover, .tray-btn[aria-expanded="true"] { background: rgba(255, 255, 255, .6); }
.tray-lead { border-right-color: rgba(22, 32, 64, .1); padding-right: 6px; }
.tray-group + .tray-group { border-left-color: rgba(22, 32, 64, .1); }
.tray-app { width: 54px; padding: 5px 2px 4px; border-radius: 13px; }
.tray-app:hover, .tray-lead-btn:hover { background: rgba(255, 255, 255, .55); }
.tray-tile { width: 42px; height: 42px; border-radius: 13px; font-size: 22px; }
.tray-lead-btn { width: 56px; padding: 5px 2px 4px; border-radius: 14px; }
.tray-lead-tile { width: 46px; height: 46px; border-radius: 15px; font-size: 25px; }
.tray-app.on::after { top: 2px; right: 2px; width: 9px; height: 9px; }
@media (hover: hover) { .tray-app .tray-name, .tray-lead-btn .tray-name { display: none; } }
@media (hover: none) { .tray-app { width: 72px; } .tray-lead-btn { width: 64px; } }
.tray-tip {
  position: fixed; z-index: 60; padding: 5px 10px; border-radius: 9px; background: var(--ink); color: #fff;
  font-size: 13px; font-weight: 800; white-space: nowrap; pointer-events: none; animation: tip-in .12s ease-out;
}
.tray-tip::after { content: ''; position: absolute; top: 100%; left: 50%; margin-left: -5px; border: 5px solid transparent; border-top-color: var(--ink); }
@keyframes tip-in { from { opacity: 0; transform: translateY(3px); } }

/* ---------- Inside a tall widget, the bar folds down to a small grip ---------- */
/* No room above or below, so the bar would sit over the tool: only a slim grip shows at the top edge. Pointing at
   it (or tapping it) opens the whole bar; dragging it moves the widget. */
.widget.bar-inside:not(.presenting) .wbar { top: 0; padding-top: 3px; }
.widget.bar-inside:not(.presenting) .wbar-inner { padding: 2px; border-radius: 0 0 11px 11px; box-shadow: 0 0 0 1px rgba(22, 32, 64, .08), 0 6px 14px -6px rgba(16, 24, 40, .35); }
.widget.bar-inside:not(.presenting) .wbar-inner > :not(.wbar-grip) { display: none; }
.widget.bar-inside:not(.presenting) .wbar-grip { width: 44px; height: 16px; border-radius: 0 0 9px 9px; }
.widget.bar-inside:not(.presenting) .wbar-grip .icon { transform: rotate(90deg); font-size: 15px; }
.widget.bar-inside:not(.presenting) .wbar:hover .wbar-inner, .widget.bar-inside:not(.presenting) .wbar:has(:focus-visible) .wbar-inner, .widget.bar-inside.bar-open:not(.presenting) .wbar-inner { padding: 4px; border-radius: 14px; }
.widget.bar-inside:not(.presenting) .wbar:hover .wbar-inner > *, .widget.bar-inside:not(.presenting) .wbar:has(:focus-visible) .wbar-inner > *, .widget.bar-inside.bar-open:not(.presenting) .wbar-inner > * { display: flex; }
.widget.bar-inside:not(.presenting) .wbar:hover .wbar-btn, .widget.bar-inside:not(.presenting) .wbar:has(:focus-visible) .wbar-btn, .widget.bar-inside.bar-open:not(.presenting) .wbar-btn { display: grid; }
.widget.bar-inside:not(.presenting) .wbar:hover .wbar-grip, .widget.bar-inside:not(.presenting) .wbar:has(:focus-visible) .wbar-grip, .widget.bar-inside.bar-open:not(.presenting) .wbar-grip { display: grid; width: 32px; height: 32px; border-radius: 10px; }
.widget.bar-inside:not(.presenting) .wbar:hover .wbar-grip .icon, .widget.bar-inside:not(.presenting) .wbar:has(:focus-visible) .wbar-grip .icon, .widget.bar-inside.bar-open:not(.presenting) .wbar-grip .icon { transform: none; font-size: 17px; }
.widget.bar-inside:not(.presenting) .wbar .draw-btn { display: none !important; }
/* Only the grip (or the open bar) takes clicks, not the strip across the top of the tool. */
.widget.bar-inside:not(.presenting) .wbar { pointer-events: none !important; }
.widget.bar-inside:not(.presenting):hover .wbar-inner, .widget.bar-inside.is-selected:not(.presenting) .wbar-inner,
.widget.bar-inside:not(.presenting):focus-within .wbar-inner { pointer-events: auto; }

/* ---------- Tucked away: a small Tools button and a round Draw button ---------- */
.dock-reveal-wrap { gap: 5px; }
.dock-reveal-wrap .dock-reveal { height: 34px; padding: 0 9px 0 9px; gap: 5px; font-size: 13px; }
.dock-reveal-wrap .dock-reveal .icon { font-size: 15px; }
.dock-reveal-wrap .dock-reveal-arrow .icon { font-size: 13px; }
.dock-reveal-wrap .dock-reveal-draw { width: 34px; padding: 0; justify-content: center; }
.dock-reveal-wrap .dock-reveal-draw .icon { font-size: 17px; }
/* A link's own picture, kept in the browser */
.lk-tile.has-pic { background-color: #fff; background-size: cover; background-position: center; box-shadow: inset 0 0 0 1px var(--line), 0 6px 14px -8px rgba(16, 24, 40, .35); }
.lk-pic-prev { height: 30px; font-size: 0; border-radius: 8px; background-color: #fff; background-size: cover; background-position: center; box-shadow: inset 0 0 0 1px var(--line); }
.lk-pics { flex-wrap: wrap; gap: 6px 8px; }
.lk-pics .chip { display: inline-flex; align-items: center; gap: .35em; font-size: 13px; }
.lk-hint { font-size: 12px; font-weight: 700; color: var(--muted); }
.lk-form { overflow: auto; gap: 6px; }
.lk-form .lk-in { height: 30px; }
.lk-form.is-drop { border-radius: 12px; box-shadow: inset 0 0 0 2px var(--accent); background: color-mix(in srgb, var(--accent) 6%, white); }

/* ---------- Classes: backups ---------- */
.backup-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 0; padding: 12px 24px; border-top: 1px solid var(--line); background: var(--surface-2); }
.backup-text { flex: 1 1 320px; display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; font-weight: 700; color: var(--ink-2); }
.backup-text b { font-size: 14px; font-weight: 900; color: var(--ink); }
.backup-text em { font-style: normal; color: var(--muted); }
.backup-row .btn { font-size: 14px; }
.backup-msg { margin: 0; padding: 8px 24px 0; font-size: 13.5px; font-weight: 800; color: var(--grass); }
.backup-msg.warn { color: #C42638; }
