/* Workbook styles. Colors come exclusively from tokens.css (and the optional
   per-workbook theme.css) — never use literal color values in this file. */

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

code,
pre,
kbd { font-family: var(--font-mono); }

.icon { width: 1em; height: 1em; flex: 0 0 auto; vertical-align: -0.125em; }

.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 8px 14px;
  font-weight: 600;
  color: var(--card);
  background: var(--accent);
  border-radius: var(--radius);
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; outline: 2px solid var(--ink); outline-offset: 2px; color: var(--card); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after { transition: none !important; animation: none !important; }
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Monospace uppercase micro label — the signature element of the worksheet look. */
.micro-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------------------------------------------------------------- sticky head */

.sticky-head { position: sticky; top: 0; z-index: 50; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  padding: 10px 24px;
  background: var(--accent);
  color: var(--card);
}

.brand {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
}

.progress {
  flex: 1 1 220px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-bar {
  flex: 1;
  height: 6px;
  appearance: none;
  border: 0;
  border-radius: 1px;
  background: color-mix(in srgb, var(--card) 20%, transparent);
  overflow: hidden;
}
.progress-bar::-webkit-progress-bar { background: color-mix(in srgb, var(--card) 20%, transparent); }
.progress-bar::-webkit-progress-value { background: var(--card); transition: width 0.3s ease; }
.progress-bar::-moz-progress-bar { background: var(--card); }

.progress-text {
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.save-status {
  min-width: 7em;
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: nowrap;
}
.save-status.is-saved { opacity: 0.8; }
.save-status.is-offline,
.save-status.is-error,
.save-status.is-logged-out {
  padding: 1px 8px;
  white-space: normal;
  color: var(--ink);
  background: var(--trainer-bg);
  border-radius: 2px;
}

.quicknav {
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 0 24px;
  overflow-x: auto;
  white-space: nowrap;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.quicknav a {
  flex: 0 0 auto;
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.quicknav a:hover,
.quicknav a:focus-visible { color: var(--accent); border-bottom-color: var(--accent); }
.quicknav-tag { font-weight: 700; color: var(--accent); }

/* ---------------------------------------------------------------- sheet & head */

.sheet {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.doc-head {
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 28px 32px;
  margin-bottom: 36px;
}
.doc-head h1 {
  margin: 0 0 6px;
  font-size: 26px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--accent);
}
.doc-sub {
  margin: 0 0 24px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 20px;
}
.field .micro-label { margin-bottom: 4px; }

.intro {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 14.5px;
  color: var(--muted);
}
.intro strong { color: var(--ink); }

/* ---------------------------------------------------------------- prose */

.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p { margin: 0 0 10px; }
.prose ul,
.prose ol { margin: 6px 0 10px; padding-left: 20px; }
.prose li { margin-bottom: 4px; }
.prose code,
.steps code,
.questions code,
.trainer-expect code {
  font-size: 0.86em;
  padding: 1px 4px;
  background: var(--accent-soft);
  border-radius: 2px;
}
.prose pre {
  margin: 8px 0 10px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.5;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
}
.prose pre code { padding: 0; background: none; font-size: inherit; }

/* ---------------------------------------------------------------- day banner */

.day { margin-bottom: 8px; }

.day-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
  margin: 44px 0 16px;
  padding: 12px 18px;
  background: var(--accent);
  color: var(--card);
  border-radius: var(--radius);
  scroll-margin-top: 104px;
}
.day:first-of-type .day-banner { margin-top: 0; }

.day-label {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--card) 70%, var(--accent));
}
.day-title { margin: 0; font-size: 16px; font-weight: 700; }
.day-sub { flex-basis: 100%; order: 3; font-size: 13px; color: color-mix(in srgb, var(--card) 78%, var(--accent)); }
.day-load {
  margin-left: auto;
  padding: 1px 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 2px;
  white-space: nowrap;
}

.is-optional .day-banner {
  background: var(--card);
  color: var(--ink);
  border: 1px dashed var(--accent);
}
.is-optional .day-label { color: var(--accent); }
.is-optional .day-sub { color: var(--muted); }

/* ---------------------------------------------------------------- module */

.module {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 24px;
}

.module-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
}
.module-code {
  padding: 3px 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 2px;
}
.module-title { flex: 1 1 180px; margin: 0; font-size: 18px; font-weight: 700; }

/* Port LEDs: one per task, lit when done, red when the trainer asks for rework. */
.ports { display: flex; gap: 4px; }
.port {
  width: 12px;
  height: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 2px;
  transition: background-color 0.25s, border-color 0.25s;
}
.port.is-lit { background: var(--ok); border-color: var(--ok); }
.port.is-redo { background: var(--redo); border-color: var(--redo); }

.module-goal {
  padding: 14px 24px;
  font-size: 14px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.module-goal .micro-label { margin-bottom: 2px; }

/* ---------------------------------------------------------------- task */

.task { padding: 24px; border-bottom: 1px solid var(--line); scroll-margin-top: 104px; }
.task:last-child { border-bottom: 0; }

.task-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  margin-bottom: 12px;
}
.task-number {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}
.task-title { flex: 1 1 200px; margin: 0; font-size: 16px; font-weight: 700; }

.level,
.duration {
  padding: 2px 7px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid;
  border-radius: 2px;
}
.level {
  --level: var(--level-grey);
  /* Slightly darkened text keeps every level at >= 4.5:1 on its tinted badge. */
  color: color-mix(in srgb, var(--level) 85%, var(--ink));
  border-color: color-mix(in srgb, var(--level) 40%, white);
  background: color-mix(in srgb, var(--level) 8%, white);
}
.level-blue { --level: var(--level-blue); }
.level-ochre { --level: var(--level-ochre); }
.level-green { --level: var(--level-green); }
.level-grey { --level: var(--level-grey); }
.level-red { --level: var(--level-red); }
.duration { color: var(--muted); border-color: var(--line); text-transform: none; letter-spacing: 0; }

.requirement { margin-bottom: 12px; }
.requirement .micro-label { margin-bottom: 2px; }

.snippet {
  margin: 8px 0 14px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.5;
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  overflow-x: auto;
}

.steps,
.questions { margin: 0 0 14px; padding-left: 22px; }
.steps li,
.questions li { margin-bottom: 5px; }
.steps li::marker { font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--accent); }
.questions { list-style: none; padding-left: 0; }
.questions li { position: relative; padding-left: 20px; }
.questions li::before {
  content: "?";
  position: absolute;
  left: 2px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent);
}

/* Blocks (free layout) */
.block-text { margin-bottom: 12px; }
.block-snippet,
.block-image { margin: 8px 0 14px; }
.block-snippet .snippet { margin: 4px 0 0; }
.block-image img { display: block; max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.block-image figcaption { margin-top: 6px; font-size: 13px; color: var(--muted); }
.table-wrap { margin: 8px 0 14px; overflow-x: auto; }
.block-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.block-table caption { caption-side: top; text-align: left; padding-bottom: 6px; font-size: 13px; color: var(--muted); }
.block-table th,
.block-table td { padding: 7px 10px; text-align: left; vertical-align: top; border: 1px solid var(--line); }
.block-table th {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--paper);
}
.note {
  margin: 8px 0 14px;
  padding: 10px 14px;
  background: var(--hint-bg);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  font-size: 14px;
}
.note-warning { background: color-mix(in srgb, var(--redo) 8%, white); border-left-color: var(--redo); }
.note-head { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; color: var(--accent); }
.note-warning .note-head { color: color-mix(in srgb, var(--redo) 85%, var(--ink)); }
.note-head .micro-label { color: inherit; }

/* ---------------------------------------------------------------- hints & bonus */

details.hints,
details.bonus {
  margin: 4px 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
details.hints { background: var(--hint-bg); border-color: color-mix(in srgb, var(--accent) 22%, var(--hint-bg)); }
details.bonus { margin: 16px 0 0; background: var(--bonus-bg); }

details > summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  cursor: pointer;
  list-style: none;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
details.bonus > summary { color: var(--muted); }
details > summary::-webkit-details-marker { display: none; }
details > summary .icon:first-child { transition: transform 0.15s ease; }
details[open] > summary .icon:first-child { transform: rotate(90deg); }
details > summary:hover { color: var(--accent-hover); }

.details-body { padding: 0 16px 14px 34px; font-size: 14px; }

/* ---------------------------------------------------------------- answers */

.answer { margin-top: 14px; }
.answer > .micro-label { margin-bottom: 5px; }
.answer fieldset { margin: 0; padding: 0; border: 0; }
.answer legend { margin-bottom: 6px; padding: 0; }
.option { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; font-size: 14.5px; cursor: pointer; }
.option input { accent-color: var(--accent); }

input[type="text"],
input[type="date"],
textarea,
select {
  width: 100%;
  padding: 9px 11px;
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
textarea { resize: vertical; }
.mono-input { font-family: var(--font-mono); font-size: 13.5px; background: var(--paper); }
input::placeholder,
textarea::placeholder { color: var(--muted); opacity: 1; }

input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible,
a:focus-visible,
input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.done-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.done-row input { width: 18px; height: 18px; margin: 0; accent-color: var(--ok); cursor: pointer; }
.done-row label { font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; }
.done-row input:checked + label { color: var(--ok); }

/* ---------------------------------------------------------------- trainer area */

.trainer {
  margin-top: 18px;
  padding: 14px 16px;
  background: var(--trainer-bg);
  border: 1px dashed color-mix(in srgb, var(--level-ochre) 40%, var(--trainer-bg));
  border-radius: var(--radius);
  font-size: 14px;
}
.trainer-head { margin-bottom: 8px; color: color-mix(in srgb, var(--level-ochre) 85%, var(--ink)); font-weight: 700; }
.trainer-expect,
.trainer-notes { margin-bottom: 12px; }
.trainer-expect ul { margin: 4px 0 0; padding-left: 20px; }
.trainer-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
.trainer-row select { flex: 0 0 180px; }
.trainer-row textarea { flex: 1 1 220px; width: auto; }

/* ---------------------------------------------------------------- sign-off & footer */

.signoff {
  margin-top: 36px;
  padding: 24px 28px;
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
}
.signoff h2 { margin: 0 0 16px; font-size: 18px; color: var(--accent); }
.signoff > .micro-label { margin-bottom: 5px; }
.signoff .field-grid { margin-top: 14px; }

.doc-foot {
  margin-top: 36px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
  text-align: center;
}

/* ---------------------------------------------------------------- progress notes */

.preview-note,
.changed-note {
  margin: 0 0 16px;
  padding: 8px 12px;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--trainer-bg);
  border-left: 3px solid var(--level-ochre);
  border-radius: var(--radius);
}
.changed-note { margin: -4px 0 12px; }
input:disabled,
textarea:disabled { color: var(--ink); background: var(--paper); cursor: not-allowed; }

.card-progress { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.progress-bar-light { flex: 0 1 220px; height: 6px; background: var(--paper); border: 1px solid var(--line); }
.progress-bar-light::-webkit-progress-bar { background: var(--paper); }
.progress-bar-light::-webkit-progress-value { background: var(--ok); }
.progress-bar-light::-moz-progress-bar { background: var(--ok); }

/* ---------------------------------------------------------------- update banner */

[hidden] { display: none !important; }

.update-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 24px;
  font-size: 14px;
  color: var(--ink);
  background: var(--trainer-bg);
  border-bottom: 1px solid var(--line);
}

.link-button {
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  background: none;
  border: 0;
  cursor: pointer;
}
.link-button:hover { color: var(--accent-hover); }
.link-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- generic pages */

.page .topbar a.brand { color: var(--card); text-decoration: none; }
.sheet-wide { max-width: 1040px; }
.page-title { margin: 0 0 8px; font-size: 24px; color: var(--accent); }
.page-intro { margin: 0 0 24px; color: var(--muted); }
.empty { color: var(--muted); }
.mono { font-family: var(--font-mono); font-size: 0.9em; }

.card-list { display: grid; gap: 16px; margin: 24px 0 0; padding: 0; list-style: none; }
.card {
  padding: 20px 24px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
}
.card-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; margin-bottom: 6px; }
.card-title { margin: 0; font-size: 18px; }
.card-title a { text-decoration: none; }
.card-title a:hover { text-decoration: underline; }
.card-sub { margin: 4px 0 0; font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.card-desc { margin: 10px 0 0; }

.data-table { width: 100%; border-collapse: collapse; background: var(--card); font-size: 14px; }
.data-table th,
.data-table td { padding: 9px 12px; text-align: left; vertical-align: top; border: 1px solid var(--line); }
.data-table th {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--paper);
}
.row-detail td { background: var(--paper); }

.status {
  display: inline-block;
  padding: 1px 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid;
  border-radius: 2px;
}
.status-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, white); }
.status-error,
.status-stale { color: var(--redo); border-color: color-mix(in srgb, var(--redo) 40%, white); }

.issue-list { margin: 4px 0 12px; padding: 0; list-style: none; }
.issue-list:last-child { margin-bottom: 0; }
.issue { display: flex; flex-wrap: wrap; gap: 4px 10px; padding: 4px 0 4px 10px; border-left: 2px solid var(--redo); }
.issue-warning { border-left-color: var(--level-ochre); }
.issue code { font-size: 12.5px; color: var(--ink); }
.issue-line { color: var(--muted); }

/* ---------------------------------------------------------------- user menu, forms */

.user-menu {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  margin-left: auto;
  font-size: 13px;
}
.user-menu a { color: var(--card); text-decoration: none; opacity: 0.85; }
.user-menu a:hover,
.user-menu a:focus-visible { opacity: 1; text-decoration: underline; color: var(--card); }
.user-menu a:focus-visible,
.brand:focus-visible { outline: 2px solid var(--card); outline-offset: 2px; }
.user-name { font-weight: 600; }
.inline-form { display: inline; margin: 0; }
.topbar-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font: inherit;
  font-size: 12.5px;
  color: var(--card);
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--card) 45%, transparent);
  border-radius: var(--radius);
  cursor: pointer;
}
a.topbar-button { text-decoration: none; }
.topbar-button:hover { background: color-mix(in srgb, var(--card) 14%, transparent); }
.topbar-button:focus-visible { outline: 2px solid var(--card); outline-offset: 2px; }

.sheet-narrow { max-width: 460px; }
.panel {
  padding: 24px 28px;
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
}
.panel > :last-child { margin-bottom: 0; }
.form-stack { display: grid; gap: 16px; }
.form-stack .page-title { margin-bottom: 0; }
.section-title { margin: 0; font-size: 17px; color: var(--accent); }
.field-hint { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.form-error {
  margin: 0 0 16px;
  padding: 10px 14px;
  color: color-mix(in srgb, var(--redo) 85%, var(--ink));
  background: color-mix(in srgb, var(--redo) 8%, white);
  border-left: 3px solid var(--redo);
  border-radius: var(--radius);
}
.form-stack .form-error { margin: 0; }
fieldset.field { margin: 0; padding: 0; border: 0; }
fieldset.field legend { margin-bottom: 6px; padding: 0; }
input[type="password"] {
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  font-size: 14.5px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
input[type="password"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.button {
  justify-self: start;
  padding: 9px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--card);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
}
.button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.button-quiet {
  padding: 4px 10px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--accent);
  background: var(--card);
  border-color: var(--line);
}
.button-quiet:hover { color: var(--card); }

.invite-box { margin-bottom: 24px; border-top-color: var(--ok); }
.form-success {
  margin: 0 0 16px;
  padding: 10px 14px;
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 8%, white);
  border-left: 3px solid var(--ok);
  border-radius: var(--radius);
}
a.button { display: inline-block; text-decoration: none; }
a.button-quiet:hover { color: var(--card); }
.data-table .actions a + form { margin-left: 4px; }
.static-value { margin: 0; padding: 9px 0; }
.assign-box { display: grid; gap: 14px; margin: 0; }
.assign-head { font-size: 15px; }
.assign-box select { max-width: 420px; }
details.overrides { border: 1px solid var(--line); border-radius: var(--radius); }
details.overrides > summary { color: var(--muted); }
details.overrides .table-wrap { margin: 0; padding: 0 12px 12px; }
.override-table td { vertical-align: middle; }
.override-table td:first-child { width: 4em; }
.override-table select { width: 100%; min-width: 200px; padding: 5px 8px; font-size: 13.5px; }
.invite-box p { margin: 6px 0 12px; }
.copy-row { display: flex; flex-wrap: wrap; gap: 8px; }
.copy-row input { flex: 1 1 280px; width: auto; }
.create-user { margin-top: 32px; }
.data-table .actions { white-space: nowrap; }
.data-table .actions form + form { margin-left: 4px; }
.supervision { margin-top: 4px; font-size: 12px; color: var(--muted); }
.status-active { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, white); }
.status-invited { color: var(--level-blue); border-color: color-mix(in srgb, var(--level-blue) 40%, white); }
.status-invite_expired,
.status-no_access { color: var(--level-ochre); border-color: color-mix(in srgb, var(--level-ochre) 40%, white); }
.status-inactive { color: var(--muted); border-color: var(--line); }

/* ---------------------------------------------------------------- export */

.export-bar {
  margin: 0 0 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.field-value { margin: 0; padding: 4px 0; font-size: 15px; }
.answer-value {
  padding: 8px 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14.5px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.answer-value.is-mono { font-family: var(--font-mono); font-size: 13px; background: var(--paper); }
.answer-value.is-empty { color: var(--muted); font-style: italic; }
.done-text { display: flex; align-items: center; gap: 6px; margin-bottom: 0; font-size: 14px; color: var(--muted); }
.done-text.is-done { color: var(--ok); font-weight: 600; }
.trainer-result { margin: 0; }
.is-export .sticky-head { position: static; }

/* ---------------------------------------------------------------- review */

.review-note {
  margin-top: 14px;
  padding: 10px 14px;
  font-size: 14px;
  background: var(--trainer-bg);
  border-left: 3px solid var(--level-ochre);
  border-radius: var(--radius);
}
.review-note.review-ok { border-left-color: var(--ok); }
.review-note.review-redo { border-left-color: var(--redo); }
.review-note .micro-label { margin-bottom: 2px; }
.review-status { display: inline-block; margin-right: 8px; }
.review-ok .review-status { color: var(--ok); }
.review-redo .review-status { color: var(--redo); }
.review-comment { margin: 4px 0 0; white-space: pre-wrap; }

.trainer-top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin-bottom: 8px; }
.trainer-top .trainer-head { margin-bottom: 0; }
.trainer-owner { font-size: 12.5px; color: var(--muted); }
.trainer-meta { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.review-select.is-ok { color: var(--ok); border-color: var(--ok); font-weight: 600; }
.review-select.is-redo { color: var(--redo); border-color: var(--redo); font-weight: 600; }
.trainer select:disabled,
.trainer textarea:disabled { background: var(--card); }

.review-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 16px;
  margin: 0 0 16px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  background: var(--trainer-bg);
  border-left: 3px solid var(--level-ochre);
  border-radius: var(--radius);
}
.review-bar a { font-weight: 500; }

.orphans {
  margin-top: 36px;
  padding: 20px 24px;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.orphans h2 { margin: 0 0 6px; font-size: 16px; }
.orphans dl { margin: 12px 0 0; }
.orphans dt { margin-top: 10px; color: var(--muted); }
.orphans dd { margin: 2px 0 0; white-space: pre-wrap; }

.signoff-comment { white-space: pre-wrap; margin-bottom: 10px; }
.signoff-meta { margin: 0; font-family: var(--font-mono); font-size: 12.5px; color: var(--ok); }

/* ---------------------------------------------------------------- my tasks */

.filter-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 24px; border-bottom: 1px solid var(--line); }
.filter-tabs a {
  padding: 8px 12px;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.filter-tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.filter-tabs a:hover { color: var(--accent); }
.filter-scope { margin-bottom: 12px; }
.filter-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: -12px 0 24px; }
.filter-chips .micro-label { margin-right: 4px; }
.filter-chips a {
  padding: 3px 10px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 2px;
}
.filter-chips a:hover { color: var(--accent); border-color: var(--accent); }
.filter-chips a[aria-current="page"] { color: var(--card); background: var(--accent); border-color: var(--accent); }
.task-group { margin-bottom: 32px; }
.task-group .section-title { margin-bottom: 10px; }
.task-group .section-title a { text-decoration: none; }
.my-tasks-table td:first-child { width: 4em; }
.row-comment { margin: 4px 0 0; font-size: 13px; color: var(--muted); white-space: pre-wrap; }
.state {
  display: inline-block;
  padding: 1px 7px;
  font-size: 12.5px;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 2px;
}
.state-open { color: var(--muted); }
.state-waiting,
.state-recheck { color: color-mix(in srgb, var(--level-ochre) 85%, var(--ink)); border-color: color-mix(in srgb, var(--level-ochre) 40%, white); }
.state-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, white); }
.state-redo { color: var(--redo); border-color: color-mix(in srgb, var(--redo) 40%, white); }

/* ---------------------------------------------------------------- editor */

.editor-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px 16px;
  margin: 0 0 16px;
  padding: 10px 0;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.editor-bar-bottom { position: static; margin-top: 24px; border-top: 1px solid var(--line); border-bottom: 0; }
.editor-status { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); }
.editor-status.is-dirty { color: color-mix(in srgb, var(--level-ochre) 85%, var(--ink)); }
.editor-status.is-ok { color: var(--ok); }
.editor-status.is-error { color: color-mix(in srgb, var(--redo) 85%, var(--ink)); }
.editor-form { display: grid; gap: 20px; }
.editor-section { display: grid; gap: 16px; }
.editor-sub { display: grid; gap: 10px; margin-top: 6px; }
.editor-sub > .micro-label { margin: 0; }
.editor-sub > .button,
.editor-section > .button,
.editor-day > .button,
.editor-module > .button { justify-self: start; }
.field-wide { grid-column: 1 / -1; }
.field-check { align-self: end; }
.color-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.editor-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) auto;
  gap: 10px 14px;
  align-items: end;
}
.editor-day { display: grid; gap: 16px; }
.editor-module {
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.editor-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.editor-head strong { flex: 1 1 200px; }
.item-tools { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-left: auto; }
.item-tools .button { padding: 3px 9px; }
.editor-tasks { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.editor-task { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.editor-task.is-open { border-color: var(--accent); }
.editor-task-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 12px; }
.editor-task-title { flex: 1 1 200px; font-weight: 600; }
.task-editor { display: grid; gap: 14px; padding: 4px 16px 16px; border-top: 1px solid var(--line); }
.layout-choice .option { margin-right: 18px; display: inline-flex; }
.editor-answer {
  display: grid;
  gap: 10px;
  padding: 10px 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.editor-trainer { margin-top: 0; }
.editor-preview-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.editor-preview:not(:empty) { padding: 12px; background: var(--paper); border: 1px dashed var(--line); border-radius: var(--radius); }
.editor-preview .task { background: var(--card); border: 1px solid var(--line); }
.editor-details > summary { color: var(--muted); }
.editor-details[open] > summary { margin-bottom: 10px; }
.field.is-invalid input,
.field.is-invalid textarea,
.field.is-invalid select { border-color: var(--redo); }
.field-error { margin: 4px 0 0; font-size: 13px; color: color-mix(in srgb, var(--redo) 85%, var(--ink)); }
.form-error ul { margin: 6px 0 0; padding-left: 20px; }
.form-error a { color: inherit; }
.confirm-box {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  padding: 14px 16px;
  background: var(--trainer-bg);
  border-left: 3px solid var(--level-ochre);
  border-radius: var(--radius);
}
.confirm-box p,
.confirm-box ul { margin: 0; }
input[readonly] { color: var(--muted); background: var(--paper); }

/* ---------------------------------------------------------------- overview */

.muted { color: var(--muted); font-weight: 400; }
.page-title-second { margin-top: 40px; font-size: 20px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 24px; font-size: 13px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.overview-section { margin-bottom: 36px; }
.overview-section .section-title { margin-bottom: 12px; }
.overview-table th[scope="row"] { font-weight: 600; white-space: nowrap; background: var(--card); text-transform: none; letter-spacing: 0; font-family: var(--font-sans); font-size: 14px; color: var(--ink); }
.overview-table td { vertical-align: middle; }
.port-link { display: inline-block; }
.port-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.port.is-ok { border-color: var(--ink); }

/* ---------------------------------------------------------------- editor: image upload */

.editor-asset {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 16px;
  align-items: start;
}
.editor-asset-controls { display: grid; gap: 10px; min-width: 0; }
.editor-asset-upload { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.editor-asset-upload input[type="file"] { flex: 1 1 200px; min-width: 0; font-size: 13px; }
.editor-thumb {
  display: block;
  max-width: 160px;
  max-height: 120px;
  object-fit: contain;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.editor-thumb.is-broken { display: none; }
.editor-asset-status { margin: 0; font-size: 13px; color: var(--muted); }
.editor-asset-status:empty { display: none; }
.editor-asset-status.is-ok { color: var(--ok); }
.editor-asset-status.is-error { color: color-mix(in srgb, var(--redo) 85%, var(--ink)); }
@media (max-width: 560px) {
  .editor-asset { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- questions & review history */

details.thread,
details.review-history {
  margin-top: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.trainer details.thread,
.trainer details.review-history { margin-top: 12px; }
details.review-history > summary,
details.thread:not(.has-comments) > summary { color: var(--muted); }
.thread-count {
  margin-left: 2px;
  color: var(--muted);
  font-weight: 500;
}
.thread-count:empty { display: none; }

.thread-list,
.history-list { margin: 0; list-style: none; }
.thread-list { padding: 0; }
.thread-item,
.history-item {
  padding: 8px 0 8px 12px;
  border-left: 2px solid var(--line);
}
.thread-item + .thread-item,
.history-item + .history-item { margin-top: 6px; }
.thread-from-trainer { border-left-color: var(--level-ochre); }
.thread-from-apprentice { border-left-color: var(--accent); }
.thread-meta,
.history-meta {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}
.thread-meta strong { color: var(--ink); font-weight: 600; }
.thread-role {
  margin-left: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--level-ochre) 85%, var(--ink));
}
.thread-text,
.history-comment {
  margin: 3px 0 0;
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.history-status { color: var(--ink); }
.history-ok .history-status { color: var(--ok); }
.history-redo .history-status { color: var(--redo); }

.thread-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  margin-top: 10px;
}
.thread-list[hidden] + .thread-form { margin-top: 0; }
.thread-form textarea { flex: 1 1 240px; width: auto; }
.thread-form .button { flex: 0 0 auto; }
.thread-form .button:disabled { cursor: progress; opacity: 0.6; }
.thread-error {
  flex: 1 0 100%;
  margin: 0;
  font-size: 13px;
  color: var(--redo);
}

.state-question,
.state-answer { margin-left: 4px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }
.state-question { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, white); background: var(--accent-soft); }
.state-answer { color: color-mix(in srgb, var(--level-ochre) 85%, var(--ink)); border-color: color-mix(in srgb, var(--level-ochre) 40%, white); }

@media print {
  .thread-form,
  details.thread:not(.has-comments) { display: none; }
}

/* ---------------------------------------------------------------- account & user deletion */

.account-data { margin-top: 24px; }
.account-data p { margin: 0; }
.data-table .actions a + a,
.data-table .actions form + a { margin-left: 4px; }
.delete-list { margin: 4px 0 0; padding-left: 20px; }
.button-danger { background: var(--redo); border-color: var(--redo); }
.button-danger:hover { background: color-mix(in srgb, var(--redo) 75%, black); border-color: color-mix(in srgb, var(--redo) 75%, black); }

/* ---------------------------------------------------------------- bulk assignment, csv links */

.page-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 24px; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin-bottom: 12px; }
.overview-section .section-head .section-title { margin-bottom: 0; }
.assign-pick { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 24px; }
.assign-pick .field { flex: 0 1 420px; }
.assign-pick select { width: 100%; }
.assign-table .option { margin: 0; }
.assign-table td { vertical-align: middle; }

/* ---------------------------------------------------------------- image housekeeping */

.assets-summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 8px; }
.asset-thumb { display: block; max-width: 140px; max-height: 90px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.asset-usage { margin: 0; padding-left: 18px; font-size: 13.5px; }
.assets-table td { vertical-align: middle; }

/* ---------------------------------------------------------------- delete workbook */

.sheet-narrow-wide { max-width: 680px; }
.delete-summary { margin: 0; padding-left: 20px; }
.delete-summary li { margin-bottom: 6px; }

/* ---------------------------------------------------------------- small screens */

@media (max-width: 600px) {
  body { font-size: 14.5px; }
  .topbar { padding: 8px 12px; }
  .quicknav { justify-content: flex-start; padding: 0 8px; }
  .sheet { padding: 16px 10px 56px; }
  .doc-head { padding: 20px 16px; }
  .doc-head h1 { font-size: 22px; }
  .field-grid { grid-template-columns: 1fr; }
  .module-head,
  .module-goal { padding-left: 14px; padding-right: 14px; }
  .task { padding: 18px 14px; }
  .details-body { padding-left: 16px; }
  .day-load { margin-left: 0; }
  .signoff { padding: 18px 14px; }
}

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

@media print {
  .skip-link,
  .sticky-head,
  .user-menu,
  button,
  .done-row input { display: none; }
  body { background: var(--card); font-size: 12pt; }
  .sheet { max-width: none; padding: 0; }
  .doc-head,
  .module,
  .signoff { break-inside: auto; }
  .task,
  .day-banner { break-inside: avoid; }
  .day-banner { break-after: avoid; }
  /* Hints and bonus are printed expanded. */
  details > summary .icon:first-child { display: none; }
  details::details-content { content-visibility: visible; display: block; }
  details:not([open]) > .details-body { display: block; }
  textarea { resize: none; }
  /* The trainer area is only printed in a trainer export. */
  .trainer,
  .signoff,
  .save-status,
  .preview-note { display: none; }
  .is-trainer-export .trainer,
  .is-trainer-export .signoff,
  .is-export .signoff { display: block; }
  .is-export .details-body { display: block; }
  .answer-value { break-inside: avoid; }
}
