* { box-sizing: border-box; }
[hidden] { display: none !important; }

/* ---------- themes ----------
   Every color/font comes from these variables; each theme on <body data-theme="..."> overrides them. */
:root {
  /* CreateABA clinician look: calm white and soft grey with one teal accent. Kid themes override these in learner mode. */
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: var(--font-body);
  --font-title: var(--font-body);
  --bg: #f5f7f8;
  --bg-image: none;
  --ink: #13222b;
  --muted: #5b6b74;
  --surface: #fff;
  --surface-2: #f2f5f6;
  --line: #e3e8eb;
  --control-border: #cfd8dd;
  --primary: #0f766e;        /* CreateABA teal (5.5:1 on white) */
  --primary-hover: #0c5f58;
  --primary-soft: #e6f3f1;
  --on-primary: #fff;
  --header-bg: #fff;
  --header-ink: var(--ink);
  --accent: #0f766e;
  --right: #2f9e44;
  --wrong: #e03131;
  --danger: #c62828;
  --radius: 10px;
  --card-border: 1px solid var(--line);
  --card-shadow: 0 1px 2px #13222b0a;
  --choice-border: #dde3e6;
  --choice-shadow: 0 2px 8px #13222b14;
  --choice-radius: 14px;
  --sd-ink: var(--ink);
  --reward-ink: #0f766e;
  --reward-bg: #ffffffcc;
  --burst: transparent;
  --mascot: "";
  --series-1: #2a78d6;   /* chart line 1 (blue), validated on white */
  --series-2: #eb6834;   /* chart line 2 (orange) */
  --sidebar-bg: #fff;
  --nav-ink: #33444d;
  --label-ink: #2b3b44;
  --badge-bg: #f1f4f5;
  --badge-ink: #1f2f38;
  --badge-border: #e1e6e8;
  --note-bg: #fff7dc;
  --note-border: #e8b400;
  --note-ink: #1d2433;
  --overlay: #13222b66;
  --shadow: #13222b;
  --on-danger: #fff;
  --met-bg: #e3f4e8;
  --met-ink: #1b6b34;
}

/* CreateABA dark mode for the clinician screens (Light / Dark / Auto in the sidebar).
   Teal-tinted dark greys, softened text; graph colours re-validated on this surface. */
:root[data-ui="dark"] {
  color-scheme: dark;
  --bg: #0f1619;
  --ink: #e4ecee;
  --muted: #9cb0b7;
  --surface: #162126;
  --surface-2: #1d2a30;
  --line: #27363d;
  --control-border: #3a4b53;
  --primary: #2dd4bf;
  --primary-hover: #5eead4;
  --primary-soft: #12403b;
  --on-primary: #062a26;
  --accent: #2dd4bf;
  --danger: #ff8a80;
  --card-shadow: 0 1px 2px #0006;
  --series-1: #3987e5;
  --series-2: #d95926;
  --sidebar-bg: #121c20;
  --nav-ink: #b9c9ce;
  --label-ink: #c7d5d9;
  --badge-bg: #22313a;
  --badge-ink: #dfe9ec;
  --badge-border: #33454e;
  --note-bg: #3a3112;
  --note-border: #b38b00;
  --note-ink: #f6edcf;
  --overlay: #000000a6;
  --shadow: #000;
  --on-danger: #3a0a07;
  --met-bg: #173a24;
  --met-ink: #8ce2a6;
}
@media (prefers-color-scheme: dark) {
  :root[data-ui="auto"] {
    color-scheme: dark;
    --bg: #0f1619;
    --ink: #e4ecee;
    --muted: #9cb0b7;
    --surface: #162126;
    --surface-2: #1d2a30;
    --line: #27363d;
    --control-border: #3a4b53;
    --primary: #2dd4bf;
    --primary-hover: #5eead4;
    --primary-soft: #12403b;
    --on-primary: #062a26;
    --accent: #2dd4bf;
    --danger: #ff8a80;
    --card-shadow: 0 1px 2px #0006;
    --series-1: #3987e5;
    --series-2: #d95926;
    --sidebar-bg: #121c20;
    --nav-ink: #b9c9ce;
    --label-ink: #c7d5d9;
    --badge-bg: #22313a;
    --badge-ink: #dfe9ec;
    --badge-border: #33454e;
    --note-bg: #3a3112;
    --note-border: #b38b00;
    --note-ink: #f6edcf;
    --overlay: #000000a6;
    --shadow: #000;
    --on-danger: #3a0a07;
  --met-bg: #173a24;
  --met-ink: #8ce2a6;
  }
}

[data-theme="superhero"] {
  --font-body: "Fredoka", "Comic Sans MS", system-ui, sans-serif;
  --font-display: "Bangers", "Impact", "Arial Black", sans-serif;
  --bg: #ffe066;
  --bg-image: radial-gradient(#f5c518 22%, transparent 23%);
  --ink: #1a1a1a;
  --muted: #4a4a4a;
  --surface-2: #fff4c2;
  --line: #1a1a1a33;
  --control-border: #1a1a1a;
  --primary: #e03131;
  --header-bg: linear-gradient(120deg, #1c3faa 0 62%, #e03131 62%);
  --accent: #1c3faa;
  --radius: 10px;
  --card-border: 3px solid #1a1a1a;
  --card-shadow: 6px 6px 0 #1a1a1a;
  --choice-border: #1a1a1a;
  --choice-shadow: 7px 7px 0 #1a1a1a;
  --choice-radius: 10px;
  --sd-ink: #1c3faa;
  --reward-ink: #e03131;
  --reward-bg: #ffffff99;
  --burst: #ffd43b;
  --mascot: "🦸 ";
}

[data-theme="princess"] {
  --font-body: "Fredoka", system-ui, sans-serif;
  --font-display: "Fredoka", system-ui, sans-serif;
  --font-title: "Pacifico", "Brush Script MT", cursive;
  --bg: #fff0f6;
  --bg-image: radial-gradient(#fcc2d7 12%, transparent 13%), radial-gradient(#e5dbff 10%, transparent 11%);
  --ink: #5a2147;
  --muted: #8f5b7f;
  --surface-2: #fff5fa;
  --line: #fcc2d7;
  --control-border: #f3a8c9;
  --primary: #d6336c;
  --header-bg: linear-gradient(120deg, #f783ac, #b197fc);
  --accent: #9c36b5;
  --radius: 22px;
  --card-border: 2px solid #fcc2d7;
  --card-shadow: 0 6px 18px #d6336c22;
  --choice-border: #f3a8c9;
  --choice-shadow: 0 8px 20px #d6336c33;
  --choice-radius: 28px;
  --sd-ink: #c2255c;
  --reward-ink: #d6336c;
  --mascot: "👑 ";
}

[data-theme="space"] {
  color-scheme: dark;
  --font-body: "Fredoka", system-ui, sans-serif;
  --font-display: "Orbitron", "Fredoka", system-ui, sans-serif;
  --bg: #0b1026;
  --bg-image: radial-gradient(#ffffff 1px, transparent 1.6px), radial-gradient(#a5d8ff99 1px, transparent 1.6px);
  --ink: #e7ecff;
  --muted: #9aa5d6;
  --surface: #161d45;
  --surface-2: #222c5e;
  --line: #2f3b78;
  --control-border: #44539c;
  --primary: #7950f2;
  --header-bg: linear-gradient(90deg, #141a46, #4c2a85);
  --accent: #4dabf7;
  --right: #51cf66;
  --wrong: #ff6b6b;
  --danger: #ff8787;
  --radius: 16px;
  --card-border: 1px solid #44539c;
  --card-shadow: 0 0 24px #4dabf722;
  --choice-border: #4dabf7;
  --choice-shadow: 0 0 22px #4dabf766;
  --sd-ink: #ffd43b;
  --reward-ink: #ffd43b;
  --reward-bg: #0b1026bb;
  --mascot: "🚀 ";
  --series-1: #3987e5;   /* chart lines stepped for the dark surface, validated */
  --series-2: #d95926;
}

[data-theme="dinosaur"] {
  --font-body: "Fredoka", system-ui, sans-serif;
  --font-display: "Fredoka", system-ui, sans-serif;
  --bg: #e6f4d7;
  --bg-image: radial-gradient(#c3e3a4 18%, transparent 19%), radial-gradient(#d8efc2 14%, transparent 15%);
  --ink: #2b3a1f;
  --muted: #5d6f4b;
  --surface-2: #f1f8e9;
  --line: #c3e3a4;
  --control-border: #94c46f;
  --primary: #2b8a3e;
  --header-bg: linear-gradient(120deg, #2b8a3e, #74b816);
  --accent: #e67700;
  --radius: 18px;
  --card-border: 3px solid #94c46f;
  --card-shadow: 0 4px 0 #74b816;
  --choice-border: #8c6d3f;
  --choice-shadow: 0 6px 0 #5c4526;
  --choice-radius: 22px;
  --sd-ink: #2b8a3e;
  --reward-ink: #e67700;
  --mascot: "🦖 ";
}

[data-theme="sports"] {
  --font-body: "Fredoka", system-ui, sans-serif;
  --font-display: "Russo One", "Fredoka", system-ui, sans-serif;
  --bg: #2f9e44;
  /* mowed-grass stripes */
  --bg-image: repeating-linear-gradient(90deg, #ffffff10 0 70px, transparent 70px 140px);
  --ink: #12261a;
  --muted: #3c5546;
  --surface-2: #eef8f0;
  --line: #ffffff66;
  --control-border: #12261a55;
  --primary: #f76707;
  --accent: #1c3faa;
  --right: #1c3faa;   /* blue, so "correct" stands out on the green field */
  --radius: 14px;
  --card-border: 3px solid #ffffff;
  --card-shadow: 0 4px 0 #1e7a33;
  --choice-border: #ffffff;
  --choice-shadow: 0 6px 0 #1e7a33;
  --choice-radius: 16px;
  --sd-ink: #ffffff;
  --reward-ink: #f76707;
  --reward-bg: #ffffffbb;
  --mascot: "⚽ ";
}
body[data-theme="sports"] { background-size: auto; }
[data-theme="sports"] .sd { text-shadow: 0 3px 0 #1e7a33; letter-spacing: 1px; }
[data-theme="sports"] .prompt-levels .hint, [data-theme="sports"] .controls .hint { color: #ffffffcc; }

[data-theme="spooky"] {
  color-scheme: dark;
  --font-body: "Fredoka", system-ui, sans-serif;
  --font-display: "Fredoka", system-ui, sans-serif;
  --bg: #1b1030;
  /* a big friendly moon and a few stars */
  --bg-image: radial-gradient(circle at 92% 34%, #ffe8a3 0 40px, #ffe8a333 41px 70px, transparent 71px),
    radial-gradient(#ffffff99 1px, transparent 1.6px);
  --ink: #f3ecff;
  --muted: #c3b6de;
  --surface: #2a1a46;
  --surface-2: #35225a;
  --line: #4b3478;
  --control-border: #6b4fa3;
  --primary: #f76707;
  --accent: #b197fc;
  --right: #69db7c;
  --wrong: #ff8787;
  --danger: #ff8787;
  --radius: 16px;
  --card-border: 2px solid #6b4fa3;
  --card-shadow: 0 0 22px #f7670726;
  --choice-border: #f76707;
  --choice-shadow: 0 0 20px #f7670755;
  --sd-ink: #ffa94d;
  --reward-ink: #ffa94d;
  --reward-bg: #1b1030cc;
  --mascot: "🎃 ";
}
body[data-theme="spooky"] { background-size: 100% 100%, 70px 70px; background-position: 0 0, 20px 30px; }
[data-theme="spooky"] .sd { text-shadow: 0 0 18px #f7670788; }
[data-theme="spooky"] .reward .word { font-family: "Creepster", "Fredoka", system-ui, sans-serif; font-weight: 400; letter-spacing: 2px; }

/* ---------- base ---------- */
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  background-color: var(--bg);
  background-image: var(--bg-image);
  background-size: 22px 22px, 37px 37px;
  background-position: 0 0, 11px 11px;
  background-attachment: fixed;
  color: var(--ink);
  min-height: 100vh;
}
body[data-theme="space"] { background-size: 90px 90px, 140px 140px; background-position: 0 0, 45px 70px; }
.icon { flex: none; vertical-align: -3px; pointer-events: none; } /* clicks go to the button, not the icon */

/* ---------- app shell: sidebar + page ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex: none; position: sticky; top: 0; height: 100vh; z-index: 20;
  display: flex; flex-direction: column; gap: 2px; padding: 18px 12px;
  background: var(--sidebar-bg); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 10px 20px; color: var(--ink); text-decoration: none; }
.brand-name { font-size: 1.2rem; font-weight: 700; letter-spacing: -.02em; }
.brand-name span { color: var(--primary); }
.nav-link {
  display: flex; align-items: center; justify-content: flex-start; gap: 10px; padding: 9px 12px; border-radius: 8px; border: none; width: 100%;
  background: none; color: var(--nav-ink); text-decoration: none; font: inherit; font-weight: 500; text-align: left; cursor: pointer;
}
.nav-link:hover { background: var(--surface-2); }
.nav-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.user-chip { display: flex; flex-direction: column; padding: 8px 12px; line-height: 1.3; }
.user-chip strong { font-size: .9rem; }
.user-chip small { color: var(--muted); font-size: .8rem; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.main-col > main { flex: 1; width: 100%; }
main { max-width: 1120px; margin: 0 auto; padding: 28px 32px 64px; }
body.logged-out .sidebar { display: none; }
/* Learner mode: a running session fills the screen in the learner's theme. */
body.learner-mode .sidebar { display: none; }
body.learner-mode main { max-width: none; padding: 10px 16px 14px; }
@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: auto; height: auto; flex-direction: row; align-items: center; overflow-x: auto; gap: 2px;
    padding: 8px 10px; border-right: none; border-bottom: 1px solid var(--line);
  }
  .brand { padding: 2px 8px 2px 4px; }
  .sidebar-foot { margin: 0 0 0 auto; padding: 0; border: none; flex-direction: row; }
  .user-chip { display: none; }
  .nav-link { width: auto; white-space: nowrap; padding: 8px 10px; }
  main { padding: 20px 16px 48px; }
}
@media (max-width: 640px) { .nav-link .nav-label, .brand-name { display: none; } }

/* ---------- controls ---------- */
button, a.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 500; padding: 8px 14px; border-radius: 8px; cursor: pointer; text-decoration: none;
  border: 1px solid var(--control-border); background: var(--surface); color: var(--ink); line-height: 1.2;
}
button:hover, a.button:hover { background: var(--surface-2); }
button:disabled { opacity: .5; cursor: default; }
button.primary, a.button.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); font-weight: 600; }
button.primary:hover, a.button.primary:hover { background: var(--primary-hover, var(--primary)); }
button.ghost, a.button.ghost { background: transparent; }
button.ghost:hover, a.button.ghost:hover { background: var(--surface-2); }
button.danger, a.button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
button.danger-solid { background: var(--danger); color: var(--on-danger); border-color: var(--danger); font-weight: 600; }
button.big { font-size: 1.05rem; padding: 11px 20px; align-self: flex-start; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
input, select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--control-border); border-radius: 8px;
  background: var(--surface); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input[type="range"] { padding: 0; accent-color: var(--primary); box-shadow: none; }
input[type="checkbox"] { accent-color: var(--primary); width: 18px; height: 18px; box-shadow: none; }
label { display: flex; flex-direction: column; gap: 5px; font-size: .875rem; font-weight: 600; color: var(--label-ink); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
.hint { color: var(--muted); font-size: .875rem; }
a { color: var(--primary); }
.error { color: var(--danger); font-weight: 600; }

.bar, .row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; min-width: 200px; }
.card, .editor {
  background: var(--surface); border-radius: var(--radius); padding: 20px;
  border: var(--card-border); box-shadow: var(--card-shadow);
  display: flex; flex-direction: column; gap: 12px; margin-top: 16px;
}
.editor h2, .card h2 { margin: 0; font-family: var(--font-display); font-size: 1.1rem; font-weight: 650; }
[data-theme="superhero"] .editor h2, [data-theme="superhero"] .card h2,
[data-theme="superhero"] .section-title { font-weight: 400; letter-spacing: 1px; font-size: 1.8rem; }
.section-title { margin: 32px 0 0; font-family: var(--font-display); font-size: 1.15rem; font-weight: 650; }
.page-title { margin: 0; font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
.card p, .editor p { margin: 0; }
.date-cell { white-space: nowrap; }

/* ---------- dialogs ---------- */
.dialog-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: var(--overlay); }
.dialog {
  width: min(440px, 100%); background: var(--surface); color: var(--ink); border-radius: 14px; padding: 22px;
  box-shadow: 0 24px 60px color-mix(in srgb, var(--shadow) 25%, transparent); display: flex; flex-direction: column; gap: 12px; font-family: "Inter", system-ui, sans-serif;
}
.dialog h2 { margin: 0; font-size: 1.1rem; font-weight: 650; }
.dialog-message { margin: 0; color: var(--muted); }
.dialog-input { width: 100%; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* accounts */
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 48px auto 0; }
.auth-brand .brand-name { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; }
.auth-brand .brand-name .brand-aba { color: var(--ink); }
.auth-card { max-width: 440px; margin: 24px auto; padding: 28px; }
.auth-card h2 { font-size: 1.35rem; }
.auth-card .hint { margin: 0; }
.auth-card .back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: .9rem; }
.auth-card button.big { align-self: stretch; }
.hint.small { font-size: .8rem; margin-top: -6px !important; }

/* welcome: BCBA login / RBT login */
.welcome { max-width: 760px; margin: 0 auto; text-align: center; }
.welcome-tag { color: var(--muted); font-size: 1.05rem; margin: 10px 0 32px; }
.role-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.role-card {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 24px;
  background: var(--surface); color: var(--ink); text-decoration: none; text-align: left;
  border-radius: 14px; border: 1px solid var(--line); box-shadow: var(--card-shadow); transition: border-color .15s, box-shadow .15s;
}
.role-card:hover { border-color: var(--primary); box-shadow: 0 6px 20px color-mix(in srgb, var(--primary) 14%, transparent); }
.role-icon {
  width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 8px;
  background: var(--primary-soft); color: var(--primary);
}
.role-card strong { font-size: 1.2rem; font-weight: 650; }
.role-card small { color: var(--muted); font-size: .92rem; padding-right: 24px; }
.role-go { position: absolute; right: 20px; bottom: 24px; color: var(--muted); }

/* instructional goals */
details.goals {
  background: var(--surface); border-radius: var(--radius); border: var(--card-border); box-shadow: var(--card-shadow);
  padding: 14px 18px; margin-top: 16px;
}
details.goals > summary {
  cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px;
}
details.goals > summary::-webkit-details-marker { display: none; }
details.goals > summary::before { content: "▸"; transition: transform .15s; display: inline-block; }
details.goals[open] > summary::before { transform: rotate(90deg); }
details.goals > summary h2 { margin: 0; font-family: var(--font-display); font-weight: 600; }
[data-theme="superhero"] details.goals > summary h2 { font-weight: 400; letter-spacing: 1px; font-size: 1.8rem; }
.goals-edit label { margin-top: 14px; font-size: 1rem; }
.goals-edit textarea {
  font: inherit; font-weight: 400; width: 100%; min-height: 100px; resize: vertical; line-height: 1.45;
  padding: 10px 12px; border: 1px solid var(--control-border); border-radius: calc(var(--radius) * .7);
  background: var(--surface); color: var(--ink);
}
.goals-read { margin: 4px 0; padding: 10px 14px; box-shadow: none; border: 1px solid var(--line); }
.goals-read section h3 { margin: 14px 0 4px; font-size: 1rem; color: var(--primary); }
.goals-read section p { margin: 0; white-space: pre-wrap; line-height: 1.45; }
.stage-goals { max-width: 900px; margin: 8px auto 0; }
#goalsStatus { margin: 6px 0 0; min-height: 1.2em; }

.goals-actions { margin: 10px 0 0; gap: 8px; }

/* goal bank */
.bank-list { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.bank-item {
  background: var(--surface); border-radius: var(--radius); border: var(--card-border); box-shadow: var(--card-shadow);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 8px;
}
.bank-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.bank-row .icon { font-size: 2rem; }
.bank-row .meta { flex: 1; min-width: 180px; }
.bank-row .meta small { color: var(--muted); }
.bank-use { margin: 0; align-items: flex-end; }

/* printing (Print / PDF): only the printable page is shown */
#printArea { display: none; }
@media print {
  body.printing > *:not(#printArea) { display: none !important; }
  body.printing { background: #fff !important; background-image: none !important; color: #000; min-height: 0; }
  body.printing #printArea { display: block; font-family: Georgia, "Times New Roman", serif; font-size: 11pt; line-height: 1.45; }
  #printArea .print-clinic { font-size: 10pt; color: #444; text-transform: uppercase; letter-spacing: 1px; }
  #printArea h1 { font-size: 20pt; margin: 2pt 0 8pt; }
  #printArea h2 { font-size: 14pt; margin: 16pt 0 4pt; border-bottom: 1.5pt solid #000; padding-bottom: 2pt; }
  #printArea h3 { font-size: 11.5pt; margin: 10pt 0 2pt; }
  #printArea p { margin: 0; white-space: pre-wrap; }
  #printArea section { break-inside: avoid; }
  #printArea .print-meta { border-collapse: collapse; width: auto; background: none; }
  #printArea .print-meta th, #printArea .print-meta td { border: none; padding: 1pt 10pt 1pt 0; font-size: 10.5pt; background: none; }
  #printArea .print-meta th { font-weight: 700; }
  /* Empty sections get ruled lines to write on. */
  #printArea .write-in { height: 54pt; background: repeating-linear-gradient(transparent 0 17pt, #999 17pt 18pt); }
  #printArea .print-trials { padding-left: 18pt; }
  #printArea .print-trials li { margin-bottom: 3pt; }
  /* Printed graphs are always black-on-white, whatever the screen theme. */
  #printArea {
    --surface: #fff; --surface-2: #f1f3f5; --ink: #000; --muted: #444; --line: #d0d4dc; --control-border: #999;
    --series-1: #2a78d6; --series-2: #eb6834; --font-body: Arial, Helvetica, sans-serif;
  }
  #printArea .print-chart { margin-top: 12pt; break-inside: avoid; }
  #printArea .print-chart svg { width: 100%; height: auto; }
  #printArea .chart-legend { margin-bottom: 4pt; color: #000; }
  #printArea .print-numbers table { width: 100%; border-collapse: collapse; background: none; }
  #printArea .print-numbers th, #printArea .print-numbers td { border: 1px solid #bbb; padding: 3pt 6pt; font-size: 10pt; background: none; color: #000; }
  /* A printed visual schedule: big pictures, headings and labels, in black and white-friendly colors. */
  #printArea .print-schedule { margin-top: 10mm; }
  #printArea:has(.print-schedule) h1 { text-align: center; font-family: "Fredoka", Arial, sans-serif; font-size: 28pt; }
  #printArea .print-schedule .sched { --card: calc((100% - 14mm * (var(--n) - 1)) / var(--n)); gap: 4mm; flex-wrap: nowrap; font-family: Arial, Helvetica, sans-serif; }
  #printArea .print-schedule .sched-step { break-inside: avoid; border: 1.5pt solid #333; border-radius: 4mm; padding: 3mm; box-shadow: none; background: #fff; }
  #printArea .print-schedule .sched-pic { background: #fff; border-radius: 2mm; }
  #printArea .print-schedule .sched-head { font-size: 16pt; }
  #printArea .print-schedule .sched-label { font-size: 14pt; color: #000; }
  #printArea .print-schedule .sched-arrow { font-size: 28pt; color: #000; }
  #printArea .print-schedule .sched-column { flex-wrap: nowrap; gap: 3mm; }
  #printArea .print-schedule .sched-column .sched-step { width: 100%; }
  #printArea .print-schedule .sched-column .sched-pic { width: 34mm; }
  #printArea .print-schedule .sched-column .sched-label { font-size: 18pt; }
  @page { margin: 16mm; }
}

/* token boards */
.token-board {
  position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 14px;
  border-radius: var(--radius); border: var(--card-border); box-shadow: var(--card-shadow);
  background: var(--surface); max-width: 900px; margin: 0 auto 8px; overflow: hidden;
}
.token-board.has-bg { background: var(--board-bg) center / cover no-repeat, var(--surface); }
/* Keep tokens readable on busy backgrounds. */
.token-board.has-bg::before { content: ""; position: absolute; inset: 0; background: #ffffff55; pointer-events: none; }
.token-board > * { position: relative; }
.token-spaces { display: grid; grid-template-columns: repeat(var(--n), minmax(36px, 64px)); gap: 8px; flex: 1; min-width: 0; }
@media (max-width: 700px) { .token-spaces { grid-template-columns: repeat(5, minmax(36px, 64px)); } }
.token-space {
  aspect-ratio: 1; border-radius: 50%; border: 3px dashed var(--control-border); background: #ffffffcc;
  display: grid; place-items: center; overflow: hidden;
}
.token-space.earned { border: 3px solid var(--accent); background: #fff; }
.token-space img { width: 100%; height: 100%; object-fit: cover; }
.token-star { font-size: clamp(1.4rem, 3vw, 2.2rem); line-height: 1; }
.token-space.pop { animation: token-pop .45s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes token-pop { 0% { transform: scale(0) rotate(-30deg); } 100% { transform: scale(1) rotate(0); } }
.token-reward {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 8px;
  background: #ffffffdd; border-radius: calc(var(--radius) * .7); border: 3px solid var(--right);
}
.token-reward img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.token-reward small { font-weight: 700; color: #1d2433; max-width: 90px; text-align: center; overflow-wrap: anywhere; }
.token-controls { display: flex; flex-direction: column; gap: 6px; }
.token-controls .primary { font-size: 1.05rem; padding: 10px 14px; }
.board-picker { flex-direction: row; align-items: center; gap: 4px; font-size: 1.1rem; }
.board-picker select { font-size: .9rem; }

.board-list { display: flex; flex-direction: column; gap: 16px; margin-top: 12px; }
.board-item-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-bottom: 8px; }
.board-item-head strong { font-size: 1.1rem; }
.board-item-head small { flex: 1; }

/* the "board is full" celebration */
.board-reward { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; background: #0008; padding: 16px; }
.board-reward-card {
  background: var(--surface); color: var(--ink); border-radius: calc(var(--radius) * 1.5); padding: 28px 32px;
  display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; max-width: 520px;
  border: var(--card-border); box-shadow: 0 20px 60px #0006; animation: reward-in .6s cubic-bezier(.3, 1.6, .5, 1);
}
.board-reward-card img { width: min(60vw, 260px); aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); animation: wiggle 1s 2; }
.board-reward-gift { font-size: 8rem; line-height: 1; animation: wiggle 1s 2; }
.board-reward-title { font-family: var(--font-display); font-size: clamp(2.2rem, 7vw, 3.5rem); color: var(--reward-ink); }
.board-reward-label { font-size: clamp(1.4rem, 4vw, 2rem); font-weight: 700; }
.board-reward-card .big { align-self: center; }
@keyframes reward-in { 0% { transform: scale(.3) rotate(-10deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }

/* graphs */
.filters { align-items: flex-end; }
.chart-card { gap: 8px; }
.chart-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.chart-head h3 { margin: 0; font-size: 1.1rem; }
#chart { width: 100%; min-width: 0; }
.chart-plot { position: relative; overflow-x: auto; outline-offset: 4px; }
.chart-plot svg { display: block; max-width: none; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis { stroke: var(--control-border); stroke-width: 1; }
.chart-axis-text { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; font-family: var(--font-body); }
.chart-axis-title { fill: var(--muted); font-size: 12px; font-weight: 600; font-family: var(--font-body); }
.chart-end-label { fill: var(--ink); font-size: 12.5px; font-weight: 700; font-family: var(--font-body); }
.chart-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { stroke: var(--surface); stroke-width: 2; }
.chart-crosshair { stroke: var(--muted); stroke-width: 1; }
.chart-hit { fill: transparent; cursor: crosshair; touch-action: pan-y; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .85rem; color: var(--ink); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend line, .chart-tip line { stroke-width: 2.5; stroke-linecap: round; }
.chart-tip {
  position: absolute; top: 8px; z-index: 2; pointer-events: none; min-width: 150px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--control-border); border-radius: 8px;
  padding: 8px 10px; box-shadow: 0 6px 20px #0002; font-size: .85rem;
}
.chart-tip-title { font-weight: 700; margin-bottom: 4px; }
.chart-tip-row { display: flex; align-items: center; gap: 6px; }
.chart-tip-row strong { font-size: 1rem; font-variant-numeric: tabular-nums; }
.chart-tip-row span, .chart-tip-note { color: var(--muted); }
.chart-tip-note { margin-top: 4px; font-size: .8rem; }
.chart-table summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
.chart-controls { margin: 4px 0 0; align-items: flex-end; }
.chart-controls .grow { flex: 1; min-width: 0; }
.program-name { color: var(--ink); text-decoration: none; }
.program-name:hover { text-decoration: underline; }

/* phases */
.phase-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: 99px;
  font-size: .8rem; font-weight: 600; white-space: nowrap; color: var(--badge-ink); background: var(--badge-bg); border: 1px solid var(--badge-border);
}
.phase-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dot, #8a979e); }
.phase-baseline { --dot: #8a979e; }
.phase-errorless { --dot: #7c5cd6; }
.phase-intervention { --dot: #2a78d6; }
.phase-maintenance { --dot: #e07b24; }
.phase-generalization { --dot: #1e9e6a; }
.phase-mastered { --dot: #c99400; background: var(--note-bg); border-color: var(--note-border); }
.phase-now { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-weight: 600; }
.phase-change { align-items: flex-end; }
.criteria { display: flex; flex-direction: column; gap: 10px; }
.criterion { border: 1px solid var(--line); border-radius: calc(var(--radius) * .7); padding: 10px 12px; }
.criterion-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; }
.criterion-fields { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.criterion-fields label.inline { flex-direction: row; align-items: center; gap: 6px; font-weight: 500; }
.criterion-fields input[type="number"] { width: 5em; }
.criterion-text { margin: 6px 0 0; }
.phase-log ul { margin: 6px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.phase-banner {
  display: flex; flex-direction: column; gap: 4px; padding: 10px 14px; border-radius: calc(var(--radius) * .7);
  border: 1px solid var(--line); color: var(--ink);
}
.phase-banner .phase-label { font-weight: 600; margin-right: 6px; }
.phase-banner .phase-badge { font-size: 1rem; }
.phase-banner .hint { color: var(--muted); }
.program-phase { margin-top: 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.phase-change-note {
  padding: 12px 14px; border-radius: calc(var(--radius) * .7); background: var(--note-bg); color: var(--note-ink);
  border: 2px solid var(--note-border); font-size: 1.05rem; line-height: 1.6;
}
.stage-phase .phase-badge { font-size: .8rem; }
.chart-phase-line { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart-phase-label { fill: var(--ink); font-size: 12px; font-weight: 700; font-family: var(--font-body); }

/* notifications */
.bell { position: relative; }
.bell-count {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: #c62828; color: #fff; font-size: .72rem; font-weight: 700; line-height: 20px; text-align: center;
}
.bell-panel {
  position: fixed; left: 248px; bottom: 16px; z-index: 40; width: min(420px, calc(100vw - 32px));
  max-height: 70vh; overflow-y: auto; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px #13222b26; padding: 8px;
}
@media (max-width: 900px) { .bell-panel { left: auto; right: 12px; top: 60px; bottom: auto; } }
.bell-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 8px; }
.bell-panel .note {
  display: flex; gap: 10px; padding: 10px; border-radius: 8px; color: var(--ink); text-decoration: none;
  border-top: 1px solid var(--line);
}
.bell-panel .note:hover { background: var(--surface-2); }
.bell-panel .note.unread { background: var(--primary-soft); }
.note-icon { color: var(--primary); display: flex; align-items: flex-start; padding-top: 2px; }
.note-body { display: flex; flex-direction: column; gap: 2px; font-size: .9rem; }
.note-body .hint { font-size: .8rem; }

/* team: clinic code */
.join-code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 2rem; font-weight: 700; letter-spacing: 3px;
  padding: 12px 16px; background: var(--surface-2); border: 2px dashed var(--control-border); border-radius: var(--radius);
  align-self: flex-start; user-select: all;
}
td.actions { white-space: nowrap; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.page-head .section-title { margin-bottom: 0; }

/* learners */
.learner-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-top: 16px; }
.learner-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 18px;
  background: var(--surface); color: var(--ink); text-decoration: none;
  border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--card-shadow); transition: border-color .15s, box-shadow .15s;
}
.learner-card:hover { border-color: var(--primary); box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 12%, transparent); }
.learner-card .avatar {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 6px;
  background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 1rem;
}
.learner-card strong { font-size: 1.05rem; }
.learner-card small { color: var(--muted); }

/* a learner's programs */
.program-list { display: flex; flex-direction: column; gap: 10px; }
.program-item {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 14px 16px;
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--card-shadow);
}
.program-item .meta { flex: 1; min-width: 160px; }
.program-item .meta small { color: var(--muted); }
.module-icon {
  width: 40px; height: 40px; border-radius: 10px; display: inline-grid; place-items: center; flex: none;
  background: var(--primary-soft); color: var(--primary);
}
.module-icon .icon { width: 22px; height: 22px; }

.danger-zone { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line); }

/* module picker */
button.module-card { font: inherit; text-align: left; cursor: pointer; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 8px; }
.module-card {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 16px;
  background: var(--surface); color: var(--ink); text-decoration: none;
  border-radius: var(--radius); border: 1px solid var(--line); transition: border-color .15s;
}
button.module-card:hover { border-color: var(--primary); background: var(--surface); }
.module-card strong { font-size: 1rem; font-weight: 650; }
.module-card small { color: var(--muted); font-weight: 400; }
.module-card.soon { opacity: .6; }
.module-card .badge {
  position: absolute; top: 12px; right: 12px; font-size: .72rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted); padding: 3px 8px; border-radius: 99px;
}

/* page and program headers */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.module-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-bottom: 20px; }
.module-head h2 { margin: 0; flex: 1; display: flex; align-items: center; gap: 12px; font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; }
.module-head .back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-weight: 500; flex-basis: 100%; }
.subtabs { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 10px; border: 1px solid var(--line); }
.subtabs a {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 8px;
  text-decoration: none; font-weight: 500; color: var(--nav-ink);
}
.subtabs a:hover { color: var(--ink); }
.subtabs a.active { background: var(--surface); color: var(--primary); font-weight: 600; box-shadow: 0 1px 3px color-mix(in srgb, var(--shadow) 14%, transparent); }

/* Build page sections */
.section-tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.section-tabs button {
  border: none; background: none; border-radius: 0; padding: 10px 12px; margin-bottom: -1px; color: var(--muted); font-weight: 500;
  border-bottom: 2px solid transparent;
}
.section-tabs button:hover { background: none; color: var(--ink); }
.section-tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.section-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.build-section > .card:first-child, .build-section > div:first-child > details.goals { margin-top: 0; }

/* goals and targets */
.met-tag {
  display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 700;
  background: var(--met-bg); color: var(--met-ink); white-space: nowrap;
}
.goal-progress { display: inline-flex; align-items: center; gap: 8px; font-size: .85rem; font-weight: 600; color: var(--label-ink); }
.goal-bar { width: 110px; height: 8px; border-radius: 99px; background: var(--badge-bg); border: 1px solid var(--badge-border); overflow: hidden; }
.goal-bar > span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.goal-progress.met { color: var(--met-ink); }
.goal-progress.met .goal-bar > span { background: var(--met-ink); }
.tree-toggle { display: inline-grid; place-items: center; color: var(--muted); transition: transform .15s; flex: none; }
details[open] > summary .tree-toggle { transform: rotate(90deg); }
.goal-item > summary, .target-card > summary { list-style: none; cursor: pointer; }
.goal-item > summary::-webkit-details-marker, .target-card > summary::-webkit-details-marker { display: none; }
.goal-item[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.target-tree {
  list-style: none; margin: 0; padding: 6px 16px 10px 44px; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-top: none; border-radius: 0 0 var(--radius) var(--radius);
}
.target-node {
  position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 0 8px 18px;
  border-left: 2px solid var(--line);
}
.target-node::before { content: ""; position: absolute; left: 0; top: 50%; width: 12px; border-top: 2px solid var(--line); }
.target-node:last-child { border-left-color: transparent; }
.target-node:last-child::after { content: ""; position: absolute; left: -2px; top: 0; height: 50%; border-left: 2px solid var(--line); }
.target-name { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.target-name .icon { color: var(--muted); }
.grow-right { margin-left: auto; }
.target-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.target-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--card-shadow); }
.target-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 12px 14px; }
.target-head .target-name { font-size: 1.05rem; }
.target-body { padding: 0 14px 12px; border-top: 1px solid var(--line); }
.target-body > .row:first-child { margin-top: 12px; }
.target-tools { align-items: center; }
.target-tools label.inline, .goal-rule label.inline { flex-direction: row; align-items: center; gap: 6px; font-weight: 500; }
.goal-rule { align-items: center; }
.goal-rule input[type="number"] { width: 5em; }
.target-body .trial-list { margin-top: 8px; }
.target-body .trial-item { box-shadow: none; background: var(--surface-2); }
.editor-target { max-width: 320px; margin-bottom: 12px; }
.target-picker { display: flex; flex-direction: column; gap: 8px; }
.target-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.target-pick.disabled { opacity: .6; }
.stage-phase { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.phase-change-note.inline { display: inline-block; padding: 4px 10px; font-size: .9rem; line-height: 1.4; border-width: 1px; }
.goal-met-note { margin-top: 12px; }
.target-goals { margin-top: 10px; }
.target-goals > .hint { margin: 4px 0 0; }

/* trial list */
.trial-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.trial-item {
  background: var(--surface); border-radius: var(--radius); padding: 12px 14px;
  border: var(--card-border); box-shadow: var(--card-shadow);
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
}
.trial-item .thumbs, .ready-item .thumbs { display: flex; flex-direction: row; flex-wrap: wrap; gap: 6px; }
.trial-item .thumbs img, .trial-item .thumbs .empty, .ready-item .thumbs img {
  width: 52px; height: 52px; object-fit: cover; border-radius: 8px; border: 2px solid var(--line); background: var(--surface-2);
}
.trial-item > button { padding: 6px 10px; font-size: .85rem; }
.trial-item .thumbs img.correct { border-color: var(--right); }
.ready-item .thumbs img.correct, .ready-item .thumb-shape.correct { border-color: var(--line); }
.trial-item .meta { flex: 1; min-width: 160px; }
.trial-item .meta small { color: var(--muted); }

/* slot editor */
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.slot {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: var(--surface);
  display: flex; flex-direction: column; gap: 8px;
}
.slot.correct { border: 2px solid var(--right); background: color-mix(in srgb, var(--right) 5%, var(--surface)); }
.slot.sample-slot { border: 2px dashed var(--accent); }
.slot h3 { margin: 0; font-size: .95rem; display: flex; justify-content: space-between; align-items: center; }
.slot h3 button { padding: 2px 8px; font-size: .8rem; }
.slot .preview {
  aspect-ratio: 1; width: 100%; border-radius: calc(var(--radius) * .7); background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--muted);
}
.slot .preview img { width: 100%; height: 100%; object-fit: cover; }
.slot .btns { display: flex; flex-wrap: wrap; gap: 6px; }
.slot .btns button { padding: 6px 10px; font-size: .85rem; }
.slot .ai { display: flex; gap: 6px; }
.slot .ai input { flex: 1; min-width: 0; font-size: .85rem; }

.slot .results { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.slot .results button.more { grid-column: 1 / -1; aspect-ratio: auto; padding: 6px; border-color: var(--control-border); font-size: .85rem; }
.slot .results:empty { display: none; }
.slot .results .hint, .slot .results .spinner { grid-column: 1 / -1; margin: 4px auto; }
.slot .results button { padding: 0; border: 2px solid transparent; border-radius: 6px; overflow: hidden; aspect-ratio: 1; }
.slot .results button:hover { border-color: var(--primary); }
.slot .results img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* trial editor: arranging picture positions */
.arrange { border: 2px dashed var(--line); border-radius: var(--radius); padding: 12px; }
.arrange-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.arrange-head h3 { margin: 0; }
.arrange-status { font-weight: 600; color: var(--muted); }
.arrange-status.fixed { color: var(--primary); }
.arrange-grid {
  display: grid; grid-template-columns: repeat(var(--cols, 2), 1fr); gap: 10px;
  max-width: calc(var(--cols, 2) * 150px); margin-top: 8px;
}
.arr-tile {
  position: relative; aspect-ratio: 1; border: 4px solid var(--choice-border); border-radius: 12px; overflow: hidden;
  background: var(--surface-2); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
  display: flex; align-items: center; justify-content: center; transition: box-shadow .1s;
}
.arr-tile.correct { border-color: var(--right); }
.arr-tile img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.arr-tile .arr-empty { color: var(--muted); font-size: .8rem; }
.arr-tile .arr-label {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 6px; font-size: .75rem; font-weight: 600;
  background: #000a; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.arr-tile.dragging { cursor: grabbing; z-index: 5; pointer-events: none; box-shadow: 0 10px 24px #0005; opacity: .9; }
.arr-tile.drop-target { box-shadow: 0 0 0 4px var(--accent); }
.arr-tile.selected { box-shadow: 0 0 0 4px var(--accent); transform: scale(.95); }

/* ---------- run (the kid-facing screen) ---------- */
body.learner-mode .module-head { display: none; }
.stage-top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 6px 8px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); border-radius: var(--radius); border: 1px solid var(--line);
}
.stage-top .grow { flex: 1; min-width: 0; }
.stage-top button { padding: 6px 10px; }
.stage-progress { font-weight: 700; padding: 0 4px; }
.stage-theme, .board-picker { flex-direction: row; align-items: center; gap: 4px; font-weight: 500; }
.stage-theme select, .board-picker select { padding: 5px 8px; font-size: .9rem; }
@media (max-width: 820px) { .stage-top button span { display: none; } }
.sd {
  text-align: center; font-size: clamp(1.8rem, 4.5vw, 2.8rem); margin: 10px 0 12px;
  font-family: var(--font-display); color: var(--sd-ink); font-weight: 700;
}
[data-theme="superhero"] .sd { font-weight: 400; letter-spacing: 2px; -webkit-text-stroke: 1px #1a1a1a; text-shadow: 3px 3px 0 #ffd43b; }
[data-theme="space"] .sd { text-shadow: 0 0 16px #ffd43b88; }
/* The field fits the screen: as wide as allowed, but never taller than the space left under the
   session bar, instruction and token board (so all pictures are visible on an iPad without scrolling). */
.field {
  --stage-chrome: 250px;
  /* Rows of --cols pictures; a last row that isn't full is centered (e.g. 5 pictures as 3 + 2). */
  display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; margin: 0 auto;
  max-width: min(calc(var(--cols, 2) * 520px), calc((100vh - var(--stage-chrome)) / var(--rows, 2) * var(--cols, 2)));
  max-width: min(calc(var(--cols, 2) * 520px), calc((100dvh - var(--stage-chrome)) / var(--rows, 2) * var(--cols, 2)));
}
#runStage.has-board .field { --stage-chrome: 345px; }
.field > .choice { width: calc((100% - 16px * (var(--cols, 2) - 1)) / var(--cols, 2)); }
.goals-dialog { width: min(680px, 100%); max-height: 85vh; overflow-y: auto; }
.goals-dialog details.goals { border: none; box-shadow: none; padding: 0; margin: 0; }
.choice {
  padding: 0; border: 6px solid var(--choice-border); border-radius: var(--choice-radius); overflow: hidden;
  aspect-ratio: 1; background: #fff; box-shadow: var(--choice-shadow);
  transition: transform .12s, box-shadow .12s;
}
.choice:hover { transform: translateY(-3px); }
.choice:active { transform: scale(.96); }
.choice img { width: 100%; height: 100%; object-fit: cover; display: block; }
.choice.right { border-color: var(--right); box-shadow: 0 0 0 6px color-mix(in srgb, var(--right) 40%, transparent); animation: wiggle .5s; }
/* A quick press on every tap (touchscreens don't always show :active). Wrong picks get only this. */
.choice.pressed:not(.right) { animation: press .18s ease-out; }
@keyframes press {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(.95); }
}
@keyframes wiggle {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-3deg) scale(1.04); }
  75% { transform: rotate(3deg) scale(1.04); }
}
.controls {
  display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: flex-end;
  max-width: 900px; margin: 14px auto 0;
}
.prompt-levels { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.prompt-levels button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.prompt-levels button.active[data-prompt="I"] { background: var(--right); border-color: var(--right); }

fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; margin: 0; }
legend { font-weight: 700; padding: 0 6px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }

/* celebration */
.reward {
  position: fixed; inset: 0; z-index: 10; isolation: isolate;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--reward-ink); background: var(--reward-bg);
  font-family: var(--font-display); text-align: center;
  animation: pop 1.1s ease-out forwards; pointer-events: none;
}
.reward .word { font-size: clamp(3.5rem, 12vw, 7rem); line-height: 1; }
.reward .praise { font-size: clamp(2rem, 6vw, 3.2rem); font-weight: 700; }
.reward .word:empty { display: none; }
[data-theme="superhero"] .reward .word { -webkit-text-stroke: 3px #1a1a1a; letter-spacing: 3px; }
[data-theme="superhero"] .reward .praise { font-weight: 400; letter-spacing: 1px; color: #1a1a1a; }
/* Comic-book starburst behind the text */
.reward::before {
  content: ""; position: absolute; z-index: -1; width: min(80vw, 560px); aspect-ratio: 1; background: var(--burst);
  clip-path: polygon(50% 0%, 61% 25%, 88% 12%, 77% 39%, 100% 50%, 77% 61%, 88% 88%, 61% 75%, 50% 100%, 39% 75%, 12% 88%, 23% 61%, 0% 50%, 23% 39%, 12% 12%, 39% 25%);
}
@keyframes pop {
  0% { opacity: 0; transform: scale(.4) rotate(-8deg); }
  25% { opacity: 1; transform: scale(1.12) rotate(2deg); }
  45% { transform: scale(1) rotate(0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}
.confetti {
  position: fixed; top: -60px; z-index: 11; font-size: 2.4rem; pointer-events: none;
  animation: fall var(--dur, 1.4s) ease-in var(--delay, 0s) forwards;
}
@keyframes fall {
  to { transform: translate(var(--drift, 0), 110vh) rotate(var(--spin, 360deg)); opacity: .8; }
}

/* data */
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 10px; overflow: hidden; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); font-size: .9rem; }
th { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

.spinner {
  width: 28px; height: 28px; border: 3px solid var(--control-border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .confetti { display: none; }
  .choice.right { animation: none; }
}

/* small icon-only buttons */
button.icon-btn { padding: 6px 8px; }
button.icon-btn .icon { pointer-events: none; }
.page-head .section-title { margin: 0; }
.page-head:has(.section-title) { margin-top: 28px; }

/* Matching: the sample card centered above the field (the field sizes itself to the space left below it). */
.match-layout { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.match-layout .field { width: 100%; margin: 0; }
.sample-zone { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: none; }
.sample-card {
  width: 150px; aspect-ratio: 1; border-radius: var(--choice-radius); overflow: hidden; /* set by fitField() in run.js */
  border: 6px solid var(--accent); background: #fff; box-shadow: var(--choice-shadow), 0 0 0 6px color-mix(in srgb, var(--accent) 25%, transparent);
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; position: relative; z-index: 3;
}
.sample-card img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.sample-card.dragging { cursor: grabbing; z-index: 30; box-shadow: 0 18px 40px #0005; }
.sample-card.returning { transition: transform .32s cubic-bezier(.3, 1.3, .5, 1); }
.sample-card.matched { pointer-events: none; }
.choice.drop-over { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 45%, transparent); transform: scale(1.03); }
#trialStage:has(.match-layout) .field { --stage-chrome: 520px; }
#runStage.has-board #trialStage:has(.match-layout) .field { --stage-chrome: 615px; }

/* The learner's theme picker on the Run screen */
.theme-choice { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 12px; background: var(--surface-2); }
.theme-choice-title { font-family: "Fredoka", var(--font-body); font-weight: 700; font-size: 1.25rem; color: var(--ink); }
.theme-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.theme-tile {
  flex-direction: column; gap: 6px; padding: 12px 8px 10px; border-radius: 14px; border: 3px solid transparent;
  background: linear-gradient(135deg, var(--s1) 0 55%, var(--s2) 55% 80%, var(--s3) 80%); color: #13222b;
  font-family: "Fredoka", var(--font-body); font-weight: 600; box-shadow: 0 2px 6px #13222b1f; transition: transform .12s;
}
.theme-tile:hover { transform: translateY(-2px); background: linear-gradient(135deg, var(--s1) 0 55%, var(--s2) 55% 80%, var(--s3) 80%); }
.theme-tile-icon { font-size: 2.2rem; line-height: 1; filter: drop-shadow(0 2px 2px #0003); }
.theme-tile-name { background: #ffffffe6; padding: 2px 10px; border-radius: 99px; font-size: .9rem; }
.theme-tile.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft), 0 2px 6px #13222b1f; transform: translateY(-2px); }
.theme-tile.active .theme-tile-name::before { content: "✓ "; color: var(--primary); }

/* Light / Dark / Auto switch (sidebar) */
.ui-switch { display: flex; gap: 2px; padding: 3px; margin: 0 12px 6px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); }
.ui-switch button { flex: 1; border: none; background: none; padding: 5px 0; border-radius: 6px; color: var(--muted); }
.ui-switch button:hover { background: none; color: var(--ink); }
.ui-switch button.active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 2px color-mix(in srgb, var(--shadow) 20%, transparent); }
@media (max-width: 900px) { .ui-switch { margin: 0 6px; } }

/* Arty, the guide (clinician screens only) */
.welcome-guide { display: flex; align-items: flex-end; justify-content: center; gap: 4px; margin: 18px auto 0; flex-wrap: wrap; }
.welcome-guide .guide { flex: none; }
.welcome-bubble {
  position: relative; max-width: 300px; margin-bottom: 70px; padding: 14px 16px; text-align: left; line-height: 1.5;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--card-shadow);
}
.welcome-bubble::before {
  content: ""; position: absolute; left: -9px; bottom: 22px; width: 16px; height: 16px; background: var(--surface);
  border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); transform: rotate(45deg);
}
.welcome-bubble strong { display: block; color: var(--primary); }
.guide-button {
  position: fixed; z-index: 63; padding: 0; border: none; background: none; cursor: pointer;
  right: max(14px, env(safe-area-inset-right, 0px)); bottom: max(10px, env(safe-area-inset-bottom, 0px));
  filter: drop-shadow(0 4px 8px color-mix(in srgb, var(--shadow) 25%, transparent)); transition: transform .15s;
}
.guide-button:hover { background: none; transform: translateY(-3px); }
.guide-button:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 12px; }
.guide-button .guide { display: block; pointer-events: none; }
.guide-button .guide-wave-arm { transform-origin: 174px 132px; animation: guide-wave 2.4s ease-in-out infinite; }
@keyframes guide-wave { 0%, 60%, 100% { transform: rotate(0); } 70% { transform: rotate(-14deg); } 80% { transform: rotate(8deg); } 90% { transform: rotate(-10deg); } }
@media (prefers-reduced-motion: reduce) { .guide-button .guide-wave-arm { animation: none; } }
.guide-button-hint {
  position: absolute; right: 54px; top: 2px; white-space: nowrap; padding: 6px 10px; border-radius: 12px; font-size: .8rem; font-weight: 700;
  background: var(--primary); color: var(--on-primary); box-shadow: var(--card-shadow);
}
body.logged-out .guide-button, body.learner-mode .guide-button, body.learner-mode .guide-panel, body.learner-mode .guide-spot { display: none; }
.guide-panel {
  position: fixed; z-index: 62; width: min(340px, calc(100vw - 32px));
  right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(110px + env(safe-area-inset-bottom, 0px));
}
.guide-bubble {
  display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: 16px; line-height: 1.5;
  background: var(--surface); color: var(--ink); border: 2px solid var(--primary); box-shadow: 0 10px 30px color-mix(in srgb, var(--shadow) 25%, transparent);
}
.guide-bubble strong { color: var(--primary); font-size: 1.02rem; }
.guide-title { display: flex; align-items: center; gap: 8px; }
.guide-title .logo-mark { flex: none; }
.guide-bubble p { margin: 0; }
.guide-count { font-size: .75rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.guide-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.guide-actions button { padding: 6px 12px; }
.guide-spot {
  position: fixed; z-index: 61; pointer-events: none; border-radius: 12px; border: 3px solid var(--primary);
  box-shadow: 0 0 0 9999px var(--overlay); transition: all .2s ease;
}
@media print { .guide-button, .guide-panel, .guide-spot { display: none !important; } }

/* ---------- visual timers ---------- */
.vtimer {
  position: relative; overflow: hidden; container-type: size; color: #1d1d1f; font-family: var(--timer-font);
  background: var(--bg-img, none) center / cover no-repeat, var(--bg);
}
.vtimer-visual { position: absolute; inset: 0; --p: 0; }
.vtimer-time {
  position: absolute; left: 0; right: 0; top: 6cqh; text-align: center; font-size: 17cqmin; line-height: 1; font-weight: 700;
  font-variant-numeric: tabular-nums; z-index: 2; color: #1d1d1f;
  text-shadow: 0 0 .06em #fff, 0 0 .12em #fff, 0 .04em .14em #fff;
}
.vtimer.finished .vtimer-time { display: none; }
.vtimer.finished .vtimer-visual { opacity: .35; filter: blur(2px); transition: opacity .4s, filter .4s; }
.vtimer-done {
  position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3cqmin;
  animation: vtimer-pop .5s cubic-bezier(.2, 1.6, .4, 1);
}
.vtimer-done img { width: 42cqmin; height: 42cqmin; object-fit: cover; border-radius: 6cqmin; border: 1.2cqmin solid #fff; box-shadow: 0 2cqmin 6cqmin #0004; background: #fff; }
.vtimer-done-emoji { font-size: 30cqmin; line-height: 1; }
.vtimer-done strong { font-size: 9cqmin; padding: 1cqmin 5cqmin; border-radius: 99px; background: #fff; box-shadow: 0 1cqmin 4cqmin #0003; }
@keyframes vtimer-pop { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.vtimer-controls {
  position: absolute; z-index: 5; left: 50%; transform: translateX(-50%); bottom: max(3cqh, env(safe-area-inset-bottom, 0px));
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 8px; border-radius: 16px;
  background: #ffffffd9; box-shadow: 0 4px 16px #0002; font-family: var(--font-body);
}
.vtimer-controls button { color: #1d1d1f; background: #fff; border-color: #cfd8dd; }
.vtimer-controls button.primary { background: #0f766e; color: #fff; border-color: #0f766e; }

/* Time Timer disc */
.pie { position: absolute; left: 50%; top: 56%; width: 66cqmin; height: 66cqmin; transform: translate(-50%, -50%); }
.pie-face { fill: #fff; stroke: #d6dde1; stroke-width: 4; }
.pie-wedge { fill: var(--fill); }
.pie-tick { stroke: #4a555b; stroke-width: 3; stroke-linecap: round; }
.pie-knob { fill: #4a555b; }

/* Fluid fill */
.fluid { position: absolute; inset: 0; }
.fluid-body { position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--p) * 100%); background: var(--fill); transition: height .3s linear; }
.fluid-wave { position: absolute; left: 0; bottom: 100%; width: 200%; height: 7cqmin; fill: var(--fill); margin-bottom: -1px; animation: fluid-wave 3s linear infinite; }
@keyframes fluid-wave { to { transform: translateX(-50%); } }
.bubble { position: absolute; left: var(--x); bottom: 0; width: 3cqmin; height: 3cqmin; border-radius: 50%; background: #ffffff80; opacity: 0; }
.vtimer.running .bubble { animation: bubble-rise var(--d) ease-in infinite; }
@keyframes bubble-rise { 0% { transform: translateY(0); opacity: 0; } 15% { opacity: 1; } 100% { transform: translateY(-60cqh); opacity: 0; } }

/* Color fill */
.colorfill { position: absolute; inset: 0; background: var(--fill); clip-path: circle(calc(var(--p) * 82%) at 50% 56%); }
.vtimer.building .colorfill { animation: color-breathe 1.6s ease-in-out infinite; }
@keyframes color-breathe { 50% { filter: brightness(1.12) saturate(1.15); } }

/* Race car */
.race { position: absolute; left: 6%; right: 6%; top: 50%; height: 34cqh; }
.race-track { position: absolute; left: 0; right: 0; bottom: 0; height: 18cqmin; background: #4b5257; border-radius: 3cqmin; border-top: 1.2cqmin solid #e9ecef; border-bottom: 1.2cqmin solid #e9ecef; }
.race-line { position: absolute; left: 3%; right: 12%; top: 50%; border-top: 1cqmin dashed #f5d90a; transform: translateY(-50%); }
.race-flag {
  position: absolute; right: 0; top: -1.2cqmin; bottom: -1.2cqmin; width: 9cqmin;
  background: repeating-conic-gradient(#111 0 25%, #fff 0 50%) 0 0 / 4.5cqmin 4.5cqmin; border-radius: 0 3cqmin 3cqmin 0;
}
.race-car-wrap { position: absolute; bottom: 9cqmin; left: calc(var(--p) * (100% - 30cqmin)); width: 30cqmin; transition: left .3s linear; }
.race-car { width: 100%; display: block; }
.vtimer.running.building .race-car { animation: car-bump .35s ease-in-out infinite; }
@keyframes car-bump { 50% { transform: translateY(-.8cqmin) rotate(-1deg); } }

/* Balloon pump */
.balloon-scene { position: absolute; left: 6%; right: 6%; bottom: 13cqh; height: 66cqh; width: 88%; }
.vtimer.running.building .pump-handle { animation: pump-push .7s ease-in-out infinite; }
@keyframes pump-push { 50% { transform: translateY(34px); } }
.balloon-g { transform-box: fill-box; transform-origin: 50% 100%; transform: scale(calc(.18 + var(--p) * .82)); transition: transform .3s linear; }
.vtimer.running.building .balloon-g { animation: balloon-wobble 1.4s ease-in-out infinite; }
@keyframes balloon-wobble { 50% { rotate: 3deg; } }
.vtimer.popped .balloon-g { animation: balloon-pop .25s ease-out forwards; }
@keyframes balloon-pop { to { transform: scale(1.35); opacity: 0; } }

/* full screen and previews */
.timer-overlay { position: fixed; inset: 0; z-index: 90; }
.timer-overlay .vtimer { position: absolute; inset: 0; }
.timer-preview .vtimer { aspect-ratio: 4 / 3; border-radius: var(--radius); border: 1px solid var(--line); }
.timer-preview .vtimer-controls button { padding: 5px 9px; font-size: .82rem; }
.timer-thumb { width: 168px; flex: none; }
.timer-thumb .vtimer { aspect-ratio: 4 / 3; border-radius: 10px; border: 1px solid var(--line); }
.timer-thumb .vtimer-done { display: none; }
@media (prefers-reduced-motion: reduce) {
  .fluid-wave, .vtimer.running .bubble, .vtimer.building .colorfill, .vtimer.running.building .race-car,
  .vtimer.running.building .pump-handle, .vtimer.running.building .balloon-g { animation: none; }
}

/* the Timers page */
.timer-list { display: flex; flex-direction: column; gap: 12px; }
.timer-item {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--card-shadow);
}
.timer-meta { flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 2px; }
.timer-form-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.timer-fields { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.timer-preview-col { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.timer-preview-col h3 { margin: 0; }
@media (max-width: 900px) { .timer-form-grid { grid-template-columns: minmax(0, 1fr); } .timer-preview-col { position: static; order: -1; } }
.style-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.style-tile {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; font-weight: 600; font-size: .85rem;
  border: 2px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 12px;
}
.style-tile.active { border-color: var(--primary); background: var(--primary-soft); }
.style-emoji { font-size: 1.6rem; line-height: 1; }
.timer-form input[type="color"] { padding: 2px; height: 40px; min-width: 70px; }
.field-btn { display: flex; align-items: flex-end; }
.timer-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.timer-picker { flex-direction: row; align-items: center; gap: 4px; font-weight: 500; }
.timer-picker select { padding: 5px 8px; font-size: .9rem; }
.timer-slots .slot .preview { aspect-ratio: auto; height: 150px; }
.timer-preview .vtimer-controls { gap: 4px; padding: 4px; border-radius: 10px; bottom: 6px; }
.timer-preview [data-timer="add"], .timer-preview [data-timer="close"] { display: none; }

/* The CreateABA wordmark: "Create" in rainbow paint colors (deeper shades on light screens, brighter in dark mode). */
:root { --paint-1: #e03131; --paint-2: #e8590c; --paint-3: #e09f00; --paint-4: #2b8a3e; --paint-5: #1c7ed6; --paint-6: #7048e8; }
:root[data-ui="dark"] { --paint-1: #ff6b6b; --paint-2: #ffa94d; --paint-3: #ffd43b; --paint-4: #69db7c; --paint-5: #4dabf7; --paint-6: #b197fc; }
@media (prefers-color-scheme: dark) {
  :root[data-ui="auto"] { --paint-1: #ff6b6b; --paint-2: #ffa94d; --paint-3: #ffd43b; --paint-4: #69db7c; --paint-5: #4dabf7; --paint-6: #b197fc; }
}
.brand-name .brand-create span { color: var(--paint-1); }
.brand-name .brand-create .paint-2 { color: var(--paint-2); }
.brand-name .brand-create .paint-3 { color: var(--paint-3); }
.brand-name .brand-create .paint-4 { color: var(--paint-4); }
.brand-name .brand-create .paint-5 { color: var(--paint-5); }
.brand-name .brand-create .paint-6 { color: var(--paint-6); }
.brand-name .brand-aba { color: var(--ink); letter-spacing: .02em; }

/* ---------- visual schedules ---------- */
.sched { display: flex; flex-wrap: wrap; justify-content: center; align-items: stretch; gap: 14px; --card: clamp(110px, calc((100% - 14px * (var(--n) - 1)) / var(--n)), 240px); }
.sched-arrows, .sched-firstThen { gap: 6px; }
.sched-step {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; width: var(--card); padding: 10px;
  background: #fff; color: #1d1d1f; border: 3px solid #dfe5e8; border-radius: 18px; font: inherit; text-align: center;
  box-shadow: 0 2px 8px #13222b14;
}
button.sched-step { cursor: pointer; }
button.sched-step:hover { background: #fff; border-color: #b9c4c9; }
.sched-head { font-family: "Fredoka", var(--font-body); font-weight: 700; font-size: 1.15rem; color: #0f766e; }
.sched-firstThen .sched-step:first-child .sched-head { color: #c2410c; }
.sched-pic { position: relative; width: 100%; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #f1f4f5; display: grid; place-items: center; }
.sched-pic img { width: 100%; height: 100%; object-fit: cover; }
.sched-empty { font-size: 2.4rem; opacity: .4; }
.sched-label { font-family: "Fredoka", var(--font-body); font-weight: 600; font-size: 1.05rem; line-height: 1.2; }
.sched-arrow { align-self: center; font-size: 2.4rem; font-weight: 700; color: #4a555b; line-height: 1; }
.sched-step.done { opacity: .55; border-color: #2f9e44; }
.sched-step.done .sched-pic img { filter: grayscale(.6); }
.sched-check {
  position: absolute; inset: 0; display: grid; place-items: center; font-size: 4.5rem; font-weight: 800; color: #fff;
  background: #2f9e44b3; text-shadow: 0 2px 6px #0004;
}
.sched-step.now { border-color: #0f766e; box-shadow: 0 0 0 5px #0f766e33, 0 4px 14px #13222b22; transform: translateY(-4px); }
.sched-now {
  position: absolute; top: -12px; right: -8px; padding: 3px 10px; border-radius: 99px; font-size: .8rem; font-weight: 800;
  background: #0f766e; color: #fff; box-shadow: 0 2px 6px #0003;
}
/* top to bottom: each step is a row (picture, then words) */
.sched-column { flex-direction: column; align-items: center; flex-wrap: nowrap; gap: 8px; }
.sched-column .sched-step { flex-direction: row; width: min(560px, 100%); text-align: left; padding: 8px 12px; }
.sched-column .sched-pic { width: clamp(64px, 14vh, 130px); flex: none; }
.sched-column .sched-head { min-width: 4.5em; }
.sched-column .sched-label { font-size: 1.3rem; }
.sched-column .sched-check { font-size: 2.6rem; }

.schedule-overlay { position: fixed; inset: 0; z-index: 90; overflow: auto; background: #fff8e7; }
.schedule-stage { min-height: 100%; display: flex; flex-direction: column; gap: 18px; padding: 24px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); }
.schedule-title { margin: 0; text-align: center; font-family: "Fredoka", var(--font-body); font-size: clamp(1.5rem, 4vw, 2.4rem); color: #1d1d1f; }
.schedule-body { flex: 1; display: flex; align-items: center; justify-content: center; }
.schedule-overlay .sched { width: 100%; --card: clamp(120px, calc((100% - 14px * (var(--n) - 1)) / var(--n)), 300px); }
.schedule-overlay .sched-arrows, .schedule-overlay .sched-firstThen { --card: clamp(110px, calc((100% - 56px * (var(--n) - 1)) / var(--n)), 300px); }
.schedule-done { text-align: center; font-family: "Fredoka", var(--font-body); font-size: 2rem; font-weight: 700; color: #2f9e44; animation: vtimer-pop .5s cubic-bezier(.2, 1.6, .4, 1); }
.schedule-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.schedule-controls button { color: #1d1d1f; background: #fff; border-color: #cfd8dd; }

.schedule-list { display: flex; flex-direction: column; gap: 14px; }
.schedule-item { padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--card-shadow); display: flex; flex-direction: column; gap: 12px; }
.schedule-item-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.schedule-mini, .schedule-preview { padding: 14px; border-radius: 12px; background: #fff8e7; overflow-x: auto; }
.schedule-mini .sched { --card: clamp(80px, calc((100% - 14px * (var(--n) - 1)) / var(--n)), 140px); }
.schedule-mini .sched-head, .schedule-mini .sched-label { font-size: .85rem; }
.schedule-mini .sched-arrow { font-size: 1.5rem; }
.template-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.schedule-steps { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; align-items: start; }
.schedule-steps .slot .preview { aspect-ratio: auto; height: 140px; }
.step-wrap { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.step-move { display: flex; justify-content: space-between; }
.step-move button { padding: 4px 8px; font-size: .8rem; }
.add-step { min-height: 140px; border: 2px dashed var(--control-border); background: none; color: var(--muted); font-weight: 600; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.add-step:hover { border-color: var(--primary); color: var(--primary); background: none; }
.sched-column .sched-step { justify-content: flex-start; gap: 14px; }
.sched-column .sched-now { top: 50%; right: 12px; transform: translateY(-50%); }
/* Full-screen list: shrink the pictures so every step fits on screen (title and buttons take ~190px). */
.schedule-overlay .sched-column { gap: 6px; }
.schedule-overlay .sched-column .sched-step { padding: 4px 12px; }
.schedule-overlay .sched-column .sched-pic { width: clamp(48px, calc((100vh - 200px) / var(--n) - 20px), 130px); }

/* a token board shown on its own (from a learner's page) */
.board-overlay { position: fixed; inset: 0; z-index: 90; overflow: auto; background: #fff8e7; }
.board-overlay-stage { min-height: 100%; display: flex; flex-direction: column; justify-content: center; gap: 18px; padding: 24px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); }
.board-overlay-board { width: min(1000px, 100%); margin: 0 auto; }

/* a learner's schedules, timers and token boards */
.supports-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.support-card {
  display: flex; flex-direction: column; gap: 10px; padding: 12px; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--card-shadow);
}
.support-card-head { display: flex; align-items: center; gap: 8px; }
.support-card-head strong { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.support-kind { font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.support-preview { border-radius: 10px; overflow: hidden; background: #fff8e7; padding: 8px; }
.support-preview .sched { --card: clamp(56px, calc((100% - 8px * (var(--n) - 1)) / var(--n)), 110px); gap: 8px; }
.support-preview .sched-step { padding: 4px; gap: 4px; border-width: 2px; border-radius: 10px; }
.support-preview .sched-head, .support-preview .sched-label { font-size: .7rem; }
.support-preview .sched-arrow { font-size: 1.1rem; }
.support-preview .vtimer { aspect-ratio: 16 / 9; border-radius: 8px; }
.support-preview .token-board { transform: scale(.9); transform-origin: top left; }
.assign-panel fieldset { display: flex; flex-direction: column; gap: 6px; }
.assign-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.learner-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.learner-chip { padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--primary-soft); color: var(--primary); text-decoration: none; }

/* privacy & security */
.notice { padding: 10px 12px; border-radius: 10px; background: var(--note-bg); color: var(--note-ink); border: 1px solid var(--note-border); font-size: .92rem; }
.welcome .notice { max-width: 520px; margin: 16px auto 0; text-align: left; }
.idle-warning {
  position: fixed; z-index: 100; left: 50%; top: max(16px, env(safe-area-inset-top, 0px)); transform: translateX(-50%);
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; width: min(560px, calc(100vw - 32px)); padding: 14px 16px;
  background: var(--surface); color: var(--ink); border: 2px solid var(--note-border); border-radius: 14px;
  box-shadow: 0 10px 30px color-mix(in srgb, var(--shadow) 30%, transparent);
}
.idle-warning .idle-text { flex: 1; min-width: 200px; }
.clinic-row { align-items: flex-end; }
.security-row label.inline { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 500; }
.audit-table td { vertical-align: top; }
.audit-table tr.refused td { background: color-mix(in srgb, var(--danger) 7%, transparent); }
.refused-tag { font-size: .72rem; font-weight: 700; padding: 1px 6px; border-radius: 99px; color: var(--on-danger); background: var(--danger); }

/* ---------- looks (clinician screens; see shared/looks.js) ---------- */
/* A faint pattern of the look's pictures (or paint dots) behind the page. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: var(--look-pattern, none); background-size: 300px 300px; opacity: var(--pattern-opacity, 0);
}
.app-shell { position: relative; z-index: 1; }
body.learner-mode::before { display: none; }
@media print { body::before { display: none; } }
/* Friendlier headings for the CreateABA look, themes and seasons. */
.page-title, .card > h2, .module-head h2, .section-title, .auth-card h2 { font-family: var(--font-title, var(--font-body)); }
:root:not([data-look="teal"]):not([data-look="purple"]):not([data-look="blue"]):not([data-look="pink"]):not([data-look="orange"]):not([data-look="green"]):not([data-look="red"]):not([data-look="slate"]) .page-title { font-weight: 600; letter-spacing: 0; }
/* The CreateABA look: sidebar icons in paint colors and a rainbow stripe across the top of each card. */
html.look-rainbow .sidebar > .nav-link:nth-of-type(6n + 1) .icon { color: var(--paint-1); }
html.look-rainbow .sidebar > .nav-link:nth-of-type(6n + 2) .icon { color: var(--paint-2); }
html.look-rainbow .sidebar > .nav-link:nth-of-type(6n + 3) .icon { color: var(--paint-3); }
html.look-rainbow .sidebar > .nav-link:nth-of-type(6n + 4) .icon { color: var(--paint-4); }
html.look-rainbow .sidebar > .nav-link:nth-of-type(6n + 5) .icon { color: var(--paint-5); }
html.look-rainbow .sidebar > .nav-link:nth-of-type(6n + 6) .icon { color: var(--paint-6); }
html.look-rainbow .card {
  background: linear-gradient(90deg, var(--paint-1), var(--paint-2), var(--paint-3), var(--paint-4), var(--paint-5), var(--paint-6)) top / 100% 4px no-repeat, var(--surface);
}

/* The Appearance picker */
.look-panel {
  position: fixed; left: 248px; bottom: 16px; z-index: 40; width: min(460px, calc(100vw - 32px));
  max-height: min(78vh, 680px); overflow-y: auto; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 16px 40px #13222b33; padding: 10px 12px 14px;
}
@media (max-width: 900px) { .look-panel { left: auto; right: 12px; top: 60px; bottom: auto; } }
.look-panel h3 { margin: 12px 4px 6px; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.look-panel > .hint { margin: 0 4px; }
.look-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.look-tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 6px; font-size: .8rem; font-weight: 600;
  border: 2px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink);
}
.look-tile:hover { background: var(--surface-2); }
.look-tile.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.look-swatch {
  width: 100%; height: 44px; border-radius: 8px; position: relative; overflow: hidden;
  background: var(--sw-bg); border: 1px solid #0000001a;
}
.look-swatch::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 12px; background: var(--sw); }
.look-swatch-art { position: absolute; inset: 4px 4px 14px; display: flex; align-items: center; justify-content: center; gap: 2px; font-size: 1.05rem; line-height: 1; }
.look-swatch-art.dots i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ---------- Sorting: category bins across the top, the pile of cards below ---------- */
.sort-layout { display: flex; flex-direction: column; align-items: center; gap: 16px; width: 100%; }
.sort-bins { display: flex; justify-content: center; gap: 14px; width: 100%; }
.sort-bin {
  flex: 1 1 0; max-width: 260px; min-width: 0; display: flex; flex-direction: column; gap: 8px; padding: 8px;
  border-radius: var(--choice-radius); background: #ffffffcc; border: 4px dashed var(--choice-border); transition: transform .12s, box-shadow .12s;
}
.sort-bin.drop-over { border-style: solid; border-color: var(--accent); transform: scale(1.03); box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 35%, transparent); }
.sort-bin-head {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; border-radius: 12px; background: #fff;
  border: 4px solid var(--choice-border); box-shadow: var(--choice-shadow); font-weight: 700; font-size: 1.05rem; color: #1d1d1f; text-align: center;
}
.sort-bin-head img { width: 100%; max-width: 13vh; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }
/* A fixed-size drop area (3 x 3 cards), so the layout doesn't move as cards land. */
.sort-bin-drop {
  height: 23vh; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: calc((100% - 12px) / 3);
  gap: 6px; align-content: start; justify-items: center;
}
.sort-placed {
  height: 100%; aspect-ratio: 1; max-width: 100%; border-radius: 8px; overflow: hidden; background: #fff; border: 3px solid #fff; box-shadow: 0 1px 4px #0003;
  cursor: grab; touch-action: none; user-select: none; position: relative; z-index: 2;
}
.sort-placed img, .sort-card img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.sort-pile { display: flex; align-items: center; justify-content: center; gap: 18px; }
.sort-pile-stack { position: relative; }
.sort-card {
  width: clamp(130px, 27vh, 260px); aspect-ratio: 1; border-radius: var(--choice-radius); overflow: hidden; background: #fff;
  border: 6px solid var(--accent); box-shadow: var(--choice-shadow), 0 0 0 6px color-mix(in srgb, var(--accent) 25%, transparent);
  cursor: grab; touch-action: none; user-select: none; position: relative; z-index: 3;
}
.sort-card.more { box-shadow: 8px 8px 0 -2px #fff, 8px 8px 0 1px var(--choice-border), 0 0 0 6px color-mix(in srgb, var(--accent) 25%, transparent); }
.sort-card.dragging, .sort-placed.dragging { cursor: grabbing; z-index: 30; box-shadow: 0 18px 40px #0005; }
.sort-card.returning, .sort-placed.returning { transition: transform .32s cubic-bezier(.3, 1.3, .5, 1); }
.sort-done { width: clamp(130px, 27vh, 260px); aspect-ratio: 1; display: grid; place-items: center; font-size: 4rem; color: var(--right); border-radius: var(--choice-radius); border: 4px dashed var(--choice-border); }
.sort-pile-side { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.sort-count { font-weight: 700; color: var(--ink); }
.sort-reset { padding: 5px 10px; font-size: .85rem; }

/* Sorting editor: one column per category */
.sort-edit { display: flex; flex-direction: column; gap: 14px; }
.sort-edit-bin { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.sort-edit-bin.target { border: 2px solid var(--right); }
.sort-edit-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sort-edit .slot .preview { aspect-ratio: auto; height: 120px; }
/* Landscape (laptops, iPad sideways): the pile sits to the right of the bins, so everything fits without scrolling. */
@media (orientation: landscape) {
  .sort-layout { flex-direction: row; align-items: flex-start; justify-content: center; }
  .sort-bins { flex: 1; max-width: 900px; }
  .sort-bin-drop { height: 28vh; }
  .sort-pile { flex-direction: column; align-self: center; }
  .sort-pile-side { align-items: center; }
}

/* ---------- Expressive ID / Tacts ---------- */
.tact-pic { cursor: default; }
.tact-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.trial-controls:empty { display: none; }
.tact-score { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.tact-answer { font-size: .95rem; color: var(--ink); background: #ffffffcc; padding: 2px 10px; border-radius: 99px; }
.tact-buttons { display: flex; gap: 10px; }
.tact-btn { font-size: 1.05rem; font-weight: 700; padding: 12px 20px; border-radius: 12px; border: 3px solid #cfd8dd; background: #fff; color: #1d1d1f; }
.tact-btn.yes.active { background: #2f9e44; border-color: #2f9e44; color: #fff; }
.tact-btn.no.active { background: #e03131; border-color: #e03131; color: #fff; }
.sd-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 10px; border-radius: 99px; font-size: .82rem; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); }
.chip.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.tact-slot { max-width: 320px; }
.tact-slot .slot .preview { aspect-ratio: auto; height: 200px; }

/* Prompt levels chooser (goal Settings) */
.prompt-choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 4px 12px; }
.prompt-choice { align-items: center; }
.prompt-choice .icon-btn { padding: 2px 4px; margin-left: 2px; }
.add-prompt { align-items: center; margin-top: 8px; }
.add-prompt input { max-width: 240px; }
/* Intraverbals with no picture: the question, big */
.iv-card {
  display: flex; align-items: center; justify-content: center; text-align: center; margin: 2vh auto 0;
  width: min(900px, 100%); min-height: 52vh; padding: 24px; border-radius: 28px; background: #fff; color: #1d1d1f;
  border: 6px solid var(--choice-border); box-shadow: var(--choice-shadow);
  font-family: var(--font-display, var(--font-body)); font-size: clamp(2rem, 6vw, 4.2rem); line-height: 1.15; font-weight: 700;
}
.iv-question { grid-column: 1 / -1; }
.dialog-choices { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.dialog-choices button { width: 100%; justify-content: center; padding: 11px 14px; }
.save-choice { margin: 4px 0 8px; }
.save-choice .hint { font-weight: 400; }

/* Mixed sessions */
.mixed-goal { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.mixed-goal:last-of-type { border-bottom: none; }
.mixed-goal-head { display: flex; align-items: center; gap: 8px; }
.mixed-goal-head .module-icon { width: 30px; height: 30px; }
.mixed-goal-head .module-icon .icon { width: 17px; height: 17px; }
.mixed-options { margin: 4px 0; }

/* ---------- Sequencing Events / Pattern Sequencing: spaces in a row, cards below ---------- */
/* Card size from the whole row's width (container units, so spaces and cards are the same size everywhere). */
.order-layout { display: flex; flex-direction: column; align-items: center; gap: 4vh; width: 100%; container-type: inline-size;
  --cell: clamp(48px, calc((100cqw - 12px * (var(--count) - 1)) / var(--count)), min(24vh, 230px)); }
.order-slot { flex: none; }
.order-row, .order-pool { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; width: 100%; }
.order-item, .order-card, .order-space {
  width: var(--cell); aspect-ratio: 1; border-radius: 16px; overflow: hidden; display: grid; place-items: center; background: #fff;
}
.order-item.shown { border: 4px solid var(--choice-border); box-shadow: var(--choice-shadow); }
.order-slot { display: flex; flex-direction: column; align-items: center; gap: 6px; transition: transform .12s; }
.order-head { font-family: "Fredoka", var(--font-body); font-weight: 700; font-size: 1.1rem; color: #0f766e; }
.order-space { border: 4px dashed var(--choice-border); background: #ffffffaa; overflow: visible; }
.order-slot.drop-over .order-space { border-style: solid; border-color: var(--accent); box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 35%, transparent); }
.order-slot.drop-over { transform: scale(1.04); }
.order-card {
  border: 4px solid var(--accent); box-shadow: var(--choice-shadow); cursor: grab; touch-action: none; user-select: none; position: relative; z-index: 3;
}
.order-space .order-card { width: 100%; }
.order-card.ghost { visibility: hidden; }
.order-card.dragging { cursor: grabbing; z-index: 30; box-shadow: 0 18px 40px #0005; }
.order-card.returning { transition: transform .3s cubic-bezier(.3, 1.3, .5, 1); }
.order-card img, .order-item img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.order-shape { width: 78%; height: 78%; pointer-events: none; }
.order-empty-pic { font-size: 2rem; opacity: .4; }
.order-pool { padding-top: 2vh; border-top: 3px dotted #00000022; }

/* Pattern editor */
.pattern-preview { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px; border-radius: 12px; background: #fff8e7; --cell: 52px; }
.pattern-preview .order-item { border-width: 2px; border-radius: 10px; }
.pattern-preview .order-item.blank { border: 3px dashed #c9b88f; background: #fffdf6; }
.pattern-plus { margin: 0 4px 0 10px; }
.pattern-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.pattern-item { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.pattern-item-head { display: flex; align-items: center; justify-content: space-between; }
.pattern-item-preview { width: 44px; height: 44px; display: grid; place-items: center; }
.pattern-item-preview svg, .pattern-item-preview img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; align-self: flex-start; }
.seg button { border: none; border-radius: 0; padding: 5px 12px; background: var(--surface); color: var(--ink); }
.seg button.active { background: var(--primary); color: var(--on-primary); }
.settings-grid.tight { gap: 8px; }
.pattern-pic .slot .preview { aspect-ratio: auto; height: 110px; }
.thumb-shape { width: 52px; height: 52px; border-radius: 8px; border: 2px solid var(--line); background: #fff; display: grid; place-items: center; }
.thumb-shape.correct { border-color: var(--right); }
.thumb-shape svg { width: 80%; height: 80%; }

/* ---------- the opening animation (shared/intro.js) ---------- */
.intro {
  position: fixed; inset: 0; z-index: 200; overflow: hidden; display: grid; place-items: center; cursor: pointer;
  background: #fffdf8; --size: clamp(3.2rem, 13vw, 9.5rem);
}
.intro-strokes { position: absolute; inset: -5%; width: 110%; height: 110%; opacity: .9; }
.intro-strokes path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: intro-stroke .8s cubic-bezier(.55, .1, .3, 1) forwards; animation-delay: calc(var(--i) * .32s); }
.intro-strokes.js-driven path { animation: none; } /* painted frame by frame together with the brush */
@keyframes intro-stroke { to { stroke-dashoffset: 0; } }
.intro-word {
  position: relative; z-index: 2; display: flex; align-items: baseline; padding: .15em .45em .3em; border-radius: .35em;
  font-family: "Fredoka", "Inter", system-ui, sans-serif; font-weight: 700; font-size: var(--size); line-height: 1; letter-spacing: -.01em;
  background: #fffdf8; box-shadow: 0 .1em .5em #0000001f;
  animation: intro-card .55s 2.25s cubic-bezier(.2, 1.4, .4, 1) both;
}
@keyframes intro-card { from { transform: scale(.6) rotate(-4deg); opacity: 0; } to { transform: none; opacity: 1; } }
.intro-letter {
  position: relative; z-index: 0; display: inline-block; color: var(--c);
  animation: intro-splat .6s cubic-bezier(.2, 1.6, .4, 1) both; animation-delay: calc(2.6s + var(--i) * .16s);
}
@keyframes intro-splat {
  0% { transform: translateY(-.8em) scale(.3) rotate(-25deg); opacity: 0; }
  60% { transform: translateY(.05em) scale(1.18, .86) rotate(4deg); opacity: 1; }
  100% { transform: none; }
}
/* A paint drip running down from where each letter touches the bottom, ending in a bead; then a drop breaks off and falls. */
/* Starts just inside the letter's bottom edge and sits behind the letter, so only the part below the letter shows. */
.drip {
  position: absolute; z-index: -1; left: var(--dx); top: calc(var(--dy) - .035em); width: .085em; height: 0; transform: translateX(-50%);
  background: var(--c); border-radius: .04em .04em .05em .05em;
  animation: intro-drip 1s cubic-bezier(.5, 0, .7, .4) forwards; animation-delay: calc(3.2s + var(--i) * .16s);
}
.drip::after { /* the bead at the end of the drip */
  content: ""; position: absolute; left: 50%; bottom: -.05em; width: .14em; height: .14em; border-radius: 50%;
  transform: translateX(-50%); background: var(--c);
}
@keyframes intro-drip { to { height: calc(var(--len) + .14em); } }
.drop {
  position: absolute; left: 50%; top: calc(100% + .02em); width: .11em; height: .13em; transform: translateX(-50%);
  border-radius: 50% 50% 50% 50% / 60% 60% 42% 42%; background: var(--c); opacity: 0;
  animation: intro-drop .85s cubic-bezier(.45, 0, .9, .5) forwards; animation-delay: calc(4.25s + var(--i) * .16s);
}
@keyframes intro-drop {
  0% { opacity: 1; transform: translate(-50%, 0) scale(.6); }
  20% { opacity: 1; transform: translate(-50%, .04em) scale(1, 1.15); }
  100% { opacity: 0; transform: translate(-50%, 1.3em) scale(.9, 1.2); }
}
.intro-aba { color: #1d1d1f; margin-left: .04em; animation: intro-aba .55s 3.65s cubic-bezier(.2, 1.3, .4, 1) both; }
@keyframes intro-aba { from { transform: translateX(.6em); opacity: 0; } to { transform: none; opacity: 1; } }
.intro-arty { position: absolute; z-index: 3; right: max(6vw, 16px); bottom: 7vh; animation: intro-arty .6s 4s cubic-bezier(.2, 1.5, .4, 1) both; }
.intro-brush { filter: drop-shadow(0 6px 6px #0003); }
/* Arty jumps for joy (after popping in): squash, leap, land, again. */
.intro-arty .guide { transform-origin: 50% 100%; animation: arty-jump .62s 4.6s ease-in-out infinite; }
@keyframes arty-jump {
  0%, 100% { transform: translateY(0) scale(1.08, .9); }
  15% { transform: translateY(0) scale(.95, 1.06); }
  45% { transform: translateY(-34%) scale(.97, 1.04) rotate(-4deg); }
  70% { transform: translateY(0) scale(1.04, .95); }
}
.intro-arty::after { /* a little shadow that shrinks as Arty leaps */
  content: ""; position: absolute; left: 20%; right: 20%; bottom: -4px; height: 10px; border-radius: 50%; background: #0003;
  animation: arty-shadow .62s 4.6s ease-in-out infinite;
}
@keyframes arty-shadow { 45% { transform: scale(.6); opacity: .5; } }
.intro-arty .guide > ellipse:first-of-type { display: none; } /* his usual shadow would jump with him; the one above stays on the ground */
@keyframes intro-arty { from { transform: translateY(60%) rotate(-10deg); opacity: 0; } to { transform: none; opacity: 1; } }
.intro-skip { position: absolute; bottom: max(16px, env(safe-area-inset-bottom, 0px)); left: 0; right: 0; text-align: center; font: 600 .85rem var(--font-body); color: #00000066; }
/* Leaving: the screen wipes away upward. */
.intro.leaving { animation: intro-leave .55s cubic-bezier(.6, 0, .4, 1) forwards; }
@keyframes intro-leave { to { clip-path: inset(0 0 100% 0); } }
.intro { clip-path: inset(0 0 0 0); }
/* Reduced motion: everything in place, no movement. */
.intro.still *, .intro.still *::after, .intro.still .intro-arty::after, .intro.still { animation: none !important; }
.intro.still .intro-strokes path { stroke-dashoffset: 0; }
.intro.still .drip { height: calc(var(--len) + .14em); }
@media (prefers-color-scheme: dark) { :root[data-ui="auto"] .intro, :root[data-ui="auto"] .intro-word { background: #14141c; } :root[data-ui="auto"] .intro-aba { color: #f1f1f4; } }
:root[data-ui="dark"] .intro, :root[data-ui="dark"] .intro-word { background: #14141c; }
:root[data-ui="dark"] .intro-aba { color: #f1f1f4; }
/* A small tip from Arty (e.g. on the mixed session screen) */
.arty-tip { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; margin-bottom: 14px; border-radius: var(--radius);
  background: var(--primary-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent); }
.arty-tip .logo-mark { flex: none; }
.arty-tip p { margin: 0; line-height: 1.5; }
.arty-tip strong:first-child { color: var(--primary); }
/* Arty popping up with a tip (ready-made sequences, patterns, schedules) */
.arty-pop { position: relative; align-items: center; animation: arty-pop .5s cubic-bezier(.3, 1.5, .5, 1) both; }
.arty-pop .guide { flex: none; }
.arty-tip-body { display: flex; flex-direction: column; gap: 8px; min-width: 0; flex: 1; padding-right: 34px; }
.arty-tip-close { position: absolute; top: 4px; right: 4px; padding: 2px 9px; font-size: 1.2rem; line-height: 1; }
@keyframes arty-pop { from { opacity: 0; transform: translateY(10px) scale(.96); } }
@media (prefers-reduced-motion: reduce) { .arty-pop { animation: none; } }
/* Ready-made chips and the ready-made checklist */
.template-chip { display: inline-flex; align-items: center; gap: 6px; }
.template-chip img { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; }
.chip-group { font-size: .7rem; font-weight: 700; letter-spacing: .04em; padding: 1px 6px; border-radius: 6px; background: var(--primary-soft); color: var(--primary); }
.ready-panel { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.ready-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 10px; }
.ready-item { display: flex; flex-direction: column; gap: 6px; padding: 10px; border-radius: var(--radius); border: 2px solid var(--line); cursor: pointer; }
.ready-item:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.ready-item.added { opacity: .55; cursor: default; }
.ready-item .ready-name { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.ready-group { margin: 4px 0 0; font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

/* The footer (login screens and the home page only) and its pages */
.site-footer { border-top: 1px solid var(--line); padding: 18px max(16px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.footer-inner { max-width: 1120px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px;
  font-size: .875rem; color: var(--muted); }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 20px; }
.footer-links a { color: var(--muted); text-decoration: none; font-weight: 500; }
.footer-links a:hover, .footer-links a:focus-visible { color: var(--primary); text-decoration: underline; }
body.learner-mode .site-footer { display: none; }
@media (max-width: 600px) { .footer-inner { flex-direction: column-reverse; text-align: center; } .footer-links { justify-content: center; } }
.info-page { max-width: 720px; margin: 0 auto; line-height: 1.65; }
.info-page .auth-brand { margin: 8px 0 20px; justify-content: flex-start; }
.info-page .back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: .9rem; }
.info-page h1 { margin: 10px 0 14px; text-wrap: balance; }
.info-page h2 { font-size: 1.15rem; margin: 28px 0 8px; }
.info-page ul { padding-left: 1.3em; display: grid; gap: 6px; }
.info-page p { margin: 0 0 12px; }
.info-big { display: flex; align-items: center; gap: 10px; font-size: 1.2rem; font-weight: 600; }
.faq { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 8px; background: var(--surface); }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { margin: 10px 0 0; }

/* ---------- touch screens (iPad, tablets) ---------- */
html { -webkit-text-size-adjust: 100%; }
/* Taps register at once (no double-tap zoom wait) and without a grey flash. (Element selectors only, so draggable cards
   keep their own touch-action: none.) */
button, a, label, select, summary { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
/* Safari zooms into text boxes with text smaller than 16px; keep them at 16px on touch screens. */
@media (pointer: coarse) { input, select, textarea { font-size: 16px; } }
/* No "lift on hover" on touch screens (a tap would leave it stuck up). */
@media (hover: none) { .choice:hover, .theme-tile:hover, .guide-button:hover { transform: none; } }
/* During a session: no pull-to-refresh or bounce, no text selection, and no "Save image" menu on a long press. */
html:has(body.learner-mode), body.learner-mode { overscroll-behavior: none; }
body.learner-mode { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.learner-mode img { -webkit-touch-callout: none; -webkit-user-drag: none; }
