/* AI Imaging Lab - a reading room for scans. Dark by default, light on request.
 * Accent (aqua) is for actions and the AI's own marks. Violet is the student's voice, amber is the
 * decision (the answer key). Colour is never the only signal: every state also has a word or a shape. */

:root {
  --bg: #0b1013;
  --panel: #121a1f;
  --raised: #1a252c;
  --line: #29363f;
  --line-strong: #3b4c57;
  --ink: #eaf0f3;
  --muted: #9fb2bc;
  --accent: #5bc2db;
  --accent-ink: #5bc2db;
  --accent-soft: rgba(91, 194, 219, 0.14);
  --on-accent: #04222b;
  --violet: #b9a0ea;
  --violet-soft: rgba(185, 160, 234, 0.12);
  --amber: #dcae62;
  --amber-soft: rgba(220, 174, 98, 0.13);
  --coral: #e79a8a;
  --field: #05080a;
  --tick: rgba(91, 194, 219, 0.55);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-head: 'Bahnschrift SemiCondensed', 'Arial Narrow', system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
}

:root[data-theme='light'] {
  --bg: #f1f5f6;
  --panel: #ffffff;
  --raised: #e9eff1;
  --line: #ced9de;
  --line-strong: #9fb1ba;
  --ink: #12222a;
  --muted: #465b65;
  --accent: #0b6a82;
  --accent-ink: #0b6a82;
  --accent-soft: rgba(11, 106, 130, 0.1);
  --on-accent: #ffffff;
  --violet: #6a43a8;
  --violet-soft: rgba(106, 67, 168, 0.09);
  --amber: #8a5a12;
  --amber-soft: rgba(138, 90, 18, 0.1);
  --coral: #a2442f;
  --tick: rgba(91, 194, 219, 0.7);
  --shadow: 0 18px 50px rgba(18, 34, 42, 0.22);
}

/* ---------- base ---------- */

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

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
}

/* Presentation view: body text is 22 px or more from laptop-projector width up. */
@media (min-width: 1100px) {
  html { font-size: 22px; }
}
@media (min-width: 1700px) {
  html { font-size: 24px; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.45;
}

h1,
h2,
h3 {
  font-family: var(--font-head);
  font-weight: 600;
  letter-spacing: 0.005em;
  line-height: 1.15;
  margin: 0;
}

p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
a { color: var(--accent-ink); }
button, input, select { font: inherit; color: inherit; }
img { max-width: 100%; }

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

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

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -4rem;
  z-index: 100;
  background: var(--accent);
  color: var(--on-accent);
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  font-size: 0.8rem;
}
.skip-link:focus { top: 0.5rem; }

.notice {
  margin: 2rem;
  padding: 1rem 1.2rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--panel);
}

/* ---------- the frame ---------- */

.shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
  text-decoration: none;
  border-radius: 8px;
}
.brand-mark { color: var(--accent-ink); flex: none; }
.brand-name {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}

.topbar-end { display: flex; align-items: center; gap: 0.5rem; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  padding: 0.1em 0.85em;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent-soft);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-dot {
  width: 0.5em;
  height: 0.5em;
  border-radius: 50%;
  background: var(--accent);
}

.work {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
}

.main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  outline: none;
}

.footbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.25rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--panel);
  font-size: 0.72rem;
}
.banner { color: var(--muted); font-weight: 500; letter-spacing: 0.01em; }
.foot-link { color: var(--muted); }
.foot-link:hover { color: var(--accent-ink); }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  min-height: 2.3em;
  padding: 0.25em 0.85em;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--raised);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 700;
  box-shadow: inset 0 -3px 0 var(--accent);
}
.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-small { font-size: 0.7rem; min-height: 2em; padding: 0.15em 0.6em; }
.btn-big { font-size: 1rem; padding: 0.4em 1.2em; }
.btn-icon { padding: 0.2em 0.55em; min-width: 2.3em; }
.btn-icon .icon { font-size: 1.15em; }

kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 0 0.35em;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.18);
  color: var(--muted);
  font: inherit;
  font-size: 0.72em;
  line-height: 1.5;
  text-align: center;
}
.btn-primary kbd { border-color: currentColor; background: transparent; color: inherit; opacity: 0.8; }

.segmented { display: inline-flex; }
.segmented .btn { border-radius: 0; }
.segmented .btn + .btn { margin-left: -1px; }
.segmented .btn:first-child { border-radius: 8px 0 0 8px; }
.segmented .btn:last-child { border-radius: 0 8px 8px 0; }
.segmented .btn[aria-pressed='true'] { position: relative; z-index: 1; }

.link-button {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent-ink);
  font-size: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.chip {
  display: inline-block;
  padding: 0.05em 0.7em;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

.icon {
  display: inline-flex;
  flex: none;
  width: 1.1em;
  height: 1.1em;
  vertical-align: -0.15em;
}
.icon svg { width: 100%; height: 100%; }

/* ---------- home ---------- */

.home { padding: 1.2rem 1.5rem 1.5rem; max-width: 92rem; margin: 0 auto; }
.hero { margin-bottom: 1.1rem; }
.hero h1 { font-size: 2.3rem; max-width: 40ch; }
.hero p { margin-top: 0.4rem; color: var(--muted); }

.doors {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.door {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.9rem 1rem 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}
.door-head { display: flex; align-items: center; gap: 0.6rem; }
.door-head h2 { font-size: 1.7rem; }
.door-icon { width: 1.8rem; height: 1.8rem; color: var(--accent-ink); }
.door-blurb { color: var(--muted); font-size: 0.8rem; min-height: 3.1em; }
.door-count { margin-top: auto; color: var(--muted); font-size: 0.7rem; }

.case-list { list-style: none; display: grid; gap: 0.4rem; }
.case-empty { color: var(--muted); font-size: 0.8rem; }

.case-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--raised);
  color: var(--ink);
  text-decoration: none;
}
.case-link:hover { border-color: var(--accent); }
.case-thumb {
  flex: none;
  width: 3rem;
  height: 3rem;
  object-fit: cover;
  border-radius: 6px;
  background: var(--field);
}
.case-link-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.case-name { font-weight: 600; font-size: 0.85rem; line-height: 1.2; }
.case-part { color: var(--muted); font-size: 0.7rem; }
.case-number {
  flex: none;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.3rem;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.4rem;
  text-align: center;
}

.library { margin-top: 1.4rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.library-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.2rem 1rem; margin-bottom: 0.7rem; }
.library-head h2 { font-size: 1.7rem; }
.library-head p { color: var(--muted); font-size: 0.8rem; }
.library-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.7rem;
  margin-bottom: 0.8rem;
}
.library-card {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  height: 100%;
  padding: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
}
.library-card:hover { border-color: var(--accent); }
.library-card .case-thumb { width: 100%; height: auto; aspect-ratio: 4 / 3; margin-bottom: 0.25rem; }
.home-end { margin-top: 1.4rem; }

/* ---------- a case ---------- */

.case {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  height: 100%;
  padding: 0.5rem 1rem 0.6rem;
}
.case-head { flex: none; display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.case-head .case-title {
  font-family: var(--font-head);
  font-size: 1.7rem;
  font-weight: 600;
  line-height: 1.15;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 1rem;
}
.image-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.viewer-block { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 0.4rem; }

.viewer {
  position: relative;
  flex: 1;
  min-height: 12rem;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--field);
  touch-action: none;
}
.viewer.zoomed { cursor: grab; }
.viewer.panning { cursor: grabbing; }
.viewer:focus-visible { outline-offset: -3px; }
/* Four corner marks, like the frame of a viewing station. */
.viewer::after {
  content: '';
  position: absolute;
  inset: 8px;
  pointer-events: none;
  background:
    linear-gradient(var(--tick), var(--tick)) top left / 18px 2px no-repeat,
    linear-gradient(var(--tick), var(--tick)) top left / 2px 18px no-repeat,
    linear-gradient(var(--tick), var(--tick)) top right / 18px 2px no-repeat,
    linear-gradient(var(--tick), var(--tick)) top right / 2px 18px no-repeat,
    linear-gradient(var(--tick), var(--tick)) bottom left / 18px 2px no-repeat,
    linear-gradient(var(--tick), var(--tick)) bottom left / 2px 18px no-repeat,
    linear-gradient(var(--tick), var(--tick)) bottom right / 18px 2px no-repeat,
    linear-gradient(var(--tick), var(--tick)) bottom right / 2px 18px no-repeat;
}

.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.scan { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.overlay-host, .box-labels, .sweep { position: absolute; inset: 0; pointer-events: none; }
.box-svg { position: absolute; left: 0; top: 0; overflow: visible; }

.box { vector-effect: non-scaling-stroke; stroke-width: 3; }
.box-ai { fill: rgba(91, 194, 219, 0.1); stroke: #5bc2db; stroke-dasharray: 9 6; }
.box-ai.is-highlighted { fill: rgba(91, 194, 219, 0.28); stroke-width: 5; }
.box-key { fill: rgba(220, 174, 98, 0.1); stroke: #dcae62; }

.box-label {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0 0.5em;
  border-radius: 5px;
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
  transform: translateY(-100%) scale(calc(1 / var(--zoom, 1)));
  transform-origin: left bottom;
}
.box-label.below { transform: scale(calc(1 / var(--zoom, 1))); transform-origin: left top; }
.box-label-ai { background: #04161c; color: #f2fbfd; border: 1.5px solid #5bc2db; }
.box-label-key { background: #1f1606; color: #fff3d6; border: 1.5px solid #dcae62; }
.box-n {
  display: inline-block;
  min-width: 1.3em;
  border-radius: 999px;
  background: #5bc2db;
  color: #04222b;
  text-align: center;
  line-height: 1.3;
}

.zoom-badge {
  position: absolute;
  right: 14px;
  top: 12px;
  padding: 0 0.5em;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.55);
  color: #cfdbe1;
  font-size: 0.62rem;
  pointer-events: none;
}

/* The scanning sweep: a soft band that crosses the picture while the AI looks. */
.sweep {
  opacity: 0;
  background: linear-gradient(
      90deg,
      transparent 38%,
      rgba(91, 194, 219, 0.3) 48.5%,
      rgba(170, 236, 248, 0.95) 50%,
      rgba(91, 194, 219, 0.3) 51.5%,
      transparent 62%
    )
    0 0 / 300% 100% no-repeat;
}
.scanning .sweep { opacity: 1; animation: sweep 2.6s linear infinite; }
@keyframes sweep {
  from { background-position: 0 0; }
  to { background-position: 100% 0; }
}

.viewer-tools {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.7rem;
  font-size: 0.7rem;
}
.tool-group { display: inline-flex; gap: 0.25rem; align-items: center; }
.zoom-reset { min-width: 3.6em; font-variant-numeric: tabular-nums; }
.range { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--muted); }
.range input { width: 4.6rem; accent-color: var(--accent); }
.range-value { min-width: 2.9em; font-variant-numeric: tabular-nums; color: var(--ink); }

.slices { flex: none; display: flex; gap: 0.5rem; overflow-x: auto; padding: 0.1rem; }
.thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.25rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: 0.62rem;
  cursor: pointer;
}
.thumb img { width: 3.6rem; height: 3.6rem; object-fit: cover; border-radius: 4px; background: var(--field); }
.thumb[aria-current='true'] { border-color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); font-weight: 700; }

.credit { flex: none; color: var(--muted); font-size: 0.66rem; }

.toolbar {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.5rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--line);
}

/* ---------- the side column ---------- */

.side {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.4rem;
  outline: none;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.side > [hidden] { display: none; }

.side h2 { font-size: 1.15rem; margin-bottom: 0.4rem; }
.side h3 { font-size: 0.95rem; margin-bottom: 0.25rem; }

.side-intro { display: grid; gap: 1rem; }
.story p { font-size: 1rem; }
.send-card {
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--panel);
}
.file-chip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.45rem 0.7rem;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--raised);
}
.file-name { font-weight: 600; }
.file-meta { color: var(--muted); font-size: 0.75rem; }

.guess { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.guess-block { display: grid; gap: 0.3rem; }
.start { align-self: flex-start; }

.side-error {
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-left: 5px solid var(--amber);
  border-radius: 10px;
  background: var(--panel);
  display: grid;
  gap: 0.6rem;
  justify-items: start;
}
.error-text { font-size: 1rem; }

/* ---------- the processing view ---------- */

.processing {
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--panel);
  display: grid;
  gap: 0.55rem;
}
.processing-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.processing-head h2 { margin: 0; font-size: 1.15rem; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1rem; color: var(--accent-ink); }

.bar { height: 0.5rem; border-radius: 999px; background: var(--raised); overflow: hidden; }
.bar-fill { height: 100%; width: 0; border-radius: 999px; background: var(--accent); transition: width 0.5s ease-out; }

.steps { list-style: none; display: grid; gap: 0.1rem; }
.step {
  display: grid;
  grid-template-columns: 1.5rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.4rem;
  padding: 0.12rem 0;
  font-size: 0.78rem;
  line-height: 1.25;
  color: var(--muted);
}
.step-mark { display: inline-flex; align-items: center; justify-content: center; width: 1.5rem; height: 1.2rem; color: var(--accent-ink); }
.step-time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.7rem; }
.step[data-state='pending'] { opacity: 0.62; }
.step[data-state='pending'] .step-mark::before {
  content: '';
  width: 0.6rem;
  height: 0.6rem;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
}
.step[data-state='active'] { color: var(--ink); font-weight: 700; }
.step[data-state='active'] .step-mark::before {
  content: '';
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.3s ease-in-out infinite;
}
.step[data-state='done'] { color: var(--ink); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(91, 194, 219, 0.7); }
  70% { box-shadow: 0 0 0 0.5rem rgba(91, 194, 219, 0); }
  100% { box-shadow: 0 0 0 0 rgba(91, 194, 219, 0); }
}

.words { color: var(--muted); font-size: 0.72rem; font-variant-numeric: tabular-nums; }
.early { padding: 0.45rem 0.7rem; border-left: 4px solid var(--violet); border-radius: 0 8px 8px 0; background: var(--violet-soft); }
.early[hidden], .words[hidden] { display: none; }
.early-line { font-weight: 700; font-size: 0.9rem; }
.early-headline { margin-top: 0.15rem; font-size: 0.9rem; }
.caption { color: var(--muted); font-size: 0.74rem; min-height: 2.6em; }
.caption strong { color: var(--ink); }

/* ---------- the answer ---------- */

.answer { display: grid; gap: 0.7rem; }
.answer > [hidden] { display: none; }

.overall {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  width: fit-content;
  padding: 0.1em 0.75em;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--raised);
  font-size: 0.75rem;
  font-weight: 700;
}
.headline { margin-top: 0.4rem; font-size: 1.55rem; }
.a-meta { margin-top: 0.3rem; color: var(--muted); font-size: 0.72rem; }

.voice-kid .v-doc,
.voice-doctor .v-kid { display: none; }
.voice-kid .headline,
.voice-kid .finding-text { padding-left: 0.6rem; border-left: 4px solid var(--violet); }
.voice-doctor .headline,
.voice-doctor .finding-text { padding-left: 0.6rem; border-left: 4px solid var(--accent); }

.finding {
  display: grid;
  grid-template-columns: 1.9rem minmax(0, 1fr);
  gap: 0.6rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--panel);
}
.finding:focus { outline: none; }
.finding-none { display: block; color: var(--muted); }
.finding-n {
  width: 1.9rem;
  height: 1.9rem;
  border: 2px solid var(--accent);
  border-radius: 50%;
  color: var(--accent-ink);
  font-weight: 700;
  line-height: 1.65rem;
  text-align: center;
}
.finding-title { font-size: 1.05rem; margin-bottom: 0.25rem; }
.finding-text { font-size: 0.85rem; }
.finding-where { margin-top: 0.35rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; color: var(--muted); font-size: 0.75rem; }
.confidence { margin-top: 0.3rem; display: inline-flex; align-items: center; gap: 0.4em; font-size: 0.75rem; font-weight: 700; }
.confidence .icon { width: 1.6em; height: 1.6em; color: var(--accent-ink); }

.a-tail { display: grid; gap: 0.7rem; }
.a-section ul { margin-left: 1.1rem; font-size: 0.82rem; display: grid; gap: 0.15rem; }
.a-section h3 { font-size: 0.95rem; }
.a-cant { padding: 0.55rem 0.8rem; border: 1px dashed var(--line-strong); border-radius: 10px; }
.a-fun, .a-safety { display: flex; gap: 0.5rem; align-items: flex-start; font-size: 0.8rem; }
.a-fun .icon, .a-safety .icon { margin-top: 0.15em; color: var(--amber); }
.a-safety { color: var(--muted); }
.a-disclaimer { padding-top: 0.5rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.7rem; }

/* ---------- the answer key ---------- */

.side-key {
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--amber);
  border-radius: 12px;
  background: var(--amber-soft);
}
.verdict {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.4rem 0.7rem;
  border: 2px solid var(--line-strong);
  border-radius: 10px;
  background: var(--panel);
  font-size: 0.85rem;
}
.verdict strong { font-size: 1.1rem; font-family: var(--font-head); }
.verdict .icon { width: 1.5rem; height: 1.5rem; }
.verdict-matches { border-color: var(--accent); }
.verdict-matches .icon { color: var(--accent-ink); }
.verdict-partly { border-color: var(--amber); border-style: dashed; }
.verdict-partly .icon { color: var(--amber); }
.verdict-misses { border-color: var(--coral); border-style: dotted; }
.verdict-misses .icon { color: var(--coral); }
.key-facts { display: grid; gap: 0.4rem; margin: 0.7rem 0 0.4rem; }
.key-facts dt { color: var(--muted); font-size: 0.7rem; }
.key-facts dd { margin: 0; font-size: 0.85rem; }
.points { margin-left: 1.1rem; font-size: 0.82rem; display: grid; gap: 0.15rem; }
.small { color: var(--muted); font-size: 0.7rem; margin-top: 0.4rem; }

/* ---------- questions ---------- */

.side-questions { padding-bottom: 0.4rem; }
.suggested { list-style: none; display: grid; gap: 0.4rem; margin-bottom: 0.6rem; }
.question { width: 100%; justify-content: flex-start; text-align: left; }
.ask-form { display: flex; gap: 0.4rem; margin-bottom: 0.6rem; }
.ask-form input {
  flex: 1;
  min-width: 0;
  padding: 0.3em 0.6em;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  font-size: 0.8rem;
}
.conv { display: grid; gap: 0.6rem; }
.qa .q { font-weight: 700; font-size: 0.82rem; color: var(--violet); }
.qa .a { margin-top: 0.15rem; font-size: 0.85rem; white-space: pre-wrap; }
.caret { display: inline-block; margin-left: 1px; color: var(--accent-ink); animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

/* ---------- under the hood ---------- */

/* Under the hood sits over the right-hand side of the screen: the picture stays in view and every key still works. */
.hood-dock {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 20;
  width: min(50rem, 58vw);
  display: flex;
  flex-direction: column;
  border-left: 2px solid var(--accent);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.hood-dock[hidden] { display: none; }
.hood-bar { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0.25rem 1rem; border-bottom: 1px solid var(--line); }
.hood-bar h2 { font-size: 1.1rem; }
.hood-scroll { flex: 1; min-height: 0; overflow: auto; padding: 0.5rem 1rem 0.8rem; }
.hood { display: grid; gap: 0.5rem; max-width: 70rem; }
.hood-item { border: 1px solid var(--line); border-radius: 8px; background: var(--raised); }
.hood-item summary { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.3rem 0.7rem; font-size: 0.78rem; font-weight: 600; cursor: pointer; }
.hood-item code { color: var(--muted); font-family: var(--font-mono); font-size: 0.7rem; font-weight: 400; }
.codeblock {
  margin: 0;
  padding: 0.5rem 0.7rem;
  max-height: 12rem;
  overflow: auto;
  background: var(--field);
  color: #d5e1e7;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 0 0 8px 8px;
}
.hood-stream h3 { font-size: 0.85rem; margin-bottom: 0.25rem; }
.hood-stream .codeblock { max-height: 9rem; border-radius: 8px; border: 1px solid var(--line); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0.4rem 1rem; margin: 0; }
.facts dt { color: var(--muted); font-size: 0.66rem; }
.facts dd { margin: 0; font-size: 0.78rem; font-weight: 600; }
.hood-note { color: var(--muted); font-size: 0.66rem; }

/* ---------- overlays ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  background: rgba(0, 0, 0, 0.55);
}
.sheet {
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
  overflow: auto;
}
.sheet:focus { outline: none; }
.sheet-sheet { margin-left: auto; width: min(34rem, 100vw); height: 100%; border-left: 1px solid var(--line-strong); }
.sheet-dialog { margin: auto; width: min(30rem, 92vw); max-height: 92vh; border: 1px solid var(--line-strong); border-radius: 14px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.6rem 1rem; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.sheet-head h2 { font-size: 1.25rem; }
.sheet-body { padding: 0.8rem 1rem 1.2rem; }

.panel { display: grid; gap: 1rem; font-size: 0.8rem; }
.panel-section h3 { font-size: 1rem; margin-bottom: 0.25rem; }
.panel-note { color: var(--muted); font-size: 0.72rem; margin-bottom: 0.4rem; }
.panel-line { margin-bottom: 0.35rem; }
.panel-warn { display: flex; gap: 0.4rem; align-items: flex-start; padding: 0.4rem 0.6rem; border-left: 4px solid var(--amber); background: var(--amber-soft); border-radius: 0 8px 8px 0; }
.panel-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.3rem 0; }
.check { display: flex; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.35rem; }
.check input { margin-top: 0.3em; width: 1.1em; height: 1.1em; accent-color: var(--accent); }
.tag { color: var(--muted); font-size: 0.85em; }
.keys { width: 100%; border-collapse: collapse; }
.keys th, .keys td { padding: 0.2rem 0.4rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); font-weight: 400; font-size: 0.72rem; }
.keys th { white-space: nowrap; width: 1%; }

.dialog-form { display: grid; gap: 0.5rem; }
.dialog-form label { font-weight: 600; font-size: 0.8rem; }
.dialog-form input[type='password'],
.dialog-form input[type='text'],
.dialog-form select {
  padding: 0.35em 0.6em;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--bg);
  font-size: 0.85rem;
}
.form-error { min-height: 1.3em; color: var(--coral); font-size: 0.78rem; font-weight: 600; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 3.2rem;
  z-index: 60;
  transform: translate(-50%, 0.6rem);
  padding: 0.3em 1em;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--panel);
  font-size: 0.78rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- wrap-up ---------- */

.wrapup { max-width: 60rem; margin: 0 auto; padding: 1.6rem 1.5rem; display: grid; gap: 1.1rem; }
.wrapup h1 { font-size: 2.3rem; }
.ideas { list-style: none; display: grid; gap: 0.8rem; counter-reset: idea; }
.idea { padding: 0.8rem 1rem 0.9rem 4rem; position: relative; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--panel); }
.idea::before {
  counter-increment: idea;
  content: counter(idea);
  position: absolute;
  left: 1rem;
  top: 0.8rem;
  width: 2.2rem;
  height: 2.2rem;
  border: 2px solid var(--accent);
  border-radius: 50%;
  color: var(--accent-ink);
  font-family: var(--font-head);
  font-weight: 700;
  line-height: 1.95rem;
  text-align: center;
}
.idea h2 { font-size: 1.7rem; margin-bottom: 0.25rem; }
.idea p { font-size: 1rem; }
.wrapup-note { color: var(--muted); }

/* ---------- smaller screens ---------- */

@media (max-width: 860px) {
  .doors { grid-template-columns: 1fr; }
  .case { height: auto; }
  .case-grid { grid-template-columns: 1fr; }
  .viewer { flex: none; height: 60vh; }
  .side { overflow: visible; padding-right: 0; }
  .case-head .case-title { white-space: normal; font-size: 1.4rem; }
  .hero h1, .wrapup h1 { font-size: 1.9rem; }
  .hood-dock { width: 100%; }
}

/* ---------- reduced motion: the sweep gives way to the plain progress bar ---------- */

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