/* ============================================================
   隐名者 · Masked Identity
   Visual language: Soviet archive (tan + red) — pushed toward
   bureaucratic-cold + constructivist + cinematic interrogation.
   Structure / DOM / JS unchanged; this is a pure restyle.
   ============================================================ */

:root {
  /* --- ink & paper (aged dossier) --- */
  --ink: #1a1613;
  --ink-2: #241f19;
  --ink-soft: rgba(26, 22, 19, 0.72);
  --ink-faint: rgba(26, 22, 19, 0.5);
  --ink-ghost: rgba(26, 22, 19, 0.34);

  --paper: #d7ccac;
  --paper-hi: #e6dcbe;
  --paper-2: #c6bb98;
  --paper-edge: #b3a880;
  --paper-ink: #efe6c8; /* light text on dark */
  --paper-ink-soft: rgba(239, 230, 200, 0.66);

  /* --- constructivist accents --- */
  --red: #a4232b;
  --red-dark: #821820;
  --red-deep: #5d0f14;
  --green: #3a5142;
  --blue: #2f4860;
  --amber: #ae7320;
  --steel: #5c655f;

  /* --- cinematic frame --- */
  --bg: #0e0d0a;
  --bg-2: #1a1712;
  --line: rgba(26, 22, 19, 0.26);
  --line-strong: rgba(26, 22, 19, 0.5);
  --hair: rgba(26, 22, 19, 0.14);
  --shadow: rgba(0, 0, 0, 0.5);

  /* --- type --- */
  --ff-display: "Oswald", "Noto Sans SC", ui-sans-serif, sans-serif;
  --ff-head: "Noto Sans SC", "Oswald", ui-sans-serif, sans-serif;
  --ff-body: "Source Serif 4", "Noto Serif SC", Georgia, serif;
  --ff-mono: "Courier Prime", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--ff-body);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  overflow: hidden;
  background:
    radial-gradient(125% 90% at 50% -18%, rgba(164, 35, 43, 0.13), transparent 52%),
    radial-gradient(100% 120% at 50% 26%, #211c15 0%, #100e0a 62%, #0a0907 100%);
}

button {
  border: 0;
  border-radius: 0;
  cursor: pointer;
  font: inherit;
  letter-spacing: 0.01em;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

/* ----- cinematic overlays (decorative, non-interactive) ----- */
#ambientCanvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  opacity: 0.6;
  pointer-events: none;
}

.film-vignette {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background:
    radial-gradient(130% 100% at 50% 34%, transparent 52%, rgba(8, 7, 5, 0.5) 100%),
    linear-gradient(180deg, rgba(8, 7, 5, 0.32), transparent 16%, transparent 84%, rgba(8, 7, 5, 0.4));
  mix-blend-mode: multiply;
}

.film-grain {
  position: fixed;
  inset: -50%;
  z-index: 5;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-drift 6s steps(4) infinite;
}

@keyframes grain-drift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-4%, 3%); }
  50% { transform: translate(3%, -2%); }
  75% { transform: translate(-2%, -3%); }
  100% { transform: translate(2%, 2%); }
}

@media (prefers-reduced-motion: reduce) {
  .film-grain { animation: none; }
}

/* paper grain helper applied to large paper surfaces */
.shell {
  position: relative;
  z-index: 1;
  height: 100vh;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 18px;
  gap: 14px;
}

/* Grid items default to min-width:auto (= min-content), which lets a wide
   child (e.g. a monospace document line) blow the single-column layout past
   the viewport. Pin them to 0 so tracks can shrink and inner panels scroll. */
.shell > *,
.panel,
.transcript,
.doc-viewer,
.notes-log,
.doc-list {
  min-width: 0;
}

/* ============================================================
   MASTHEAD  (dark interrogation band)
   ============================================================ */
.topbar {
  position: relative;
  min-height: 80px;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(420px, 0.95fr) auto;
  align-items: center;
  gap: 20px;
  padding: 14px 18px;
  background:
    linear-gradient(180deg, #211c15, #15110c);
  border: 1px solid #000;
  border-top: 3px solid var(--red);
  box-shadow:
    inset 0 1px 0 rgba(239, 230, 200, 0.06),
    0 22px 50px rgba(0, 0, 0, 0.55);
}

.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: repeating-linear-gradient(90deg, var(--red) 0 18px, transparent 18px 30px);
  opacity: 0.55;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand-emblem {
  width: 64px;
  height: 56px;
  object-fit: contain;
  flex: 0 0 auto;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6));
}

h1,
p {
  margin: 0;
}

h1 {
  font-family: var(--ff-display);
  font-weight: 700;
  font-size: 30px;
  line-height: 0.92;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--paper-ink);
}

.brand-text {
  min-width: 0;
}

.brand-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  min-width: 0;
}

.case-short {
  display: none;
  font-family: var(--ff-mono);
  font-size: 12px;
  letter-spacing: 0.03em;
  color: var(--paper-ink-soft);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#caseLine {
  margin-top: 5px;
  font-family: var(--ff-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--paper-ink-soft);
}

/* ----- meters as constructivist gauges (label + value grouped, bar below) ----- */
.meters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  min-width: 0;
}

.meter {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  font-family: var(--ff-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--paper-ink-soft);
}

.meter-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.meter-head span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meter-head b {
  font-family: var(--ff-display);
  font-weight: 600;
  font-size: 17px;
  color: var(--paper-ink);
}

.meter-bar {
  position: relative;
  height: 9px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(239, 230, 200, 0.14);
}

.meter-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(90deg, transparent 0 11px, rgba(0, 0, 0, 0.55) 11px 12px);
}

.meter-bar i {
  display: block;
  height: 100%;
  width: 0;
  transition: width 320ms cubic-bezier(0.2, 0.7, 0.2, 1);
  box-shadow: 0 0 10px currentColor;
}

#truthBar {
  background: var(--amber);
  color: var(--amber);
}

#safetyBar {
  background: #5e8466;
  color: #5e8466;
}

#identityBar {
  background: #4f739a;
  color: #4f739a;
}

/* ----- top action buttons (outlined on dark) ----- */
.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-menu {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ghost.header-toggle {
  display: none;
  font-size: 16px;
}

.panel-chevron {
  display: none;
}

.panel-head .panel-chevron {
  display: none;
  padding: 0;
  background: transparent;
  color: var(--ink-faint);
  font-size: 11px;
  letter-spacing: 0;
}

.ghost {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 56px;
  padding: 9px 13px;
  border: 1px solid rgba(239, 230, 200, 0.28);
  background: rgba(239, 230, 200, 0.04);
  color: var(--paper-ink);
  font-family: var(--ff-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.ghost::before {
  font-size: 14px;
  line-height: 1;
}

#musicBtn::before { content: "\266a"; }
#mapBtn::before {
  content: "";
  width: 16px;
  height: 14px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 6a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 6a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z'/%3E%3C/svg%3E") center/contain no-repeat;
}
#resetBtn::before { content: "\21bb"; }

/* chapter title may be long — let it wrap instead of clipping to an ellipsis */
#chapterTitle {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.2;
}

.ghost:hover {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

#musicBtn[aria-pressed="false"]::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26px;
  height: 2px;
  background: var(--red);
  transform: translate(-50%, -50%) rotate(-45deg);
  pointer-events: none;
}

/* ============================================================
   WORKBENCH  (paper panels under the lamp)
   ============================================================ */
.workbench {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(260px, 0.86fr) minmax(360px, 1.28fr) minmax(300px, 0.92fr);
  gap: 14px;
}

body[data-mode="intro"] .workbench,
body[data-mode="ending"] .workbench {
  grid-template-columns: minmax(320px, 0.95fr) minmax(420px, 1.25fr) minmax(300px, 0.85fr);
}

.panel {
  position: relative;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, var(--paper-hi), var(--paper) 12%, var(--paper-2) 100%);
  border: 1px solid var(--paper-edge);
  box-shadow:
    inset 0 1px 0 rgba(255, 252, 240, 0.5),
    inset 0 0 0 1px rgba(26, 22, 19, 0.08),
    0 20px 46px rgba(0, 0, 0, 0.5);
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 11px;
  border-bottom: 2px solid var(--ink);
  background: linear-gradient(180deg, rgba(26, 22, 19, 0.05), transparent);
}

.panel-head span {
  display: inline-block;
  padding: 3px 7px;
  background: var(--ink);
  color: var(--paper-hi);
  font-family: var(--ff-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.panel-head strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--ff-head);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.01em;
  color: var(--ink);
}

.location {
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  font-style: italic;
  font-size: 13.5px;
  line-height: 1.55;
}

/* scrollbars */
.transcript,
.notes-log,
.doc-viewer,
.dossier-body,
.dossier-body section {
  scrollbar-width: thin;
  scrollbar-color: rgba(26, 22, 19, 0.32) transparent;
}
.transcript::-webkit-scrollbar,
.notes-log::-webkit-scrollbar,
.doc-viewer::-webkit-scrollbar,
.dossier-body::-webkit-scrollbar,
.dossier-body section::-webkit-scrollbar { width: 9px; height: 9px; }
.transcript::-webkit-scrollbar-thumb,
.notes-log::-webkit-scrollbar-thumb,
.doc-viewer::-webkit-scrollbar-thumb,
.dossier-body::-webkit-scrollbar-thumb,
.dossier-body section::-webkit-scrollbar-thumb {
  background: rgba(26, 22, 19, 0.3);
  border: 2px solid transparent;
  background-clip: content-box;
}

/* ----- transcript ----- */
.transcript {
  flex: 1;
  overflow: auto;
  padding: 16px 18px;
}

.utterance {
  margin: 0 0 16px;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--red-dark);
  line-height: 1.74;
  font-size: 15.5px;
  color: var(--ink);
}

.utterance.doctor {
  border-color: var(--blue);
}

.utterance[data-speaker="旁白"],
.utterance[data-speaker="陌生人"],
.utterance[data-speaker="Narrator"],
.utterance[data-speaker="Stranger"] {
  border-color: var(--ink-ghost);
  color: var(--ink-soft);
  font-style: italic;
}

.utterance em {
  display: block;
  margin-bottom: 4px;
  font-family: var(--ff-mono);
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--red-dark);
}

.utterance[data-speaker="旁白"] em,
.utterance[data-speaker="陌生人"] em,
.utterance[data-speaker="Narrator"] em,
.utterance[data-speaker="Stranger"] em {
  color: var(--ink-faint);
}

/* doctor's operations, interleaved into the transcript as a gray log line */
.utterance.op {
  border-left-color: var(--ink-ghost);
  color: var(--ink-faint);
  font-style: italic;
  font-size: 14px;
  line-height: 1.6;
}

.utterance.op em {
  color: var(--ink-faint);
  letter-spacing: 0.08em;
}

.utterance.op.danger {
  border-left-color: var(--red);
  color: var(--red-dark);
}

/* ----- document list (file tabs) ----- */
/* ----- document list: compact numbered chips (desktop) ----- */
.doc-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 13px;
  border-bottom: 1px solid var(--line);
}

.empty-doc-list {
  width: 100%;
  padding: 14px;
  color: var(--ink-soft);
  font-style: italic;
  line-height: 1.6;
}

.doc-tab {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  background: linear-gradient(180deg, rgba(255, 253, 244, 0.4), rgba(255, 253, 244, 0.12));
  border: 1px solid var(--paper-edge);
  border-top: 1px solid rgba(255, 255, 255, 0.5);
  color: var(--ink);
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.doc-tab:hover {
  border-color: var(--ink-faint);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
  transform: translateY(-1px);
}

.doc-tab-num {
  font-family: var(--ff-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.02em;
}

.doc-tab-info {
  display: none;
}

.doc-tab-star {
  position: absolute;
  top: -6px;
  right: -6px;
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 999px;
  background: var(--amber);
  color: #1a1613;
  font-size: 10px;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.doc-tab-keep {
  background: linear-gradient(180deg, rgba(58, 81, 66, 0.16), rgba(58, 81, 66, 0.05));
  border-color: rgba(58, 81, 66, 0.5);
}

.doc-tab-redact {
  background: linear-gradient(180deg, rgba(47, 72, 96, 0.16), rgba(47, 72, 96, 0.05));
  border-color: rgba(47, 72, 96, 0.5);
}

.doc-tab-burn,
.doc-tab-transferred {
  opacity: 0.48;
}

.doc-tab-presented-keep {
  border-color: rgba(58, 81, 66, 0.7);
  background: linear-gradient(180deg, rgba(58, 81, 66, 0.26), rgba(58, 81, 66, 0.1));
}

.doc-tab-presented-redact {
  border-color: rgba(47, 72, 96, 0.65);
  background: linear-gradient(180deg, rgba(47, 72, 96, 0.26), rgba(47, 72, 96, 0.1));
}

.doc-tab-relevant::after {
  content: "";
  position: absolute;
  left: 5px;
  right: 5px;
  bottom: 3px;
  height: 2px;
  background: var(--amber);
}

.doc-tab[aria-selected="true"] {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
  box-shadow: 0 4px 14px rgba(130, 24, 32, 0.45);
}

.doc-tab[aria-selected="true"] .doc-tab-num {
  color: #fff;
}

.doc-tab small {
  display: block;
  margin-top: 5px;
  font-family: var(--ff-mono);
  color: var(--ink-faint);
  font-size: 11px;
  letter-spacing: 0.03em;
}

.doc-meta {
  display: block;
  margin-top: 5px;
  font-family: var(--ff-mono);
  color: var(--ink-faint);
  font-size: 10.5px;
  letter-spacing: 0.03em;
}

/* ----- document viewer (typed archive) ----- */
.doc-viewer {
  flex: 1;
  overflow: auto;
  padding: 18px 20px 24px;
  font-family: var(--ff-mono);
  font-size: 14px;
  color: var(--ink);
  background:
    linear-gradient(rgba(26, 22, 19, 0.06) 1px, transparent 1px) 0 0 / 100% 29px,
    linear-gradient(180deg, rgba(231, 222, 192, 0.5), rgba(214, 204, 172, 0.42));
}

.doc-viewer h2 {
  margin: 0 0 8px;
  font-family: var(--ff-display);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink);
  border-bottom: 2px solid var(--ink);
  padding-bottom: 7px;
}

.doc-viewer p {
  margin: 13px 0;
  line-height: 1.85;
}

.doc-system-note {
  padding: 10px 12px;
  border-left: 4px solid var(--green);
  background: rgba(58, 81, 66, 0.12);
  color: var(--ink-soft);
  font-style: normal;
}

.doc-revealed-body {
  margin: 18px 0 10px;
  padding: 12px 14px;
  border: 1px dashed rgba(58, 81, 66, 0.66);
  background: rgba(255, 255, 255, 0.22);
}

.doc-revealed-title {
  display: block;
  margin-bottom: 7px;
  font-family: var(--ff-mono);
  font-weight: 700;
  color: var(--green);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.doc-revealed-body p {
  margin: 8px 0;
}

/* redaction bar */
.mask {
  padding: 0 3px;
  background: #100d0b;
  color: #100d0b;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55);
}

/* rubber stamp seal */
.doc-seal {
  display: inline-block;
  margin: 10px 7px 0 0;
  padding: 6px 10px;
  border: 2.5px solid var(--red);
  color: var(--red-dark);
  font-family: var(--ff-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transform: rotate(-3deg);
  box-shadow: inset 0 0 0 1px rgba(164, 35, 43, 0.4);
  opacity: 0.92;
}

@keyframes stamp-in {
  0% { transform: rotate(-3deg) scale(1.7); opacity: 0; }
  60% { opacity: 0.95; }
  100% { transform: rotate(-3deg) scale(1); opacity: 0.92; }
}

.doc-seal.revealed {
  border-color: var(--green);
  color: var(--green);
  transform: rotate(1.5deg);
  box-shadow: inset 0 0 0 1px rgba(58, 81, 66, 0.4);
}

@media (prefers-reduced-motion: reduce) {
  .doc-seal { animation: none; }
}

/* ----- disposition actions ----- */
.actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 13px;
  border-top: 2px solid var(--ink);
}

.actions button,
.diagnosis-box button,
.primary {
  padding: 11px 12px;
  background: var(--ink);
  color: var(--paper-hi);
  font-family: var(--ff-head);
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: 0.02em;
  transition: filter 130ms ease, transform 90ms ease;
}

.actions button:hover,
.diagnosis-box button:hover,
.primary:hover {
  filter: brightness(1.18);
}

.actions button:active,
.primary:active {
  transform: translateY(1px);
}

.actions button:nth-child(2) {
  background: var(--blue);
}

.actions button:nth-child(3) {
  background: var(--red-deep);
}

/* ============================================================
   NOTES PANEL
   ============================================================ */
.identity-strip {
  padding: 9px 15px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 4px;
  font-family: var(--ff-mono);
  font-size: 12px;
}

.identity-strip div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 4px;
  border-bottom: 1px dotted var(--hair);
}

.identity-strip div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.identity-strip span {
  flex: 0 0 auto;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.identity-strip b {
  color: var(--red-dark);
  font-weight: 700;
  min-width: 0;
  text-align: right;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.notes-log {
  flex: 1;
  overflow: auto;
  padding: 13px 15px;
}

.evidence-panel {
  margin-bottom: 15px;
  padding: 13px;
  border: 1px solid var(--red-dark);
  border-left-width: 4px;
  background: rgba(130, 24, 32, 0.07);
}

.evidence-panel strong {
  display: block;
  margin-bottom: 9px;
  color: var(--red-dark);
  font-family: var(--ff-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.evidence-panel p {
  color: var(--ink-faint);
  font-size: 12.5px;
  line-height: 1.5;
  margin: 0;
}

.evidence-panel div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.evidence-panel button {
  padding: 6px 9px;
  background: var(--ink);
  color: var(--paper-hi);
  font-family: var(--ff-mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background 130ms ease;
}

.evidence-panel button:hover {
  background: var(--red-dark);
}

.evidence-panel.contact-locked {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.14);
}

.evidence-panel.contact-locked strong {
  color: var(--ink-soft);
}

.evidence-panel.contact-locked button,
.evidence-panel button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.evidence-panel.contact-locked button:hover,
.evidence-panel button:disabled:hover {
  background: var(--ink);
}

.note {
  margin-bottom: 11px;
  padding: 10px 12px;
  border-left: 4px solid var(--green);
  background: rgba(255, 255, 255, 0.22);
  line-height: 1.6;
  font-size: 13.5px;
}

.note button {
  display: block;
  margin-top: 9px;
  padding: 8px 10px;
  background: var(--ink);
  color: var(--paper-hi);
  font-family: var(--ff-head);
  font-weight: 700;
  font-size: 12.5px;
}

.note.danger {
  border-color: var(--red);
}

.note.neutral {
  border-color: var(--blue);
}

.diagnosis-box {
  padding: 13px;
  border-top: 2px solid var(--ink);
  display: grid;
  gap: 8px;
}

.diagnosis-box:empty {
  display: none;
}

.diagnosis-box button {
  text-align: left;
  background: var(--ink-2);
}

.diagnosis-box button.selected {
  background: var(--green);
}

/* ----- case-note panel (lives in the assessment column / Case Note tab) ----- */
.cn-lead {
  color: var(--ink-soft);
  font-style: italic;
  font-size: 13.5px;
  line-height: 1.6;
  margin-bottom: 12px;
}

.cn-lead.done {
  border-left: 4px solid var(--green);
  padding: 9px 12px;
  background: rgba(58, 81, 66, 0.1);
  font-style: normal;
}

.cn-reminder {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-left: 4px solid var(--blue);
  background: rgba(47, 72, 96, 0.1);
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.55;
}

.cn-options {
  display: grid;
  gap: 9px;
  margin-bottom: 14px;
}

.cn-options button {
  text-align: left;
  padding: 13px 14px;
  background: var(--ink-2);
  color: var(--paper-hi);
  font-family: var(--ff-head);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.4;
  transition: filter 130ms ease, transform 90ms ease;
}

.cn-options button:hover:not(:disabled) {
  filter: brightness(1.18);
}

.cn-options button:active:not(:disabled) {
  transform: translateY(1px);
}

.cn-options button.selected {
  background: var(--green);
}

.cn-record-btn {
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
  font-family: var(--ff-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: background 130ms ease, color 130ms ease;
}

.cn-record-btn:hover {
  background: var(--ink);
  color: var(--paper-hi);
}

.diagnosis-lock {
  color: var(--ink-soft);
  font-style: italic;
  font-size: 13px;
  line-height: 1.55;
}

.diagnosis-hint {
  padding: 10px 12px;
  border-left: 4px solid var(--amber);
  background: rgba(174, 115, 32, 0.12);
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.6;
}

/* ============================================================
   INTRO / ENDING
   ============================================================ */
.intro-copy {
  padding: 10px 4px;
}

.intro-copy h2,
.ending h2 {
  margin: 0 0 14px;
  font-family: var(--ff-display);
  font-weight: 700;
  color: var(--red-dark);
  font-size: 34px;
  line-height: 0.95;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ending-signature {
  margin: 16px 0 18px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-style: italic;
  font-size: 15px;
}

.ending-name {
  position: relative;
  display: inline-block;
  color: var(--ink);
  font-weight: 700;
  font-style: normal;
  letter-spacing: 0.03em;
}

.ending-name.redacting::after {
  content: "";
  position: absolute;
  left: -2px;
  top: 6%;
  height: 88%;
  width: 0;
  background: var(--ink);
  animation: redact-sweep 3.8s 0.65s ease-in forwards;
}

@keyframes redact-sweep {
  from { width: 0; }
  to { width: calc(100% + 4px); }
}

.intro-copy p {
  margin: 0 0 16px;
  line-height: 1.82;
  font-size: 16px;
}

.rule-list {
  display: grid;
  gap: 12px;
}

.rule-list div {
  border-left: 4px solid var(--red-dark);
  padding: 11px 13px;
  background: rgba(255, 255, 255, 0.2);
}

.rule-list b {
  display: block;
  margin-bottom: 5px;
  font-family: var(--ff-head);
  color: var(--red-dark);
}

.rule-list p {
  line-height: 1.62;
}

/* ============================================================
   MAP / TREE NODES
   ============================================================ */
.map-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.map-node {
  min-height: 112px;
  padding: 12px 13px;
  border: 1px solid var(--paper-edge);
  background:
    linear-gradient(90deg, rgba(130, 24, 32, 0.13), transparent 38%),
    rgba(255, 255, 255, 0.2);
  color: var(--ink);
  text-align: left;
}

.map-node:disabled {
  background: rgba(26, 22, 19, 0.1);
  color: var(--ink-ghost);
}

.map-node.done {
  box-shadow: inset 5px 0 0 var(--green);
}

.map-node span {
  display: block;
  font-family: var(--ff-mono);
  color: var(--red-dark);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.map-node strong {
  display: block;
  margin: 6px 0;
  font-family: var(--ff-head);
  font-size: 15px;
}

.map-node small {
  display: block;
  line-height: 1.5;
  font-size: 12.5px;
}

.secret-list {
  min-width: 0;
  max-width: 100%;
  display: grid;
  gap: 10px;
}

.secret {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(76px, auto) minmax(0, 1fr);
  gap: 12px;
  padding: 11px;
  border-left: 4px solid var(--ink-ghost);
  background: rgba(255, 255, 255, 0.18);
  line-height: 1.6;
}

details.secret {
  min-width: 0;
  display: block;
  padding: 0;
}

details.secret summary {
  display: grid;
  grid-template-columns: minmax(76px, auto) minmax(0, 1fr);
  gap: 12px;
  padding: 11px;
  cursor: pointer;
}

.secret span,
details.secret summary span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.secret.open {
  border-color: var(--red-dark);
}

.secret b {
  font-family: var(--ff-mono);
  color: var(--red-dark);
  font-size: 12px;
  white-space: nowrap;
}

.secret-archive {
  min-width: 0;
  padding: 0 11px 11px 88px;
  overflow-wrap: anywhere;
}

.secret-archive p {
  margin: 8px 0 0;
  line-height: 1.68;
}

.ending-list {
  gap: 8px;
}

.ending-record summary span {
  font-weight: 700;
}

.pressure-heading {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* ============================================================
   DOSSIER OVERLAY
   ============================================================ */
.dossier-overlay {
  position: fixed;
  inset: 0;
  z-index: 7;
  padding: 32px;
  background: rgba(6, 5, 4, 0.72);
  backdrop-filter: blur(4px);
}

.dossier-card {
  min-width: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
  border: 1px solid #000;
  border-top: 3px solid var(--red);
  background:
    linear-gradient(rgba(26, 22, 19, 0.05) 1px, transparent 1px) 0 0 / 100% 29px,
    linear-gradient(180deg, var(--paper-hi), var(--paper-2));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
}

.dossier-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 16px;
  border-bottom: 2px solid var(--ink);
}

.dossier-head span {
  font-family: var(--ff-mono);
  color: var(--red-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.dossier-head h2 {
  margin: 4px 0 0;
  font-family: var(--ff-display);
  font-weight: 700;
  font-size: 28px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.dossier-head button,
.tree-node button,
#sealCase {
  padding: 10px 14px;
  background: var(--ink);
  color: var(--paper-hi);
  font-family: var(--ff-head);
  font-weight: 700;
  font-size: 13px;
  transition: filter 130ms ease;
}

.dossier-head button:hover,
.tree-node button:hover,
#sealCase:hover {
  filter: brightness(1.2);
}

#sealCase {
  background: var(--red-deep);
}

.dossier-body {
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: grid;
  grid-template-columns: minmax(380px, 1.25fr) minmax(320px, 0.95fr) minmax(260px, 0.75fr);
  gap: 14px;
  padding: 18px;
}

.dossier-section {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--paper-edge);
  background: rgba(255, 255, 255, 0.16);
}

.dossier-section-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 15px 15px 0;
  background: transparent;
  text-align: left;
  cursor: default;
}

.dossier-section-head h3 {
  flex: 1;
  min-width: 0;
}

.dossier-section-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 15px 15px;
}

.dossier-body h3 {
  margin: 0 0 13px;
  font-family: var(--ff-head);
  font-weight: 700;
  color: var(--red-dark);
  font-size: 16px;
  letter-spacing: 0.02em;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.tree-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
}

.tree-node {
  position: relative;
  min-height: 112px;
  padding: 12px 13px;
  border: 1px solid var(--paper-edge);
  background:
    linear-gradient(90deg, rgba(130, 24, 32, 0.13), transparent 38%),
    rgba(255, 255, 255, 0.2);
}

.tree-node::after {
  content: "";
  position: absolute;
  left: 18px;
  bottom: -12px;
  width: 1px;
  height: 11px;
  background: rgba(130, 24, 32, 0.45);
}

.tree-node.locked {
  color: var(--ink-ghost);
  background: rgba(26, 22, 19, 0.1);
}

.tree-node.current {
  box-shadow: inset 5px 0 0 var(--amber);
}

.tree-node.done {
  box-shadow: inset 5px 0 0 var(--green);
}

.tree-node.contact {
  border-style: dashed;
  background:
    linear-gradient(90deg, rgba(26, 22, 19, 0.12), transparent 40%),
    rgba(255, 255, 255, 0.14);
}

.tree-node span {
  display: block;
  font-family: var(--ff-mono);
  color: var(--red-dark);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tree-node strong {
  display: block;
  margin: 6px 0;
  font-family: var(--ff-head);
}

.tree-node small {
  display: block;
  line-height: 1.5;
  font-size: 12.5px;
}

.tree-node button {
  margin-top: 10px;
}

/* ============================================================
   FOOTER  (dark bracket)
   ============================================================ */
.footer {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
  background: linear-gradient(180deg, #1a160f, #14110b);
  border: 1px solid #000;
  border-bottom: 3px solid var(--red);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.4);
}

.footer-handle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 18px;
  background: transparent;
  color: var(--paper-ink-soft);
  font-family: var(--ff-mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-align: left;
  transition: color 140ms ease, background 140ms ease;
}

.footer-handle:hover {
  color: var(--paper-ink);
}

.footer-handle-chevron {
  flex: 0 0 auto;
  font-size: 11px;
  line-height: 1;
  opacity: 0.7;
  transition: transform 200ms ease;
}

.footer-handle-mark {
  display: none;
  flex: 0 0 auto;
  font-size: 14px;
  line-height: 1;
}

.footer-handle-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body[data-footer-open="true"] .footer-handle {
  justify-content: center;
  gap: 8px;
  padding: 6px 18px 0;
}

body[data-footer-open="true"] .footer-handle-chevron {
  transform: rotate(180deg);
}

body[data-footer-open="true"] .footer-handle-label {
  display: none;
}

body:not([data-mode="chapter"]) .footer-handle {
  display: none;
}

/* The footer collapse handle is a mobile affordance only; on wider screens the
   footer stays expanded and Continue simply enables once a note is written. */
@media (min-width: 769px) {
  .footer-handle {
    display: none;
  }
}

.footer-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 4px 18px 13px;
}

body[data-footer-open="false"] .footer-body {
  display: none;
}

/* collapsed + actionable: SAME slim bar as normal, just blinking so the player
   notices there's a next step — the same attention cue as the tab hints. */
body[data-footer-actionable="true"][data-footer-open="false"] .footer-handle {
  color: var(--paper-ink);
  animation: footer-blink 1.6s ease-in-out infinite;
}

@keyframes footer-blink {
  0%, 100% { background: linear-gradient(180deg, rgba(164, 35, 43, 0.1), transparent); }
  50% { background: linear-gradient(180deg, rgba(164, 35, 43, 0.42), transparent); }
}

body[data-footer-actionable="true"][data-footer-open="false"] .footer-handle-chevron {
  color: var(--red);
  opacity: 1;
  animation: footer-hint 1.5s ease-in-out infinite;
}

@keyframes footer-hint {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
  body[data-footer-actionable="true"][data-footer-open="false"] .footer-handle-chevron { animation: none; }
}

#statusLine {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.5;
  font-family: var(--ff-mono);
  font-size: 12.5px;
  letter-spacing: 0.02em;
  color: var(--paper-ink-soft);
}

.primary {
  min-width: 110px;
  background: var(--red);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.primary:not(:disabled) {
  box-shadow: 0 4px 0 var(--red-deep);
}

/* When a case note is written (continue ready), the button blinks for attention
   — the same cue family as the evidence/case-note hints. */
body[data-footer-actionable="true"] .primary:not(:disabled) {
  animation: cta-pulse 1.6s ease-in-out infinite;
}

@keyframes cta-pulse {
  0%, 100% { box-shadow: 0 4px 0 var(--red-deep), 0 0 0 0 rgba(164, 35, 43, 0); }
  50% { box-shadow: 0 4px 0 var(--red-deep), 0 0 18px 2px rgba(164, 35, 43, 0.72); }
}

@media (prefers-reduced-motion: reduce) {
  body[data-footer-actionable="true"] .primary:not(:disabled) { animation: none; }
}

body[data-tutorial-pending="true"][data-mode="intro"] #nextBtn,
body[data-tutorial-stage="archive-keep"] [data-action="keep"],
body[data-tutorial-stage="archive-redact"] [data-action="redact"],
body[data-tutorial-stage="archive-burn"] [data-action="burn"],
body[data-tutorial-stage="archive-redact-demo"] [data-action="redact"] {
  animation: guide-pulse 1.05s ease-in-out infinite;
}

body[data-tutorial-stage="assessment"] .cn-options button {
  opacity: 1;
  cursor: pointer;
  background: var(--ink-2);
  color: var(--paper-hi);
  animation: guide-dark-pulse 1.05s ease-in-out infinite;
}

body[data-tutorial-stage="footer"] #nextBtn {
  opacity: 1;
  cursor: pointer;
  background: var(--red);
  color: #fff;
  box-shadow: 0 4px 0 var(--red-deep);
  animation: guide-red-pulse 1.05s ease-in-out infinite;
}

body[data-tutorial-stage="archive-redact-demo"] .meter {
  animation: guide-meter-pulse 1.05s ease-in-out infinite;
}

body[data-tutorial-stage="archive-redact-demo"] .meter-head span,
body[data-tutorial-stage="archive-redact-demo"] .meter-head b {
  animation: guide-meter-text-pulse 1.05s ease-in-out infinite;
}

body[data-tutorial-stage="archive-redact-demo"] .meter-bar {
  animation: guide-axis-pulse 1.05s ease-in-out infinite;
}

@keyframes guide-pulse {
  0%, 100% {
    filter: brightness(1);
    box-shadow: 0 4px 0 var(--red-deep), 0 0 0 0 rgba(174, 115, 32, 0);
  }
  50% {
    filter: brightness(1.25);
    box-shadow: 0 4px 0 var(--red-deep), 0 0 0 8px rgba(174, 115, 32, 0.34);
  }
}

@keyframes guide-dark-pulse {
  0%, 100% {
    filter: brightness(1);
    box-shadow: 0 0 0 0 rgba(26, 22, 19, 0);
  }
  50% {
    filter: brightness(1.22);
    box-shadow: 0 0 0 7px rgba(26, 22, 19, 0.34);
  }
}

@keyframes guide-red-pulse {
  0%, 100% {
    filter: brightness(1);
    box-shadow: 0 4px 0 var(--red-deep), 0 0 0 0 rgba(164, 35, 43, 0);
  }
  50% {
    filter: brightness(1.18);
    box-shadow: 0 4px 0 var(--red-deep), 0 0 0 8px rgba(164, 35, 43, 0.38);
  }
}

@keyframes guide-meter-pulse {
  0%, 100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.28);
  }
}

@keyframes guide-meter-text-pulse {
  0%, 100% {
    color: inherit;
    text-shadow: none;
  }
  50% {
    color: var(--paper-hi);
    text-shadow: 0 0 12px rgba(239, 230, 200, 0.55);
  }
}

@keyframes guide-axis-pulse {
  0%, 100% {
    border-color: rgba(239, 230, 200, 0.14);
    box-shadow: none;
  }
  50% {
    border-color: rgba(239, 230, 200, 0.6);
    box-shadow: 0 0 0 4px rgba(239, 230, 200, 0.08), 0 0 18px rgba(239, 230, 200, 0.24);
  }
}

body[data-tutorial-active="true"] .topbar,
body[data-tutorial-active="true"] .panel,
body[data-tutorial-active="true"] .footer,
body[data-tutorial-active="true"] .mobile-tabs {
  pointer-events: none;
}

body[data-tutorial-active="true"] .panel,
body[data-tutorial-active="true"] .mobile-tabs {
  filter: brightness(0.42) saturate(0.8);
  transition: filter 220ms ease, box-shadow 220ms ease;
}

body[data-tutorial-active="true"] .topbar,
body[data-tutorial-active="true"] .footer {
  position: relative;
  z-index: 9;
}

body[data-tutorial-stage="transcript"] .transcript-panel,
body[data-tutorial-stage="archive-keep"] .archive-panel,
body[data-tutorial-stage="archive-redact"] .archive-panel,
body[data-tutorial-stage="archive-burn"] .archive-panel,
body[data-tutorial-stage="archive-redact-demo"] .archive-panel,
body[data-tutorial-stage="assessment"] .notes-panel {
  z-index: 7;
  filter: brightness(1) saturate(1);
  box-shadow:
    inset 0 1px 0 rgba(255, 252, 240, 0.5),
    inset 0 0 0 2px rgba(174, 115, 32, 0.55),
    0 0 0 9999px rgba(0, 0, 0, 0.52),
    0 24px 70px rgba(0, 0, 0, 0.72);
}

body[data-tutorial-stage="footer"] .panel {
  filter: brightness(0.42) saturate(0.8);
}

body[data-tutorial-stage="footer"] .footer {
  z-index: 8;
  box-shadow:
    0 0 0 9999px rgba(0, 0, 0, 0.52),
    0 0 0 3px rgba(174, 115, 32, 0.5),
    0 18px 54px rgba(0, 0, 0, 0.72);
}

body[data-tutorial-stage="archive-redact-demo"] .doc-viewer strong {
  padding: 0 3px;
  background: #100d0b;
  color: #100d0b;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55);
}

body[data-tutorial-stage="transcript"] #mobileTabTranscript,
body[data-tutorial-stage="archive-keep"] #mobileTabEvidence,
body[data-tutorial-stage="archive-redact"] #mobileTabEvidence,
body[data-tutorial-stage="archive-burn"] #mobileTabEvidence,
body[data-tutorial-stage="archive-redact-demo"] #mobileTabEvidence,
body[data-tutorial-stage="assessment"] #mobileTabDiagnosis,
body[data-tutorial-stage="footer"] #mobileTabDiagnosis {
  filter: brightness(1);
  animation: guide-pulse 1.05s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  body[data-tutorial-pending="true"][data-mode="intro"] #nextBtn,
  body[data-tutorial-active="true"] * {
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

.primary:not(:disabled):active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--red-deep);
}

/* hidden until mobile */
.mobile-doc-back,
.mobile-doc-context,
.mobile-tabs,
.mobile-diagnosis-inline,
.scroll-hint {
  display: none;
}

.scroll-hint {
  position: fixed;
  z-index: 8;
  width: 32px;
  height: 28px;
  transform: translateX(-50%);
  place-items: center;
  border: 1px solid rgba(239, 230, 200, 0.32);
  border-radius: 999px;
  background: rgba(26, 22, 19, 0.5);
  color: var(--paper-ink);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  font-size: 14px;
  line-height: 1;
  pointer-events: none;
}

.ending {
  padding: 18px 20px;
  line-height: 1.78;
  font-size: 15.5px;
}

.ending h2 {
  margin: 0 0 10px;
  font-size: 26px;
}

/* ============================================================
   RESPONSIVE — mid desktop: meters drop to their own row so
   they never collide with the action buttons
   ============================================================ */
@media (min-width: 981px) and (max-width: 1440px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand actions"
      "meters meters";
    row-gap: 13px;
    align-items: center;
  }

  .brand {
    grid-area: brand;
  }

  .top-actions {
    grid-area: actions;
    align-self: start;
  }

  .meters {
    grid-area: meters;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
  }
}

/* ============================================================
   RESPONSIVE — tablet / collapsed desktop
   ============================================================ */
@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .shell {
    height: auto;
    padding: 12px;
    gap: 12px;
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .meters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .workbench {
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(330px, auto);
  }

  body[data-mode="intro"] .workbench,
  body[data-mode="ending"] .workbench {
    grid-template-columns: 1fr;
  }

  .dossier-overlay {
    padding: 12px;
  }

  .dossier-body {
    grid-template-columns: 1fr;
  }

  .tree-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   RESPONSIVE — phone
   ============================================================ */
@media (max-width: 768px) {
  html,
  body {
    height: 100%;
    min-height: 100%;
    overflow: hidden;
  }

  #ambientCanvas {
    pointer-events: none;
  }

  .shell {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    gap: 9px;
    padding: 9px;
  }

  /* ---- collapsed compact banner (default) ---- */
  .topbar {
    min-height: 0;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand gear"
      "meters gear";
    gap: 5px 10px;
    padding: 9px 11px;
    align-items: center;
  }

  .brand {
    grid-area: brand;
    gap: 10px;
    align-items: center;
  }

  .brand-text {
    min-width: 0;
  }

  .brand-emblem {
    width: 38px;
    height: 34px;
  }

  h1 {
    font-size: 17px;
    letter-spacing: 0.03em;
  }

  .brand-line {
    gap: 2px 9px;
  }

  .case-short {
    display: inline-block;
    max-width: 100%;
    font-size: 10.5px;
  }

  .case-full {
    display: none;
  }

  .meters {
    grid-area: meters;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }

  .meter {
    gap: 0;
    font-size: 10px;
  }

  .meter-head {
    gap: 5px;
  }

  .meter-head b {
    font-size: 15px;
  }

  .meter-bar {
    display: block;
    height: 6px;
  }

  .top-actions {
    grid-area: gear;
    align-self: center;
    justify-self: end;
    gap: 6px;
  }

  .header-menu {
    display: none;
  }

  .ghost.header-toggle {
    display: inline-flex;
    width: 42px;
    min-width: 42px;
    min-height: 40px;
    padding: 0;
    font-size: 17px;
  }

  body[data-header-open="true"] .header-toggle {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
  }

  /* ---- expanded banner (gear tapped) ---- */
  body[data-header-open="true"] .topbar {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand actions"
      "meters meters";
    gap: 7px 10px;
  }

  body[data-header-open="true"] .case-short {
    display: none;
  }

  body[data-header-open="true"] .case-full {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
    line-height: 1.3;
    font-size: 10.5px;
    margin-top: 5px;
  }

  body[data-header-open="true"] .meter {
    gap: 4px;
  }

  body[data-header-open="true"] .meter-bar {
    display: block;
    height: 7px;
  }

  body[data-header-open="true"] .top-actions {
    grid-area: actions;
    justify-self: end;
    align-self: start;
    gap: 6px;
  }

  body[data-header-open="true"] .header-menu {
    display: flex;
    gap: 6px;
  }

  body[data-header-open="true"] .header-toggle {
    display: none;
  }

  .header-menu .ghost {
    width: 42px;
    min-width: 42px;
    min-height: 40px;
    padding: 0;
    font-size: 0;
    gap: 0;
  }

  .header-menu .ghost::before {
    font-size: 16px;
  }

  #langBtn {
    font-size: 12px;
  }

  .workbench {
    min-height: 0;
    height: 100%;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-auto-rows: auto;
  }

  body[data-mode="chapter"] .panel {
    display: none;
    min-height: 0;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  }

  body[data-mode="chapter"][data-mobile-tab="transcript"] .transcript-panel,
  body[data-mode="chapter"][data-mobile-tab="evidence"] .archive-panel,
  body[data-mode="chapter"][data-mobile-tab="diagnosis"] .notes-panel {
    display: flex;
  }

  body:not([data-mode="chapter"]) .workbench {
    overflow: auto;
    grid-template-columns: minmax(0, 1fr);
    grid-auto-rows: minmax(240px, auto);
  }

  body:not([data-mode="chapter"]) .panel {
    display: flex;
    min-height: 240px;
  }

  .panel-head {
    padding: 11px 12px 9px;
  }

  .panel-head strong {
    font-size: 14.5px;
  }

  .location {
    padding: 9px 12px;
    font-size: 12.5px;
  }

  .transcript,
  .notes-log,
  .doc-viewer {
    -webkit-overflow-scrolling: touch;
  }

  .transcript {
    padding: 13px;
  }

  body[data-mode="chapter"] .mobile-diagnosis-inline:not(:empty) {
    display: grid;
    gap: 7px;
    padding: 10px 11px;
    border-top: 2px solid var(--ink);
    background: rgba(130, 24, 32, 0.07);
  }

  .mobile-diagnosis-inline .diagnosis-lock {
    font-size: 12px;
    line-height: 1.5;
  }

  .mobile-diagnosis-inline button {
    min-height: 44px;
    padding: 10px 11px;
    background: var(--ink-2);
    color: var(--paper-hi);
    font-family: var(--ff-head);
    font-weight: 700;
    text-align: left;
  }

  .mobile-diagnosis-inline button.selected {
    background: var(--green);
  }

  .utterance {
    margin-bottom: 13px;
    line-height: 1.68;
    font-size: 15px;
  }

  body[data-mode="chapter"][data-mobile-tab="evidence"][data-mobile-doc-open="false"] .doc-list {
    flex: 1;
    overflow: auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    gap: 9px;
    padding: 11px;
    border-bottom: 0;
  }

  body[data-mode="chapter"][data-mobile-tab="evidence"][data-mobile-doc-open="false"] .doc-viewer,
  body[data-mode="chapter"][data-mobile-tab="evidence"][data-mobile-doc-open="false"] .actions,
  body[data-mode="chapter"][data-mobile-tab="evidence"][data-mobile-doc-open="false"] .mobile-doc-back,
  body[data-mode="chapter"][data-mobile-tab="evidence"][data-mobile-doc-open="false"] .mobile-doc-context {
    display: none;
  }

  .doc-tab {
    width: auto;
    height: auto;
    min-height: 72px;
    padding: 12px;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 11px;
    text-align: left;
  }

  .doc-tab-num {
    flex: 0 0 auto;
    font-size: 16px;
    line-height: 1.3;
    color: var(--red-dark);
  }

  .doc-tab[aria-selected="true"] {
    background: linear-gradient(180deg, rgba(255, 253, 244, 0.5), rgba(255, 253, 244, 0.15));
    color: var(--ink);
    box-shadow: inset 5px 0 0 var(--red), 0 6px 16px rgba(0, 0, 0, 0.2);
  }

  .doc-tab[aria-selected="true"] .doc-tab-num {
    color: var(--red-dark);
  }

  .doc-tab-info {
    display: block;
    min-width: 0;
  }

  .doc-tab-title {
    display: block;
    line-height: 1.34;
    font-weight: 600;
    font-family: var(--ff-head);
  }

  .doc-tab small,
  .doc-meta {
    font-size: 11.5px;
  }

  body[data-mode="chapter"][data-mobile-tab="evidence"][data-mobile-doc-open="true"] .panel-head,
  body[data-mode="chapter"][data-mobile-tab="evidence"][data-mobile-doc-open="true"] .doc-list {
    display: none;
  }

  body[data-mode="chapter"][data-mobile-tab="evidence"][data-mobile-doc-open="true"] .mobile-doc-back {
    display: block;
    min-height: 46px;
    padding: 11px 13px;
    border-bottom: 2px solid var(--ink);
    background: var(--ink);
    color: var(--paper-hi);
    font-family: var(--ff-mono);
    letter-spacing: 0.04em;
    text-align: left;
  }

  body[data-mode="chapter"][data-mobile-tab="evidence"][data-mobile-doc-open="true"] .mobile-doc-context {
    display: block;
    padding: 9px 13px;
    border-bottom: 1px solid var(--line);
    overflow: hidden;
    color: var(--ink-soft);
    font-family: var(--ff-mono);
    font-size: 11.5px;
    line-height: 1.4;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body[data-mode="chapter"][data-mobile-tab="evidence"][data-mobile-doc-open="true"] .doc-viewer {
    flex: 1;
    min-height: 0;
    display: block;
    padding: 15px;
    font-size: 14.5px;
  }

  .doc-viewer h2 {
    font-size: 19px;
  }

  .doc-viewer p {
    line-height: 1.78;
  }

  body[data-mode="chapter"][data-mobile-tab="evidence"][data-mobile-doc-open="true"] .actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 9px;
  }

  body[data-mode="chapter"][data-mobile-tab="evidence"][data-mobile-doc-open="true"] .footer {
    display: none;
  }

  .actions button,
  .diagnosis-box button,
  .primary {
    min-height: 44px;
    padding: 10px 8px;
    font-size: 14px;
  }

  .identity-strip {
    padding: 11px 13px;
  }

  .notes-log {
    padding: 11px 13px;
  }

  .diagnosis-box {
    padding: 11px;
  }

  .footer {
    min-height: 0;
    padding: 0;
    gap: 0;
  }

  #statusLine {
    overflow: visible;
    display: block;
    font-size: 11.5px;
    line-height: 1.5;
  }

  .primary {
    min-width: 86px;
    flex: 0 0 auto;
  }

  body[data-mode="chapter"] .mobile-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    min-height: calc(56px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: linear-gradient(180deg, #1a160f, #14110b);
    border: 1px solid #000;
    border-top: 2px solid var(--red);
    box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.4);
  }

  .mobile-tabs button {
    position: relative;
    min-height: 56px;
    border-radius: 0;
    border-right: 1px solid rgba(0, 0, 0, 0.5);
    background: transparent;
    color: var(--paper-ink-soft);
    font-family: var(--ff-head);
    font-weight: 700;
    letter-spacing: 0.02em;
  }

  .mobile-tabs button:last-child {
    border-right: 0;
  }

  .mobile-tabs button.active {
    background: linear-gradient(180deg, rgba(164, 35, 43, 0.32), transparent 60%);
    color: #fff;
  }

  .mobile-tabs button.active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 2px;
    background: var(--red);
  }

  /* "ready to write" / "you can still present" hints on the tabs */
  .mobile-tabs button.tab-ready,
  .mobile-tabs button.tab-hint {
    color: var(--paper-ink);
  }

  .mobile-tabs button.tab-ready:not(.active),
  .mobile-tabs button.tab-hint:not(.active) {
    animation: tab-glow 1.8s ease-in-out infinite;
  }

  .mobile-tabs button.tab-ready::before,
  .mobile-tabs button.tab-hint::before {
    content: "";
    position: absolute;
    top: 8px;
    right: 12px;
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--amber);
    box-shadow: 0 0 8px var(--amber);
  }

  @keyframes tab-glow {
    0%, 100% { background: transparent; }
    50% { background: linear-gradient(180deg, rgba(174, 115, 32, 0.26), transparent 60%); }
  }

  @media (prefers-reduced-motion: reduce) {
    .mobile-tabs button.tab-ready:not(.active),
    .mobile-tabs button.tab-hint:not(.active) { animation: none; }
  }

  #mobileEvidenceBadge:not(:empty) {
    display: inline-grid;
    min-width: 18px;
    height: 18px;
    margin-left: 3px;
    place-items: center;
    border-radius: 999px;
    background: var(--red);
    color: #fff;
    font-family: var(--ff-mono);
    font-size: 11px;
  }

  .scroll-hint.visible {
    display: grid;
  }

  .dossier-overlay {
    padding: 9px;
  }

  .dossier-head {
    padding: 14px 15px 12px;
  }

  .dossier-head h2 {
    font-size: 22px;
  }

  .dossier-body {
    gap: 10px;
    padding: 11px;
    overflow-x: hidden;
  }

  .dossier-body section {
    max-width: 100%;
    overflow-x: hidden;
  }

  .secret,
  details.secret summary {
    grid-template-columns: minmax(74px, auto) minmax(0, 1fr);
  }

  .secret-archive {
    padding-left: 84px;
  }
}

/* ============================================================
   CASE NOTE SHEET  (focused decision surface)
   Centered modal on desktop, bottom sheet on phone. Holds the
   patient's recent reaction, presentable materials, and the
   case-note options — all in one scrollable place so the
   decision no longer crowds the transcript or materials.
   ============================================================ */
.casenote-overlay {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(6, 5, 4, 0.74);
  backdrop-filter: blur(4px);
}

.casenote-overlay[hidden] {
  display: none;
}

.casenote-card {
  width: min(640px, 100%);
  max-height: min(86vh, 780px);
  display: flex;
  flex-direction: column;
  border: 1px solid #000;
  border-top: 3px solid var(--red);
  background:
    linear-gradient(rgba(26, 22, 19, 0.05) 1px, transparent 1px) 0 0 / 100% 29px,
    linear-gradient(180deg, var(--paper-hi), var(--paper-2));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
  animation: casenote-rise 240ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes casenote-rise {
  from { opacity: 0; transform: translateY(16px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .casenote-card { animation: none; }
}

.casenote-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px 14px;
  border-bottom: 2px solid var(--ink);
}

.casenote-head span {
  font-family: var(--ff-mono);
  color: var(--red-dark);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.casenote-head h2 {
  margin: 4px 0 0;
  font-family: var(--ff-display);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink);
}

.casenote-head button {
  flex: 0 0 auto;
  padding: 9px 13px;
  background: rgba(26, 22, 19, 0.08);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  font-family: var(--ff-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  transition: background 130ms ease, color 130ms ease;
}

.casenote-head button:hover {
  background: var(--ink);
  color: var(--paper-hi);
}

.casenote-meters {
  display: flex;
  gap: 9px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(26, 22, 19, 0.05);
}

.cn-meter {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--paper-edge);
  background: rgba(255, 255, 255, 0.3);
  font-family: var(--ff-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.cn-meter em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: normal;
}

.cn-meter b {
  flex: 0 0 auto;
  font-family: var(--ff-display);
  font-weight: 700;
  font-size: 17px;
  color: var(--ink);
}

.casenote-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 14px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.casenote-decision {
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 13px;
  scrollbar-width: thin;
  scrollbar-color: rgba(26, 22, 19, 0.32) transparent;
}

.casenote-decision::-webkit-scrollbar,
.casenote-recap-lines::-webkit-scrollbar { width: 9px; }
.casenote-decision::-webkit-scrollbar-thumb,
.casenote-recap-lines::-webkit-scrollbar-thumb {
  background: rgba(26, 22, 19, 0.3);
  border: 2px solid transparent;
  background-clip: content-box;
}

.casenote-section-label {
  display: block;
  margin-bottom: 9px;
  font-family: var(--ff-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--red-dark);
}

.casenote-recap {
  flex: 1 1 auto;
  min-height: 124px;
  display: flex;
  flex-direction: column;
  padding: 11px 14px;
  border-left: 4px solid var(--blue);
  background: rgba(255, 255, 255, 0.24);
}

.casenote-recap-lines {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(26, 22, 19, 0.32) transparent;
}

.casenote-recap-lines .utterance {
  margin-bottom: 12px;
  font-size: 14.5px;
  line-height: 1.66;
}

.casenote-recap-lines .utterance:last-child {
  margin-bottom: 0;
}

.casenote-materials {
  padding: 12px 14px;
  border-left: 4px solid var(--green);
  background: rgba(58, 81, 66, 0.1);
}

.casenote-hint {
  margin: 0 0 11px;
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.55;
  font-style: italic;
}

.casenote-materials .casenote-hint:last-child {
  margin-bottom: 0;
}

.casenote-material-rows {
  display: grid;
  gap: 8px;
}

.casenote-material-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  background: rgba(255, 255, 255, 0.32);
  border: 1px solid var(--paper-edge);
}

.casenote-material-row span {
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: var(--ff-head);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink);
}

.casenote-material-row button {
  flex: 0 0 auto;
  padding: 9px 12px;
  background: var(--ink);
  color: var(--paper-hi);
  font-family: var(--ff-mono);
  font-size: 11px;
  letter-spacing: 0.03em;
  transition: background 130ms ease;
}

.casenote-material-row button:hover {
  background: var(--red-dark);
}

.casenote-options {
  display: grid;
  gap: 9px;
}

.casenote-options .diagnosis-lock {
  color: var(--ink-soft);
  font-style: italic;
  font-size: 13.5px;
  line-height: 1.6;
}

.casenote-options .diagnosis-hint {
  padding: 10px 12px;
  border-left: 4px solid var(--amber);
  background: rgba(174, 115, 32, 0.12);
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.6;
}

.casenote-options button {
  width: 100%;
  text-align: left;
  padding: 14px 15px;
  background: var(--ink-2);
  color: var(--paper-hi);
  font-family: var(--ff-head);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.42;
  transition: filter 130ms ease, transform 90ms ease;
}

.casenote-options button:hover:not(:disabled) {
  filter: brightness(1.18);
}

.casenote-options button:active:not(:disabled) {
  transform: translateY(1px);
}

.casenote-options button.selected {
  background: var(--green);
}

.casenote-launch {
  width: 100%;
  margin-top: 4px;
  padding: 13px;
  background: var(--red);
  color: #fff;
  font-family: var(--ff-head);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 4px 0 var(--red-deep);
  transition: filter 130ms ease, transform 90ms ease, box-shadow 90ms ease;
}

.casenote-launch:hover {
  filter: brightness(1.12);
}

.casenote-launch:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--red-deep);
}

@media (max-width: 768px) {
  .casenote-overlay {
    padding: 0;
    place-items: end stretch;
  }

  .casenote-card {
    width: 100%;
    max-height: 92dvh;
    border-top-width: 3px;
  }

  .casenote-head {
    padding: 14px 16px 12px;
  }

  .casenote-head h2 {
    font-size: 20px;
  }

  .casenote-body {
    padding: 14px 16px calc(18px + env(safe-area-inset-bottom));
  }

  .casenote-options button {
    min-height: 50px;
    font-size: 15px;
  }
}

/* ============================================================
   COLLAPSIBLE CHROME (phone)
   Header collapses to a gear; intro/ending panels and the
   dossier become single-open accordions; the footer is a slim
   handle that expands when there's something to do. Keeps the
   dialogue and evidence maximized by default.
   ============================================================ */
@media (max-width: 768px) {
  /* --- intro / ending: panels become a single-open accordion --- */
  body[data-panel-accordion="true"] .workbench {
    overflow: auto;
    grid-auto-rows: auto;
  }

  body[data-panel-accordion="true"] .panel {
    display: flex;
    min-height: 0;
  }

  body[data-panel-accordion="true"] .panel-head {
    cursor: pointer;
  }

  body[data-panel-accordion="true"] .panel .panel-chevron {
    display: inline-block;
    flex: 0 0 auto;
    margin-left: auto;
    font-size: 11px;
    color: var(--ink-faint);
    transition: transform 180ms ease;
  }

  body[data-panel-accordion="true"] .panel.panel-open .panel-chevron {
    transform: rotate(180deg);
  }

  body[data-panel-accordion="true"] .panel:not(.panel-open) > :not(.panel-head) {
    display: none !important;
  }

  /* --- dossier accordion --- */
  .dossier-section .panel-chevron {
    display: inline-block;
    flex: 0 0 auto;
    margin-left: 8px;
    font-size: 11px;
    color: var(--ink-faint);
    transition: transform 180ms ease;
  }

  .dossier-section-head {
    cursor: pointer;
  }

  .dossier-section {
    overflow: visible;
  }

  .dossier-section.open .panel-chevron {
    transform: rotate(180deg);
  }

  .dossier-section:not(.open) .dossier-section-body {
    display: none;
  }

  /* --- footer handle sizing --- */
  .footer-handle {
    padding: 8px 13px;
  }

  body[data-footer-open="true"] .footer-handle {
    padding: 6px 13px 0;
  }

  .footer-body {
    flex-direction: column;
    align-items: stretch;
    gap: 9px;
    padding: 4px 12px 11px;
  }

  .footer-body .primary {
    width: 100%;
  }
}

/* ============================================================
   METRIC IMPACT TOAST
   Flashes the Truth / Safety / Identity deltas when presenting
   a document or writing a case note — the banner meters are
   hidden behind the case-note overlay, so the impact would
   otherwise be invisible.
   ============================================================ */
.metric-toast {
  position: fixed;
  top: 92px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  z-index: 20;
  display: flex;
  gap: 8px;
  padding: 9px 12px;
  background: linear-gradient(180deg, #211c15, #14110b);
  border: 1px solid #000;
  border-top: 3px solid var(--red);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease, transform 300ms ease;
}

.metric-toast[hidden] {
  display: none;
}

.metric-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.metric-toast-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 62px;
}

.metric-toast-chip em {
  font-style: normal;
  font-family: var(--ff-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--paper-ink-soft);
}

.metric-toast-chip b {
  font-family: var(--ff-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.02em;
}

.metric-toast-up b { color: #8fbf86; }
.metric-toast-down b { color: #d2706a; }
.metric-toast-flat b { color: var(--paper-ink-soft); }

@media (max-width: 768px) {
  .metric-toast {
    top: 12px;
    padding: 8px 10px;
  }

  .metric-toast-chip {
    min-width: 52px;
  }
}

/* ============================================================
   FULL RECORD OVERLAY  (cross-chapter transcript, log mode)
   ============================================================ */
.record-overlay {
  position: fixed;
  inset: 0;
  z-index: 8;
  padding: 32px;
  background: rgba(6, 5, 4, 0.72);
  backdrop-filter: blur(4px);
}

.record-overlay[hidden] {
  display: none;
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(6, 5, 4, 0.72);
  backdrop-filter: blur(4px);
}

.confirm-overlay[hidden] {
  display: none;
}

.confirm-card {
  width: min(460px, 100%);
  padding: 22px;
  border: 1px solid #000;
  border-top: 3px solid var(--red);
  background:
    linear-gradient(rgba(26, 22, 19, 0.05) 1px, transparent 1px) 0 0 / 100% 29px,
    linear-gradient(180deg, var(--paper-hi), var(--paper-2));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.72);
}

.confirm-card span {
  font-family: var(--ff-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--red-dark);
}

.confirm-card h2 {
  margin: 5px 0 12px;
  font-family: var(--ff-display);
  font-size: 28px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.confirm-card p {
  color: var(--ink-soft);
  line-height: 1.65;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.confirm-actions button {
  min-width: 88px;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--paper-hi);
  font-family: var(--ff-head);
  font-weight: 700;
}

.confirm-actions button:last-child {
  background: var(--red);
}

.record-card {
  height: 100%;
  max-width: 760px;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr;
  border: 1px solid #000;
  border-top: 3px solid var(--red);
  background:
    linear-gradient(rgba(26, 22, 19, 0.05) 1px, transparent 1px) 0 0 / 100% 29px,
    linear-gradient(180deg, var(--paper-hi), var(--paper-2));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
}

.record-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px 14px;
  border-bottom: 2px solid var(--ink);
}

.record-head span {
  font-family: var(--ff-mono);
  color: var(--red-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.record-head h2 {
  margin: 4px 0 0;
  font-family: var(--ff-display);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.record-head button {
  flex: 0 0 auto;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--paper-hi);
  font-family: var(--ff-head);
  font-weight: 700;
  font-size: 13px;
  transition: filter 130ms ease;
}

.record-head button:hover {
  filter: brightness(1.2);
}

.record-body {
  min-height: 0;
  overflow-y: auto;
  padding: 18px 22px 28px;
  scrollbar-width: thin;
  scrollbar-color: rgba(26, 22, 19, 0.32) transparent;
}

.record-body::-webkit-scrollbar { width: 9px; }
.record-body::-webkit-scrollbar-thumb {
  background: rgba(26, 22, 19, 0.3);
  border: 2px solid transparent;
  background-clip: content-box;
}

.record-chapter {
  margin-bottom: 24px;
}

.record-divider {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 4px 0 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--ink);
}

.record-divider span {
  font-family: var(--ff-mono);
  color: var(--red-dark);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.record-divider strong {
  font-family: var(--ff-head);
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
}

.record-empty {
  color: var(--ink-soft);
  font-style: italic;
}

@media (max-width: 768px) {
  .record-overlay {
    padding: 9px;
  }

  .record-head {
    padding: 14px 15px 12px;
  }

  .record-head h2 {
    font-size: 22px;
  }

  .record-body {
    padding: 14px 15px calc(20px + env(safe-area-inset-bottom));
  }
}
