/* WordNorth — styles
   Colors are tokens on :root. Dark mode follows the device ("auto") unless the
   person picks Light or Dark, which sets data-theme on <html>. */

:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f0ede6;
  --line: #ddd8cc;
  --text: #1d1f24;
  --muted: #5d6270;
  --accent: #2f6fe4;
  --accent-text: #ffffff;
  --danger: #c93a3a;
  --focus: #ff9d00;
  --shadow: 0 1px 2px rgba(30, 25, 10, .08), 0 2px 8px rgba(30, 25, 10, .06);
  --key-text: #1d1f24;
  --key-edge: rgba(0, 0, 0, .14);

  /* Modified Fitzgerald Key word colors */
  --c-pron: #ffef9e;
  --c-verb: #bfeab4;
  --c-adj: #bcdcff;
  --c-noun: #ffd3a3;
  --c-social: #ffcde3;
  --c-q: #ddcdff;
  --c-neg: #ffc2c2;
  --c-prep: #eceef2;
  --c-misc: #c9eee9;
  --c-folder: #eedfc6;
  --c-people: #f9d9c9;

  --radius: 14px;
  --gap: 6px;
  --font: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif;
  --label-scale: 1;
  --sym-scale: 1;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #16181d;
    --surface: #20232a;
    --surface-2: #2a2e37;
    --line: #3a3f4b;
    --text: #eef0f4;
    --muted: #a6adbb;
    --accent: #6f9dff;
    --accent-text: #0d1220;
    --danger: #ff7a7a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 2px 10px rgba(0, 0, 0, .3);
    --key-text: #f3f4f7;
    --key-edge: rgba(0, 0, 0, .45);
    --c-pron: #5b5119;
    --c-verb: #24502b;
    --c-adj: #1e4166;
    --c-noun: #63401b;
    --c-social: #5f2a46;
    --c-q: #3f3170;
    --c-neg: #6a2a2a;
    --c-prep: #353a45;
    --c-misc: #1b4d48;
    --c-folder: #564731;
    --c-people: #5a3a2c;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #16181d;
  --surface: #20232a;
  --surface-2: #2a2e37;
  --line: #3a3f4b;
  --text: #eef0f4;
  --muted: #a6adbb;
  --accent: #6f9dff;
  --accent-text: #0d1220;
  --danger: #ff7a7a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 2px 10px rgba(0, 0, 0, .3);
  --key-text: #f3f4f7;
  --key-edge: rgba(0, 0, 0, .45);
  --c-pron: #5b5119;
  --c-verb: #24502b;
  --c-adj: #1e4166;
  --c-noun: #63401b;
  --c-social: #5f2a46;
  --c-q: #3f3170;
  --c-neg: #6a2a2a;
  --c-prep: #353a45;
  --c-misc: #1b4d48;
  --c-folder: #564731;
  --c-people: #5a3a2c;
}

/* High contrast: black and white with strong borders (either theme) */
:root.contrast {
  --line: #000;
  --key-edge: #000;
}
:root.contrast .key { border: 3px solid var(--text) !important; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
input, textarea, select { -webkit-user-select: text; user-select: text; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
  gap: 6px;
}

/* ---------- message bar ---------- */
.msgbar {
  display: flex;
  gap: 6px;
  align-items: stretch;
  min-height: 84px;
  flex: 0 0 auto;
}
.msg-speak {
  flex: 0 0 auto;
  width: 84px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
}
.msg-speak svg { width: 44px; height: 44px; }
.msg-speak.speaking { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.94); } }
.msg {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.msg:empty::before {
  content: "Tap pictures to make a sentence";
  color: var(--muted);
  font-size: 18px;
}
.msg-item {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  padding: 2px 6px;
  border-radius: 10px;
  animation: pop .18s ease-out;
}
.msg-item .sym { font-size: 34px; line-height: 1.05; height: 42px; display: grid; place-items: center; }
.msg-item .sym img { height: 40px; width: 40px; object-fit: contain; border-radius: 6px; }
.msg-item .w { font-size: 18px; font-weight: 700; white-space: nowrap; }
.msg-item.typing .w { border-bottom: 3px solid var(--accent); }
.msg-item.typing .w::after { content: "▏"; animation: blink 1s steps(1) infinite; color: var(--accent); }
.msg-item.saying { background: var(--c-pron); }
.msg.text-only .msg-item .sym { display: none; }
.msg.text-only .msg-item .w { font-size: 26px; }
@keyframes blink { 50% { opacity: 0; } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.msg-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.msg-btn {
  width: 64px;
  border: 2px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 800;
  box-shadow: var(--shadow);
}
.msg-btn svg { width: 30px; height: 30px; }
.msg-btn:active, .tool:active, .msg-speak:active { transform: scale(.95); }

/* ---------- toolbar ---------- */
.toolbar {
  display: flex;
  align-items: stretch;
  gap: 6px;
  flex: 0 0 auto;
  min-height: 48px;
}
.tool {
  border: 2px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  padding: 2px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-weight: 700;
  font-size: 16px;
  position: relative;
  box-shadow: var(--shadow);
}
.tool .ti { font-family: var(--emoji), var(--font); font-size: 22px; display: grid; place-items: center; }
.tool .ti svg { width: 24px; height: 24px; }
.tool.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.tool:disabled { opacity: .4; cursor: default; }
.crumb {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
}
.tool-adult { padding: 2px 10px; color: var(--muted); }
.hold-ring {
  position: absolute;
  inset: -2px;
  border-radius: 12px;
  pointer-events: none;
  background: conic-gradient(var(--accent) calc(var(--p, 0) * 1turn), transparent 0);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  padding: 3px;
  opacity: 0;
}
.tool-adult.holding .hold-ring { opacity: 1; }

/* ---------- edit and modeling bars ---------- */
.editbar, .modelbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-text);
  flex: 0 0 auto;
  flex-wrap: wrap;
}
.modelbar { background: #f2a516; color: #1d1f24; font-weight: 700; }
.editbar-msg, #modelMsg { flex: 1 1 200px; }
.editbar .btn { background: rgba(255, 255, 255, .2); color: inherit; border-color: transparent; }
.editbar .btn.primary { background: var(--surface); color: var(--text); }

/* ---------- board ---------- */
.board {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows, 4), minmax(0, 1fr));
  touch-action: none;
}
.key, .cell-empty {
  min-width: 0;
  min-height: 0;
  border-radius: var(--radius);
}
.key {
  position: relative;
  container-type: size;
  border: 0;
  border-bottom: 4px solid var(--key-edge);
  background: var(--key-bg, var(--c-prep));
  color: var(--key-text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3px;
  overflow: hidden;
  transition: transform .08s ease-out, box-shadow .15s;
  box-shadow: var(--shadow);
}
.key .sym {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  width: 100%;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr); /* a definite box, so every picture shrinks to fit */
  place-items: center;
  font-family: var(--emoji), var(--font);
  font-size: calc(min(6vh, 4.5vw) * var(--sym-scale)); /* browsers without container sizes */
  font-size: calc(min(58cqh, 62cqw) * var(--sym-scale));
  line-height: 1;
}
.key .sym img {
  max-width: 94%;
  max-height: 100%;
  width: auto;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.key .sym img.photo { border-radius: 10px; object-fit: cover; width: 94%; }
.key .lbl {
  flex: 0 0 auto;
  font-weight: 800;
  /* fits the word to the button: --n is the label's length in characters */
  font-size: calc(clamp(9px, 1.5vw, 20px) * var(--label-scale)); /* browsers without container sizes */
  font-size: calc(clamp(6.5px, min(20cqh, calc(148cqw / var(--n, 6))), 40px) * var(--label-scale));
  text-overflow: ellipsis;
  line-height: 1.1;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  padding: 0 2px;
}
.key.no-sym .sym { display: none; }
.key.no-sym .lbl {
  font-size: calc(clamp(12px, 2vw, 28px) * var(--label-scale)); /* browsers without container sizes */
  /* fits the longest word: --n is the label's length; phrases may wrap between words, never inside one */
  font-size: calc(clamp(6.5px, min(30cqh, calc(150cqw / var(--n-word, var(--n, 6)))), 52px) * var(--label-scale));
  white-space: normal;
  overflow-wrap: normal;
  word-break: keep-all;
  line-height: 1.1;
  text-wrap: balance;
}
.labels-above .key { flex-direction: column-reverse; }
.labels-hidden .key .lbl { display: none; }
.key.pressed { transform: scale(.93); filter: brightness(.95); }
.press-grow .key.pressed { transform: scale(1.08); z-index: 3; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.key .hold-fill {
  position: absolute;
  inset: auto 0 0 0;
  height: calc(var(--p, 0) * 100%);
  background: rgba(47, 111, 228, .28);
  pointer-events: none;
}

.cat-pron { --key-bg: var(--c-pron); }
.cat-verb { --key-bg: var(--c-verb); }
.cat-adj { --key-bg: var(--c-adj); }
.cat-noun { --key-bg: var(--c-noun); }
.cat-social { --key-bg: var(--c-social); }
.cat-q { --key-bg: var(--c-q); }
.cat-neg { --key-bg: var(--c-neg); }
.cat-prep { --key-bg: var(--c-prep); }
.cat-misc { --key-bg: var(--c-misc); }
.cat-folder { --key-bg: var(--c-folder); }
.cat-people { --key-bg: var(--c-people); }

/* folders get a tab on the top-left, like a file folder */
.key.folder { border-radius: 4px var(--radius) var(--radius) var(--radius); }
.key.folder::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 38%;
  height: 7%;
  min-height: 5px;
  background: rgba(0, 0, 0, .16);
  border-radius: 0 0 8px 0;
}
.key.now::after {
  content: "";
  position: absolute;
  right: 6px;
  top: 6px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  opacity: .35;
}

/* invisible spot that keeps a word's place for later levels */
.cell-empty { background: transparent; }
.editing .cell-empty {
  border: 2px dashed var(--line);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 28px;
  cursor: pointer;
}
.editing .cell-empty::before { content: "+"; }
.editing .key { cursor: grab; }
.editing .key.is-hidden { opacity: .38; }
.editing .key.above-level { opacity: .55; outline: 2px dashed var(--muted); outline-offset: -4px; }
.key .badge {
  position: absolute;
  left: 4px;
  top: 4px;
  font-size: 11px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  opacity: .85;
}
.dragging { opacity: .3; }
.drop-target { outline: 3px solid var(--accent); outline-offset: 2px; }
.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 50;
  opacity: .9;
  transform: translate(-50%, -50%) scale(1.05);
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}

/* modeling (show me the way) */
.key.model-next { animation: modelpulse 1.1s ease-in-out infinite; z-index: 2; }
@keyframes modelpulse {
  0%, 100% { box-shadow: 0 0 0 4px #f2a516, 0 0 0 0 rgba(242,165,22,.6); }
  50% { box-shadow: 0 0 0 4px #f2a516, 0 0 0 16px rgba(242,165,22,0); }
}
.tool.model-next { animation: modelpulse 1.1s ease-in-out infinite; }

/* switch scanning highlight */
.scan-hi { outline: 5px solid var(--focus) !important; outline-offset: 1px; z-index: 4; position: relative; }
.scan-row-hi { box-shadow: 0 0 0 4px var(--focus) !important; }

/* ---------- keyboard board ---------- */
.board.kb { display: flex; flex-direction: column; gap: var(--gap); }
.kb-predict { display: flex; gap: var(--gap); flex: 1 1 0; min-height: 0; }
.kb-row { display: flex; gap: var(--gap); flex: 1 1 0; min-height: 0; justify-content: center; }
.kb-row .key { flex: 1 1 0; max-width: calc(100% / 10); }
.kb-row .key.wide { max-width: none; flex: 2 1 0; }
.kb-row .key.space { max-width: none; flex: 5 1 0; }
.kb .key .lbl { font-size: clamp(16px, 3vh, 28px); font-size: clamp(16px, 40cqh, 40px); white-space: nowrap; }
.kb-predict .key { flex: 1 1 0; --key-bg: var(--c-misc); }
.kb-predict .key .lbl { font-size: clamp(14px, 2.4vh, 24px); font-size: clamp(14px, 30cqh, 30px); }

/* ---------- generic controls ---------- */
.btn {
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  text-decoration: none;
  line-height: 1.2;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- dialogs ---------- */
dialog.dlg {
  border: 0;
  border-radius: 18px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px); /* older browsers */
  max-height: calc(100dvh - 32px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
dialog.dlg.wide { width: min(980px, calc(100vw - 32px)); }
dialog.dlg.full { width: min(1100px, calc(100vw - 16px)); height: calc(100vh - 16px); height: calc(100dvh - 16px); max-height: none; }
dialog.dlg::backdrop { background: rgba(10, 12, 18, .5); }
/* stand-in for browsers without <dialog> */
dialog:not([open]) { display: none; }
dialog.dlg.shim[open] { display: block; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); margin: 0; z-index: 1000; box-shadow: 0 0 0 100vmax rgba(10, 12, 18, .5), 0 20px 60px rgba(0, 0, 0, .35); }
.dlg-in { display: flex; flex-direction: column; max-height: inherit; height: 100%; }
.dlg-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.dlg-head h2 { margin: 0; font-size: 20px; flex: 1; }
.dlg-x { border: 0; background: transparent; font-size: 26px; cursor: pointer; color: var(--muted); padding: 0 6px; line-height: 1; }
.dlg-body { padding: 16px 18px; overflow: auto; -webkit-user-select: text; user-select: text; }
.dlg-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.dlg-foot .spacer { flex: 1; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > span, .field-label { font-weight: 700; font-size: 14px; }
.field small, .hint { color: var(--muted); font-size: 13px; line-height: 1.4; }
.hint { margin: 0 0 12px; }
input[type="text"], input[type="password"], input[type="number"], input[type="search"], select, textarea {
  font: inherit;
  padding: 9px 11px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 20px; height: 20px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; cursor: pointer; }
.check > span { display: flex; flex-direction: column; gap: 2px; }
.check b { font-size: 15px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: inline-flex; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 8px 14px; cursor: pointer; font-weight: 700; }
.seg button + button { border-left: 2px solid var(--line); }
.seg button.on { background: var(--accent); color: var(--accent-text); }

/* settings layout */
.set-wrap { display: flex; height: 100%; min-height: 0; }
.set-nav { flex: 0 0 224px; border-right: 1px solid var(--line); padding: 10px; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.set-nav button { text-align: left; border: 0; background: transparent; padding: 10px 12px; border-radius: 10px; cursor: pointer; font-weight: 700; display: flex; gap: 10px; align-items: center; }
.set-nav button.on { background: var(--surface-2); color: var(--accent); }
.set-nav .nav-ic { flex: 0 0 auto; width: 1.4em; text-align: center; }
.set-nav .nav-name { min-width: 0; line-height: 1.25; text-wrap: balance; }
.set-nav .nav-part { white-space: nowrap; } /* break only between parts */
.check.beside-field { margin-top: 26px; }
.where-card > p:first-child { margin-top: 0; }
.where-status { display: block; margin: 0 0 10px; color: var(--muted); } /* lines up with the input next to it */
.set-main { flex: 1; overflow: auto; padding: 18px 22px; -webkit-user-select: text; user-select: text; }
.set-main h3 { margin: 22px 0 10px; font-size: 17px; }
.set-main h3:first-child { margin-top: 0; }
.card { border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: var(--surface); margin-bottom: 12px; }

.levels { display: grid; gap: 8px; }
.level-opt { display: flex; gap: 12px; align-items: center; border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer; background: var(--surface); text-align: left; width: 100%; }
.level-opt.on { border-color: var(--accent); background: var(--surface-2); }
.level-opt .lv { font-size: 22px; font-weight: 800; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--c-misc); flex: 0 0 auto; }
.level-opt b { display: block; }
.level-opt small { color: var(--muted); }
.level-dots { display: grid; grid-template-columns: repeat(10, 6px); gap: 2px; margin-left: auto; flex: 0 0 auto; }
.level-dots i { width: 6px; height: 6px; border-radius: 1px; background: var(--line); }
.level-dots i.on { background: var(--accent); }

.student-list { display: grid; gap: 8px; }
.student { display: flex; align-items: center; gap: 12px; border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.student.on { border-color: var(--accent); }
.student .av { width: 44px; height: 44px; border-radius: 50%; background: var(--c-people); display: grid; place-items: center; font-size: 22px; overflow: hidden; flex: 0 0 auto; }
.student .av img { width: 100%; height: 100%; object-fit: cover; }
.student .nm { flex: 1; min-width: 0; }
.student .nm b { display: block; }
.student .nm small { color: var(--muted); }

.board-list { display: grid; gap: 6px; }
.board-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.board-row .nm { flex: 1; font-weight: 700; }
.board-row small { color: var(--muted); font-weight: 400; }

.usage-bars { display: grid; gap: 4px; }
.usage-bar { display: grid; grid-template-columns: 110px 1fr 40px; align-items: center; gap: 8px; font-size: 14px; }
.usage-bar .bar { height: 14px; border-radius: 4px; background: var(--accent); min-width: 2px; }
.usage-bar .n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.usage-bars.cats .usage-bar { grid-template-columns: 170px 1fr 48px; }
.usage-bar .bar[class*="cat-"] { background: var(--key-bg); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text, #000) 25%, transparent); }
/* usage: period picker, number tiles, words per day */
.usage-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 14px 0 10px; }
.period-step { display: flex; align-items: center; gap: 8px; }
.period-step .btn { min-width: 40px; font-size: 18px; }
.period-title { display: grid; min-width: 150px; text-align: center; line-height: 1.2; }
.period-title small { color: var(--muted); }
.stat-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin-bottom: 14px; }
.stat-tile { border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 2px; background: var(--surface); }
.stat-tile b { font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-tile span { font-size: 13px; color: var(--muted); }
.stat-tile .delta { font-size: 12px; color: var(--muted); }
.col-chart { display: flex; align-items: stretch; gap: 2px; height: 150px; padding: 6px 0 0; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.col-chart .col { flex: 1 1 0; min-width: 0; display: grid; grid-template-rows: 16px 1fr 18px; align-items: end; justify-items: center; border: 0; background: none; padding: 0; cursor: pointer; color: var(--muted); font: inherit; }
.col-chart .col:hover .col-bar, .col-chart .col:focus-visible .col-bar { filter: brightness(1.15); outline: 2px solid var(--accent); outline-offset: 1px; }
.col-chart .col-bar { width: min(70%, 36px); background: var(--accent); border-radius: 4px 4px 0 0; min-height: 0; align-self: end; }
.col-chart .col-n { font-size: 11px; font-variant-numeric: tabular-nums; align-self: end; }
.col-chart .col-x { font-size: 11px; white-space: nowrap; transform: translateY(16px); margin-top: -16px; }
.col-chart.dense .col-n { display: none; }
.col-chart + * { margin-top: 22px; }
/* compare and choose (two copies of one student) */
.rc-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0 12px; }
.rc-sec { border: 2px solid var(--line); border-radius: 12px; margin: 0 0 10px; background: var(--surface); }
.rc-sec > summary { cursor: pointer; padding: 10px 14px; font-weight: 800; }
.rc-list, .rc-cards, .rc-bulk { padding: 0 12px 12px; }
.rc-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.rc-what { display: grid; gap: 2px; min-width: 0; }
.rc-what small { color: var(--muted); }
.rc-what small b { color: var(--text); font-weight: 700; }
.rc-choice button { padding: 6px 12px; font-size: 14px; }
.rc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.rc-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: grid; gap: 6px; justify-items: center; }
.rc-pair { display: flex; align-items: center; gap: 8px; }
.rc-pair figure { margin: 0; display: grid; gap: 4px; justify-items: center; }
.rc-pair figcaption { font-size: 12px; color: var(--muted); }
.rc-key, .rc-empty { width: 86px; height: 86px; }
.rc-key { pointer-events: none; }
.rc-key:disabled { opacity: 1; }
.rc-empty { border: 2px dashed var(--line); border-radius: 12px; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.rc-arrow { font-size: 22px; color: var(--muted); }
.rc-where { color: var(--muted); text-align: center; }
.cam { display: grid; gap: 10px; }
.cam-frame { position: relative; width: 100%; max-width: 640px; margin: 0 auto; aspect-ratio: 4 / 3; max-height: 58vh; background: #000; border-radius: 14px; overflow: hidden; }
.cam-video, .cam-still { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-still { object-fit: contain; background: #000; }
.cam-frame.mirror .cam-video { transform: scaleX(-1); }
.cam-guide { position: absolute; top: 50%; left: 50%; height: 92%; aspect-ratio: 1; transform: translate(-50%, -50%); border: 3px dashed rgba(255, 255, 255, .85); border-radius: 12px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); pointer-events: none; }
.cam-still:not([hidden]) ~ .cam-guide { display: none; }
.cam-actions { justify-content: center; }
.cam-other { justify-content: center; opacity: .9; }
.btn.big { font-size: 18px; padding: 12px 20px; }
.word-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 14px; background: var(--surface); }
.chip.quiet { color: var(--muted); border-style: dashed; }

/* editor */
.ed-top { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.ed-preview { width: 120px; height: 120px; flex: 0 0 auto; }
.ed-preview .key { width: 100%; height: 100%; }
.ed-pic-btns { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { border: 2px solid var(--line); border-radius: 10px; padding: 6px 10px; cursor: pointer; background: var(--key-bg); color: var(--key-text); font-weight: 700; font-size: 13px; }
.swatch.on { outline: 3px solid var(--accent); outline-offset: 1px; }
.sym-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; max-height: 46vh; overflow: auto; padding: 2px; }
.sym-pick { aspect-ratio: 1; border: 2px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; display: grid; place-items: center; font-size: 34px; font-family: var(--emoji), var(--font); padding: 4px; }
.sym-pick img { width: 100%; height: 100%; object-fit: contain; }
.sym-pick:hover { border-color: var(--accent); }
.credit { font-size: 12px; color: var(--muted); margin-top: 10px; }

/* popover for word forms */
.forms-pop { display: flex; flex-wrap: wrap; gap: 10px; }
.forms-pop .key { width: 130px; height: 90px; }

/* find / history lists */
.list { display: grid; gap: 6px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; text-align: left; width: 100%; }
.list-item:hover { border-color: var(--accent); }
.list-item .sym { font-size: 30px; width: 40px; text-align: center; font-family: var(--emoji), var(--font); }
.list-item .sym img { width: 40px; height: 40px; object-fit: contain; }
.list-item b { display: block; font-size: 17px; }
.list-item small { color: var(--muted); }

/* QR */
.qr-box { display: grid; place-items: center; gap: 10px; text-align: center; }
.qr-box svg { width: min(340px, 78vw); height: auto; background: #fff; border-radius: 8px; }
.qr-small svg { width: 160px; }
.qr-cycle-foot { display: flex; gap: 10px; align-items: center; justify-content: center; }
.qr-cam { position: relative; border-radius: 14px; overflow: hidden; background: #000; aspect-ratio: 4/3; }
.qr-cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
.qr-dots { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px 0 4px; }
.qr-dots i { width: 14px; height: 14px; border-radius: 4px; background: var(--line); }
.qr-dots i.on { background: #2ea44f; }
.qr-steps { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: start; text-align: left; }

/* welcome */
.welcome-hero { text-align: center; padding: 6px 0 14px; }
.welcome-hero .big { font-size: 56px; font-family: var(--emoji), var(--font); }
.welcome-hero h1 { margin: 6px 0; font-size: 26px; }
.welcome-hero p { color: var(--muted); margin: 0 auto; max-width: 420px; }

/* toasts */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 700; box-shadow: var(--shadow); animation: pop .2s ease-out; max-width: 90vw; }

/* print sheet (QR codes for a binder) */
.print-sheet { display: none; }
@media print {
  @page { margin: 12mm; }
  body * { visibility: hidden; }
  .print-sheet, .print-sheet * { visibility: visible; }
  .print-sheet { display: block; position: absolute; inset: 0; color: #000; background: #fff; }
  .print-sheet h1 { font-size: 18pt; margin: 0 0 4pt; }
  .print-sheet p { font-size: 10pt; margin: 0 0 10pt; }
  .print-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8mm; }
  .print-grid figure { margin: 0; text-align: center; break-inside: avoid; }
  .print-grid svg { width: 100%; height: auto; }
  .print-grid figcaption { font-size: 9pt; }
}

/* ---------- small screens ---------- */
/* Phones: same layout, just smaller. Toolbar labels stay (under the icons) so every device looks alike. */
@media (max-width: 760px) {
  .tool { flex-direction: column; gap: 0; padding: 2px 6px; font-size: 11px; justify-content: center; }
  .tool .ti { font-size: 18px; }
  /* with every tool turned on, tools share the width instead of pushing the page sideways */
  .toolbar { gap: 4px; }
  .tool:not(.tool-adult) { min-width: 0; flex: 0 1 auto; padding: 2px 4px; }
  .tool .tl { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tool-lang .ti { font-size: 12px; }
  .crumb { font-size: 16px; }
  .msgbar { min-height: 64px; }
  .msg-speak { width: 60px; }
  .msg-speak svg { width: 32px; height: 32px; }
  .msg-btn { width: 46px; }
  .msg-item .sym { font-size: 26px; height: 32px; }
  .msg-item .w { font-size: 15px; }
  .set-wrap { flex-direction: column; }
  .set-nav { flex: 0 0 auto; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .set-nav button { white-space: nowrap; padding: 8px 10px; }
  .set-nav .nav-name { white-space: nowrap; text-wrap: nowrap; } /* one line in the scrolling row */
  .check.beside-field { margin-top: 0; }
  .set-main { padding: 14px 16px; }
  .row2 { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .app { gap: 4px; padding: max(4px, env(safe-area-inset-top)) 4px max(4px, env(safe-area-inset-bottom)); }
  :root { --gap: 4px; --radius: 10px; }
}
/* Phones turned sideways: shorter bars so the board keeps most of the height. */
@media (max-height: 520px) {
  .msgbar { min-height: 52px; }
  .toolbar { min-height: 38px; }
  .tool { flex-direction: row; font-size: 12px; padding: 2px 8px; }
  .msg-speak { width: 56px; }
  .msg-speak svg { width: 28px; height: 28px; }
  .msg-btn { width: 44px; }
  .msg-item .sym { font-size: 22px; height: 26px; }
  .msg-item .w { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition: none !important; }
}

/* smart grammar: a word whose form changed to fit the sentence gets a soft underline */
.key.smart .lbl { text-decoration: underline 2px; text-decoration-color: currentColor; text-underline-offset: 3px; text-decoration-thickness: 2px; opacity: .95; }

/* imported button colors (the school's own); softened in dark mode */
.key.custom { --key-bg: var(--raw-bg); }
.key.custom.dark-bg { --key-text: #fff; }
/* (only where the browser can mix colors; older ones show the school's colors as they are) */
@supports (color: color-mix(in srgb, red, blue)) {
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .key.custom { --key-bg: color-mix(in srgb, var(--raw-bg) 45%, #1b1e24); --key-text: #f3f4f7; }
  }
  :root[data-theme="dark"] .key.custom { --key-bg: color-mix(in srgb, var(--raw-bg) 45%, #1b1e24); --key-text: #f3f4f7; }
}

/* help sections */
.help-sec { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; background: var(--surface); }
.help-sec > summary { cursor: pointer; padding: 12px 14px; font-weight: 700; list-style-position: inside; }
.help-sec > div { padding: 0 16px 12px; }
.help-sec ol, .help-sec ul { margin: 4px 0 8px; padding-left: 22px; line-height: 1.5; }

.page-help { display: flex; justify-content: flex-end; margin: -6px 0 6px; }
.dlg-head .btn.small { white-space: nowrap; }
@media (max-width: 760px) { .dlg-head { flex-wrap: wrap; } }

/* ---- the progress report (printed or saved as PDF) ---------------------------------------- */
.rp { --rp-ink: #1b1f27; --rp-ink-2: #4a5160; --rp-muted: #6b7282; --rp-line: #dfe2e8; --rp-soft: #f4f6f9; --rp-accent: #2f6fe4; --rp-accent-soft: #9dbcf5;
  color: var(--rp-ink); font: 10pt/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
.rp * { box-sizing: border-box; }
.rp-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16pt; padding-bottom: 10pt; border-bottom: 2.5pt solid var(--rp-accent); }
.rp-brand { display: flex; align-items: center; gap: 9pt; }
.rp-logo { width: 34pt; height: 34pt; border-radius: 8pt; }
.rp-app { font-size: 15pt; font-weight: 800; letter-spacing: -.01em; }
.rp-doc { font-size: 9pt; color: var(--rp-muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.rp-who { text-align: right; }
.rp-name { font-size: 20pt; font-weight: 800; line-height: 1.1; letter-spacing: -.01em; }
.rp-meta { font-size: 9pt; color: var(--rp-ink-2); }
.rp-summary { margin: 12pt 0 10pt; padding: 10pt 12pt; background: var(--rp-soft); border-left: 3pt solid var(--rp-accent); border-radius: 0 6pt 6pt 0; font-size: 10.5pt; line-height: 1.5; }
.rp-kpis { display: grid; gap: 6pt; margin: 0 0 4pt; }
.rp-kpi { border: 1pt solid var(--rp-line); border-radius: 7pt; padding: 7pt 9pt 6pt; break-inside: avoid; }
.rp-kpi-v { font-size: 18pt; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.rp-kpi-l { font-size: 8.5pt; color: var(--rp-ink-2); font-weight: 600; margin-top: 1pt; }
.rp-delta { display: block; font-size: 7.5pt; color: var(--rp-muted); margin-top: 2pt; }
.rp-arrow { font-size: 6.5pt; }
.rp-sec { margin-top: 13pt; }
.rp-sec.keep, .rp-kpis, .rp-chart, .rp-lines, .rp-sign, .rp-about, .rp-chips { break-inside: avoid; }
.rp-sec h2 { break-after: avoid; }
.rp-sec h2 { font-size: 11pt; font-weight: 800; margin: 0 0 6pt; padding-bottom: 3pt; border-bottom: 1pt solid var(--rp-line); letter-spacing: .01em; }
.rp-sec h3 { font-size: 9pt; font-weight: 700; color: var(--rp-ink-2); margin: 6pt 0 4pt; }
.rp-note { font-size: 8pt; color: var(--rp-muted); margin: 5pt 0 0; }
.rp-chart { width: 100%; height: auto; display: block; }
.rp-chart .rp-bar { fill: var(--rp-accent); }
.rp-chart .rp-grid { stroke: var(--rp-line); stroke-width: .6; }
.rp-chart .rp-axis { stroke: #9aa1ae; stroke-width: 1; }
.rp-chart .rp-tick { font-size: 9px; fill: var(--rp-muted); font-family: inherit; }
.rp-chart .rp-val { font-size: 9px; fill: var(--rp-ink-2); font-weight: 700; font-family: inherit; }
.rp-cols { display: grid; grid-template-columns: 1.15fr 1fr; gap: 16pt; align-items: start; }
.rp-cols .rp-sec { margin-top: 13pt; }
.rp-table { width: 100%; border-collapse: collapse; font-size: 9pt; }
.rp-table th { text-align: left; font-size: 7.5pt; text-transform: uppercase; letter-spacing: .06em; color: var(--rp-muted); font-weight: 700; padding: 0 4pt 3pt; border-bottom: 1pt solid var(--rp-line); }
.rp-table td { padding: 2.6pt 4pt; border-bottom: .5pt solid #eef0f3; vertical-align: middle; }
.rp-table tr { break-inside: avoid; }
.rp-cols .rp-table { break-inside: avoid; }
.rp-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rp-table .muted { color: var(--rp-muted); }
.rp-word { font-weight: 700; }
.rp-barcell { width: 40%; white-space: nowrap; }
.rp-hbar { display: inline-block; height: 7pt; background: var(--rp-accent); border-radius: 0 3pt 3pt 0; vertical-align: middle; max-width: 78%; }
.rp-hbar.soft { background: var(--rp-accent-soft); max-width: 100%; }
.rp-pct { font-size: 7.5pt; color: var(--rp-muted); margin-left: 4pt; vertical-align: middle; }
.rp-swatch { display: inline-block; width: 9pt; height: 9pt; border-radius: 2.5pt; margin-right: 6pt; vertical-align: -1pt; box-shadow: inset 0 0 0 .6pt rgba(0, 0, 0, .25); }
.rp-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.rp-chips { display: flex; flex-wrap: wrap; gap: 4pt; }
.rp-chip { border: 1pt solid var(--rp-line); background: var(--rp-soft); border-radius: 99pt; padding: 1.5pt 7pt; font-size: 9pt; font-weight: 600; }
.rp-chip.quiet { background: none; border-style: dashed; color: var(--rp-ink-2); font-weight: 500; }
.rp-sents td:first-child { font-weight: 600; }
.rp-lines .rp-line { height: 20pt; border-bottom: .75pt solid #c8ccd4; }
.rp-sign { display: grid; grid-template-columns: 2fr 1fr; gap: 18pt; margin-top: 10pt; }
.rp-sign .rp-line { height: 22pt; border-bottom: .75pt solid #8d94a1; }
.rp-sign span { font-size: 7.5pt; color: var(--rp-muted); text-transform: uppercase; letter-spacing: .06em; }
.rp-about dl { display: grid; grid-template-columns: 9.5em 1fr; gap: 3pt 10pt; margin: 0; font-size: 8.5pt; }
.rp-about dt { font-weight: 700; }
.rp-about dd { margin: 0; color: var(--rp-ink-2); }
.rp-foot { margin-top: 14pt; padding-top: 6pt; border-top: 1pt solid var(--rp-line); font-size: 7.5pt; color: var(--rp-muted); text-align: center; }
@media print {
  /* the report flows over several pages: take everything else out of the layout */
  body.printing-report > *:not(.print-sheet) { display: none !important; }
  html:has(body.printing-report), body.printing-report { background: #fff !important; }
  body.printing-report .print-sheet { position: static; padding: 0; visibility: visible; background: #fff; }
  body.printing-report .print-sheet * { visibility: visible; }
  body.printing-report .rp, body.printing-report .rp * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
@page report { size: letter; margin: 14mm 14mm 16mm; @bottom-right { content: "Page " counter(page) " of " counter(pages); font: 8pt system-ui, sans-serif; color: #6b7282; } }
body.printing-report .print-sheet { page: report; }

/* ---- 1.7: language button, symbol library ------------------------------------------------- */
.tool-lang .ti { font-family: var(--font); font-size: 15px; font-weight: 800; letter-spacing: .04em; border: 2px solid currentColor; border-radius: 7px; padding: 0 4px; line-height: 1.25; }
.mb-grid { grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); }
.sym-pick.mb { aspect-ratio: auto; display: flex; flex-direction: column; gap: 3px; padding: 6px 4px 5px; background: #fff; }
.sym-pick.mb img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.sym-pick.mb span { font: 600 11px/1.15 var(--font); color: #2a2d33; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.key .sym img.drawn { background: transparent; }

/* ---- photo scenes ----------------------------------------------------------------------------- */
.board.scene-board { display: flex; align-items: center; justify-content: center; }
.scene-box { position: relative; flex: none; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: var(--surface-2); }
.scene-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; display: block; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.scene-missing { display: grid; place-items: center; height: 100%; color: var(--muted); padding: 20px; text-align: center; }
.key.spot { position: absolute; background: transparent; border: 0; box-shadow: none; border-radius: 12px; padding: 0; justify-content: flex-end; container-type: normal; }
.key.spot .sym { display: none; }
.key.spot .lbl { display: none; }
.key.spot::before, .key.spot::after { display: none; }
.scene-box.outlined .key.spot { border: 3px dashed rgba(255, 255, 255, .95); outline: 1.5px solid rgba(0, 0, 0, .45); outline-offset: -4.5px; }
.scene-box.outlined .key.spot .lbl { display: block; flex: none; margin: 0 0 6px; padding: 2px 10px; border-radius: 999px; background: rgba(255, 255, 255, .92); color: #1d1f24; font-size: clamp(12px, 1.6vw, 20px); font-weight: 800; max-width: calc(100% - 8px); box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }
.key.spot.pressed { transform: none; background: rgba(255, 255, 255, .38); filter: none; }
.key.spot.scan-hi, .key.spot.scan-row-hi { background: rgba(255, 157, 0, .35); }
.scene-box.editing .key.spot { cursor: move; background: rgba(47, 111, 228, .16); }
.scene-box.editing .key.spot .badge { display: none; }
.scene-box.editing { cursor: crosshair; }
.spot-handle { position: absolute; right: -2px; bottom: -2px; width: 22px; height: 22px; border-radius: 6px 0 10px 0; background: var(--accent); cursor: nwse-resize; box-shadow: 0 0 0 2px #fff; }
.spot-draft { position: absolute; border: 3px dashed var(--accent); background: rgba(47, 111, 228, .18); border-radius: 10px; pointer-events: none; }

/* ---- schedules -------------------------------------------------------------------------------- */
dialog.sch-dlg .dlg-in { height: 100%; display: flex; flex-direction: column; }
dialog.sch-dlg .dlg-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
dialog.sch-dlg .dlg-head { padding-bottom: 0; border-bottom: 0; }
.sch { display: flex; flex-direction: column; gap: 14px; flex: 1; min-height: 0; }
.sch-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sch-name { margin: 0; font-size: 26px; }
.sch-ft, .sch-list { flex: 1; min-height: 0; display: flex; gap: 18px; align-items: stretch; justify-content: center; }
.sch-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); grid-auto-rows: minmax(150px, 1fr); }
.sch-list.many { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); grid-auto-rows: minmax(120px, 1fr); }
.sch-arrow { align-self: center; font-size: 48px; color: var(--muted); }
.sch-card { position: relative; flex: 1; max-width: 460px; border: 0; border-bottom: 5px solid var(--key-edge); border-radius: 22px; background: var(--key-bg, var(--c-noun)); color: var(--key-text); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 14px; cursor: pointer; box-shadow: var(--shadow); font: inherit; min-height: 0; transition: transform .1s, opacity .2s; }
.sch-card:active { transform: scale(.97); }
.sch-tag { position: absolute; top: 10px; left: 14px; font-size: 18px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; opacity: .75; }
.sch-pic { flex: 1; min-height: 0; width: 100%; display: grid; place-items: center; font-family: var(--emoji), var(--font); font-size: clamp(56px, 14vmin, 160px); line-height: 1; }
.sch-pic img { max-width: 90%; max-height: 100%; object-fit: contain; border-radius: 12px; }
.sch-list .sch-pic { font-size: clamp(40px, 9vmin, 110px); }
.sch-word { font-size: clamp(18px, 3.6vmin, 36px); font-weight: 800; text-align: center; }
.sch-card.now { box-shadow: 0 0 0 6px var(--accent), var(--shadow); }
.sch-card.done { opacity: .42; }
.sch-check { position: absolute; top: 10px; right: 12px; width: 44px; height: 44px; border-radius: 50%; background: #fff; color: #1d1f24; display: grid; place-items: center; font-size: 28px; font-weight: 900; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); }
.sch-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sch-hint { margin: 0; color: var(--muted); }
.sch-row-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.sch-row-top small { color: var(--muted); }
.sch-mini { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.sch-mini-step { display: inline-flex; align-items: center; gap: 4px; background: var(--key-bg); color: var(--key-text); border-radius: 8px; padding: 3px 8px 3px 4px; font-weight: 700; font-size: 14px; }
.sch-mini-step .sym { font-family: var(--emoji), var(--font); font-size: 20px; display: inline-grid; place-items: center; width: 24px; height: 24px; }
.sch-mini-step .sym img { max-width: 24px; max-height: 24px; border-radius: 4px; }
.sch-edit-list { display: grid; gap: 6px; }
.sch-edit-step { display: grid; grid-template-columns: 48px 44px 1fr auto auto auto auto; gap: 6px; align-items: center; }
.sch-edit-n { font-weight: 800; color: var(--muted); font-size: 13px; text-align: center; }
.sch-edit-pic { width: 44px; height: 44px; border-radius: 10px; background: var(--key-bg); display: grid; place-items: center; font-family: var(--emoji), var(--font); font-size: 26px; overflow: hidden; }
.sch-edit-pic img { max-width: 40px; max-height: 40px; object-fit: contain; }
@media (max-width: 560px) { .sch-ft { flex-direction: column; } .sch-arrow { transform: rotate(90deg); font-size: 32px; } .sch-edit-step { grid-template-columns: 36px 40px 1fr auto auto; } .sch-edit-step .btn[title="Move up"], .sch-edit-step .btn[title="Move down"] { display: none; } }

/* ---- goals ------------------------------------------------------------------------------------ */
.goal-list { display: grid; gap: 10px; }
.goal-card { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--surface); }
.goal-card.done { opacity: .7; }
.goal-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.goal-title { font-size: 16px; }
.goal-note { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.goal-body { display: grid; grid-template-columns: minmax(180px, 280px) 1fr; gap: 16px; align-items: center; margin-top: 8px; }
.goal-status { display: grid; gap: 3px; font-weight: 700; }
.goal-status small { font-weight: 400; color: var(--muted); }
.goal-spark { width: 100%; height: auto; display: block; overflow: visible; }
.goal-spark .gs-bar { fill: var(--accent); opacity: .38; }
.goal-spark .gs-bar.met { opacity: 1; }
.goal-spark .gs-bar.now { opacity: .6; }
.goal-spark .gs-bar.now.met { opacity: 1; }
.goal-spark .gs-axis { stroke: var(--line); stroke-width: 1; }
.goal-spark .gs-target { stroke: var(--text); stroke-width: 1.2; stroke-dasharray: 4 3; opacity: .7; }
.goal-spark .gs-x { font-size: 9px; fill: var(--muted); font-family: var(--font); }
.goal-preview { font-weight: 700; background: var(--surface-2); padding: 8px 12px; border-radius: 10px; }
.empty-goals p { margin: 4px 0; }
.warn-card { border-color: var(--focus); }
@media (max-width: 560px) { .goal-body { grid-template-columns: 1fr; } }

/* ---- class & district view -------------------------------------------------------------------- */
.dv-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; margin: 10px 0; }
.dv-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 760px; }
.dv-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; padding: 8px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.dv-table th.sortable { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.dv-table th.on { color: var(--text); }
.dv-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.dv-table tr:last-child td { border-bottom: 0; }
.dv-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dv-table .muted { color: var(--muted); }
.dv-src { display: block; color: var(--muted); font-size: 11px; }
.dv-flags { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }

/* ---- translations ----------------------------------------------------------------------------- */
.tr-list { display: grid; gap: 4px; max-height: 52vh; overflow: auto; margin-top: 10px; padding-right: 4px; }
.tr-row { display: grid; grid-template-columns: 1fr 1.3fr; gap: 10px; align-items: center; font-weight: 700; }
.tr-row small { color: var(--muted); font-weight: 400; }
.tr-row input::placeholder { color: var(--muted); opacity: .8; }
small.warn { color: var(--danger); }

/* ---- paper boards (printed; always light colors) ---------------------------------------------- */
.pb { color: #1d1f24; font-family: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif; }
.pb, .pb * { print-color-adjust: exact; -webkit-print-color-adjust: exact; box-sizing: border-box; }
.pb-page { width: var(--pb-w, 10.24in); height: var(--pb-h, 7.74in); display: flex; flex-direction: column; gap: 4pt; overflow: hidden; break-after: page; page-break-after: always; }
.pb-page:last-child { break-after: auto; page-break-after: auto; }
.pb-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12pt; padding: 0 2pt 4pt; border-bottom: 1.5pt solid #1d1f24; flex: none; }
.pb-title { display: flex; align-items: baseline; gap: 10pt; min-width: 0; }
.pb-board { font-size: 21pt; font-weight: 800; letter-spacing: -.01em; line-height: 1; white-space: nowrap; }
.pb-where { font-size: 9pt; color: #5d6270; font-weight: 600; white-space: nowrap; }
.pb-who { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.pb-name { font-size: 11pt; font-weight: 800; }
.pb-pg { font-size: 8pt; color: #5d6270; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.pb-grid { display: grid; flex: none; background: #f6f4ef; border-radius: 10pt; padding: 5pt; margin-top: 3pt; }
.pb-key { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1pt; border-radius: 8pt; border-bottom: 2.4pt solid rgba(0, 0, 0, .14); box-shadow: 0 0 0 .5pt rgba(0, 0, 0, .08); padding: 2pt 2pt 1.5pt; overflow: hidden; color: #1d1f24; }
.pb-key.dark { color: #fff; }
.pb-key.above { flex-direction: column-reverse; }
.pb-key.folder { border-radius: 2.5pt 8pt 8pt 8pt; }
.pb-key.folder::before { content: ""; position: absolute; top: 0; left: 0; width: 38%; height: 6%; min-height: 3pt; background: rgba(0, 0, 0, .16); border-radius: 0 0 5pt 0; }
.pb-key.now::after { content: ""; position: absolute; right: 4pt; top: 4pt; width: 5pt; height: 5pt; border-radius: 50%; background: currentColor; opacity: .35; }
.pb-sym { width: 100%; flex: none; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; line-height: 1; overflow: hidden; }
.pb-sym img { width: 92%; height: 100%; min-height: 0; object-fit: contain; }
.pb-sym img.photo { border-radius: 5pt; object-fit: cover; width: 92%; }
.pb-lbl { font-weight: 800; line-height: 1.08; text-align: center; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 1pt; }
.pb-key.no-sym .pb-lbl { white-space: normal; word-break: keep-all; overflow-wrap: normal; text-wrap: balance; }
.pb-lbl2 { font-weight: 600; font-style: italic; line-height: 1.05; text-align: center; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .8; }
.pb-goto { position: absolute; right: 3pt; top: 3pt; font-size: 6.5pt; font-weight: 800; background: rgba(255, 255, 255, .85); color: #1d1f24; border-radius: 99pt; padding: .5pt 4pt; box-shadow: 0 0 0 .5pt rgba(0, 0, 0, .2); }
.pb-empty { min-width: 0; min-height: 0; }
.pb-foot { flex: none; display: grid; grid-template-columns: 1fr auto auto; gap: 12pt; align-items: center; padding: 3pt 2pt 0; border-top: .75pt solid #d5d2c8; margin-top: auto; font-size: 7.5pt; color: #4a4f5a; }
.pb-tips { line-height: 1.35; max-width: 4.6in; }
.pb-tips b { color: #1d1f24; }
.pb-key-legend { display: flex; flex-wrap: wrap; gap: 3pt 8pt; max-width: 3.8in; }
.pb-key-legend span { display: inline-flex; align-items: center; gap: 3pt; white-space: nowrap; }
.pb-key-legend i { width: 8pt; height: 8pt; border-radius: 2.5pt; box-shadow: inset 0 0 0 .6pt rgba(0, 0, 0, .25); display: inline-block; }
.pb-made { font-weight: 700; color: #8a8f99; white-space: nowrap; }
/* the cover */
.pb-cover { display: grid; grid-template-columns: 1.15fr 1fr; gap: 26pt; padding: 8pt 6pt; }
.pc-left, .pc-right { display: flex; flex-direction: column; min-height: 0; }
.pc-hello { font-size: 11pt; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; color: #2f6fe4; }
.pc-name { font-size: 44pt; font-weight: 800; line-height: 1; letter-spacing: -.02em; margin: 2pt 0 8pt; }
.pc-photo { width: 1.25in; height: 1.25in; border-radius: 50%; object-fit: cover; border: 3pt solid #fff; box-shadow: 0 0 0 1pt #d5d2c8; position: absolute; }
.pc-left { position: relative; }
.pc-left .pc-photo { right: 0; top: 0; }
.pc-lead { font-size: 12pt; line-height: 1.45; margin: 0 0 10pt; max-width: 4.6in; }
.pb-cover h2 { font-size: 12pt; font-weight: 800; margin: 4pt 0 6pt; padding-bottom: 3pt; border-bottom: 1.2pt solid #1d1f24; }
.pc-tips { list-style: none; margin: 0; padding: 0; counter-reset: tip; display: grid; gap: 5pt; }
.pc-tips li { counter-increment: tip; position: relative; padding-left: 22pt; font-size: 10pt; line-height: 1.38; }
.pc-tips li::before { content: counter(tip); position: absolute; left: 0; top: 0; width: 15pt; height: 15pt; border-radius: 50%; background: #2f6fe4; color: #fff; font-weight: 800; font-size: 8.5pt; display: grid; place-items: center; }
.pc-fields { margin-top: auto; display: grid; gap: 9pt; padding-top: 10pt; }
.pc-field { display: grid; grid-template-columns: auto 1fr; gap: 8pt; align-items: end; font-size: 8.5pt; font-weight: 700; color: #4a4f5a; text-transform: uppercase; letter-spacing: .05em; }
.pc-line { border-bottom: .8pt solid #8d94a1; height: 14pt; }
.pc-right { background: #f6f4ef; border-radius: 12pt; padding: 14pt 16pt; }
.pc-toc { list-style: none; margin: 0 0 10pt; padding: 0; display: grid; gap: 2.5pt; columns: 1; font-size: 10pt; }
.pc-toc li { display: flex; align-items: baseline; gap: 4pt; }
.pc-toc-n { font-weight: 700; white-space: nowrap; }
.pc-dots { flex: 1; border-bottom: 1pt dotted #9aa0aa; transform: translateY(-3pt); }
.pc-toc-p { font-variant-numeric: tabular-nums; font-weight: 700; color: #4a4f5a; }
.pc-how { margin-top: auto; }
.pc-how h3 { font-size: 10pt; margin: 0 0 3pt; }
.pc-how p { font-size: 9pt; line-height: 1.4; margin: 0 0 6pt; }
.pc-pg { font-size: 7pt; font-weight: 800; background: #fff; border-radius: 99pt; padding: .5pt 4pt; box-shadow: 0 0 0 .5pt rgba(0, 0, 0, .25); }
.pc-legend { font-size: 8pt; max-width: none; }
.pc-foot { display: flex; align-items: center; gap: 8pt; margin-top: 12pt; padding-top: 8pt; border-top: .75pt solid #d5d2c8; font-size: 8pt; color: #5d6270; }
.pc-foot b { color: #1d1f24; }
.pc-logo { width: 22pt; height: 22pt; border-radius: 5pt; }
/* a printed schedule */
.sch-print-grid { align-content: center; }
.sch-print-cell { display: flex; flex-direction: column; gap: 3pt; min-height: 0; }
.sch-print-tag { font-size: 10pt; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: #4a4f5a; }
.sch-print-cell .pb-key { flex: 1; }
/* class summary print */
.dv-print .rp-table { font-size: 8.5pt; }
@media print {
  body.printing-paper > *:not(.print-sheet) { display: none !important; }
  html:has(body.printing-paper), body.printing-paper { background: #fff !important; }
  body.printing-paper .print-sheet { position: static; padding: 0; visibility: visible; background: #fff; page: paper; }
  body.printing-paper .print-sheet * { visibility: visible; }
}
/* goals in the progress report */
.rp-goal-note { font-size: 7.5pt; color: var(--rp-muted); margin-top: 1pt; }
.rp-goal-chart { width: 46%; }
.rp-goal-chart .goal-spark { width: 100%; max-width: 240px; }
.rp .goal-spark .gs-bar { fill: var(--rp-accent); }
.rp .goal-spark .gs-target { stroke: var(--rp-ink); }
.rp .goal-spark .gs-axis { stroke: #9aa1ae; }
.rp .goal-spark .gs-x { fill: var(--rp-muted); font-size: 8px; }
.rp-goals td { vertical-align: top; padding-top: 5pt; padding-bottom: 5pt; }
/* Mulberry's black line drawings: a soft light edge keeps them clear on dark buttons */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .key .sym img.drawn, :root:not([data-theme="light"]) .msg-item .sym img.drawn { filter: drop-shadow(0 0 1px rgba(255, 255, 255, .95)) drop-shadow(0 0 2px rgba(255, 255, 255, .6)); } }
:root[data-theme="dark"] .key .sym img.drawn, :root[data-theme="dark"] .msg-item .sym img.drawn { filter: drop-shadow(0 0 1px rgba(255, 255, 255, .95)) drop-shadow(0 0 2px rgba(255, 255, 255, .6)); }

/* ---- the move from the old address (Glyphabet → WordNorth) ---------------------------------- */
.move-banner { position: fixed; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50; display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 16px; border-radius: 999px; background: var(--surface); color: var(--text); border: 1px solid var(--line); box-shadow: 0 6px 24px rgba(0, 0, 0, .18); font-weight: 600; max-width: calc(100vw - 24px); }
.move-dlg { text-align: center; }
.move-logo { width: 84px; height: 84px; border-radius: 20px; margin: 4px auto 10px; display: block; }
.welcome-logo { width: 84px; height: 84px; border-radius: 20px; display: block; margin: 0 auto 6px; box-shadow: 0 4px 14px rgba(22, 56, 143, .25); }
