/* app.css — design tokens and layout (narvi-kngu) */

/* ------------------------------------------------------------------ */
/* Design tokens                                                       */
/* ------------------------------------------------------------------ */

:root {
  /* Surface elevation palette (warm-neutral dark base) */
  --bg-base:           #15161c;
  --bg-gradient-peak:  #1a1b22;
  --bg-surface:        #1c1d24;
  --bg-surface-2:      #232530;
  --bg-elevated:       #2a2c38;

  /* Border tokens */
  --border-subtle:  #272830;
  --border-default: #32333e;

  /* Foreground tokens */
  --fg-primary:   #e0e1e8;
  --fg-secondary: #9fa0ad;
  --fg-muted:     #6b6c7a;

  /* Color: grayscale (legacy — alias to new tokens for backward compat) */
  --color-bg:        var(--bg-base);
  --color-surface:   var(--bg-surface);
  --color-border:    var(--border-default);
  --color-muted:     var(--fg-muted);
  --color-fg-dim:    var(--fg-secondary);
  --color-fg:        var(--fg-primary);
  --color-fg-strong: #f2f3fa;

  /* Color: accent (reserved for links, focus rings, active-phase bar, in-progress dot) */
  --accent:            #5b8def;
  --color-accent:      #5b8cff;
  --color-accent-dim:  #3a6ee0;
  --color-link:        var(--color-accent);

  /* Color: warning */
  --color-warning: #e0a050;

  /* Color: error/danger */
  --color-error:         #e05a5a;
  --color-error-dim:     #c04040;
  --color-error-surface: #fef2f2;
  --color-error-fg:      #990000;

  /* Color: status badges (desaturated) */
  --color-status-open:        #5a7a9e;
  --color-status-in-progress: #5e8a62;
  --color-status-notable:     #7a6e9a;
  --color-status-blocked:     #8a6a3e;
  --color-status-closed:      #4a4b56;
  --color-status-deferred:    #5a5b68;
  --color-status-deferred-bg: #4a4a4a;

  /* Status dot tokens (vivid; used by status dots, not badges) */
  --status-in-progress: #5b8def;
  --status-open:        #4ade80;
  --status-warn:        #f5a524;
  --status-blocked:     #ef4444;

  /* Narrative event glyph colors */
  --color-narrative-added:   #5cc8b5;
  --color-narrative-changed: #5b8cff;
  --color-narrative-fixed:   #a070e0;
  --color-narrative-blocked: #e05a5a;

  /* Contrast text (for colored/elevated surfaces) */
  --color-white:      #fff;
  --color-on-accent:  #111;

  /* Error severity: critical level for error backgrounds */
  --color-error-critical: #b91c1c;

  /* Color: data viz (sparklines, charts) */
  --color-chart-secondary: #fbbf24;

  /* Type scale: 4 sizes, body 15px */
  --text-xs:   12px;
  --text-sm:   13px;
  --text-base: 15px;
  --text-lg:   18px;
  --text-xl:   22px;

  /* Semantic type scale (spec: title 28/600/-0.01em, section 17/600,
     subsection 14/600, body 14/400 1.55, meta 12/400) */
  --text-title:       28px;  /* page titles, top-level h1 */
  --text-section:     17px;  /* section headers, h2 */
  --text-subsection:  14px;  /* subsection headers, h3 */
  --text-body:        14px;  /* body prose */
  --text-meta:        12px;  /* timestamps, IDs, slugs */

  /* Font families */
  --font-sans: "Geist", "Inter Tight", "General Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "Geist Mono", "JetBrains Mono", "SFMono-Regular", Consolas, monospace;

  /* Spacing: 4px multiples — canonical scale: 4 8 12 16 24 32 48 64 */
  --space-1:   4px;
  --space-2:   8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-6:  24px;
  --space-8:  32px;
  --space-12: 48px;
  --space-16: 64px;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 6px;

  /* Drawer */
  --drawer-w: 270px;

  /* History page service + outcome badges (narvi-2p0j) */
  --history-service-trampoline-bg: #1e3a5f;
  --history-service-trampoline-fg: #93c5fd;
  --history-service-broker-bg:     #3b1b6a;
  --history-service-broker-fg:     #c4b5fd;
  --history-outcome-ok-bg:         #14532d;
  --history-outcome-ok-fg:         #86efac;
  --history-outcome-failed-bg:     #7f1d1d;
  --history-outcome-failed-fg:     #fca5a5;
  --history-outcome-skipped-bg:    #78350f;
  --history-outcome-skipped-fg:    #fcd34d;
  --history-outcome-started-bg:    #1e3a5a;
  --history-outcome-started-fg:    #93c5fd;
  --history-outcome-rejected-bg:   #4c0519;
  --history-outcome-rejected-fg:   #fda4af;

}

/* ------------------------------------------------------------------ */
/* Reset / base                                                        */
/* ------------------------------------------------------------------ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
}

body {
  background: var(--color-bg);
  background-image: radial-gradient(ellipse 80% 60% at 50% 0%, var(--bg-gradient-peak), var(--bg-base));
  color: var(--color-fg);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: 1.55;
  min-height: 100dvh;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color 150ms ease-out;
}

a:hover {
  text-decoration: underline;
  color: var(--color-fg-strong);
}

a:focus-visible,
button:focus-visible,
select:focus-visible,
textarea:focus-visible,
input:focus-visible,
.phase-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ------------------------------------------------------------------ */
/* Layout: full-width CSS grid                                         */
/* ------------------------------------------------------------------ */

body {
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: 1fr;
  max-width: 100%;
}

#header {
  grid-row: 1;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  /* sticky: breadcrumbs and orchestrator status remain visible on scroll */
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-row--top {
  display: flex;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  gap: var(--space-3);
}

.header-row__left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.header-row__right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
  min-width: 0;
}

.header-row--project-nav {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-6);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-base);
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ------------------------------------------------------------------ */
/* Project content header                                              */
/* ------------------------------------------------------------------ */

.project-content-header {
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-subtle);
}

#header a,
#header button {
  color: var(--color-fg);
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--text-sm);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
}

#header a:hover,
#header button:hover {
  background: var(--color-border);
}

#header a:active,
#header button:active {
  background: var(--color-muted);
}

/* Global busy indicator — thin progress strip pinned to header bottom */
.header-busy-strip {
  height: 2px;
  position: relative;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.15s;
}

body[data-loading] .header-busy-strip {
  opacity: 1;
}

.header-busy-strip::before {
  content: '';
  position: absolute;
  left: 0;
  width: 60%;
  height: 100%;
  background: var(--accent);
  transform: translateX(-200%);
}

body[data-loading] .header-busy-strip::before {
  animation: header-busy-slide 1.4s ease-in-out infinite;
}

@keyframes header-busy-slide {
  0%   { transform: translateX(-200%); }
  100% { transform: translateX(350%); }
}

.orch-status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--fg-primary);
  background: var(--bg-surface-2);
  border-radius: 99px;
  padding: var(--space-1) var(--space-3);
  cursor: default;
  letter-spacing: 0.02em;
}
.orch-status__dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.orch-status--idle .orch-status__dot {
  background: var(--color-status-closed);
}
.orch-status--baseline .orch-status__dot,
.orch-status--running .orch-status__dot,
.orch-status--closing .orch-status__dot {
  background: var(--color-status-in-progress);
}
.orch-status--paused .orch-status__dot {
  background: var(--color-status-blocked);
}
.orch-status a {
  color: var(--color-accent);
  text-decoration: none;
}
.orch-status a:hover {
  text-decoration: underline;
}

/* narvi-cat9: status text and the action button render inside a single
   pill that mirrors .usage-stats-pill's surface treatment. */
.orch-widget {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--bg-surface-2);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-meta);
  overflow-wrap: anywhere;
  min-width: 0;
}
.orch-widget__pause-reason {
  color: var(--fg-secondary);
}
.orch-widget__pause-time {
  color: var(--fg-muted);
}
.orch-widget__pause-pending {
  color: var(--fg-muted);
}
/* The status text inside the pill no longer needs its own surface — the
   parent provides it. Keep the dot color but drop the rounded background. */
.orch-widget .orch-status {
  background: transparent;
  padding: 0;
}

.orch-pause-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: flex-end;
}

.usage-stats-pill {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-surface-2);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-meta);
}
.usage-stats-pill--reset-pending {
  background: color-mix(in srgb, var(--color-error) 12%, var(--bg-surface-2));
}
.usage-stats-pill__row {
  display: flex;
  align-items: baseline;
  white-space: nowrap;
  flex-wrap: wrap;
}
.usage-stats-pill__label {
  color: var(--fg-muted);
}
.usage-stats-pill__bar {
  color: var(--fg-muted);
  font-size: 0.85em;
  letter-spacing: -0.05em;
}
.usage-stats-pill__bar--shared {
  color: var(--color-accent);
}
.usage-stats-pill__bar--sonnet {
  color: var(--color-narrative-added);
}
.usage-stats-pill__bar--all {
  color: var(--color-narrative-fixed);
}
.usage-stats-pill__value {
  color: var(--fg-secondary);
  font-variant-numeric: tabular-nums;
}
.usage-stats-pill__value--warn {
  color: var(--status-warn);
}
.usage-stats-pill__reset {
  color: var(--fg-muted);
}
.usage-stats-pill__note {
  color: var(--fg-muted);
  font-size: 0.8em;
  padding-top: var(--space-1);
  white-space: normal;
  max-width: 16em;
}
.usage-stats-pill__separator {
  height: 1px;
  background: var(--border-muted);
  margin: var(--space-1) 0;
}

/* narvi-1q75t: credentials-outage degraded indicator in the header.
   Mirrors .usage-stats-pill's surface treatment but uses the error colour
   so the outage is immediately visible. */
.usage-degraded-pill {
  display: inline-flex;
  align-items: center;
  background: color-mix(in srgb, var(--color-error) 15%, var(--bg-surface-2));
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-meta);
  color: var(--color-error);
  white-space: nowrap;
}

/* Desktop-only header items: usage pill, notifications, settings.
   Hidden on mobile and replaced by the overflow menu. */
.header-desktop-items {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Overflow button: hidden on desktop, shown on mobile. */
.header-overflow-btn {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--fg-primary);
  font-size: var(--text-lg);
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

.header-overflow-btn:hover {
  background: var(--color-border);
}

.header-overflow-btn:active {
  background: var(--color-muted);
}

/* Overflow menu: full-width panel shown below the top row on mobile. */
.header-overflow-menu {
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-default);
  padding: var(--space-2) var(--space-4);
  gap: var(--space-2);
}

#app {
  grid-row: 2;
  padding: var(--space-4);
  width: 100%;
  max-width: 100%;
}

/* Internal columns inside #app */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}

/* ------------------------------------------------------------------ */
/* Drawer                                                              */
/* ------------------------------------------------------------------ */

#drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--drawer-w);
  z-index: 200;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
}

body[data-drawer-open="true"] #drawer {
  transform: none;
}

#drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 199;
  background: rgba(0, 0, 0, 0.4);
}

@media (min-width: 760px) {
  body[data-drawer-open="true"] {
    padding-left: var(--drawer-w);
  }
}

@media (max-width: 759px) {
  body[data-drawer-open="true"] #drawer-backdrop {
    display: block;
  }
}

.drawer-brand {
  display: flex;
  align-items: center;
  padding: var(--space-4) var(--space-4) var(--space-3);
  font-size: var(--text-section);
  font-weight: 600;
  color: var(--color-fg);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.drawer-brand:hover {
  color: var(--color-fg-strong);
  text-decoration: none;
}

.drawer-orch {
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--color-border);
}

.drawer-usage {
  padding: var(--space-2) var(--space-3);
}

.drawer-nav {
  display: flex;
  flex-direction: column;
  padding: var(--space-2);
  gap: var(--space-1);
  border-top: 1px solid var(--color-border);
  flex: 1;
}

.drawer-nav-link {
  display: flex;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  color: var(--color-fg);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  min-height: 36px;
  min-width: 0;
}

.drawer-nav-link:hover {
  background: var(--color-border);
  color: var(--color-fg-strong);
  text-decoration: none;
}

.drawer-toggle-strip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
}

.drawer-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-fg);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  min-height: 44px;
  min-width: 44px;
  font-size: var(--text-lg);
}

.drawer-toggle-btn:hover {
  background: var(--color-border);
}

.drawer-strip-orch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-meta);
  min-width: 0;
  overflow: hidden;
}

/* ------------------------------------------------------------------ */
/* Responsive breakpoints                                              */
/* ------------------------------------------------------------------ */

@media (max-width: 600px) {
  #header {
    padding: var(--space-2) var(--space-3);
    gap: var(--space-2);
  }

  #app {
    padding: var(--space-3);
  }

  .app-grid {
    grid-template-columns: 1fr;
  }

  /* Prevent tables from causing horizontal scroll */
  table {
    display: block;
    overflow-x: auto;
    max-width: 100%;
  }
}

@media (min-width: 900px) {
  #app {
    padding: var(--space-6) var(--space-8);
  }
}

/* ------------------------------------------------------------------ */
/* Typography                                                          */
/* ------------------------------------------------------------------ */

h1 { font-size: var(--text-title);       font-weight: 600; letter-spacing: -0.01em; color: var(--color-fg-strong); }
h2 { font-size: var(--text-section);     font-weight: 600; color: var(--color-fg-strong); }
h3 { font-size: var(--text-subsection);  font-weight: 600; color: var(--fg-secondary); }

p { margin-bottom: var(--space-3); }

code, pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--color-surface);
  border-radius: var(--radius-sm);
}

pre {
  padding: var(--space-3);
  overflow-x: auto;
  max-width: 100%;
}

code {
  padding: 1px 4px;
}

/* ------------------------------------------------------------------ */
/* Buttons                                                             */
/* ------------------------------------------------------------------ */

button,
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-fg);
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out;
  min-height: 44px;
  min-width: 44px;
}

button:hover,
.btn:hover {
  background: var(--color-border);
}

button:active,
.btn:active {
  background: var(--color-muted);
  border-color: var(--color-fg-dim);
}

button:disabled,
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.loading::after {
  content: "…";
}

/* Button tiers — opt in explicitly; secondary is the default */
.btn--secondary {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-fg);
}

.btn--secondary:hover {
  background: var(--color-border);
}

.btn--primary {
  background: var(--bg-elevated);
  border-color: var(--accent);
  color: var(--color-white);
}

.btn--primary:hover {
  background: var(--bg-surface-2);
}

.btn--danger {
  background: var(--color-error-dim);
  border-color: var(--color-error);
  color: var(--color-white);
}

.btn--danger:hover {
  background: var(--color-error);
}

.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--color-fg-dim);
}

.btn--ghost:hover {
  background: var(--color-border);
  color: var(--color-fg);
}

/* ------------------------------------------------------------------ */
/* Forms                                                               */
/* ------------------------------------------------------------------ */

select,
textarea,
input[type="text"],
input[type="password"] {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-fg);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  width: 100%;
  max-width: 100%;
}

textarea {
  resize: vertical;
  min-height: 80px;
}

/* ------------------------------------------------------------------ */
/* Q&A page                                                            */
/* ------------------------------------------------------------------ */

.qa-new-question {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.qa-new-question label {
  flex-basis: 100%;
}

.qa-input {
  flex: 1 1 200px;
  min-width: 0;
}

.qa-submit-btn {
  background: var(--color-accent);
  color: var(--color-white);
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  cursor: pointer;
  white-space: nowrap;
}

.qa-submit-btn:hover {
  background: var(--color-accent-dim);
}

/* ------------------------------------------------------------------ */
/* Responsive tables                                                   */
/* ------------------------------------------------------------------ */

.table-responsive {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

/* ------------------------------------------------------------------ */
/* Responsive SVG charts                                               */
/* ------------------------------------------------------------------ */

.svg-chart {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}

.svg-axis-gridline {
  stroke: var(--border-subtle);
  stroke-width: 0.5;
  opacity: 0.8;
}

.svg-axis-ytick {
  fill: var(--fg-muted);
  font-size: 9px;
  font-family: inherit;
  text-anchor: end;
}

.svg-axis-xtick {
  fill: var(--fg-muted);
  font-size: 8px;
  font-family: inherit;
  text-anchor: middle;
}

.svg-axis-ytick-right {
  fill: var(--color-chart-secondary);
  font-size: 9px;
  font-family: inherit;
  text-anchor: end;
}

.lucide-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  flex-shrink: 0;
}

/* ------------------------------------------------------------------ */
/* Stats usage legend (Row 6)                                          */
/* ------------------------------------------------------------------ */

.stats-usage-legend {
  display: flex;
  gap: var(--space-3, 0.75rem);
  margin-top: var(--space-2, 0.5rem);
  font-size: var(--text-sm, 0.8125rem);
  color: var(--fg-muted);
}

.stats-usage-legend__item {
  display: flex;
  align-items: center;
  gap: var(--space-1, 0.25rem);
}

.stats-usage-legend__item.stats-usage-legend__swatch--five-hour { color: var(--accent); }
.stats-usage-legend__item.stats-usage-legend__swatch--seven-day { color: var(--status-warn); }
.stats-usage-legend__item.stats-usage-legend__swatch--thirty-day { color: var(--color-narrative-added); }
.stats-usage-legend__item.stats-usage-legend__item--model { opacity: 0.6; }

/* ------------------------------------------------------------------ */
/* Status badges                                                       */
/* ------------------------------------------------------------------ */

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  padding: 1px var(--space-2);
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
  min-height: 44px;
  min-width: 44px;
}

.status-badge--open        { background: var(--color-status-open);        color: var(--color-white); }
.status-badge--in_progress { background: var(--color-status-in-progress); color: var(--color-on-accent); }
.status-badge--blocked     { background: var(--color-status-blocked);     color: var(--color-on-accent); }
/* AA contrast: #fff on #555555 ≈ 7.5:1; #fff on #4a4a4a ≈ 8.6:1 (was #ccc, failed at 2.5:1) */
.status-badge--closed      { background: var(--color-status-closed);      color: var(--color-white); }
.status-badge--deferred    { background: var(--color-status-deferred-bg); color: var(--color-white); }

/* ------------------------------------------------------------------ */
/* Bead list                                                           */
/* ------------------------------------------------------------------ */

ul.bead-list {
  list-style: none;
}

ul.bead-list li {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  flex-wrap: wrap;
}

ul.bead-list li:last-child {
  border-bottom: none;
}

.bead-id {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-fg-dim);
  flex-shrink: 0;
}


/* ------------------------------------------------------------------ */
/* Toast — ARIA live region                                            */
/* ------------------------------------------------------------------ */

.toast {
  position: fixed;
  bottom: var(--space-4);
  right: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-fg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  max-width: min(360px, calc(100vw - 2 * var(--space-4)));
}

.toast--error  { border-color: var(--color-error); color: var(--color-error); }
.toast--success { border-color: var(--color-status-in-progress); }

/* ------------------------------------------------------------------ */
/* Auth modal                                                          */
/* ------------------------------------------------------------------ */

.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.auth-modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  width: min(360px, calc(100vw - var(--space-8)));
}

/* Auth-gated elements: hidden when body has data-authed="false" */
body[data-authed="false"] .requires-auth {
  display: none;
}

/* ------------------------------------------------------------------ */
/* Bead detail view                                                    */
/* ------------------------------------------------------------------ */

.bead-detail {
  max-width: 800px;
}

.bead-detail h1 {
  margin-bottom: var(--space-4);
}

.bead-detail section {
  margin-bottom: var(--space-6);
}

/* Back link */
.bead-back-link {
  display: inline-block;
  font-size: var(--text-sm);
  color: var(--color-fg-dim);
  margin-bottom: var(--space-4);
}

.bead-back-link:hover {
  color: var(--color-fg);
}

.back-to-project {
  display: inline-block;
  font-size: var(--text-sm);
  color: var(--color-fg-dim);
  margin-bottom: var(--space-4);
}

.back-to-project:hover {
  color: var(--color-fg);
}

/* Header bar */
.bead-detail-header {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.bead-detail-header h1 {
  flex: 1 1 100%;
  margin-bottom: var(--space-3);
}

/* Runtime stats strip — pinned to header, right-aligned */
.bead-stats-strip {
  font-size: var(--text-sm);
  color: var(--color-fg-dim);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-left: auto;
  align-self: flex-start;
  max-width: 100%;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Area and milestone read-only chips */
.bead-area-badge,
.bead-milestone-badge {
  font-size: var(--text-meta);
  color: var(--fg-secondary);
  padding: var(--space-1) var(--space-2);
  background: var(--bg-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

/* Markdown prose */
.prose h1, .prose h2, .prose h3, .prose h4 {
  margin: var(--space-4) 0 var(--space-2);
  color: var(--color-fg-strong);
  font-weight: 600;
}

/* Demote in-body headings: authored h1–h6 inside description/comment bodies must
   not exceed the subsection size so page-chrome section headers (h2 "Comments")
   always read as more prominent. */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  font-size: var(--text-subsection);
  color: var(--fg-secondary);
}

.prose p {
  margin-bottom: var(--space-3);
}

.prose ul, .prose ol {
  padding-left: var(--space-6);
  margin-bottom: var(--space-3);
}

.prose li {
  margin-bottom: var(--space-1);
}

.prose code {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 1px var(--space-1);
  border-radius: var(--radius-sm);
}

.prose {
  word-break: break-word;
  overflow-wrap: anywhere;
}

.prose pre {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  overflow-x: auto;
  max-width: 100%;
  overflow-wrap: normal;
  margin-bottom: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.prose pre code {
  background: none;
  border: none;
  padding: 0;
}

.prose blockquote {
  border-left: 3px solid var(--color-border);
  padding-left: var(--space-3);
  color: var(--color-fg-dim);
  margin-bottom: var(--space-3);
}

.prose a {
  color: var(--color-accent);
}

.mutations-panel {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: center;
}

.mutations-panel label {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-fg-dim);
}

.mutations-panel select {
  width: auto;
}

/* Comments */
.bead-comments {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.bead-comment {
  background: var(--bg-surface);
  padding: var(--space-4);
  border-radius: var(--radius-md);
}

.bead-comment-meta {
  font-size: var(--text-xs);
  color: var(--color-fg-dim);
  margin-bottom: var(--space-2);
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}

.comment-tag-pill {
  font-family: var(--font-mono);
  font-size: var(--text-meta);
  background: var(--bg-surface-2);
  color: var(--fg-secondary);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

.bead-comment-tag {
  font-family: var(--font-mono);
  background: var(--color-border);
  color: var(--color-fg); /* AA: #d4d4d4 on #2e2e2e ≈ 8.3:1 (was inherited #888, 3.4:1) */
  padding: 1px var(--space-2);
  border-radius: var(--radius-sm);
}

.bead-comment-author {
  font-weight: 500;
  color: var(--color-fg);
}

.bead-comment-ts {
  color: var(--color-fg-dim);
}

.bead-type-badge {
  font-size: var(--text-sm);
  color: var(--color-fg);
  padding: var(--space-1) var(--space-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.bead-badge {
  display: inline-block;
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-2);
  border-radius: 99px;
  background: var(--color-border);
  color: var(--color-fg-dim);
}

.bead-badge--interactive {
  background: transparent;
  color: var(--color-accent);
  border: none;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}

.bead-badge--plan {
  background: var(--color-narrative-added);
  color: var(--color-fg-strong);
}

.bead-phase-bar {
  display: inline-block;
  width: 28px;
  height: var(--space-1);
  background: var(--bg-surface-2);
  border-radius: 99px;
  overflow: hidden;
  vertical-align: middle;
}

.bead-phase-bar__fill {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  width: 0;
}

.bead-phase-bar--queued   .bead-phase-bar__fill { width: 0%; }
.bead-phase-bar--baseline .bead-phase-bar__fill { width: 15%; }
.bead-phase-bar--running  .bead-phase-bar__fill { width: 50%; }
.bead-phase-bar--closing  .bead-phase-bar__fill { width: 85%; }

.bead-comment-body {
  font-size: var(--text-sm);
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Log section */
.bead-log {
  margin-top: var(--space-6);
}

.bead-log-toggle {
  font-size: var(--text-sm);
  padding: var(--space-1) var(--space-3);
  margin-bottom: var(--space-3);
}

.bead-log-content {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  overflow-x: auto;
  max-width: 100%;
}

.bead-log-content ul {
  list-style: none;
  padding: 0;
}

.bead-log-content li {
  padding: var(--space-1) 0;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-fg-dim);
}

/* Mobile: stack detail page */
@media (max-width: 600px) {
  .bead-detail-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .mutations-panel {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Legacy comment classes kept for backwards compat */
.comment {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
}

.comment:last-child {
  border-bottom: none;
}

.comment-meta {
  font-size: var(--text-xs);
  color: var(--color-fg-dim);
  margin-bottom: var(--space-2);
}

.comment-tag {
  font-family: var(--font-mono);
  background: var(--color-border);
  padding: 1px var(--space-2);
  border-radius: var(--radius-sm);
}

/* ------------------------------------------------------------------ */
/* Briefing / project summaries                                        */
/* ------------------------------------------------------------------ */

.briefing-active-task {
  margin-bottom: var(--space-4);
  padding: var(--space-3);
  background: var(--bg-surface-2);
  border-radius: var(--radius-md);
}

.briefing-active-task-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
}

.briefing-task-title {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.briefing-active-task-row--stranded {
  opacity: 0.6;
}

.briefing-active-task-elapsed {
  min-width: 0;
  font-variant-numeric: tabular-nums;
  color: var(--fg-secondary);
  font-size: var(--text-meta);
}

.briefing-active-task-project {
  min-width: 0;
  color: var(--fg-muted);
  font-size: var(--text-meta);
}

.briefing-summary {
  margin-bottom: var(--space-6);
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: var(--text-sm);
  color: var(--color-fg-dim);
  overflow-wrap: anywhere;
}

.briefing-summary-stat {
  margin: 0 0 var(--space-1) 0;
}

.briefing-summary-models {
  margin: 0;
  font-size: var(--text-xs);
}

.briefing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

section.briefing-project {
  margin-bottom: 0;
  border-left: 3px solid transparent;
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 1px 2px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.15);
  min-width: 0;
}

.briefing-project--active {
  border-left-color: var(--color-accent);
  background: var(--bg-elevated);
}

section.briefing-project h2 {
  margin: 0 0 var(--space-1) 0;
  color: var(--color-fg-strong);
}

.briefing-project-summary {
  margin: 0 0 var(--space-2) 0;
  color: var(--color-fg-dim);
  overflow-wrap: anywhere;
}

.up-next h3 {
  margin: var(--space-2) 0 var(--space-1) 0;
  color: var(--color-fg-dim);
  font-size: var(--text-sm);
}

.up-next p {
  margin: 0;
  color: var(--color-fg-dim);
  font-size: var(--text-sm);
}

.up-next ol {
  margin: 0;
  padding-left: 1.2em;
}

.up-next li {
  font-size: var(--text-sm);
  color: var(--color-fg);
}

.up-next a {
  color: var(--color-accent);
}

.briefing-project-status-row {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-wrap: wrap;
  margin: var(--space-2) 0;
  font-size: var(--text-sm);
  color: var(--fg-secondary);
}

.project-health-banner {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin: var(--space-1) 0 var(--space-2);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.project-health-banner--error {
  background: var(--color-error-surface);
  color: var(--color-error-fg);
  border: 1px solid var(--color-error-dim);
}

.project-health-banner--warn {
  background: color-mix(in srgb, var(--color-warning) 12%, transparent);
  color: var(--color-warning);
  border: 1px solid var(--color-warning);
}

.briefing-project-link {
  display: inline-flex;
  margin-top: var(--space-3);
  text-decoration: none;
  font-weight: 600;
}

.briefing-project-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-1) var(--space-4);
  margin: var(--space-3) 0;
  font-size: var(--text-xs);
  color: var(--color-fg-dim);
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ------------------------------------------------------------------ */
/* Briefing compact stats bar — <760px (narvi-dbk5)                    */
/* dots reuse --status-in-progress, --status-open, --status-blocked,   */
/* --status-warn via .status-dot--* rules at app.css:1831+             */
/* ------------------------------------------------------------------ */

.briefing-project-compact-stats {
  display: none;
}

@media (max-width: 759px) {
  .briefing-project-stats,
  .briefing-project-status-row {
    display: none;
  }
  .briefing-project-compact-stats {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    white-space: nowrap;
    overflow-x: auto;
    gap: var(--space-1);
    margin: var(--space-2) 0;
    font-size: var(--text-sm);
    color: var(--fg-secondary);
  }
}

/* ------------------------------------------------------------------ */
/* Stats KPI strip — Row 1 (narvi-x7v4)                               */
/* ------------------------------------------------------------------ */

.stats-kpi-strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-3) 0;
}

/* ------------------------------------------------------------------ */
/* Stats tile — KPI strip component (narvi-qs1j)                       */
/* ------------------------------------------------------------------ */

.stats-tile {
  display: inline-flex;
  flex-direction: column;
  background: var(--bg-surface-2);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  position: relative;
}
.stats-tile__label {
  font-size: var(--text-meta);
  color: var(--fg-muted);
}
.stats-tile__value {
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  color: var(--fg-secondary);
  font-weight: 600;
}
.stats-tile__sublabel {
  font-size: var(--text-meta);
  color: var(--fg-muted);
}
.stats-tile__tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + var(--space-1));
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-meta);
  white-space: nowrap;
  z-index: 10;
  pointer-events: none;
}
.stats-tile:hover .stats-tile__tooltip {
  display: block;
}

.stats-window-picker {
  display: flex;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
}
.stats-window-btn {
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--fg-secondary);
  cursor: pointer;
  font-size: var(--text-sm);
  padding: var(--space-1) var(--space-2);
}
.stats-window-btn.is-active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--bg-primary);
}

/* ------------------------------------------------------------------ */
/* Stats Row 4 — model usage bar list (narvi-6bo1)                    */
/* ------------------------------------------------------------------ */

.stats-model-list {
  margin: var(--space-3) 0;
}

.stats-model-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-1) 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
  color: var(--fg-secondary);
  position: relative;
}

.stats-model-row__bar {
  height: 4px;
  background: var(--color-accent);
  border-radius: 2px;
  min-width: 2px;
  position: absolute;
  bottom: 0;
  left: 0;
}

.stats-model-row__name {
  font-weight: 600;
  min-width: 6em;
  color: var(--color-fg);
}

.stats-model-row__tasks,
.stats-model-row__cost,
.stats-model-row__runtime,
.stats-model-row__tokens {
  font-variant-numeric: tabular-nums;
  color: var(--fg-secondary);
  font-size: var(--text-xs);
}

.stats-model-row__provider {
  font-size: var(--text-xs);
  color: var(--fg-muted);
  background: var(--bg-surface-2);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.4em;
  margin-left: auto;
}

.stats-empty {
  color: var(--fg-muted);
  font-size: var(--text-sm);
  font-style: italic;
  padding: var(--space-2) 0;
}

.stats-row {
  display: flex;
  gap: var(--space-4);
  margin: var(--space-3) 0;
}

.stats-row--time {
  display: block;
}

.svg-rolling {
  opacity: 0.4;
}

.stats-row--problems {
  display: block;
}

.stats-row--throughput {
  display: block;
  position: relative;
}

.stats-row--provider {
  display: block;
}

.stats-provider-runtime {
  margin-top: var(--space-3);
}

.stats-provider-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-1) 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
  color: var(--fg-secondary);
  position: relative;
}

.stats-provider-bar {
  height: 4px;
  background: var(--color-accent);
  border-radius: 2px;
  min-width: 2px;
  position: absolute;
  bottom: 0;
  left: 0;
}

.stats-provider-name {
  font-weight: 600;
  min-width: 6em;
  color: var(--color-fg);
}

.stats-provider-runtime__value {
  font-variant-numeric: tabular-nums;
  font-size: var(--text-xs);
  color: var(--fg-secondary);
}

.stats-row--tokens {
  display: block;
}

.stats-row--cost-by-project {
  display: block;
}

.stats-bar-tooltip {
  display: none;
  position: absolute;
  top: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm, 4px);
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  color: var(--fg-primary);
  white-space: pre;
  pointer-events: none;
  z-index: 10;
}

.stats-row__chart-wrap {
  flex: 1 1 0;
  min-width: 0;
}

.stats-chartjs-wrap {
  position: relative;
  width: 100%;
}

.stats-chart-label {
  display: block;
  font-size: var(--text-xs);
  color: var(--fg-muted);
  margin-bottom: var(--space-1);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stats-throughput-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--fg-primary);
}

.stats-throughput-legend__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.stats-throughput-legend__swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.stats-throughput-legend__label {
  display: inline;
}

.stats-problems-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--fg-primary);
}

.stats-problems-legend__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.stats-problems-legend__swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.stats-problems-legend__swatch--anomalies {
  background-color: var(--accent);
}

.stats-problems-legend__swatch--reopens {
  background-color: var(--color-chart-secondary);
}

.stats-problems-legend__swatch--blocked {
  background-color: var(--status-blocked);
}

.stats-problems-legend__swatch--failed {
  background-color: var(--status-warn);
}

.stats-problems-legend__label {
  display: inline;
}

/* ------------------------------------------------------------------ */
/* Stats page — Row 2 combined cost+runtime chart legend (narvi-locu)  */
/* ------------------------------------------------------------------ */

.stats-time-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--fg-primary);
}

.stats-time-legend__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.stats-time-legend__swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.stats-time-legend__swatch--cost {
  background-color: var(--accent);
}

.stats-time-legend__swatch--runtime {
  background-color: var(--color-chart-secondary);
}

.stats-time-legend__label {
  display: inline;
}

/* ------------------------------------------------------------------ */
/* Stats page — token volume legend (narvi-rfvwh)                      */
/* ------------------------------------------------------------------ */

.stats-tokens-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--fg-primary);
}

.stats-tokens-legend__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.stats-tokens-legend__swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.stats-tokens-legend__swatch--input {
  background-color: var(--accent);
}

.stats-tokens-legend__swatch--output {
  background-color: var(--color-chart-secondary);
}

.stats-tokens-legend__label {
  display: inline;
}

/* ------------------------------------------------------------------ */
/* Stats page — section cards (narvi-3f8r)                             */
/* ------------------------------------------------------------------ */

.stats-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin: var(--space-3) 0;
}

.stats-card--kpi {
  background: transparent;
  border-color: var(--border-subtle);
}

.stats-card__header {
  margin-bottom: var(--space-3);
}

.stats-card__title {
  font-size: var(--text-section);
  font-weight: 600;
  color: var(--fg-primary);
  margin: 0 0 var(--space-1) 0;
}

.stats-card__lede {
  font-size: var(--text-sm);
  color: var(--fg-secondary);
  margin: 0;
}

/* ------------------------------------------------------------------ */
/* Claude usage widget                                                 */
/* ------------------------------------------------------------------ */

section.claude-usage-widget {
  margin-top: var(--space-6);
  padding: var(--space-4);
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  max-width: 480px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 1px 2px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.15);
}

section.claude-usage-widget h2 {
  margin-bottom: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cu-status {
  display: block;
  font-size: var(--text-sm);
  color: var(--color-fg-dim);
  margin-bottom: var(--space-3);
}

.cu-status--error {
  color: var(--color-white);
  background: var(--color-error-critical);
  padding: var(--space-2);
  border-radius: 4px;
  word-break: break-word;
  white-space: pre-wrap;
}

.cu-chart {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.cu-sparkline-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.cu-sparkline-label {
  font-size: var(--text-xs);
  color: var(--color-fg-dim);
  width: 2ch;
  flex-shrink: 0;
}

.cu-sparkline-svg {
  width: 100%;
  height: auto;
  flex: 1;
}

/* ------------------------------------------------------------------ */
/* Utility                                                             */
/* ------------------------------------------------------------------ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.muted { color: var(--color-fg-dim); }
.error { color: var(--color-error); }

/* ------------------------------------------------------------------ */
/* Project view                                                        */
/* ------------------------------------------------------------------ */

.project-view-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  position: relative;
}


.project-view-header h1 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--color-fg);
}

.project-view-header .counts {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}

.status-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: var(--space-1) var(--space-2);
  border-radius: 99px;
  background: var(--color-border);
  color: var(--color-fg-dim);
  min-height: 44px;
  min-width: 44px;
}

.status-count-badge--open        { background: var(--color-status-open);        color: var(--color-white); }
.status-count-badge--in_progress { background: var(--color-status-in-progress); color: var(--color-on-accent); }
.status-count-badge--blocked     { background: var(--color-status-blocked);     color: var(--color-on-accent); }
/* AA contrast: matches .status-badge fixes (was #ccc, failed) */
.status-count-badge--closed      { background: var(--color-status-closed);      color: var(--color-white); }
.status-count-badge--deferred    { background: var(--color-status-deferred-bg); color: var(--color-white); }

/* Status-dot vocabulary (narvi-ascq) */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  vertical-align: middle;
}

.status-dot--in_progress { background: var(--status-in-progress); }
.status-dot--open        { background: transparent; border: 1.5px solid var(--status-open); box-sizing: border-box; }
.status-dot--blocked     { background: var(--status-blocked); }
.status-dot--done        { background: var(--fg-muted); }
.status-dot--anomaly     { background: var(--status-warn); }
.status-dot--deferred    { background: var(--color-status-deferred-bg); }

.project-view-header .full-dag {
  margin-left: auto;
  color: var(--color-link);
  text-decoration: none;
  font-size: 0.875rem;
}


.project-view-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* On desktop, constrain the body to exactly 100dvh so the grid's 1fr row
   (#app) fills the remaining viewport height regardless of header row count.
   This eliminates the page-level scroll bar without a magic pixel subtraction. */
body:has(.project-view-body) {
  height: 100dvh;
  overflow: hidden;
}

#app:has(.project-view-body) {
  overflow: hidden;
  padding: 0;
  display: flex;
  flex-direction: column;
}

#app:has(.project-view-body) .project-view-body {
  flex: 1;
  min-height: 0;
  height: auto;
}

#narrative-rail {
  overflow-y: auto;
  padding: var(--space-3);
  min-height: 0;
  flex: 1;
}

.project-status-strip {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  padding: var(--space-2) var(--space-4);
  background: var(--bg-surface-2);
  font-size: var(--text-sm);
  color: var(--fg-secondary);
  border-bottom: 1px solid var(--border-default);
}

.status-strip-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.status-strip-counts,
.status-strip-anomalies,
.status-strip-spend {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.status-strip-spend {
  margin-left: auto;
}

.status-strip-count {
  background: none;
  border: none;
  color: var(--fg-secondary);
  cursor: pointer;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  padding: 0 var(--space-1);
}

.status-strip-count:disabled {
  opacity: 0.4;
  cursor: default;
}

.status-strip-count--active {
  color: var(--color-link);
  text-decoration: underline;
}

.status-strip-dismiss {
  cursor: pointer;
  margin-left: var(--space-1);
}

.status-strip-no-anomalies {
  opacity: 0.5;
}

/* narvi-sw1y: anomaly chip uses the canonical --status-warn token (matches
   .status-dot--anomaly and .narrative-anomaly), so anomalies read as the same
   vocabulary across surfaces. Higher specificity than .status-strip-count's
   default fg-secondary so the warn color survives unless --active overrides. */
.status-strip-anomalies .status-strip-count {
  color: var(--status-warn);
}

/* narvi-wbcvx: compact dot+count row; visible only at <760px via media query below */
.status-strip-compact {
  display: none;
}

.project-view-phase-banner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--bg-surface-2);
  font-size: var(--text-xs);
  color: var(--fg-secondary);
  border-bottom: 1px solid var(--border-default);
}

.phase-banner-dismiss {
  background: none;
  border: none;
  color: var(--fg-secondary);
  cursor: pointer;
  padding: 0 var(--space-1);
  font-size: var(--text-sm);
  line-height: 1;
}


/* Shared bead-id-first row layout for narrative events and upcoming entries */
.row-bead-id {
  flex-shrink: 0;
  width: 104px;
  min-width: 96px;
  font-family: var(--font-mono, monospace);
  font-size: var(--text-xs);
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
}

a.row-bead-id:hover {
  text-decoration: underline;
}

.narrative-day-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: 24px;
  margin-bottom: 12px;
  color: var(--fg-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  list-style: none;
}

.narrative-day-header::before,
.narrative-day-header::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--border-subtle);
}

.narrative-section-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: 24px;
  margin-bottom: 12px;
  color: var(--fg-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  list-style: none;
}

.narrative-section-header::before,
.narrative-section-header::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--border-subtle);
}

.narrative-event {
  display: grid;
  /* bead-id | chips | glyph | text (wraps) | runtime | cost | model | provider */
  grid-template-columns: min-content 48px 12px minmax(0, 1fr) 64px 64px 56px 64px;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-1) 0;
  font-size: var(--text-sm);
  transition: background 150ms ease-out;
}

.narrative-event:hover {
  background: var(--bg-surface-2);
}

.narrative-event .row-bead-id {
  grid-column: 1;
  width: auto;
  min-width: 0;
}

.row-chips {
  grid-column: 2;
  display: flex;
  align-items: center;
  /* The parent .narrative-event grid baseline-aligns its cells against the
   * bead-id text baseline. SVG icons have no text baseline so the row falls
   * back to the icon's bottom edge, lifting the chip above the text line.
   * align-self: center overrides that just for the chip column. */
  align-self: center;
  gap: 1px;
}

.narrative-event .glyph {
  grid-column: 3;
  width: 12px;
  height: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.narrative-event .text {
  grid-column: 4;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.narrative-added .glyph   { color: var(--color-narrative-added); }
.narrative-changed .glyph { color: var(--color-narrative-changed); }
.narrative-fixed .glyph   { color: var(--color-narrative-fixed); }
.narrative-notable .glyph { color: var(--color-status-notable); }
.narrative-blocked .glyph { color: var(--color-narrative-blocked); }

.narrative-event .detail {
  grid-column: 1 / -1;
  font-size: var(--text-xs);
  color: var(--color-fg); /* AA: #d4d4d4 on dark bg (was #888 fg-dim, marginal at 0.75rem) */
}

.narrative-event.narrative-anomaly,
.narrative-event.narrative-blocked {
  box-shadow: inset 2px 0 0 var(--row-accent);
  background: color-mix(in srgb, var(--row-accent) 10%, transparent);
  padding-inline-start: var(--space-2);
}

.narrative-event.narrative-anomaly { --row-accent: var(--status-warn); }
.narrative-event.narrative-blocked  { --row-accent: var(--status-blocked); }

.narrative-event.narrative-no-change {
  opacity: 0.6;
}

.row-runtime,
.row-cost,
.row-model,
.row-provider {
  font-family: var(--font-mono, monospace);
  font-size: var(--text-xs);
  color: var(--fg-muted);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.row-runtime  { grid-column: 5; }
.row-cost     { grid-column: 6; }
.row-model    { grid-column: 7; }
.row-provider { grid-column: 8; }

/* narvi-cx9m: two-row collapse — text drops to row 2, metrics right-align on row 1 */
@media (max-width: 759px) {
  .narrative-event {
    grid-template-columns: min-content 48px 12px 1fr auto auto auto;
  }

  .narrative-event .row-provider {
    display: none;
  }

  .narrative-event .text {
    grid-row: 2;
    grid-column: 1 / -1;
    min-width: 0;
  }
}


.in-flight-section {
  list-style: none;
  margin: 0;
  padding: 0;
}

.in-flight-entry {
  display: grid;
  /* bead-id | chips | glyph | text (wraps) | runtime | cost | complexity */
  grid-template-columns: min-content 48px 12px minmax(0, 1fr) 64px 64px 56px;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-1) 0;
  font-size: var(--text-sm);
}

.in-flight-entry .row-bead-id {
  grid-column: 1;
  width: auto;
  min-width: 0;
}

.in-flight-entry .row-chips {
  grid-column: 2;
}

.in-flight-entry .glyph {
  grid-column: 3;
  width: 12px;
  height: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.in-flight-entry .row-text {
  grid-column: 4;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.in-flight-entry .row-runtime { grid-column: 5; }
.in-flight-entry .row-cost    { grid-column: 6; }
.in-flight-entry .row-complexity { grid-column: 7; }

/* narvi-f0i74: in-flight-entry two-row collapse — text drops to row 2, metrics right-align on row 1 */
@media (max-width: 759px) {
  .in-flight-entry {
    grid-template-columns: min-content 48px 12px 1fr auto auto auto;
  }

  .in-flight-entry .row-text {
    grid-row: 2;
    grid-column: 1 / -1;
    min-width: 0;
  }
}

.row-complexity {
  font-family: var(--font-mono, monospace);
  font-size: var(--text-xs);
  color: var(--fg-muted);
  text-align: right;
  white-space: nowrap;
}

.in-flight-deferred-group {
  margin-top: var(--space-1);
}

.in-flight-deferred-label {
  font-size: var(--text-xs, 0.75rem);
  color: var(--color-fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: block;
  padding: var(--space-1) 0;
}

.in-flight-deferred-list {
  list-style: none;
  margin: 0;
  padding: 0;
}


@media (max-width: 768px) {
  /* Collapse top row to single-row mobile header (~48px = --space-12) */
  .header-row--top {
    max-height: var(--space-12);
  }

  /* Show overflow button on mobile */
  .header-overflow-btn {
    display: inline-flex;
  }

  .header-row--project-nav {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  /* narvi-6l3q: on mobile, wrap rather than ellipsize so the full title stays
     on screen. m8ig's ellipsis design hid the right-hand portion of titles. */
  .row-text {
    min-width: 0;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .briefing-active-task-row {
    flex-wrap: wrap;
  }

  .usage-stats-pill__row {
    white-space: normal;
  }

  /* Status strip: wrap all groups so counts don't overflow on 760-768px viewport */
  .project-status-strip {
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .status-strip-left {
    flex-wrap: wrap;
  }

  .status-strip-counts {
    flex-wrap: wrap;
  }

}

@media (max-width: 759px) {
  /* narvi-wbcvx: collapse stats strip to single-line dot+count tokens.
   * Hide the labeled wide-format groups; show the compact row instead. */
  .status-strip-left,
  .status-strip-spend {
    display: none;
  }

  .status-strip-compact {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    white-space: nowrap;
    overflow-x: auto;
    gap: var(--space-1);
    font-size: var(--text-sm);
    color: var(--fg-secondary);
    min-width: 0;
  }
}

@media (max-width: 480px) {
  .briefing-grid {
    grid-template-columns: 1fr;
  }
}

/* ------------------------------------------------------------------ */
/* Map page — phase cards                                              */
/* ------------------------------------------------------------------ */

.map-phases {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.phase-card {
  background: var(--bg-surface);
  border-left: 3px solid transparent;
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  text-decoration: none;
  color: inherit;
  transition: background 200ms ease-out;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 1px 2px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.15);
}

.phase-card:hover {
  background: var(--bg-surface-2);
}

.phase-card-expanded {
  margin-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--space-2);
}

.phase-task-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) 0;
  font-size: var(--text-sm);
}

.phase-task-row__title {
  flex: 1;
  min-width: 0;
  color: var(--fg-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.phase-card-show-more {
  display: block;
  margin-top: var(--space-2);
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-sm);
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
}

.phase-card-view-all {
  display: block;
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--accent);
}

.phase-card__name {
  margin: 0 0 var(--space-1) 0;
  font-size: var(--text-base);
  color: var(--color-fg-strong);
}

.phase-card__status {
  display: block;
  font-size: var(--text-sm);
  color: var(--color-fg-dim);
  margin-bottom: var(--space-2);
}

.phase-card__mini-bar {
  font-size: var(--text-sm);
  color: var(--color-fg-dim);
  font-variant-numeric: tabular-nums;
  margin-bottom: var(--space-2);
}

.phase-card__anomaly {
  display: inline-block;
  font-size: var(--text-sm);
  color: var(--color-error);
  margin-right: var(--space-3);
}

.phase-card__spend,
.phase-card__date-range {
  display: inline-block;
  font-size: var(--text-sm);
  color: var(--color-fg-dim);
  font-variant-numeric: tabular-nums;
  margin-right: var(--space-3);
}

/* State modifiers */

.phase-card--active {
  background: var(--bg-surface-2);
  border-left-color: var(--color-accent);
}

.phase-card--done {
  background: var(--bg-surface);
  opacity: 0.7;
}

.phase-card--done .phase-card__name {
  font-size: var(--text-sm);
}

.phase-card--paused {
  background: var(--bg-surface);
  border-left-color: var(--border-default);
}

.phase-card--upcoming {
  background: var(--bg-surface);
  border-left-color: var(--border-subtle);
}

@media (max-width: 768px) {
  /* minmax(0, 1fr): a bare 1fr resolves to max(min-content, available), and
     descendants' nowrap titles push min-content past the viewport. */
  .map-phases {
    grid-template-columns: minmax(0, 1fr);
  }

  /* This override must come AFTER the base .phase-task-row__title rule in
     source order; placing it in an earlier @media block loses the cascade
     for shared properties (overflow, white-space, text-overflow). */
  .phase-task-row__title {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
  }
}

.phase-card__blocked-by {
  display: block;
  font-size: var(--text-xs);
  color: var(--fg-secondary);
  margin-top: var(--space-1);
}

.phase-card__enables-chip {
  display: inline-block;
  font-size: var(--text-xs);
  color: var(--fg-secondary);
  background: var(--bg-surface-2);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-1);
  margin-top: var(--space-1);
  margin-right: var(--space-1);
}

.map-arrows {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.map-arrow {
  stroke: var(--border-default);
  stroke-width: 1;
  fill: none;
}

/* ------------------------------------------------------------------ */
/* Auto-generated docs page                                            */
/* ------------------------------------------------------------------ */

.auto-docs-banner {
  background: var(--color-surface);
  border-left: 4px solid var(--color-accent);
  padding: var(--space-2) var(--space-4);
  margin-bottom: var(--space-6);
  border-radius: var(--radius-sm);
}

.auto-docs-index {
  margin-bottom: var(--space-8);
  position: sticky;
  top: 0;
  background: var(--color-bg);
  z-index: 50;
}

.auto-docs-index ul {
  list-style: none;
  padding-left: 0;
}

.auto-doc-section {
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.auto-doc-section .auto-doc-filename {
  margin-bottom: var(--space-4);
}

.auto-doc-section pre {
  overflow-x: auto;
  max-width: 100%;
}

.auto-doc-body {
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.65;
}

.auto-doc-body h2 {
  font-size: 1.25em;
  font-weight: 600;
  margin-top: var(--space-8);
  margin-bottom: var(--space-3);
}

.auto-doc-body h3 {
  font-size: 1.05em;
  font-weight: 600;
  color: var(--fg-secondary);
  margin-top: var(--space-6);
  margin-bottom: var(--space-2);
}

.auto-doc-body p {
  margin-bottom: var(--space-3);
}

.auto-doc-body pre {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-6);
  margin: var(--space-4) 0;
}

.auto-doc-body code {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.15em 0.35em;
  font-size: 0.9em;
}

.auto-doc-body pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}

/* Two-column layout: sticky TOC rail + content */
.doc-two-col {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: var(--space-6);
  align-items: start;
  margin-top: var(--space-4);
}

.doc-toc {
  position: sticky;
  top: var(--header-height, 0px);
  align-self: start;
  max-height: calc(100dvh - var(--header-height, 0px));
  overflow: auto;
  background: var(--color-bg);
  z-index: 5;
}

.doc-toc-skinny {
  display: none;
}

.doc-toc-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-2) var(--space-3) var(--space-1);
}

.doc-toc-nav {
  list-style: none;
  padding: 0;
  margin: 0;
}

.doc-toc-nav a {
  display: block;
  color: var(--fg-secondary);
  font-size: var(--text-sm);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  text-decoration: none;
}


.doc-toc-nav a:hover {
  color: var(--fg-primary);
  background: var(--bg-surface-2);
}

.doc-toc-nav .doc-toc-h3 {
  padding-left: var(--space-6);
}

.doc-content {
  min-width: 0;
  padding-left: var(--space-4);
}

@media (max-width: 759px) {
  .doc-two-col {
    grid-template-columns: 1fr;
  }

  .doc-toc {
    display: none;
  }

  .doc-toc-skinny {
    display: block;
    margin-bottom: var(--space-4);
  }
}

.project-docs-picker {
  display: block;
  margin-bottom: var(--space-4);
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-fg);
  font-size: var(--text-sm);
}

/* ------------------------------------------------------------------ */
/* Render error (development diagnostic)                               */
/* ------------------------------------------------------------------ */

.render-error {
  padding: var(--space-4);
  border: 2px solid var(--color-error);
  background: var(--color-error-surface);
  color: var(--color-error-fg);
  font-family: var(--font-mono);
  white-space: pre-wrap;
}

/* ------------------------------------------------------------------ */
/* Plan form                                                           */
/* ------------------------------------------------------------------ */

.plan-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: 720px;
}

.plan-form__field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.plan-form__field span {
  font-size: var(--text-sm);
  color: var(--color-muted);
}

.plan-form__field input[type="text"],
.plan-form__field select {
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-fg);
  font-size: var(--text-sm);
}

.plan-form__spec-textarea {
  width: 100%;
  min-height: 200px;
  padding: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-fg);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  resize: vertical;
}

.plan-form__field--inline {
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
}

.plan-form__error {
  color: var(--color-error);
  font-size: var(--text-sm);
}

.plan-log-output {
  max-height: 480px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--color-surface);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
}

.plan-run-status { font-size: var(--text-sm); color: var(--color-muted); }
.plan-run-done { font-size: var(--text-sm); }
.plan-back-link { font-size: var(--text-sm); }


/* .region-stale — applied to #app when the displayed manifest is behind the   */
/* highest generation seen across all fetches. Render is never blocked.        */
.region-stale {
  box-shadow: inset 0 0 0 1px var(--border-subtle);
  opacity: 0.92;
}

/* ------------------------------------------------------------------ */
/* History page (narvi-2p0j)                                          */
/* ------------------------------------------------------------------ */

.history-page { padding: var(--space-4) 0; }

.history-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.history-table th, .history-table td {
  text-align: left;
  padding: var(--space-1) var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}
.history-table th {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--fg-muted);
}
.history-table tr:last-child td { border-bottom: none; }
.history-table tr:hover td { background: var(--bg-surface-2); }

.history-ts { color: var(--fg-secondary); white-space: nowrap; }
.history-target {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--fg-secondary);
  word-break: break-all;
}
.history-duration { color: var(--fg-muted); white-space: nowrap; }

.history-service {
  display: inline-block;
  padding: .1rem .4rem;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
}
.history-service--trampoline { background: var(--history-service-trampoline-bg); color: var(--history-service-trampoline-fg); }
.history-service--broker     { background: var(--history-service-broker-bg);     color: var(--history-service-broker-fg); }

.history-outcome {
  display: inline-block;
  padding: .1rem .4rem;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
}
.history-outcome--ok       { background: var(--history-outcome-ok-bg);       color: var(--history-outcome-ok-fg); }
.history-outcome--failed   { background: var(--history-outcome-failed-bg);   color: var(--history-outcome-failed-fg); }
.history-outcome--skipped  { background: var(--history-outcome-skipped-bg);  color: var(--history-outcome-skipped-fg); }
.history-outcome--started  { background: var(--history-outcome-started-bg);  color: var(--history-outcome-started-fg); }
.history-outcome--rejected { background: var(--history-outcome-rejected-bg); color: var(--history-outcome-rejected-fg); }

/* --- Trampoline status panel (narvi-1ijg) --------------------------------- */

.trampoline-status-panel {
  margin-bottom: var(--space-4);
}

.trampoline-status-banner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  margin-bottom: var(--space-2);
}

.trampoline-status-banner--stale {
  background: color-mix(in srgb, var(--status-warn) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--status-warn) 30%, transparent);
  color: var(--fg-primary);
}

.trampoline-status-banner--failed {
  background: color-mix(in srgb, var(--status-blocked) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--status-blocked) 30%, transparent);
  color: var(--fg-primary);
}

.trampoline-build-section h3 {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--fg-secondary);
  margin: 0 0 var(--space-2) 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.trampoline-build-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.trampoline-build-table th {
  text-align: left;
  padding: var(--space-1) var(--space-2);
  color: var(--fg-muted);
  font-weight: 500;
  border-bottom: 1px solid var(--border-subtle);
}

.trampoline-build-table td {
  padding: var(--space-1) var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

.trampoline-build-row--failed td {
  color: var(--fg-primary);
}

.trampoline-build-tag {
  font-family: var(--font-mono);
  color: var(--fg-primary);
  overflow-wrap: anywhere;
}

.trampoline-build-log {
  font-family: var(--font-mono);
  color: var(--fg-muted);
  font-size: var(--text-xs, 0.75rem);
  overflow-wrap: anywhere;
}

.trampoline-build-tail-row td {
  background: var(--bg-surface-2);
  padding: 0;
}

.trampoline-build-tail {
  margin: 0;
  padding: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs, 0.75rem);
  color: var(--color-error);
  white-space: pre-wrap;
  overflow-x: auto;
  max-height: 10em;
  overflow-y: auto;
}
