/* Two rooms: a quiet porcelain page for reading and answering, and a dark reading room for the images.
   The flair lives around the images (the timeline, the tracking thread, the closing ring), never on them. */

@font-face { font-family: "Lora"; src: url("/static/fonts/Lora-Variable.ttf") format("truetype"); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Lora"; src: url("/static/fonts/Lora-Italic-Variable.ttf") format("truetype"); font-weight: 400 700; font-style: italic; font-display: swap; }

:root {
  --paper: #F2F4F6;
  --paper-2: #E6EAEE;
  --ink: #1B2430;
  --ink-2: #566273;
  --rule: #D3D9E0;
  --film: #2D5F86;          /* film-base blue: actions and links */
  --film-ink: #F4F7FA;
  --lamp: #E9A23B;          /* lamp amber: lit progress, the marked finding */
  --danger: #A33A2E;

  --room: #000000;          /* image surround, as in a reading room */
  --panel: #15181C;
  --panel-2: #1D2126;
  --panel-3: #262B31;
  --room-text: #E7EAED;
  --room-muted: #98A2AD;
  --room-line: #2C3238;
  --ref: #5FC6E3;           /* Task A reference box; AI marker in the feedback survey */
  --mine: #C3A4FF;          /* the reviewer's own Task B mark */
  --thread: #F2D27C;        /* the tracking thread, a wax-pencil yellow */

  --serif: "Lora", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 6px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  transition: background-color .6s var(--ease), color .6s var(--ease);
  -webkit-font-smoothing: antialiased;
}
body.room { background: var(--room); color: var(--room-text); }
a { color: var(--film); }
body.room a { color: var(--ref); }
:focus-visible { outline: 3px solid var(--film); outline-offset: 2px; }
body.room :focus-visible { outline-color: var(--thread); }
.noscript { padding: 2rem; }

/* ------------------------------------------------------------------ page (light) */
.page { max-width: 760px; margin: 0 auto; padding: 48px 24px 72px; }
.masthead { margin-bottom: 36px; }
.masthead .study { font-size: 14px; color: var(--ink-2); margin: 0 0 6px; }
.masthead h1 { font-family: var(--serif); font-weight: 600; font-size: 34px; line-height: 1.2; margin: 0; letter-spacing: -.005em; }
.years { display: flex; gap: 10px; align-items: end; height: 18px; margin-top: 22px; }
.years i { display: block; width: 2px; height: 8px; background: var(--rule); border-radius: 1px; }
.years i:nth-child(4n+1) { height: 16px; background: #B9C2CC; }
.years i.lit { background: var(--lamp); }

h2 { font-family: var(--serif); font-weight: 600; font-size: 26px; line-height: 1.25; margin: 0 0 14px; }
h3 { font-family: var(--serif); font-weight: 600; font-size: 19px; margin: 28px 0 8px; }
p { margin: 0 0 14px; }
.lede { font-size: 17px; color: var(--ink-2); }
.muted { color: var(--ink-2); }
.demo-flag { display: inline-block; font-size: 13px; padding: 3px 10px; border-radius: 999px; background: #FCEFD8; color: #6A4A12; margin-bottom: 18px; }
body.room .demo-flag { background: #3A2E17; color: #F4D9A6; margin: 0; }

.reading { font-family: var(--serif); font-size: 17.5px; line-height: 1.7; }
.reading p { margin-bottom: 16px; }
.consent-title { font-size: 20px; margin-top: 4px; }
.consent-meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-family: var(--sans); font-size: 15px; padding: 16px 18px; background: var(--paper-2); border-radius: var(--radius); margin: 0 0 22px; }
.consent-meta dt { color: var(--ink-2); }
.consent-meta dd { margin: 0; }
.consent-qr { display: block; margin: 4px 0 18px; image-rendering: pixelated; border: 6px solid #fff; border-radius: 4px; }

/* questions */
.q { margin: 0 0 26px; border: 0; padding: 0; min-width: 0; }
.q legend, .q .q-text { font-weight: 600; font-size: 16.5px; margin-bottom: 10px; padding: 0; }
.q .q-note { font-size: 14.5px; color: var(--ink-2); margin: -4px 0 10px; }
body.room .q .q-note { color: var(--room-muted); }
.opts { display: grid; gap: 6px; }
.opt { position: relative; display: flex; gap: 12px; align-items: flex-start; padding: 10px 14px; border: 1px solid var(--rule); border-radius: var(--radius); background: #fff; cursor: pointer; transition: border-color .15s, background-color .15s; }
.opt:hover { border-color: #AAB5C1; }
.opt input { appearance: none; -webkit-appearance: none; flex: 0 0 auto; width: 18px; height: 18px; margin: 2px 0 0; border: 2px solid #8C98A6; border-radius: 50%; background: transparent; cursor: pointer; display: grid; place-content: center; }
.opt input::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--film); transform: scale(0); transition: transform .12s var(--ease); }
.opt input:checked { border-color: var(--film); }
.opt input:checked::before { transform: scale(1); }
.opt:has(input:checked) { border-color: var(--film); background: #EAF1F7; }
.opt input:focus-visible { outline: 3px solid var(--film); outline-offset: 2px; }
.clear-answer { background: none; border: 0; padding: 4px 0; font: inherit; font-size: 14px; color: var(--ink-2); text-decoration: underline; cursor: pointer; margin-top: 4px; }
textarea { width: 100%; min-height: 96px; font: inherit; font-size: 15.5px; padding: 10px 12px; border: 1px solid var(--rule); border-radius: var(--radius); background: #fff; color: var(--ink); resize: vertical; }
textarea:focus { border-color: var(--film); outline: none; box-shadow: 0 0 0 3px rgba(45, 95, 134, .2); }

/* buttons */
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 30px; }
.btn { font: inherit; font-size: 16px; font-weight: 600; padding: 11px 20px; border-radius: var(--radius); border: 1px solid transparent; cursor: pointer; transition: background-color .15s, border-color .15s, opacity .15s; }
.btn-primary { background: var(--film); color: var(--film-ink); }
.btn-primary:hover { background: #244E6F; }
.btn-quiet { background: transparent; color: var(--ink); border-color: #AEB8C3; }
.btn-quiet:hover { background: var(--paper-2); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.hint { font-size: 14px; color: var(--ink-2); }
.error { color: var(--danger); font-size: 15px; }

/* sign-in */
.code-field { display: flex; gap: 12px; flex-wrap: wrap; align-items: stretch; margin-top: 8px; }
.code-field input { font: inherit; font-size: 22px; letter-spacing: .12em; font-variant-numeric: tabular-nums; text-transform: uppercase; padding: 10px 14px; width: min(100%, 300px); border: 1px solid #AEB8C3; border-radius: var(--radius); background: #fff; color: var(--ink); }
.code-field input:focus { border-color: var(--film); outline: none; box-shadow: 0 0 0 3px rgba(45, 95, 134, .2); }
.foot { margin-top: 56px; padding-top: 18px; border-top: 1px solid var(--rule); font-size: 14px; color: var(--ink-2); }

ul.plain { padding-left: 1.1em; margin: 0 0 14px; }
ul.plain li { margin-bottom: 8px; }
.task-block { margin: 22px 0; padding: 18px 20px; border-left: 3px solid var(--lamp); background: #fff; border-radius: 0 var(--radius) var(--radius) 0; }
.task-block h3 { margin-top: 0; }

/* ------------------------------------------------------------------ reading room */
.room-shell { display: grid; grid-template-rows: auto 1fr; height: 100vh; height: 100dvh; height: var(--app-h, 100dvh); }
.topbar { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(240px, 3fr) minmax(200px, 1fr); align-items: center; gap: 18px; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--room-line); }
.topbar .where { font-size: 13px; color: var(--room-muted); line-height: 1.35; }
.topbar .where strong { display: block; color: var(--room-text); font-weight: 600; font-size: 14px; }
.topbar .counter { text-align: right; font-size: 13px; color: var(--room-muted); line-height: 1.35; }
.topbar .counter strong { display: block; font-family: var(--serif); font-weight: 600; font-size: 18px; color: var(--room-text); }

.workspace { display: grid; grid-template-columns: 1fr 384px; min-height: 0; }
.stage-wrap { display: grid; grid-template-rows: 1fr auto; min-width: 0; min-height: 0; background: var(--room); }
.stage { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px; min-height: 0; }
.pane { position: relative; display: grid; grid-template-rows: auto 1fr; min-width: 0; min-height: 0; }
.pane-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 2px 4px 8px; font-size: 13.5px; color: var(--room-muted); }
.pane-head strong { color: var(--room-text); font-weight: 600; font-size: 14.5px; }
.pane-head .legend { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 14px; height: 10px; border: 2px solid var(--lamp); border-radius: 2px; }
.swatch.ref { border-color: var(--ref); border-style: dashed; }
.swatch.mine { border-color: var(--mine); }
.swatch.ai { border-color: var(--ref); border-width: 3px; }
.canvas-box { position: relative; min-height: 0; overflow: hidden; background: #000; border-radius: 3px; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.canvas-box.dragging { cursor: grabbing; }
.canvas-box.marking { cursor: crosshair; }
.canvas-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.canvas-box .loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--room-muted); font-size: 14px; }
.zoom-chip:empty { display: none; }
.zoom-chip { position: absolute; right: 8px; bottom: 8px; font-size: 12px; color: var(--room-muted); background: rgba(21, 24, 28, .8); padding: 2px 8px; border-radius: 999px; pointer-events: none; font-variant-numeric: tabular-nums; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px 10px; border-top: 1px solid var(--room-line); background: var(--panel); }
.tool { font: inherit; font-size: 13.5px; color: var(--room-text); background: var(--panel-2); border: 1px solid var(--room-line); border-radius: var(--radius); padding: 6px 11px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
.tool:hover { background: var(--panel-3); }
.tool[aria-pressed="true"] { border-color: var(--thread); color: var(--thread); }
.tool kbd, .keys kbd { font-family: var(--sans); font-size: 11.5px; color: var(--room-muted); border: 1px solid var(--room-line); border-radius: 4px; padding: 0 5px; }
.tool select { font: inherit; color: inherit; background: transparent; border: 0; padding: 0; cursor: pointer; }
.tool select option { background: var(--panel); }
.toolbar .spacer { flex: 1; }

.side { display: grid; grid-template-rows: 1fr auto; min-height: 0; background: var(--panel); border-left: 1px solid var(--room-line); }
.side-scroll { overflow-y: auto; padding: 18px 20px 8px; }
.side h2 { font-size: 20px; color: var(--room-text); margin-bottom: 4px; }
.side .code { font-size: 13.5px; color: var(--room-muted); margin-bottom: 14px; font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; font-size: 14px; margin: 0 0 18px; }
.facts dt { color: var(--room-muted); }
.facts dd { margin: 0; }
.practice-note { font-size: 13.5px; color: #F4D9A6; background: #33291A; border-radius: var(--radius); padding: 8px 12px; margin-bottom: 16px; }
body.room .opt { background: var(--panel-2); border-color: var(--room-line); }
body.room .opt:hover { border-color: #4A525C; }
body.room .opt input { border-color: #77828E; }
body.room .opt input::before { background: var(--thread); }
body.room .opt input:checked { border-color: var(--thread); }
body.room .opt:has(input:checked) { border-color: var(--thread); background: #2A2717; }
body.room .q legend, body.room .q .q-text { font-size: 15.5px; }
body.room .opt { padding: 8px 12px; font-size: 15px; }
body.room textarea { background: var(--panel-2); border-color: var(--room-line); color: var(--room-text); min-height: 80px; }
body.room textarea:focus { border-color: var(--thread); box-shadow: 0 0 0 3px rgba(242, 210, 124, .18); }
body.room .clear-answer { color: var(--room-muted); }

.ai-card { margin: 0 0 20px; padding: 14px 16px; background: var(--panel-2); border: 1px solid var(--room-line); border-left: 3px solid var(--ref); border-radius: 0 var(--radius) var(--radius) 0; }
.ai-card .label { font-size: 13px; color: var(--room-muted); }
.ai-card .answer { font-family: var(--serif); font-size: 26px; font-weight: 600; line-height: 1.2; margin: 2px 0 4px; }
.ai-card .help { font-size: 13.5px; color: var(--room-muted); margin: 0; }
.ai-card .flag { display: inline-block; margin-top: 10px; font-size: 13px; padding: 2px 10px; border-radius: 999px; border: 1px solid #C98B3A; color: #F1C27D; }
.ai-card blockquote { margin: 12px 0 0; padding: 0 0 0 12px; border-left: 2px solid var(--room-line); font-family: var(--serif); font-style: italic; font-size: 15.5px; color: var(--room-text); }
.caution { font-size: 13px; color: var(--room-muted); margin: 0 0 18px; }

.side-foot { padding: 12px 20px 14px; border-top: 1px solid var(--room-line); background: var(--panel); }
.side-foot .row { display: flex; gap: 8px; flex-wrap: wrap; }
.side-foot .btn { font-size: 15px; padding: 9px 14px; }
body.room .btn-primary { background: var(--thread); color: #1B1A12; }
body.room .btn-primary:hover { background: #F7DF9C; }
body.room .btn-quiet { color: var(--room-text); border-color: #4A525C; }
body.room .btn-quiet:hover { background: var(--panel-2); }
.status { font-size: 12.5px; color: var(--room-muted); margin-top: 8px; min-height: 1.2em; }
.status.bad { color: #F0A49A; }
.why { font-size: 13px; color: var(--room-muted); margin: 8px 0 0; }

/* ------------------------------------------------------------------ timeline */
.timeline { position: relative; display: flex; align-items: center; gap: 12px; min-width: 0; }
.tl-seg { position: relative; display: flex; align-items: center; min-width: 0; flex: 0 1 auto; }
.tl-seg.main { flex: 1 1 auto; }
.tl-seg::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--room-line); }
.tl-seg .tl-label { position: absolute; left: 0; top: calc(50% + 9px); font-size: 11px; color: var(--room-muted); white-space: nowrap; }
.tl-ticks { position: relative; display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 2px; }
.tl-seg.first .tl-ticks { width: auto; }
.tl-seg.first .tick { flex: 0 0 16px; }
.tick { position: relative; flex: 0 1 18px; min-width: 7px; height: 24px; padding: 0; border: 0; background: none; cursor: pointer; }
.tick::after { content: ""; position: absolute; left: 50%; top: 50%; width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%; background: #3A414A; transition: background-color .3s, transform .3s var(--ease), box-shadow .3s; }
.tick[data-state="done"]::after { background: var(--lamp); }
.tick[data-state="skipped"]::after { background: transparent; box-shadow: inset 0 0 0 1.5px #6B7580; }
.tick[data-current="true"]::after { transform: scale(1.6); box-shadow: 0 0 0 2px var(--room); outline: 1.5px solid var(--room-text); outline-offset: 1.5px; }
.tick.lit-now::after { animation: lit 900ms var(--ease) 1; }
@keyframes lit { 0% { box-shadow: 0 0 0 0 rgba(233, 162, 59, .9); } 100% { box-shadow: 0 0 0 10px rgba(233, 162, 59, 0); } }
.tick:hover::after { transform: scale(1.4); }

/* ------------------------------------------------------------------ tracking thread (feedback survey) */
.thread-layer { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 3; }
.thread-layer path.thread { fill: none; stroke: var(--thread); stroke-width: 3; stroke-linecap: round; opacity: .95; }
.thread-layer circle.anchor { fill: var(--thread); }
.thread-layer circle.arrive { fill: none; stroke: var(--thread); stroke-width: 2; }

/* ------------------------------------------------------------------ loupe */
.loupe { position: fixed; width: 240px; height: 240px; border-radius: 50%; overflow: hidden; pointer-events: none; z-index: 50; box-shadow: 0 0 0 2px var(--thread), 0 10px 30px rgba(0, 0, 0, .6); display: none; background: #000; }
.loupe canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ------------------------------------------------------------------ dialog */
.scrim { position: fixed; inset: 0; background: rgba(10, 14, 20, .55); display: grid; place-items: center; z-index: 100; padding: 16px; }
.dialog { max-width: 460px; width: 100%; background: var(--paper); color: var(--ink); border-radius: 10px; padding: 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.dialog h2 { font-size: 22px; }
.keys { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 14.5px; }
.keys kbd { color: var(--ink-2); border-color: var(--rule); font-size: 13px; }

/* ------------------------------------------------------------------ closing ring */
.closing { display: grid; justify-items: start; }
.ring-wrap { width: 220px; height: 220px; margin: 8px 0 26px; }
.ring-wrap svg { width: 100%; height: 100%; overflow: visible; }
.ring-wrap .bead { transition: transform 1.1s var(--ease), opacity .6s; }
.ring-wrap .check { fill: none; stroke: var(--film); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 90; stroke-dashoffset: 90; transition: stroke-dashoffset .7s var(--ease) 1.4s; }
.ring-wrap.closed .check { stroke-dashoffset: 0; }
.fade-late { opacity: 0; transform: translateY(6px); transition: opacity .6s var(--ease) 1.7s, transform .6s var(--ease) 1.7s; }
.closed-page .fade-late { opacity: 1; transform: none; }

/* ------------------------------------------------------------------ compare (expert feedback) */
[hidden] { display: none !important; }
.stage.single { grid-template-columns: 1fr; }
.legends { display: inline-flex; gap: 16px; }
.canvas-box.on-divider { cursor: ew-resize; }
.cmp-controls { display: inline-flex; align-items: center; gap: 10px; padding: 2px 4px 2px 6px; border-left: 1px solid var(--room-line); }
.seg-group { display: inline-flex; border: 1px solid var(--room-line); border-radius: var(--radius); overflow: hidden; }
.seg { font: inherit; font-size: 13px; color: var(--room-muted); background: var(--panel-2); border: 0; padding: 6px 10px; cursor: pointer; }
.seg + .seg { border-left: 1px solid var(--room-line); }
.seg[aria-pressed="true"] { color: #1B1A12; background: var(--thread); }
.blend { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--room-muted); }
.blend input[type="range"] { -webkit-appearance: none; appearance: none; width: 220px; height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--lamp), var(--ref)); outline-offset: 6px; }
.blend input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--thread); border: 2px solid #1B1A12; cursor: ew-resize; }
.blend input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--thread); border: 2px solid #1B1A12; cursor: ew-resize; }
.tool { position: relative; }
.tool[disabled] { opacity: .4; cursor: not-allowed; }
.hint-chip { position: absolute; left: 50%; bottom: calc(100% + 10px); transform: translateX(-50%); white-space: nowrap; font-size: 12.5px; color: #1B1A12; background: var(--thread); padding: 4px 10px; border-radius: 999px; pointer-events: none; }
.hint-chip::after { content: ""; position: absolute; left: 50%; top: 100%; margin-left: -5px; border: 5px solid transparent; border-top-color: var(--thread); }
.tool.hinting { border-color: var(--thread); animation: nudge 1.6s var(--ease) 2; }
@keyframes nudge { 0%, 100% { box-shadow: 0 0 0 0 rgba(242, 210, 124, 0); } 50% { box-shadow: 0 0 0 5px rgba(242, 210, 124, .25); } }

.only-narrow { display: none; }
.ai-more { margin: 8px 0 0; font-size: 13.5px; color: var(--room-muted); }
.ai-more summary { cursor: pointer; }
.ai-more p { margin: 4px 0 0; }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr 330px; }
  .topbar { grid-template-columns: 1fr 2fr 1fr; }
}

/* ------------------------------------------------------------------ phones and tablets held upright
   The page does not scroll here: the images keep the top of the screen and the questions scroll in their own
   panel below, so a finger on an image always moves the image and a finger on the questions always scrolls. */
@media (max-width: 860px) {
  .page { padding: 28px 16px 48px; }
  .masthead { margin-bottom: 26px; }
  .masthead .study { font-size: 13px; }
  .masthead h1 { font-size: 25px; }
  h2 { font-size: 22px; }
  .reading { font-size: 16.5px; line-height: 1.65; }
  .consent-meta { grid-template-columns: 1fr; gap: 0; padding: 12px 14px; }
  .consent-meta dd { margin-bottom: 8px; }
  .actions .btn { flex: 1 1 auto; }

  html:has(body.room), body.room { height: 100%; overflow: hidden; overscroll-behavior: none; }
  .room-shell { height: 100vh; height: 100dvh; height: var(--app-h, 100dvh); grid-template-rows: auto minmax(0, 1fr); }
  .topbar { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "counter where" "tl tl"; gap: 2px 12px; padding: 8px 12px 16px; }
  .topbar .counter { grid-area: counter; text-align: left; font-size: 12px; }
  .topbar .counter strong { font-size: 16px; }
  .topbar .where { grid-area: where; align-self: start; text-align: right; font-size: 12px; }
  .topbar .where strong { display: none; }
  .topbar .timeline { grid-area: tl; }
  .tick { min-width: 4px; height: 18px; }
  .tick::after { width: 5px; height: 5px; margin: -2.5px 0 0 -2.5px; }
  .tl-seg.first .tick { flex-basis: 12px; }

  .workspace { grid-template-columns: 1fr; grid-template-rows: minmax(0, 3fr) minmax(0, 2fr); min-height: 0; }
  .room-shell.big .workspace { grid-template-rows: minmax(0, 4fr) minmax(0, 1fr); }
  .stage { grid-template-columns: 1fr 1fr; gap: 6px; padding: 6px; }
  .stage.single { grid-template-columns: 1fr; }
  .canvas-box { height: auto; }
  .pane-head { flex-wrap: wrap; gap: 0 8px; padding: 0 2px 4px; font-size: 12px; line-height: 1.35; }
  .pane-head strong { font-size: 12.5px; }
  .legends { flex-wrap: wrap; gap: 0 10px; }
  .swatch { width: 11px; height: 8px; }
  .swatch.ai { width: 10px; height: 10px; }

  .toolbar { flex-wrap: nowrap; overflow-x: auto; gap: 6px; padding: 6px 8px; scrollbar-width: none; }
  .toolbar::-webkit-scrollbar { display: none; }
  .tool { flex: 0 0 auto; white-space: nowrap; padding: 6px 9px; font-size: 13px; }
  .toolbar .spacer { display: none; }
  .cmp-controls { flex: 0 0 auto; }
  .blend input[type="range"] { width: 120px; }
  .hint-chip { display: none; }
  .only-narrow { display: inline-flex; }

  .side { border-left: 0; border-top: 1px solid var(--room-line); min-height: 0; }
  .side-scroll { padding: 12px 14px 6px; overscroll-behavior: contain; }
  .side h2 { font-size: 18px; }
  .ai-card { padding: 10px 12px; margin-bottom: 14px; }
  .ai-card .answer { font-size: 22px; }
  .side-foot { padding: 8px 14px 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .side-foot .btn { padding: 8px 12px; font-size: 14.5px; }
  .status, .why { margin-top: 4px; }
}
@media (max-width: 560px) {
  .workspace { grid-template-rows: minmax(0, 3fr) minmax(0, 2fr); }
  .room-shell.big .workspace { grid-template-rows: minmax(0, 5fr) minmax(0, 1fr); }
  .stage { gap: 4px; padding: 4px; }
  .topbar { padding: 6px 10px; }
  .topbar .counter { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .counter strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; }
  .topbar .where .demo-flag { font-size: 11px; padding: 2px 8px; }
  .tl-seg .tl-label { display: none; }
  /* image headers sit on the image itself, so the images get the height */
  .pane { grid-template-rows: minmax(0, 1fr); }
  .pane-head { position: absolute; top: 0; left: 0; right: 0; z-index: 2; padding: 3px 6px 12px; font-size: 11px; pointer-events: none;
    background: linear-gradient(rgba(0, 0, 0, .82), rgba(0, 0, 0, .55) 70%, rgba(0, 0, 0, 0)); border-radius: 3px 3px 0 0; }
  .pane-head strong { font-size: 11.5px; }
  .side-scroll { padding: 10px 12px 4px; }
  .side-foot { padding: 6px 12px 8px; }
  .side-foot { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 8px; }
  .side-foot .why { grid-column: 1 / -1; font-size: 12px; }
  .side-foot .status { grid-column: 2; grid-row: 1; margin: 0; font-size: 11.5px; text-align: right; }
  .masthead h1 { font-size: 23px; }
  .code-field input { width: 100%; font-size: 20px; letter-spacing: .06em; }
  .code-field .btn { width: 100%; }
}
/* phones turned sideways: images on the left, questions on the right */
@media (max-width: 1100px) and (max-height: 560px) and (orientation: landscape) {
  .topbar { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "counter tl where"; padding: 6px 12px; }
  .topbar .timeline { min-width: 160px; }
  .tl-seg .tl-label { display: none; }
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(260px, 38%); grid-template-rows: minmax(0, 1fr); }
  .room-shell.big .workspace { grid-template-rows: minmax(0, 1fr); }
  .side { border-top: 0; border-left: 1px solid var(--room-line); }
  .only-narrow { display: none; }
}
/* touch screens: no keyboard hints, and text fields at 16 px so the phone does not zoom in when typing */
@media (hover: none) and (pointer: coarse) {
  .tool kbd { display: none; }
  .tool-keys { display: none !important; }
  textarea, body.room textarea { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; transition-delay: 0s !important; animation: none !important; }
}

/* ---------------- feedback: what the AI did (input, question, answer), set apart from the reviewer's questions */
.ai-flow { margin: 0 0 14px; padding: 14px 16px 6px; background: var(--panel-2); border: 1px solid var(--room-line); border-top: 3px solid var(--ref); border-radius: var(--radius); }
.ai-flow-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.ai-flow-head strong { font-size: 16px; color: var(--room-text); }
.ai-badge { display: inline-grid; place-items: center; min-width: 30px; height: 22px; padding: 0 6px; border-radius: 4px; background: var(--ref); color: #06202A; font: 700 12px/1 var(--sans); letter-spacing: .04em; }
.ai-replay { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; font: 600 13px var(--sans); color: var(--ref); background: transparent; border: 1px solid #2F5D6B; border-radius: 999px; padding: 4px 12px 4px 10px; cursor: pointer; }
.ai-replay:hover { background: #12313A; }
.ai-replay .tri { width: 0; height: 0; border-left: 8px solid var(--ref); border-top: 5px solid transparent; border-bottom: 5px solid transparent; }
.flag-top { margin: 0 0 10px; padding: 8px 10px; font-size: 13.5px; color: #F7D9A8; background: #3A2A12; border: 1px solid #8A6326; border-radius: var(--radius); }
.ai-steps { list-style: none; margin: 0; padding: 0; }
.ai-step { position: relative; display: grid; grid-template-columns: 26px 1fr; gap: 10px; padding: 0 0 14px; transition: opacity .25s var(--ease); }
.ai-step:not(:last-child)::before { content: ""; position: absolute; left: 12px; top: 26px; bottom: 2px; width: 2px; background: var(--room-line); }
.ai-step-n { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; border: 2px solid #3A6F7E; color: var(--ref); font: 700 12.5px var(--sans); background: var(--panel); transition: background .25s, color .25s; }
.ai-step-title { font: 600 13.5px var(--sans); color: var(--room-text); margin: 4px 0 6px; }
.ai-step .help { font-size: 13px; color: var(--room-muted); margin: 0 0 4px; }
.ai-step .help.small { font-size: 12px; margin-top: 6px; }
.ai-step .answer { font-family: var(--serif); font-size: 24px; font-weight: 600; line-height: 1.15; color: var(--room-text); margin: 0 0 2px; }
.ai-step .flag { display: inline-block; margin-top: 6px; font-size: 12.5px; padding: 2px 10px; border-radius: 999px; border: 1px solid #C98B3A; color: #F1C27D; }
.ai-crops { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ai-crop { margin: 0; padding: 0; cursor: pointer; border-radius: 4px; outline-offset: 2px; }
.ai-crop canvas { display: block; width: 100%; aspect-ratio: 1; border-radius: 4px; border: 1px solid var(--room-line); background: #000; }
.ai-crop:hover canvas, .ai-crop:focus-visible canvas { border-color: var(--ref); }
.ai-crop figcaption { font-size: 11.5px; line-height: 1.3; color: var(--room-muted); margin-top: 4px; }
.ai-prompt { margin: 0; padding: 9px 11px; font: 13px/1.45 var(--sans); color: #CFE9F1; background: #0E1F25; border: 1px solid #23434D; border-radius: 4px; }
.ai-prompt::before { content: "Prompt"; display: block; font: 700 10.5px var(--sans); letter-spacing: .06em; color: var(--ref); margin-bottom: 4px; text-transform: none; }
.ai-flow.playing .ai-step { opacity: .38; }
.ai-flow.playing .ai-step.lit { opacity: 1; }
.ai-flow.playing .ai-step.lit .ai-step-n { background: var(--ref); color: #06202A; border-color: var(--ref); }
.ai-flow.playing .ai-step.lit .ai-crop canvas { border-color: var(--ref); box-shadow: 0 0 0 2px rgba(95, 198, 227, .35); }
.you-divider { display: flex; align-items: center; gap: 10px; margin: 6px 0 4px; color: var(--room-muted); font: 600 12px var(--sans); }
.you-divider::before, .you-divider::after { content: ""; flex: 1; height: 1px; background: var(--room-line); }
.side h2.you-h { margin-top: 4px; }
@media (prefers-reduced-motion: reduce) { .ai-step, .ai-step-n { transition: none; } }
.ai-summary { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 10px; margin: 0 0 10px; padding: 8px 10px; background: var(--panel); border: 1px solid var(--room-line); border-radius: var(--radius); }
.ai-sum-label { font-size: 12.5px; color: var(--room-muted); }
.ai-sum-answer { font: 600 20px/1 var(--serif); color: var(--room-text); }
.ai-summary .flag { font-size: 12.5px; padding: 2px 10px; border-radius: 999px; border: 1px solid #C98B3A; color: #F1C27D; }
/* folded by default: the question and the answer; the steps open on request */
.ai-qa { display: grid; gap: 6px; margin: 0 0 8px; padding: 9px 11px; background: var(--panel); border: 1px solid var(--room-line); border-radius: var(--radius); }
.ai-q, .ai-a { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 13.5px; color: var(--room-text); }
.qa-k { flex: none; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 4px; background: #12313A; color: var(--ref); font: 700 11.5px var(--sans); }
.ai-a .ai-sum-label { font-size: 12px; color: var(--room-muted); }
.ai-a .flag { font-size: 12px; padding: 1px 9px; border-radius: 999px; border: 1px solid #C98B3A; color: #F1C27D; }
.ai-qa .flag-top { margin: 2px 0 0; }
.ai-toggle { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 8px; padding: 2px 0; font: 600 13px var(--sans); color: var(--ref); background: none; border: 0; cursor: pointer; }
.ai-toggle .chev { width: 7px; height: 7px; border-right: 2px solid var(--ref); border-bottom: 2px solid var(--ref); transform: rotate(-45deg); transition: transform .2s var(--ease); }
.ai-toggle[aria-expanded="true"] .chev { transform: rotate(45deg); }
.ai-flow:not(.open) { padding-bottom: 4px; }
.ai-steps[hidden] { display: none; }
/* one play control under the answer; "Hide the steps" appears once the steps are open */
.ai-ctrl { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 0 0 8px; }
.ai-ctrl .ai-replay { margin-left: 0; padding: 6px 14px 6px 11px; }
.ai-ctrl .ai-toggle { margin: 0; }
.ai-ctrl .ai-toggle[hidden] { display: none; }
.ai-ctrl .ai-toggle .chev { transform: rotate(-135deg); }
.ai-qa .ai-q { flex-wrap: nowrap; align-items: flex-start; }
.ai-qa .ai-q > span:last-child { flex: 1; min-width: 0; }
/* try-it area: sample cases to play with; nothing is recorded */
.try-note { border-left-color: var(--ref); }
.try-panel { margin: 0 0 14px; padding: 12px 14px 10px; background: var(--panel-2); border: 1px solid var(--room-line); border-radius: var(--radius); }
.try-panel h3 { margin: 0 0 4px; font-size: 15px; color: var(--room-text); }
.try-panel .help { margin: 4px 0 8px; }
.try-credit { margin: 10px 0 0; font-size: 12px; line-height: 1.4; color: var(--room-muted); }
.try-sub { margin: 8px 0 6px; font: 600 12.5px var(--sans); color: var(--room-muted); }
.cand-row { display: flex; flex-wrap: wrap; gap: 6px; }
.cand-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px 4px 5px; border: 1px solid var(--room-line); border-radius: 999px; background: var(--panel); color: var(--room-text); font: 500 13px var(--sans); cursor: pointer; }
.cand-chip:hover { border-color: #2F5D6B; }
.cand-chip.on { border-color: var(--ref); box-shadow: 0 0 0 1px var(--ref) inset; }
.cand-n { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #1D2328; border: 1.5px solid #E7EDF2; font-weight: 700; font-size: 11.5px; }
.cand-a.yes { color: var(--ref); font-weight: 600; }
.cand-a.no { color: var(--room-muted); font-weight: 600; }
.cand-pick { font-size: 11px; padding: 1px 6px; border-radius: 999px; background: #12313A; color: var(--ref); }
.try-switches { display: grid; gap: 6px; margin: 10px 0 2px; }
.try-switch { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--room-text); cursor: pointer; }
.try-switch input { width: 16px; height: 16px; accent-color: var(--ref); }
.try-dist dl { display: grid; grid-template-columns: auto auto; justify-content: start; gap: 3px 16px; margin: 0; font-size: 13.5px; color: var(--room-text); }
.try-dist dt { color: var(--room-muted); }
.try-dist dd { margin: 0; font-variant-numeric: tabular-nums; }
.try-panel h3 { font: 600 15.5px var(--sans); letter-spacing: 0; }
.try-panel .help, .try-dist .help { font-size: 13.5px; line-height: 1.5; color: var(--room-muted); }
.try-sw { display: grid; gap: 4px; }
.try-keys { display: flex; flex-wrap: wrap; gap: 4px 14px; padding-left: 24px; font-size: 12.5px; color: var(--room-muted); }
.tkey { display: inline-flex; align-items: center; gap: 6px; }
.tsw { display: inline-block; width: 13px; height: 13px; flex: none; }
.tsw.alt1 { border: 2px dashed #C3A4FF; }
.tsw.alt2 { border: 2px dashed #B5BEC4; }
.tsw.rad { border: 2px solid #7FD88F; }
.tsw.rad-dot { border: 2px solid #7FD88F; border-radius: 50%; }
.tsw.cand-yes { border-radius: 50%; background: #5FC6E3; }
.tsw.cand-no { border-radius: 50%; background: #1D2328; border: 1.5px solid #E7EDF2; }
