/* Field Measure AI · phone UI, from the final design hand-off (design/DESIGN-SPEC.md).
   Cream (light) or Charcoal (dark), following the phone. Jimmy is a pendant light at the top
   (presence.js); his words are Cheltenham and light up as he says them. Measurements in the
   spec are for a 390 × 844 screen; here they're anchored to the safe areas and the app's height. */

@font-face { font-family: "ITC Cheltenham Std"; src: url("assets/fonts/cheltenham-300.ttf") format("truetype"); font-weight: 300; font-display: swap; }
@font-face { font-family: "ITC Cheltenham Std"; src: url("assets/fonts/cheltenham-400.ttf") format("truetype"); font-weight: 400; font-display: swap; }

:root {
  color-scheme: light;
  /* Cream */
  --bg: #fcfaf6;
  --text: #35312e;
  --unspoken: rgba(53, 49, 46, 0.38);
  --dim: rgba(53, 49, 46, 0.64);
  --faint: rgba(53, 49, 46, 0.42);
  --bubble: #ece8de;
  --chip: rgba(70, 85, 97, 0.10);
  --chip-ink: #35312e;
  --end: #35312e;
  --end-ink: #fcfaf6;
  --primary: #af5a3c;
  --primary-ink: #ffffff;
  --edge: rgba(70, 85, 97, 0.16);
  --raise: #f3f0e9;
  /* the same in both modes */
  --rust: #af5a3c;
  --rust-lo: #9a4e33;
  --paper: #fcfaf6;
  --ink: #35312e;
  --ink-dim: rgba(53, 49, 46, 0.64);
  --ink-faint: rgba(53, 49, 46, 0.55);
  --mic-blue: #5a7ea6;
  --mic-blue-hi: #7d9ec2;
  --shadow: rgba(53, 49, 46, 0.28);
  --scrim: rgba(53, 49, 46, 0.45);
  --display: "ITC Cheltenham Std", Georgia, "Times New Roman", serif;
  --body: "Figtree", -apple-system, "Avenir Next", system-ui, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --curve: cubic-bezier(0.2, 0.75, 0.2, 1);
  --top: max(env(safe-area-inset-top, 0px), 10px); /* where the header starts: under the status bar */
  --sab: env(safe-area-inset-bottom, 0px);
  --media-h: clamp(168px, 28%, 236px);
  --kb-offset: 0px;   /* on-screen keyboard height (iOS doesn't resize the page) */
  --kb-gap: calc(30px + var(--sab));
  --kb-h: 96px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    /* Charcoal */
    --bg: #262321;
    --text: #f5f1ea;
    --unspoken: rgba(245, 241, 234, 0.38);
    --dim: rgba(245, 241, 234, 0.66);
    --faint: rgba(245, 241, 234, 0.40);
    --bubble: #3a3633;
    --chip: rgba(255, 255, 255, 0.09);
    --chip-ink: #f5f1ea;
    --end: #f5f1ea;
    --end-ink: #262321;
    --primary: #f5f1ea;
    --primary-ink: #35312e;
    --edge: rgba(245, 241, 234, 0.16);
    --raise: #312d2b;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
body {
  font-family: var(--body); font-size: 16px; line-height: 1.45; color: var(--text); background: var(--bg);
  overflow: hidden; overscroll-behavior: none;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; -webkit-user-select: none; user-select: none;
}
input { -webkit-user-select: text; user-select: text; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--rust); outline-offset: 3px; }
svg { display: block; }
[hidden] { display: none !important; }
.display { font-family: var(--display); font-weight: 400; letter-spacing: 0.004em; margin: 0; }
.eyebrow { font: 700 11px/1.3 var(--body); letter-spacing: 0.14em; text-transform: uppercase; color: var(--rust); }

/* the app: one phone-shaped column, everything positioned inside it */
.app { position: fixed; inset: 0; margin: 0 auto; max-width: 560px; overflow: hidden; isolation: isolate; background: var(--bg); color: var(--text); transition: background-color 0.5s ease, color 0.5s ease; }

/* ---------- presence ---------- */
.fx { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.band {
  position: absolute; left: 0; top: 0; width: 100%; height: 52%; z-index: 2; pointer-events: none;
  -webkit-mask-image: linear-gradient(to bottom, #000 78%, transparent); mask-image: linear-gradient(to bottom, #000 78%, transparent);
  transition: opacity 0.6s ease;
}
body[data-media="on"] .band { opacity: 0.35; }

/* ---------- header ---------- */
.appbar {
  position: absolute; top: calc(var(--top) + 4px); left: 60px; right: 60px; height: 40px; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; pointer-events: none;
}
.appname { font-family: var(--display); font-weight: 400; font-size: 19px; }
.appsub { margin-top: 3px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 10px/1.2 var(--body); letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); transition: opacity 0.3s ease; }
.menu-btn {
  position: absolute; top: calc(var(--top) + 6px); right: 14px; z-index: 6; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; color: var(--dim); opacity: 0; pointer-events: none; transition: opacity 0.4s ease, background-color 0.2s;
}
.menu-btn svg { width: 20px; height: 20px; fill: currentColor; }
.menu-btn:active { background: var(--chip); }
body[data-screen="talk"] .menu-btn { opacity: 1; pointer-events: auto; }

/* ---------- Jimmy's area ---------- */
.media {
  position: absolute; left: 16px; right: 16px; top: calc(var(--top) + 50px); height: var(--media-h); margin: 0; z-index: 3;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 4px;
  border-radius: 16px; background: var(--paper); color: var(--ink); border: 1px solid rgba(70, 85, 97, 0.16); box-shadow: 0 10px 30px -14px var(--shadow);
  opacity: 0; transform: translateY(14px) scale(0.98); pointer-events: none; visibility: hidden;
  transition: opacity 0.45s ease 0.1s, transform 0.6s var(--curve) 0.1s, visibility 0s linear 0.7s;
}
body[data-media="on"] .media { opacity: 1; transform: none; pointer-events: auto; cursor: zoom-in; visibility: visible; transition: opacity 0.45s ease 0.1s, transform 0.6s var(--curve) 0.1s, visibility 0s; }
.media-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; color: var(--ink); }
.media-head b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--display); font-weight: 400; font-size: 16px; }
.media-head span { flex: none; font: 700 9.5px/1 var(--body); letter-spacing: 0.12em; text-transform: uppercase; color: var(--rust); }
.media-sheet { position: relative; flex: 1; min-height: 0; }
.media-sheet > .art { position: absolute; inset: 0; opacity: 0; transition: opacity 0.35s ease; }
.media-sheet > .art.show { opacity: 1; }
.art svg { position: absolute; inset: 0; width: 100%; height: 100%; }
/* view only: no long-press save, selection or dragging */
.view-only, .view-only *, .draw-area, .draw-area * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-user-drag: none; }

/* ---------- welcome, microphone, done: a centered stack under the light ---------- */
.stack {
  position: absolute; inset: 0; z-index: 4; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: none;
  display: flex; flex-direction: column; align-items: center;
  padding: 0 30px calc(28px + var(--sab));
  opacity: 0; transform: translateY(16px); pointer-events: none; visibility: hidden;
  transition: opacity 0.5s ease, transform 0.6s ease, visibility 0s linear 0.6s;
}
.stack::-webkit-scrollbar { display: none; }
.stack::before { content: ""; flex: 0 1 46%; min-height: calc(var(--top) + 120px); }
.welcome::before { flex-basis: 48%; }
body[data-screen="welcome"] #welcome, body[data-screen="perm"] #perm, body[data-screen="done"] #done {
  opacity: 1; transform: none; pointer-events: auto; visibility: visible; transition: opacity 0.5s ease, transform 0.6s ease, visibility 0s;
}
.stack-body { width: 100%; max-width: 360px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; flex: none; }
.stack h1 { font-weight: 300; font-size: 32px; line-height: 1.12; text-wrap: balance; }
.welcome h1 { font-size: 36px; line-height: 1.1; }
.stack p { margin: 0; max-width: 28ch; font-size: 16px; line-height: 1.45; color: var(--dim); text-wrap: pretty; }
.stack .fine { font-size: 13px; color: var(--faint); }
.actions { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 18px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 15px 28px; border-radius: 10px;
  font: 600 14px/1.2 var(--body); letter-spacing: 0.06em; text-transform: uppercase;
  transition: transform 0.15s var(--curve), background-color 0.2s, opacity 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.secondary { color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.link { min-height: 44px; padding: 0 14px; font: 500 15px var(--body); color: var(--dim); text-decoration: underline; text-decoration-color: var(--edge); text-underline-offset: 4px; }
.ghost { min-height: 44px; margin-top: 6px; padding: 12px 22px; border-radius: 10px; border: 1px solid var(--edge); font: 600 13px var(--body); letter-spacing: 0.06em; text-transform: uppercase; color: var(--text); }
.ghost:active, .link:active { background: var(--chip); }
.steps { margin: 4px 0 0; padding-left: 20px; display: grid; gap: 10px; text-align: left; font-size: 15px; line-height: 1.45; color: var(--dim); }
.steps b { color: var(--text); font-weight: 600; }
.dots { display: flex; gap: 6px; justify-content: center; padding-top: 6px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); animation: blink 1.1s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
.next { width: 100%; margin: 10px 0 0; padding: 14px 16px; list-style: none; text-align: left; border-radius: 12px; background: var(--bubble); display: grid; gap: 10px; font-size: 15px; line-height: 1.4; }
.next li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; }
.next b { font-family: var(--display); font-weight: 400; font-size: 17px; line-height: 1.2; color: var(--rust); }
.save-state { min-height: 20px; font-size: 13px !important; color: var(--faint) !important; }

/* ---------- conversation ---------- */
.talk { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.talk > * { pointer-events: auto; }
.thread {
  position: absolute; left: 0; right: 0; z-index: 4;
  top: max(calc(var(--top) + 202px), 30.3%);
  bottom: calc(124px + var(--sab));
  padding: 28px 22px 2px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  display: flex; flex-direction: column; gap: 14px;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 40px); mask-image: linear-gradient(to bottom, transparent 0, #000 40px);
  opacity: 0; visibility: hidden;
  transition: opacity 0.5s ease 0.15s, top 0.6s var(--curve), bottom 0.45s var(--curve), visibility 0s linear 0.65s;
}
.thread::-webkit-scrollbar { display: none; }
body[data-screen="talk"] .thread { opacity: 1; visibility: visible; transition: opacity 0.5s ease 0.15s, top 0.6s var(--curve), bottom 0.45s var(--curve), visibility 0s; }
body[data-media="on"] .thread { top: calc(var(--top) + 62px + var(--media-h)); }
body.typing .thread { bottom: calc(var(--kb-offset) + var(--kb-gap) + var(--kb-h) + 14px); }
.thread > :first-child { margin-top: auto; }
.msg { flex: none; min-width: 0; margin: 0; overflow-wrap: anywhere; animation: msgIn 0.35s var(--curve) both; }
.msg.old { animation: none; }
.msg p { margin: 0; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } }
/* Jimmy: Cheltenham read-along, no bubble. Unspoken words are faint and fill in as he says them. */
.msg.ai { max-width: 100%; font-family: var(--display); font-weight: 400; font-size: 21px; line-height: 1.45; letter-spacing: 0.002em; color: var(--text); -webkit-user-select: text; user-select: text; }
.msg.ai .w { color: var(--unspoken); transition: color 0.18s linear; }
.msg.ai .w.lit, .msg.ai.plain .w { color: var(--text); }
.msg.ai.typing p::after { content: "•••"; font-family: var(--body); font-size: 16px; letter-spacing: 3px; color: var(--faint); animation: blink 1.2s ease-in-out infinite; }
.msg.you { align-self: flex-end; max-width: 78%; padding: 10px 15px; border-radius: 18px 18px 6px 18px; background: var(--bubble); font-size: 16px; font-weight: 500; line-height: 1.45; letter-spacing: -0.01em; -webkit-user-select: text; user-select: text; }
.msg.you.live { opacity: 0.62; animation: none; }
.msg.sys { align-self: center; max-width: 92%; font-size: 13px; font-weight: 500; color: var(--faint); text-align: center; }
.msg.photo { align-self: flex-end; padding: 4px; border-radius: 18px 18px 6px 18px; background: var(--bubble); }
.photo-btn { display: block; overflow: hidden; border-radius: 14px 14px 4px 14px; }
.photo-btn img { display: block; width: 168px; height: 126px; object-fit: cover; }
.new-pill {
  position: absolute; left: 50%; bottom: calc(132px + var(--sab)); transform: translateX(-50%); z-index: 6;
  display: inline-flex; align-items: center; gap: 5px; height: 34px; padding: 0 15px 0 11px; border-radius: 999px;
  background: var(--end); color: var(--end-ink); font-size: 14px; font-weight: 600; box-shadow: 0 8px 20px -10px var(--shadow); animation: msgIn 0.3s var(--curve) both;
}
body.typing .new-pill { bottom: calc(var(--kb-offset) + var(--kb-gap) + var(--kb-h) + 22px); }
.new-pill svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- the dock: camera, mic, X ---------- */
.dock {
  position: absolute; left: 0; right: 0; bottom: calc(40px + var(--sab)); z-index: 5;
  display: flex; align-items: center; justify-content: center; gap: 34px;
  opacity: 0; transform: translateY(20px); pointer-events: none;
  transition: opacity 0.5s ease, transform 0.6s ease;
}
body[data-screen="talk"]:not(.typing):not([data-mode="review"]) .dock { opacity: 1; transform: none; pointer-events: auto; }
.round, .mic { position: relative; isolation: isolate; border-radius: 50%; display: grid; place-items: center; background: var(--chip); color: var(--chip-ink); transition: background-color 0.2s, color 0.2s, transform 0.15s var(--curve); }
.round { width: 52px; height: 52px; }
.mic { width: 68px; height: 68px; }
.round:active, .mic:active { transform: scale(0.93); }
.round svg, .mic svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mic svg { width: 26px; height: 26px; }
/* the mic fills blue as the haze reaches it (presence.js sets --cover) */
.mic::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit;
  background: radial-gradient(circle at 50% 30%, var(--mic-blue-hi), var(--mic-blue) 72%);
  box-shadow: 0 0 26px 2px rgba(90, 126, 166, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.4);
  opacity: var(--cover, 0);
}
.mic .mic-off { display: none; }
.mic.muted { background: var(--rust); color: #fff; }
.mic.muted::before { opacity: 0; }
.mic.muted .mic-on { display: none; }
.mic.muted .mic-off { display: block; }
.round.x { background: var(--end); color: var(--end-ink); }
.round.cam.want { background: var(--rust); color: #fff; }
.round.cam.want::after { content: ""; position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 2px var(--rust); animation: ring 2s var(--curve) infinite; }
@keyframes ring { from { transform: scale(1); opacity: 0.9; } to { transform: scale(1.55); opacity: 0; } }
.live-line {
  position: absolute; left: 24px; right: 24px; bottom: calc(10px + var(--sab)); z-index: 5; margin: 0;
  min-height: 20px; font-size: 14px; line-height: 20px; color: var(--faint); text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: opacity 0.3s ease;
}
body.typing .live-line, body[data-mode="review"] .live-line, body:not([data-screen="talk"]) .live-line { opacity: 0; }

/* ---------- typing mode ---------- */
.kb {
  position: absolute; left: 14px; right: 14px; bottom: calc(var(--kb-offset) + var(--kb-gap)); z-index: 8; margin: 0;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  opacity: 0; transform: translateY(20px); pointer-events: none; visibility: hidden;
  transition: opacity 0.45s ease, transform 0.55s var(--curve), bottom 0.25s ease, visibility 0s linear 0.55s;
}
body.typing .kb { opacity: 1; transform: none; pointer-events: auto; visibility: visible; transition: opacity 0.45s ease, transform 0.55s var(--curve), bottom 0.25s ease, visibility 0s; }
.talk-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 10px 18px; border-radius: 22px; box-shadow: inset 0 0 0 1.5px var(--rust); color: var(--rust); font: 600 13px var(--body); letter-spacing: 0.06em; text-transform: uppercase; transition: transform 0.15s var(--curve); }
.talk-btn:active { transform: scale(0.96); }
.talk-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }
body.kb-always .talk-btn { display: none; }
.kb-row { width: 100%; display: flex; align-items: center; gap: 8px; }
.kb-cam { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--chip); color: var(--chip-ink); }
.kb-cam.want { background: var(--rust); color: #fff; }
.kb input { flex: 1; min-width: 0; height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid var(--edge); background: var(--bubble); color: var(--text); font: 500 16px var(--body); outline: none; }
.kb input::placeholder { color: var(--faint); }
.kb input:focus { border-color: var(--faint); }
.kb-send { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--rust); color: #fff; transition: transform 0.15s; }
.kb-send:active { transform: scale(0.92); }
.kb-send svg, .kb-cam svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- review sheet (always cream: drawings are on paper) ---------- */
.review {
  position: absolute; left: 0; right: 0; bottom: 0; top: calc(var(--top) + 96px); z-index: 7;
  padding: 10px 18px calc(24px + var(--sab)); display: flex; flex-direction: column; gap: 10px;
  border-radius: 26px 26px 0 0; background: var(--paper); color: var(--ink); box-shadow: 0 -16px 40px -18px rgba(0, 0, 0, 0.35);
  transform: translateY(105%); transition: transform 0.6s var(--curve), padding-bottom 0.25s ease;
}
.review.open { transform: none; }
.review .grab { flex: none; align-self: center; width: 38px; height: 5px; border-radius: 3px; background: rgba(53, 49, 46, 0.18); }
.review-head { flex: none; display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; }
.review-head .eyebrow { font-size: 10.5px; }
.review-head h2 { margin-top: 2px; font-size: 26px; line-height: 1.1; color: var(--ink); text-wrap: balance; }
.review-head .count { flex: none; padding-bottom: 3px; font-size: 13px; font-weight: 600; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.review .q { flex: none; margin: 0; font-size: 16px; font-weight: 500; line-height: 1.4; color: rgba(53, 49, 46, 0.75); max-height: 4.2em; overflow: hidden; }
.review .q .w { color: rgba(53, 49, 46, 0.38); transition: color 0.18s linear; }
.review .q .w.lit, .review .q.plain .w { color: rgba(53, 49, 46, 0.85); }
.review-sheet { position: relative; flex: 1; min-height: 120px; overflow: hidden; border-radius: 12px; border: 1px solid rgba(70, 85, 97, 0.16); background: var(--paper); touch-action: none; }
.review-btns { flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.review-btns button { height: 52px; border-radius: 10px; font: 600 13.5px var(--body); letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; transition: transform 0.15s var(--curve), background-color 0.2s; }
.review-btns button:active { transform: scale(0.97); }
.review-btns .off { box-shadow: inset 0 0 0 1.5px var(--ink); color: var(--ink); }
.review-btns .ok { background: var(--rust); color: #fff; }
.review-btns .ok:active { background: var(--rust-lo); }
.review .say { flex: none; margin: 0; min-height: 18px; text-align: center; font-size: 13px; color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.review .say.live { font-style: italic; color: rgba(53, 49, 46, 0.7); }
.review.swap .review-sheet .zoomer, .review.swap .review-head h2 { animation: swapIn 0.45s var(--curve) both; }
@keyframes swapIn { from { opacity: 0; transform: translateX(22px); } }
/* typing during review: the text bar sits on the sheet, in the sheet's colors */
body.typing .review { padding-bottom: calc(var(--kb-offset) + var(--kb-gap) + var(--kb-h) + 14px); }
body[data-mode="review"] .kb { --bubble: #ece8de; --chip: rgba(70, 85, 97, 0.10); --chip-ink: #35312e; --text: #35312e; --faint: rgba(53, 49, 46, 0.42); --edge: rgba(70, 85, 97, 0.16); }
body[data-mode="review"] .kb .talk-btn { display: none; }

/* drawings: pinch / double-tap zoom inside the review sheet and the enlarged view */
.draw-area { touch-action: none; }
.zoomer { position: absolute; inset: 0; transform-origin: 0 0; }
.zoomer.anim { transition: transform 0.3s var(--curve); }
.zoomer svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.zoomer .msg { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; color: var(--ink-dim); font-size: 16px; text-align: center; animation: none; }

/* ---------- enlarged view of Jimmy's area ---------- */
.zoom { position: absolute; inset: 0; z-index: 30; display: grid; padding: calc(var(--top) + 16px) 12px calc(70px + var(--sab)); background: var(--scrim); animation: fade 0.25s ease both; }
.zoom-card { min-height: 0; display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: 16px; background: var(--paper); color: var(--ink); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25); animation: zoomIn 0.4s var(--curve) both; }
.zoom-head { flex: none; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.zoom-head b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--display); font-weight: 400; font-size: 16px; }
.zoom-x { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: rgba(70, 85, 97, 0.10); color: var(--ink); }
.zoom-x svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.zoom-sheet { position: relative; flex: 1; min-height: 0; overflow: hidden; border-radius: 10px; }
@keyframes fade { from { opacity: 0; } }
@keyframes zoomIn { from { opacity: 0; transform: translateY(14px) scale(0.98); } }

/* ---------- menu, toast, photo, confirm ---------- */
.menu { position: absolute; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.menu-scrim { position: absolute; inset: 0; background: var(--scrim); animation: fade 0.25s both; }
.menu-card { position: relative; width: 100%; margin: 0 10px calc(10px + var(--sab)); padding: 8px; border-radius: 22px; background: var(--bg); box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.5), inset 0 0 0 1px var(--edge); animation: up 0.45s var(--curve) both; }
.menu-item { width: 100%; min-height: 56px; display: flex; align-items: center; gap: 14px; padding: 0 14px; border-radius: 14px; font-size: 17px; font-weight: 500; text-align: left; color: var(--text); }
.menu-item:active { background: var(--chip); }
.menu-item svg { width: 22px; height: 22px; flex: none; fill: none; stroke: var(--rust); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.menu-item.close { justify-content: center; margin-top: 4px; border-top: 1px solid var(--edge); border-radius: 0 0 14px 14px; color: var(--dim); }
@keyframes up { from { opacity: 0; transform: translateY(30px); } }
.toast {
  position: absolute; left: 50%; bottom: calc(132px + var(--sab)); z-index: 50; transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 32px); display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 18px; border-radius: 16px;
  background: var(--end); color: var(--end-ink); font-size: 15px; line-height: 1.35; box-shadow: 0 18px 40px -14px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.4s var(--curve) both;
}
.toast.leaving { animation: toastOut 0.25s ease both; }
.toast-btn { flex: none; min-height: 40px; padding: 0 16px; border-radius: 10px; background: var(--rust); color: #fff; font: 600 13px var(--body); letter-spacing: 0.06em; text-transform: uppercase; }
body.typing .toast { bottom: calc(var(--kb-offset) + var(--kb-gap) + var(--kb-h) + 16px); }
body[data-mode="review"] .toast { bottom: auto; top: calc(var(--top) + 50px); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px) scale(0.97); } }
@keyframes toastOut { to { opacity: 0; transform: translate(-50%, 8px); } }
.lightbox { position: absolute; inset: 0; z-index: 60; display: grid; place-items: center; padding: calc(var(--top) + 52px) 12px calc(24px + var(--sab)); background: rgba(20, 18, 17, 0.94); animation: fade 0.2s both; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; object-fit: contain; }
.lightbox-x { position: absolute; top: calc(var(--top) + 6px); right: 12px; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: rgba(245, 241, 234, 0.14); color: #f5f1ea; }
.lightbox-x svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }
.confirm { position: absolute; inset: 0; z-index: 70; display: grid; place-items: center; padding: 20px; background: var(--scrim); animation: fade 0.2s both; }
.confirm-card { width: 100%; max-width: 340px; padding: 22px 20px 18px; border-radius: 18px; background: var(--paper); color: var(--ink); animation: up 0.35s var(--curve) both; }
.confirm-card h2 { font-size: 26px; font-weight: 300; margin-bottom: 8px; }
.confirm-card p { margin: 0 0 18px; color: var(--ink-dim); font-size: 15px; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.confirm-actions .btn { min-height: 50px; padding: 0 10px; font-size: 13px; }
.confirm-actions .btn.primary { background: var(--rust); color: #fff; }
.debug { position: absolute; z-index: 90; left: 8px; right: 8px; top: calc(var(--top) + 46px); padding: 4px 8px; border-radius: 8px; pointer-events: none; background: rgba(10, 13, 16, 0.72); color: #c8f0c8; font: 500 9.5px/1.4 var(--mono); }
.debug div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.noscript { position: fixed; inset: auto 0 40% 0; z-index: 100; text-align: center; }

/* ---------- instruction clips (each clip's own CSS is scoped under .clip-<id>) ---------- */
.clip-wrap { position: absolute; inset: 0; }
.clip-wrap svg { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ---------- small screens ---------- */
@media (max-height: 640px) {
  .stack h1 { font-size: 28px; }
  .welcome h1 { font-size: 31px; }
  .msg.ai { font-size: 20px; }
  .dock { bottom: calc(28px + var(--sab)); }
  .thread { bottom: calc(110px + var(--sab)); }
  .live-line { bottom: calc(4px + var(--sab)); }
}
@media (max-width: 350px) {
  .thread { padding-left: 16px; padding-right: 16px; }
  .msg.ai { font-size: 20px; }
  .dock { gap: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  .media, .stack, .thread, .dock, .band, .kb, .review { transition-duration: 0.01s !important; }
  .msg, .zoom-card, .menu-card, .toast { animation: none !important; }
}
