:root {
  --navy: #0b1f33;
  --navy-2: #132a44;
  --navy-3: #1b3a5a;
  --ink: #1c2938;
  --slate: #445566;
  --muted: #5e6e80;
  --line: #d5dee8;
  --line-2: #c3cedb;
  --bg: #e8eef4;
  --paper: #f7f9fb;
  --card: #ffffff;
  --accent: #1e4d78;
  --accent-2: #163a5c;
  --gold: #8a6a22;
  --gold-bg: #f4ead0;
  --pass: #166534;
  --pass-bg: #dcfce7;
  --fail: #9f1239;
  --fail-bg: #ffe4e6;
  --prog: #92400e;
  --prog-bg: #fef3c7;
  --idle: #475569;
  --idle-bg: #e2e8f0;
  --crit: #b45309;
  --shadow: 0 1px 2px rgba(15, 31, 51, 0.08), 0 8px 24px rgba(15, 31, 51, 0.06);
  --tap: 48px;
  --radius: 10px;
  --font: "Segoe UI", "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", "ui-monospace", "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { font-size: 16px; }
html { height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button, select, input, textarea { font-family: inherit; font-size: 16px; }
button { cursor: pointer; touch-action: manipulation; }
select, input, textarea { touch-action: manipulation; }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid #7aa2c9;
  outline-offset: 2px;
}

.app { min-height: 100vh; display: flex; flex-direction: column; }

/* Header */
.topbar {
  background: var(--navy);
  color: #e8eef4;
  padding: 12px 20px 10px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-bottom: 3px solid #c4a35a;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 240px; }
.mark {
  width: 44px; height: 44px; border-radius: 8px;
  background: linear-gradient(180deg, #1e4d78, #0f2a46);
  border: 1px solid #3a6a96;
  display: grid; place-items: center;
  font-weight: 800; letter-spacing: 0.04em; color: #f4ead0;
  font-size: 14px;
}
.brand h1 {
  margin: 0; font-size: 1.2rem; font-weight: 700; letter-spacing: 0.01em; color: #fff;
}
.brand .sub { margin: 1px 0 0; font-size: 0.78rem; color: #b7c6d6; }
.badge {
  display: inline-block; margin-left: 8px; vertical-align: middle;
  background: var(--gold-bg); color: var(--gold);
  font-size: 0.65rem; font-weight: 800; letter-spacing: 0.12em;
  padding: 2px 7px; border-radius: 4px; border: 1px solid #d9c48a;
}
.top-meta { text-align: right; font-size: 0.78rem; color: #c5d3e0; }
.top-meta strong { color: #fff; font-weight: 600; display: block; }
.legend {
  background: #f3efe4;
  color: #4a4030;
  font-size: 0.78rem;
  padding: 7px 20px;
  border-bottom: 1px solid #e2d8c0;
}
.legend b { color: var(--navy); }

.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 10px 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.mode-toggle { display: flex; background: #dfe7ef; border-radius: 8px; padding: 3px; }
.mode-toggle button {
  min-height: 42px; min-width: 108px; padding: 0 16px;
  border: 0; background: transparent; color: var(--slate);
  font-weight: 650; border-radius: 6px;
}
.mode-toggle button.active { background: var(--navy); color: #fff; }
.toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn {
  min-height: var(--tap); padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--line-2);
  background: #fff; color: var(--ink); font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { background: #f3f6f9; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent-2); }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--fail); border-color: #fecdd3; background: #fff; }
.btn.danger:hover { background: var(--fail-bg); }
.btn.pass { background: var(--pass); color: #fff; border-color: #14532d; }
.btn.fail { background: var(--fail); color: #fff; border-color: #881337; }
.btn.sm { min-height: 40px; padding: 0 10px; font-size: 0.88rem; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.kbd {
  font-family: var(--mono); font-size: 0.72rem; color: var(--muted);
  background: #eef2f6; border: 1px solid var(--line); border-bottom-width: 2px;
  padding: 1px 5px; border-radius: 4px;
}

.main { flex: 1; padding: 16px 20px 28px; max-width: 1440px; width: 100%; margin: 0 auto; }

/* Station */
.station { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .station { grid-template-columns: 1fr; } }

.picker-row {
  display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 14px 16px; }
.picker { flex: 1; min-width: 280px; }
.picker-label { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.student-nav { display: flex; gap: 8px; align-items: center; }
.student-nav select {
  flex: 1; min-height: var(--tap); padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: 8px; background: #fff; font-weight: 600;
}
.nav-btn { width: var(--tap); min-width: var(--tap); padding: 0; font-size: 1.2rem; }

.groups { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.groups button {
  min-height: 40px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line-2); background: #fff; color: var(--slate); font-weight: 650; font-size: 0.88rem;
}
.groups button.active { background: var(--navy-2); color: #fff; border-color: var(--navy-2); }
.skill-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.skill-chips button {
  min-width: 44px; min-height: 44px; padding: 0 10px;
  border-radius: 8px; border: 1px solid var(--line-2); background: #fff;
  font-weight: 700; color: var(--navy);
}
.skill-chips button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.skill-chips button.st-pass { box-shadow: inset 0 -3px 0 var(--pass); }
.skill-chips button.st-fail { box-shadow: inset 0 -3px 0 var(--fail); }
.skill-chips button.st-prog { box-shadow: inset 0 -3px 0 #d97706; }

.sheet-head { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0 0 6px; font-size: 1.15rem; }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 0.82rem; }
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--idle-bg); color: var(--idle);
  padding: 3px 8px; border-radius: 999px; font-weight: 650; font-size: 0.75rem;
}
.pill.jpr { background: #e8eef6; color: var(--accent); }

.section { padding: 14px 18px 8px; }
.section h3 {
  margin: 0 0 8px; font-size: 0.78rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--navy-3);
  display: flex; align-items: center; gap: 8px;
}
.hint { font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--muted); font-size: 0.78rem; }

.item {
  display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; align-items: start;
  padding: 10px 10px; border: 1px solid transparent; border-radius: 8px; margin-bottom: 6px;
}
.item.selected { background: #f0f5fa; border-color: #b9cde0; }
.item .idx { font-weight: 800; color: var(--navy-3); padding-top: 10px; font-variant-numeric: tabular-nums; }
.item .txt { padding-top: 8px; }
.item .txt .ref { display: block; font-size: 0.75rem; color: var(--muted); margin-top: 2px; font-family: var(--mono); }
.crit-tag {
  display: inline-block; margin-left: 6px;
  background: #fff7ed; color: var(--crit); border: 1px solid #fed7aa;
  font-size: 0.65rem; font-weight: 800; letter-spacing: 0.04em;
  padding: 1px 6px; border-radius: 4px; vertical-align: middle;
}
.cat-tag {
  display: inline-block; margin-right: 6px;
  font-size: 0.68rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--accent); background: #e8eef6; padding: 1px 6px; border-radius: 4px;
}
.cat-tag.safety { background: #fff7ed; color: #9a3412; }

.pf { display: flex; gap: 6px; }
.pf button, .rubric button, .prod button {
  min-height: var(--tap); min-width: var(--tap); padding: 0 12px;
  border-radius: 8px; border: 1px solid var(--line-2); background: #fff; font-weight: 750;
}
.pf button.on-pass, .prod button.on-pass { background: var(--pass); color: #fff; border-color: #14532d; }
.pf button.on-fail, .prod button.on-fail { background: var(--fail); color: #fff; border-color: #881337; }
.rubric { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.rubric button { min-width: 44px; padding: 0 6px; font-size: 0.82rem; line-height: 1.1; text-align: center; }
.rubric button small { display: block; font-weight: 600; font-size: 0.62rem; color: var(--muted); }
.rubric button.on { background: var(--navy-2); color: #fff; border-color: var(--navy-2); }
.rubric button.on.low { background: var(--fail); border-color: #881337; }
.rubric button.on.ok { background: var(--pass); border-color: #14532d; }
.rubric button.on small { color: rgba(255,255,255,0.85); }

.notes { padding: 8px 18px 18px; display: grid; gap: 10px; }
.notes label { font-size: 0.78rem; font-weight: 700; color: var(--slate); display: block; margin-bottom: 4px; }
.notes textarea, .notes input[type="text"], .notes input[type="date"] {
  width: 100%; border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 12px; background: #fff;
}
.notes textarea { min-height: 88px; resize: vertical; }
.notes-row { display: grid; grid-template-columns: 1fr 160px; gap: 10px; }


.side { position: sticky; top: 72px; }
.side .card { padding: 16px; }
.status-hero { text-align: center; padding: 8px 0 12px; }
.status-hero .lbl { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.status-hero .val {
  margin-top: 6px; font-size: 1.35rem; font-weight: 800; letter-spacing: 0.04em;
  padding: 10px; border-radius: 8px;
}
.status-hero .val.pass { background: var(--pass-bg); color: var(--pass); }
.status-hero .val.fail { background: var(--fail-bg); color: var(--fail); }
.status-hero .val.in_progress { background: var(--prog-bg); color: var(--prog); }
.status-hero .val.not_started { background: var(--idle-bg); color: var(--idle); }

.why { margin: 8px 0 0; padding: 0; list-style: none; font-size: 0.82rem; }
.why li { margin: 0 0 8px; padding: 8px 10px; background: var(--fail-bg); color: #7f1d1d; border-radius: 6px; }
.counts { font-size: 0.82rem; color: var(--slate); margin-top: 10px; }
.counts div { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--line); }
.side-actions { display: grid; gap: 8px; margin-top: 14px; }
.side-actions .btn { width: 100%; }
.keys { font-size: 0.75rem; color: var(--muted); margin-top: 12px; line-height: 1.6; }

/* Roster */
.roster-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 12px; }
.roster-bar .field { min-width: 220px; flex: 1; }
.roster-bar select {
  width: 100%; min-height: var(--tap); padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: 8px; background: #fff; font-weight: 600;
}
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters button, .views button {
  min-height: 42px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--line-2); background: #fff; font-weight: 650; color: var(--slate);
}
.filters button.active, .views button.active { background: var(--navy-2); color: #fff; border-color: var(--navy-2); }
.stats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; min-width: 92px;
}
.stat b { display: block; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: 0.72rem; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; }

table.roster {
  width: 100%; border-collapse: collapse; background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
table.roster th, table.roster td {
  text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle;
}
table.roster th {
  font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
  background: #f4f7fa;
}
table.roster tr:last-child td { border-bottom: 0; }
table.roster .name { font-weight: 700; }
table.roster .code { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); }
.row-acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.chip {
  display: inline-flex; align-items: center; min-height: 26px; padding: 0 8px;
  border-radius: 999px; font-size: 0.75rem; font-weight: 750; letter-spacing: 0.02em;
}
.chip.pass { background: var(--pass-bg); color: var(--pass); }
.chip.fail { background: var(--fail-bg); color: var(--fail); }
.chip.in_progress { background: var(--prog-bg); color: var(--prog); }
.chip.not_started { background: var(--idle-bg); color: var(--idle); }

.matrix-wrap { overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table.matrix { border-collapse: collapse; min-width: 980px; width: 100%; }
table.matrix th, table.matrix td {
  border: 1px solid var(--line); text-align: center; padding: 0; height: 48px; min-width: 48px;
}
table.matrix th { background: #f4f7fa; font-size: 0.72rem; color: var(--muted); font-weight: 700; }
table.matrix td.name, table.matrix th.name {
  text-align: left; padding: 0 12px; min-width: 180px; position: sticky; left: 0; background: #fff; z-index: 1;
}
table.matrix th.name { background: #f4f7fa; z-index: 2; }
table.matrix td.cell { cursor: pointer; }
table.matrix td.cell:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
table.matrix td.cell.pass { background: #dcfce7; color: var(--pass); font-weight: 800; }
table.matrix td.cell.fail { background: #ffe4e6; color: var(--fail); font-weight: 800; }
table.matrix td.cell.in_progress { background: #fef3c7; color: var(--prog); font-weight: 800; }
table.matrix td.cell.not_started { color: #94a3b8; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 8px;
  box-shadow: var(--shadow); font-weight: 650; z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.toast.show { opacity: 1; }

.modal-back {
  position: fixed; inset: 0; background: rgba(11,31,51,0.45);
  display: none; align-items: center; justify-content: center; z-index: 40; padding: 20px;
}
.modal-back.show { display: flex; }
.modal {
  background: #fff; border-radius: 12px; padding: 20px; max-width: 420px; width: 100%;
  box-shadow: var(--shadow);
}
.modal h3 { margin: 0 0 8px; }
.modal p { margin: 0 0 16px; color: var(--slate); }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; }

.empty { padding: 28px; text-align: center; color: var(--muted); }
footer.fine {
  padding: 10px 20px 18px; font-size: 0.72rem; color: var(--muted); text-align: center;
}


.meta-plain {
  display: inline-flex; align-items: center;
  color: var(--muted); font-size: 0.82rem; font-weight: 550;
  padding: 2px 0;
}

.given {
  margin: 0;
  padding: 12px 18px 14px;
  background: #f7f9fb;
  border-bottom: 1px solid var(--line);
}
.given-top {
  display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px;
}
.given-kicker {
  font-size: 0.7rem; font-weight: 800; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--navy-3);
}
.given-mute { font-size: 0.75rem; color: var(--muted); }
.given-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.given-field { display: grid; gap: 4px; min-width: 0; }
.given-field span {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--muted);
}
.given-field select {
  width: 100%; min-height: 44px; padding: 8px 10px;
  border: 1px solid var(--line-2); border-radius: 8px; background: #fff;
  font-weight: 650; color: var(--navy);
}
.given-blurb {
  margin: 10px 0 0; font-size: 0.9rem; color: var(--slate); line-height: 1.4;
}
.given-facts {
  display: flex; flex-wrap: wrap; gap: 8px 14px;
  margin-top: 8px; font-size: 0.78rem; font-weight: 650; color: var(--navy-3);
}
.given-facts span + span::before {
  content: "·"; margin-right: 14px; color: var(--muted); font-weight: 500;
}


.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }

/* ---- iPad / tablet ---- */
@media (hover: none), (pointer: coarse) {
  .kbd, .keys { display: none !important; }
  table.matrix td.cell:hover { outline: none; }
}

@media (max-width: 1180px) {
  .station { grid-template-columns: 1fr; }
  .side { position: static; }
  .picker { min-width: 0; }
  .item {
    grid-template-columns: 32px 1fr;
    padding: 12px 8px 12px;
  }
  .item .acts {
    grid-column: 1 / -1;
    display: flex;
    width: 100%;
    justify-content: stretch;
  }
  .pf, .prod { display: flex; width: 100%; gap: 8px; }
  .pf button, .prod button { flex: 1; min-height: 52px; }
  .rubric {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    width: 100%;
    gap: 6px;
    justify-content: stretch;
  }
  .rubric button {
    min-width: 0;
    width: 100%;
    min-height: 56px;
    padding: 6px 2px;
  }
  .notes-row { grid-template-columns: 1fr 1fr; }
  .given-row { grid-template-columns: 1fr 1fr; }
  .given-label span { display: block; margin: 4px 0 0; }
  .side-actions {
    position: sticky;
    bottom: 0;
    background: linear-gradient(180deg, rgba(247,249,251,0), #fff 18%);
    padding: 12px 0 calc(10px + env(safe-area-inset-bottom));
    z-index: 12;
  }
  .toolbar { top: env(safe-area-inset-top); }
}

@media (max-width: 900px) {
  .topbar { padding: 10px 14px; }
  .top-meta { text-align: left; }
  .legend { padding: 8px 14px; }
  .main { padding: 12px 12px 28px; }
  .toolbar { padding: 8px 12px; }
  .mode-toggle { width: 100%; }
  .mode-toggle button { flex: 1; min-width: 0; min-height: 48px; }
  .toolbar-right { width: 100%; justify-content: space-between; }
  .notes-row, .given-row { grid-template-columns: 1fr; }
  .picker-row { flex-direction: column; }
  .sheet-head h2 { font-size: 1.05rem; }
  table.roster th, table.roster td { padding: 12px 10px; }
  .row-acts { justify-content: flex-start; }
  .row-acts .btn { flex: 1; min-width: 88px; min-height: 48px; }
  table.matrix { min-width: 860px; }
  table.matrix th, table.matrix td { height: 52px; min-width: 44px; }
  table.matrix td.name, table.matrix th.name { min-width: 140px; }
}

@media (max-width: 600px) {
  .brand h1 { font-size: 1.05rem; }
  .mark { width: 38px; height: 38px; }
}

/* JPR map */
.map-page { display: grid; gap: 16px; }
.map-intro { font-size: 0.92rem; color: var(--slate); line-height: 1.45; }
.map-h { margin: 8px 0 0; font-size: 0.82rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--navy-3); }
.map-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.map-jpr {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 14px 12px; box-shadow: var(--shadow);
}
.map-jpr-head { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.map-jpr h3 { margin: 0; font-size: 1rem; line-height: 1.35; }
.map-count { margin: 6px 0 10px; font-size: 0.78rem; color: var(--muted); font-weight: 650; }
.map-sheets { display: flex; flex-direction: column; gap: 6px; }
.map-sheet {
  text-align: left; border: 1px solid var(--line-2); background: #f7f9fb;
  border-radius: 8px; padding: 10px 12px; min-height: 48px;
  font-weight: 650; color: var(--navy);
}
.map-sheet span { display: block; font-weight: 500; font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.map-sheet:active, .map-sheet:focus { background: #e8eef6; border-color: var(--accent); }
.map-row-open {
  min-height: 44px; min-width: 52px; font-weight: 800;
  border: 1px solid var(--line-2); border-radius: 8px; background: #fff; color: var(--navy);
}
.map-table td { vertical-align: top; }
@media (max-width: 900px) {
  .map-grid { grid-template-columns: 1fr; }
}

.fail-modal { max-width: 560px; max-height: min(86vh, 720px); display: flex; flex-direction: column; }
.fail-modal p { margin: 0 0 12px; }
.fail-items {
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  margin: 0 -4px 14px; padding: 0 4px 4px;
  display: grid; gap: 8px;
}
.fail-group {
  font-size: 0.7rem; font-weight: 800; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--navy-3); margin-top: 6px;
}
.fail-row {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #f7f9fb;
}
.fail-txt { font-size: 0.88rem; line-height: 1.35; color: var(--navy); }
.fail-scores { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.fail-row .btn.sm { min-height: 44px; min-width: 48px; }
@media (max-width: 700px) {
  .fail-row { grid-template-columns: 1fr; }
  .fail-scores, .fail-row .btn { width: 100%; }
  .fail-scores .btn { flex: 1; }
}

.stem {
  margin: 0; padding: 8px 18px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.stem summary {
  cursor: pointer; list-style: none;
  font-size: 0.78rem; font-weight: 800; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--navy-3);
  min-height: 40px; display: flex; align-items: center;
}
.stem summary::-webkit-details-marker { display: none; }
.stem summary::after {
  content: "Show"; margin-left: auto; font-weight: 650; letter-spacing: 0;
  text-transform: none; color: var(--accent); font-size: 0.8rem;
}
.stem[open] summary::after { content: "Hide"; }
.stem p {
  margin: 0 0 10px; font-size: 0.9rem; color: var(--slate); line-height: 1.45;
}
.stem p:last-child { margin-bottom: 2px; }
.stem p span {
  display: block; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--navy-3); margin-bottom: 3px;
}
.stem-res { font-size: 0.8rem !important; color: var(--muted) !important; }

/* —— Klar Fire additions —— */
.mark.lg { width: 56px; height: 56px; font-size: 18px; margin: 0 auto 10px; }
.auth-gate {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: center;
  background: linear-gradient(160deg, #0b1f33, #1b3a5a 55%, #0b1f33);
  padding: 24px;
}
.auth-gate[hidden] { display: none !important; }
.auth-card {
  width: min(400px, 100%);
  background: #fff; border-radius: 14px; padding: 28px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  display: grid; gap: 12px; text-align: center;
}
.auth-card h1 { margin: 0; font-size: 1.35rem; }
.auth-sub { margin: 0; color: var(--muted); font-size: 0.88rem; }
.auth-card label { text-align: left; font-size: 0.78rem; font-weight: 700; color: var(--slate); display: grid; gap: 4px; }
.auth-card input {
  min-height: var(--tap); padding: 0 12px; border: 1px solid var(--line-2); border-radius: 8px; font-size: 16px;
}
.btn.block { width: 100%; }
.auth-hint { color: var(--fail); font-size: 0.85rem; margin: 0; }
.auth-fine { font-size: 0.75rem; color: var(--muted); margin: 4px 0 0; }
body.locked .app { display: none; }

.mode-toggle { flex-wrap: wrap; max-width: 100%; }
.mode-toggle button { min-width: 96px; font-size: 0.88rem; }

.honest-note {
  margin: 0 0 10px; padding: 10px 12px; border-radius: 8px;
  background: #fff8e8; border: 1px solid #e8d4a8; color: #5c4a20; font-size: 0.88rem;
}
.muted { color: var(--muted); font-size: 0.88rem; }
.chip-prov {
  margin-left: 6px; font-size: 0.65rem; font-weight: 800; letter-spacing: 0.04em;
  background: #fef3c7; color: #92400e; padding: 1px 5px; border-radius: 4px;
}

.drill-hero-top { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.drill-notes { margin: 10px 0 0; color: var(--slate); font-size: 0.9rem; }
.field { display: grid; gap: 4px; flex: 1; min-width: 200px; }
.field span { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.field select, .field input {
  min-height: var(--tap); padding: 0 12px; border: 1px solid var(--line-2); border-radius: 8px; background: #fff; font-weight: 600;
}
.seg { display: flex; background: #e8eef4; border-radius: 8px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button {
  min-height: 44px; padding: 0 12px; border: 0; background: transparent; border-radius: 6px;
  font-weight: 700; color: var(--slate); font-size: 0.82rem;
}
.seg button.active { background: var(--navy); color: #fff; }
.seg button.active.warn { background: #b45309; }
.seg button.active.ok { background: var(--pass); }

.report-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.report-tabs button {
  min-height: 42px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-2);
  background: #fff; font-weight: 650; color: var(--slate);
}
.report-tabs button.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.bar {
  display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: #e2e8f0; min-width: 100px;
}
.bar span { display: block; height: 100%; }
.b-pass { background: #16a34a; }
.b-fail { background: #e11d48; }
.b-prog { background: #d97706; }
.b-idle { background: #94a3b8; }

.timeline { list-style: none; margin: 0; padding: 16px 18px; }
.tl-item {
  display: grid; grid-template-columns: 140px 1fr; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
  position: relative;
}
.tl-item:last-child { border-bottom: 0; }
.tl-time { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); padding-top: 2px; }
.tl-item.st-fail .tl-body b { color: var(--fail); }
.tl-item.st-pass .tl-body b { color: var(--pass); }
.tl-item.st-needs_retrain .tl-body b { color: #b45309; }

.tour-back {
  position: fixed; inset: 0; z-index: 80; background: rgba(11,31,51,0.55);
  display: grid; place-items: center; padding: 20px;
}
.tour-back[hidden] { display: none !important; }
.tour-card {
  width: min(440px, 100%); background: #fff; border-radius: 14px; padding: 22px;
  box-shadow: var(--shadow);
}
.tour-progress { height: 6px; background: #e2e8f0; border-radius: 4px; margin-bottom: 14px; overflow: hidden; }
.tour-progress span { display: block; height: 100%; background: var(--accent); width: 20%; transition: width 0.25s ease; }
.tour-card h3 { margin: 0 0 8px; }
.tour-card p { margin: 0 0 16px; color: var(--slate); }
.row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

.walk-modal { width: min(520px, 100%); }
.walk-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.walk-tabs button {
  min-height: 40px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-2);
  background: #fff; font-weight: 650; font-size: 0.85rem;
}
.walk-tabs button.active { background: var(--navy-2); color: #fff; }
.walk-stage { min-height: 160px; }
.anim-walk { display: grid; gap: 10px; }
.anim-step {
  padding: 12px 14px; border-radius: 10px; background: #eef4fa; border-left: 4px solid var(--accent);
  font-weight: 650; opacity: 0; transform: translateY(8px);
  animation: walkIn 0.45s ease forwards;
}
.anim-step.s2 { animation-delay: 0.35s; }
.anim-step.s3 { animation-delay: 0.7s; }
@keyframes walkIn {
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
  .mode-toggle button { min-width: 78px; padding: 0 10px; font-size: 0.8rem; }
  .tl-item { grid-template-columns: 1fr; gap: 4px; }
  .top-meta { text-align: left; }
}
@media (max-width: 700px) {
  .toolbar { padding: 8px 12px; }
  .main { padding: 12px; }
  .seg button { flex: 1; min-width: 72px; }
}

@media print {
  .topbar, .toolbar, .legend, .fine, .toast, .modal-back, .tour-back, .auth-gate { display: none !important; }
  .app { display: block; }
  body { background: #fff; }
}

/* ---------- hold to set all ---------- */
.anim-step.s4 { animation-delay: 1.05s; }
.acts button {
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
.acts button.holdable { position: relative; overflow: hidden; }
.acts button.holdable::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 100%; width: 0;
  background: rgba(21, 128, 61, 0.28); pointer-events: none;
}
.acts button.holdable.holding::after {
  animation: holdFill var(--hold-ms, 600ms) linear forwards;
}
.acts button.holdable.holding { box-shadow: 0 0 0 3px rgba(21, 128, 61, 0.35); }
@keyframes holdFill { from { width: 0; } to { width: 100%; } }
.hold-hint {
  flex-basis: 100%; width: 100%; text-align: right;
  font-size: 0.7rem; font-weight: 600; color: var(--muted); margin-top: 2px;
}
.hold-hint::before { content: "\21BB  "; }
.item.pulse { animation: rowPulse 0.9s ease-out; }
@keyframes rowPulse {
  0% { background: #bbf7d0; border-color: #4ade80; }
  100% { background: transparent; border-color: transparent; }
}
.item.selected.pulse { animation: rowPulseSel 0.9s ease-out; }
@keyframes rowPulseSel {
  0% { background: #bbf7d0; border-color: #4ade80; }
  100% { background: #f0f5fa; border-color: #b9cde0; }
}
@media (prefers-reduced-motion: reduce) {
  .item.pulse, .item.selected.pulse { animation: none; }
}
.pf, .prod { flex-wrap: wrap; }
.hold-hint { grid-column: 1 / -1; }
@media (max-width: 1180px) {
  /* keep the 0-4 scale on one row on iPad (.item .acts was overriding the grid) */
  .item .acts.rubric { display: grid; grid-template-columns: repeat(5, 1fr); }
}
