/* ═══════════════════════════════════════════════════════════════════════════
   MARBLELENS · AI CONTENT — the internal workspace
   Tokens come from design-system.css. This file loads WITHOUT base.css or
   sections.css on purpose: those carry the marketing page's shell and would
   fight a product surface. Everything here is self-contained.

   Character: ~70% premium creative software, ~30% command interface.
   Ivory ground, graphite construction, ONE ochre accent, nothing neon.
   ═══════════════════════════════════════════════════════════════════════════ */

:root { --accent: var(--ochre); --accent-ink: #8a5c18; --accent-wash: rgba(196,135,50,0.12); }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }

body {
  font-family: var(--sans);
  font-size: var(--t-body);
  line-height: var(--lh-body);
  color: var(--ink-2);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

/* paper fibre — same feTurbulence family as the marketing site */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)' opacity='0.045'/%3E%3C/svg%3E");
}

.mono-s {
  font-family: var(--mono); font-size: var(--t-label);
  letter-spacing: var(--ls-label); text-transform: uppercase;
  color: var(--graphite);
}
.vh {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
:where(a, button, input, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.skip {
  position: absolute; left: 12px; top: -48px; z-index: 99;
  background: var(--ink); color: var(--paper-hi); padding: .6em 1em;
  font: 500 var(--t-label)/1 var(--mono); letter-spacing: .16em;
  text-decoration: none; transition: top var(--dur-fast) var(--ease-out);
}
.skip:focus { top: 12px; }

/* ══ HEADER ═══════════════════════════════════════════════════════════════ */
.hd {
  position: relative; z-index: 20;
  display: grid; grid-template-columns: auto 1fr auto;
  align-items: center; gap: var(--s-4);
  padding: 0 clamp(.9rem, 2.2vw, 2rem); height: 58px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.hd-l { display: flex; align-items: baseline; gap: var(--s-3); min-width: 0; }
.wordmark {
  font: 600 clamp(.72rem, 1.5vw, .84rem)/1 var(--sans);
  letter-spacing: .24em; color: var(--ink); text-decoration: none; white-space: nowrap;
}
.wordmark:hover { color: var(--accent-ink); }
.hd-product {
  font-family: var(--mono); font-size: var(--t-label);
  letter-spacing: var(--ls-label); text-transform: uppercase;
  color: var(--accent-ink); white-space: nowrap;
}
.hd-r { display: flex; align-items: center; gap: clamp(.5rem, 1.4vw, 1.1rem); justify-self: end; }
.hd-link {
  background: none; border: 0; cursor: pointer; padding: .4em 0;
  font-family: var(--mono); font-size: var(--t-label); letter-spacing: .16em;
  text-transform: uppercase; color: var(--graphite); white-space: nowrap;
}
.hd-link:hover { color: var(--ink); }
.avatar {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--line); background: var(--paper-hi); color: var(--graphite);
  font: 600 .58rem/1 var(--mono); letter-spacing: .06em;
}
.avatar:hover { border-color: var(--graphite-2); color: var(--ink); }

/* ── stage path ── */
.stages { display: flex; align-items: center; gap: clamp(.5rem, 1.6vw, 1.5rem); list-style: none; justify-self: center; }
.stage { display: flex; align-items: baseline; gap: .45em; white-space: nowrap; }
.stage-n {
  font-family: var(--mono); font-size: .58rem; letter-spacing: .1em;
  color: var(--graphite-2); transition: color var(--dur-fast) var(--ease-out);
}
.stage-l {
  font-family: var(--mono); font-size: var(--t-label); letter-spacing: .18em;
  text-transform: uppercase; color: var(--graphite-2);
  transition: color var(--dur-fast) var(--ease-out);
}
.stage[data-s="done"] .stage-n, .stage[data-s="done"] .stage-l { color: var(--graphite); }
.stage[data-s="on"]   .stage-n { color: var(--accent-ink); }
.stage[data-s="on"]   .stage-l { color: var(--ink); }
.stage[data-s="on"]   { position: relative; }
.stage[data-s="on"]::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -6px; height: 1px; background: var(--accent);
}

/* ══ WORKSPACE ════════════════════════════════════════════════════════════ */
.ws {
  position: relative; z-index: 1; min-height: 0;
  display: grid; grid-template-columns: minmax(0, 1fr);
  transition: grid-template-columns var(--dur) var(--ease-settle);
}
body[data-has-canvas="1"] .ws { grid-template-columns: minmax(0, 1fr) clamp(300px, 32vw, 460px); }
body[data-state="RESULT"] .ws { grid-template-columns: minmax(0, 0.62fr) minmax(0, 1fr); }

/* ── left: the worksheet ── */
.sheet {
  min-width: 0; min-height: 0; display: flex; flex-direction: column;
  border-right: 1px solid transparent;
}
body[data-has-canvas="1"] .sheet { border-right-color: var(--line); }

.stream {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: clamp(1.4rem, 3.4vw, 3.2rem) clamp(1.1rem, 3.4vw, 3.4rem) 1rem;
  display: flex; flex-direction: column; gap: var(--s-4);
}
.stream > * { max-width: 68ch; width: 100%; }

/* ── the opening question ── */
.hero { display: flex; flex-direction: column; gap: var(--s-3); padding-block: clamp(1rem, 5vh, 4rem); }
.hero h1 {
  font-family: var(--serif); font-weight: 500; font-size: var(--t-h1);
  line-height: var(--lh-head); color: var(--ink); text-wrap: balance; letter-spacing: var(--ls-head);
}
.hero p { font-size: var(--t-lede); color: var(--graphite); max-width: 46ch; }
.hero .hand {
  font-family: var(--pencil); font-size: 1.25rem; color: var(--accent-ink);
  transform: rotate(-1.4deg); transform-origin: left center; margin-top: .2em;
}
body:not([data-state="IDEA_EMPTY"]) .hero { display: none; }

/* ── notes (the rough transcript) ── */
.note {
  display: flex; flex-direction: column; gap: .3em;
  animation: rise var(--dur) var(--ease-settle) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(5px); } }
.note-t { font-size: var(--t-body); }
.note-user .note-t {
  color: var(--ink); padding-left: var(--s-3);
  border-left: 2px solid var(--accent); font-family: var(--serif); font-size: 1.06rem;
}
.note-ml .note-t { color: var(--graphite); max-width: 56ch; }
.note-k { display: inline-flex; align-items: center; gap: .5em; font-family: var(--mono);
  font-size: .58rem; letter-spacing: var(--ls-label); color: var(--graphite-2); }
.mk { width: 5px; height: 5px; background: var(--accent); display: inline-block; }

/* ── cards ── */
.card {
  position: relative; background: var(--paper-hi); border: 1px solid var(--line);
  padding: clamp(1rem, 2.2vw, 1.6rem);
  display: flex; flex-direction: column; gap: var(--s-3);
  box-shadow: var(--sh-mount);
  animation: rise var(--dur) var(--ease-settle) both;
}
/* corner markers — the construction language, not decoration */
.card::before, .card::after {
  content: ""; position: absolute; width: 9px; height: 9px; pointer-events: none;
  border-color: var(--graphite-2); border-style: solid; opacity: .7;
}
.card::before { top: -1px; left: -1px; border-width: 1px 0 0 1px; }
.card::after  { bottom: -1px; right: -1px; border-width: 0 1px 1px 0; }

.card-h { display: flex; align-items: baseline; gap: var(--s-3); }
.idx { font-family: var(--mono); font-size: var(--t-label); letter-spacing: .14em; color: var(--accent-ink); }
.card-t {
  font-family: var(--serif); font-weight: 500; font-size: var(--t-h3);
  line-height: var(--lh-head); color: var(--ink); text-wrap: balance;
}
.card-hint { font-size: var(--t-small); color: var(--graphite); max-width: 56ch; }

/* ── chips ── */
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip {
  cursor: pointer; background: var(--paper); border: 1px solid var(--line);
  color: var(--ink-2); font-family: var(--sans); font-size: var(--t-small);
  padding: .58em 1em; text-align: left;
  transition: border-color var(--dur-fast) var(--ease-out),
              background-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
.chip:hover { border-color: var(--graphite-2); background: var(--paper-hi); transform: translateY(-1px); }
.chip[aria-pressed="true"] {
  border-color: var(--accent); background: var(--accent-wash); color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--accent-wash);
}
.chip[aria-pressed="true"]::after { content: " ✓"; color: var(--accent-ink); }

.q-custom { display: flex; gap: .4rem; flex-wrap: wrap; }
.q-input {
  flex: 1 1 12rem; min-width: 0; background: var(--paper); border: 1px solid var(--line);
  padding: .58em .8em; font-family: var(--sans); font-size: var(--t-small); color: var(--ink);
}
.q-input:focus { border-color: var(--accent); outline-offset: 1px; }
.q-acts, .card-acts { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.card-acts { margin-top: .2em; }

.mini {
  cursor: pointer; background: none; border: 1px solid var(--line); color: var(--graphite);
  font-family: var(--mono); font-size: var(--t-label); letter-spacing: .14em;
  text-transform: uppercase; padding: .62em 1em;
  transition: border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.mini:hover { border-color: var(--graphite-2); color: var(--ink); }
.mini-go { border-color: var(--accent); color: var(--accent-ink); }
.mini-quiet { border-style: dashed; }

.btn {
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: .7em;
  background: var(--ink); border: 1px solid var(--ink); color: var(--paper-hi);
  font-family: var(--mono); font-size: var(--t-label); letter-spacing: .2em;
  text-transform: uppercase; padding: .9em 1.5em;
  transition: background-color var(--dur-fast) var(--ease-out), letter-spacing var(--dur-fast) var(--ease-out);
}
.btn:hover:not(:disabled) { background: #2b2a26; letter-spacing: .24em; }
.btn:disabled { background: none; color: var(--graphite-2); border-color: var(--line); cursor: not-allowed; }
.arw { transition: transform var(--dur-fast) var(--ease-out); }
.btn:hover:not(:disabled) .arw { transform: translateX(3px); }
.btn-wide { width: 100%; }

/* ── spec table ── */
.spec { display: flex; flex-direction: column; }
.spec-row {
  display: grid; grid-template-columns: 8.5rem minmax(0, 1fr); gap: var(--s-3);
  padding: .55em 0; border-top: 1px solid var(--line-2);
}
.spec-row:first-child { border-top: 0; }
.spec-k {
  font-family: var(--mono); font-size: var(--t-label); letter-spacing: .16em;
  text-transform: uppercase; color: var(--graphite); padding-top: .15em;
}
.spec-v { font-size: var(--t-small); color: var(--ink-2); min-width: 0; }
.dir-title { font-family: var(--serif); letter-spacing: .04em; }

/* ── prompt build shimmer (mechanical, not a spinner) ── */
.build-bars { display: flex; flex-direction: column; gap: .4rem; }
.build-bars i {
  display: block; height: 6px; background: var(--paper-lo);
  transform-origin: left center; transform: scaleX(0);
  animation: draw-bar .42s var(--ease-settle) forwards;
  animation-delay: calc(var(--i) * 110ms);
}
.build-bars i:nth-child(2) { width: 84%; } .build-bars i:nth-child(3) { width: 62%; }
.build-bars i:nth-child(4) { width: 91%; } .build-bars i:nth-child(5) { width: 47%; }
@keyframes draw-bar { to { transform: scaleX(1); } }

/* ── review ── */
.rev-easy { display: flex; flex-direction: column; border-top: 1px solid var(--line-2); }
.rev-row {
  display: grid; grid-template-columns: 7.5rem minmax(0, 1fr) auto; gap: var(--s-3);
  align-items: baseline; padding: .6em 0; border-bottom: 1px solid var(--line-2);
}
.rev-k {
  font-family: var(--mono); font-size: var(--t-label); letter-spacing: .16em;
  text-transform: uppercase; color: var(--graphite);
}
.rev-v { font-size: var(--t-small); color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
.rev-edit {
  cursor: pointer; background: none; border: 0; padding: .2em .1em;
  font-family: var(--mono); font-size: .6rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--graphite-2); border-bottom: 1px solid transparent;
}
.rev-edit:hover { color: var(--accent-ink); border-bottom-color: var(--accent); }

/* the prompt no longer matches the answers — loud enough to catch, quiet enough to trust */
.stale {
  display: flex; flex-direction: column; align-items: flex-start; gap: .6rem;
  padding: .85rem 1rem; background: var(--accent-wash);
  border: 1px solid var(--accent); border-left-width: 3px;
}
.stale-k {
  font-family: var(--mono); font-size: var(--t-label); letter-spacing: var(--ls-label);
  text-transform: uppercase; color: var(--accent-ink);
}
.stale-t { font-size: var(--t-small); color: var(--ink-2); max-width: 54ch; }

.rev-adv { display: flex; flex-direction: column; gap: var(--s-3); }
.rev-toggle {
  align-self: flex-start; cursor: pointer; background: none; border: 0; padding: .3em 0;
  display: inline-flex; align-items: center; gap: .5em;
  font-family: var(--mono); font-size: var(--t-label); letter-spacing: .16em;
  text-transform: uppercase; color: var(--graphite);
}
.rev-toggle:hover { color: var(--ink); }
.caret { color: var(--accent-ink); }

.prompt-box { display: flex; flex-direction: column; gap: .55rem; }
.prompt-meta { display: flex; flex-wrap: wrap; gap: .6rem; align-items: baseline; }
.edited {
  font-family: var(--mono); font-size: .58rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent-ink); border: 1px solid var(--accent); padding: .12em .5em;
}
.prompt-ta {
  width: 100%; resize: vertical; min-height: 9rem;
  background: var(--paper); border: 1px solid var(--line); color: var(--ink);
  font-family: var(--mono); font-size: .8rem; line-height: 1.62; padding: .9em 1em;
}
.prompt-ta:focus { border-color: var(--accent); outline-offset: 1px; }

/* ══ CANVAS (right) ═══════════════════════════════════════════════════════ */
.canvas {
  position: relative; min-width: 0; min-height: 0; overflow-y: auto;
  display: flex; align-items: center; justify-content: center;
  padding: clamp(1rem, 2.4vw, 2.4rem);
  /* fine construction grid — the "creative machine" ground */
  background-image:
    linear-gradient(to right, var(--line-2) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line-2) 1px, transparent 1px);
  background-size: 48px 48px;
}
body[data-has-canvas="0"] .canvas { display: none; }
.canvas.over { background-color: var(--accent-wash); }

.cv-stack { display: flex; flex-direction: column; gap: var(--s-4); width: 100%; max-width: 420px; }
.cv-empty { text-align: center; color: var(--graphite-2); display: flex; flex-direction: column; gap: .5em; }
.cv-note { font-size: var(--t-small); }

/* selection brackets — lock onto whatever is active */
.brk { position: absolute; inset: -7px; pointer-events: none; }
.brk i { position: absolute; width: 13px; height: 13px; border: 1px solid var(--accent); }
.brk-tl { top: 0; left: 0; border-width: 1px 0 0 1px; }
.brk-tr { top: 0; right: 0; border-width: 1px 1px 0 0; }
.brk-bl { bottom: 0; left: 0; border-width: 0 0 1px 1px; }
.brk-br { bottom: 0; right: 0; border-width: 0 1px 1px 0; }

.plate {
  position: relative; background: var(--paper-hi); border: 1px solid var(--line);
  padding: 10px; box-shadow: var(--sh-mount);
}
.plate img { display: block; width: 100%; height: auto; max-height: 42vh; object-fit: contain; }
.plate-cap { display: flex; justify-content: space-between; gap: .8em; margin-top: .6em; align-items: baseline; }
.plate-name { font-size: .72rem; color: var(--graphite); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plate-x, .slot-x {
  position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; line-height: 1; cursor: pointer;
  border: 0; background: rgba(31,31,28,.72); color: var(--paper-hi); font-size: .8rem;
  opacity: 0; transition: opacity var(--dur-fast) var(--ease-out);
}
.plate:hover .plate-x, .plate-x:focus-visible,
.slot:hover .slot-x, .slot-x:focus-visible { opacity: 1; }

.refsheet { display: flex; flex-direction: column; gap: .5rem; }
.refs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.slot {
  position: relative; aspect-ratio: 1; background: var(--paper-lo);
  border: 1px solid var(--line); overflow: hidden;
}
.slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.slot-n {
  position: absolute; left: 3px; top: 2px; z-index: 2;
  font-family: var(--mono); font-size: .52rem; letter-spacing: .1em;
  color: var(--paper-hi); text-shadow: 0 1px 2px rgba(0,0,0,.6);
}

/* ── generating ── */
.gen { position: relative; width: 100%; max-width: 420px; aspect-ratio: 1; }
.gen-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.gen-svg line, .gen-svg rect, .gen-svg circle {
  fill: none; stroke: var(--graphite-2); stroke-width: 1;
  stroke-dasharray: var(--len, 400); stroke-dashoffset: var(--len, 400);
  animation: trace .6s var(--ease-settle) forwards; animation-delay: var(--d, 0ms);
}
@keyframes trace { to { stroke-dashoffset: 0; } }
.gen-cap { position: absolute; left: 0; right: 0; bottom: -1.8em; text-align: center; }

/* ── result ── */
.result { display: flex; flex-direction: column; align-items: center; gap: var(--s-3); width: 100%; }
.res-plate {
  position: relative; background: var(--paper-hi); border: 1px solid var(--line);
  padding: 12px; box-shadow: var(--sh-lift); max-width: min(520px, 100%);
}
.res-img { display: block; width: 100%; height: auto; max-height: 54vh; object-fit: contain; }
.ph-tag {
  position: absolute; left: 18px; bottom: 18px; z-index: 3;
  background: rgba(31,31,28,.8); color: var(--paper-hi);
  font-family: var(--mono); font-size: .52rem; letter-spacing: .16em;
  text-transform: uppercase; padding: .4em .7em;
}
.res-meta { display: flex; justify-content: space-between; gap: 1em; width: 100%; max-width: 520px; }
.res-acts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.act {
  cursor: pointer; background: none; border: 1px solid var(--line); color: var(--graphite);
  font-family: var(--mono); font-size: var(--t-label); letter-spacing: .16em;
  text-transform: uppercase; padding: .68em 1.1em;
  transition: border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.act:hover { border-color: var(--ink); color: var(--ink); }
.result .btn-wide { max-width: 520px; }

/* ══ COMPOSER + FOOT ══════════════════════════════════════════════════════ */
.foot { padding: 0 clamp(1.1rem, 3.4vw, 3.4rem); }
.foot:empty { display: none; }
.foot > .btn { max-width: 68ch; }
.foot-note {
  font-size: .72rem; color: var(--graphite-2); margin-top: .5em; max-width: 68ch;
  font-family: var(--mono); letter-spacing: .04em;
}

.composer {
  border-top: 1px solid var(--line); background: var(--paper);
  padding: clamp(.7rem, 1.6vw, 1rem) clamp(1.1rem, 3.4vw, 3.4rem) clamp(1rem, 2vw, 1.4rem);
  display: flex; flex-direction: column; gap: .6rem;
}
.cmp-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .6rem; align-items: end;
  max-width: 68ch; width: 100%;
}
.cmp-input {
  width: 100%; resize: none; overflow-y: auto; min-height: 46px; max-height: 160px;
  background: var(--paper-hi); border: 1px solid var(--line); color: var(--ink);
  font-family: var(--sans); font-size: var(--t-body); line-height: 1.5; padding: .74em .9em;
}
.cmp-input::placeholder { color: var(--graphite-2); }
.cmp-input:focus { border-color: var(--accent); outline-offset: 1px; }
.send {
  cursor: pointer; height: 46px; padding: 0 1.15em;
  background: var(--ink); border: 1px solid var(--ink); color: var(--paper-hi);
  font-family: var(--mono); font-size: var(--t-label); letter-spacing: .16em; text-transform: uppercase;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.send:hover { background: #2b2a26; }
.cmp-tools { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; max-width: 68ch; }
.tool {
  cursor: pointer; background: none; border: 1px dashed var(--line); color: var(--graphite);
  font-family: var(--mono); font-size: var(--t-label); letter-spacing: .14em; text-transform: uppercase;
  padding: .5em .85em;
  transition: border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.tool:hover { border-color: var(--accent); color: var(--accent-ink); }

/* clarity meter — visible proof the brief is sharpening */
.clarity { display: flex; align-items: center; gap: .55rem; margin-left: auto; }
.clarity-bar { width: 74px; height: 3px; background: var(--paper-lo); position: relative; }
.clarity-bar::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: var(--p, 0%);
  background: var(--accent); transition: width var(--dur) var(--ease-settle);
}
.clarity-pct { font-family: var(--mono); font-size: .58rem; letter-spacing: .1em; color: var(--graphite); font-variant-numeric: tabular-nums; }

/* ══ RESPONSIVE ═══════════════════════════════════════════════════════════ */

/* ≤1180 — the canvas rail narrows before it moves */
@media (max-width: 1180px) {
  body[data-has-canvas="1"] .ws { grid-template-columns: minmax(0, 1fr) clamp(260px, 30vw, 340px); }
  .stages { gap: .8rem; }
  .stage-l { display: none; }
  .stage[data-s="on"] .stage-l { display: inline; }
}

/* ≤1023 — TABLET: one column, canvas becomes a band above the sheet */
@media (max-width: 1023px) {
  body[data-has-canvas="1"] .ws,
  body[data-state="RESULT"] .ws { grid-template-columns: minmax(0, 1fr); }
  .ws { grid-template-rows: auto minmax(0, 1fr); }
  .canvas {
    grid-row: 1; max-height: 40vh; border-bottom: 1px solid var(--line);
    padding: var(--s-3);
  }
  body[data-state="RESULT"] .canvas { max-height: 58vh; }
  .sheet { grid-row: 2; border-right: 0; }
  .cv-stack { flex-direction: row; align-items: flex-start; max-width: none; }
  .cv-stack .plate { flex: 0 0 min(46%, 230px); }
  .plate img { max-height: 26vh; }
  .refsheet { flex: 1; min-width: 0; }
  .refs { grid-template-columns: repeat(4, 1fr); }
  .gen { max-width: 240px; }
  .res-img { max-height: 44vh; }
}

/* ≤767 — MOBILE: conversation first, everything stacks, composer stays reachable */
@media (max-width: 767px) {
  .hd { height: 52px; grid-template-columns: auto 1fr auto; gap: .6rem; }
  .hd-product { display: none; }
  .stages { display: none; }
  .hd-link { display: none; }

  .stream { padding: 1.1rem 1rem .8rem; gap: var(--s-3); }
  .stream > * { max-width: none; }
  .hero h1 { font-size: clamp(1.8rem, 8.4vw, 2.4rem); }

  .canvas { max-height: 32vh; }
  /* RESULT owns the screen on mobile — the plate AND every control must fit
     without the band scrolling the CTA out of reach */
  body[data-state="RESULT"] .canvas { max-height: none; padding-block: var(--s-3) var(--s-4); }
  body[data-state="RESULT"] .res-img { max-height: 38vh; }
  body[data-state="RESULT"] .sheet .stream { padding-top: .8rem; }
  .cv-stack { flex-direction: column; }
  .cv-stack .plate { flex: none; width: 100%; }
  .plate img { max-height: 20vh; }
  .refs { grid-template-columns: repeat(5, 1fr); }

  .spec-row, .rev-row { grid-template-columns: minmax(0, 1fr); gap: .15rem; }
  .rev-row { grid-template-columns: minmax(0, 1fr) auto; }
  .rev-k { grid-column: 1 / -1; }

  .composer { padding: .7rem 1rem 1rem; }
  .cmp-row, .cmp-tools, .foot > .btn, .foot-note { max-width: none; }
  .foot { padding: 0 1rem; }
  .act { flex: 1 1 44%; text-align: center; }
  .res-acts { width: 100%; }
}

/* ≤360 — nothing may leave the screen */
@media (max-width: 360px) {
  .wordmark { letter-spacing: .16em; font-size: .66rem; }
  .chips { gap: .35rem; }
  .chip { padding: .55em .8em; }
  .act { flex: 1 1 100%; }
  .refs { grid-template-columns: repeat(4, 1fr); }
  .send { padding: 0 .85em; }
}

/* ══ REDUCED MOTION ═══════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  :root { --grain-opacity: 0.28; }
  *, *::before, *::after {
    animation-duration: 1ms !important; animation-iteration-count: 1 !important;
    transition-duration: 1ms !important; scroll-behavior: auto !important;
  }
  .note, .card { animation: none; opacity: 1; transform: none; }
  .build-bars i { transform: scaleX(1); animation: none; }
  .gen-svg line, .gen-svg rect, .gen-svg circle { stroke-dashoffset: 0; animation: none; }
  .chip:hover { transform: none; }
}
