/* Nib, in Apple's language: the live page blurred behind frosted glass, SF type (Inter where SF isn't
   installed), one tint (system yellow: "here", "sign here", the main action), green only for done,
   and the Apple Intelligence glow only while Nib is listening, thinking or reading. */
:root {
  --bg: #000;
  --elev-1: #1C1C1E;
  --elev-2: #2C2C2E;
  --label: #FFFFFF;
  --label-2: rgba(235, 235, 245, 0.78);
  --label-3: rgba(235, 235, 245, 0.62);
  --fill: rgba(118, 118, 128, 0.24);
  --fill-2: rgba(118, 118, 128, 0.12);
  --sep: rgba(84, 84, 88, 0.55);
  --tint: #FFD60A;
  --tint-ink: #1C1C1E;
  --green: #30D158;
  --orange: #FF9F0A;
  --red: #FF453A;
  --glass: rgba(28, 28, 30, 0.58);
  --glass-hi: rgba(255, 255, 255, 0.14);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --spring: cubic-bezier(0.32, 0.72, 0, 1);
  --r-card: 26px;
  --gap: clamp(10px, 0.9vw, 16px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--label); color-scheme: dark; overscroll-behavior: none; }
body { font-family: var(--font); font-feature-settings: "cv11", "ss03"; -webkit-font-smoothing: antialiased; letter-spacing: -0.011em; }
button, select { font: inherit; color: inherit; letter-spacing: inherit; }
:focus-visible { outline: 3px solid var(--tint); outline-offset: 3px; }
.stage, .caption { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.sr { position: absolute; top: 0; left: 0; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Frosted glass: translucent fill, blur and saturation, a hairline edge and a soft top highlight. */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  border: 0.5px solid var(--glass-hi);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 18px 50px rgba(0, 0, 0, 0.45);
}

/* The live page, small and blurred, scaled up to fill the window: GPU work, no per-frame script. */
.ambient { position: fixed; inset: 0; overflow: hidden; pointer-events: none; background: radial-gradient(90% 70% at 50% 25%, #111218 0%, #020204 72%); }
.ambient > * { position: absolute; left: 0; top: 0; width: 25%; height: 25%; object-fit: cover; transform: scale(4.2); transform-origin: 0 0; filter: blur(20px) brightness(0.12) saturate(1.2); opacity: 0; transition: opacity 0.9s var(--spring); }
.ambient.on > * { opacity: 1; }
.ambient::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 35%, transparent 20%, rgba(0, 0, 0, 0.16) 60%, rgba(0, 0, 0, 0.6) 100%); }

#app {
  position: relative;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: var(--gap);
  padding: max(var(--gap), env(safe-area-inset-top)) max(var(--gap), env(safe-area-inset-right)) max(var(--gap), env(safe-area-inset-bottom)) max(var(--gap), env(safe-area-inset-left));
}

/* ---------- header capsule ---------- */
.bar {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  min-height: 60px;
  padding: 8px 20px 8px 10px;
  border-radius: 22px;
  overflow: hidden;
}
/* Progress fills along the bottom edge as answers are kept. */
.bar::after { content: ""; position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; transform-origin: left; transform: scaleX(var(--p, 0)); background: var(--green); transition: transform 0.7s var(--spring); }
.brand { display: flex; align-items: center; gap: 10px; }
.app-icon, .hero-icon {
  display: block;
  width: 40px; height: 40px;
  border-radius: 11px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M20 6.5 29 19.5 20 34 11 19.5Z' fill='%231C1C1E'/%3E%3Cpath d='M20 20v14' stroke='%23FFD60A' stroke-width='2.2' stroke-linecap='round'/%3E%3Ccircle cx='20' cy='19.5' r='2.6' fill='%23FFD60A'/%3E%3C/svg%3E") center / 72% no-repeat,
    linear-gradient(160deg, #FFE45C 0%, #FFD60A 45%, #F5B800 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 4px 14px rgba(255, 214, 10, 0.22);
}
.wordmark { font-weight: 700; font-size: 22px; letter-spacing: -0.02em; }
.doc-context { min-width: 0; display: grid; gap: 4px; }
.session-kicker { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 5px 10px; color: var(--label-2); font-size: 13px; font-weight: 500; line-height: 1.3; }
#sessionMode { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border: 0.5px solid rgba(235, 235, 245, 0.23); border-radius: 7px; background: rgba(255, 255, 255, 0.05); color: #F3F3F8; font-weight: 600; white-space: nowrap; }
#sessionMode::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--tint); }
#sessionState { min-width: 0; overflow-wrap: anywhere; }
.current-field { margin: 0; font-size: clamp(25px, 2.3vw, 36px); font-weight: 700; line-height: 1.13; letter-spacing: -0.03em; overflow-wrap: anywhere; }
.current-field[hidden] { display: none; }
.doc { margin: 0; font-size: 17px; font-weight: 500; color: var(--label-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
[data-field-active] .doc { font-size: 13px; color: var(--label-2); }
.doc:empty { display: none; }
.steps { display: flex; align-items: center; gap: 14px; }
.count { font-size: 15px; font-weight: 500; color: var(--label-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.count b { font-weight: 700; font-size: 1.35em; color: var(--label); }
.progress { display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; }
.progress li { width: 20px; height: 6px; border-radius: 3px; background: rgba(235, 235, 245, 0.18); transition: background-color 0.35s, width 0.45s var(--spring); }
.progress li[data-state="active"] { width: 34px; background: var(--tint); }
.progress li[data-state="done"] { background: var(--green); }
.progress li[data-state="review"] { background: var(--orange); }
.progress li[data-state="skipped"] { background: rgba(235, 235, 245, 0.08); }
.progress li[data-just] { animation: pill 0.5s var(--spring); }
@keyframes pill { from { transform: scaleY(2.4); } }
@media (min-width: 1100px) {
  .bar { min-height: 64px; }
  .doc { font-size: clamp(17px, 1.15vw, 21px); }
  .progress li { width: 24px; }
  .progress li[data-state="active"] { width: 40px; }
}

/* ---------- stage ---------- */
.stage { position: relative; min-height: 0; display: grid; grid-template-columns: 1fr; gap: var(--gap); }
@media (min-width: 1100px) { .stage { grid-template-columns: 1fr clamp(360px, 25vw, 480px); } }
#video { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.view { position: relative; min-width: 0; min-height: 0; border-radius: var(--r-card); }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; transition: opacity 0.3s var(--spring); }
[data-sim] #canvas { cursor: none; }

/* Apple Intelligence glow: only while Nib listens, thinks or reads the page. */
@property --spin { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
.view::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: var(--r-card);
  padding: 5px;
  background: conic-gradient(from var(--spin), #BC82F3, #F5B9EA, #8D9FFF, #AA6EEE, #FF6778, #FFBA71, #C686FF, #BC82F3);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  filter: blur(7px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s var(--spring);
  animation: spin 4s linear infinite;
}
[data-talk] .view::after, [data-mode="reading"] .view::after { opacity: 1; }
@keyframes spin { to { --spin: 360deg; } }
[data-talk] #canvas { opacity: 0.7; }
/* A glass status capsule at the top of the view: Listening, Thinking. */
[data-talk] .view::before {
  content: "Listening";
  position: absolute;
  top: 18px;
  left: 50%;
  z-index: 4;
  transform: translateX(-50%);
  padding: 10px 22px;
  border-radius: 999px;
  background: rgba(28, 28, 30, 0.72);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border: 0.5px solid var(--glass-hi);
  font: 600 clamp(15px, 1.2vw, 20px)/1.2 var(--font);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  animation: pop-in 0.45s var(--spring) both;
}
[data-talk="thinking"] .view::before { content: "Thinking…"; }
@keyframes pop-in { from { opacity: 0; transform: translate(-50%, -8px) scale(0.94); } }

/* ---------- What Nib sees: an inset grouped list on glass ---------- */
.panel {
  display: none;
  min-height: 0;
  font-size: clamp(16px, 1vw, 19px);
  padding: 1.3em 1.1em 1em;
  border-radius: var(--r-card);
  flex-direction: column;
  gap: 0.45em;
}
@media (min-width: 1100px) { .panel { display: flex; } }
.panel-label { margin: 0 0.2em; font-size: 0.78em; font-weight: 600; color: var(--label-2); }
.panel-title { margin: 0 0.15em 0.1em; font-size: 1.65em; font-weight: 700; line-height: 1.12; letter-spacing: -0.025em; text-wrap: balance; }
[data-mode="reading"] .panel-title { color: var(--label-2); }
.panel-meta { margin: 0 0.25em 0.5em; font-size: 0.85em; color: var(--label-2); font-variant-numeric: tabular-nums; }
.panel-find {
  margin: 0 0 0.5em;
  padding: 0.75em 1em;
  border-radius: 16px;
  background: var(--tint);
  color: var(--tint-ink);
  font-weight: 700;
  font-size: 1.15em;
  line-height: 1.25;
  text-wrap: balance;
  animation: pop 0.45s var(--spring) both;
}
.panel-find::before { content: "Finding"; display: block; font-size: 0.66em; font-weight: 600; opacity: 0.7; margin-bottom: 0.15em; }
.panel-meta[hidden], .panel-find[hidden] { display: none; }
@keyframes pop { from { opacity: 0; transform: scale(0.96); } }

.fields {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  display: grid;
  align-content: start;
  scrollbar-width: none;
  border-radius: 18px;
  background: var(--fill-2);
}
.fields:empty { background: transparent; }
.fields::-webkit-scrollbar { display: none; }
.fields:focus-visible { outline-offset: -3px; }
[data-mode="reading"] .fields:empty::before {
  content: "";
  height: min(100%, 22em);
  border-radius: 18px;
  background:
    linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.09) 50%, transparent 70%) 150% 0 / 200% 100% no-repeat,
    repeating-linear-gradient(to bottom, rgba(118, 118, 128, 0.16) 0 3em, transparent 3em 3.25em);
  animation: sweep 1.5s linear infinite;
}
@keyframes sweep { to { background-position: -50% 0, 0 0; } }
.fields li {
  position: relative;
  display: grid;
  grid-template-columns: 1.75em 1fr;
  gap: 0.7em;
  align-items: start;
  padding: 0.7em 0.9em;
  animation: row-in 0.5s var(--spring) both;
  transition: background-color 0.3s;
}
.fields li + li::before { content: ""; position: absolute; top: 0; left: 3.35em; right: 0; height: 0.5px; background: var(--sep); }
@keyframes row-in { from { opacity: 0; transform: translateY(8px); } }
.fields .n {
  display: grid;
  place-items: center;
  width: 1.75em; height: 1.75em;
  border-radius: 50%;
  background: rgba(118, 118, 128, 0.32);
  font-size: 0.8em;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.f-body { display: grid; grid-template-columns: 1fr auto; gap: 1px 10px; align-items: baseline; min-width: 0; }
.f-label { font-weight: 600; font-size: 1.02em; text-wrap: balance; min-width: 0; }
.f-kind { font-size: 0.82em; color: var(--label-2); white-space: nowrap; }
.f-answer, .f-hint { grid-column: 1 / -1; font-size: 0.9em; }
.f-answer { font-family: var(--font); font-size: 1.02em; line-height: 1.35; color: var(--label-2); overflow: hidden; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.f-hint { color: var(--label-2); }

.fields li[data-state="todo"] .f-label { color: var(--label-2); }
.fields li[data-state="active"] { background: var(--tint); color: var(--tint-ink); }
.fields li[data-state="active"] .f-kind, .fields li[data-state="active"] .f-hint { color: rgba(28, 28, 30, 0.7); }
.fields li[data-state="active"] + li::before, .fields li[data-state="active"]::before { display: none; }
.fields li[data-state="active"] .n { background: var(--tint-ink); color: var(--tint); }
.fields li[data-state="active"] .f-label { font-size: 1.15em; font-weight: 700; }
.fields li[data-state="active"] .f-answer { color: var(--tint-ink); } /* a proposal until it is kept */
.fields li[data-state="done"] .n { background: var(--green); color: #000; }
.fields li[data-state="done"] .f-answer { color: var(--label); }
.fields li[data-state="skipped"] .f-label { color: var(--label-2); text-decoration: line-through; }
.fields li[data-state="skipped"] .n { background: var(--fill-2); color: var(--label-3); }
.fields li[data-flag="review"] .n { background: var(--orange); color: #000; }
.fields li[data-flag="review"] .f-kind { color: var(--orange); font-weight: 600; }
.fields li[data-flag="review"] .f-answer { text-decoration: underline wavy var(--orange); text-underline-offset: 4px; }
.fields li[data-state="review"] { background: rgba(255, 159, 10, 0.09); }
.fields li[data-state="review"] .n { background: var(--orange); color: #000; }
.fields li[data-state="review"] .f-kind { color: #FFB547; font-weight: 600; }
.fields li[data-state="review"] .f-answer { color: var(--label); text-decoration: underline wavy var(--orange); text-underline-offset: 4px; }
.fields li[data-flag="added"] .f-kind { color: var(--tint); font-weight: 600; }
.fields li[data-just="done"] { animation: flash-ok 0.9s ease-out; }
.fields li[data-just="done"] .n { animation: check-pop 0.5s var(--spring) both; }
.fields li[data-just="done"] .f-answer { animation: ink 0.6s steps(14) both; }
.fields li[data-just="active"] { animation: arrive 0.45s var(--spring); }
@keyframes flash-ok { from { background: rgba(48, 209, 88, 0.28); } }
@keyframes check-pop { 0% { transform: scale(0.4); } 60% { transform: scale(1.15); } }
@keyframes ink { from { clip-path: inset(0 100% 0 0); } }
@keyframes arrive { from { transform: scale(0.97); } }

/* The finish: a summary card in the iOS style. */
.panel-foot { display: block; overflow: hidden; border-radius: 20px; background: rgba(48, 209, 88, 0.14); border: 0.5px solid rgba(48, 209, 88, 0.4); animation: pop 0.6s var(--spring) both; }
.panel-foot[data-open] { background: rgba(255, 159, 10, 0.14); border-color: rgba(255, 159, 10, 0.45); }
.panel-foot[hidden] { display: none; }
.ft-kicker { margin: 0; padding: 0.9em 1em 0; font-size: 0.82em; font-weight: 600; color: var(--green); }
.panel-foot[data-open] .ft-kicker { color: var(--orange); }
.ft-time { display: inline-block; padding: 0 0.2em 0 0.45em; font-size: 3em; font-weight: 700; line-height: 1.1; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.ft-unit { font-size: 0.85em; color: var(--label-2); }
.ft-grid { display: grid; grid-template-columns: 1fr 1fr; margin: 0.7em 0 0; border-top: 0.5px solid var(--sep); }
.ft-grid > div { padding: 0.7em 1em; }
.ft-grid > div:nth-child(odd) { border-right: 0.5px solid var(--sep); }
.ft-grid > div:nth-child(n + 3) { border-top: 0.5px solid var(--sep); }
.ft-grid dt { font-size: 0.75em; color: var(--label-2); }
.ft-grid dd { margin: 0.1em 0 0; font-size: 1.75em; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.ft-grid small { font-size: 0.55em; font-weight: 600; color: var(--label-2); }
.ft-grid .warn dd { color: var(--orange); }
.ft-note { margin: 0; padding: 0.8em 1em 1em; border-top: 0.5px solid rgba(255, 159, 10, 0.35); color: #FFC16B; font-size: 0.9em; font-weight: 500; line-height: 1.5; overflow-wrap: anywhere; }
[data-mode="done"] .panel-foot { order: 1; }
[data-mode="done"] .fields { order: 2; }
[data-mode="done"] .panel-hud { order: 3; }
[data-mode="done"] .fields li { padding: 0.45em 0.9em; }
[data-mode="done"] .f-kind { display: none; }

/* The live readout. */
.panel-hud { display: grid; grid-template-columns: 1fr auto; gap: 0.3em 1em; margin: auto 0.2em 0; padding-top: 0.8em; font-size: 0.74em; line-height: 1.3; color: var(--label-3); }
.panel-hud b { text-align: right; color: var(--label-2); font-weight: 500; font-variant-numeric: tabular-nums; }
.panel-hud b.warn { color: var(--orange); }

/* ---------- the handwriting card ---------- */
.readback {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 4;
  margin: 0;
  width: min(420px, calc(100% - 32px));
  border-radius: 24px;
  overflow: hidden;
  padding: 10px;
  max-height: calc(100% - 32px);
  overflow-y: auto;
  background: rgba(22, 23, 27, 0.94);
  animation: sheet-in 0.5s var(--spring) both;
  transition: box-shadow 0.35s var(--spring);
}
.readback[hidden] { display: none; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(24px) scale(0.97); } }
.readback img { display: block; width: 100%; max-height: 150px; object-fit: contain; border-radius: 16px; background: #F5F5F2; }
.readback figcaption { display: grid; gap: 9px; padding: 15px 12px 10px; }
.rb-label { font-size: 14px; font-weight: 600; line-height: 1.45; color: var(--label-2); overflow-wrap: anywhere; }
.rb-label::after { content: " · Reading…"; }
/* A readback is a proposal (yellow) until the person keeps it (green). */
.readback[data-state="ok"] { box-shadow: inset 0 0 0 2px var(--tint), 0 18px 50px rgba(0, 0, 0, 0.45); }
.readback[data-state="ok"] .rb-label::after { content: " · Is this right?"; color: var(--tint); }
.readback[data-state="unsure"] { box-shadow: inset 0 0 0 2px var(--orange), 0 18px 50px rgba(0, 0, 0, 0.45); }
.readback[data-state="unsure"] .rb-label::after { content: " · Partly unclear"; color: var(--orange); }
.readback[data-state="empty"] .rb-label::after { content: " · Nothing there yet"; color: var(--label); }
.readback[data-state="kept"] { box-shadow: inset 0 0 0 2px var(--green), 0 18px 50px rgba(0, 0, 0, 0.45); }
.readback[data-state="kept"] .rb-label::after { content: " · Kept"; color: var(--green); }
.rb-text { font-size: 34px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.16; min-height: 1.16em; overflow-wrap: anywhere; }
.rb-help { display: none; margin: 0; color: var(--label-2); font-size: 14px; line-height: 1.45; }
[data-mode="confirm"] .rb-help { display: block; }
.readback[data-state="reading"] .rb-text::after { content: ""; display: inline-block; width: 0.45em; height: 0.09em; border-radius: 1px; background: var(--tint); animation: blink 0.8s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.rb-redo { display: none; justify-self: start; margin-top: 3px; min-height: 48px; padding: 0 18px; border: 0.5px solid rgba(235, 235, 245, 0.22); border-radius: 999px; background: rgba(118, 118, 128, 0.22); font-size: 16px; font-weight: 600; cursor: pointer; transition: background-color 0.2s; }
[data-mode="confirm"] .rb-redo { display: inline-flex; align-items: center; }
@media (min-width: 1100px) {
  .readback { left: 20px; bottom: 20px; width: min(540px, 60%); }
  .rb-text { font-size: clamp(30px, 2.6vw, 52px); }
  .rb-label { font-size: 16px; }
  .readback img { max-height: 190px; }
}

/* ---------- start screen ---------- */
.start { position: fixed; inset: 0; z-index: 6; display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top)) 6vw max(24px, env(safe-area-inset-bottom)); overflow-y: auto; background: radial-gradient(70% 60% at 70% 40%, #141418 0%, #000 70%); }
[data-screen="run"] .start { display: none; }
[data-screen="start"] .caption, [data-screen="start"] .panel, [data-screen="start"] .bar { visibility: hidden; }
.start-hit { position: absolute; inset: 0; width: 100%; border: 0; background: transparent; color: transparent; cursor: pointer; }
.start-hit:focus-visible { outline-offset: -8px; }
.start-grid { position: relative; pointer-events: none; display: grid; gap: 6vw; align-items: center; width: min(1400px, 100%); }
.start-body { position: relative; display: grid; justify-items: start; gap: 20px; max-width: 720px; }
.start-body .controls, .start-body a { pointer-events: auto; }
.hero-icon { width: 76px; height: 76px; border-radius: 19px; animation: rise 0.8s var(--spring) both; }
.hero { margin: 0; font-size: clamp(46px, 5.4vw, 92px); font-weight: 700; line-height: 1.035; letter-spacing: -0.045em; text-wrap: balance; animation: rise 0.8s 0.06s var(--spring) both; }
.lede { margin: 0; max-width: 34ch; font-size: clamp(19px, 1.5vw, 25px); line-height: 1.42; color: var(--label-2); letter-spacing: -0.015em; text-wrap: pretty; animation: rise 0.8s 0.12s var(--spring) both; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }
.cta { margin: 6px 0 0; animation: rise 0.8s 0.18s var(--spring) both; }
.tab { display: inline-flex; align-items: center; min-height: 64px; padding: 0 34px; border-radius: 999px; background: var(--label); color: #000; font-size: clamp(18px, 1.35vw, 22px); font-weight: 600; letter-spacing: -0.015em; box-shadow: 0 8px 26px rgba(255, 255, 255, 0.09); }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 20px; animation: rise 0.8s 0.24s var(--spring) both; }
/* The language picker is an iOS segmented control. */
.langs { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 14px; background: var(--fill); }
.langs button { min-height: 44px; padding: 0 18px; border: 0; border-radius: 11px; background: transparent; font-weight: 600; font-size: 16px; cursor: pointer; transition: background-color 0.25s var(--spring); }
.langs button[aria-pressed="true"] { background: #636366; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25), inset 0 0.5px 0 rgba(255, 255, 255, 0.2); }
.cam { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; color: var(--label-2); }
.cam[hidden], [data-sim] .cam { display: none; }
.cam select { min-height: 44px; max-width: 260px; padding: 0 12px; border: 0; border-radius: 12px; background: var(--fill); font-size: 16px; color: var(--label); }
.status { margin: 0; min-height: 1.3em; font-size: 15px; line-height: 1.45; color: var(--label-3); max-width: 60ch; }
.status:empty { display: none; }
[data-reader="on"] .reader { color: var(--label-2); }
[data-reader="on"] .reader::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--green); vertical-align: 1px; }
.mode-link { color: var(--tint); font-size: 17px; font-weight: 600; text-decoration: none; }
.alert { max-width: 40ch; padding: 16px 20px; border-radius: 20px; background: rgba(255, 69, 58, 0.16); border: 0.5px solid rgba(255, 69, 58, 0.5); }
.alert[hidden] { display: none; }
.alert strong { display: block; font-size: clamp(20px, 1.8vw, 26px); font-weight: 700; letter-spacing: -0.02em; }
.alert p { margin: 6px 0 0; color: var(--label-2); font-size: 17px; }
.alert:not([hidden]) ~ .mode-link, [data-reader="off"] .mode-link { display: inline-grid; place-items: center; min-height: 48px; padding: 0 22px; border-radius: 999px; background: rgba(255, 214, 10, 0.16); }

/* The demo: a page under the camera, Live Text brackets hopping from blank to blank. */
.demo { display: none; margin: 0; position: relative; }
@media (min-width: 1100px) {
  .start-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr); }
  .demo { display: block; }
}
.demo-glow { position: absolute; inset: 10% 6%; border-radius: 40px; background: conic-gradient(from 200deg, #BC82F3, #F5B9EA, #8D9FFF, #FF6778, #FFBA71, #C686FF, #BC82F3); filter: blur(70px); opacity: 0.32; animation: breathe 5s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: 0.18; transform: scale(0.97); } }
.demo-paper { position: relative; aspect-ratio: 8.5 / 11; max-height: 72vh; margin-inline: auto; border-radius: 14px; background: #F5F5F2; box-shadow: 0 50px 100px rgba(0, 0, 0, 0.55), 0 0 0 0.5px rgba(255, 255, 255, 0.3); transform: perspective(1600px) rotateY(-9deg) rotateX(4deg); animation: rise 1s 0.2s var(--spring) both; overflow: hidden; }
.demo-paper i { position: absolute; left: 10%; display: block; }
.demo-title { top: 8%; width: 46%; height: 3.4%; border-radius: 4px; background: #1C1C1E; }
.demo-sub { top: 14%; width: 30%; height: 1.4%; border-radius: 2px; background: #8E8E93; }
.demo-row { top: var(--y); width: 80%; height: 1.4%; }
.demo-row::before { content: ""; position: absolute; left: 0; bottom: 0; width: 22%; height: 100%; border-radius: 2px; background: #8E8E93; }
.demo-row::after { content: ""; position: absolute; left: 28%; right: 0; bottom: 0; height: 2px; background: #3A3A3C; }
.demo-text { top: var(--y); width: var(--w, 78%); height: 1.2%; border-radius: 2px; background: #AEAEB2; }
/* Live Text corner brackets around the blank in play, hopping down the form */
.demo-target { position: absolute; left: 31%; width: 61%; height: 7%; top: 25.5%; animation: hop 7.5s var(--spring) infinite; }
.demo-target::before { content: ""; position: absolute; inset: 0; border-radius: 8px; background: rgba(255, 214, 10, 0.38); mix-blend-mode: multiply; }
.demo-target i { position: absolute; width: 18px; height: 18px; border: 3.5px solid var(--tint); left: auto; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3)); }
.demo-target i:nth-child(1) { top: -7px; left: -7px; border-right: 0; border-bottom: 0; border-top-left-radius: 10px; }
.demo-target i:nth-child(2) { top: -7px; right: -7px; border-left: 0; border-bottom: 0; border-top-right-radius: 10px; }
.demo-target i:nth-child(3) { bottom: -7px; left: -7px; border-right: 0; border-top: 0; border-bottom-left-radius: 10px; }
.demo-target i:nth-child(4) { bottom: -7px; right: -7px; border-left: 0; border-top: 0; border-bottom-right-radius: 10px; }
@keyframes hop { 0%, 30% { top: 25.5%; } 36%, 63% { top: 39.5%; } 69%, 94% { top: 53.5%; } 100% { top: 25.5%; } }
.demo-label { position: absolute; left: 31%; top: 16%; padding: 7px 14px; border-radius: 999px; background: #fff; color: #000; font-size: clamp(13px, 0.9vw, 16px); font-weight: 600; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25); animation: hop-label 7.5s var(--spring) infinite; }
.demo-label::after { content: ""; position: absolute; left: 22px; bottom: -6px; border: 6px solid transparent; border-bottom: 0; border-top-color: #fff; }
@keyframes hop-label { 0%, 30% { top: 16%; } 36%, 63% { top: 30%; } 69%, 94% { top: 44%; } 100% { top: 16%; } }
.demo-tip { position: absolute; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.35); animation: tip 7.5s var(--spring) infinite; }
.demo-tip::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: #fff; }
@keyframes tip {
  0% { left: 72%; top: 82%; }
  22%, 30% { left: 34%; top: 30.5%; border-color: var(--tint); }
  33% { left: 58%; top: 50%; border-color: #fff; }
  55%, 63% { left: 34%; top: 44.5%; border-color: var(--tint); }
  66% { left: 62%; top: 72%; border-color: #fff; }
  88%, 94% { left: 34%; top: 58.5%; border-color: var(--tint); }
  100% { left: 72%; top: 82%; border-color: #fff; }
}

/* ---------- caption: Live Captions on glass ---------- */
.caption { position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 18px; height: clamp(132px, 19vh, 220px); padding: 14px 16px 14px 14px; border-radius: var(--r-card); }
/* The cue: a rounded tile that shows where to move; it fills with yellow as the finger closes in. */
.cue {
  --close: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 2px;
  align-self: stretch;
  aspect-ratio: 1;
  border-radius: 20px;
  background: linear-gradient(to top, rgba(255, 255, 255, 0.16) calc(var(--close) * 100%), transparent calc(var(--close) * 100%)), var(--fill);
  color: var(--label);
  transition: background-color 0.3s var(--spring), color 0.3s;
}
.cue-glyph { font-size: clamp(48px, 4.6vw, 88px); font-weight: 600; line-height: 1; min-height: 1em; }
.cue-word { font-size: clamp(12px, 0.95vw, 16px); font-weight: 600; min-height: 1em; opacity: 0.8; }
.cue[data-cue="on"] { background: var(--tint); color: var(--tint-ink); animation: lock 0.45s var(--spring); }
@keyframes lock { 0% { transform: scale(0.88); } 60% { transform: scale(1.05); } }
.cue[data-cue="write"], .cue[data-cue="confirm"] { background: var(--tint); color: var(--tint-ink); }
.cue[data-cue="done"] { background: var(--green); color: #000; }
.cue[data-cue="error"] { background: var(--red); color: #fff; }
.cue[data-cue="listen"], .cue[data-cue="think"] { background: #fff; color: #000; }
.cue[data-cue="wait"] .cue-glyph::before, .cue[data-cue="think"] .cue-glyph::before {
  content: "";
  display: block;
  width: 0.56em; height: 0.56em;
  margin: 0.22em;
  border: 0.07em solid rgba(235, 235, 245, 0.2);
  border-top-color: var(--label);
  border-radius: 50%;
  animation: turn 0.9s linear infinite;
}
.cue[data-cue="think"] .cue-glyph::before { border-color: rgba(0, 0, 0, 0.15); border-top-color: #000; }
@keyframes turn { to { transform: rotate(360deg); } }
.cue[data-cue="listen"] .cue-glyph {
  width: 0.9em;
  height: 0.8em;
  background:
    linear-gradient(currentColor, currentColor) 0 50% / 0.14em 40% no-repeat,
    linear-gradient(currentColor, currentColor) 50% 50% / 0.14em 90% no-repeat,
    linear-gradient(currentColor, currentColor) 100% 50% / 0.14em 60% no-repeat;
  animation: level 0.9s ease-in-out infinite alternate;
}
@keyframes level { to { background-size: 0.14em 85%, 0.14em 35%, 0.14em 95%; } }

.caption-text { position: relative; margin: 0; align-self: center; max-height: 100%; overflow-y: auto; scrollbar-width: none; padding: 4px 6px; font-weight: 650; font-size: clamp(24px, min(2.7vw, 4.6vh), 52px); line-height: 1.16; letter-spacing: -0.025em; text-wrap: balance; }
.caption-text::-webkit-scrollbar { display: none; }
.caption-text span { color: rgba(245, 245, 250, 0.9); transition: color 0.15s; }
.caption-text span.said { color: var(--label); }
.caption-text span.now { color: var(--tint); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.12em; }
[data-talk] .caption-text span, [data-talk] .caption-text { color: var(--label); }

.buttons { display: flex; align-items: center; gap: 12px; }
.talk { display: flex; align-items: center; gap: 8px; min-height: 64px; padding: 0 24px 0 20px; border: 0; border-radius: 999px; background: rgba(118, 118, 128, 0.28); font-weight: 600; font-size: 19px; cursor: pointer; touch-action: none; user-select: none; transition: background-color 0.2s, color 0.2s, transform 0.25s var(--spring); }
.talk svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.talk svg rect { fill: currentColor; stroke: none; }
.talk[aria-pressed="true"] { background: #fff; color: #000; }
[data-screen="start"] .talk { display: none; }
.action { min-height: 64px; min-width: 180px; padding: 0 30px; border: 0; border-radius: 999px; background: var(--tint); color: var(--tint-ink); font-size: 19px; font-weight: 650; cursor: pointer; transition: transform 0.25s var(--spring), background-color 0.2s, color 0.2s; }
.action:active:not(:disabled), .talk:active { transform: scale(0.96); }
.action:disabled { background: var(--fill); color: var(--label-3); cursor: default; }
.action:focus-visible { outline-color: #fff; }
@media (hover: hover) {
  .action:hover:not(:disabled) { background: #FFE14D; }
  .talk:hover { background: rgba(118, 118, 128, 0.4); }
  .langs button:hover:not([aria-pressed="true"]) { background: var(--fill); }
  .rb-redo:hover { background: rgba(118, 118, 128, 0.42); }
}
@media (min-width: 1100px) {
  .action, .talk { min-height: 72px; font-size: 22px; }
  .action { min-width: 220px; }
  .talk svg { width: 26px; height: 26px; }
}

/* ---------- iPhone ---------- */
@media (max-width: 720px) {
  :root { --r-card: 22px; }
  .bar { grid-template-columns: auto 1fr auto; gap: 6px 10px; min-height: 0; padding: 8px 14px 10px 8px; border-radius: 20px; }
  .app-icon { width: 32px; height: 32px; border-radius: 9px; }
  .wordmark { font-size: 19px; }
  .doc-context { display: contents; }
  .session-kicker { grid-column: 2; grid-row: 1; gap: 4px 8px; font-size: 13px; }
  #sessionMode { padding: 3px 6px; }
  .doc { grid-column: 1 / -1; grid-row: 2; margin: 0 4px; font-size: 13px; }
  .current-field { grid-column: 1 / -1; grid-row: 2; margin: 2px 4px 0; font-size: 24px; line-height: 1.15; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  [data-field-active] .doc { grid-row: 3; font-size: 12px; }
  .steps { display: contents; }
  .count { grid-column: 3; grid-row: 1; font-size: 13px; }
  .progress { grid-column: 1 / -1; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; margin-left: 6px; }
  .progress li, .progress li[data-state="active"] { width: auto; height: 4px; }
  .caption { height: auto; grid-template-columns: 60px auto 1fr; grid-template-areas: "text text text" "cue ask act"; gap: 10px; padding: 14px; }
  .buttons { display: contents; }
  .caption-text { grid-area: text; padding: 0 4px; font-size: clamp(20px, 5.6vw, 25px); line-height: 1.22; height: calc(3 * 1.22em + 2px); max-height: none; }
  .cue { grid-area: cue; aspect-ratio: auto; min-height: 64px; border-radius: 18px; }
  .cue-glyph { font-size: 30px; }
  .cue-word { font-size: 10px; }
  .talk { grid-area: ask; min-height: 64px; padding: 0 18px; }
  .action { grid-area: act; min-width: 0; padding: 0 14px; font-size: clamp(15px, 4.4vw, 18px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .readback { left: 10px; right: 10px; top: 10px; bottom: auto; width: auto; max-height: calc(100% - 20px); }
  .readback img { max-height: 110px; }
  .readback figcaption { padding: 12px 8px 8px; }
  .rb-text { font-size: 30px; }
  .rb-label, .rb-help { font-size: 14px; }
  .start { place-items: end start; padding: 20px 18px max(28px, env(safe-area-inset-bottom)); }
  .start-body { gap: 16px; }
  .hero-icon { width: 64px; height: 64px; border-radius: 16px; }
  .hero { font-size: clamp(39px, 10.8vw, 52px); }
  .langs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; }
  .langs button { padding: 0 6px; font-size: 14px; }
}

/* Short landscape screens keep the same camera fit and reserve space for cues. */
@media (min-width: 721px) and (max-height: 480px) {
  .bar { padding-top: 6px; padding-bottom: 6px; }
  .doc-context { gap: 2px; }
  .current-field { font-size: 22px; }
  [data-field-active] .doc { font-size: 12px; }
  .caption { height: 108px; padding: 11px 14px; gap: 14px; }
  .caption-text { font-size: 24px; }
  .cue-glyph { font-size: 38px; }
  .cue-word { font-size: 11px; }
  .talk { padding-inline: 18px; font-size: 17px; }
  .action { min-width: 160px; font-size: 17px; padding-inline: 22px; }
  .readback { top: 10px; bottom: auto; max-height: calc(100% - 20px); }
  .readback img { max-height: 60px; }
  .readback figcaption { padding-top: 9px; gap: 6px; }
  .rb-text { font-size: 27px; }
  .start { place-items: start center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .fields li[data-just] { box-shadow: inset 0 0 0 2px currentColor; }
  [data-talk] .view::after, [data-mode="reading"] .view::after { opacity: 0.8; }
}

a.brand { min-height: 44px; color: inherit; text-decoration: none; border-radius: 12px; }
a.brand:focus-visible { outline: 3px solid var(--tint); outline-offset: 3px; }
.around-link { display: inline-grid; place-items: center; min-height: 48px; padding: 0 22px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); color: var(--label, #fff); }

/* Shared Nib chrome. The camera stage, view, video, canvas and fitting rules above stay unchanged. */
.skip-link { position: fixed; left: 16px; top: 12px; z-index: 100; padding: 18px 24px; border-radius: 14px; background: var(--tint); color: #000; font-weight: 700; transform: translateY(-160%); }
.skip-link:focus { transform: none; }
.glass { background: rgba(18, 18, 18, .88); border-color: #38383b; box-shadow: none; }
.ambient { background: #000; }
.ambient::after { background: rgba(0, 0, 0, .4); }
.start { background: #000; }
.demo-glow { display: none; }
.view::after { background: var(--tint); filter: blur(4px); animation: none; }
.brand, .start-home { min-height: 64px; color: var(--label); text-decoration: none; }
.home-label { padding-left: 10px; border-left: 1px solid #38383b; color: var(--label-2); font-size: 14px; font-weight: 500; }
.start-nav { position: absolute; z-index: 2; top: max(16px, env(safe-area-inset-top)); left: max(24px, 6vw); right: max(24px, 6vw); display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--label-2); font-size: 14px; }
.start-home { display: inline-flex; align-items: center; gap: 10px; padding-right: 10px; border-radius: 12px; }
.start-home img { border-radius: 10px; }
.mode-eyebrow { margin: 0; color: var(--tint); font-size: 13px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; }
.start-body { gap: 16px; }
.start-body .lede { max-width: 38ch; }
.paper-mode-links { display: flex; gap: 10px; width: 100%; pointer-events: auto; }
.paper-mode-links .mode-link { flex: 1; min-height: 64px; font-size: 16px; text-align: center; }
.mode-link { display: inline-flex; align-items: center; min-height: 64px; }
.langs button, .cam select, .rb-redo { min-height: 64px; }
.start-body .langs button { min-height: 64px; }
@media (max-width: 720px) {
  .bar .wordmark { display: none; }
  .bar .home-label { padding: 0; border: 0; color: var(--label); }
  .start { padding-top: max(104px, calc(env(safe-area-inset-top) + 96px)); place-items: start; }
  .start-nav { left: 20px; right: 20px; }
  .start-body { gap: 13px; }
  .mode-eyebrow { font-size: 12px; }
  .start-body .hero { font-size: clamp(39px, 10.8vw, 52px); }
  .paper-mode-links .mode-link { font-size: 15px; }
}
@media (min-width: 721px) and (max-height: 600px) {
  .start { padding-top: 108px; }
}
