/* Claude Skills Team OS demo page, "drawing set". Tokens live in tokens.css (loaded first).
   Commercial real estate runs on drawings, and nothing gets built until a drawing is stamped;
   here nothing gets saved until the broker confirms. Blueprint paper with a 24px grid, navy ink,
   line blue, amber for what is still waiting, red ink for a refusal. Square corners, hairline
   rules, mono uppercase labels, and a title block (the bottom strip of a drawing) on the read
   back card. Layout rules from the review fixes stay: a story band on desktop, a bottom sheet on
   phones, 44px touch targets, the step 2 fit. */

/* =====================================================================
   BASE
   ===================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; color: var(--color-text);
  background-color: var(--color-bg);
  background-image: linear-gradient(var(--color-grid) 1px, transparent 1px), linear-gradient(90deg, var(--color-grid) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
  font-family: var(--font-sans); font-size: var(--text-base); line-height: var(--leading-base);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p, ol, ul, dl, dd, figure, blockquote { margin: 0; }
ol, ul { padding: 0; list-style: none; }
button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--color-accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.i { width: var(--icon-md); height: var(--icon-md); flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: square; stroke-linejoin: miter; }
.i-sm { width: var(--icon-sm); height: var(--icon-sm); }
code { font-family: var(--font-mono); font-size: 12px; }

/* the mono label: sheet numbers, title block fields, tags */
.story-kicker, .kicker, .pane-eyebrow, .group-label, .rb-kicker, .rb-kind, .rows dt, .rb-list b, .time-box > span,
.tb-cell > span, .tag, .skill, .pill, .pipe-head, .pipe-k, .pipe-cell em, .fig-bar, .fig-quote > span, .fig-note,
.stamp, .hero-points span, .saved-kind, .log .at, .hood-body h4, .usage dt, .table th, .story-figures span {
  font-family: var(--font-mono); text-transform: uppercase; letter-spacing: var(--tracking-caps); font-weight: var(--weight-medium);
}

/* =====================================================================
   PRIMITIVES
   ===================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--control-md); padding: 0 var(--space-4); border-radius: var(--radius-md);
  border: 1px solid transparent; font-size: var(--text-base); font-weight: var(--weight-semibold); white-space: nowrap;
  transition: background var(--duration-fast), border-color var(--duration-fast), color var(--duration-fast), box-shadow var(--duration-fast);
}
.btn .i { width: 15px; height: 15px; stroke-width: 1.9; }
.btn-sm { height: 32px; padding: 0 var(--space-3); font-size: var(--text-sm); }
.btn-lg { height: 52px; padding: 0 var(--space-6); font-size: var(--text-lg); }
.btn-primary { background: var(--color-ink); color: var(--color-on-ink); }
.btn-primary:hover { background: var(--color-ink-hover); }
.btn-primary:active { background: var(--color-accent-pressed); }
.btn-secondary { background: var(--color-surface); border-color: var(--color-border-strong); color: var(--color-text); font-weight: var(--weight-medium); }
.btn-secondary:hover { background: var(--color-surface-hover); border-color: var(--color-accent); }
.btn-ghost { color: var(--color-accent-text); font-weight: var(--weight-medium); }
.btn-ghost:hover { background: var(--color-surface-hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: 0; box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-accent); }
.btn-link { color: var(--color-accent-text); font-size: var(--text-md); font-weight: var(--weight-medium); padding: var(--space-2); min-height: 44px; text-decoration: underline; text-decoration-color: var(--color-accent-border); text-underline-offset: 4px; }
.btn-link:hover { color: var(--color-text); text-decoration-color: currentColor; }

.seg { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--radius-md); background: var(--color-control-track); border: 1px solid var(--color-border); }
.seg button {
  display: inline-flex; align-items: center; gap: var(--space-1-5); height: 30px; padding: 0 var(--space-3);
  border-radius: var(--radius-sm); font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--color-text-secondary); white-space: nowrap;
}
.seg button:hover { color: var(--color-text); }
.seg button[aria-pressed="true"] { background: var(--color-control-selected); color: var(--color-text); box-shadow: 0 0 0 1px var(--color-border-strong); }
.seg button:disabled { opacity: .45; cursor: not-allowed; }
.live-dot { width: 6px; height: 6px; background: var(--color-text-tertiary); }
[aria-pressed="true"] .live-dot { background: var(--color-accent); }

.pill {
  display: inline-flex; align-items: center; gap: var(--space-1-5); height: 22px; padding: 0 var(--space-2);
  border-radius: var(--radius-xs); font-size: 10.5px; white-space: nowrap; border: 1px solid transparent; flex: none;
}
.pill::before { content: ""; width: 6px; height: 6px; background: currentColor; }
.pill-plain::before { display: none; }
.pill-pending { background: var(--color-amber-soft); color: var(--color-amber-text); border-color: var(--color-amber-border); }
.pill-saved { background: transparent; color: var(--color-stamp); border-color: currentColor; }
.pill-refused { background: var(--color-danger-soft); color: var(--color-danger-text); border-color: var(--color-danger-border); }
.pill-quiet { background: var(--color-surface-muted); color: var(--color-text-secondary); border-color: var(--color-border); }
.pill-short { display: none; }
.count {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--radius-xs);
  background: var(--color-amber-soft); color: var(--color-amber-text); border: 1px solid var(--color-amber-border);
  font-family: var(--font-mono); font-size: 11px; font-weight: var(--weight-semibold); line-height: 1;
}

/* the stamp: lands on what was decided */
.stamp {
  display: inline-flex; align-items: center; gap: var(--space-1-5); padding: 3px 9px; border: 2px solid currentColor;
  outline: 1px solid currentColor; outline-offset: 2px; border-radius: var(--radius-xs); font-size: 12px; font-weight: var(--weight-semibold);
  letter-spacing: .12em; line-height: 16px; white-space: nowrap; rotate: -6deg; opacity: .94; pointer-events: none;
}
.stamp-saved { color: var(--color-stamp); }
.stamp-refused { color: var(--color-danger); }
.stamp.anim { animation: stamp 560ms var(--ease-stamp) both; animation-delay: var(--age, 0ms); }
@keyframes stamp {
  0% { opacity: 0; scale: 1.9; rotate: -16deg; }
  65% { opacity: 1; scale: .95; rotate: -5deg; }
  100% { opacity: .94; scale: 1; rotate: -6deg; }
}
@keyframes rise { from { opacity: 0; translate: 0 14px; } to { opacity: 1; translate: 0 0; } }
@keyframes slide { from { opacity: 0; translate: 28px 0; } to { opacity: 1; translate: 0 0; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes pop { from { opacity: 0; scale: .2; } to { opacity: 1; scale: 1; } }

/* =====================================================================
   APP FRAME
   ===================================================================== */
body.app-body { overflow: hidden; }
.app { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--topbar-height) auto minmax(0, 1fr); height: 100vh; height: 100dvh; }
.topbar {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-6);
  padding: 0 var(--space-8) 0 var(--space-10); background: var(--color-bg); border-bottom: 1px solid var(--color-border);
  position: relative; z-index: 5;
}
.brand { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.brand-mark { width: 32px; height: 32px; flex: none; }
.brand-mark rect { fill: var(--color-ink); }
.brand-mark path { fill: none; stroke: var(--color-bg); stroke-width: 1.6; }
.brand-text { min-width: 0; display: grid; }
.brand-name { font-size: var(--text-md); line-height: 20px; font-weight: var(--weight-semibold); white-space: nowrap; }
.brand-sub { font-family: var(--font-mono); font-size: 10.5px; line-height: 15px; letter-spacing: .06em; text-transform: uppercase; color: var(--color-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); }
.top-actions .btn { height: 44px; }
.phone-only { display: none !important; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) clamp(380px, 34vw, 540px); min-height: 0; }

/* ---------- the broker's side: a sheet on the paper */
.broker-pane { display: flex; flex-direction: column; align-items: center; min-height: 0; padding: var(--space-5) var(--space-8) 0; }
.pane-eyebrow {
  width: 100%; max-width: var(--chat-max-width); display: flex; align-items: center; gap: var(--space-2);
  height: 20px; margin-bottom: var(--space-2); font-size: 11px; color: var(--color-text-secondary); transition: color var(--duration-slow);
}
.pane-eyebrow .i { width: 13px; height: 13px; }
.messenger {
  position: relative; flex: 1; min-height: 0; width: 100%; max-width: var(--chat-max-width);
  display: flex; flex-direction: column; background: var(--color-surface); border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; transition: box-shadow var(--duration-slow), border-color var(--duration-slow);
}
.fiction-note { width: 100%; max-width: var(--chat-max-width); padding: var(--space-3) var(--space-2); font-family: var(--font-mono); font-size: 11px; line-height: 15px; letter-spacing: .03em; color: var(--color-text-secondary); text-align: center; }
.m-head { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-4); border-bottom: 1px solid var(--color-border); min-height: 52px; }
.avatar { position: relative; width: 30px; height: 30px; border-radius: var(--radius-sm); background: var(--color-accent-soft); color: var(--color-accent-text); border: 1px solid var(--color-accent-border); display: grid; place-items: center; flex: none; }
.avatar svg { width: 16px; height: 16px; fill: currentColor; stroke: none; }
.avatar.sm { width: 26px; height: 26px; }
.avatar.sm svg { width: 14px; height: 14px; }
.m-title { font-size: var(--text-base); line-height: 18px; font-weight: var(--weight-semibold); }
.m-status { font-size: var(--text-xs); line-height: var(--leading-xs); color: var(--color-text-secondary); margin-top: 1px; }

.thread { position: relative; flex: 1; min-height: 0; overflow-y: auto; padding: var(--space-5) var(--space-5) var(--space-8); display: flex; flex-direction: column; gap: var(--space-5); scrollbar-width: thin; scrollbar-color: var(--color-border-strong) transparent; }
.out-row { display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-1); }
.bubble { max-width: min(82%, var(--bubble-max-width)); padding: 10px var(--space-4); border-radius: var(--radius-md); font-size: var(--text-md); line-height: var(--leading-md); overflow-wrap: anywhere; }
.bubble-out { background: var(--color-bubble-out); color: var(--color-bubble-out-text); border: 1px solid var(--color-border); white-space: pre-wrap; }

.bot { display: grid; grid-template-columns: 26px minmax(0, 1fr); column-gap: var(--space-3); row-gap: var(--space-2); align-items: start; }
.bot > .avatar { grid-row: 1; }
.bot > :not(.avatar) { grid-column: 2; min-width: 0; }
.bot-head { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-1-5) var(--space-2); min-height: 26px; }
.bot-name { font-size: var(--text-base); font-weight: var(--weight-semibold); }
.tag { font-size: 10px; letter-spacing: .05em; color: var(--color-text-secondary); border: 1px solid var(--color-border-strong); border-radius: var(--radius-xs); padding: 0 5px; line-height: 17px; }
.answer { font-size: var(--text-md); line-height: var(--leading-md); overflow-wrap: anywhere; max-width: 640px; }
.answer ul { list-style: disc; padding-left: 20px; margin: 2px 0; }
.answer strong { font-weight: var(--weight-semibold); }

/* the skill badge: which skill loaded for this reply */
.skill {
  display: inline-flex; align-items: flex-start; gap: var(--space-1-5); min-height: 24px; padding: 3px 8px; max-width: 100%;
  border: 1px solid var(--color-border-strong); border-radius: var(--radius-xs); background: var(--color-surface);
  font-size: 10.5px; line-height: 16px; letter-spacing: .04em; color: var(--color-accent-text); white-space: normal; overflow-wrap: anywhere;
}
.skill .i { width: 12px; height: 12px; flex: none; margin-top: 2px; stroke-width: 1.2; }
.skill b { font-weight: var(--weight-semibold); }
.skill.none { color: var(--color-text-secondary); border-style: dashed; }

/* what Claude looked at */
.trace { max-width: 640px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); }
.trace > summary { display: flex; align-items: center; gap: var(--space-2); padding: 7px var(--space-3); list-style: none; cursor: pointer; font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--color-text-secondary); }
.trace > summary::-webkit-details-marker { display: none; }
.trace > summary:hover { color: var(--color-text); }
.trace > summary .chev { margin-left: auto; transition: transform var(--duration-base) var(--ease-out); color: var(--color-text-tertiary); }
.trace[open] > summary .chev { transform: rotate(180deg); }
.trace > summary .ok { color: var(--color-accent-text); }
.steps { padding: 0 var(--space-3) var(--space-3); display: grid; gap: var(--space-2); }
.steps li { position: relative; display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: var(--space-2); font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--color-text-secondary); }
.tick { width: 16px; height: 16px; margin-top: 1px; border-radius: var(--radius-xs); display: grid; place-items: center; background: var(--color-accent-soft); color: var(--color-accent-text); border: 1px solid var(--color-accent-border); }
.tick .i { width: 10px; height: 10px; stroke-width: 2.6; }
.tick.no { background: var(--color-danger-soft); color: var(--color-danger-text); border-color: var(--color-danger-border); }
.tick.blocked { background: var(--color-amber-soft); color: var(--color-amber-text); border-color: var(--color-amber-border); }

.working { display: inline-grid; gap: var(--space-2); padding: 10px var(--space-4); background: var(--color-surface-subtle); border: 1px dashed var(--color-border-strong); border-radius: var(--radius-md); max-width: 640px; justify-self: start; }
.working-head { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--color-text-secondary); }
.working .steps { padding: 0; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 5px; height: 5px; background: var(--color-accent); animation: blink 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.sys-line { align-self: center; display: inline-flex; align-items: center; gap: var(--space-1-5); font-family: var(--font-mono); font-size: 11px; letter-spacing: .03em; color: var(--color-text-secondary); text-align: center; }
.sys-line.saved { color: var(--color-stamp); }

/* =====================================================================
   THE READ BACK CARD: a drawing waiting for its stamp
   ===================================================================== */
.rb {
  position: relative; max-width: 720px; container-type: inline-size; border: 1px solid var(--color-border-strong); border-radius: var(--radius-lg);
  background: var(--color-surface); box-shadow: var(--shadow-lg); scroll-margin: var(--space-3);
}
.rb.anim { animation: rise 520ms var(--ease-out) both; animation-delay: var(--age, 0ms); }
.rb-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 11px 18px; border-bottom: 1px solid var(--color-border); }
.rb-headline { display: grid; gap: 1px; min-width: 0; }
.rb-kicker { font-size: 10.5px; line-height: 15px; color: var(--color-accent-text); }
.rb-sum { font-size: var(--text-lg); line-height: 22px; font-weight: var(--weight-semibold); overflow-wrap: anywhere; }
.rb-sum:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; }
.tb-flags { display: none; }
.rb-body { display: grid; }
.rb-col { display: grid; align-content: start; gap: var(--space-3); padding: 14px 18px; min-width: 0; }
@container (min-width: 560px) {
  .rb-body.two { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
  .rb-body.two > .rb-col + .rb-col { border-left: 1px solid var(--color-border); }
}
@container (max-width: 559px) {
  .rb-body.two > .rb-col + .rb-col { border-top: 1px solid var(--color-border); }
}
.rb-item { display: grid; gap: var(--space-2); }
.rb-item + .rb-item { border-top: 1px dashed var(--color-border); padding-top: var(--space-3); }
.rb-kind { display: flex; align-items: center; gap: var(--space-1-5); font-size: 10.5px; line-height: 15px; color: var(--color-text-secondary); }
.rb-kind .i { width: 13px; height: 13px; }
.rows { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px var(--space-4); font-size: var(--text-base); line-height: 20px; }
.rows dt { font-size: 10.5px; line-height: 20px; color: var(--color-text-secondary); }
.rows dd { color: var(--color-text); overflow-wrap: anywhere; }
.rb-list { display: grid; gap: 2px; font-size: var(--text-base); line-height: 20px; }
.rb-list b { display: block; font-size: 10.5px; line-height: 16px; color: var(--color-text-secondary); }
.rb-list ul { list-style: square; padding-left: 18px; color: var(--color-text); }
.rb-list li::marker { color: var(--color-accent); }
.rb-tasks { display: grid; }
.rb-tasks li { display: grid; gap: 2px; padding: var(--space-2) 0; border-bottom: 1px dashed var(--color-border); font-size: var(--text-base); line-height: 20px; }
.rb-tasks li:first-child { padding-top: 0; }
.rb-tasks li:last-child { border-bottom: 0; padding-bottom: 0; }
.rb-task-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.rb-task-head > span:first-child { min-width: 0; overflow-wrap: anywhere; font-weight: var(--weight-medium); }
.rb-tasks small, .saved-list small { font-size: var(--text-xs); line-height: var(--leading-xs); color: var(--color-text-secondary); }
.warn-line { display: block; color: var(--color-amber-text) !important; }
.rb-flags { gap: var(--space-1); }
.rb-flags .rb-kind { color: var(--color-amber-text); }
.rb-flags ul { list-style: square; padding-left: 18px; font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--color-amber-text); }
.rb.fit .rb-body { overflow-y: auto; box-shadow: var(--shadow-scroll); scrollbar-width: thin; }
.due {
  flex: none; font-family: var(--font-mono); font-size: 11px; line-height: 18px; padding: 0 6px; border-radius: var(--radius-xs);
  border: 1px solid var(--color-border); color: var(--color-text-secondary); white-space: nowrap; letter-spacing: .02em;
}
.due.exact { border-color: var(--color-accent-border); color: var(--color-accent-text); }
.due.flagged { border-color: var(--color-amber-border); background: var(--color-amber-soft); color: var(--color-amber-text); }

/* the title block: the bottom strip of the drawing */
.rb-foot { border-top: 2px solid var(--color-ink); }
.times { display: flex; flex-wrap: wrap; }
.time-box, .tb-cell { flex: 1 1 0; min-width: 0; display: grid; align-content: start; gap: 2px; padding: 11px 18px 12px; }
.times > * + * { border-left: 1px solid var(--color-border); }
.time-box > span, .tb-cell > span { display: block; font-size: 10px; line-height: 14px; color: var(--color-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.time-box b, .tb-cell b { display: block; font-size: var(--text-md); line-height: 20px; font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.time-box small, .tb-cell small { display: block; font-size: var(--text-xs); line-height: 16px; color: var(--color-text-secondary); }
.time-box.flagged { background: var(--color-amber-soft); }
.time-box.flagged > span, .time-box.flagged small { color: var(--color-amber-text); }
.time-box.flagged b { color: var(--color-amber-strong); }
.time-box.exact > span { color: var(--color-accent-text); }
.tb-approve { flex: 0 0 auto; position: relative; align-content: center; }
.tb-approve.is-signed { flex: 1.3 1 0; }
.rb-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-top: 4px; }
.rb-actions .btn { height: 40px; }
.tb-approve.is-signed { padding-right: 140px; }
.tb-approve .stamp { position: absolute; right: 16px; top: 50%; translate: 0 -50%; }
.rb-done { display: flex; align-items: center; gap: var(--space-2); padding: 12px 18px; font-size: var(--text-sm); color: var(--color-text-secondary); }
.rb-done .i { color: var(--color-text-tertiary); }
.rb.is-saved { border-color: var(--color-border-strong); }
.rb.is-off { box-shadow: none; }
.rb.is-off .rb-body { opacity: .7; }
.rb.is-off .rb-foot { border-top-width: 1px; border-top-color: var(--color-border); }

/* a test row: something tried and refused, in red ink */
.event {
  position: relative; display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: var(--space-1) var(--space-3); align-items: center;
  padding: 12px 18px 12px 14px; border: 1px solid var(--color-danger-border); background: var(--color-danger-soft); border-radius: var(--radius-lg);
}
.event.anim { animation: rise 420ms var(--ease-out) both; animation-delay: var(--age, 0ms); }
.event > .i { color: var(--color-danger-text); width: 20px; height: 20px; align-self: start; margin-top: 1px; }
.event-text { min-width: 0; display: grid; gap: 2px; }
.event-head { font-size: var(--text-base); line-height: 20px; font-weight: var(--weight-semibold); color: var(--color-danger-text); }
.event-body { font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--color-text); }
.event .stamp { font-size: 14px; padding: 4px 12px; margin-left: var(--space-2); }
.event.let-through { border-color: var(--color-border-strong); background: var(--color-surface); }
.event.let-through > .i, .event.let-through .event-head { color: var(--color-text); }

/* chips (suggested messages) */
.chip {
  flex: none; display: inline-flex; align-items: center; gap: var(--space-1-5); height: 32px; padding: 0 var(--space-3);
  border-radius: var(--radius-md); border: 1px solid var(--color-border-strong); background: var(--color-surface);
  font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--color-text); white-space: nowrap;
  transition: border-color var(--duration-fast), color var(--duration-fast), background var(--duration-fast);
}
.chip:hover { border-color: var(--color-accent); color: var(--color-accent-text); background: var(--color-accent-soft); }
.chip .i { width: 14px; height: 14px; }
.chip-near { border-style: dashed; color: var(--color-text-secondary); }
.chip-test { border-style: dashed; }
.chip-test .i { color: var(--color-danger-text); }
.suggest { position: relative; display: flex; gap: var(--space-2); overflow-x: auto; padding: var(--space-1) var(--space-4) var(--space-2); scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent); }
.suggest::-webkit-scrollbar { display: none; }
.thread-fade { position: relative; height: 0; }
.thread-fade::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 24px; background: linear-gradient(to bottom, transparent, var(--color-surface)); pointer-events: none; }

.composer { padding: var(--space-1) var(--space-4) var(--space-4); }
.composer-box {
  display: flex; align-items: flex-end; gap: var(--space-2); padding: 6px 6px 6px 14px; border-radius: var(--radius-md);
  border: 1px solid var(--color-border-strong); background: var(--color-surface);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.composer-box:focus-within { border-color: var(--color-accent); box-shadow: var(--shadow-focus); }
.composer textarea { flex: 1; min-height: 32px; max-height: 120px; padding: 5px 0; border: 0; outline: 0; resize: none; background: transparent; font-size: var(--text-md); line-height: var(--leading-md); color: var(--color-text); }
.composer textarea::placeholder { color: var(--color-text-tertiary); }
.composer textarea[readonly] { color: var(--color-text-secondary); cursor: default; }
.send { width: 34px; height: 34px; border-radius: var(--radius-md); background: var(--color-ink); color: var(--color-on-ink); display: grid; place-items: center; flex: none; }
.send:hover { background: var(--color-ink-hover); }
.send:disabled { background: var(--color-surface-muted); color: var(--color-text-tertiary); cursor: default; }
.send .i { stroke-width: 2; }

/* =====================================================================
   THE CRM: a drawing register
   ===================================================================== */
.crm-pane { display: flex; flex-direction: column; min-height: 0; background: var(--color-surface); border-left: 1px solid var(--color-border); }
.crm-head { display: grid; gap: var(--space-2); padding: var(--space-5) var(--space-6) var(--space-4); border-bottom: 1px solid var(--color-border); }
.crm-head .pane-eyebrow { margin: 0; color: var(--color-text-secondary); }
.crm-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.crm-desc { font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--color-text-secondary); }
.cost-line { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--color-text-secondary); }
.cost-line strong { color: var(--color-text); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* the pipeline strip */
.pipe-wrap { display: grid; gap: var(--space-1-5); margin-top: var(--space-1); }
.pipe-wrap:empty { display: none; }
.pipe-head { display: flex; justify-content: space-between; gap: var(--space-2); font-size: 10px; line-height: 14px; color: var(--color-text-secondary); }
.pipe { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); overflow: hidden; }
.pipe-cell { position: relative; display: grid; align-content: start; gap: 1px; padding: 7px 8px 8px; min-width: 0; transition: background var(--duration-slow); }
.pipe-cell + .pipe-cell { border-left: 1px solid var(--color-border); }
.pipe-k { font-size: 9.5px; line-height: 13px; letter-spacing: .02em; color: var(--color-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pipe-cell b { font-family: var(--font-mono); font-size: 20px; line-height: 24px; font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
.pipe-cell em { font-style: normal; font-size: 9px; line-height: 12px; letter-spacing: .06em; color: var(--color-accent-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pipe-cell.here { background: var(--color-accent-soft); box-shadow: inset 0 3px 0 var(--color-accent); }
.pipe-cell.here .pipe-k, .pipe-cell.here b { color: var(--color-accent-soft-text); }
.pipe-cell.moving { background: var(--color-amber-soft); box-shadow: inset 0 3px 0 var(--color-amber-line); }
.pipe-cell.moving em, .pipe-cell.moving .pipe-k { color: var(--color-amber-text); }

.panel { flex: 1; min-height: 0; overflow-y: auto; padding: var(--space-4) var(--space-6) var(--space-6); background: var(--color-surface); display: flex; flex-direction: column; gap: var(--space-3); scrollbar-width: thin; scrollbar-color: var(--color-border-strong) transparent; }
.group-label { display: flex; align-items: center; gap: var(--space-2); font-size: 10.5px; line-height: 15px; color: var(--color-text-secondary); margin-top: var(--space-2); }
.group-label::after { content: ""; flex: 1; height: 1px; background: var(--color-border); }
.group-label:first-child { margin-top: 0; }
.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); }
.rec { display: grid; gap: var(--space-3); padding: 14px var(--space-4); }
.rec.anim { animation: slide 560ms var(--ease-out) both; animation-delay: var(--age, 0ms); }
.rec-head .stamp { margin: 4px 4px 0 0; font-size: 11px; padding: 2px 8px; }
.rec.anim .saved-list li { animation: slide 480ms var(--ease-out) both; animation-delay: calc(var(--age, 0ms) + 220ms + var(--i, 0) * 90ms); }
.rec-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-3); align-items: start; }
.rec-title { font-size: var(--text-md); line-height: 21px; font-weight: var(--weight-semibold); overflow-wrap: anywhere; }
.rec-sub { font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--color-text-secondary); margin-top: 1px; }
.rec.is-waiting { border-style: dashed; border-color: var(--color-amber-border); background: var(--color-amber-soft); }
.rec.is-waiting .rec-title { color: var(--color-amber-strong); }
.rec.is-waiting .rec-sub { color: var(--color-amber-text); }
.rec.is-saved { border-color: var(--color-border-strong); }
.rec .times { border: 1px solid var(--color-border); border-top: 2px solid var(--color-ink); border-radius: var(--radius-xs); }
.rec .time-box { padding: 8px 12px 9px; }
.rec .time-box b { font-size: var(--text-sm); line-height: 19px; }
.saved-list { display: grid; }
.saved-list li { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; gap: var(--space-2); align-items: start; padding: var(--space-2) 0; border-top: 1px solid var(--color-hairline); }
.saved-list li:first-child { border-top: 0; padding-top: 0; }
.saved-kind { font-size: 9.5px; line-height: 19px; color: var(--color-text-secondary); }
.saved-title { font-size: var(--text-sm); line-height: var(--leading-sm); font-weight: var(--weight-medium); overflow-wrap: anywhere; }
.empty { display: grid; justify-items: center; text-align: center; gap: var(--space-1-5); padding: var(--space-6) var(--space-5); border: 1px dashed var(--color-border-strong); border-radius: var(--radius-lg); }
.empty h3 { font-size: var(--text-base); font-weight: var(--weight-semibold); }
.empty p { max-width: 380px; font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--color-text-secondary); }

/* the activity log: a register with a mono time column */
.fold > summary { display: flex; align-items: center; gap: var(--space-3); padding: 12px var(--space-4); list-style: none; cursor: pointer; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary .chev { margin-left: auto; color: var(--color-text-tertiary); transition: transform var(--duration-base) var(--ease-out); }
.fold[open] > summary .chev { transform: rotate(180deg); }
.fold-title { font-size: var(--text-base); font-weight: var(--weight-semibold); }
.fold-sub { font-size: var(--text-xs); color: var(--color-text-secondary); }
.log { border-top: 1px solid var(--color-border); }
.log > li { display: grid; grid-template-columns: 66px minmax(0, 1fr) auto; gap: var(--space-3); align-items: start; padding: 9px var(--space-4); border-top: 1px solid var(--color-hairline); font-size: var(--text-sm); line-height: var(--leading-sm); }
.log > li:first-child { border-top: 0; }
.log .at { font-size: 10.5px; line-height: 19px; letter-spacing: .04em; color: var(--color-text-secondary); font-variant-numeric: tabular-nums; }
.log .what { min-width: 0; overflow-wrap: anywhere; color: var(--color-text); }
.log .who { display: block; font-size: var(--text-xs); color: var(--color-text-secondary); }
.log > li.refused { background: var(--color-danger-soft); }
.log > li.refused .what { color: var(--color-danger-text); }
.log > li.blocked { background: var(--color-amber-soft); }
.log-more { padding: var(--space-2) var(--space-4) var(--space-3); }
.log-more .btn-link { font-size: var(--text-sm); }

/* under the hood */
.hood-body { display: grid; gap: var(--space-4); padding: 0 var(--space-4) var(--space-4); }
.hood-body h4 { font-size: 10.5px; color: var(--color-text-secondary); margin-bottom: var(--space-2); }
.explain { font-size: var(--text-sm); line-height: 20px; color: var(--color-text-secondary); }
.usage { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2) var(--space-4); font-size: var(--text-sm); }
.usage dt { color: var(--color-text-secondary); font-size: 10px; }
.usage dd { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: var(--weight-medium); }
.skill-list { display: grid; gap: var(--space-2); }
.skill-list li { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: var(--space-2); font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--color-text-secondary); }
.skill-list b { color: var(--color-text); }
.skill-list code { color: var(--color-accent-text); }
.skill-list .tick.idle { background: var(--color-surface-muted); color: var(--color-text-tertiary); border-color: var(--color-border); }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-xs); }
.table th, .table td { text-align: left; padding: 6px 8px; border-top: 1px solid var(--color-hairline); vertical-align: top; }
.table th { color: var(--color-text-secondary); font-size: 10px; border-top: 0; }
.raw { font-family: var(--font-mono); font-size: 11px; line-height: 16px; color: var(--color-text-secondary); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 220px; overflow: auto; padding: var(--space-2); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-subtle); }

.side-label {
  position: fixed; z-index: 45; left: 50%; top: 128px; transform: translateX(-50%); padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md); background: var(--color-surface-inverse); color: var(--color-text-inverse);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .07em; text-transform: uppercase; box-shadow: var(--shadow-md); animation: fade var(--duration-slow) var(--ease-out);
}
.toast { display: inline-flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--color-surface-inverse); color: var(--color-text-inverse); font-size: var(--text-sm); box-shadow: var(--shadow-md); }
.toast-fixed { position: fixed; z-index: 50; left: 16px; right: 16px; margin: 0 auto; width: max-content; max-width: calc(100% - 32px); bottom: var(--space-6); }

/* =====================================================================
   THE STORY: one sheet at a time, one action per sheet
   ===================================================================== */
.story {
  position: relative; z-index: 4; display: grid; grid-template-columns: minmax(0, 72ch) auto; justify-content: start; column-gap: var(--space-10);
  align-items: center; padding: var(--space-5) var(--space-10); background: var(--color-surface); border-bottom: 1px solid var(--color-border);
  font-size: 16px;     /* so 72ch is a comfortable line of story text */
  min-height: 186px;   /* the tallest sheet: the band keeps one height and its button one place, so nothing jumps */
}
body[data-step="free"] .story { min-height: 0; padding-top: var(--space-4); padding-bottom: var(--space-4); }
.story-main { min-width: 0; display: grid; gap: 6px; }
.story-kicker { display: flex; align-items: center; gap: var(--space-3); font-size: 11.5px; line-height: 16px; color: var(--color-accent-text); }
.story-bars { display: inline-flex; gap: 3px; }
.story-bars i { width: 14px; height: 3px; background: var(--color-border); }
.story-bars i.on { background: var(--color-accent); }
.story-title { font-size: var(--text-3xl); line-height: var(--leading-3xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-tight); }
.story-text { font-size: var(--text-lg); line-height: var(--leading-lg); color: var(--color-text-secondary); }
.story-quote { margin-top: 2px; font-size: var(--text-sm); line-height: 20px; padding: 8px 12px 9px; }
.story-quote .quote-text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; color: var(--color-amber-strong); }
.story-quote > span { margin-bottom: 1px; }
.story-text b { color: var(--color-text); font-weight: var(--weight-semibold); }
.story-text code, .story-list code { font-size: 12.5px; color: var(--color-text); }
.story-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; justify-content: flex-end; }
.story .btn-primary { height: 46px; padding: 0 var(--space-5); font-size: var(--text-md); }
.story-wait { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--color-text-secondary); }
.story-list { display: grid; grid-template-columns: repeat(3, minmax(0, max-content)); gap: var(--space-1-5) var(--space-6); margin-top: var(--space-1); }
.story-list.one { grid-template-columns: minmax(0, 1fr); }
.story-list li { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: var(--space-2); font-size: var(--text-base); line-height: 21px; color: var(--color-text-secondary); white-space: nowrap; }
.story-list.one li { white-space: normal; }
.story-list li .i { width: 16px; height: 16px; margin-top: 2px; color: var(--color-accent-text); }
.story-list li .i.warn { color: var(--color-amber-text); }
.story-list li b { color: var(--color-text); font-weight: var(--weight-semibold); }
.story-figures { display: flex; gap: var(--space-8); flex-wrap: wrap; }
.story-figures div { display: grid; }
.story-figures span { font-size: 10px; color: var(--color-text-secondary); }
.story-figures strong { font-family: var(--font-mono); font-size: var(--text-2xl); line-height: var(--leading-2xl); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
.story-note { margin-top: var(--space-1); font-size: var(--text-sm); line-height: var(--leading-sm); font-weight: var(--weight-medium); color: var(--color-accent-text); }
.story-short { display: none; font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--color-text-secondary); }
.free-row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; font-size: var(--text-sm); color: var(--color-text-secondary); }
.free-row select { height: 34px; padding: 0 var(--space-2); border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); background: var(--color-surface); font-size: var(--text-sm); }

/* the pane this sheet is about gets the line blue */
body.in-story[data-focus="broker"] .broker-pane .pane-eyebrow, body.in-story[data-focus="crm"] .crm-pane .pane-eyebrow { color: var(--color-accent-text); }
body.in-story[data-focus="broker"] .messenger { border-color: var(--color-accent); }
.ring { animation: ring 1.8s var(--ease-out) infinite; }
.ring:focus-visible { animation: none; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 var(--color-focus-ring); } 50% { box-shadow: 0 0 0 6px var(--color-focus-ring); } 100% { box-shadow: 0 0 0 0 transparent; } }
body.in-story .send:not(:disabled) { background: var(--color-surface-muted); color: var(--color-text-tertiary); }
.rb.ring-card { border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-soft), var(--shadow-lg); }
.rec.ring-card { border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-soft); }

/* =====================================================================
   THE FIRST SCREEN: sheet A-101
   ===================================================================== */
body[data-step="0"] .app { grid-template-rows: var(--topbar-height) minmax(0, 1fr); }
body[data-step="0"] .layout, body[data-step="0"] .switch-row { display: none !important; pointer-events: none; }
body[data-step="0"] .story { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; padding: var(--space-12) var(--space-14); background: transparent; border: 0; }
/* centred in the screen; when it is taller than the screen it starts at the top (a column's auto margins never go negative) */
.hero { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-12) var(--space-14); width: 100%; max-width: 1328px; margin: auto; }
.hero-copy { flex: 1 1 480px; min-width: 0; display: flex; flex-direction: column; gap: var(--space-6); }
.kicker { display: inline-flex; align-items: center; gap: 10px; font-size: 12px; color: var(--color-accent-text); }
.kicker i { display: inline-block; width: 28px; height: 1px; background: currentColor; }
.story-headline { font-size: clamp(30px, 3.4vw, 52px); line-height: 1.07; letter-spacing: var(--tracking-tighter); font-weight: var(--weight-semibold); text-wrap: balance; }
.story-headline span { display: block; color: var(--color-accent-text); text-wrap: balance; }
.story-sub { font-size: clamp(16px, 1.3vw, 19px); line-height: 1.55; color: var(--color-text-secondary); max-width: 540px; }
.hero-actions { display: flex; align-items: center; gap: var(--space-5); flex-wrap: wrap; }
.hero-points { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: var(--space-2); border-top: 1px solid var(--color-border); }
.hero-points li { display: grid; align-content: start; gap: 6px; padding: var(--space-4) var(--space-4) 0; font-size: var(--text-base); line-height: 1.45; font-weight: var(--weight-medium); }
.hero-points li:first-child { padding-left: 0; }
.hero-points li + li { border-left: 1px solid var(--color-border); }
.hero-points span { font-size: 12px; color: var(--color-accent-text); letter-spacing: .04em; }

.hero-side { flex: 1 1 540px; min-width: 0; display: grid; gap: var(--space-3); }
.hero-fig { background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.fig-bar { display: flex; align-items: center; justify-content: space-between; gap: 2px var(--space-4); flex-wrap: wrap; padding: 9px var(--space-4); border-bottom: 1px solid var(--color-border); font-size: 10.5px; line-height: 15px; color: var(--color-text-secondary); }
.fig-plan { padding: var(--space-3) var(--space-4) var(--space-4); display: grid; gap: var(--space-2); }
.plan { display: block; width: 100%; height: auto; overflow: visible; }
.fp-wall rect, .fp-wall path { fill: none; stroke: var(--color-accent); stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.fp-wall .fp-door { stroke-dasharray: 3 3; stroke-width: 1; }
.fp-wall .fp-dock { stroke-width: 2.6; }
.fp-faint path, .fp-faint circle { fill: none; stroke: var(--color-border-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.fp-label { font-family: var(--font-mono); font-size: 11px; letter-spacing: .06em; fill: var(--color-text-secondary); }
.fp-short { display: none; }
.fp-lead { fill: none; stroke: var(--color-amber-line); stroke-width: 1.4; }
.fp-dot { fill: var(--color-amber-line); }
.fp-lead.fp-worried { stroke: var(--color-danger-text); }
.fp-dot.fp-worried { fill: var(--color-danger-text); }
.fp-tag { font-family: var(--font-mono); font-size: 11px; font-weight: var(--weight-semibold); letter-spacing: .08em; fill: var(--color-amber-text); paint-order: stroke; stroke: var(--color-surface); stroke-width: 5px; stroke-linejoin: round; }
.fp-tag.fp-worried { fill: var(--color-danger-text); }
.hero-fig.anim .fp-lead { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 900ms var(--ease-out) both; animation-delay: calc(450ms + var(--d, 0ms) + var(--age, 0ms)); }
.hero-fig.anim .fp-dot { transform-box: fill-box; transform-origin: center; animation: pop 300ms var(--ease-out) both; animation-delay: calc(300ms + var(--age, 0ms)); }
.hero-fig.anim .fp-tag { animation: fade 400ms var(--ease-out) both; animation-delay: calc(1250ms + var(--age, 0ms)); }
.fig-quote { padding: 11px 14px 12px; background: var(--color-amber-soft); border: 1px solid var(--color-amber-border); border-radius: var(--radius-md); font-size: var(--text-base); line-height: 1.5; color: var(--color-amber-strong); }
.fig-quote > span { display: block; margin-bottom: 3px; font-size: 10.5px; color: var(--color-amber-text); }
.tb { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 2px solid var(--color-ink); }
.tb .tb-cell { padding: 10px 14px 11px; }
.tb .tb-cell + .tb-cell { border-left: 1px solid var(--color-border); }
.tb .tb-cell b { font-size: var(--text-sm); line-height: 19px; }
.tb .tb-wait { background: var(--color-amber-soft); }
.tb .tb-wait > span, .tb .tb-wait b { color: var(--color-amber-text); }
.tb .tb-approved { position: relative; align-content: start; }
.tb .tb-approved .stamp { justify-self: start; max-width: 100%; margin-top: 3px; font-size: 10.5px; padding: 1px 6px; letter-spacing: .05em; white-space: normal; rotate: -4deg; }
.fig-note { font-size: 10.5px; line-height: 15px; letter-spacing: .04em; color: var(--color-text-secondary); text-transform: none; }

@media (min-width: 901px) {
  .suggest { flex-wrap: wrap; overflow: visible; -webkit-mask-image: none; mask-image: none; scrollbar-width: thin; }
  body.chat-started .suggest { flex-wrap: nowrap; overflow-x: auto; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent); }
  /* D1: at step 2 the whole card fits: no chat header, no trace, no avatar column for that reply */
  body[data-step="2"] .m-head, body[data-step="2"] .bot:has(.ring-card) .trace { display: none; }
  body[data-step="2"] .bot:has(.ring-card) { grid-template-columns: minmax(0, 1fr); }
  body[data-step="2"] .bot:has(.ring-card) > .avatar { display: none; }
  body[data-step="2"] .bot:has(.ring-card) > :not(.avatar) { grid-column: 1; }
  body[data-step="2"] .rb.ring-card, body[data-step="2"] .bot:has(.ring-card) .answer { max-width: none; }
  .switch-row { display: none; }
  body[data-step="2"] .composer, body[data-step="2"] .fiction-note { display: none; }   /* room for the read back card */
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .hero-fig .fp-lead { stroke-dasharray: none !important; stroke-dashoffset: 0 !important; animation: none !important; }
  .anim, .anim * { animation: none !important; }
}

/* =====================================================================
   RESPONSIVE
   ===================================================================== */
@media (max-height: 760px) and (min-width: 901px) {
  .crm-desc { display: none; }
  .story { min-height: 164px; }
  body[data-step="2"] .thread { padding-bottom: var(--space-3); }
  body[data-step="2"] .answer { font-size: var(--text-base); line-height: 21px; }
  body[data-step="2"] .rb-kicker { display: none; }   /* the title and the pill say it; the card needs the room */
  body[data-step="2"] .rb { --text-base: 13px; }
  body[data-step="2"] .rows, body[data-step="2"] .rb-list, body[data-step="2"] .rb-tasks li { line-height: 18px; }
  body[data-step="2"] .rows { gap: 3px var(--space-3); }
  body[data-step="2"] .rows dt { line-height: 18px; }
  body[data-step="2"] .rb-body.two { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
  body[data-step="2"] .rb .time-box small { font-size: 11.5px; line-height: 15px; }
  .story-quote .quote-text { -webkit-line-clamp: 1; }
  .story-list.one { grid-template-columns: repeat(2, minmax(0, max-content)); }
  body[data-step="2"] .broker-pane > .pane-eyebrow { display: none; }
  body[data-step="2"] .thread { padding-top: var(--space-3); gap: var(--space-3); }
  .rb-col { padding: 10px 16px; gap: var(--space-2); }
  .rb-head { padding: 8px 16px; }
  .time-box, .tb-cell { padding: 8px 16px 9px; }
  .broker-pane { padding-top: var(--space-3); }
  .thread { padding-top: var(--space-4); gap: var(--space-4); }
  .fiction-note { padding: var(--space-2); }
  .story { padding-top: var(--space-3); padding-bottom: var(--space-3); }
  .story-title { font-size: var(--text-2xl); line-height: var(--leading-2xl); }
  .story-text { font-size: var(--text-md); line-height: 22px; }
  .m-head { min-height: 44px; padding-top: 6px; padding-bottom: 6px; }
  body[data-step="2"] .m-head { display: none; }   /* the read back card needs the room */
  .crm-head { padding-top: var(--space-4); }
  body[data-step="0"] .story { padding: var(--space-8) var(--space-12); }
  .hero-copy { gap: var(--space-5); }
}
@media (max-width: 1180px) {
  .story { padding: var(--space-4) var(--space-6); column-gap: var(--space-6); }
  .topbar { padding: 0 var(--space-4) 0 var(--space-6); }
  .broker-pane { padding-left: var(--space-5); padding-right: var(--space-5); }
  .story-list { grid-template-columns: repeat(2, minmax(0, max-content)); }
  body[data-step="0"] .story { padding: var(--space-10) var(--space-8); }
}

/* phone and small tablet: one pane at a time, the story is a bottom sheet */
@media (max-width: 900px) {
  :root { --topbar-height: 56px; }
  .app { grid-template-rows: var(--topbar-height) auto minmax(0, 1fr); }
  .topbar { grid-template-columns: minmax(0, 1fr) auto; padding: 0 var(--space-2) 0 var(--space-4); gap: var(--space-3); }
  .topbar > div:nth-child(2) { display: none; }
  .brand-mark { width: 30px; height: 30px; }
  .brand-sub .sub-long { display: none; }
  .brand-sub .sub-short { display: inline; }
  .m-head { display: none; }   /* the story sheet or the free chat row says who is signed in */
  .phone-only { display: flex !important; }
  .top-actions { gap: 0; }
  .top-actions .btn span { display: none; }
  .top-actions .btn { width: 44px; height: 44px; padding: 0; }
  .switch-row { padding: 2px var(--space-4); background: var(--color-bg); border-bottom: 1px solid var(--color-border); }
  .skill { letter-spacing: .02em; padding: 3px 7px; }
  .tag { letter-spacing: .03em; }
  .switch-row .seg { display: flex; width: 100%; padding: 3px; }
  .switch-row .seg button { flex: 1; justify-content: center; height: 44px; font-size: var(--text-sm); }

  .layout { display: block; min-height: 0; }
  .broker-pane, .crm-pane { height: 100%; }
  body:not([data-pane="crm"]) .crm-pane { display: none; }
  body[data-pane="crm"] .broker-pane { display: none; }
  .broker-pane { padding: 0; }
  .broker-pane > .pane-eyebrow, .fiction-note { display: none; }
  .messenger { max-width: none; border: 0; border-radius: 0; box-shadow: none; }
  body.in-story[data-focus="broker"] .messenger { border: 0; }
  .m-head { padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4); }
  .thread { padding: var(--space-5) var(--space-4) var(--space-6); gap: var(--space-4); }
  .bubble { max-width: 88%; }
  .chip { height: 40px; }
  .composer { padding: var(--space-1) var(--space-3) max(var(--space-3), env(safe-area-inset-bottom)); }
  .composer-box { padding: 5px 5px 5px 14px; }
  .composer textarea { font-size: 16px; }   /* stops iOS zooming on focus */
  .send { width: 40px; height: 40px; }
  .crm-pane { border-left: 0; }
  .crm-head { padding: var(--space-3) var(--space-4); }
  .crm-head .pane-eyebrow, .crm-desc { display: none; }
  .panel { padding: var(--space-3) var(--space-4) var(--space-8); }
  .pipe-cell { padding: 6px 7px 7px; }
  .pipe-k { font-size: 10px; letter-spacing: 0; }
  .pipe-cell em, .saved-kind { font-size: 10px; }
  .pipe-cell b { font-size: 17px; line-height: 21px; }
  .log > li { grid-template-columns: 60px minmax(0, 1fr); }
  .log > li .pill { grid-column: 2; justify-self: start; }
  .bot > .rb, .bot > .event { grid-column: 1 / -1; }   /* full width on a phone: the card needs the room */
  .rb-head { padding: 9px 14px; }
  .rb-col { padding: 12px 14px; }
  .rb-tasks li .rb-task-head { flex-direction: column; gap: 2px; }
  .times > .time-box { flex: 1 1 calc(50% - 1px); padding: 8px 12px; }
  .rb .tb-approve { flex: 1 1 100%; border-left: 0; border-top: 1px solid var(--color-border); padding: 8px 12px 10px; }
  .rb .tb-approve:not(.is-signed) > span { display: none; }
  .rb-actions { display: grid; grid-template-columns: 1.4fr 1fr; margin: 0; }
  .rb-actions .btn { height: var(--control-lg); font-size: var(--text-md); }
  .tb-approve.is-signed { padding-right: 150px; }
  .event { grid-template-columns: 20px minmax(0, 1fr); }
  .event .stamp { grid-column: 2; justify-self: start; margin: 6px 0 2px; }
  .saved-list li { grid-template-columns: 40px minmax(0, 1fr); }
  .saved-list li .due { grid-column: 2; justify-self: start; }
  .rec .times > .time-box { padding: 7px 10px; }

  /* the story becomes a bottom sheet with its button always in view */
  .story {
    position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; grid-template-columns: minmax(0, 1fr); row-gap: var(--space-3);
    max-height: 46vh; overflow-y: auto; padding: var(--space-4) var(--space-4) max(var(--space-4), env(safe-area-inset-bottom));
    border-top: 2px solid var(--color-ink); border-bottom: 0; box-shadow: var(--shadow-xl); min-height: 0;
  }
  .story-actions {
    justify-content: stretch; position: sticky; bottom: calc(-1 * max(var(--space-4), env(safe-area-inset-bottom)));
    margin-bottom: calc(-1 * max(var(--space-4), env(safe-area-inset-bottom)));
    padding: var(--space-2) 0 max(var(--space-4), env(safe-area-inset-bottom)); background: var(--color-surface);
  }
  .story-actions:empty { display: none; }
  .story-actions .btn-primary { flex: 1; height: var(--control-lg); }
  .story .btn-link { min-height: 44px; }
  .story-kicker { font-size: 10.5px; gap: var(--space-2); }
  .story-title { font-size: var(--text-xl); line-height: var(--leading-xl); }
  .story-text { font-size: var(--text-sm); line-height: var(--leading-sm); }
  .story-list { grid-template-columns: minmax(0, 1fr); }
  .story-list li { font-size: var(--text-sm); line-height: 19px; }
  .story-figures strong { font-size: var(--text-xl); }
  .side-label { top: auto; bottom: calc(var(--story-h, 200px) + var(--space-3)); }
  .toast-fixed { bottom: calc(var(--story-h, 0px) + var(--space-4)); }
  body.in-story .suggest, body.in-story .composer { display: none; }
  body.in-story .thread, body.in-story .panel { padding-bottom: calc(var(--story-h, 220px) + var(--space-4)); }
  body.in-story .m-head { display: none; }
  body[data-step="2"] .story-text { display: none; }   /* the read back card needs the room */
  body[data-step="2"] .story-short { display: block; }
  /* step 2 on a phone: the badge, the card's header and Confirm all fit above the sheet */
  body[data-step="2"] .bot:has(.ring-card) { grid-template-columns: minmax(0, 1fr); }
  body[data-step="2"] .bot:has(.ring-card) > .avatar, body[data-step="2"] .bot:has(.ring-card) .trace,
  body[data-step="2"] .bot:has(.ring-card) .bot-name { display: none; }
  body[data-step="2"] .bot:has(.ring-card) > :not(.avatar) { grid-column: 1; }
  body[data-step="2"] .rb-kicker { display: none; }   /* the pill says it is not saved yet */
  body[data-step="2"] .rb-sum { font-size: var(--text-md); line-height: 20px; }
  body[data-step="2"] .bot:has(.ring-card) .answer { font-size: var(--text-base); line-height: 20px; }
  .skill-extra { display: none; }

  /* the first screen on a phone: the copy, then the drawing under it */
  body[data-step="0"] .story {
    position: fixed; top: var(--topbar-height); bottom: 0; max-height: none; border-top: 0; box-shadow: none;
    padding: var(--space-8) var(--space-5) var(--space-10); background-color: var(--color-bg);
    background-image: linear-gradient(var(--color-grid) 1px, transparent 1px), linear-gradient(90deg, var(--color-grid) 1px, transparent 1px);
    background-size: var(--grid-size) var(--grid-size);
  }
  .hero { gap: var(--space-8); min-height: 0; }
  .hero-copy { gap: var(--space-5); flex-basis: 100%; }
  .story-headline { font-size: 31px; line-height: 1.1; }
  .story-sub { font-size: var(--text-md); line-height: 1.5; }
  .hero-actions { gap: var(--space-3); }
  .hero-actions .btn-primary { flex: 1 1 auto; }
  .hero-points { grid-template-columns: minmax(0, 1fr); }
  .hero-points li, .hero-points li:first-child { grid-template-columns: 28px minmax(0, 1fr); gap: var(--space-2); padding: 10px 0; display: grid; }
  .hero-points li + li { border-left: 0; border-top: 1px solid var(--color-border); }
  .hero-points span { padding-top: 1px; }
  .hero-side { flex-basis: 100%; }
  /* the drawing comes right after the buttons, before the 01 02 03 points */
  .hero { flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: var(--space-5); }
  .hero-copy { display: contents; }
  .hero-copy > * { order: 0; }
  .hero-side { order: 1; margin-top: var(--space-2); }
  .hero-points { order: 2; margin-top: 0; }
  .fp-long { display: none; }
  .fp-short { display: inline; font-size: 20px; letter-spacing: .04em; }
  .fp-tag { font-size: 17px; stroke-width: 6px; }
  .fp-lead { stroke-width: 2.4; }
  .fp-dot { r: 6px; }
  .tb { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tb .tb-cell:nth-child(3) { border-left: 0; }
  .tb .tb-cell:nth-child(n + 3) { border-top: 1px solid var(--color-border); }

  /* free chat: the story becomes a slim row above the chat, so the composer stays reachable */
  body:not(.in-story) .story {
    position: static; max-height: none; box-shadow: none; border-top: 0;
    border-bottom: 1px solid var(--color-border); padding: var(--space-2) var(--space-4); row-gap: var(--space-2);
  }
  body:not(.in-story) .story-kicker, body:not(.in-story) .story-title { display: none; }
  body:not(.in-story) .story-actions { position: static; margin: 0; padding: 0; }
  body:not(.in-story) .app { grid-template-rows: var(--topbar-height) auto auto minmax(0, 1fr); }
  body:not(.in-story):has(#input:focus) .story { display: none; }
  body:not(.in-story):has(#input:focus) .app { grid-template-rows: var(--topbar-height) auto minmax(0, 1fr); }
}
@media (max-width: 900px) and (max-height: 700px) {
  .story { max-height: 50vh; }
}
@media (max-width: 420px) {
  .pill-long { display: none; }
  .pill-short { display: inline; }
  .rb-count { display: none; }
  .pk-long { display: none; }
  .pk-short { display: inline; }
  .pipe-cell { padding: 6px 5px 7px; }
  .pipe-cell em { display: none; }   /* the shading and the top rule mark it; screen readers get the words */
  .rec-head { grid-template-columns: minmax(0, 1fr); }
  .rec-head .stamp { justify-self: start; margin: 2px 0 0 2px; }
  .time-box > span { font-size: 10px; letter-spacing: .03em; }
  .story-headline { font-size: 29px; }
}
@media (max-width: 380px) {
  .story-headline { font-size: 27px; }
}

.sub-short, .pk-short { display: none; }
@media (max-width: 900px) {
  /* step 2 on a phone: the amber "when it happened" cell and the flags sit above Confirm */
  .rb .tb-flags {
    display: flex; flex: 1 1 100%; align-items: center; gap: var(--space-1-5); min-width: 0; padding: 4px 12px; border-left: 0;
    border-top: 1px solid var(--color-border); background: var(--color-amber-soft); color: var(--color-amber-text); font-size: var(--text-xs); line-height: 16px;
  }
  .rb .tb-flags .i { width: 13px; height: 13px; flex: none; }
  .rb .tb-flags span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .story-quote .quote-text { -webkit-line-clamp: 3; }
}
@media (min-width: 901px) and (max-width: 1300px) {
  .pk-long { display: none; }
  .pk-short { display: inline; }
}

/* a reply with a read back card: two lines of Claude's text, the rest on request */
.answer.clamp:not(.open) { max-height: calc(2 * var(--leading-md)); overflow: hidden; }
.more-toggle {
  justify-self: start; margin-top: -4px; padding: 2px 0; min-height: 24px; font-size: var(--text-xs); line-height: 16px;
  font-weight: var(--weight-medium); color: var(--color-accent-text); text-decoration: underline; text-decoration-color: var(--color-accent-border);
  text-underline-offset: 3px;
}
.more-toggle:hover { color: var(--color-text); text-decoration-color: currentColor; }
@media (max-height: 760px) and (min-width: 901px) {
  body[data-step="2"] .answer.clamp:not(.open) { max-height: 42px; }   /* two lines at the step's 14px / 21px */
}
@media (max-width: 900px) {
  body[data-step="2"] .bot:has(.ring-card) .answer.clamp:not(.open) { max-height: 40px; }   /* two lines at 14px / 20px */
  body[data-step="2"] .bot:has(.ring-card) .more-toggle { margin-top: -8px; min-height: 22px; }
}
