/* ═══════════════════════════════════════════════════════════════════════════
   COMPONENTS
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Panels & cards ─────────────────────────────────────────────────────── */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
}
.panel-pad { padding: 16px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--line);
}
.panel-title { font-size: 12px; font-weight: 660; letter-spacing: 0.03em; text-transform: uppercase; color: var(--ink-2); }
.panel-body { padding: 16px; }
.panel.glow-green { box-shadow: inset 0 1px 0 rgba(0,229,160,0.14), 0 0 34px rgba(0,229,160,0.06); }
.panel.glow-violet { box-shadow: inset 0 1px 0 rgba(139,92,246,0.16), 0 0 34px rgba(139,92,246,0.07); }
.panel.glow-red { box-shadow: inset 0 1px 0 rgba(255,77,94,0.16), 0 0 34px rgba(255,77,94,0.08); }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.grid-auto-lg { grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); }
/* Stat tiles size to the space they actually have, not to the viewport. These
   rows sit inside a half-width column, so a viewport media query is the wrong
   instrument — measured at a 1200px viewport the column was ~230px and each of
   the four tiles was 53px wide, which is 23px of content. `auto-fit` wraps them
   when the column is narrow and collapses the empty tracks, so four items still
   means at most four columns. */
.grid-tiles { grid-template-columns: repeat(auto-fit, minmax(116px, 1fr)); gap: 10px; }
/* Four items have three tidy shapes — 4x1, 2x2, 1x4 — and `auto-fit` steps
   through 3, which leaves an orphan under a gap. Ask the panel how much room it
   has and pick a shape. Scoped with :has() so only panels holding a tile rack
   get containment, and left as an override on top of the auto-fit rule above so
   a browser without container queries still lands somewhere sane. */
.panel-body:has(> .grid-tiles) { container-type: inline-size; }
@container (max-width: 499px) { .grid-tiles { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@container (max-width: 239px) { .grid-tiles { grid-template-columns: minmax(0,1fr); } }
@media (max-width: 1080px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 700px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0,1fr); } }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px; border-radius: 8px;
  background: var(--panel-2); border: 1px solid var(--line-2);
  color: var(--ink); font-size: 13px; font-weight: 550;
  transition: all 0.15s cubic-bezier(.2,.8,.3,1);
  position: relative; overflow: hidden; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--panel-hi); border-color: rgba(255,255,255,0.24); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0) scale(0.985); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 11.5px; border-radius: 6px; }
.btn-lg { padding: 11px 22px; font-size: 14.5px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-primary { background: linear-gradient(135deg, var(--green), #00c48a); color: #04120c; border-color: transparent; font-weight: 650; }
.btn-primary:hover:not(:disabled) { box-shadow: 0 4px 24px rgba(0,229,160,0.35); background: linear-gradient(135deg, #12f5b0, #00d093); }
.btn-violet { background: linear-gradient(135deg, var(--violet), #7c3aed); color: #fff; border-color: transparent; font-weight: 620; }
.btn-violet:hover:not(:disabled) { box-shadow: 0 4px 24px rgba(139,92,246,0.4); background: linear-gradient(135deg, #9e74fa, #8b4ae8); }
.btn-danger { background: linear-gradient(135deg, var(--red), #e03e50); color: #fff; border-color: transparent; }
.btn-danger:hover:not(:disabled) { background: linear-gradient(135deg, #ff6876, #e84c5e); box-shadow: 0 4px 24px rgba(255,77,94,0.35); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--panel); }
.btn-icon { padding: 7px; width: 32px; height: 32px; }

/* Action buttons (the clicker layer).

   The button is wrapped in a slot because a disabled `<button>` fires no
   `contextmenu`, and the workstation's right-click on a *blocked* action is the
   one that says what it needs. The slot is the grid item and the button fills
   it, so the layout is exactly what it was. */
.action-slot { display: flex; min-width: 0; }
.action-slot > .action-btn, .action-slot > .btn { flex: 1 1 auto; }
.action-slot.block { display: block; }
.action-slot.inline { display: inline-flex; }
/* A disabled button takes no pointer events in some browsers, and with them
   goes the note that says why it is disabled. The slot takes the hover — and
   the right-click — instead, and carries the note. */
.action-slot > button:disabled { pointer-events: none; }
.action-slot[data-tip] { cursor: not-allowed; }
.tip .note {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--amber);
}

.action-btn {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
  padding: 13px 15px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line);
  transition: all 0.14s cubic-bezier(.2,.8,.3,1);
  position: relative; overflow: hidden; text-align: left; width: 100%;
}
.action-btn::after {
  content: ''; position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(400px 120px at var(--mx,50%) var(--my,50%), rgba(255,255,255,0.09), transparent 70%);
  transition: opacity 0.2s; pointer-events: none;
}
.action-btn:hover:not(:disabled) { border-color: var(--line-2); transform: translateY(-2px); box-shadow: var(--shadow-2); }
.action-btn:hover:not(:disabled)::after { opacity: 1; }
.action-btn:active:not(:disabled) { transform: translateY(0) scale(0.99); }
.action-btn:disabled { opacity: 0.36; cursor: not-allowed; }
.action-name { font-size: 13.5px; font-weight: 620; display: flex; align-items: center; gap: 8px; }
.action-desc { font-size: 11px; color: var(--ink-3); line-height: 1.4; }
.action-cost { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); display: flex; gap: 9px; margin-top: 2px; }
.action-key {
  position: absolute; top: 9px; right: 10px;
  font-family: var(--mono); font-size: 9px; color: var(--ink-4);
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px;
}

/* ── Bars & meters ──────────────────────────────────────────────────────── */
.bar { height: 6px; border-radius: 4px; background: rgba(255,255,255,0.07); overflow: hidden; position: relative; }
.bar-fill { height: 100%; border-radius: 4px; transition: width 0.28s cubic-bezier(.2,.8,.3,1); position: relative; }
.bar-fill.shimmer::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
  animation: shimmer 1.9s infinite;
}
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(200%); } }
.bar.tall { height: 9px; }
.bar.thin { height: 4px; }

.meter { display: flex; flex-direction: column; gap: 5px; }
.meter-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.meter-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); font-weight: 620; }
.meter-value { font-family: var(--mono); font-size: 12.5px; font-weight: 600; }

/* Resource chips */
.res-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 20px;
  background: var(--panel); border: 1px solid var(--line);
  font-size: 12px;
}
.res-chip .mono { font-weight: 600; }
.res-icon { font-size: 12px; opacity: 0.9; }

/* ── Sliders (custom, re-render safe) ───────────────────────────────────── */
.slider { position: relative; height: 26px; display: flex; align-items: center; cursor: pointer; touch-action: none; user-select: none; }
.slider-track { position: absolute; left: 0; right: 0; height: 5px; border-radius: 3px; background: rgba(255,255,255,0.09); }
.slider-fill { position: absolute; left: 0; height: 5px; border-radius: 3px; transition: width 0.1s linear; }
.slider-knob {
  position: absolute; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.55); transform: translateX(-50%);
  transition: left 0.1s linear, transform 0.12s;
  border: 2px solid rgba(0,0,0,0.35);
}
.slider:hover .slider-knob { transform: translateX(-50%) scale(1.18); }

.alloc-row { display: grid; grid-template-columns: 108px 1fr 52px; align-items: center; gap: 12px; padding: 3px 0; }
.alloc-name { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 550; }
.alloc-pct { font-family: var(--mono); font-size: 12px; text-align: right; color: var(--ink-2); }

/* ── Feed items ─────────────────────────────────────────────────────────── */
.feed-item {
  padding: 9px 11px; border-radius: 9px;
  background: rgba(255,255,255,0.018); border: 1px solid transparent;
  font-size: 12px; line-height: 1.46;
  animation: feedIn 0.4s cubic-bezier(.2,.8,.3,1);
  border-left: 2px solid transparent;
}
@keyframes feedIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.feed-item.good { border-left-color: var(--green); background: rgba(0,229,160,0.045); }
.feed-item.bad { border-left-color: var(--red); background: rgba(255,77,94,0.05); }
.feed-meta { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; font-size: 10px; color: var(--ink-4); }
.feed-author { font-weight: 620; color: var(--ink-3); }
.feed-type {
  font-size: 8.5px; text-transform: uppercase; letter-spacing: 0.09em;
  padding: 1px 5px; border-radius: 4px; background: var(--panel-2); color: var(--ink-3); font-weight: 700;
}
.feed-type.hn { background: rgba(255,102,0,0.18); color: #ff8c3a; }
.feed-type.news { background: rgba(96,165,250,0.16); color: var(--blue); }
.feed-type.log { background: rgba(139,92,246,0.16); color: var(--violet); }
.feed-type.ship { background: rgba(0,229,160,0.16); color: var(--green); }
.feed-type.launch { background: rgba(0,229,160,0.22); color: var(--green); }
.feed-type.incident { background: rgba(255,77,94,0.2); color: var(--red); }
.feed-type.research { background: rgba(77,208,225,0.16); color: var(--cyan); }
.feed-text { color: var(--ink-2); }
.feed-text b, .feed-text strong { color: var(--ink); font-weight: 620; }
.feed-text em { color: var(--ink-3); }
.feed-sub { font-size: 10px; color: var(--ink-4); margin-top: 3px; font-family: var(--mono); }

/* ── Event modal ────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(3,4,7,0.80); backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fadeIn 0.28s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(720px, 100%); max-width: 100%; max-height: min(88vh, 900px);
  background: linear-gradient(165deg, #10131c, #0a0c12);
  border: 1px solid var(--line-2); border-radius: 18px;
  box-shadow: var(--shadow-3), inset 0 1px 0 rgba(255,255,255,0.06);
  display: flex; flex-direction: column; overflow: hidden;
  animation: modalIn 0.4s cubic-bezier(.16,1,.3,1);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(22px) scale(0.97); } to { opacity: 1; transform: none; } }
.modal.wide { width: min(940px, 100%); max-width: 100%; }
.modal-top {
  padding: 20px 26px 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: flex-start; gap: 15px; position: relative; flex: 0 0 auto;
}
.modal-top::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--kind-color, var(--violet)), transparent);
}
.event-portrait {
  width: 62px; height: 62px; flex: 0 0 62px; border-radius: 13px; overflow: hidden;
  border: 1px solid var(--line-2); background: #0a0c12; display: grid; place-items: center;
  position: relative;
}
.event-portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }
.event-portrait::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, transparent 55%, rgba(0,0,0,0.35));
}
.char-portrait {
  width: 46px; height: 46px; flex: 0 0 46px; border-radius: 11px; overflow: hidden;
  border: 1px solid var(--line-2); background: #0a0c12;
}
.char-portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }
.event-avatar {
  width: 46px; height: 46px; border-radius: 12px; flex: 0 0 46px;
  display: grid; place-items: center; font-size: 21px;
  background: var(--panel-2); border: 1px solid var(--line-2);
}
.event-kind {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--kind-color, var(--violet)); font-weight: 750;
}
.event-title { font-size: 21px; font-weight: 670; letter-spacing: -0.02em; margin-top: 1px; }
.event-char { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.modal-body { padding: 22px 26px; overflow-y: auto; flex: 1; min-height: 0; }
.event-body { font-size: 14.5px; line-height: 1.72; color: var(--ink-2); white-space: pre-wrap; }
.event-body strong { color: var(--ink); font-weight: 640; }
.event-body em { color: var(--ink-3); font-style: italic; }
.event-body code {
  font-family: var(--mono); font-size: 12.5px;
  background: rgba(255,255,255,0.06); padding: 1.5px 5px; border-radius: 4px; color: var(--cyan);
}
.event-body blockquote, .event-body .quote {
  border-left: 2px solid var(--line-2); padding: 3px 0 3px 15px; margin: 12px 0;
  color: var(--ink-3); font-style: italic;
}
.event-body pre {
  font-family: var(--mono); font-size: 12px; background: rgba(0,0,0,0.4);
  padding: 12px 14px; border-radius: 8px; margin: 12px 0; overflow-x: auto;
  border: 1px solid var(--line); color: var(--cyan);
}
.modal-choices { padding: 6px 20px 20px; display: flex; flex-direction: column; gap: 8px; flex: 0 0 auto; }
.choice {
  display: flex; align-items: flex-start; gap: 12px; text-align: left;
  padding: 13px 16px; border-radius: 11px;
  background: var(--panel); border: 1px solid var(--line);
  transition: all 0.16s cubic-bezier(.2,.8,.3,1); position: relative; overflow: hidden;
}
.choice:hover { background: var(--panel-2); border-color: var(--line-2); transform: translateX(3px); }
.choice-num {
  width: 21px; height: 21px; border-radius: 6px; flex: 0 0 21px; margin-top: 1px;
  display: grid; place-items: center; font-family: var(--mono); font-size: 10.5px;
  background: rgba(255,255,255,0.07); color: var(--ink-3); font-weight: 700;
}
.choice-label { font-size: 13.5px; font-weight: 570; line-height: 1.4; }
/* The tone's mark. Same table as the manual's legend; the colour is the
   tone's own where hud.css names one, steel where it does not. */
.choice-tone {
  flex: 0 0 auto; align-self: flex-start; margin-top: 3px;
  font-family: var(--mono); font-size: 10.5px; line-height: 1;
  color: var(--tone, var(--ink-4)); opacity: 0.9;
}
.choice-tone.good { --tone: var(--green); } .choice-tone.risky { --tone: var(--amber); }
.choice-tone.cruel { --tone: var(--red); } .choice-tone.costly { --tone: var(--cyan); }
.tone-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.tone-key { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-3); }
.tone-key .choice-tone { margin-top: 0; }
.choice-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; line-height: 1.4; }
.choice.good { border-left: 2px solid var(--green); }
.choice.risky { border-left: 2px solid var(--amber); }
.choice.cruel { border-left: 2px solid var(--red); }
.choice.costly { border-left: 2px solid var(--cyan); }
.choice.good:hover { box-shadow: -8px 0 24px -12px var(--green); }
.choice.risky:hover { box-shadow: -8px 0 24px -12px var(--amber); }
.choice.cruel:hover { box-shadow: -8px 0 24px -12px var(--red); }

.outcome {
  padding: 18px 22px; margin: 0 0 4px;
  background: linear-gradient(180deg, rgba(0,229,160,0.055), transparent);
  border-top: 1px solid var(--line);
  animation: fadeIn 0.4s ease;
}
.outcome-text { font-size: 14px; line-height: 1.68; color: var(--ink-2); white-space: pre-wrap; }
.outcome-effects { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }
.eff {
  font-family: var(--mono); font-size: 11px; padding: 3px 9px; border-radius: 6px;
  background: var(--panel-2); border: 1px solid var(--line);
  animation: effIn 0.4s cubic-bezier(.2,1.4,.4,1) backwards;
}
@keyframes effIn { from { opacity: 0; transform: scale(0.7) translateY(6px);} to { opacity:1; transform: none; } }
.eff.pos { color: var(--green); border-color: rgba(0,229,160,0.28); background: rgba(0,229,160,0.08); }
.eff.neg { color: var(--red); border-color: rgba(255,77,94,0.28); background: rgba(255,77,94,0.08); }

/* ── Toasts ─────────────────────────────────────────────────────────────── */
/* ── Objectives ─────────────────────────────────────────────────────────── */
.obj {
  display: flex; align-items: flex-start; gap: 9px; text-align: left; width: 100%;
  padding: 9px 11px; border-radius: 9px; background: rgba(0,229,160,0.035);
  border: 1px solid rgba(0,229,160,0.14); transition: all 0.15s;
}
.obj.clickable:hover { background: rgba(0,229,160,0.075); border-color: rgba(0,229,160,0.3); transform: translateY(-1px); }
.obj-dot {
  width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; margin-top: 5px;
  background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse 2.6s infinite;
}
.obj-title { display: block; font-size: 12.5px; font-weight: 600; line-height: 1.35; }
.obj-hint { display: block; font-size: 10.5px; color: var(--ink-3); line-height: 1.4; margin-top: 2px; }

#toast-root {
  position: fixed; bottom: 18px; left: calc(var(--nav-w) + 20px); z-index: 300;
  display: flex; flex-direction: column-reverse; gap: 8px; pointer-events: none;
  max-width: 350px;
}
.toast {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 15px; border-radius: 11px;
  background: rgba(16,19,28,0.96); border: 1px solid var(--line-2);
  box-shadow: var(--shadow-2); backdrop-filter: blur(14px);
  animation: toastIn 0.42s cubic-bezier(.16,1,.3,1);
  pointer-events: auto;
}
.toast.out { animation: toastOut 0.3s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(-26px) scale(0.95); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(-26px) scale(0.95); } }
.toast-icon { font-size: 18px; width: 24px; text-align: center; }
.toast-title { font-size: 12.5px; font-weight: 620; }
.toast-sub { font-size: 11px; color: var(--ink-3); margin-top: 1px; }
.toast.achievement { border-color: rgba(245,166,35,0.42); background: linear-gradient(135deg, rgba(245,166,35,0.14), rgba(16,19,28,0.96)); }
.toast.good { border-color: rgba(0,229,160,0.38); }
.toast.bad { border-color: rgba(255,77,94,0.38); }
.toast-count { font-size: 10.5px; color: var(--ink-3); font-weight: 700; }

/* ── Floating numbers ───────────────────────────────────────────────────── */
#fx-root { position: fixed; inset: 0; pointer-events: none; z-index: 250; overflow: hidden; }
.float-num {
  position: absolute; font-family: var(--mono); font-size: 14px; font-weight: 700;
  animation: floatUp 1.1s cubic-bezier(.2,.7,.3,1) forwards; text-shadow: 0 2px 10px rgba(0,0,0,0.8);
}
@keyframes floatUp { 0% { opacity: 0; transform: translateY(0) scale(0.85);} 18% { opacity: 1; transform: translateY(-10px) scale(1.06);} 100% { opacity: 0; transform: translateY(-58px) scale(1);} }

/* ── Agent cards ────────────────────────────────────────────────────────── */
.agent-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 14px; transition: all 0.16s; position: relative; overflow: hidden;
}
.agent-card:hover { border-color: var(--line-2); transform: translateY(-2px); box-shadow: var(--shadow-2); }
.agent-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--agent-color, var(--violet)); opacity: 0.7;
}
.agent-top { display: flex; align-items: flex-start; gap: 11px; }
.agent-avatar {
  width: 38px; height: 38px; border-radius: 10px; flex: 0 0 38px;
  display: grid; place-items: center; font-size: 15px; font-weight: 700;
  background: var(--agent-bg, var(--panel-2)); border: 1px solid var(--line-2);
  color: var(--agent-color, var(--ink));
}
.agent-name { font-size: 13.5px; font-weight: 650; font-family: var(--mono); letter-spacing: -0.01em; }
.agent-role { font-size: 10.5px; color: var(--ink-3); }
.agent-lvl {
  font-family: var(--mono); font-size: 10px; padding: 1px 6px; border-radius: 5px;
  background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--line);
}
.trait-chip {
  font-size: 10px; padding: 2px 7px; border-radius: 5px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink-2);
  cursor: help; white-space: nowrap;
}
.trait-chip.bad { border-color: rgba(255,77,94,0.3); color: #ff9aa4; background: rgba(255,77,94,0.07); }
.trait-chip.good { border-color: rgba(0,229,160,0.28); color: #6ff3c8; background: rgba(0,229,160,0.06); }

.lane-tabs { display: flex; gap: 4px; background: rgba(0,0,0,0.28); padding: 3px; border-radius: 8px; }
.lane-tab {
  flex: 1; padding: 5px 4px; border-radius: 5px; font-size: 10.5px; font-weight: 600;
  color: var(--ink-3); transition: all 0.13s; display: flex; align-items: center; justify-content: center; gap: 4px;
}
.lane-tab:hover { color: var(--ink); background: var(--panel); }
.lane-tab.on { background: var(--panel-hi); color: var(--ink); }

/* ── Research tree ──────────────────────────────────────────────────────── */
.branch-tabs { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 16px; }
.branch-tab {
  display: flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: 9px;
  background: var(--panel); border: 1px solid var(--line); font-size: 12.5px; font-weight: 560;
  color: var(--ink-2); transition: all 0.15s;
}
.branch-tab:hover { background: var(--panel-2); color: var(--ink); }
.branch-tab.on { background: var(--panel-hi); color: var(--ink); border-color: var(--branch-color, var(--line-2)); box-shadow: 0 0 20px -6px var(--branch-color); }
.branch-count { font-family: var(--mono); font-size: 10px; color: var(--ink-4); }

.tier-row { display: flex; gap: 12px; align-items: stretch; margin-bottom: 12px; }
.tier-label {
  writing-mode: vertical-rl; font-size: 9px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-4); padding: 4px 0; font-weight: 700; flex: 0 0 auto; text-align: center;
}
.tier-nodes { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; flex: 1; }

.tech-node {
  padding: 12px 13px; border-radius: var(--radius); text-align: left;
  background: var(--panel); border: 1px solid var(--line);
  transition: all 0.16s cubic-bezier(.2,.8,.3,1); position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 5px;
}
.tech-node:hover:not(.locked) { transform: translateY(-2px); border-color: var(--line-2); box-shadow: var(--shadow-2); }
.tech-node.done { background: rgba(0,229,160,0.055); border-color: rgba(0,229,160,0.28); }
.tech-node.done::after {
  content: '✓'; position: absolute; top: 9px; right: 11px; color: var(--green); font-size: 13px; font-weight: 700;
}
.tech-node.active { border-color: var(--cyan); box-shadow: 0 0 26px -8px var(--cyan); background: rgba(77,208,225,0.06); }
.tech-node.locked { opacity: 0.36; cursor: not-allowed; }
.tech-node.affordable { border-color: rgba(255,255,255,0.2); }
.tech-node.queued { border-color: rgba(77,208,225,0.4); }
.node-queue {
  position: absolute; top: 7px; right: 7px; width: 20px; height: 20px; border-radius: 5px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink-3);
  font-size: 11px; font-family: var(--mono); display: grid; place-items: center;
  opacity: 0; transition: all 0.15s; z-index: 2;
}
.tech-node:hover .node-queue { opacity: 1; }
.tech-node.queued .node-queue { opacity: 1; background: rgba(77,208,225,0.16); color: var(--cyan); border-color: rgba(77,208,225,0.35); }
.node-queue:hover { background: var(--panel-hi); color: var(--ink); }
.tech-node[role="button"] { cursor: pointer; }
.tech-name { font-size: 13px; font-weight: 620; line-height: 1.32; }
.tech-desc { font-size: 11px; color: var(--ink-3); line-height: 1.44; }
.tech-flavor { font-size: 10.5px; color: var(--ink-4); font-style: italic; line-height: 1.42; }
.tech-cost { font-family: var(--mono); font-size: 11px; display: flex; gap: 9px; align-items: center; margin-top: 2px; }
.tech-reqs { font-size: 10px; color: var(--amber); }

/* ── Competitor rows ────────────────────────────────────────────────────── */
.rival-row {
  display: grid; grid-template-columns: 1fr auto auto auto auto; gap: 14px; align-items: center;
  padding: 11px 14px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line); transition: all 0.15s;
}
.rival-row:hover { background: var(--panel-2); }
.rival-name { font-size: 13px; font-weight: 600; }
.rival-sub { font-size: 10.5px; color: var(--ink-3); }
.threat-pips { display: flex; gap: 2px; }
.pip { width: 5px; height: 13px; border-radius: 2px; background: rgba(255,255,255,0.1); }
.pip.on { background: var(--red); box-shadow: 0 0 7px rgba(255,77,94,0.55); }

/* ── Stats & charts ─────────────────────────────────────────────────────── */
.spark { width: 100%; height: 42px; display: block; }
.stat-tile {
  padding: 13px 15px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line);
}
.stat-tile-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--ink-3); font-weight: 650; }
.stat-tile-value { font-family: var(--mono); font-size: 20px; font-weight: 620; letter-spacing: -0.025em; margin-top: 3px; }
.stat-tile-sub { font-size: 10.5px; color: var(--ink-4); margin-top: 2px; }

/* ── Achievements ───────────────────────────────────────────────────────── */
.ach {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line); transition: all 0.15s;
}
.ach.got { background: rgba(245,166,35,0.06); border-color: rgba(245,166,35,0.24); }
.ach.rare.got { background: rgba(139,92,246,0.08); border-color: rgba(139,92,246,0.32); }
.ach-icon {
  width: 32px; height: 32px; border-radius: 8px; flex: 0 0 32px; display: grid; place-items: center;
  font-size: 15px; background: var(--panel-2); border: 1px solid var(--line); opacity: 0.4;
}
.ach.got .ach-icon { opacity: 1; background: rgba(245,166,35,0.14); border-color: rgba(245,166,35,0.34); color: var(--amber); }
.ach.rare.got .ach-icon { background: rgba(139,92,246,0.16); border-color: rgba(139,92,246,0.4); color: var(--violet); }
.ach-name { font-size: 12.5px; font-weight: 600; }
.ach-desc { font-size: 10.5px; color: var(--ink-3); }
.ach:not(.got) .ach-name { color: var(--ink-3); }

/* ── Character cards ────────────────────────────────────────────────────── */
.char-card {
  display: flex; gap: 13px; padding: 15px; border-radius: var(--radius-lg);
  background: var(--panel); border: 1px solid var(--line);
}
.char-avatar {
  width: 46px; height: 46px; border-radius: 12px; flex: 0 0 46px; display: grid; place-items: center;
  font-size: 20px; border: 1px solid var(--line-2);
}
.char-name { font-size: 14px; font-weight: 640; }
.char-role { font-size: 11px; color: var(--ink-3); }
.char-bio { font-size: 11.5px; color: var(--ink-3); line-height: 1.52; margin-top: 7px; }
.char-arc { font-size: 11.5px; font-style: italic; margin-top: 7px; }
.affinity-bar { display: flex; gap: 2px; margin-top: 8px; align-items: center; }
.aff-pip { width: 15px; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.1); }

/* ── Journal ────────────────────────────────────────────────────────────── */
.journal-entry {
  padding: 13px 15px; border-radius: var(--radius); background: var(--panel);
  border: 1px solid var(--line); border-left: 2px solid var(--line-2);
}
.journal-day { font-family: var(--mono); font-size: 10px; color: var(--ink-4); }
.journal-title { font-size: 13px; font-weight: 620; margin-top: 2px; }
.journal-choice { font-size: 11.5px; color: var(--cyan); margin-top: 5px; }
.journal-outcome { font-size: 12px; color: var(--ink-3); margin-top: 6px; line-height: 1.55; }

/* ── Onboarding / setup ─────────────────────────────────────────────────── */
.setup { max-width: 880px; margin: 0 auto; padding: 40px 24px 80px; }
.setup-title { font-size: 34px; font-weight: 720; letter-spacing: -0.035em; line-height: 1.08; }
.setup-sub { font-size: 15px; color: var(--ink-3); margin-top: 10px; line-height: 1.65; max-width: 640px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-3); font-weight: 660; }
.input {
  padding: 11px 14px; border-radius: 9px; background: rgba(0,0,0,0.32);
  border: 1px solid var(--line-2); color: var(--ink); font-size: 14px; width: 100%;
  transition: all 0.15s; outline: none;
}
.input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(0,229,160,0.13); }
.input::placeholder { color: var(--ink-4); }

.pick-card {
  padding: 15px; border-radius: var(--radius-lg); background: var(--panel);
  border: 1px solid var(--line); text-align: left; transition: all 0.17s cubic-bezier(.2,.8,.3,1);
  position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 6px;
}
.pick-card:hover:not(.locked) { transform: translateY(-3px); border-color: var(--line-2); box-shadow: var(--shadow-2); }
.pick-card.on { border-color: var(--pick-color, var(--green)); background: var(--panel-2);
  box-shadow: 0 0 30px -10px var(--pick-color, var(--green)), inset 0 1px 0 rgba(255,255,255,0.07); }
.pick-card.locked { opacity: 0.32; cursor: not-allowed; }
.pick-icon { font-size: 22px; }
.pick-name { font-size: 15px; font-weight: 660; }
.pick-tag { font-size: 11.5px; color: var(--ink-3); font-style: italic; }
.pick-desc { font-size: 11.5px; color: var(--ink-3); line-height: 1.5; }
.pick-stats { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.pick-stat { font-family: var(--mono); font-size: 10px; padding: 2px 7px; border-radius: 5px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink-2); }

/* ── Act transition ─────────────────────────────────────────────────────── */
.act-overlay {
  position: fixed; inset: 0; z-index: 400; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 45%, rgba(139,92,246,0.16), rgba(3,4,7,0.97) 62%);
  backdrop-filter: blur(22px); animation: fadeIn 0.7s ease;
}
.act-inner { text-align: center; max-width: 640px; padding: 30px; }
.act-roman { font-family: var(--mono); font-size: 76px; font-weight: 200; letter-spacing: 0.16em;
  background: linear-gradient(180deg, #fff, rgba(255,255,255,0.35)); -webkit-background-clip: text;
  background-clip: text; color: transparent; animation: actIn 1.1s cubic-bezier(.16,1,.3,1); }
.act-big { font-size: 38px; font-weight: 700; letter-spacing: -0.035em; margin-top: 4px;
  animation: actIn 1.1s 0.13s cubic-bezier(.16,1,.3,1) backwards; }
.act-tag { font-size: 15px; color: var(--ink-3); margin-top: 12px; line-height: 1.65;
  animation: actIn 1.1s 0.26s cubic-bezier(.16,1,.3,1) backwards; }
@keyframes actIn { from { opacity: 0; transform: translateY(24px); filter: blur(9px);} to { opacity: 1; transform: none; filter: none;} }

/* ── Tooltip ────────────────────────────────────────────────────────────── */
.tip {
  position: fixed; z-index: 500; pointer-events: none;
  background: rgba(14,17,25,0.98); border: 1px solid var(--line-2);
  border-radius: 9px; padding: 9px 12px; font-size: 11.5px; line-height: 1.5;
  max-width: 290px; box-shadow: var(--shadow-2); color: var(--ink-2);
  animation: fadeIn 0.13s ease;
}
.tip-title { font-weight: 650; color: var(--ink); font-size: 12px; margin-bottom: 3px; }
.tip b { color: var(--ink); }

/* ── Misc ───────────────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.empty {
  padding: 34px 20px; text-align: center; color: var(--ink-4); font-size: 12.5px; line-height: 1.6;
}
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 14px;
  font-size: 10.5px; font-weight: 620; background: var(--panel-2); border: 1px solid var(--line);
}
.pill.green { background: var(--green-dim); color: var(--green); border-color: rgba(0,229,160,0.28); }
.pill.red { background: var(--red-dim); color: var(--red); border-color: rgba(255,77,94,0.28); }
.pill.amber { background: var(--amber-dim); color: var(--amber); border-color: rgba(245,166,35,0.28); }
.pill.violet { background: var(--violet-dim); color: var(--violet); border-color: rgba(139,92,246,0.3); }
.pill.cyan { background: var(--cyan-dim); color: var(--cyan); border-color: rgba(77,208,225,0.28); }

.tick-up { animation: tickUp 0.5s cubic-bezier(.2,1.6,.4,1); }
@keyframes tickUp { 0% { transform: scale(1); } 30% { transform: scale(1.13); color: var(--green); } 100% { transform: scale(1); } }

.shake { animation: shake 0.45s cubic-bezier(.36,.07,.19,.97); }
@keyframes shake { 10%,90%{transform:translateX(-1px)} 20%,80%{transform:translateX(2px)} 30%,50%,70%{transform:translateX(-4px)} 40%,60%{transform:translateX(4px)} }

/* ── Ending overlay ─────────────────────────────────────────────────────── */
.ending-overlay {
  position: fixed; inset: 0; z-index: 500; overflow: hidden;
  background: radial-gradient(ellipse 120% 80% at 50% -10%, color-mix(in srgb, var(--end-color) 16%, transparent), rgba(3,4,7,0.99) 60%);
  backdrop-filter: blur(24px);
  animation: fadeIn 1.1s ease;
}
.ending-scroll { height: 100%; overflow-y: auto; overflow-x: hidden; }
.ending-inner { max-width: 860px; width: 100%; margin: 0 auto; padding: 72px 28px 120px; }
.ending-kicker {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-4); margin-bottom: 14px;
  animation: actIn 0.9s cubic-bezier(.16,1,.3,1) backwards;
}
.ending-title {
  font-size: clamp(34px, 6vw, 56px); font-weight: 730; letter-spacing: -0.04em; line-height: 1.02;
  background: linear-gradient(150deg, #fff 18%, var(--end-color) 96%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: actIn 1s 0.1s cubic-bezier(.16,1,.3,1) backwards;
}
.ending-body {
  font-size: 16px; line-height: 1.82; color: var(--ink-2); white-space: pre-wrap; margin-top: 26px;
  animation: actIn 1s 0.26s cubic-bezier(.16,1,.3,1) backwards;
}
.ending-body strong { color: var(--ink); }
.ending-rule { height: 1px; background: linear-gradient(90deg, var(--line-2), transparent); margin: 38px 0 22px; }
.ending-section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; font-weight: 700;
  color: var(--ink-3); margin-bottom: 14px;
}
.ending-story p { font-size: 14.5px; line-height: 1.75; color: var(--ink-2); margin-bottom: 13px; }
.ending-story em { color: var(--ink-3); }
.ending-legacy {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 20px 22px; border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(139,92,246,0.10), transparent);
  border: 1px solid rgba(139,92,246,0.28);
}
.ending-points { font-family: var(--mono); font-size: 40px; font-weight: 700; color: var(--violet); letter-spacing: -0.03em; }

/* ── Act hero banner ────────────────────────────────────────────────────── */
.act-hero {
  position: relative; height: 132px; border-radius: var(--radius-lg); overflow: hidden;
  margin-bottom: 16px; border: 1px solid var(--line);
  background-size: cover; background-position: center right;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  padding: 16px 18px;
}
.act-hero-1 { background-image: url('../assets/img/act1.jpg'); }
.act-hero-2 { background-image: url('../assets/img/act2.jpg'); }
.act-hero-3 { background-image: url('../assets/img/act3.jpg'); }
.act-hero-4 { background-image: url('../assets/img/act4.jpg'); }
.act-hero-5 { background-image: url('../assets/img/act5.jpg'); }
.act-hero-fade {
  position: absolute; inset: 0;
  background: linear-gradient(100deg, #06070a 4%, rgba(6,7,10,0.90) 34%, rgba(6,7,10,0.30) 68%, rgba(6,7,10,0.55));
}
.act-hero-text { position: relative; z-index: 1; min-width: 0; }
.act-hero-kicker {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--green); font-weight: 700;
}
.act-hero-title { font-size: 24px; font-weight: 680; letter-spacing: -0.028em; margin-top: 3px; }
.act-hero-sub { font-size: 12px; color: var(--ink-3); margin-top: 3px; font-style: italic; }
.act-hero-badges { position: relative; z-index: 1; display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 700px) {
  .act-hero { height: 108px; padding: 12px 14px; }
  .act-hero-title { font-size: 19px; }
  .act-hero-badges { display: none; }
}

/* ── Title screen ───────────────────────────────────────────────────────── */
.title-screen {
  height: 100%; display: grid; place-items: center; overflow-y: auto;
  position: relative;
}
.title-screen::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background-image: url('../assets/img/title_bg.jpg');
  background-size: cover; background-position: center;
  opacity: 0.30;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 45%, black 20%, transparent 80%);
}

/* ── Flow streak ────────────────────────────────────────────────────────── */
.streak-chip {
  font-family: var(--mono); font-size: 10.5px; font-weight: 700; color: var(--amber);
  opacity: 0; transition: opacity 0.4s;
}
.streak-chip.pop { opacity: 1; animation: streakPop 0.55s cubic-bezier(.2,1.6,.4,1); }
@keyframes streakPop { 0% { transform: scale(0.7); opacity: 0; } 40% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }

/* ── Keys ───────────────────────────────────────────────────────────────── */
.kbd {
  font-family: var(--mono); font-size: 10.5px; font-weight: 700; min-width: 30px;
  padding: 3px 7px; border-radius: 5px; text-align: center; flex: 0 0 auto;
  background: var(--panel-2); border: 1px solid var(--line-2);
  box-shadow: 0 1.5px 0 rgba(0,0,0,0.5); color: var(--ink-2);
}

/* ── Reduced motion ─────────────────────────────────────────────────────── */
html.reduced-motion *,
html.reduced-motion *::before,
html.reduced-motion *::after {
  animation-duration: 0.001s !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.06s !important;
}
html.reduced-motion #bg-canvas { display: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.06s !important;
  }
  #bg-canvas { display: none; }
}

/* ── Focus visibility (keyboard navigation) ─────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
  border-radius: 6px;
}
.agent-note {
  margin-top: 11px; padding: 8px 10px; border-radius: 8px;
  background: rgba(255,255,255,0.022); border-left: 2px solid var(--line-2);
  font-size: 11px; line-height: 1.45; color: var(--ink-3); font-style: italic; cursor: help;
}
.lane-tab .lane-name { display: none; }
.lane-tab.match { color: var(--green); }
.lane-tab.on.match { background: rgba(0,229,160,0.14); }
@media (min-width: 1500px) {
  .lane-tab .lane-name { display: inline; font-size: 10px; }
}

/* ── Regions ────────────────────────────────────────────────────────────── */
.region-card {
  padding: 14px; border-radius: var(--radius-lg);
  background: var(--panel); border: 1px solid var(--line);
  transition: all 0.16s; position: relative; overflow: hidden;
}
.region-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--rc); opacity: 0.55;
}
.region-card:hover { border-color: var(--line-2); transform: translateY(-2px); box-shadow: var(--shadow-2); }
.region-stages { display: flex; align-items: center; gap: 4px; margin-top: 8px; }
.region-pip {
  width: 16px; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.10);
}
.region-pip.on { background: var(--rc); box-shadow: 0 0 7px -1px var(--rc); }

/* ── Timeline ───────────────────────────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; }
.tl-entry { display: grid; grid-template-columns: 20px 1fr; gap: 12px; }
.tl-rail { position: relative; display: flex; justify-content: center; }
.tl-rail::before {
  content: ''; position: absolute; top: 0; bottom: -1px; width: 1px;
  background: var(--line); left: 50%;
}
.tl-entry:first-child .tl-rail::before { top: 9px; }
.tl-entry:last-child .tl-rail::before { bottom: auto; height: 9px; }
.tl-dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 6px; position: relative; z-index: 1; }
.tl-body { padding-bottom: 20px; min-width: 0; }
.tl-day { font-size: 9.5px; color: var(--ink-4); letter-spacing: 0.08em; }
.tl-kind { font-size: 9px; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; }
.tl-title { font-size: 13.5px; font-weight: 640; margin-top: 2px; }
.tl-choice { font-size: 11.5px; color: var(--cyan); margin-top: 4px; }
.tl-outcome { font-size: 12px; color: var(--ink-3); margin-top: 6px; line-height: 1.55; }
.tl-eff {
  font-family: var(--mono); font-size: 9.5px; padding: 1px 6px; border-radius: 4px;
  background: var(--panel-2); border: 1px solid var(--line);
}
.tl-eff.pos { color: var(--green); } .tl-eff.neg { color: var(--red); }

/* ── Directives ─────────────────────────────────────────────────────────── */
.directive {
  display: flex; align-items: center; gap: 8px; text-align: left; width: 100%;
  padding: 9px 11px; border-radius: 9px;
  background: var(--panel); border: 1px solid var(--line);
  transition: all 0.15s; position: relative; overflow: hidden;
}
.directive:hover { background: var(--panel-2); border-color: var(--line-2); transform: translateY(-1px); }
.directive.on {
  border-color: var(--dc); background: color-mix(in srgb, var(--dc) 10%, transparent);
  box-shadow: inset 0 0 22px -12px var(--dc);
}
.dir-icon { font-size: 14px; width: 17px; text-align: center; flex: 0 0 17px; }
.dir-name { font-size: 12px; font-weight: 560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ach.this-run { box-shadow: inset 0 0 0 1px rgba(245,166,35,0.20); }
.ach.this-run .ach-icon::after {
  content: ''; position: absolute; margin: -14px 0 0 22px; width: 5px; height: 5px;
  border-radius: 50%; background: var(--green); box-shadow: 0 0 6px var(--green);
}
.ach-icon { position: relative; }

/* ── Doctrines ──────────────────────────────────────────────────────────── */
.doctrine {
  padding: 12px; border-radius: var(--radius); background: var(--panel);
  border: 1px solid var(--line); transition: all 0.16s; position: relative; overflow: hidden;
}
.doctrine.earned {
  border-color: color-mix(in srgb, var(--dcc) 40%, transparent);
  background: linear-gradient(135deg, color-mix(in srgb, var(--dcc) 8%, transparent), transparent);
}
.doctrine.earned::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: var(--dcc);
}
.g7 { gap: 7px; }
.mb3 { margin-bottom: 3px; }
.share-block {
  margin-top: 14px; padding: 14px 16px; border-radius: var(--radius);
  background: rgba(0,0,0,0.45); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 11.5px; line-height: 1.6; color: var(--ink-3);
  white-space: pre; overflow-x: auto; user-select: all;
}

/* ── Prompt approaches ──────────────────────────────────────────────────── */
.approach-strip { margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--line); }

/* ── Spend the bar ──────────────────────────────────────────────────────────
   Four hands and one key. Three columns at every width the strip is drawn at:
   the rack of hands wraps inside itself and the key stays on the right, so the
   sentence above it never has to move. */
.spend-strip { margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--line); }
.spend-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spend-hands { display: flex; gap: 4px; flex: 1 1 220px; min-width: 0; }
.spend-hand {
  flex: 1 1 0; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 6px 6px; border-radius: 6px; border: 1px solid var(--line);
  background: rgba(255,255,255,0.02); color: var(--ink-3); font-size: 11px; transition: all 0.13s;
}
.spend-hand .sh-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spend-hand:hover { color: var(--ink); border-color: var(--line-2); }
.spend-hand.on { color: var(--ink); border-color: rgba(0,229,160,0.45); background: rgba(0,229,160,0.08); }
.spend-go { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; }
.spend-go .action-key { position: static; }
@media (max-width: 620px) { .spend-hand .sh-name { display: none; } }
.approach-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 7px; }
.approach {
  display: flex; flex-direction: column; gap: 6px; align-items: stretch; text-align: left;
  padding: 8px 9px; border-radius: 8px; background: var(--panel);
  border: 1px solid var(--line); transition: all 0.15s;
}
.approach:hover:not(.locked) { background: var(--panel-2); border-color: var(--line-2); transform: translateY(-1px); }
.approach.on { border-color: var(--ac); background: color-mix(in srgb, var(--ac) 9%, transparent);
  box-shadow: inset 0 0 20px -12px var(--ac); }
.approach.locked { opacity: 0.32; cursor: not-allowed; }
.approach-head { display: flex; align-items: center; gap: 6px; font-size: 11px; }
.approach-name { font-weight: 570; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.approach-dist { display: flex; height: 4px; border-radius: 2px; overflow: hidden; gap: 1px; }
.ab { display: block; border-radius: 1px; }
.ab-brilliant { background: var(--green); }
.ab-good { background: var(--cyan); }
.ab-messy { background: var(--amber); }
.ab-hallucinated { background: var(--red); }
.approach-cost { font-size: 9.5px; color: var(--ink-4); }

/* ── Live threads in the feed ───────────────────────────────────────────── */
.feed-item.actionable {
  border-left-color: var(--amber);
  background: rgba(245,166,35,0.055);
  box-shadow: inset 0 0 20px -14px var(--amber);
}
.feed-item.answered { opacity: 0.86; }
.feed-live {
  font-size: 8.5px; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700;
  color: var(--amber); background: rgba(245,166,35,0.16); padding: 1px 5px; border-radius: 4px;
  animation: pulse 2.4s infinite;
}
.thread-opts { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.thread-opt {
  text-align: left; padding: 5px 9px; border-radius: 6px; font-size: 11px;
  background: rgba(255,255,255,0.045); border: 1px solid var(--line);
  color: var(--ink-2); transition: all 0.13s;
}
.thread-opt:hover { background: rgba(245,166,35,0.14); border-color: rgba(245,166,35,0.4); color: var(--ink); transform: translateX(2px); }
.thread-out {
  margin-top: 7px; padding-top: 7px; border-top: 1px dashed var(--line);
  font-size: 11px; color: var(--ink-3); line-height: 1.5;
}
.thread-chosen { display: block; color: var(--cyan); font-size: 10.5px; margin-bottom: 3px; }

/* ── §I12. Alarms ───────────────────────────────────────────────────────────
   Something went wrong, on the panel that owns it. A border colour and nothing
   else in the base layer — `hud.css` adds the cut-following glow, because a
   `box-shadow` on a chamfered plate draws a rectangle behind the cut.

   Under reduced motion the frame simply holds red for the same window. What
   must never happen is that the founder is told nothing. */
/* Doubled, not `!important`: `.feed-item.actionable` and friends are two-class
   rules and would otherwise out-specify this, and reaching for `!important` in
   these stylesheets is what the frame rules were written to avoid. */
.alarm.alarm { border-color: rgba(255,77,94,0.85); animation: alarmPulse 1.1s ease-in-out infinite; }
.alarm.grid { border: 1px solid var(--red); padding: 6px; }
@keyframes alarmPulse {
  0%, 100% { border-color: rgba(255,77,94,0.85); }
  50%      { border-color: rgba(255,77,94,0.30); }
}
html.reduced-motion .alarm.alarm { animation: none; border-color: var(--red); }
@media (prefers-reduced-motion: reduce) { .alarm { animation: none; } }
.stat.alarm .stat-value { color: var(--red); }

/* ── The list ───────────────────────────────────────────────────────────────
   §I4. Generated every morning and thrown away every night. A tick is a real
   checkbox, the row is a door, and a ticked row goes quiet rather than away —
   crossing it out and leaving it there is what a paper list does. */
.td { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.td-head { display: flex; align-items: baseline; gap: 10px; padding: 12px 14px 8px; }
.td-k { font-size: 13px; font-weight: 620; }
.td-count { font-size: 9px; letter-spacing: 0.12em; color: var(--ink-5); }
.td-prog { margin-left: auto; font-size: 9.5px; color: var(--ink-4); letter-spacing: 0.1em; }
.td-rule { height: 1px; background: var(--line); }
.td-rows { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; padding: 8px 10px; min-height: 0; }
.today-sticky .td-rows { padding: 0; overflow: visible; }
.td-row {
  display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: start;
  gap: 8px; padding: 6px 6px; border: 1px solid transparent;
}
.td-row:hover { border-color: var(--line); background: rgba(255,255,255,0.02); }
.td-tick {
  width: 16px; height: 16px; margin-top: 1px; display: grid; place-items: center;
  border: 1px solid var(--line-2); background: transparent; color: var(--green);
  font-size: 10px; line-height: 1; padding: 0;
}
.td-tick:hover { border-color: var(--green); }
.td-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.td-title { font-size: 11.5px; color: var(--ink-2); line-height: 1.35; }
.td-sub { font-size: 10.5px; color: var(--ink-4); line-height: 1.45; }
.td-row.done .td-title { color: var(--ink-5); text-decoration: line-through; }
.td-row.done .td-sub { color: var(--ink-5); }
.td-side { display: flex; align-items: center; gap: 6px; }
.td-note { font-size: 8.5px; letter-spacing: 0.1em; color: var(--ink-5); white-space: nowrap; }
.td-row.advice .td-note { color: var(--amber); }
.td-go {
  width: 20px; height: 20px; display: grid; place-items: center; padding: 0;
  border: 1px solid transparent; background: transparent; color: var(--ink-4); font-size: 11px;
}
.td-go:hover { color: var(--ink); border-color: var(--line-2); }
.td-empty {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 32px 20px; text-align: center;
}
.td-empty-mark { font-size: 22px; color: var(--ink-5); }
.td-empty-k { font-family: var(--mono); font-size: 9px; letter-spacing: 0.2em; color: var(--ink-4); }
.td-empty-line { font-size: 11px; color: var(--ink-4); max-width: 34ch; line-height: 1.5; }
.td-foot { padding: 8px 14px 12px; margin-top: auto; }

/* ── The activity strip ─────────────────────────────────────────────────────
   §I3. One row per agent. The bar is a *shift*, not a progress meter: a segment
   travelling a track, offset per row so the rack does not march in step, and it
   holds still under reduced motion — the row still says what it is doing. */
.act-strip { display: flex; flex-direction: column; gap: 5px; }
.act-row {
  display: grid; align-items: center; gap: 8px; min-width: 0; width: 100%;
  grid-template-columns: minmax(58px, 88px) minmax(0, 84px) 54px minmax(0, 1fr);
  padding: 4px 6px; border: 1px solid transparent; background: transparent;
  text-align: left; color: inherit;
}
.act-row:hover { border-color: var(--line); background: rgba(255,255,255,0.02); }
.act-who {
  font-size: 11px; font-weight: 600; color: var(--ink-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.act-lane {
  font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--lc, var(--cyan));
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.act-track {
  position: relative; height: 3px; background: rgba(255,255,255,0.07); overflow: hidden;
}
.act-track > i {
  position: absolute; top: 0; bottom: 0; width: 34%; background: var(--lc, var(--cyan));
  opacity: 0.85; animation: actShift 3.4s linear infinite;
  animation-delay: calc(var(--ph, 0) * -3.4s);
}
.act-task {
  font-size: 10.5px; color: var(--ink-4); line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.act-row.noted .act-task { color: var(--ink-3); }
.act-more { padding: 2px 6px; }
@keyframes actShift { from { transform: translateX(-110%); } to { transform: translateX(330%); } }
html.reduced-motion .act-track > i {
  animation: none; transform: none; left: 0; width: calc(28% + var(--ph, 0) * 60%);
}
@media (prefers-reduced-motion: reduce) {
  .act-track > i { animation: none; transform: none; left: 0; width: calc(28% + var(--ph, 0) * 60%); }
}
@media (max-width: 700px) {
  .act-row { grid-template-columns: minmax(52px, 1fr) 46px minmax(0, 2fr); }
  .act-row .act-lane { display: none; }
}

/* ── Save slots ─────────────────────────────────────────────────────────────
   Three rows in Settings, the same three the workstation's login screen draws
   as tiles. The one in play is marked on all four sides, never on one edge. */
.set-slots { display: flex; flex-direction: column; gap: 6px; }
/* §C2. Five toggles that belong to the row above them. An indent says "these
   are under that" without a rule down one side — a one-sided line here would
   be a new entry on `oneside.mjs`'s list of neutral hairlines, and this is a
   sub-list inside a dialog rather than a region boundary. */
.set-indent { padding-left: 12px; }
.slot-row {
  padding: 5px 8px; border: 1px solid transparent; border-radius: 6px;
}
.slot-row.on { border-color: rgba(0,229,160,0.28); background: rgba(0,229,160,0.05); }

/* ── Triage ─────────────────────────────────────────────────────────────────
   What is left of a thread's life, the key that buys a week of it, and a
   letter drawn as an envelope rather than as a wall of prose. */
.feed-left {
  font-size: 8.5px; letter-spacing: 0.08em; color: var(--ink-4);
  padding: 1px 4px; border: 1px solid var(--line); border-radius: 3px; white-space: nowrap;
}
.feed-left.near { color: var(--amber); border-color: rgba(245,166,35,0.34); }
.feed-left.soon { color: var(--red); border-color: rgba(255,77,94,0.42); }
.feed-item.later { opacity: 0.74; }
.thread-later {
  align-self: flex-start; margin-top: 2px; padding: 3px 9px; border-radius: 6px;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase;
  background: transparent; border: 1px solid var(--line); color: var(--ink-4); transition: all 0.13s;
}
.thread-later:hover { color: var(--ink-2); border-color: var(--line-2); }
.thread-later.done { opacity: 0.5; cursor: default; }

.feed-item.envelope { padding: 0; }
.env-line {
  display: flex; align-items: center; gap: 7px; width: 100%; text-align: left;
  padding: 8px 11px; background: transparent; border: 0; color: inherit; min-width: 0;
}
.env-line:hover { background: rgba(255,255,255,0.03); }
.env-mark { color: var(--amber); font-size: 11px; flex: 0 0 auto; }
.env-who {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.04em; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 38%; flex: 0 1 auto;
}
.env-subject {
  font-size: 11px; color: var(--ink-3); flex: 1 1 auto; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.env-day { font-size: 9px; color: var(--ink-5); flex: 0 0 auto; }
.env-body {
  padding: 0 11px 9px; font-size: 11.5px; line-height: 1.55; color: var(--ink-2);
  white-space: pre-wrap;
}
.feed-item.envelope .thread-opts { padding: 0 11px 10px; margin-top: 0; }
.feed-item.envelope .thread-out { margin: 0 11px 10px; }

/* ── Ending commitments ─────────────────────────────────────────────────── */
.ending-card {
  padding: 16px; border-radius: var(--radius-lg); background: var(--panel);
  border: 1px solid var(--line); transition: all 0.16s;
}
.ending-card.ready {
  border-color: rgba(139,92,246,0.45);
  background: linear-gradient(150deg, rgba(139,92,246,0.08), transparent);
  box-shadow: 0 0 34px -14px var(--violet);
}
.commit {
  padding: 9px 10px; border-radius: 8px; background: rgba(255,255,255,0.02);
  border: 1px solid var(--line); border-left: 2px solid var(--line-2);
}
.commit.done { border-left-color: var(--green); background: rgba(0,229,160,0.05); }
.commit-mark { width: 14px; text-align: center; color: var(--ink-4); font-size: 12px; margin-top: 1px; }
.commit.done .commit-mark { color: var(--green); }
.commit-name { display: block; font-size: 12px; font-weight: 600; }
.commit-desc { display: block; font-size: 10.5px; color: var(--ink-3); line-height: 1.45; margin-top: 2px; }
.commit-cost { display: block; font-size: 10px; color: var(--amber); margin-top: 3px; font-family: var(--mono); }
.commit-hint { display: block; font-size: 10px; color: var(--ink-4); margin-top: 3px; font-style: italic; }
.branch-tab.hot { border-color: rgba(139,92,246,0.35); }
.branch-tab.hot.on { box-shadow: 0 0 22px -6px var(--violet); }
.ending-coda { margin-top: 30px; padding-top: 24px; border-top: 1px solid var(--line); }
.ending-coda p {
  font-size: 15px; line-height: 1.85; color: var(--ink-2); margin-bottom: 20px;
  animation: actIn 1s cubic-bezier(.16,1,.3,1) backwards;
}
.ending-coda p:nth-child(1) { animation-delay: 0.40s; }
.ending-coda p:nth-child(2) { animation-delay: 0.55s; }
.ending-coda p:nth-child(3) { animation-delay: 0.70s; }
.ending-coda p:nth-child(4) { animation-delay: 0.85s; }
.ending-coda strong { color: var(--ink); }
/* The world's own last word, when an assistant wrote one. It sits under the
   written epilogues and reads as a hand other than the game's, which is what
   it is — a rule above it, and nothing else. The ending is film, not
   interface, so it does not get a plate. */
.ending-coda p.ending-world-coda {
  margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line);
  color: var(--ink-2); animation-delay: 1s;
}

/* Event choices arrive after the text has landed. */
.choice.reveal { opacity: 0; transform: translateY(10px); transition: opacity .4s cubic-bezier(.16,1,.3,1), transform .4s cubic-bezier(.16,1,.3,1), background .16s, border-color .16s, box-shadow .16s; }
.choice.reveal.shown { opacity: 1; transform: none; }

/* Act transitions run over the act's own image. */
.act-overlay { overflow: hidden; }
.act-plate {
  position: absolute; inset: 0; background-size: cover; background-position: center;
  opacity: 0; animation: actPlate 7s cubic-bezier(.2,.7,.3,1) forwards;
}
@keyframes actPlate {
  0% { opacity: 0; transform: scale(1.14); }
  22% { opacity: 0.52; }
  85% { opacity: 0.52; }
  100% { opacity: 0.30; transform: scale(1); }
}
.act-veil {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 78% 68% at 50% 50%, rgba(4,5,10,0.78), rgba(4,5,10,0.96) 72%);
}
.act-inner { position: relative; z-index: 1; }
