/* doclayer — shared mock styling */

:root {
  /* PATCHABLE: /variant/tokens/color/bg guard=colorToken */
  --bg: #0a0a0b;
  /* PATCHABLE: /variant/tokens/color/panel guard=colorToken */
  --panel: #131316;
  /* PATCHABLE: /variant/tokens/color/panel-2 guard=colorToken */
  --panel-2: #1a1a1f;
  /* PATCHABLE: /variant/tokens/color/border guard=colorToken */
  --border: #26262c;
  /* PATCHABLE: /variant/tokens/color/border-soft guard=colorToken */
  --border-soft: #1f1f25;
  /* PATCHABLE: /variant/tokens/color/text guard=colorToken */
  --text: #ebebef;
  /* PATCHABLE: /variant/tokens/color/text-2 guard=colorToken */
  --text-2: #b0b0b8;
  /* PATCHABLE: /variant/tokens/color/text-muted guard=colorToken */
  --text-muted: #6a6a74;
  /* PATCHABLE: /variant/tokens/color/accent guard=colorToken */
  --accent: #95e35d;
  /* PATCHABLE: /variant/tokens/color/accent-soft guard=colorToken */
  --accent-soft: #95e35d22;
  /* PATCHABLE: /variant/tokens/color/accent-2 guard=colorToken */
  --accent-2: #7a9a6e;
  /* PATCHABLE: /variant/tokens/color/vishal guard=colorToken */
  --vishal: #6ba0ff;
  /* PATCHABLE: /variant/tokens/color/akhil guard=colorToken */
  --akhil: #ff8aa8;
  /* PATCHABLE: /variant/tokens/color/warn guard=colorToken */
  --warn: #ffb86b;
  /* third-writer color: muted purple — sits between vishal blue and akhil pink */
  /* PATCHABLE: /variant/tokens/color/third guard=colorToken */
  --third: #b58acc;
  --third-soft: #b58acc1a;
  --third-border: #b58acc55;
  /* PATCHABLE: /variant/tokens/typography/code/family guard=fontFamily */
  --code: 'IBM Plex Mono', 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  /* PATCHABLE: /variant/tokens/typography/sans/family guard=fontFamily */
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  /* PATCHABLE: /variant/tokens/typography/serif/family guard=fontFamily */
  --serif: 'Iowan Old Style', 'Charter', 'Source Serif Pro', Georgia, serif;
  /* PATCHABLE: /variant/tokens/spacing/radius guard=spacing(0,24) */
  --r: 8px;
  /* PATCHABLE: /variant/tokens/spacing/radius-lg guard=spacing(0,32) */
  --r-lg: 14px;
  /* Cross-scenario row reservations (topbar + harness-strip + content + statusbar). */
  /* PATCHABLE: /variant/tokens/spacing/row-topbar guard=spacing(28,80) */
  --row-topbar: 44px;
  /* PATCHABLE: /variant/tokens/spacing/row-harness guard=spacing(20,48) */
  --row-harness: 27px;
  /* PATCHABLE: /variant/tokens/spacing/row-status guard=spacing(20,48) */
  --row-status: 28px;
  /* PATCHABLE: /variant/styles/cssVars/typing-speed-ms guard=int(10,300) */
  --typing-speed-ms: 60;
  /* PATCHABLE: /variant/styles/animation/global/duration guard=float(0.5,2.0) */
  --anim-scale: 1.0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- App chrome ---------- */
.app {
  display: grid;
  grid-template-rows: var(--row-topbar) 1fr var(--row-status);
  height: 100vh;
  width: 100vw;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  font-family: var(--code);
  font-size: 12px;
  color: var(--text-2);
}
.topbar .brand {
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}
.topbar .brand .dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
  margin-right: 8px;
  vertical-align: middle;
  animation: pulse 2.4s ease-in-out infinite;
}
.topbar .crumb { color: var(--text-muted); }
.topbar .crumb b { color: var(--text-2); font-weight: 500; }
.topbar .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--vishal);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sans);
  border: 2px solid var(--panel);
}
.avatar.akhil { background: var(--akhil); }

.statusbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  font-family: var(--code);
  font-size: 11px;
  color: var(--text-muted);
}
.statusbar .live::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent-2);
  margin-right: 6px;
  vertical-align: middle;
  animation: pulse 1.6s ease-in-out infinite;
}

/* ---------- Harness state strip (cross-scenario spine) ---------- */
.harness-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 26px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border-soft);
  font-family: var(--code);
  font-size: 10.5px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.harness-strip .phase {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--accent-soft);
  border: 1px solid #95e35d44;
  color: var(--accent);
  font-weight: 500;
}
.harness-strip .phase.draft    { background: #6ba0ff22; border-color: #6ba0ff44; color: var(--vishal); }
.harness-strip .phase.review   { background: #ffb86b22; border-color: #ffb86b44; color: var(--warn); }
.harness-strip .phase.publish  { background: var(--accent-soft); border-color: #95e35d66; color: var(--accent); }
.harness-strip .phase.reader   { background: #ff8aa822; border-color: #ff8aa844; color: var(--akhil); }
.harness-strip .chain {
  color: var(--text-2);
  letter-spacing: 0.06em;
}
.harness-strip .chain b { color: var(--text); font-weight: 500; }
.harness-strip .pip {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}
.harness-strip .pip::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 6px var(--accent-2);
}
.harness-strip .pip.composing::before,
.harness-strip .pip.binding::before,
.harness-strip .pip.running::before {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 1.4s ease-in-out infinite;
}

/* ---------- Lifecycle ribbon ----------
   Compact mono pill+line indicator hosted inside the harness-strip.
   Current step lit; previous steps dim+checked; future steps muted. */
.lifecycle-ribbon {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0;
  margin: 0 0 0 18px;
  padding: 0;
  font-family: var(--code);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.lifecycle-ribbon .lcr-step {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--text-muted);
  white-space: nowrap;
  position: relative;
}
.lifecycle-ribbon .lcr-step .lcr-num {
  font-size: 8.5px;
  opacity: 0.55;
  font-variant-numeric: tabular-nums;
}
.lifecycle-ribbon .lcr-step.done {
  color: var(--accent-2);
}
.lifecycle-ribbon .lcr-step.done::before {
  content: '\2713';
  font-size: 8.5px;
  color: var(--accent-2);
  margin-right: 2px;
}
.lifecycle-ribbon .lcr-step.current {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: #95e35d44;
  font-weight: 500;
}
.lifecycle-ribbon .lcr-step.current::after {
  content: '';
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  margin-left: 2px;
  animation: pulse 1.6s ease-in-out infinite;
}
.lifecycle-ribbon .lcr-line {
  display: inline-block;
  width: 14px;
  height: 1px;
  background: var(--border);
  margin: 0 1px;
  flex-shrink: 0;
}
.lifecycle-ribbon .lcr-step.done + .lcr-line { background: var(--accent-2); opacity: 0.4; }

/* ---------- Auto-advance pill: hint that the flow continues ---------- */
.advance-pill {
  position: fixed;
  bottom: 16px;
  right: 200px;
  z-index: 99;
  padding: 6px 12px;
  background: var(--panel);
  border: 1px solid #95e35d44;
  border-radius: var(--r);
  font-family: var(--code);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.02em;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  animation: advancePillIn 800ms cubic-bezier(.2,.8,.2,1) 22s both,
             advancePulse 2.6s ease-in-out 24s infinite;
}
.advance-pill:hover { background: var(--accent-soft); text-decoration: none; }
.advance-pill::before {
  content: '';
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  margin-right: 7px;
  vertical-align: middle;
}
@keyframes advancePillIn {
  0%   { opacity: 0; transform: translateY(6px); }
  100% { opacity: 1; transform: translateY(0); pointer-events: auto; }
}
@keyframes advancePulse {
  0%, 100% { box-shadow: 0 0 0 0 #95e35d00; }
  50%      { box-shadow: 0 0 0 4px #95e35d22; }
}
/* keep pill clickable after entry */
body:has(.advance-pill) .advance-pill { pointer-events: auto; }
@media (prefers-reduced-motion: reduce) {
  .advance-pill { animation: none; opacity: 1; transform: none; pointer-events: auto; }
}

/* ---------- Phase tabs ---------- */
.phase-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.phase-tab {
  padding: 6px 14px;
  font-family: var(--code);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 220ms ease;
}
.phase-tab:hover { color: var(--text-2); }
.phase-tab.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: #95e35d44;
}
.phase-tab .step {
  font-size: 9px;
  opacity: 0.5;
  margin-right: 6px;
}

/* ---------- Workspace ---------- */
.workspace {
  display: grid;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}
.panel {
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}
.panel:last-child { border-right: none; }
.panel-header {
  padding: 10px 14px;
  font-family: var(--code);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel-header .pin, .panel-header .dismiss {
  margin-left: auto;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
}
.panel-header .pin:hover { color: var(--accent); background: var(--accent-soft); }
.panel-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

/* ---------- Outline ---------- */
.outline {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 13px;
}
.outline li {
  padding: 7px 10px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: grab;
  position: relative;
  transition: background 180ms ease;
}
.outline li:hover { background: var(--panel-2); }
.outline li .num {
  font-family: var(--code);
  font-size: 10px;
  color: var(--text-muted);
  min-width: 14px;
}
.outline li.nested { padding-left: 32px; }
.outline li.nested .num { color: var(--text-muted); opacity: 0.6; }
.outline li.active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- Evidence cards ---------- */
.evidence {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.evidence-card {
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--r);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: border-color 180ms ease;
}
.evidence-card:hover { border-color: var(--accent); }
.evidence-card .src {
  font-family: var(--code);
  font-size: 10px;
  color: var(--text-muted);
}
.evidence-card .title { color: var(--text); }
.evidence-card .meta {
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
}

/* ---------- Tension tracker ---------- */
.tension {
  background: linear-gradient(180deg, #1c1614 0%, var(--panel-2) 100%);
  border: 1px solid #ffb86b33;
  border-radius: var(--r);
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 12px;
}
.tension .head {
  color: var(--warn);
  font-family: var(--code);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.tension .body { color: var(--text-2); }
.tension .authors { font-size: 10px; color: var(--text-muted); margin-top: 6px; }

/* ---------- Editor area ---------- */
.editor {
  padding: 48px 80px;
  background: var(--bg);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  overflow-y: auto;
  flex: 1;
  position: relative;
}
.editor h1 {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
.editor .subtitle {
  font-size: 15px;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 32px;
}
.editor h2 {
  font-size: 22px;
  font-weight: 600;
  margin: 32px 0 12px;
  letter-spacing: -0.01em;
}
.editor p { margin: 0 0 16px; }

/* ---------- Cursors ---------- */
.cursor {
  position: absolute;
  width: 2px;
  height: 22px;
  border-radius: 1px;
  pointer-events: none;
  z-index: 10;
}
.cursor.vishal { background: var(--vishal); }
.cursor.akhil { background: var(--akhil); }
.cursor::after {
  content: attr(data-name);
  position: absolute;
  top: -18px;
  left: -2px;
  background: inherit;
  color: #fff;
  font-family: var(--sans);
  font-size: 9px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 3px;
  white-space: nowrap;
}

/* ---------- Voice sampler ---------- */
.voice-sample {
  padding: 8px 10px;
  border-left: 2px solid var(--vishal);
  margin-bottom: 10px;
  font-family: var(--serif);
  font-size: 12px;
  color: var(--text-2);
  font-style: italic;
}
.voice-sample.akhil { border-left-color: var(--akhil); }
.voice-sample .who {
  font-family: var(--code);
  font-style: normal;
  font-size: 9px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------- Density meter ---------- */
.density {
  padding: 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--r);
  background: var(--panel-2);
}
.density .label {
  font-family: var(--code);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
}
.density .bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.density .bar .fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 600ms cubic-bezier(.2,.8,.2,1);
}
.density .stat {
  margin-top: 6px;
  font-family: var(--code);
  font-size: 11px;
  color: var(--text-2);
}

/* ---------- Revision variants ---------- */
.variant-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.variant {
  padding: 12px;
  border: 1px solid var(--border-soft);
  background: var(--panel-2);
  border-radius: var(--r);
  font-family: var(--serif);
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 180ms ease;
}
.variant:hover {
  border-color: var(--accent);
  color: var(--text);
}
.variant .label {
  font-family: var(--code);
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

/* ---------- Suggestion chips ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  background: var(--accent-soft);
  border: 1px solid #95e35d44;
  border-radius: 999px;
  font-family: var(--code);
  font-size: 10px;
  color: var(--accent);
  cursor: pointer;
  margin-right: 6px;
  margin-top: 6px;
  transition: all 180ms ease;
}
.chip .x { opacity: 0.5; }
.chip:hover { background: #95e35d33; }
.chip.dismissed {
  opacity: 0;
  transform: translateX(-12px);
  pointer-events: none;
}

/* ---------- Comments ---------- */
.comment {
  padding: 10px;
  background: var(--panel-2);
  border-radius: var(--r);
  margin-bottom: 8px;
  font-size: 12px;
}
.comment .head {
  font-family: var(--code);
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: flex;
  gap: 8px;
}
.comment .head .who { color: var(--text-2); font-weight: 500; }

/* ---------- Reader prior picker ---------- */
.prior-row {
  display: flex;
  gap: 8px;
  margin: 16px 0;
}
.prior-pill {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 12px;
  cursor: pointer;
  transition: all 220ms ease;
  font-family: var(--code);
  letter-spacing: 0.02em;
}
.prior-pill:hover { border-color: var(--text-muted); color: var(--text); }
.prior-pill.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- Animations ---------- */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
@keyframes blink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideRight {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes slideLeft {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

.cursor { animation: blink 1s steps(1, end) infinite; }

.fade-in { animation: fadeIn 600ms ease both; }
.fade-up { animation: fadeUp 600ms cubic-bezier(.2,.8,.2,1) both; }
.slide-right { animation: slideRight 500ms ease both; }
.slide-left { animation: slideLeft 500ms ease both; }

/* Stagger helpers */
.d-1 { animation-delay: 0.1s; }
.d-2 { animation-delay: 0.25s; }
.d-3 { animation-delay: 0.4s; }
.d-4 { animation-delay: 0.6s; }
.d-5 { animation-delay: 0.85s; }
.d-6 { animation-delay: 1.1s; }
.d-7 { animation-delay: 1.4s; }
.d-8 { animation-delay: 1.7s; }

/* ---------- Index page ---------- */
.index-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 64px 32px 96px;
}
.index-wrap h1 {
  font-size: 56px;
  letter-spacing: -0.03em;
  font-weight: 600;
  margin: 0 0 12px;
}
.index-wrap h1 .accent { color: var(--accent); }
.index-wrap .lede {
  font-size: 18px;
  color: var(--text-2);
  max-width: 640px;
  line-height: 1.55;
  margin-bottom: 48px;
}
.scenario-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.scenario-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  cursor: pointer;
  transition: all 250ms ease;
  display: block;
}
.scenario-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
}
.scenario-card .num {
  font-family: var(--code);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}
.scenario-card h3 {
  margin: 0 0 8px;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--text);
}
.scenario-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

/* ---------- Bootstrap-specific ---------- */
.bootstrap-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: radial-gradient(1200px 600px at 50% 30%, #0f1810 0%, var(--bg) 60%);
}
.bootstrap-card {
  width: 560px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 32px;
}
.bootstrap-card h2 {
  margin: 0 0 4px;
  font-size: 22px;
  letter-spacing: -0.01em;
}
.bootstrap-card .sub {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 24px;
}
.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-family: var(--code);
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.field .input {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 12px;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text);
  min-height: 22px;
  position: relative;
}
.field .input.typing::after {
  content: '|';
  color: var(--accent);
  animation: blink 1s steps(1) infinite;
  margin-left: 1px;
}

/* ---------- Reader-harness comparison ---------- */
.reader-col {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.reader-col-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--panel-2);
  font-family: var(--code);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
}
/* ---------- Publish stage ---------- */
.publish-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  height: 100%;
  gap: 0;
}
.publish-form {
  padding: 24px;
  border-right: 1px solid var(--border);
  background: var(--panel);
  overflow-y: auto;
}
.publish-form h3 {
  margin: 0 0 16px;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.publish-preview {
  background: var(--bg);
  padding: 24px;
  overflow-y: auto;
  position: relative;
}
.preview-frame {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 32px 40px;
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.65;
  height: 100%;
}
.publish-btn {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #0a1408;
  border: none;
  border-radius: var(--r);
  font-family: var(--code);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  margin-top: 16px;
}
.publish-btn:hover { background: #aaeb70; }

/* ---------- Misc ---------- */
.kbd {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-family: var(--code);
  font-size: 10px;
  color: var(--text-2);
}
.muted { color: var(--text-muted); }
.scenario-nav {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  gap: 8px;
  z-index: 100;
}
.scenario-nav a {
  padding: 6px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-family: var(--code);
  font-size: 11px;
  color: var(--text-2);
}
.scenario-nav a:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

/* ---------- Scenario guide overlay (cross-scenario) ----------
   Bottom-left toggle pill opens a left-anchored side panel
   containing timed narration beats for the current scenario. */
.guide-btn {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 101;
  padding: 6px 11px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--code);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--accent-2);
  cursor: pointer;
  transition: all 220ms ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.guide-btn::before {
  content: '?';
  display: inline-flex;
  width: 14px; height: 14px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-2);
  color: #0a1408;
  font-size: 9px;
  font-weight: 700;
  font-family: var(--sans);
}
.guide-btn:hover {
  border-color: var(--accent-2);
  color: var(--accent);
  text-decoration: none;
}
.guide-btn.is-open {
  background: var(--accent-soft);
  border-color: #95e35d66;
  color: var(--accent);
}

.scenario-guide {
  position: fixed;
  top: 0; left: 0;
  width: 340px;
  height: 100vh;
  background: var(--panel);
  border-right: 1px solid var(--border);
  box-shadow: 4px 0 32px rgba(0,0,0,0.45);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 260ms cubic-bezier(.2,.8,.2,1);
  font-family: var(--sans);
}
.scenario-guide.is-open { transform: translateX(0); }
.scenario-guide .sg-head {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 10px;
}
.scenario-guide .sg-head .sg-title {
  font-family: var(--code);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  flex: 1;
}
.scenario-guide .sg-head .sg-title b {
  color: var(--text);
  font-weight: 500;
}
.scenario-guide .sg-close {
  appearance: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 22px; height: 22px;
  border-radius: 50%;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.scenario-guide .sg-close:hover { color: var(--accent); border-color: var(--accent); }
.scenario-guide .sg-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px 18px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-2);
}
.scenario-guide .sg-tagline {
  font-family: var(--serif);
  font-size: 14px;
  color: var(--text);
  font-style: italic;
  margin: 0 0 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-soft);
}
.scenario-guide .sg-beat {
  margin: 0 0 14px;
  padding-left: 12px;
  border-left: 2px solid var(--border);
}
.scenario-guide .sg-beat .sg-t {
  display: block;
  font-family: var(--code);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-bottom: 4px;
}
.scenario-guide .sg-beat p {
  margin: 0;
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.55;
}
.scenario-guide .sg-beat:hover { border-left-color: var(--accent); }
.scenario-guide .sg-proof {
  margin-top: 18px;
  padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-left: 2px solid var(--accent);
  border-radius: var(--r);
  font-size: 12px;
  color: var(--text-2);
}
.scenario-guide .sg-proof .lbl {
  font-family: var(--code);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
  margin-bottom: 4px;
}
.scenario-guide .sg-foot {
  padding: 10px 18px;
  border-top: 1px solid var(--border-soft);
  font-family: var(--code);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  display: flex;
  justify-content: space-between;
}
.scenario-guide .sg-foot a { color: var(--accent-2); }

.scenario-guide-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}
.scenario-guide-scrim.is-open {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 800px) {
  .scenario-guide {
    width: 100vw;
    border-right: none;
  }
  .guide-btn { bottom: 12px; left: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .scenario-guide { transition: none; }
}

/* ===== Feedback widget (cross-scenario) =====
   Third-writer "drop a comment" affordance. The trigger pill anchors
   bottom-right (z-index:60, below scenario-nav at z:100). Clicking opens
   a modal panel that drafts a live AI response via /api/draft-feedback,
   with a canned-fallback JSON for offline/demo mode. Color: muted purple
   (--third), sitting tonally between vishal-blue and akhil-pink. Scenario
   context is read from data-scenario / data-phase on .fb-panel.
*/

/* --- Trigger pill: anchored bottom-right, stacked ABOVE scenario-nav
   (scenario-nav lives at bottom:16; this sits at bottom:56 so prev/next
   doesn't occlude clicks on the trigger). --- */
.fb-trigger {
  position: fixed;
  right: 16px;
  bottom: 56px;
  z-index: 101;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 10px;
  border-radius: 999px;
  font-family: var(--code);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--third);
  background: var(--third-soft);
  border: 1px solid var(--third-border);
  cursor: pointer;
  user-select: none;
  transition: background 160ms var(--ease), transform 160ms var(--ease);
  box-shadow: 0 4px 14px rgba(0,0,0,0.32);
}
.fb-trigger:hover { background: #b58acc26; transform: translateY(-1px); }
.fb-trigger .fb-plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--third);
  color: #1a1020;
  font-weight: 700;
  font-size: 11px;
  line-height: 1;
}
.fb-trigger .fb-trig-label b { color: var(--text); font-weight: 500; }

/* --- Scrim --- */
.fb-scrim {
  position: fixed;
  inset: 0;
  background: rgba(4,4,6,0.62);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 70;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms var(--ease);
}
.fb-scrim.open { opacity: 1; pointer-events: auto; }

/* When panel is open: dim the stage and hide the bottom-right nav stack so
   scenario-nav (z:100) / advance-pill (z:99) don't poke through the modal. */
body.fb-open .stage { filter: saturate(0.72) brightness(0.78); transition: filter 240ms var(--ease); }
body.fb-open .scenario-nav,
body.fb-open .advance-pill,
body.fb-open .fb-trigger { opacity: 0; pointer-events: none; transition: opacity 180ms var(--ease); }

/* --- Panel: small modal overlay, anchored right --- */
.fb-panel {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 420px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  z-index: 80;
  background: linear-gradient(180deg, #14101a 0%, var(--panel) 100%);
  border: 1px solid var(--third-border);
  border-radius: 12px;
  box-shadow: 0 18px 48px rgba(0,0,0,0.6), 0 0 0 1px #b58acc1a;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 220ms var(--ease), transform 220ms var(--ease);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.fb-panel.open { opacity: 1; transform: translateY(0); pointer-events: auto; }

/* Header */
.fb-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, #1a1322 0%, transparent 100%);
}
.fb-head .fb-title {
  font-family: var(--code);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text-2);
  text-transform: lowercase;
}
.fb-head .fb-title b { color: var(--third); font-weight: 600; }
.fb-head .fb-close {
  margin-left: auto;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.fb-head .fb-close:hover { color: var(--text); border-color: var(--text-muted); }

/* Body scroll container */
.fb-body {
  overflow-y: auto;
  padding: 12px 14px 4px;
  flex: 1;
  min-height: 0;
}

/* Textarea */
.fb-text {
  width: 100%;
  min-height: 92px;
  max-height: 200px;
  padding: 10px 12px;
  background: #0b0a10;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--code);
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease);
}
.fb-text::placeholder { color: var(--text-muted); }
.fb-text:focus { border-color: var(--third-border); box-shadow: 0 0 0 2px #b58acc22; }

.fb-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  font-family: var(--code);
  font-size: 9.5px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.fb-meta .fb-count {
  font-variant-numeric: tabular-nums; text-align: right;
  padding: 2px 6px; border-radius: 4px;
  background: var(--panel-2); color: var(--text-2);
  transition: color 160ms var(--ease), background 160ms var(--ease);
}
.fb-meta .fb-count.warn { color: var(--warn); background: #3a1f0e; }

/* Submit row */
.fb-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.fb-submit {
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--accent);
  color: #0a1004;
  border: 1px solid var(--accent);
  font-family: var(--code);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: filter 140ms var(--ease);
}
.fb-submit:hover:not(:disabled) { filter: brightness(1.08); }
.fb-submit:disabled {
  background: var(--panel-2);
  border-color: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}
/* --- Drafting state (shown while awaiting response) --- */
.fb-drafting {
  display: none;
  align-items: center;
  gap: 8px;
  margin: 10px 0 4px;
  padding: 10px 12px;
  background: #110d18;
  border: 1px dashed var(--third-border);
  border-radius: 8px;
  font-family: var(--code);
  font-size: 10.5px;
  color: var(--text-2);
  letter-spacing: 0.04em;
}
.fb-drafting.on { display: flex; }
.fb-drafting .fb-pulse {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--third);
  box-shadow: 0 0 8px var(--third);
  animation: fbPulse 1.2s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes fbPulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50%      { opacity: 1;    transform: scale(1.15); }
}

/* --- Response surface (modeled on .toast / .ctx-card) --- */
.fb-response {
  display: none;
  margin: 10px 0 4px;
  padding: 12px 14px;
  background: linear-gradient(180deg, #15101c 0%, var(--panel) 100%);
  border: 1px solid var(--third-border);
  border-radius: 10px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.3), 0 0 0 1px #b58acc14;
}
.fb-response.on { display: block; }
.fb-response .fb-resp-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--code);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--third);
  margin-bottom: 8px;
  text-transform: lowercase;
}
.fb-response .fb-resp-head .fb-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--third);
  box-shadow: 0 0 6px var(--third);
}
.fb-response .fb-resp-head .fb-route { color: var(--text-muted); }
.fb-response .fb-resp-body {
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  letter-spacing: -0.005em;
  min-height: 1.4em;
  white-space: pre-wrap;
}
.fb-response .fb-resp-body.tw-typing::after {
  content: '▍';
  display: inline-block;
  margin-left: 1px;
  color: var(--third);
  animation: fbCaret 0.9s steps(2) infinite;
}
@keyframes fbCaret { 50% { opacity: 0; } }
.fb-response .fb-resp-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--border-soft);
  font-family: var(--code);
  font-size: 9.5px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.fb-response .fb-resp-foot .fb-mode-sub { color: var(--warn); }
.fb-response .fb-again {
  padding: 4px 10px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  font-family: var(--code);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.fb-response .fb-again:hover { color: var(--text); border-color: var(--text-muted); }

/* --- Error surface --- */
.fb-error {
  display: none;
  margin: 10px 0 4px;
  padding: 10px 12px;
  background: #1a0e0e;
  border: 1px solid #ff8aa844;
  border-radius: 8px;
  font-family: var(--code);
  font-size: 11px;
  color: var(--akhil);
  line-height: 1.5;
}
.fb-error.on { display: block; }
.fb-error .fb-retry {
  margin-left: 8px;
  padding: 3px 9px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid #ff8aa844;
  color: var(--akhil);
  font-family: var(--code);
  font-size: 10px;
  cursor: pointer;
}

/* --- Prior threads list (above input on reopen) --- */
.fb-history {
  display: none;
  margin-bottom: 12px;
  padding: 8px 10px;
  background: #0d0c12;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  max-height: 160px;
  overflow-y: auto;
}
.fb-history.on { display: block; }
.fb-history .fb-hist-title {
  font-family: var(--code);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.fb-history .fb-hist-item {
  padding: 6px 0;
  border-top: 1px dashed var(--border-soft);
  font-family: var(--code);
  font-size: 10.5px;
  line-height: 1.45;
}
.fb-history .fb-hist-item:first-of-type { border-top: 0; }
.fb-history .fb-hist-you { color: var(--third); }
.fb-history .fb-hist-arch { color: var(--text-2); display: block; margin-top: 2px; font-family: var(--serif); font-size: 12px; color: var(--text-2); }
.fb-history .fb-hist-ts { color: var(--text-muted); font-size: 9px; float: right; }

/* --- Custom gutter particle: third-writer comment ---
   Re-uses .ev shape; fires once on submit via .ev.fire-once class.
   Only meaningful on scenarios that render a .gutter (e.g. 09). */
.ev.third {
  border-color: var(--third-border);
  color: var(--third);
  background: #b58acc12;
}
.ev.fire-once {
  animation: fbFlyOnce 1600ms var(--ease) 1 both;
}
@keyframes fbFlyOnce {
  0%   { opacity: 0; transform: translate(-280%, -50%) scale(0.6); }
  18%  { opacity: 1; transform: translate(-120%, -50%) scale(1); }
  50%  { opacity: 1; transform: translate(0,     -50%) scale(1.1); box-shadow: 0 0 14px var(--third); }
  82%  { opacity: 1; transform: translate(120%,  -50%) scale(1); }
  100% { opacity: 0; transform: translate(280%,  -50%) scale(0.6); }
}

/* Offline queue banner */
.fb-queue {
  margin-bottom: 10px; padding: 7px 10px;
  background: #1a1408; border: 1px solid #d4a14844; border-radius: 8px;
  font: 10.5px var(--code); color: var(--warn);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.fb-queue-try {
  padding: 3px 9px; border-radius: 999px;
  background: transparent; border: 1px solid #d4a14866;
  color: var(--warn); font: 10px var(--code); cursor: pointer;
}

/* --- Universal submit→architect-pip particle ---
   Spawned at the submit button's center, flies a gentle arc to the
   architect pip on every scenario (works without an orchestration rail).
   Single subtle dot, no trail. */
.fb-particle {
  position: fixed;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--third);
  box-shadow: 0 0 10px var(--third), 0 0 4px var(--third);
  pointer-events: none;
  z-index: 1000;
  opacity: 0;
  will-change: transform, opacity;
  animation: fbCommentFly 700ms cubic-bezier(0.22, 0.61, 0.36, 1) 1 forwards;
}
@keyframes fbCommentFly {
  0%   { opacity: 0; transform: translate(0, 0) scale(0.5); }
  14%  { opacity: 1; transform: translate(calc(var(--fb-dx) * 0.14), calc(var(--fb-dy) * 0.14 + var(--fb-arc) * 0.55)) scale(1); }
  60%  { opacity: 1; transform: translate(calc(var(--fb-dx) * 0.6),  calc(var(--fb-dy) * 0.6  + var(--fb-arc) * 0.85)) scale(1); }
  88%  { opacity: 1; transform: translate(calc(var(--fb-dx) * 0.92), calc(var(--fb-dy) * 0.92 + var(--fb-arc) * 0.25)) scale(0.9); }
  100% { opacity: 0; transform: translate(var(--fb-dx),               var(--fb-dy)) scale(0.55); }
}

/* Architect pip "composing" override while feedback is drafting */
.pip.fb-drafting-pip::before {
  background: var(--third) !important;
  box-shadow: 0 0 8px var(--third) !important;
  animation: pulse 1.4s ease-in-out infinite !important;
}

/* --- Reduced motion: skip transitions & typing --- */
@media (prefers-reduced-motion: reduce) {
  .fb-trigger, .fb-panel, .fb-scrim, .fb-drafting .fb-pulse,
  .fb-response .fb-resp-body.tw-typing::after, .ev.fire-once, .fb-particle {
    transition: none !important;
    animation: none !important;
  }
}

/* ===== Pause + anchored comments ===== */
/* Global pause: stop CSS animations + transitions while body.doclayer-paused.
   The crosshair signals click-to-anchor; suppressed if the global feedback
   panel is open. */
body.doclayer-paused *,
body.doclayer-paused *::before,
body.doclayer-paused *::after {
  animation-play-state: paused !important;
  transition: none !important;
}
body.doclayer-paused { cursor: crosshair; }
body.doclayer-paused.fb-open { cursor: auto; }

/* Pause toast — top-center, slides down on pause, up on resume */
.dlc-toast {
  position: fixed;
  top: 0; left: 50%;
  transform: translate(-50%, -120%);
  z-index: 60;
  padding: 7px 14px;
  background: #0f1a14;
  border: 1px solid var(--accent-2);
  border-top: none;
  border-radius: 0 0 10px 10px;
  color: var(--accent-2);
  font: 11px/1.3 var(--code);
  letter-spacing: 0.02em;
  box-shadow: 0 6px 22px #0008;
  transition: transform 220ms cubic-bezier(0.22, 0.61, 0.36, 1), opacity 220ms;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}
.dlc-toast.on { transform: translate(-50%, 0); opacity: 1; }
.dlc-toast-bars { color: var(--accent-2); margin-right: 2px; letter-spacing: -1px; }

/* Comments layer sits above the demo content but below the global widget scrim (which is z=200) */
.dlc-layer {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 50;
}
.dlc-layer .dlc-dot,
.dlc-layer .dlc-bubble {
  pointer-events: auto;
}

/* Anchor dot — at the click point */
.dlc-dot {
  --dlc-color: var(--third);
  position: fixed;
  width: 10px; height: 10px;
  margin-left: -5px; margin-top: -5px;
  border-radius: 50%;
  background: var(--dlc-color);
  box-shadow: 0 0 10px var(--dlc-color), 0 0 3px var(--dlc-color);
  cursor: pointer;
  animation: dlcDotPulse 1.8s ease-in-out infinite;
}
@keyframes dlcDotPulse {
  0%, 100% { transform: scale(1); opacity: 0.95; }
  50%      { transform: scale(1.18); opacity: 0.7; }
}

/* Comment bubble */
.dlc-bubble {
  --dlc-color: var(--third);
  position: fixed;
  width: 280px;
  background: #0f0f12;
  border: 1px solid #ffffff14;
  border-left: 2px solid var(--dlc-color);
  border-radius: 8px;
  box-shadow: 0 10px 28px #000a, 0 0 0 1px #00000040;
  color: #d8d8dc;
  font: 11.5px/1.45 var(--code);
  overflow: hidden;
  animation: dlcBubbleIn 200ms cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
.dlc-bubble.dlc-collapsed { display: none; }
@keyframes dlcBubbleIn {
  from { opacity: 0; transform: translateY(4px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.dlc-head {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 9px;
  background: #14141a;
  border-bottom: 1px solid #ffffff10;
}
.dlc-avatar {
  width: 8px; height: 8px; border-radius: 50%;
  flex: 0 0 8px;
}
.dlc-handle {
  flex: 1;
  color: #d8d8dc;
  font: 10.5px var(--code);
  letter-spacing: 0.02em;
}
.dlc-close {
  background: transparent; border: 0;
  color: #8a8a92; font: 13px var(--code);
  cursor: pointer; padding: 0 2px;
  line-height: 1;
}
.dlc-close:hover { color: #ddd; }

.dlc-body { padding: 9px 10px 10px; }
.dlc-ta {
  width: 100%;
  background: #08080a;
  border: 1px solid #ffffff14;
  border-radius: 5px;
  color: #e8e8ee;
  font: 11.5px/1.5 var(--code);
  padding: 7px 8px;
  resize: none;
  outline: none;
  box-sizing: border-box;
}
.dlc-ta:focus { border-color: var(--dlc-color); }
.dlc-ta:disabled { opacity: 0.55; }

.dlc-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 6px; gap: 8px;
}
.dlc-count { color: #6c6c75; font: 10px var(--code); }
.dlc-count.warn { color: var(--warn); }
.dlc-submit {
  background: var(--dlc-color);
  color: #0a0a0b;
  border: 0;
  border-radius: 999px;
  padding: 4px 10px;
  font: 10.5px var(--code);
  letter-spacing: 0.02em;
  cursor: pointer;
}
.dlc-submit:disabled { opacity: 0.4; cursor: not-allowed; }

.dlc-drafting {
  display: none;
  margin-top: 8px;
  align-items: center; gap: 7px;
  color: var(--third);
  font: 10.5px var(--code);
}
.dlc-drafting.on { display: flex; }
.dlc-pulse {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--third);
  box-shadow: 0 0 8px var(--third);
  animation: pulse 1.4s ease-in-out infinite;
}

.dlc-error {
  display: none;
  margin-top: 8px;
  padding: 5px 7px;
  background: #1a0e0e;
  border: 1px solid #ff6b6b44;
  border-radius: 5px;
  color: #ff9b9b;
  font: 10.5px var(--code);
}
.dlc-error.on { display: block; }

/* Thread view */
.dlc-msg {
  display: flex; gap: 7px;
  padding: 5px 0;
  border-top: 1px dashed #ffffff0a;
}
.dlc-msg:first-child { border-top: 0; padding-top: 2px; }
.dlc-msg-tag {
  flex: 0 0 auto;
  color: var(--dlc-color);
  font: 10px var(--code);
  letter-spacing: 0.02em;
  text-transform: lowercase;
}
.dlc-msg-arch .dlc-msg-tag { color: var(--third); }
.dlc-msg-text {
  flex: 1;
  color: #d8d8dc;
}
.dlc-msg-text.dlc-typing::after {
  content: '\258C';
  margin-left: 1px;
  color: var(--third);
  animation: pulse 1s steps(2) infinite;
}
.dlc-foot-thread { justify-content: flex-end; margin-top: 6px; }
.dlc-resolve {
  background: transparent;
  border: 0;
  color: #8a8a92;
  font: 10.5px var(--code);
  cursor: pointer;
  padding: 2px 4px;
}
.dlc-resolve:hover { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  .dlc-toast, .dlc-dot, .dlc-bubble, .dlc-pulse, .dlc-msg-text.dlc-typing::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ===== Identity + settings ===== */
/* Onboarding modal: dark backdrop + centered card. */
.id-modal {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--sans);
}
.id-modal-scrim {
  position: absolute; inset: 0;
  background: rgba(4, 6, 10, 0.72);
  backdrop-filter: blur(3px);
  animation: idFade 180ms ease both;
}
.id-modal-card {
  position: relative;
  width: min(420px, calc(100vw - 32px));
  padding: 22px 22px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
  animation: idRise 220ms cubic-bezier(.2,.8,.2,1) both;
}
.id-modal-title {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.3;
  color: var(--text);
  margin-bottom: 6px;
}
.id-modal-lede {
  font-family: var(--code);
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.5;
}
.id-modal-input {
  width: 100%;
  padding: 9px 12px;
  background: #0d0c12;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--code);
  font-size: 13px;
  outline: none;
  transition: border-color 160ms ease;
  box-sizing: border-box;
}
.id-modal-input:focus { border-color: var(--accent-2); }
.id-modal-err {
  min-height: 16px;
  margin-top: 6px;
  font: 10.5px var(--code);
  color: var(--akhil);
}
.id-modal-row {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px;
}
.id-modal-cancel, .id-modal-submit {
  padding: 7px 14px;
  border-radius: 999px;
  font-family: var(--code);
  font-size: 11px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  transition: all 160ms ease;
}
.id-modal-cancel:hover { color: var(--text); border-color: var(--text-muted); }
.id-modal-submit {
  background: var(--accent-soft);
  border-color: #95e35d66;
  color: var(--accent);
}
.id-modal-submit:hover { background: var(--accent); color: #0a1408; }
body.id-modal-open { overflow: hidden; }

/* Settings gear button (bottom-left, just right of ?guide). */
.id-gear {
  position: fixed;
  bottom: 16px;
  left: 88px;
  z-index: 101;
  padding: 6px 9px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--code);
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 220ms ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.id-gear:hover { border-color: var(--accent-2); color: var(--accent-2); }
.id-gear-icon { font-size: 12px; line-height: 1; }
.id-gear-avatar {
  display: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  align-items: center; justify-content: center;
  font-family: var(--sans);
  font-size: 8.5px;
  font-weight: 700;
  color: #0a1408;
}

/* Settings panel: small left-anchored slide-in (mirrors scenario-guide). */
.id-settings {
  position: fixed;
  top: 0; left: 0;
  width: 320px;
  height: 100vh;
  background: var(--panel);
  border-right: 1px solid var(--border);
  box-shadow: 4px 0 32px rgba(0,0,0,0.45);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 240ms cubic-bezier(.2,.8,.2,1);
  font-family: var(--sans);
}
.id-settings.is-open { transform: translateX(0); }
.id-set-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 10px;
  font-family: var(--code);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.id-set-head span { flex: 1; }
.id-set-close {
  appearance: none; background: transparent;
  border: 1px solid var(--border); color: var(--text-muted);
  width: 22px; height: 22px; border-radius: 50%;
  cursor: pointer; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.id-set-close:hover { color: var(--accent); border-color: var(--accent); }
.id-set-body {
  padding: 16px 18px;
  font-size: 13px;
  color: var(--text-2);
  overflow-y: auto;
  flex: 1;
}
.id-set-you { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.id-set-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  color: #0a1408;
}
.id-set-handle { font-family: var(--code); font-size: 13px; color: var(--text); display: flex; flex-direction: column; gap: 2px; }
.id-set-label { font-size: 9.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.id-set-variant { font-family: var(--code); font-size: 10.5px; color: var(--text-muted); margin-bottom: 8px; }
.id-set-variant code { color: var(--accent); background: transparent; }
.id-set-stats {
  font-family: var(--code); font-size: 10.5px;
  color: var(--text-muted);
  padding: 8px 10px; border-radius: 6px;
  background: #0d0c12;
  margin-bottom: 14px;
}
.id-set-stats b { color: var(--text); font-weight: 600; }
.id-set-anon {
  font-family: var(--code); font-size: 11px;
  color: var(--text-muted); line-height: 1.55;
  margin-bottom: 14px;
}
.id-set-action {
  display: block; width: 100%; text-align: left;
  margin-top: 6px;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-2);
  font-family: var(--code);
  font-size: 11.5px;
  cursor: pointer;
  transition: all 140ms ease;
}
.id-set-action:hover { color: var(--text); border-color: var(--text-muted); }
.id-set-join { color: var(--accent); border-color: #95e35d44; }
.id-set-join:hover { background: var(--accent-soft); }
.id-set-danger { color: var(--akhil); border-color: #ff8aa844; margin-top: 14px; }
.id-set-danger:hover { background: #1a0e0e; color: var(--akhil); border-color: var(--akhil); }
.id-settings-scrim {
  position: fixed; inset: 0;
  background: rgba(4, 6, 10, 0.45);
  z-index: 150;
  opacity: 0; pointer-events: none;
  transition: opacity 180ms ease;
}
.id-settings-scrim.is-open { opacity: 1; pointer-events: auto; }

/* Improvements modal (cross-scenario list). */
.id-improve .id-improve-card {
  position: relative;
  width: min(560px, calc(100vw - 32px));
  max-height: 80vh;
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
  animation: idRise 220ms cubic-bezier(.2,.8,.2,1) both;
}
.id-improve-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center;
  font-family: var(--code);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.id-improve-head span { flex: 1; }
.id-improve-close {
  appearance: none; background: transparent;
  border: 1px solid var(--border); color: var(--text-muted);
  width: 22px; height: 22px; border-radius: 50%;
  cursor: pointer; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
}
.id-improve-body {
  padding: 14px 18px;
  overflow-y: auto;
  font-size: 12.5px;
  color: var(--text-2);
}
.id-improve-empty {
  font-family: var(--code); font-size: 11px;
  color: var(--text-muted); padding: 18px 0; text-align: center;
}
.id-improve-group { margin-bottom: 14px; }
.id-improve-sc {
  display: inline-block;
  font-family: var(--code);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-bottom: 6px;
  text-decoration: none;
  border-bottom: 1px dashed var(--border-soft);
  padding-bottom: 3px;
}
.id-improve-sc:hover { color: var(--accent); }
.id-improve-list { list-style: none; margin: 0; padding: 0; }
.id-improve-item {
  padding: 8px 10px;
  border-left: 2px solid var(--border-soft);
  margin: 6px 0;
  font-family: var(--code);
  font-size: 11.5px;
  line-height: 1.5;
}
.id-improve-item.resolved { opacity: 0.55; text-decoration: line-through; }
.id-improve-ts { color: var(--text-muted); font-size: 9.5px; margin-right: 8px; }
.id-improve-text { color: var(--text); }
.id-improve-resp { display: block; margin-top: 4px; font-family: var(--serif); font-size: 12.5px; color: var(--text-2); }

@keyframes idFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes idRise {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== Patches modal (Phase 4 "see all patches →") ===== */
.id-patches-modal .id-patches-card {
  position: relative;
  width: min(620px, calc(100vw - 32px));
  max-height: 80vh;
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
  animation: idRise 220ms cubic-bezier(.2,.8,.2,1) both;
}
.id-patches-modal .id-patches-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center;
  font-family: var(--code);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.id-patches-modal .id-patches-head span { flex: 1; }
.id-patches-modal .id-patches-close {
  appearance: none; background: transparent;
  border: 1px solid var(--border); color: var(--text-muted);
  width: 22px; height: 22px; border-radius: 50%;
  cursor: pointer; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
}
.id-patches-modal .id-patches-close:hover {
  color: var(--text); border-color: var(--text-muted);
}
.id-patches-modal .id-patches-body {
  flex: 1 1 auto;
  padding: 14px 18px;
  overflow-y: auto;
  font-size: 12.5px;
  color: var(--text-2);
}
.id-patches-modal .id-patches-empty {
  font-family: var(--code); font-size: 11px;
  color: var(--text-muted); padding: 18px 0; text-align: center;
}
.id-patches-modal .pm-group { margin-bottom: 18px; }
.id-patches-modal .pm-scenario-header {
  display: block;
  position: sticky;
  top: -14px;
  padding: 6px 0 4px;
  margin-bottom: 6px;
  background: linear-gradient(var(--panel) 65%, transparent);
  font-family: var(--code);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
  text-decoration: none;
  border-bottom: 1px dashed var(--border-soft);
  z-index: 1;
}
.id-patches-modal .pm-scenario-header:hover { color: var(--accent); }
.id-patches-modal .pm-list { list-style: none; margin: 0; padding: 0; }
.id-patches-modal .pm-patch-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-areas:
    "intent when status"
    "sup    sup  sup";
  gap: 4px 10px;
  align-items: baseline;
  padding: 8px 10px;
  border-left: 2px solid var(--border-soft);
  margin: 6px 0;
  font-family: var(--code);
  font-size: 11.5px;
  line-height: 1.5;
  transition: background-color 200ms ease;
}
.id-patches-modal .pm-patch-row.pm-superseded {
  opacity: 0.75;
}
.id-patches-modal .pm-patch-row.pm-superseded .pm-intent {
  text-decoration: line-through;
  text-decoration-color: #ffffff44;
  color: var(--text-muted);
}
.id-patches-modal .pm-patch-row.pm-flash {
  background: rgba(120, 220, 140, 0.10);
  border-left-color: var(--accent);
}
.id-patches-modal .pm-intent { grid-area: intent; color: var(--text); word-break: break-word; }
.id-patches-modal .pm-when   { grid-area: when; color: var(--text-muted); font-size: 10px; }
.id-patches-modal .pm-badge  {
  grid-area: status;
  font-size: 9.5px;
  padding: 1px 7px;
  border-radius: 9px;
  text-transform: lowercase;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
}
.id-patches-modal .pm-badge-applied    { background: var(--accent-soft); color: var(--accent); }
.id-patches-modal .pm-badge-superseded { background: #2a2026; color: var(--text-muted); text-decoration: line-through; }
.id-patches-modal .pm-badge-undone     { background: #3a2a18; color: #e7a86b; }
.id-patches-modal .pm-badge-rev-accepted { background: #1a2a3a; color: var(--vishal); }
.id-patches-modal .pm-badge-rev-proposed { background: #1a1a26; color: var(--text-muted); border-color: #2a2a3a; }
.id-patches-modal .pm-icon-rv {
  display: inline-block;
  color: var(--vishal);
  font-family: var(--code);
  font-size: 11px;
  margin-right: 4px;
  opacity: 0.8;
}
.id-patches-modal .pm-superseded-ref { grid-area: sup; font-size: 10px; color: var(--text-muted); }
.id-patches-modal .pm-superseded-by {
  color: var(--text-muted);
  text-decoration: dotted underline;
}
.id-patches-modal .pm-superseded-by:hover { color: var(--accent-2); }
.id-patches-modal .id-patches-foot {
  padding: 10px 18px 14px;
  border-top: 1px solid var(--border-soft);
  display: flex; justify-content: center;
}
.id-patches-modal .pm-load-more-btn {
  appearance: none; background: transparent;
  border: 1px solid var(--border); color: var(--text-2);
  font: 10.5px var(--code); letter-spacing: 0.08em;
  text-transform: lowercase;
  padding: 6px 14px; border-radius: 14px;
  cursor: pointer;
}
.id-patches-modal .pm-load-more-btn:hover {
  color: var(--accent); border-color: var(--accent-soft);
}

/* Popover macro badge — small accent-2 pill alongside intent. */
.patch-stack-popover .psp-macro-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #14141a;
  color: var(--accent-2);
  font: 9.5px var(--code);
  letter-spacing: 0.04em;
  text-transform: lowercase;
  vertical-align: baseline;
}

@media (max-width: 560px) {
  .id-gear { left: 78px; bottom: 12px; }
  .id-settings { width: 88vw; }
}
@media (prefers-reduced-motion: reduce) {
  .id-modal-scrim, .id-modal-card, .id-improve-card, .id-patches-card { animation: none !important; }
  .id-settings { transition: none !important; }
  .id-patches-modal .pm-patch-row { transition: none !important; }
}

/* ===== Patch preview + apply UX (Phase 4) ===== */
.patched-hidden { display: none !important; }

.patch-preview {
  margin-top: 8px;
  padding: 8px 9px 7px;
  background: #0c0c11;
  border: 1px solid #2a2a32;
  border-radius: 6px;
  font: 10.5px var(--code);
  color: var(--text-2);
}
.patch-preview-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.patch-intent {
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.patch-ops {
  display: flex; flex-direction: column; gap: 3px;
  padding: 4px 5px;
  background: #07070a;
  border-radius: 4px;
}
.patch-preview .patch-op {
  display: flex; gap: 6px; align-items: baseline;
  flex-wrap: wrap;
  line-height: 1.4;
}
.patch-preview .ptv-key {
  color: var(--text-muted);
  flex: 0 0 auto;
}
.patch-preview .ptv-from {
  color: #ff9b9b;
  text-decoration: line-through;
  text-decoration-color: #ff9b9b66;
}
.patch-preview .ptv-arr {
  color: var(--text-muted);
  margin: 0 2px;
}
.patch-preview .ptv-to {
  color: var(--accent);
}
.patch-op-empty {
  color: var(--text-muted);
  font-style: italic;
}
/* ---- Macro / structural / block-op badges in patch preview ---- */
.patch-macro-row {
  display: flex; gap: 6px; align-items: center;
  margin: 4px 0 6px;
  flex-wrap: wrap;
  font-size: 10.5px;
}
.patch-macro-kind {
  color: var(--text);
  font-family: var(--code);
}
.patch-macro-params {
  color: var(--text-muted);
  font-family: var(--code);
  font-size: 10px;
  word-break: break-word;
}
.patch-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.patch-badge-structural {
  background: var(--warn);
  color: #1a1100;
}
.patch-badge-block {
  background: var(--third);
  color: #1a0a22;
  margin-right: 6px;
}
.patch-op-block {
  align-items: center;
}
.patch-ops-effective {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border-soft);
}
.patch-ops-effective-label {
  font-size: 9.5px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.patch-signin-btn {
  background: var(--accent);
  color: var(--bg);
}
.patch-signin-btn:hover:not(:disabled) {
  background: var(--accent-2);
}
.patch-preview-foot {
  display: flex; gap: 8px; align-items: center;
  margin-top: 7px;
}
.patch-apply-btn {
  background: var(--accent);
  color: #0a0a0b;
  border: 0;
  border-radius: 4px;
  padding: 5px 10px;
  font: 600 10.5px var(--code);
  cursor: pointer;
  letter-spacing: 0.01em;
}
.patch-apply-btn:disabled { opacity: 0.5; cursor: default; }
.patch-apply-btn:hover:not(:disabled) { background: var(--accent-2); }
.patch-discard-link {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font: 10.5px var(--code);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: #ffffff22;
}
.patch-discard-link:hover { color: var(--text); }

.patch-applying-row {
  display: flex; align-items: center; gap: 7px;
  margin-top: 6px;
  font: 10.5px var(--code);
  color: var(--third);
}
.patch-applying-label { letter-spacing: 0.02em; }

.patch-error {
  margin-top: 6px;
  padding: 5px 7px;
  background: #1a120a;
  border: 1px solid var(--warn);
  border-radius: 4px;
  color: var(--warn);
  font: 10.5px var(--code);
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.patch-error-action {
  background: transparent;
  border: 1px solid var(--warn);
  color: var(--warn);
  border-radius: 3px;
  padding: 2px 7px;
  font: 10.5px var(--code);
  cursor: pointer;
}
.patch-error-action:hover { background: #ffb86b22; }

.patch-preview.patch-applied {
  border-color: var(--accent-soft);
}
.patch-applied-countdown {
  margin-top: 7px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: center;
  font: 10.5px var(--code);
}
.patch-applied-countdown .pac-label { color: var(--text-2); }
.patch-applied-countdown .pac-secs { color: var(--accent); font-weight: 600; }
.patch-applied-countdown .pac-bar {
  grid-column: 1 / span 2;
  height: 3px;
  background: #1a1a20;
  border-radius: 2px;
  overflow: hidden;
}
.patch-applied-countdown .pac-fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
  transition: width 90ms linear;
}
.patch-applied-countdown.expired .pac-fill { background: var(--text-muted); }
.patch-applied-countdown .pac-undone {
  color: var(--text-muted);
  font-style: italic;
}
.patch-undo-btn {
  background: transparent;
  border: 1px solid var(--text-muted);
  color: var(--text);
  border-radius: 999px;
  padding: 2px 9px;
  font: 10.5px var(--code);
  cursor: pointer;
}
.patch-undo-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.patch-undo-btn:disabled { opacity: 0.5; cursor: default; }

/* Patch-stack hover popover */
.patch-stack-popover {
  position: fixed;
  z-index: 9500;
  width: 320px;
  max-height: 280px;
  overflow-y: auto;
  padding: 8px 9px;
  background: #0a0a0e;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 14px 32px rgba(0,0,0,0.55);
  font: 10.5px var(--code);
  color: var(--text-2);
}
.patch-stack-popover .psp-head {
  color: var(--text-muted);
  text-transform: lowercase;
  letter-spacing: 0.04em;
  margin: 4px 0 3px;
  font-size: 9.5px;
}
.patch-stack-popover .psp-current {
  padding: 4px 6px;
  background: #14141a;
  border-radius: 4px;
  color: var(--accent);
  word-break: break-word;
  margin-bottom: 4px;
}
.patch-stack-popover .psp-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 6px;
  padding: 4px 0;
  border-top: 1px dashed #ffffff0a;
  align-items: baseline;
}
.patch-stack-popover .psp-row:first-of-type { border-top: 0; }
.patch-stack-popover .psp-when { color: var(--text-muted); font-size: 9.5px; }
.patch-stack-popover .psp-intent { color: var(--text); word-break: break-word; }
.patch-stack-popover .psp-author { color: var(--text-muted); font-size: 9.5px; grid-column: 1 / span 2; }
.patch-stack-popover .psp-badge {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 8px;
  text-transform: lowercase;
  letter-spacing: 0.04em;
}
.patch-stack-popover .psp-badge-applied {
  background: var(--accent-soft);
  color: var(--accent);
}
.patch-stack-popover .psp-badge-superseded {
  background: #2a2026;
  color: var(--text-muted);
}
.patch-stack-popover .psp-superseded .psp-intent,
.patch-stack-popover .psp-superseded .psp-when {
  text-decoration: line-through;
  text-decoration-color: #ffffff44;
  color: var(--text-muted);
}
.patch-stack-popover .psp-empty {
  color: var(--text-muted);
  font-style: italic;
  padding: 4px 0;
}

@media (prefers-reduced-motion: reduce) {
  .patch-applied-countdown .pac-fill { transition: none !important; }
}

/* =========================================================================
   Phase 5 — Variants gallery + cross-variant browse + diff modal.
   ========================================================================= */
.variants-page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 56px 32px 96px;
}
.variants-page h1 {
  font-size: 44px;
  letter-spacing: -0.03em;
  font-weight: 600;
  margin: 0 0 14px;
  line-height: 1.05;
  color: var(--text);
}
.variants-page .vp-lede {
  font-family: var(--serif);
  font-size: 17px;
  color: var(--text-2);
  max-width: 720px;
  line-height: 1.55;
  margin: 0 0 28px;
}
.variants-page .vp-cta-anon {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  margin-bottom: 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 2px solid var(--akhil);
  border-radius: var(--r);
  font-size: 13px;
  color: var(--text-2);
}
.variants-page .vp-cta-anon-btn {
  font-family: var(--code);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: #0a1408;
  background: var(--accent);
  border: none;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
}
.variants-page .vp-cta-anon-btn:hover { filter: brightness(1.05); }

.variants-page .vp-filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.variants-page .vp-search {
  flex: 1 1 280px;
  min-width: 240px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--code);
  font-size: 12px;
}
.variants-page .vp-search:focus {
  outline: none;
  border-color: var(--accent);
}
.variants-page .vp-sort {
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-2);
  font-family: var(--code);
  font-size: 12px;
}
.variants-page .vp-count {
  font-family: var(--code);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.variants-page .vp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}
.variants-page .vp-empty {
  grid-column: 1 / -1;
  padding: 36px 18px;
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  border: 1px dashed var(--border);
  border-radius: var(--r);
}

.variant-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r);
  text-decoration: none;
  color: inherit;
  transition: border-color 180ms ease, transform 180ms ease;
}
.variant-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  text-decoration: none;
}
.variant-card .vc-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.variant-card-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  color: #0a1408;
  font-family: var(--code);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.variant-card .vc-id { flex: 1; min-width: 0; }
.variant-card .vc-email {
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.variant-card .vc-sub {
  font-family: var(--code);
  font-size: 10.5px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-top: 2px;
}
.variant-card .vc-sub code {
  font-family: var(--code);
  color: var(--text-2);
  background: var(--panel-2);
  padding: 1px 4px;
  border-radius: 3px;
}
.variant-card .vc-stats {
  font-family: var(--code);
  font-size: 11px;
  color: var(--text-2);
  letter-spacing: 0.04em;
}
.variant-card .vc-stats b { color: var(--accent); font-weight: 600; }
.variant-card .vc-paths {
  list-style: none;
  margin: 0;
  padding: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-top: 1px solid var(--border-soft);
  font-size: 12px;
  color: var(--text-2);
}
.variant-card .vc-paths li {
  font-family: var(--code);
  font-size: 11px;
  color: var(--text-2);
  padding-left: 12px;
  position: relative;
}
.variant-card .vc-paths li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--text-muted);
}
.variant-card .vc-paths-empty {
  padding: 8px 0 0;
  border-top: 1px solid var(--border-soft);
  font-family: var(--code);
  font-size: 10.5px;
  color: var(--text-muted);
  font-style: italic;
}

/* Palette chip strip — 5 color tokens (bg / panel / accent / vishal / akhil)
   for this variant. Makes visual divergence visible BEFORE the card is opened. */
.variant-card .vc-palette {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 2px;
}
.variant-card .vc-palette-chip {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--border-soft);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
  flex-shrink: 0;
}
.variant-card .vc-palette-chip.is-diverged {
  /* Diverged from canonical — bright ring to call attention. */
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.10), 0 0 0 1px var(--accent-soft);
}
.variant-card .vc-palette-label {
  font-family: var(--code);
  font-size: 9.5px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-left: 4px;
}

/* Scenario-coverage pills — mono badges showing which scenarios this
   variant has patched. Each pill is clickable, opens that scenario in the
   variant's browse mode. */
.variant-card .vc-scenarios {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.variant-card .vc-scenario-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  font-family: var(--code);
  font-size: 10px;
  color: var(--text-2);
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  letter-spacing: 0.05em;
  text-decoration: none;
}
.variant-card .vc-scenario-pill:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.variant-card .vc-scenarios-empty {
  font-family: var(--code);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  font-style: italic;
}
.variant-card .vc-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
}
.variant-card .vc-browse {
  font-family: var(--code);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.04em;
}
.variant-card .vc-diff {
  font-family: var(--code);
  font-size: 10.5px;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border-soft);
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 0.04em;
}
.variant-card .vc-diff:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.variants-page .vp-foot {
  display: flex;
  justify-content: center;
  margin-bottom: 32px;
}
.variants-page .vp-load-more {
  font-family: var(--code);
  font-size: 12px;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
  padding: 8px 18px;
  border-radius: 6px;
  cursor: pointer;
}
.variants-page .vp-footer-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-family: var(--code);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.variants-page .vp-footer-link a { color: var(--accent); }

/* ---- Read-only banner ---- */
.variant-readonly-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9000;
  background: linear-gradient(90deg, rgba(255,138,168,0.16) 0%, rgba(255,138,168,0.08) 100%);
  border-bottom: 2px solid var(--akhil);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.variant-readonly-banner .vrb-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 8px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--code);
  font-size: 11.5px;
  color: var(--text);
  letter-spacing: 0.03em;
  flex-wrap: wrap;
}
.variant-readonly-banner .vrb-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--akhil);
  box-shadow: 0 0 10px var(--akhil);
  flex-shrink: 0;
}
.variant-readonly-banner .vrb-text { flex: 1; color: var(--text-2); }
.variant-readonly-banner .vrb-text b { color: var(--text); font-weight: 600; }
.variant-readonly-banner .vrb-diff,
.variant-readonly-banner .vrb-back {
  color: var(--akhil);
  text-decoration: none;
  font-size: 11px;
  letter-spacing: 0.05em;
  padding: 3px 10px;
  border: 1px solid #ff8aa866;
  border-radius: 999px;
}
.variant-readonly-banner .vrb-diff:hover,
.variant-readonly-banner .vrb-back:hover {
  color: var(--text);
  border-color: var(--akhil);
  background: rgba(255,138,168,0.12);
}

/* Push page content below the fixed banner. */
body.variant-readonly { padding-top: 38px; }
/* Offset fixed-position descendants that anchor to the top of the viewport.
   38px is the banner height; without this, top-anchored fixed UI (toasts,
   side panels, gear icons, etc.) collides with or hides under the banner.
   Bottom-anchored fixed UI (advance-pill, fb-trigger, scenario-nav, guide-btn,
   id-gear) is unaffected and intentionally left alone. */
body.variant-readonly .dlc-toast { top: 38px; }
body.variant-readonly .scenario-guide { top: 38px; height: calc(100vh - 38px); }
body.variant-readonly .id-settings { top: 38px; height: calc(100vh - 38px); }
body.variant-readonly .scenario-guide-scrim,
body.variant-readonly .id-settings-scrim,
body.variant-readonly .fb-scrim,
body.variant-readonly .dlc-layer {
  top: 38px;
  /* These elements use `inset: 0`; override top so the banner stays visible. */
}
/* Hide write-side UI in read-only mode. */
body.variant-readonly .fb-trigger,
body.variant-readonly .id-set-action.id-set-danger,
body.variant-readonly .patch-preview .patch-apply-btn,
body.variant-readonly .patch-preview .patch-discard-link,
body.variant-readonly .patch-preview-foot,
body.variant-readonly .patch-applied-countdown {
  display: none !important;
}
body.variant-readonly .patch-preview::after {
  content: 'read-only · this is someone else\'s variant';
  display: block;
  margin-top: 8px;
  padding: 6px 10px;
  font-family: var(--code);
  font-size: 10.5px;
  color: var(--akhil);
  background: rgba(255,138,168,0.10);
  border: 1px dashed var(--akhil);
  border-radius: 4px;
  letter-spacing: 0.04em;
}

/* ---- Diff modal ---- */
.variant-diff-modal .id-patches-card {
  /* Inherits from .id-patches-modal sizing — we just narrow it. */
  max-width: 720px;
}
.variant-diff-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 12px;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border-soft);
  font-family: var(--code);
  font-size: 11px;
  align-items: center;
}
.variant-diff-row:last-child { border-bottom: none; }
.variant-diff-row .vdr-label {
  color: var(--text-2);
  letter-spacing: 0.04em;
  word-break: break-all;
}
.variant-diff-row .vdr-values {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.variant-diff-row .vdr-canonical {
  color: var(--text-muted);
  background: var(--panel-2);
  padding: 2px 6px;
  border-radius: 4px;
  text-decoration: line-through;
  text-decoration-color: var(--text-muted);
}
.variant-diff-row .vdr-arrow,
.variant-diff-row .variant-color-arrow {
  color: var(--text-muted);
  font-size: 11px;
}
.variant-diff-row .vdr-variant {
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 6px;
  border-radius: 4px;
}
.variant-color-swatch {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--border);
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}

@media (prefers-reduced-motion: reduce) {
  .variant-card { transition: none !important; }
}

/* ---- Revision-variant preview (Phase 6 prose escape hatch) ---- */
/* A revision-variant proposal is the architect saying "rewrite this prose" —
 * it can't be a patch because prose lives in Yjs sub-docs. The bubble looks
 * like a patch preview but uses the vishal accent + a quote-mark visual to
 * distinguish from a structural patch. */
.revision-variant-preview {
  border-color: #6ba0ff44;
  background: #0c0e15;
}
.revision-variant-preview .rv-pill {
  background: var(--vishal);
  color: #0a0a0b;
  padding: 1px 7px;
  border-radius: 3px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.revision-variant-preview .rv-intent-text {
  color: var(--text-muted);
  font-family: var(--code);
  font-size: 10.5px;
  margin-left: 6px;
}
.rv-target {
  font-size: 10px;
  color: var(--text-muted);
  margin: 4px 0 6px;
}
.rv-target-id {
  background: #07070a;
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--vishal);
  font-family: var(--code);
}
.rv-not-found {
  margin-left: 6px;
  color: var(--akhil);
  font-size: 9.5px;
  font-style: italic;
}
.rv-current {
  background: #07070a;
  border-radius: 4px;
  padding: 6px 8px;
  font-family: var(--code);
  font-size: 10.5px;
  color: #ff9b9b;
  line-height: 1.45;
  margin-bottom: 4px;
}
.rv-current-label {
  color: var(--text-muted);
  margin-right: 4px;
}
.rv-suggested {
  display: flex;
  align-items: stretch;
  gap: 8px;
  background: #07070a;
  border-radius: 4px;
  padding: 6px 8px 6px 4px;
  margin-bottom: 4px;
}
.rv-suggested-bar {
  flex: 0 0 3px;
  background: var(--vishal);
  border-radius: 2px;
}
.rv-suggested-text {
  font-family: var(--code);
  font-size: 10.5px;
  color: var(--text);
  line-height: 1.45;
  flex: 1 1 auto;
  word-break: break-word;
}
.rv-rationale {
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
  margin: 0 0 6px;
  line-height: 1.4;
}
.rv-accept-btn {
  background: var(--vishal);
  color: #0a0a0b;
  border: 0;
  border-radius: 4px;
  padding: 5px 10px;
  font: 600 10.5px var(--code);
  cursor: pointer;
  letter-spacing: 0.01em;
}
.rv-accept-btn:disabled { opacity: 0.5; cursor: default; }
.rv-accept-btn:hover:not(:disabled) { filter: brightness(1.1); }
.rv-dismiss-btn {
  background: transparent;
  color: var(--text-muted);
  border: 0;
  font: 10.5px var(--code);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--border-soft);
}
.rv-dismiss-btn:hover:not(:disabled) { color: var(--text); }
.rv-signin-btn { background: var(--accent); }
.rv-signin-btn:hover:not(:disabled) { background: var(--accent-2); }
.rv-accepted .rv-pill { background: var(--ok, #6bff9b); }
.rv-accepted-row {
  margin-top: 6px;
  font-size: 10px;
  color: var(--ok, #6bff9b);
  font-family: var(--code);
}
.rv-accepted-label::before {
  content: "✓ ";
}

/* P6: drift indicator — applied to [data-prose] blocks whose canonical text
 * shifted between revision-accept and replay. replayAcceptedRevisions skips
 * the swap and tags the element so the reader can see the rewrite was dropped.
 * Cleared on a successful re-accept or fresh replay. */
[data-revision-stale="1"] {
  position: relative;
  text-decoration: underline dashed var(--vishal);
  text-underline-offset: 3px;
  cursor: help;
}
[data-revision-stale="1"]::after {
  content: "rewrite skipped — canonical changed";
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  padding: 4px 8px;
  font-size: 11px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
  z-index: 100;
}
[data-revision-stale="1"]:hover::after {
  opacity: 1;
}
