/* ============================================================
   Creative Engine v2 — printed matter.
   One material world: warm paper, real ink, mud accents (§6).
   No dark mode on the main path. Paper physics, not app physics.
   ============================================================ */

:root {
  --paper: #F3EFE7;
  --paper-deep: #ECE6DA;
  --ink: #1A1714;
  --ink-70: rgba(26, 23, 20, 0.72);
  --ink-50: rgba(26, 23, 20, 0.52);
  --ink-30: rgba(26, 23, 20, 0.32);
  --hairline: rgba(26, 23, 20, 0.16);
  --hairline-soft: rgba(26, 23, 20, 0.09);
  --accent: #4A4438; /* overridden per viewport by territory */
  --kill: #93402A;
  --ship: #4F5C38;
  --mast-h: 58px;
  --ease-paper: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: var(--mast-h);
}

img { max-width: 100%; }
a { color: inherit; }
button { font-family: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; color: inherit; }

::selection { background: var(--ink); color: var(--paper); }

/* ---------- the record's voice: Space Mono, captions ONLY ---------- */

.caption,
.running-head,
.mast-note {
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink-50);
}

.caption a, .caption-link { color: var(--ink-50); }

/* ---------- loading ---------- */

.loading {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  color: var(--ink-50);
}

/* ============================================================
   GATE — same paper, front door
   ============================================================ */

.gate-overlay {
  position: fixed;
  inset: 0;
  background: var(--paper);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.25s var(--ease-paper);
}
.gate-out { opacity: 0; }
.gate-box { text-align: center; max-width: 340px; padding: 24px; }
.gate-logo { height: 30px; margin-bottom: 22px; }
.gate-title {
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.14em;
  margin-bottom: 6px;
}
.gate-sub { font-size: 14px; color: var(--ink-50); margin-bottom: 20px; }
.gate-form { display: flex; gap: 8px; justify-content: center; }
.gate-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--hairline);
  background: transparent;
  border-radius: 4px;
  font-size: 15px;
}
.gate-input:focus { outline: none; border-color: var(--ink); }
.gate-error { margin-top: 14px; color: var(--kill); font-size: 13px; }
.shake { animation: shake 0.3s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ============================================================
   MASTHEAD FOOTER — the escape hatches (§6)
   ============================================================ */

.masthead {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--mast-h);
  background: var(--paper);
  border-top: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 clamp(16px, 4vw, 48px);
  z-index: 40;
}
.mast-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.16em;
}
.mast-logo img { height: 16px; }
.mast-nav { display: flex; gap: clamp(10px, 2.5vw, 28px); margin-left: auto; }
.mast-link {
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ink-70);
  padding: 4px 2px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s;
  white-space: nowrap;
}
.mast-nav .mast-link.mast-on { color: var(--ink); border-bottom-color: var(--ink); }
.mast-link:hover { color: var(--ink); }
.mast-note { margin-left: 12px; white-space: nowrap; }
.mast-note-warn { color: var(--kill); }
.door-catch { animation: doorcatch 0.7s var(--ease-paper); }
@keyframes doorcatch {
  30% { transform: translateY(-4px); }
  60% { transform: translateY(0); }
}

/* ============================================================
   THE ACTS — one thing per viewport
   ============================================================ */

.main { min-height: calc(100vh - var(--mast-h)); }

.act {
  min-height: calc(100vh - var(--mast-h));
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: clamp(20px, 4vw, 56px);
  position: relative;
}

.slide-in { animation: slidein 0.32s var(--ease-paper) both; }
@keyframes slidein {
  from { transform: translateY(22px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.act-skip {
  position: absolute;
  bottom: 26px;
  right: clamp(20px, 4vw, 56px);
}

/* ---------- running head + ticks ---------- */

.running-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 8px;
  margin-bottom: 8px;
  text-transform: uppercase;
}
.rh-source { color: var(--accent); font-weight: 700; }
.rh-source-sm {
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
}

.progress-ticks { display: flex; gap: 4px; margin: 6px 0 0; width: 100%; }
.tick {
  height: 3px;
  flex: 1;
  max-width: 26px;
  background: var(--hairline-soft);
  border-radius: 1px;
}
.tick-done { background: var(--ink-50); }
.tick-now { background: var(--accent); }

/* ============================================================
   ACT 1 — THE COVER
   ============================================================ */

.act-cover { text-align: center; }
.cover-top {
  position: absolute;
  top: clamp(20px, 4vh, 44px);
  text-transform: uppercase;
}
.cover-week {
  font-weight: 700;
  font-size: clamp(64px, 15vw, 168px);
  line-height: 0.95;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  margin: 0 0 clamp(16px, 3vh, 32px);
}
.cover-tally {
  font-size: clamp(19px, 2.4vw, 24px);
  line-height: 1.45;
  max-width: 34ch;
  margin: 0 auto 10px;
  font-weight: 500;
  text-wrap: balance;
}
.cover-from {
  font-size: 16px;
  color: var(--ink-70);
  max-width: 46ch;
  margin: 0 auto 6px;
}
.cover-line {
  font-size: 15px;
  color: var(--ink-70);
  max-width: 52ch;
  margin: 4px auto;
}
.cover-stale { display: block; margin-top: 14px; }
.cover-start { margin-top: clamp(24px, 5vh, 48px); }
.btn-start { font-size: 17px; padding: 13px 44px; }

.cover-who { margin-bottom: 18px; }
.cover-who-label { display: block; margin-bottom: 10px; text-transform: uppercase; }
.cover-who-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 10px; }
.cover-who .input { max-width: 240px; text-align: center; }

.cover-doors { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 26px; }
.door {
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 20px;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  transition: border-color 0.15s, background 0.15s;
}
.door:hover { border-color: var(--ink); }
.cover-again { margin-top: 18px; }

/* ============================================================
   ACT 2 — THE TERRITORY PITCH
   ============================================================ */

.pitch-slot { width: min(920px, 100%); }
.pitch-card { width: 100%; }
.pitch-name {
  font-weight: 600;
  font-size: clamp(48px, 8.5vw, 104px);
  letter-spacing: -0.025em;
  line-height: 0.98;
  margin: clamp(20px, 5vh, 48px) 0 18px;
  color: var(--accent);
}
.pitch-case {
  font-size: clamp(19px, 2.2vw, 22px);
  line-height: 1.5;
  max-width: 60ch;
  margin: 0 0 10px;
}
.pitch-thin { font-size: 16px; color: var(--ink-70); font-style: italic; margin: 0 0 10px; }
.pitch-evidence { display: flex; gap: 18px; flex-wrap: wrap; margin: 14px 0 4px; }
.pitch-actions { display: flex; gap: 12px; margin-top: clamp(20px, 4vh, 40px); }

/* ============================================================
   ACT 3 — THE DECK · the spread (§3)
   ============================================================ */

/* the deck act is a fixed stage: card scrolls if it must, verdicts never leave */
.act-deck {
  justify-content: flex-start;
  height: calc(100vh - var(--mast-h));
  min-height: 0;
  overflow: hidden;
  padding-top: clamp(16px, 3vh, 32px);
  padding-bottom: 14px;
}
.deck-slot {
  width: min(980px, 100%);
  perspective: 1600px;
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}
.deck-controls, .deck-ack { flex: 0 0 auto; }

.spread {
  width: 100%;
  position: relative;
  touch-action: pan-y;
}
.spread.dragging { transition: none; cursor: grabbing; user-select: none; }
.spread:not(.dragging) { transition: transform 0.3s var(--ease-paper); }

.spread-flip {
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.45s var(--ease-paper);
}
.spread.flipped .spread-flip { transform: rotateY(180deg); }
.spread-face { backface-visibility: hidden; }
.spread-back {
  position: absolute;
  inset: 0;
  transform: rotateY(180deg);
  overflow-y: auto;
  background: var(--paper);
}

.spread-body { padding: clamp(14px, 3vh, 30px) 0 8px; }

.lane-stamp {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  border: 1.5px solid var(--ink);
  padding: 3px 9px;
  border-radius: 3px;
  margin-bottom: clamp(10px, 2vh, 20px);
  transform: rotate(-1.2deg);
}

.hook {
  font-weight: 600;
  font-size: clamp(38px, 7.2vw, 96px);
  line-height: 1.02;
  letter-spacing: -0.025em;
  margin: 0 0 clamp(12px, 2vh, 22px);
  max-width: 18ch;
  text-wrap: balance;
}
.hook-lg { font-size: clamp(30px, 4.9vw, 62px); max-width: 26ch; }
.hook-xl { font-size: clamp(25px, 3.7vw, 46px); max-width: 34ch; }
.subline {
  font-size: clamp(17px, 2vw, 20px);
  color: var(--ink-70);
  max-width: 56ch;
  margin: 0 0 clamp(14px, 2.5vh, 26px);
}
.case {
  font-size: clamp(18px, 2.1vw, 21px);
  line-height: 1.5;
  max-width: 60ch;
  margin: 0 0 clamp(14px, 2.5vh, 24px);
  border-left: 3px solid var(--accent);
  padding-left: 16px;
}

/* customer-source cards lead with the quote (§10) */
.lead-quote { margin: clamp(10px, 2vh, 18px) 0 6px; }
.lead-quote blockquote {
  margin: 0 0 4px;
  font-size: clamp(19px, 2.4vw, 26px);
  line-height: 1.35;
  font-style: italic;
  max-width: 52ch;
  color: var(--accent);
}

/* provenance strip */
.provenance {
  border-top: 1px solid var(--hairline);
  padding-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 22px 44px;
}
.prov-quote { margin: 0; max-width: 46ch; }
.prov-quote blockquote {
  margin: 0 0 4px;
  font-size: 15px;
  line-height: 1.45;
  font-style: italic;
  color: var(--ink-70);
}
.prov-money { max-width: 40ch; }
.prov-money p { margin: 0 0 4px; font-size: 15px; color: var(--ink-70); }
.prov-hunch { margin: 0; font-size: 15px; font-style: italic; color: var(--ink-70); }

.flag-line {
  font-size: 14px;
  color: var(--kill);
  border: 1px solid var(--kill);
  border-radius: 4px;
  padding: 8px 12px;
  max-width: 60ch;
  margin: 0 0 16px;
}
.flag-line strong { letter-spacing: 0.02em; }

.spread-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--hairline-soft);
  padding-top: 8px;
  margin-top: 4px;
}
.flip-btn { background: none; border: none; padding: 2px 0; }
.flip-btn:hover { color: var(--ink); }

/* the back — analyst strings */
.back-body { padding: 14px 0; }
.back-table {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 4px 14px;
  margin: 0 0 16px;
  font-size: 14px;
}
.back-table dt { font-family: 'Space Mono', monospace; font-size: 12px; color: var(--ink-50); }
.back-table dd { margin: 0; }
.back-block { border-top: 1px solid var(--hairline-soft); padding: 10px 0; }
.back-block p { margin: 4px 0; font-size: 14px; line-height: 1.5; color: var(--ink-70); }
.back-block-label { text-transform: uppercase; }
.back-ref { word-break: break-all; display: block; margin-top: 4px; }

/* ---------- verdicts ---------- */

.deck-controls { width: min(980px, 100%); margin-top: 18px; }
.verdict-row { display: flex; gap: 10px; }
.vbtn {
  flex: 1;
  padding: 14px 10px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.vkey {
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  color: var(--ink-30);
  margin: 0 6px;
}
.vbtn-kill:hover { border-color: var(--kill); color: var(--kill); }
.vbtn-ship { border-color: var(--ink); }
.vbtn-ship:hover { background: var(--ink); color: var(--paper); }
.vbtn-ship:hover .vkey { color: rgba(243, 239, 231, 0.6); }
.vbtn-save:hover { border-color: var(--ink); }

.deck-ack {
  width: min(980px, 100%);
  min-height: 18px;
  margin-top: 10px;
  text-align: center;
}

.btn-undo { margin-top: 10px; }

.reason-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 0;
}

/* ---------- the stamp: the one theatrical moment ---------- */

.stamp {
  position: absolute;
  top: 16%;
  right: 4%;
  font-weight: 700;
  font-size: clamp(34px, 5.5vw, 64px);
  line-height: 1;
  letter-spacing: 0.08em;
  padding: 10px 22px;
  border: 5px solid currentColor;
  border-radius: 5px;
  color: var(--ink);
  mix-blend-mode: multiply;
  opacity: 0.94;
  pointer-events: none;
  animation: thunk 0.1s cubic-bezier(0.2, 0, 0.4, 1) both;
  z-index: 5;
}
.stamp-kill { color: var(--kill); }
.stamp-ship { color: var(--ship); }
@keyframes thunk {
  from { transform: rotate(-4deg) scale(2.1); opacity: 0; }
  70% { opacity: 1; }
  to { transform: rotate(-4deg) scale(1); opacity: 0.94; }
}

/* exits — paper slides, no bounce */
.exit-kill, .exit-save, .exit-ship { transition: transform 0.32s var(--ease-paper), opacity 0.32s var(--ease-paper) !important; }
.exit-kill { transform: translateX(-115%) rotate(-5deg) !important; opacity: 0 !important; }
.exit-ship { transform: translateX(115%) rotate(5deg) !important; opacity: 0 !important; }
.exit-save { transform: translateY(-70vh) rotate(-1.5deg) !important; opacity: 0 !important; }

.fly-ghost {
  position: fixed;
  border: 1px solid var(--ink-30);
  border-radius: 6px;
  background: var(--paper-deep);
  z-index: 60;
  pointer-events: none;
  transition: transform 0.55s var(--ease-paper), opacity 0.55s var(--ease-paper);
}

/* deck done */
.deck-done { text-align: center; padding: 40px 0; }
.deck-done .running-head { justify-content: center; }
.deck-done-title {
  font-weight: 600;
  font-size: clamp(40px, 7vw, 88px);
  letter-spacing: -0.02em;
  margin: 26px 0 8px;
}
.deck-done-sub { color: var(--ink-70); font-size: 18px; margin: 0 0 26px; }

/* ============================================================
   ACT 4 — THE WIRE
   ============================================================ */

.act-wire { justify-content: flex-start; }
.wire-head { width: min(920px, 100%); margin-top: 8px; }
.wire-scroll { width: min(920px, 100%); }

.wire-quiet { text-align: center; }
.wire-quiet .running-head { justify-content: center; }
.wire-quiet-line {
  font-weight: 600;
  font-size: clamp(34px, 6vw, 72px);
  letter-spacing: -0.02em;
  margin: 30px 0;
}
.wire-quiet-sm { font-size: clamp(22px, 3vw, 30px); margin: 12px 0 6px; }

.wire-story {
  padding: clamp(26px, 5vh, 48px) 0;
  border-bottom: 1px solid var(--hairline);
}
.wire-brand { text-transform: uppercase; }
.wire-headline {
  font-weight: 600;
  font-size: clamp(28px, 4.4vw, 52px);
  line-height: 1.06;
  letter-spacing: -0.02em;
  margin: 8px 0 16px;
  max-width: 26ch;
  text-wrap: balance;
}
.wire-sowhat {
  font-size: clamp(17px, 2vw, 20px);
  max-width: 60ch;
  margin: 14px 0;
}
.wire-actions { margin-top: 8px; }
.wire-next { margin-top: 26px; }

.contact-sheet {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  max-width: 640px;
}
.contact-sheet-sm { max-width: 460px; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
.sheet-cell {
  aspect-ratio: 4 / 5;
  border: 1px solid var(--hairline);
  border-radius: 3px;
  overflow: hidden;
  background: var(--paper-deep);
  position: relative;
}
.sheet-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.85);
  display: block;
}
.sheet-broken img { display: none; }
.sheet-text, .sheet-broken {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--ink-50);
  text-align: center;
}

.still-running { padding: clamp(26px, 5vh, 44px) 0; }
.shelf-title {
  font-weight: 600;
  font-size: clamp(22px, 3vw, 30px);
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}
.shelf-sub { color: var(--ink-70); font-size: 15px; margin: 0 0 16px; }
.shelf-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.shelf-cell { flex: 0 0 130px; }
.shelf-cell img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border: 1px solid var(--hairline);
  border-radius: 3px;
  filter: saturate(0.85);
}
.shelf-cap { display: block; margin-top: 4px; }

/* ============================================================
   ACT 5 — THE COLOPHON
   ============================================================ */

.colophon-card { width: min(760px, 100%); text-align: center; }
.colophon-card .running-head { justify-content: center; }
.colophon-tally {
  display: flex;
  justify-content: center;
  gap: clamp(28px, 7vw, 80px);
  margin: clamp(26px, 5vh, 48px) 0 18px;
}
.tally-num {
  font-weight: 700;
  font-size: clamp(56px, 10vw, 120px);
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.colophon-line { font-size: clamp(18px, 2.2vw, 22px); max-width: 40ch; margin: 0 auto 14px; }
.colophon-note { font-size: 15px; color: var(--ink-70); max-width: 46ch; margin: 10px auto; }
.colophon-top { margin: 22px auto; max-width: 56ch; }
.colophon-top-hook {
  font-weight: 600;
  font-size: clamp(22px, 3vw, 32px);
  letter-spacing: -0.015em;
  line-height: 1.15;
  margin: 6px 0;
}
.colophon-actions { margin: 18px 0; }
.colophon-bye {
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-50);
  margin-top: clamp(24px, 5vh, 44px);
}

/* ============================================================
   THE ROOMS — Deck · Library · Wire (calm grids, same paper)
   ============================================================ */

.room {
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(28px, 5vh, 64px) clamp(16px, 4vw, 48px) 80px;
}
.room-head { margin-bottom: 28px; }
.room-label { text-transform: uppercase; display: block; margin-bottom: 10px; }
.room-title {
  font-weight: 600;
  font-size: clamp(34px, 5vw, 56px);
  letter-spacing: -0.02em;
  line-height: 1.02;
  margin: 0 0 10px;
}
.room-sub { font-size: 16px; color: var(--ink-70); max-width: 64ch; margin: 0; }

.view-tabs { display: flex; gap: 8px; margin-top: 18px; }
.view-tab {
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 500;
}
.view-tab-on { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.lib-section {
  font-weight: 600;
  font-size: clamp(20px, 2.6vw, 26px);
  letter-spacing: -0.01em;
  margin: 40px 0 10px;
  padding-top: 22px;
  border-top: 1px solid var(--hairline);
}

/* ---------- deck rows ---------- */

.deck-list { display: flex; flex-direction: column; }
.deck-row {
  padding: 22px 0 20px 18px;
  border-bottom: 1px solid var(--hairline);
  border-left: 3px solid var(--accent);
  margin-bottom: 2px;
  position: relative;
}
.deck-row-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.deck-row .lane-stamp { margin-bottom: 0; font-size: 10px; padding: 2px 7px; }
.deck-code { font-weight: 700; color: var(--ink); }
.deck-status { margin-left: auto; }
.deck-hook {
  font-weight: 600;
  font-size: clamp(20px, 2.6vw, 28px);
  letter-spacing: -0.015em;
  line-height: 1.15;
  margin: 10px 0 6px;
  max-width: 40ch;
}
.deck-life { font-size: 15px; color: var(--ink-70); margin: 0 0 12px; max-width: 70ch; }
.deck-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.deck-linked { display: block; margin-top: 10px; word-break: break-all; }

.menu-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 18px;
  line-height: 1;
  padding: 2px 8px;
  color: var(--ink-50);
}
.menu-btn:hover { border-color: var(--hairline); color: var(--ink); }
.move-menu {
  position: absolute;
  right: 0;
  top: 46px;
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  box-shadow: 0 8px 28px rgba(26, 23, 20, 0.12);
  z-index: 20;
  min-width: 170px;
  overflow: hidden;
}
.move-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 14px;
  background: none;
  border: none;
  font-size: 14px;
}
.move-item:hover { background: var(--paper-deep); }

.linkad-wrap { display: flex; gap: 8px; margin-top: 12px; max-width: 460px; }
.linkad-wrap .input { flex: 1; }

/* ---------- library grid ---------- */

.lib-search {
  width: 100%;
  max-width: 420px;
  margin-bottom: 24px;
}
.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}
.lib-card {
  border: 1px solid var(--hairline);
  border-top: 3px solid var(--accent);
  border-radius: 6px;
  padding: 16px 16px 14px;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lib-card-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lib-card .lane-stamp { margin-bottom: 0; font-size: 10px; padding: 2px 7px; }
.lib-hook {
  font-weight: 600;
  font-size: 19px;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 0;
}
.lib-subline { font-size: 14px; color: var(--ink-70); margin: 0; }
.lib-meta { margin-top: auto; }
.lib-actions { display: flex; gap: 8px; }
.lib-card-comp { border-top-color: var(--hairline); }
.lib-comp-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 3px;
  filter: saturate(0.85);
}
.lib-comp-hook { font-size: 14px; margin: 0; }

/* ---------- map: gaps ---------- */

.gap-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.gap-card {
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 18px;
  position: relative;
}
.gap-rank {
  font-weight: 700;
  font-size: 42px;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink-30);
  font-variant-numeric: tabular-nums;
}
.gap-label { font-weight: 600; font-size: 19px; margin: 8px 0 6px; letter-spacing: -0.01em; }
.gap-line { font-size: 14px; color: var(--ink-70); margin: 0 0 14px; }

/* ---------- map: coverage grid ---------- */

.coverage-grid {
  display: grid;
  grid-template-columns: 130px repeat(5, 1fr);
  gap: 1px;
  background: var(--hairline);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  overflow: hidden;
  margin-top: 18px;
}
.cov-corner, .cov-colhead, .cov-rowhead, .cov-cell { background: var(--paper); padding: 10px; }
.cov-colhead { text-transform: uppercase; font-size: 11px; }
.cov-rowhead { font-size: 13px; font-weight: 600; display: flex; align-items: center; }
.cov-cell {
  border: none;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 74px;
  position: relative;
  transition: background 0.15s;
}
.cov-cell:not(.cov-untagged)::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--ink);
  opacity: calc(var(--heat, 0) * 0.13);
  pointer-events: none;
}
.cov-cell:hover { background: var(--paper-deep); }
.cov-gap { background: repeating-linear-gradient(-45deg, var(--paper), var(--paper) 6px, var(--paper-deep) 6px, var(--paper-deep) 7px); }
.cov-spend { font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; }
.cov-cac { font-family: 'Space Mono', monospace; font-size: 12px; color: var(--ink-50); }
.cov-cac-warn { color: #9C7420; }
.cov-cac-bad { color: var(--kill); }
.cov-untagged { grid-column: span 5; cursor: default; }
.cov-untagged-head { color: var(--ink-50); }

.cov-detail-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 12px 16px;
  margin-top: 10px;
}
.cov-detail-stats { color: var(--ink-70); font-size: 14px; }
.cov-detail-actions { display: flex; gap: 8px; }

/* ---------- map: territory board ---------- */

.territory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.territory-tile {
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 14px 16px;
  text-align: left;
}
.tile-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.tile-name { font-weight: 600; font-size: 15px; }
.tile-spend { font-size: 14px; color: var(--ink-70); margin: 6px 0; font-variant-numeric: tabular-nums; }
.tile-verdicts { display: flex; gap: 12px; margin-bottom: 8px; }
.vdot-wrap { display: inline-flex; align-items: center; gap: 4px; }
.vdot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.vdot-scale { background: var(--ship); }
.vdot-wait { background: #9C7420; }
.vdot-kill { background: var(--kill); }
.span-all { grid-column: 1 / -1; }

/* ---------- wire room ---------- */

.wire-list { margin-top: 6px; }
.wire-issue {
  border: 1px solid var(--hairline);
  border-radius: 6px;
  margin-top: 10px;
  padding: 0 16px;
}
.wire-issue summary {
  cursor: pointer;
  padding: 13px 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 500;
  font-size: 15px;
}
.wire-issue-body { padding: 4px 0 16px; }
.wire-arch-brand { margin: 12px 0 8px; font-size: 14px; }

/* ============================================================
   ASK — the wizard
   ============================================================ */

.act-ask { justify-content: flex-start; padding-top: clamp(28px, 6vh, 72px); }
.act-ask .running-head { width: min(920px, 100%); }

.ask-q {
  font-weight: 600;
  font-size: clamp(40px, 7vw, 88px);
  letter-spacing: -0.025em;
  line-height: 1;
  margin: clamp(18px, 4vh, 40px) 0 10px;
  width: min(920px, 100%);
}
.ask-rec {
  font-size: clamp(17px, 2vw, 20px);
  color: var(--ink-70);
  width: min(920px, 100%);
  max-width: 60ch;
  margin: 0 0 clamp(18px, 3.5vh, 34px);
}

.ask-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  width: min(920px, 100%);
}
.ask-cards-5 { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
.ask-card {
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 22px 18px;
  text-align: left;
  position: relative;
  transition: border-color 0.15s, transform 0.15s var(--ease-paper);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ask-card:hover { border-color: var(--ink); transform: translateY(-2px); }
.ask-card-rec { border-color: var(--ink); box-shadow: 3px 3px 0 var(--hairline); }
.ask-card-title { font-weight: 700; font-size: 21px; letter-spacing: 0.02em; }
.ask-card-title-sm { font-size: 17px; letter-spacing: 0; }
.ask-card-sub { font-size: 14px; color: var(--ink-70); margin: 0; }
.ask-card-receipts { display: block; }
.ask-rec-mark { text-transform: uppercase; color: var(--accent, var(--ink)); font-weight: 700; }
.thin-dot {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9C7420;
}

.ask-own { width: min(920px, 100%); margin-top: 18px; }
.ask-own summary { cursor: pointer; font-size: 14px; color: var(--ink-70); }
.ask-own-grid { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 0; }

.ask-spark {
  width: min(920px, 100%);
  margin-top: 8px;
  resize: vertical;
  font-size: 16px;
}
.ask-go { margin-top: 22px; width: min(920px, 100%); }

.think-wrap {
  min-height: 50vh;
  display: flex;
  align-items: center;
  width: min(920px, 100%);
}
.think-line {
  font-weight: 600;
  font-size: clamp(26px, 4.5vw, 48px);
  letter-spacing: -0.02em;
  line-height: 1.15;
  max-width: 26ch;
  animation: thinkpulse 2.4s ease-in-out infinite;
}
.think-swap { animation: slidein 0.3s var(--ease-paper), thinkpulse 2.4s ease-in-out infinite; }
@keyframes thinkpulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 0.45; }
}

.answering {
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 6px 0 8px;
}

.ask-controls { width: min(980px, 100%); margin-top: 16px; }
.critique-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.critique-free { display: flex; gap: 8px; max-width: 480px; margin-bottom: 14px; }
.critique-free .input { flex: 1; }
.ask-verdicts { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.ask-cap-note { display: block; margin-bottom: 12px; }

/* ============================================================
   SHARED CONTROLS
   ============================================================ */

.btn {
  display: inline-block;
  background: transparent;
  border: 1px solid var(--ink);
  border-radius: 4px;
  padding: 10px 22px;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn:disabled:hover { background: transparent; color: inherit; }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: #322D27; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-ghost { border-color: transparent; color: var(--ink-50); }
.btn-ghost:hover { background: transparent; color: var(--ink); border-color: var(--hairline); }

.chip {
  display: inline-block;
  font-size: 13px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 5px 13px;
  background: transparent;
}
.chip-btn { cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.chip-btn:hover { border-color: var(--ink); }
.chip-quiet { color: var(--ink-50); border-color: transparent; }
.chip-accent { border-color: var(--accent, var(--ink)); color: var(--accent, var(--ink)); font-weight: 500; }
.chip-accent:hover { background: var(--accent, var(--ink)); color: var(--paper); }
.chip-flagged { color: var(--kill); border-color: var(--kill); }

.input {
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 15px;
  width: 100%;
}
.input:focus { outline: none; border-color: var(--ink); }
.input-sm { padding: 7px 10px; font-size: 13px; }
.select { appearance: auto; }

.verdict-mark {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
}
.verdict-scale { color: var(--ship); }
.verdict-wait { color: #9C7420; }
.verdict-kill { color: var(--kill); }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  bottom: calc(var(--mast-h) + 14px);
  left: 50%;
  transform: translate(-50%, 12px);
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  padding: 11px 20px;
  border-radius: 5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.25s var(--ease-paper);
  z-index: 70;
  max-width: min(90vw, 480px);
  text-align: center;
}
.toast-show { opacity: 1; transform: translate(-50%, 0); }
.toast-warn { background: var(--kill); }

/* ---------- modal (brief view) ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 23, 20, 0.4);
  z-index: 80;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(12px, 4vh, 48px) 16px;
  overflow-y: auto;
}
.modal-box {
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
  position: relative;
}
.modal-wide { max-width: 780px; }
.modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  font-size: 26px;
  color: var(--ink-50);
}
.modal-close:hover { color: var(--ink); }
.modal-open { overflow: hidden; }
.modal-label {
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--ink-50);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.modal-title { font-weight: 600; font-size: 24px; letter-spacing: -0.01em; margin-bottom: 8px; }
.modal-sub { color: var(--ink-70); font-size: 15px; margin: 0 0 16px; }
.modal-fields { display: flex; flex-direction: column; gap: 10px; }

/* ---------- brief view ---------- */

.brief-head { margin-bottom: 14px; }
.idea-badges { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.idea-code { font-family: 'Space Mono', monospace; font-size: 12px; font-weight: 700; }
.brief-intro { font-size: 15px; color: var(--ink-70); }
.brief-actions { margin-top: 18px; }
.brief-note {
  border: 1px solid var(--hairline);
  border-radius: 5px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 14px;
}
.brief-fail, .brief-failed { color: var(--kill); }
.brief-generating { padding: 26px 0; }
.brief-stage-line {
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.01em;
  animation: thinkpulse 2.4s ease-in-out infinite;
  margin-bottom: 10px;
}
.brief-stage-log { display: flex; flex-direction: column; gap: 3px; margin-bottom: 12px; }
.brief-stage-done { color: var(--ship); }
.brief-gen-cap { display: block; }
.brief-catch { display: block; margin-bottom: 12px; color: var(--ship); }
.brief-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.brief-date, .brief-note-inline {
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  color: var(--ink-50);
}
.flag-callout {
  border: 1px solid var(--kill);
  border-radius: 5px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.flag-title { font-weight: 600; color: var(--kill); font-size: 14px; }
.flag-notes { font-size: 14px; color: var(--ink-70); margin: 6px 0 0; }
.rails-callout { margin: 14px 0; font-size: 14px; }
.rails-callout summary { cursor: pointer; color: var(--ink-70); }
.rails-body { white-space: pre-wrap; color: var(--ink-70); margin: 8px 0 0; }

.md-body { font-size: 15px; line-height: 1.6; }
.md-body h1, .md-body h2, .md-body h3 { letter-spacing: -0.01em; margin: 22px 0 8px; }
.md-body h1 { font-size: 24px; }
.md-body h2 { font-size: 20px; }
.md-body h3 { font-size: 17px; }
.md-body hr { border: none; border-top: 1px solid var(--hairline); margin: 18px 0; }
.md-body code {
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  background: var(--paper-deep);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ---------- empty states ---------- */

.empty-state {
  border: 1px dashed var(--hairline);
  border-radius: 8px;
  padding: 44px 24px;
  text-align: center;
  margin: 18px 0;
}
.empty-title { font-weight: 600; font-size: 18px; margin-bottom: 6px; letter-spacing: -0.01em; }
.empty-msg { color: var(--ink-70); font-size: 15px; max-width: 52ch; margin: 0 auto; }

/* ============================================================
   MOBILE — 390px: same acts, type clamps down, buttons + swipe
   ============================================================ */

@media (max-width: 640px) {
  .mast-logo span { display: none; }
  .masthead { gap: 10px; padding: 0 14px; }
  .mast-nav { gap: 14px; overflow-x: auto; }
  .mast-note { display: none; }

  .act { padding: 40px 16px calc(var(--mast-h) + 8px); justify-content: flex-start; }
  .act-cover { justify-content: center; padding-top: 18px; }

  .running-head { flex-direction: column; gap: 2px; }
  .rh-source { order: -1; }

  .verdict-row { position: sticky; bottom: calc(var(--mast-h) + 8px); background: var(--paper); }
  .vbtn { padding: 15px 6px; }

  .provenance { gap: 14px; }
  .coverage-grid { grid-template-columns: 84px repeat(5, minmax(72px, 1fr)); overflow-x: auto; }
  .cov-rowhead { font-size: 11px; }
  .colophon-tally { gap: 22px; }
  .act-skip { position: static; margin-top: 18px; }
  .back-table { grid-template-columns: 90px 1fr; }
}
