/* ==========================================================================
   Why Wrong
   --------------------------------------------------------------------------
   Light and plain, like the teacher-facing products it sits beside: white
   ground, one blue for actions, green for correct, amber and red for problems,
   and twelve misconception hues that only ever appear in the data. No glows,
   no gradients, no decoration. The only motion is the rows reordering,
   because that is the mechanism.
   ========================================================================== */

:root {
  color-scheme: light;

  --bg:          #fffaf3;
  --bg-2:        #fdf1e3;
  --bg-3:        #f7e6d2;
  --surface:     #fffdf9;
  --surface-2:   #fcf3e7;
  --surface-3:   #f5e7d5;
  --ink:         #0b3a4a;
  --ink-2:       #2f5563;
  --muted:       #56707b;
  --line:        #eddcc4;
  --line-soft:   #f4e8d6;
  --line-hi:     #dcc7a6;

  --accent:      #0b7285;
  --accent-2:    #085a69;
  --accent-tint: #e2f3f4;
  --accent-line: #b5dfe2;
  --coral:       #c23a28;
  --coral-2:     #a92f1f;

  --good:        #0f7b6c;
  --good-tint:   #e3f4ef;
  --good-line:   #b6e0d5;
  --accent-hi:   var(--good);   /* the no-clear-pattern band on the sorted map */
  --warn:        #a35a05;
  --warn-tint:   #fdf3e3;
  --warn-line:   #f0d3a5;
  --bad:         #b3261e;
  --bad-tint:    #fcecea;
  --bad-line:    #f0c3bf;

  /* response encoding */
  --correct:     #f1e5d3;
  --slip:        #a99f91;

  /* 12 misconception hues, tuned to stay apart from each other on white */
  --m1:  #e0533f;
  --m2:  #f28c28;
  --m3:  #e6b41e;
  --m4:  #86bb3c;
  --m5:  #2e9e66;
  --m6:  #17a3a0;
  --m7:  #36a0dc;
  --m8:  #3a64d8;
  --m9:  #7556d4;
  --m10: #b158c9;
  --m11: #e0619d;
  --m12: #96694a;

  --cell: 16px;
  --gap: 3px;
  --row: 19px;
  --r: 10px;
  --r-s: 8px;
  --shadow-1: 0 1px 2px rgba(11,58,74,.05);
  --shadow-2: 0 18px 40px -18px rgba(11,58,74,.22), 0 2px 6px rgba(11,58,74,.05);
  --ease: cubic-bezier(.22,.9,.28,1);
  --ease-out: cubic-bezier(.16,1,.3,1);

  --display: Fredoka, Lexend, "Source Sans 3", system-ui, sans-serif;
  --body: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Source Code Pro", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

/* `hidden` has to win over any display a component sets for itself. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  font-variant-numeric: tabular-nums;
}

h1, h2, h3 { margin: 0; line-height: 1.15; font-family: var(--display); font-weight: 600; letter-spacing: -0.02em; color: var(--ink); }
p { margin: 0; }
b { font-weight: 700; color: var(--ink); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

::selection { background: var(--accent-line); color: var(--ink); }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 32px; }

.mono, .mono-block { font-family: var(--mono); font-variant-ligatures: none; }

* { scrollbar-width: thin; scrollbar-color: var(--line-hi) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-hi); border-radius: 10px; border: 3px solid var(--bg); }
*::-webkit-scrollbar-track { background: transparent; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* -------------------------------- nav ---------------------------------- */

.bar { position: relative; z-index: 40; background: var(--bg); border-bottom: 1px solid var(--line); }

.bar-top {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 32px;
  height: 66px;
  display: flex;
  align-items: center;
  gap: 32px;
}

/* The wordmark: a textbook serif, with "Wrong" underlined in red pen. */
.brand {
  display: inline-block;
  font-family: "Source Serif 4", Georgia, serif;
  font-weight: 700;
  font-size: 24px;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-u { position: relative; display: inline-block; }
.brand-u svg { position: absolute; left: -2px; bottom: -7px; width: calc(100% + 5px); height: 9px; overflow: visible; }
.brand-mark { width: 28px; height: 28px; flex: 0 0 28px; display: block; }

.nav-links { display: flex; gap: 4px; }
.nav-links a {
  color: var(--ink-2);
  font-size: 16px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--r-s);
}
.nav-links a:hover { color: var(--ink); background: var(--bg-2); text-decoration: none; }

.bar-end { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

/* ------------------------------ buttons -------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--r-s);
  border: 1px solid var(--line-hi);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover:not(:disabled) { background: var(--bg-2); border-color: var(--muted); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }

.btn-primary { background: var(--coral); border-color: var(--coral); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--coral-2); border-color: var(--coral-2); }

.btn-quiet { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-quiet:hover:not(:disabled) { background: var(--bg-2); border-color: transparent; color: var(--ink); }

.btn-lg { height: 48px; padding: 0 22px; font-size: 16.5px; }
.btn-tiny { height: 30px; padding: 0 12px; font-size: 14px; }

.linkish { font: inherit; background: none; border: none; padding: 0; color: var(--accent); cursor: pointer; }
.linkish:hover { text-decoration: underline; text-underline-offset: 3px; }

/* -------------------------------- hero --------------------------------- */

.hero { padding: 72px 0 80px; }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, .98fr);
  gap: 64px;
  align-items: center;
}

.eyebrow { font-size: 16px; font-weight: 600; color: var(--accent); margin-bottom: 16px; }

.hero h1 {
  font-size: clamp(34px, 4vw, 50px);
  line-height: 1.1;
  letter-spacing: -0.03em;
  max-width: 17ch;
  text-wrap: balance;
}

.lede {
  margin-top: 22px;
  max-width: 54ch;
  color: var(--ink-2);
  font-size: 19px;
  line-height: 1.55;
  text-wrap: pretty;
}

.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 32px; }
.hero-trust { margin-top: 18px; font-size: 15px; color: var(--muted); }

/* The worked example: one real question from the sample class, every option
   labelled with what choosing it means. It is the whole idea in one card. */
.ex {
  margin: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.ex-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14.5px;
  color: var(--muted);
}
.ex-head b { color: var(--ink-2); font-weight: 600; }
.ex-q { padding: 20px 22px 6px; font-family: var(--display); font-size: 21px; font-weight: 500; letter-spacing: -0.01em; }
.ex-opts { list-style: none; margin: 0; padding: 12px 22px 20px; display: grid; gap: 14px; }
.ex-opt { display: grid; grid-template-columns: 26px minmax(54px, auto) 1fr 30px; gap: 4px 12px; align-items: center; }
.ex-l {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border: 1px solid var(--line-hi);
  border-radius: 6px;
  font-size: 14px; font-weight: 700; color: var(--ink-2);
}
.ex-opt.is-correct .ex-l { background: var(--good); border-color: var(--good); color: #fff; }
.ex-t { font-size: 17px; font-weight: 600; white-space: nowrap; }
.ex-track { height: 10px; background: var(--bg-3); border-radius: 5px; overflow: hidden; }
.ex-fill { display: block; height: 100%; border-radius: 5px; background: var(--slip); }
.ex-opt.is-correct .ex-fill { background: var(--good); }
.ex-n { font-size: 15px; color: var(--muted); text-align: right; }
.ex-why { grid-column: 2 / -1; display: flex; align-items: baseline; gap: 8px; font-size: 15px; color: var(--ink-2); line-height: 1.35; }
.ex-why .sw { transform: translateY(1px); }
/* A sentence on one line would squeeze the bar away, so it sits underneath. */
.ex-long .ex-opt { grid-template-columns: 26px 1fr 30px; }
.ex-long .ex-t { white-space: normal; line-height: 1.3; }
.ex-long .ex-n { grid-column: 3; grid-row: 1; }
.ex-long .ex-track { grid-column: 2 / -1; grid-row: 2; }
.ex-opt.is-correct .ex-why { color: var(--good); font-weight: 600; }
.ex-opt.is-slip .ex-why { color: var(--muted); }
.ex-foot { padding: 16px 22px; background: var(--bg-2); border-top: 1px solid var(--line-soft); font-size: 15.5px; color: var(--ink-2); }
sup { font-size: .68em; line-height: 0; }

/* ---------------------------- how it works ----------------------------- */

.how { position: relative; background: var(--bg-2); padding: 104px 0 80px; }
/* The tide line between the hero and the section under it. */
.how::before {
  content: "";
  position: absolute;
  inset: -1px 0 auto;
  height: 42px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 42' preserveAspectRatio='none'%3E%3Cpath d='M0 0h600v16c-50 22-100 22-150 8s-100-14-150 0-100 14-150 0S50-2 0 16z' fill='%23fffaf3'/%3E%3C/svg%3E") repeat-x 0 0 / 600px 42px;
}

.sec-head { margin-bottom: 32px; }
.sec-head h2 { font-size: clamp(27px, 3vw, 36px); margin-bottom: 10px; }
.sec-head p { color: var(--ink-2); font-size: 18px; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.how-step { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 26px 26px 28px; box-shadow: var(--shadow-1); }
.how-n {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: 9px;
  background: var(--accent-tint);
  color: var(--accent);
  font-family: var(--display);
  font-weight: 600;
  font-size: 17px;
  margin-bottom: 18px;
}
.how-step h3 { font-size: 19px; line-height: 1.3; margin-bottom: 10px; }
.how-step p { color: var(--ink-2); font-size: 16.5px; }

/* ------------------------------ app intro ------------------------------ */

.app-intro { padding: 64px 0 8px; }

.app-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; }
.app-head h2 { font-size: clamp(27px, 3vw, 36px); margin-bottom: 10px; }
.btn.bar-toggle { display: none; }

/* A field is one bordered control with its label inside, so the toolbar reads
   as a row of controls rather than a row of labels and boxes. */
.toolbar {
  margin-top: 26px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.toolbar-in {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px 22px;
  flex-wrap: wrap;
}
.tool-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tool-end { margin-left: auto; }

.field {
  display: inline-flex;
  align-items: center;
  height: 40px;
  background: var(--bg);
  border: 1px solid var(--line-hi);
  border-radius: var(--r-s);
  transition: border-color .15s, box-shadow .15s;
}
.field:hover { border-color: var(--muted); }
.field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }

.field label {
  padding-left: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.field input, .field select {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  background: transparent;
  border: none;
  height: 100%;
  padding: 0 12px 0 8px;
  outline: none;
}
.field input { width: 62px; }
.field-select select {
  max-width: 250px;
  padding-right: 32px;
  cursor: pointer;
  text-overflow: ellipsis;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23667387' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
.field select option { background: var(--bg); color: var(--ink); }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }

.pack-line { margin-top: 14px; font-size: 15px; color: var(--muted); min-height: 23px; }
.pack-line .gen-flag {
  display: inline-block;
  background: var(--accent-tint);
  color: var(--accent);
  border: 1px solid var(--accent-line);
  border-radius: 6px;
  padding: 0 8px;
  margin-left: 8px;
  font-size: 13.5px;
  font-weight: 600;
}

/* ------------------------------- summary ------------------------------- */

/* Flex rather than grid so a short last row stretches to fill: a grid leaves
   an empty cell, which the 1px-gap hairlines paint as a grey block. */
.summary {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.sum {
  flex: 1 1 150px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  background: var(--bg);
  padding: 20px 20px 18px;
  min-width: 0;
}
.sum-v {
  font-family: var(--display);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--ink);
}
.sum-v.ok { color: var(--accent); }
.sum-v.warn { color: var(--warn); }
.sum-sub { font-size: 14px; font-weight: 600; color: var(--warn); margin-top: 4px; }
.sum-k {
  font-size: 15px;
  line-height: 1.3;
  color: var(--muted);
  margin-top: 10px;
  text-wrap: balance;
}

.sum-go { font: inherit; text-align: left; border: none; cursor: pointer; transition: background .15s; color: inherit; }
.sum-go:hover { background: var(--bg-2); }
.sum-go:hover .sum-k { color: var(--accent); }

.strip-note { margin-top: 16px; font-size: 16.5px; color: var(--ink-2); }
.paste-notes { margin-top: 12px; padding: 10px 14px; background: var(--warn-tint); border: 1px solid var(--warn-line); border-radius: var(--r-s); color: var(--ink-2); font-size: 15.5px; }
.paste-notes-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.paste-notes-head b { font-weight: 600; color: var(--ink); }
.paste-notes ul { margin: 6px 0 0; padding-left: 20px; }
.save-nudge { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; padding: 10px 14px; background: var(--warn-tint); border: 1px solid var(--warn-line); border-radius: var(--r-s); color: var(--warn); font-size: 15.5px; }

body.has-import .sample-only { display: none; }
.import-only { display: none; }
body.has-import .import-only { display: inline-flex; }

/* --------------------------------- tabs -------------------------------- */

.tabs {
  position: sticky;
  top: 0;
  z-index: 30;
  margin-top: 30px;
  background: rgba(255,250,243,.96);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.tabs-in { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.tabs-in::-webkit-scrollbar { display: none; }

.tab {
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  color: var(--muted);
  padding: 15px 12px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .12s, border-color .12s;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

/* --------------------------------- views ------------------------------- */

.main { padding: 36px 32px 88px; }

.view { display: none; }
.view.is-active { display: block; }
.view.entering, .summary.entering { animation: view-in .24s var(--ease-out, ease-out); }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.view-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 28px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}
/* The heading's text gives a little before its buttons drop below it. */
.view-head > div:first-child { flex: 1 1 400px; max-width: 660px; }

.view-head h2 {
  font-size: clamp(23px, 2.4vw, 29px);
  margin-bottom: 10px;
  text-wrap: balance;
}

.sub { color: var(--ink-2); max-width: 78ch; font-size: 17px; text-wrap: pretty; }

.note {
  font-size: 15.5px;
  color: var(--muted);
  max-width: 86ch;
  margin-top: 16px;
}

.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* plain card, used by everything card-like */
.board, .group, .item, .metric, .stu, .empty, .defended, .modal-card, .pop, .mat, .dg, .dr-facts {
  background: var(--bg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
}

/* -------------------------------- matrix ------------------------------- */

.hint {
  list-style: none;
  margin: 0 0 18px;
  border-radius: var(--r);
  padding: 12px 18px;
  font-size: 15.5px;
  color: var(--ink-2);
  background: var(--accent-tint);
  border: 1px solid var(--accent-line);
  display: flex;
  gap: 6px 28px;
  flex-wrap: wrap;
}
.hint li { position: relative; padding-left: 14px; }
.hint li::before {
  content: "";
  position: absolute; left: 0; top: .6em;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent);
}
.hint b { color: var(--ink); }

.board {
  border-radius: 12px;
  padding: 20px 0 20px 20px;
  overflow: hidden;
  position: relative;
}

.board { scroll-margin-top: 66px; }
.board-scroll { overflow-x: auto; overflow-y: hidden; padding-right: 20px; position: relative; }

.matrix { position: relative; }

.m-row {
  position: absolute;
  left: 0; top: 0;
  display: flex;
  align-items: center;
  gap: var(--gap);
  height: var(--row);
  transition: transform .9s var(--ease);
  will-change: transform;
}

.m-head { display: contents; }
.m-name {
  width: 116px;
  flex: 0 0 116px;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  padding: 0;
  transition: padding-left .45s var(--ease), width .45s var(--ease), flex-basis .45s var(--ease), color .3s;
}
.matrix.sorted .m-name { width: 194px; flex-basis: 194px; padding-left: 88px; }
/* Almost as close to another group: only worth marking once the map shows groups. */
.matrix.sorted .m-name.m-between { text-decoration: underline dashed var(--warn); text-underline-offset: 3px; }

/* Names stay put when the map scrolls sideways, or on a phone you lose track of
   whose row you are reading by the tenth question. The background only covers
   the name itself, so the group bars show through the padding, and on the sorted
   map the padding is allowed to scroll away. */
.m-name { position: sticky; left: 0; z-index: 2; background: var(--bg); background-clip: content-box; }
.matrix.sorted .m-name { left: -88px; }
.m-name:hover { color: var(--accent); text-decoration: underline; }

.m-cell {
  width: var(--cell);
  height: var(--cell-h, var(--cell));
  border-radius: 3px;
  background: var(--correct);
  flex: 0 0 var(--cell);
  border: none;
  padding: 0;
  cursor: pointer;
  transition: opacity .2s;
}
.m-cell.slip { background: var(--slip); }

html.big-class { --row: 12px; --cell-h: 10px; }
html.big-class .m-cell { border-radius: 2px; }
html.big-class .m-name, html.big-class .m-score { font-size: 11px; line-height: 12px; }
html.big-class .show-letters .m-cell[data-letter]::after { font-size: 9px; }
html.key-above .legend-head { margin-top: 0; padding-top: 0; border-top: none; }
html.key-above .legend { padding-bottom: 20px; }

.show-letters .m-cell[data-letter], .show-letters .leg .sw[data-letter] { display: grid; place-items: center; }
.show-letters .m-cell[data-letter]::after, .show-letters .leg .sw[data-letter]::after {
  content: attr(data-letter);
  font: 700 10.5px/1 var(--mono);
  color: #fff;
  text-shadow: 0 0 2px rgba(0,0,0,.85), 0 0 1px rgba(0,0,0,.85);
}
.show-letters .leg .sw[data-letter] { width: 16px; height: 16px; }
#show-letters[aria-pressed="true"] { background: var(--accent-tint); border-color: var(--accent-line); color: var(--accent-2); }
.m-cell:hover {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
  position: relative;
  z-index: 2;
}
.m-cell.omit {
  background: repeating-linear-gradient(-45deg, transparent, transparent 2px, var(--line-hi) 2px, var(--line-hi) 4px);
  box-shadow: inset 0 0 0 1px var(--line);
}

.matrix.filtered .m-cell { opacity: .12; }
.matrix.filtered .m-cell.lit { opacity: 1; }
/* An unlabelled pattern's picks are grey cells; darken them so the line-up shows. */
.matrix.filtered .m-cell.lit-unl { background: color-mix(in srgb, var(--slip) 45%, var(--ink)); }

.m-score {
  font-size: 13px;
  color: var(--muted);
  margin-left: 12px;
  white-space: nowrap;
}

.band {
  position: absolute;
  left: 0;
  width: 4px;
  border-radius: 2px;
  opacity: 0;
  transition: opacity .5s .5s;
}
.band.on { opacity: 1; }

.band-tag {
  position: absolute;
  left: 12px;
  width: 70px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity .5s .55s;
  pointer-events: none;
  line-height: 1.2;
}
.band-tag.on { opacity: 1; }

/* -------------------------------- legend ------------------------------- */

.legend-actions { display: inline-flex; gap: 8px; }
.legend-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-family: var(--display);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}

/* An even grid, not a ragged run of pills: each entry is a row with its count
   right-aligned, so the key reads as a table. */
.legend {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  gap: 6px 8px;
  padding-top: 14px;
}

.leg {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font: inherit;
  font-size: 14.5px;
  text-align: left;
  color: var(--ink-2);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  padding: 7px 12px 7px 10px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.leg > span:nth-child(3), .leg-static > span:nth-child(2) {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.leg:hover { background: var(--bg-2); border-color: var(--line-hi); }
.leg.is-on { background: var(--ink); color: #fff; border-color: var(--ink); }
.leg.is-on .leg-n, .leg.is-on .leg-c { color: rgba(255,255,255,.72); }
.leg-static { cursor: default; background: var(--bg-2); }
.leg-static:hover { background: var(--bg-2); border-color: var(--line); }

.sw { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 12px; display: inline-block; }
.leg-n { font-size: 13px; font-weight: 700; color: var(--muted); }
.leg-c { font-size: 13px; color: var(--muted); margin-left: auto; padding-left: 6px; }
.sw-omit {
  background: repeating-linear-gradient(-45deg, transparent, transparent 2px, var(--line-hi) 2px, var(--line-hi) 4px);
  box-shadow: inset 0 0 0 1px var(--line);
}

/* -------------------------------- groups ------------------------------- */

.groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr));
  gap: 18px;
  align-items: start;
}

.group {
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}

.group-top {
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line-soft);
  border-top: 4px solid var(--gc, var(--accent));
  background: color-mix(in srgb, var(--gc, var(--accent)) 6%, white);
}
.group.secure { --gc: var(--good); }
.group.thin { --gc: var(--warn); }
/* The grey of an unlabelled wrong answer on the class map, because that is what it is built from. */
.group.unlabelled { --gc: var(--slip); }
.group.unlabelled .group-top { border-top-style: dashed; }

.unl-list { list-style: none; margin: 4px 0 6px; padding: 0; }
.unl-list li { padding: 7px 0; border-bottom: 1px solid var(--line-soft); line-height: 1.45; }
.unl-list li:last-child { border-bottom: none; }
.unl-q {
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-tint);
  border: 1px solid var(--accent-line);
  border-radius: 6px;
  padding: 0 7px;
  cursor: pointer;
}
.unl-q:hover { background: var(--accent); color: #fff; }
.unl-stem { color: var(--ink-2); }
.unl-pick { color: var(--muted); font-size: 15px; margin-top: 2px; }
.unl-pick b { color: var(--ink); font-weight: 600; }

.group-n {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.group h3 { font-size: 20px; margin: 10px 0 14px; line-height: 1.25; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips-lab { font-size: 13.5px; color: var(--muted); margin-bottom: 6px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  font-size: 13.5px;
  padding: 3px 10px 3px 8px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.chip:hover { border-color: var(--line-hi); background: var(--bg-2); }

.group-body { padding: 20px 24px 22px; }

.belief {
  font-size: 16px;
  color: var(--ink-2);
  padding-left: 14px;
  border-left: 3px solid var(--gc, var(--line));
  margin-bottom: 20px;
}

.lab {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}
.group-more { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.group-more summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.group-more h4 { margin: 14px 0 4px; font-family: var(--display); font-size: 16.5px; font-weight: 600; }
.group-more-p { font-family: var(--mono); font-size: 14px; font-weight: 400; color: var(--muted); }

.lab.accent { color: var(--accent); }
.lab.warn { color: var(--warn); }
.lab-n { font-weight: 500; color: var(--muted); }
.roster-note { margin: 0 0 6px; }
.sub-group + .sub-group { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.sub-group .plan { margin-bottom: 10px; }

.plan { font-size: 16px; color: var(--ink); margin-bottom: 20px; }

.checks { margin: 0; padding-left: 20px; color: var(--ink-2); font-size: 16px; }
.checks li { margin-bottom: 5px; }
.checks li::marker { color: var(--muted); }

.roster {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 14px;
  color: var(--muted);
  line-height: 1.75;
}
.roster-names { display: flex; flex-wrap: wrap; gap: 5px; }
.rname {
  font: inherit;
  font-size: 13.5px;
  max-width: 100%;
  text-align: left;
  overflow-wrap: anywhere;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 8px;
  color: var(--ink-2);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.rname:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.roster-between .rname { border-style: dashed; border-color: var(--warn-line); background: var(--warn-tint); }
.rname-alt { color: var(--warn); }
.rname:hover .rname-alt { color: inherit; }

.pill {
  display: inline-block;
  font-family: var(--body);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  border: 1px solid var(--line);
  background: var(--bg-2);
  padding: 1px 8px;
  border-radius: 6px;
  margin-left: 10px;
  vertical-align: 3px;
  letter-spacing: 0;
}
.pill-ai { color: var(--accent); background: var(--accent-tint); border-color: var(--accent-line); }

/* --------------------------------- items ------------------------------- */

.items { display: flex; flex-direction: column; gap: 12px; }

.item {
  font: inherit;
  text-align: left;
  width: 100%;
  cursor: pointer;
  border-radius: 12px;
  padding: 20px 24px;
  color: var(--ink);
  position: relative;
  transition: border-color .15s, box-shadow .15s;
}
.item::before {
  content: "";
  position: absolute; left: -1px; top: 14px; bottom: 14px; width: 4px;
  border-radius: 0 3px 3px 0;
  background: var(--ic, var(--line-hi));
}
.item:hover { border-color: var(--line-hi); box-shadow: var(--shadow-2); }
.item.broken, .item.key { --ic: var(--bad); }
.item.weak { --ic: var(--warn); }
.item.diagnostic { --ic: var(--good); }
.item.minor, .item.watch { --ic: var(--muted); }
.item.strong, .item.ok { --ic: var(--line-hi); }

.item-top {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: baseline;
  flex-wrap: wrap;
}

.item-stem { font-size: 17px; color: var(--ink); font-weight: 600; }
.item-id { font-size: 14px; color: var(--muted); margin-right: 10px; font-weight: 600; }

.verdict {
  font-size: 13.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 6px;
  white-space: nowrap;
  background: var(--bg-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
}
.v-broken, .v-key { background: var(--bad-tint); color: var(--bad); border-color: var(--bad-line); }
.v-weak { background: var(--warn-tint); color: var(--warn); border-color: var(--warn-line); }
.v-diagnostic, .v-strong { background: var(--good-tint); color: var(--good); border-color: var(--good-line); }

.item-note { font-size: 15.5px; color: var(--ink-2); margin-top: 10px; }

.flags { margin: 14px 0 0; padding: 0; list-style: none; }
.flags li {
  font-size: 15.5px;
  color: var(--ink-2);
  padding-left: 18px;
  position: relative;
  margin-bottom: 5px;
}
.flags li::before {
  content: "";
  position: absolute; left: 0; top: 9px;
  width: 7px; height: 7px; border-radius: 2px;
  background: var(--bad);
}
.flags li.minor::before { background: var(--muted); }

.bars { margin-top: 16px; display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.bar-t {
  width: 180px; flex: 0 0 180px;
  color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 15px;
}
.bars-long .bar-t { display: flex; width: 300px; flex-basis: 300px; white-space: normal; overflow: visible; }
.bars-long .opt-l { flex: none; }
.bar-row.correct .bar-t { color: var(--good); font-weight: 700; }

/* The letter an option is printed under on paper. */
.opt-l { display: inline-block; width: 1.6em; color: var(--muted); font-weight: 600; }
.bar-row.correct .opt-l, .opt-correct .opt-l { color: inherit; }
.bar-track { flex: 1; height: 8px; background: var(--bg-3); border-radius: 4px; overflow: hidden; min-width: 60px; }
.bar-fill { display: block; height: 100%; border-radius: 4px; background: var(--slip); }
.bar-row.correct .bar-fill { background: var(--good); }
.bar-c { font-size: 13.5px; color: var(--muted); width: 56px; text-align: right; }

.defended {
  margin-top: 0;
  margin-bottom: 6px;
  padding: 22px 24px;
  border-radius: 12px;
  background: var(--good-tint);
  border-color: var(--good-line);
  box-shadow: none;
}
.defended:empty { display: none; }
.defended h3 { margin: 0 0 10px; font-family: var(--display); font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.defended p { margin: 0 0 10px; color: var(--ink-2); font-size: 16px; }
.defended p:last-child { margin-bottom: 0; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2); padding: 3px; gap: 2px; }
.seg-b {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted);
  padding: 5px 14px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.seg-b:hover { color: var(--ink); }
.seg-b.is-on { background: var(--bg); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow-1); }

.seg-wrap { flex-wrap: wrap; }
.student-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 14px; }
.student-count { color: var(--muted); font-size: 14.5px; }

.search {
  font: inherit;
  font-size: 15.5px;
  height: 40px;
  min-width: 240px;
  padding: 0 14px 0 38px;
  border: 1px solid var(--line-hi);
  border-radius: var(--r-s);
  background: var(--bg);
  color: var(--ink);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23667387' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 13px center;
  transition: border-color .15s, box-shadow .15s;
}
.search::placeholder { color: var(--muted); }
.search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }

.empty {
  border-radius: 12px;
  padding: 28px 30px;
}
.empty h3 { margin: 0 0 10px; font-family: var(--display); font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.empty p { color: var(--ink-2); font-size: 16px; margin-bottom: 9px; }
.empty p:last-child { margin-bottom: 0; }

/* ------------------------------- students ------------------------------- */

.students { display: flex; flex-direction: column; gap: 8px; }

.stu {
  font: inherit;
  color: var(--ink);
  text-align: left;
  display: grid;
  grid-template-columns: minmax(150px, 220px) 1fr auto;
  gap: 18px;
  align-items: center;
  border-radius: var(--r);
  padding: 14px 20px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.stu:hover { border-color: var(--line-hi); box-shadow: var(--shadow-2); }

.stu-l { min-width: 0; }
.stu-name { font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }
.stu-meta { font-size: 14px; color: var(--muted); margin-top: 2px; }
.stu-m { display: flex; flex-wrap: wrap; gap: 5px; }
.stu-r { display: flex; align-items: center; gap: 16px; }
.stu-score { font-size: 15px; font-weight: 600; color: var(--ink-2); }
.stu-go { color: var(--muted); }
.stu:hover .stu-go { color: var(--accent); }
.chip-more, .chip-clear { color: var(--muted); cursor: default; }
.chip-clear { background: var(--good-tint); border-color: var(--good-line); color: var(--good); font-weight: 600; }
.chip-thin { background: var(--warn-tint); border-color: var(--warn-line); color: var(--warn); font-weight: 600; cursor: default; }
/* One answer points here: a question to ask, not a diagnosis. */
.chip-check { border-style: dashed; border-color: var(--warn-line); background: var(--warn-tint); color: var(--warn); cursor: default; }

/* ------------------------------ validation ----------------------------- */

.pred { margin-top: 18px; padding: 20px 24px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.pred h3 { font-size: 19px; margin-bottom: 8px; }
.pred p { color: var(--ink-2); font-size: 16px; margin: 0 0 10px; }
.pred-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 6px 18px; margin: 12px 0; }
.pred-row { display: flex; gap: 9px; align-items: flex-start; font-size: 15.5px; color: var(--ink); cursor: pointer; }
.pred-row input { margin-top: 4px; accent-color: var(--accent); }
.pred-result:empty { display: none; }
.pred-result { padding-top: 12px; border-top: 1px solid var(--line-soft); }
.pred-result .pred-sum { color: var(--ink); font-weight: 600; }

.empty-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.prog-verdict { padding: 18px 22px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-2); margin-bottom: 18px; }
.prog-verdict h3 { margin: 0 0 6px; font-family: var(--display); font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.prog-verdict p { margin: 0; color: var(--ink-2); font-size: 16px; }
.prog-verdict .prog-caveat { margin-top: 8px; font-size: 14.5px; color: var(--muted); }
.prog-verdict.is-improved { background: var(--good-tint); border-color: var(--good-line); }
.prog-verdict.is-worse { background: var(--bad-tint); border-color: var(--bad-line); }
.prog-verdict.is-unclear { background: var(--warn-tint); border-color: var(--warn-line); }

.prog-h { font-size: 19px; margin: 28px 0 12px; }
.prog-groups { display: grid; gap: 10px; }
.prog-group { padding: 14px 18px; border: 1px solid var(--line); border-left: 4px solid var(--gc); border-radius: var(--r-s); background: var(--surface); }
.prog-group-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.prog-group-n { font-size: 14px; font-weight: 700; color: var(--muted); }
.prog-group-score { font-family: var(--mono); font-size: 14.5px; color: var(--ink); white-space: nowrap; }
.prog-group-who { margin: 6px 0 0; font-size: 15px; color: var(--ink-2); }

.progs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 12px; }
.prog { padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.prog-top { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 12px; }
.prog-top .sw { flex: none; margin-top: 6px; }
.prog-name { flex: 1; min-width: 0; font-weight: 600; font-size: 16px; line-height: 1.35; }
.prog-read { flex: none; font-size: 13.5px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.prog-read.is-improved { color: var(--good); }
.prog-read.is-worse { color: var(--bad); }
.prog-row { display: grid; grid-template-columns: 52px 1fr 28px; gap: 8px; align-items: center; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.prog-track { height: 9px; background: var(--bg-3); border-radius: 5px; overflow: hidden; }
.prog-fill { display: block; height: 100%; border-radius: 5px; }
.prog-n { text-align: right; font-family: var(--mono); color: var(--ink); }
.prog-who { margin-top: 10px; font-size: 15px; }
.prog-who summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.prog-who p { margin: 6px 0 0; color: var(--ink-2); overflow-wrap: anywhere; }

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 14px;
}

.metric {
  border-radius: 12px;
  padding: 24px 24px 22px;
  position: relative;
  overflow: hidden;
}
.metric-v {
  font-family: var(--display);
  font-size: 44px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--accent);
}
.metric-k {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 12px;
}
.metric-x { font-size: 15px; color: var(--ink-2); margin-top: 8px; line-height: 1.5; }

.confusion { margin-top: 28px; overflow-x: auto; }
.confusion table { border-collapse: separate; border-spacing: 0; font-size: 15px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg); }
.confusion th, .confusion td { border-bottom: 1px solid var(--line-soft); border-right: 1px solid var(--line-soft); padding: 10px 18px; text-align: center; color: var(--ink-2); }
.confusion tr > :last-child { border-right: none; }
.confusion tbody tr:last-child > * { border-bottom: none; }
.confusion th { color: var(--muted); font-weight: 600; font-size: 14px; background: var(--bg-2); }
.confusion td.hot { background: var(--accent-tint); color: var(--accent); font-weight: 700; }
.confusion caption { text-align: left; color: var(--muted); font-size: 15.5px; margin-bottom: 12px; caption-side: top; }
/* The table can be wider than a phone and scroll. Its caption should not. */
.cap-in { display: block; position: sticky; left: 0; max-width: min(80ch, calc(100vw - 40px)); }

/* -------------------------------- method ------------------------------- */

.method { counter-reset: st; list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; max-width: 88ch; }
.method li {
  position: relative;
  padding: 24px 28px 24px 80px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  box-shadow: var(--shadow-1);
}
.method li::before {
  counter-increment: st;
  content: counter(st);
  position: absolute; left: 26px; top: 24px;
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--accent-tint);
  color: var(--accent);
  font-family: var(--display);
  font-size: 16px;
  font-weight: 600;
}
.method h3 { font-size: 20px; margin-bottom: 10px; line-height: 1.3; }
.method p { color: var(--ink-2); font-size: 16.5px; margin-bottom: 10px; }
.method p:last-child { margin-bottom: 0; }

.mono-block {
  font-size: 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  padding: 13px 16px;
  color: var(--ink);
  overflow-x: auto;
  white-space: nowrap;
}

.params { font-size: 15px; color: var(--muted); }

/* -------------------------------- footer -------------------------------- */

.foot { background: var(--bg-2); border-top: 1px solid var(--line); padding: 36px 0 48px; }
.foot-in { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px 40px; flex-wrap: wrap; }
.foot-brand { display: flex; gap: 12px; align-items: flex-start; max-width: 74ch; }
.foot-brand .brand-mark { width: 24px; height: 24px; flex: 0 0 24px; margin-top: 1px; }
.foot-brand p { color: var(--muted); font-size: 15.5px; }
.foot-brand b { color: var(--ink); }
.foot-brand a { text-decoration: underline; text-underline-offset: 2px; }
.foot-links { display: flex; gap: 22px; align-items: center; font-size: 15.5px; font-weight: 600; white-space: nowrap; }

/* -------------------------------- modal -------------------------------- */

/* Centred by auto margins in a scrolling flex box, so a card taller than a
   short screen scrolls instead of losing its top edge. */
.modal {
  position: fixed; inset: 0;
  background: rgba(11,58,74,.45);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-y: auto;
  padding: 24px;
  z-index: 60;
}

.modal-card {
  border-radius: 16px;
  padding: 30px;
  max-width: 540px;
  width: 100%;
  margin: auto 0;
  border: none;
  box-shadow: 0 30px 70px -20px rgba(11,58,74,.35);
}
.modal-card h3 { font-size: 23px; margin-bottom: 12px; }
.modal-card > p { color: var(--ink-2); font-size: 16px; margin-bottom: 22px; }
.modal-wide { max-width: 680px; }

.modal-field { margin-bottom: 16px; }
.modal-field label {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}
.modal-field input {
  width: 100%;
  font: inherit;
  font-size: 16px;
  background: var(--bg);
  border: 1px solid var(--line-hi);
  color: var(--ink);
  border-radius: var(--r-s);
  padding: 10px 13px;
  transition: border-color .15s, box-shadow .15s;
}
.modal-field input::placeholder { color: var(--muted); }
.modal-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.hint-s { font-size: 14px; color: var(--muted); margin-top: 6px; }

.modal-progress {
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: var(--bg-2);
  padding: 13px 15px;
  font-size: 15px;
  color: var(--ink-2);
  margin-bottom: 14px;
}
.modal-progress .step { display: block; margin-bottom: 4px; }
.modal-progress .step:last-child { margin-bottom: 0; }
.modal-progress .step.done::before { content: "✓ "; color: var(--good); }
.modal-progress .step.active::before { content: "→ "; color: var(--accent); }

.modal-err { color: var(--bad); font-size: 15px; min-height: 20px; margin-bottom: 6px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }

.import-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

#import-text {
  width: 100%;
  height: 200px;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.6;
  border: 1px solid var(--line-hi);
  border-radius: var(--r-s);
  padding: 12px 14px;
  resize: vertical;
  color: var(--ink);
  background: var(--bg);
}
#import-text::placeholder { color: var(--muted); }
#import-text:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }

.import-report {
  margin-top: 14px;
  border-radius: var(--r-s);
  padding: 13px 15px;
  font-size: 15px;
  border: 1px solid var(--line);
  background: var(--bg-2);
}
.import-report { background: var(--bad-tint); border-color: var(--bad-line); }
.ir-h { font-weight: 700; margin-bottom: 6px; }
.ir-e { color: var(--bad); margin-bottom: 4px; }

/* ------------------------------ intro + tour ---------------------------- */

.intro-card { max-width: 540px; }
.intro-kicker {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 16px;
}
.intro-kicker .brand-mark { width: 22px; height: 22px; flex: 0 0 22px; }
.intro-card h3 { font-size: 25px; line-height: 1.2; text-wrap: balance; }
.modal-card > p.intro-note { font-size: 14.5px; color: var(--muted); margin-bottom: 4px; }

.intro-steps { list-style: none; counter-reset: s; margin: -6px 0 22px; padding: 0; display: grid; gap: 10px; }
.intro-steps li { counter-increment: s; display: flex; gap: 12px; align-items: baseline; font-size: 16px; color: var(--ink-2); }
.intro-steps li::before {
  content: counter(s);
  flex: 0 0 24px;
  height: 24px;
  display: grid; place-items: center;
  font-family: var(--display);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-tint);
  border-radius: 6px;
  transform: translateY(-1px);
}

.coach {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 90;
  width: min(480px, calc(100vw - 24px));
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 20px 16px;
  box-shadow: 0 24px 60px -16px rgba(11,58,74,.4);
}
.coach-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.coach-n { font-size: 14px; font-weight: 700; color: var(--accent); }
.coach-x {
  font: inherit; font-size: 20px; line-height: 1;
  width: 30px; height: 30px; margin-right: -6px;
  border: none; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer;
}
.coach-x:hover { background: var(--bg-2); color: var(--ink); }
.coach-title { margin: 0 0 6px; font-family: var(--display); font-size: 18px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
.coach-text { font-size: 16px; color: var(--ink-2); line-height: 1.5; }
.coach-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; }
.coach-dots { display: flex; gap: 5px; }
.coach-dots i { width: 16px; height: 4px; border-radius: 2px; background: var(--line); transition: background .2s; }
.coach-dots i.on { background: var(--accent); }
.coach-btns { display: flex; gap: 6px; }
.coach .btn { height: 34px; padding: 0 14px; font-size: 14.5px; }

/* The step's subject stays lit; everything else dims behind it. */
.tour-lit {
  position: relative;
  z-index: 45;
  border-radius: 12px;
  box-shadow: 0 0 0 3px var(--accent), 0 0 0 100vmax rgba(11,58,74,.42);
}

.mats-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.mat {
  font: inherit;
  color: var(--ink);
  text-align: left;
  display: block;
  width: 100%;
  border-radius: var(--r-s);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.mat:hover { border-color: var(--accent-line); background: var(--accent-tint); }
.mat-t { display: block; font-size: 16px; font-weight: 700; margin-bottom: 2px; }
.mat-d { display: block; font-size: 15px; color: var(--muted); }

/* ------------------------------ explainers ------------------------------ */

.info {
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  width: 18px; height: 18px;
  line-height: 1;
  padding: 0;
  margin-left: 6px;
  border-radius: 50%;
  border: 1px solid var(--line-hi);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  vertical-align: 1px;
  transition: background .12s, color .12s, border-color .12s;
}
.info:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.x-anchor { display: inline; }

.pop {
  position: absolute;
  /* Above the student and question panel (80), whose "?" buttons open these
     too, and below the tour (90). */
  z-index: 85;
  width: min(360px, calc(100vw - 24px));
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow-2);
}
/* It takes focus when it opens; keep its own corners under the focus ring. */
.pop:focus-visible { border-radius: 12px; }
.pop-h { font-family: var(--display); font-size: 16.5px; font-weight: 600; margin-bottom: 8px; letter-spacing: -0.01em; }
.pop-also {
  display: block;
  font-family: var(--body);
  font-size: 14px;
  font-weight: 400;
  color: var(--muted);
  margin-top: 2px;
}
.pop-b { font-size: 15px; color: var(--ink-2); margin-bottom: 10px; }
.pop-u { font-size: 15px; color: var(--ink); background: var(--accent-tint); border: 1px solid var(--accent-line); border-radius: 8px; padding: 10px 12px; }

/* -------------------------------- drawer -------------------------------- */

.drawer { position: fixed; inset: 0; z-index: 80; }
.drawer[hidden] { display: none; }
.drawer-scrim {
  position: absolute; inset: 0;
  background: rgba(11,58,74,.38);
  opacity: 0; transition: opacity .22s;
}
.drawer.is-open .drawer-scrim { opacity: 1; }

.drawer-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(560px, 100vw);
  background: var(--bg);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform .32s var(--ease-out);
  box-shadow: -24px 0 60px -24px rgba(11,58,74,.35);
}
.drawer.is-open .drawer-panel { transform: none; }

.drawer-bar {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: flex-end;
  padding: 14px 16px 0;
  background: linear-gradient(var(--bg) 70%, transparent);
  z-index: 2;
}
.drawer-x {
  font: inherit;
  font-size: 21px;
  line-height: 1;
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.drawer-x:hover { background: var(--bg-2); color: var(--ink); }

/* Step through the list the panel was opened from. */
.drawer-step { display: flex; align-items: center; gap: 4px; margin-right: auto; }
.drawer-nav {
  font: inherit; font-size: 20px; line-height: 1;
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink-2);
  cursor: pointer; transition: background .12s, color .12s, opacity .12s;
}
.drawer-nav:hover:not(:disabled) { background: var(--bg-2); color: var(--ink); }
.drawer-nav:disabled { opacity: .35; cursor: default; }
.drawer-pos { font-size: 14px; color: var(--muted); min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; }
.drawer-pos:focus { outline: none; }
.dr-step { animation: dr-step .18s var(--ease-out, ease-out); }
@keyframes dr-step { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.dr { padding: 4px 32px 44px; }
.dr-kicker {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}
.dr-title { font-size: 27px; margin-bottom: 22px; line-height: 1.15; overflow-wrap: anywhere; }

.dr-facts {
  display: flex;
  gap: 1px;
  background: var(--line);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 28px;
  box-shadow: none;
}
.dr-fact { background: var(--bg-2); padding: 14px 16px; flex: 1 1 auto; min-width: 0; }
.dr-fact-v { font-family: var(--display); font-size: 23px; font-weight: 600; letter-spacing: -0.02em; }
.dr-fact-k { font-size: 14px; color: var(--muted); margin-top: 4px; }

.dr-h {
  display: flex;
  align-items: center;
  font-family: var(--display);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  margin: 28px 0 12px;
}
.dr-sub { font-size: 15px; font-weight: 700; color: var(--ink); margin: 16px 0 6px; }
.dr-note { font-size: 16px; color: var(--ink-2); }
.dr-warn { padding: 10px 12px; background: var(--warn-tint); border: 1px solid var(--warn-line); border-radius: var(--r-s); color: var(--warn); }
.dr-plan { font-size: 16px; color: var(--ink); }

.dg { border-radius: 12px; padding: 18px 20px; margin-bottom: 12px; }
.dg-weak { opacity: .65; }
.dg-top { display: flex; align-items: center; gap: 10px; }
.dg-name { font-size: 16.5px; font-weight: 700; flex: 1; }
.dg-p { font-family: var(--display); font-size: 19px; font-weight: 600; letter-spacing: -0.02em; }
.dg-meter { height: 6px; background: var(--bg-3); border-radius: 3px; margin: 12px 0; overflow: hidden; }
.dg-fill { display: block; height: 100%; border-radius: 3px; }
.dg-belief { font-size: 15px; color: var(--ink-2); margin-bottom: 4px; }

.ev { margin-top: 14px; border-top: 1px solid var(--line-soft); padding-top: 12px; }
.ev-h {
  display: flex; align-items: center;
  font-size: 14.5px; font-weight: 700;
  color: var(--ink); margin-bottom: 8px;
}
.ev-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 10px;
  align-items: baseline;
  font-size: 14.5px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line-soft);
}
.ev-row:last-of-type { border-bottom: none; }
.ev-id { font-size: 13.5px; font-weight: 600; color: var(--muted); }
.ev-what { color: var(--ink-2); }
.ev-w { font-size: 13.5px; font-weight: 700; white-space: nowrap; }
.ev-row.for .ev-w { color: var(--bad); }
.ev-row.against .ev-w { color: var(--good); }
.ev-row.blank .ev-w, .ev-row.blank .ev-what { color: var(--muted); }
.ev-ask { font-size: 15px; color: var(--ink-2); margin-top: 10px; padding: 10px 12px; border-radius: var(--r-s); background: var(--warn-tint); border: 1px dashed var(--warn-line); }
.ev-ask b { color: var(--warn); font-weight: 700; }
.ev-sum { font-size: 14.5px; color: var(--muted); margin-top: 10px; }

.dr-more { margin-top: 8px; }
.dr-more summary { font-size: 15px; font-weight: 600; color: var(--accent); cursor: pointer; padding: 6px 0; }
.dr-more summary:hover { text-decoration: underline; text-underline-offset: 3px; }

.dr-verdict { border-radius: 12px; padding: 15px 18px; margin-bottom: 20px; background: var(--bg-2); border: 1px solid var(--line); }
.dr-verdict-t { font-family: var(--display); font-size: 17px; font-weight: 600; margin-bottom: 4px; letter-spacing: -0.01em; }
.dr-verdict-b { font-size: 15px; color: var(--ink-2); }
.dr-verdict.v-broken, .dr-verdict.v-key { background: var(--bad-tint); border-color: var(--bad-line); }
.dr-verdict.v-weak { background: var(--warn-tint); border-color: var(--warn-line); }
.dr-verdict.v-diagnostic, .dr-verdict.v-strong { background: var(--good-tint); border-color: var(--good-line); }
.dr-verdict.v-broken .dr-verdict-t, .dr-verdict.v-key .dr-verdict-t { color: var(--bad); }
.dr-verdict.v-weak .dr-verdict-t { color: var(--warn); }
.dr-verdict.v-diagnostic .dr-verdict-t, .dr-verdict.v-strong .dr-verdict-t { color: var(--good); }

.dr-defend {
  font-size: 15px;
  color: var(--ink-2);
  background: var(--good-tint);
  border: 1px solid var(--good-line);
  border-radius: var(--r-s);
  padding: 12px 14px;
  margin-bottom: 18px;
}

.opt { margin-bottom: 16px; }
.opt-head { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; margin-bottom: 6px; }
.opt-t { font-size: 15.5px; font-weight: 600; }
.opt-correct .opt-t { color: var(--good); font-weight: 700; }
.opt-n { font-size: 14px; color: var(--muted); white-space: nowrap; }
.opt-track { height: 8px; background: var(--bg-3); border-radius: 4px; overflow: hidden; }
.opt-fill { display: block; height: 100%; border-radius: 4px; background: var(--slip); }
.opt-tag { font-size: 14px; color: var(--muted); margin-top: 6px; display: flex; gap: 7px; align-items: baseline; }
.opt-mis { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.opt-slip { font-style: italic; }
.opt-found { margin-top: 4px; padding-left: 8px; border-left: 3px dashed var(--slip); color: var(--ink-2); font-weight: 600; }
.opt-who {
  font-size: 13.5px;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.7;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 7px 10px;
}

/* ------------------------------ responsive ----------------------------- */

@media (max-width: 1060px) {
  .hero-grid { grid-template-columns: 1fr; gap: 44px; }
  .hero h1 { max-width: 18ch; }
  .ex { max-width: 620px; }
}

@media (max-width: 900px) {
  .bar-top { padding: 0 20px; gap: 20px; }
  .wrap { padding: 0 20px; }
  .main { padding: 28px 20px 64px; }
  .hero { padding: 48px 0 56px; }
  .how { padding: 56px 0 60px; }
  .app-intro { padding-top: 56px; }
  .steps { grid-template-columns: 1fr; gap: 12px; }
  :root { --cell: 13px; --row: 16px; --gap: 2px; }
  .m-name { width: 84px; flex-basis: 84px; font-size: 12.5px; }
  .matrix.sorted .m-name { width: 140px; flex-basis: 140px; padding-left: 60px; left: -60px; }
  .band-tag { left: 8px; width: 54px; font-size: 10.5px; }
  .bar-t { width: 124px; flex-basis: 124px; }
  .bars-long .bar-row { flex-wrap: wrap; gap: 2px 12px; }
  .bars-long .bar-t { width: auto; flex: 1 1 100%; }
  .stu { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .stu-r { justify-content: space-between; }
  .dr { padding: 4px 20px 32px; }
  .drawer-panel { width: 100vw; }
  .method li { padding-left: 26px; padding-top: 74px; }
  .method li::before { top: 24px; }
}

/* Phones: the toolbar folds away behind "Change class" and opens as a tidy
   grid, so the analysis is not pushed down by five rows of controls. */
@media (max-width: 720px) {
  .nav-links { display: none; }
  .btn.src-link { display: none; }
  .btn.bar-toggle { display: inline-flex; flex: 0 0 auto; }
  .app-head { align-items: flex-start; }
  .toolbar { display: none; }
  body.toolbar-open .toolbar { display: block; }
  .toolbar-in { flex-direction: column; align-items: stretch; gap: 8px; padding: 12px; }
  .tool-group { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .tool-group .field-select, #new-subject { grid-column: 1 / -1; }
  .tool-end { margin-left: 0; }
  .field { width: 100%; }
  .field-select select { flex: 1; max-width: none; min-width: 0; }
  .field-num input { flex: 1; width: auto; min-width: 0; }
  .tool-group .btn { width: 100%; }
  .coach { bottom: 12px; padding: 12px 14px; }
  .ex-opt { grid-template-columns: 26px minmax(44px, auto) 1fr 26px; gap: 4px 10px; }
  .ex-head, .ex-q, .ex-opts, .ex-foot { padding-left: 16px; padding-right: 16px; }
}

@media (max-width: 560px) {
  .app-head { flex-direction: column; gap: 14px; }
  .ex-head { flex-direction: column; gap: 0; }
  .hero-cta .btn { width: 100%; }
  .sum-v { font-size: 28px; }
  .search { min-width: 0; width: 100%; }
  .head-actions { width: 100%; }
  .coach-dots { display: none; }
  .coach-btns { margin-left: auto; }
  .modal { padding: 14px; }
  .modal-card { padding: 24px 20px 20px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .m-row, .band, .band-tag, .m-name, .dr-step, .view.entering, .summary.entering,
  .drawer-panel, .drawer-scrim { transition: none !important; animation: none !important; }
}

/* --------------------------------- print -------------------------------- */

@media (max-width: 640px) {
  #progress .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  #progress .metric { padding: 14px 16px; }
  #progress .metric-x { display: none; }
  #progress .metric-k { font-size: 14.5px; overflow-wrap: anywhere; }
  .prog-group-top .prog-name { order: 3; flex-basis: 100%; }
}

@media print {
  :root { --bg: #fff; --surface: #fff; --bg-2: #fff; --bg-3: #f4f5f7; --line: #bbb; --line-soft: #ddd; --line-hi: #999; }
  .bar, .tabs, .hero, .how, .app-intro, .foot, .drawer, .modal, .coach,
  .head-actions, .view-head .btn, .hint, .legend, .legend-head, .info { display: none !important; }
  .tour-lit { box-shadow: none !important; }
  .view { display: none !important; }
  .view#view-groups { display: block !important; }
  body.print-progress .view#view-groups { display: none !important; }
  body.print-progress .view#view-progress { display: block !important; }
  .prog, .prog-group, .prog-verdict, .metric { break-inside: avoid; page-break-inside: avoid; background: #fff; box-shadow: none; }
  .prog-who summary, .group-more summary { display: none; }
  .progs { display: block; }
  .metrics { grid-template-columns: repeat(4, 1fr); }
  .prog { margin-bottom: 8pt; }
  .prog-fill { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .main { padding: 0; }
  body { font-size: 11pt; background: #fff; color: #111; }
  .groups { display: block; }
  /* A big class has groups taller than a page, and asking the browser to keep one
     whole leaves a blank sheet before it. The pieces stay whole instead. */
  .group-top, .group-more h4, .checks, .roster { break-inside: avoid; page-break-inside: avoid; }
  .group-top, .group .lab, .group-more h4 { break-after: avoid; page-break-after: avoid; }
  .group {
    margin-bottom: 14pt;
    border: 1px solid #999;
    background: #fff;
    box-shadow: none;
  }
  .group-top { background: none; }
  .roster-names { display: block; }
  .rname { border: none; background: none; padding: 0 6px 0 0; color: #333; }
  /* An unlabelled pattern's controls mean nothing on paper; its answers and students do. */
  .group .btn, .track { display: none !important; }
  .chip { background: none; color: #333; }
  .view-head h2 { font-size: 16pt; margin-bottom: 6pt; }
  a[href]::after { content: ""; }
}

/* ---------------------- Does it work?: the hidden-belief test ---------------------- */
.hide-test { margin-top: 36px; padding-top: 28px; border-top: 1px solid var(--line); max-width: 860px; }
.hide-test h3 { font-size: 21px; margin: 0 0 8px; }
.hide-test .sub { margin-bottom: 14px; }
.hide-res { font-weight: 600; color: var(--ink); margin: 0 0 16px; }
.hide-test .group { margin-bottom: 16px; border: 1px solid var(--line); }

/* ---------------------- tracking a found pattern ---------------------- */
.track { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line-soft); display: grid; grid-template-columns: 1fr auto; gap: 8px 10px; align-items: center; }
.track-l { grid-column: 1 / -1; font-size: 14.5px; font-weight: 600; color: var(--ink-2); }
.track-i { font: inherit; font-size: 15.5px; padding: 8px 12px; border: 1px solid var(--line-hi); border-radius: var(--r-s); background: var(--surface); color: var(--ink); min-width: 0; }
.track-i:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.track-msg { grid-column: 1 / -1; margin: 0; color: var(--bad); font-size: 14px; }
.track-msg:empty { display: none; }
@media (max-width: 560px) { .track { grid-template-columns: 1fr; } }
