/*
 * NVDGE — Developer Panel theme. Variables are namespaced `--nvdge-*` so a
 * future re-skin is a global find-replace. The current values match the RFX
 * Roofing Management site palette (frontend/tailwind.config.ts) since the
 * panel ships embedded against that target. Dark mode by design.
 */

:root {
  /* RFX core palette */
  --nvdge-bg: #0B1120;             /* dark-bg */
  --nvdge-card: #1F2937;           /* dark-card */
  --nvdge-surface: #151E2E;        /* surface */
  --nvdge-surface-2: #1A2538;      /* surface hover */
  --nvdge-sidebar: #0F1923;        /* sidebar */
  --nvdge-sidebar-2: #080E18;      /* sidebar dark */
  --nvdge-border: #1E293B;         /* dark-border */
  --nvdge-border-2: #1A2332;       /* dark-border-light */
  --nvdge-line: rgba(255,255,255,0.06);

  --nvdge-fg: #E2E8F0;             /* text-primary */
  --nvdge-fg-2: #94A3B8;           /* text-secondary */
  --nvdge-fg-dim: #64748B;         /* text-muted */

  --nvdge-primary: #2563EB;        /* primary */
  --nvdge-primary-hover: #3B82F6;  /* primary-light */
  --nvdge-primary-wash: rgba(37,99,235,0.08);
  --nvdge-primary-active: rgba(37,99,235,0.15);

  --nvdge-accent: #06B6D4;
  --nvdge-success: #10B981;
  --nvdge-warning: #F59E0B;
  --nvdge-danger: #EF4444;
  --nvdge-danger-bg: rgba(239,68,68,0.1);

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;

  --shadow-1: 0 1px 0 rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.4);
  --shadow-2: 0 4px 12px rgba(0,0,0,0.4), 0 12px 32px rgba(0,0,0,0.5);

  --font-body: "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-heading: "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Menlo", monospace;

  --t-fast: 140ms cubic-bezier(.2,.8,.2,1);
  --t-med: 240ms cubic-bezier(.2,.8,.2,1);

  /* Shell geometry. Header height + rail width define the chrome around
   * the active mode's content. The proto-panel-w is overridden inline by
   * the drag handle so its current value persists across renders. */
  --header-h: 44px;
  --rail-w: 44px;
  --proto-panel-w: 25vw;
  --proto-panel-min-pct: 25;
  --proto-panel-max-pct: 75;
  --resize-handle-w: 6px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
/* `html` carries the same dark background so reload navigations don't
 * paint a white frame during the brief gap between teardown and
 * fresh-paint. Also matches the user-agent backdrop on the iframe's
 * empty state and on any portion of the viewport not yet covered by
 * `.shell` during initial paint. */
html { background: var(--nvdge-bg); color-scheme: dark; }
body {
  background: var(--nvdge-bg);
  color: var(--nvdge-fg);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6 { font-family: var(--font-heading); font-weight: 600; margin: 0; }

#app, #app > .shell { height: 100dvh; }

/* Visually-hidden helper for screen-reader-only labels. */
.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;
}

/* =================================================================
 * Shell layout (header on top, rail down the left, mode content on
 * the right). Mode content fills the remaining area; in Proto mode
 * it splits further into [resizable panel | drag handle | iframe].
 * ================================================================= */

.shell {
  position: relative; /* anchor for the absolute signin-screen overlay */
  display: grid;
  grid-template-rows: var(--header-h) 1fr;
  height: 100dvh;
  background: var(--nvdge-bg);
}
.shell-body {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  min-height: 0;
}
.shell-body > * { min-width: 0; min-height: 0; }

/* ----- Header ----- */
.shell-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 0;
  border-bottom: 1px solid var(--nvdge-border);
  background: var(--nvdge-sidebar-2);
  font-size: 13px;
}
.shell-logo {
  width: var(--rail-w);
  height: var(--header-h);
  display: grid;
  place-items: center;
  border-right: 1px solid var(--nvdge-border);
  background: var(--nvdge-sidebar);
  color: var(--nvdge-primary-hover);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.05em;
  user-select: none;
}
.shell-header-spacer { flex: 1; }
.shell-header select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--nvdge-surface);
  background-image: linear-gradient(45deg, transparent 50%, var(--nvdge-fg-2) 50%),
                    linear-gradient(135deg, var(--nvdge-fg-2) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 10px) 50%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  border: 1px solid var(--nvdge-border);
  border-radius: var(--radius-sm);
  color: var(--nvdge-fg);
  font: inherit;
  font-size: 12px;
  padding: 4px 24px 4px 10px;
  cursor: pointer;
  outline: none;
  height: 28px;
  max-width: 220px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
.shell-header select:hover { background-color: var(--nvdge-surface-2); }
.shell-header select:focus-visible { border-color: var(--nvdge-primary); }
.shell-header select option { background: var(--nvdge-card); color: var(--nvdge-fg); }
.shell-header-label {
  font-size: 10px;
  color: var(--nvdge-fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: -4px;
}

/* Branch picker — custom tree dropdown replacing native <select> so the
 * parent-child branch hierarchy can render with indentation. */
.branch-picker {
  position: relative;
  font-size: 12px;
  max-width: 240px;
}
.branch-picker.is-empty { padding: 4px 10px; color: var(--nvdge-fg-dim); }
.branch-picker-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  background: var(--nvdge-surface);
  border: 1px solid var(--nvdge-border);
  border-radius: var(--radius-sm);
  color: var(--nvdge-fg);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  max-width: 220px;
}
.branch-picker-trigger:hover { background: var(--nvdge-surface-2); }
.branch-picker.is-open .branch-picker-trigger { border-color: var(--nvdge-primary); }
.branch-picker-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}
.branch-picker-chevron {
  width: 9px;
  height: 6px;
  flex-shrink: 0;
  color: var(--nvdge-fg-2);
  transition: transform 120ms ease-out;
}
.branch-picker.is-open .branch-picker-chevron { transform: rotate(180deg); }
.branch-picker-tree {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 60;
  min-width: 240px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--nvdge-card);
  border: 1px solid var(--nvdge-border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
  padding: 4px 0;
}
.branch-picker-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 6px 6px 8px;
  white-space: nowrap;
  color: var(--nvdge-fg);
  user-select: none;
}
.branch-picker-item:hover { background: var(--nvdge-surface-2); }
.branch-picker-item.is-active { background: var(--nvdge-surface-2); color: var(--nvdge-fg); font-weight: 600; }
.branch-picker-item.is-prod { color: var(--nvdge-fg-dim); }
.branch-picker-pick {
  flex: 1;
  min-width: 0;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
}
.branch-picker-edit,
.branch-picker-del {
  background: transparent;
  border: 0;
  color: var(--nvdge-fg-dim);
  font: inherit;
  font-size: 14px;
  line-height: 1;
  width: 22px; height: 22px;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 100ms ease-out;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}
.branch-picker-edit svg { width: 12px; height: 12px; }
.branch-picker-item:hover .branch-picker-edit,
.branch-picker-item:hover .branch-picker-del { opacity: 1; }
.branch-picker-edit:hover {
  background: var(--nvdge-surface-2);
  color: var(--nvdge-fg);
}
.branch-picker-del:hover {
  background: var(--nvdge-danger-bg);
  color: #fca5a5;
}
.branch-picker-elbow {
  display: inline-block;
  color: var(--nvdge-fg-dim);
  margin-right: 2px;
}
.shell-icon-btn {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  color: var(--nvdge-fg-2);
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.shell-icon-btn:hover { background: var(--nvdge-surface-2); color: var(--nvdge-fg); }
.shell-icon-btn:focus-visible { outline: 2px solid var(--nvdge-primary); outline-offset: 1px; }
.shell-icon-btn svg { width: 16px; height: 16px; }
.shell-icon-btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.shell-icon-btn-danger:hover:not([disabled]) { background: var(--nvdge-danger-bg); color: #fca5a5; }

/* Header Nudge button — sized to 28px so it sits flush with the branch
 * picker trigger and the icon buttons. Active state inverts to a ghost
 * outline so the user knows inspect mode is on. */
.shell-nudge-btn {
  appearance: none;
  background: var(--nvdge-primary);
  border: 1px solid var(--nvdge-primary);
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  height: 28px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.shell-nudge-btn:hover { background: var(--nvdge-primary-hover); border-color: var(--nvdge-primary-hover); }
.shell-nudge-btn:focus-visible { outline: 2px solid var(--nvdge-primary); outline-offset: 2px; }
.shell-nudge-btn.is-active {
  background: transparent;
  border-color: var(--nvdge-border);
  color: var(--nvdge-fg-2);
}
.shell-nudge-btn.is-active:hover {
  background: var(--nvdge-surface-2);
  color: var(--nvdge-fg);
}
.shell-account {
  margin-left: 4px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--nvdge-primary);
  color: #fff;
  font-weight: 600;
  font-size: 11px;
  display: grid; place-items: center;
  border: 0;
  cursor: pointer;
  user-select: none;
}
.shell-account:hover { background: var(--nvdge-primary-hover); }
.shell-account:focus-visible { outline: 2px solid var(--nvdge-primary); outline-offset: 2px; }

/* Account dropdown */
.account-menu {
  position: absolute;
  top: calc(var(--header-h) + 4px);
  right: 8px;
  background: var(--nvdge-card);
  border: 1px solid var(--nvdge-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  min-width: 220px;
  z-index: 250;
  padding: 6px;
  display: flex; flex-direction: column;
  gap: 2px;
}
.account-menu-head {
  padding: 8px 10px 6px;
  border-bottom: 1px solid var(--nvdge-border);
  margin-bottom: 4px;
}
.account-menu-email {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--nvdge-fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-menu-org {
  font-size: 10px;
  color: var(--nvdge-fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}
.account-menu-item {
  appearance: none;
  background: transparent;
  border: 0;
  text-align: left;
  font: inherit;
  font-size: 12px;
  color: var(--nvdge-fg);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: block;
  width: 100%;
}
.account-menu-item:hover { background: var(--nvdge-surface-2); }
.account-menu-item.is-danger { color: #fca5a5; }

/* ----- Vertical mode rail ----- */
.shell-rail {
  background: var(--nvdge-sidebar);
  border-right: 1px solid var(--nvdge-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 0;
  gap: 2px;
}
.rail-mode {
  appearance: none;
  background: transparent;
  border: 0;
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  color: var(--nvdge-fg-2);
  cursor: pointer;
  display: grid; place-items: center;
  transition: background var(--t-fast), color var(--t-fast);
  position: relative;
}
.rail-mode svg { width: 18px; height: 18px; }
.rail-mode:hover { background: var(--nvdge-surface-2); color: var(--nvdge-fg); }
.rail-mode.is-active { color: var(--nvdge-primary-hover); background: var(--nvdge-primary-active); }
.rail-mode.is-active::before {
  content: '';
  position: absolute;
  left: -8px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 18px;
  border-radius: 0 2px 2px 0;
  background: var(--nvdge-primary-hover);
}
.rail-mode:focus-visible { outline: 2px solid var(--nvdge-primary); outline-offset: 1px; }

/* ----- Mode content area ----- */
.shell-main { display: grid; grid-template-rows: 1fr; min-height: 0; }
.shell-main > * { min-height: 0; min-width: 0; }

/* Proto mode: panel | drag handle | iframe.
 * Width of the panel column is set inline via --proto-panel-w (clamped by
 * the drag-handle JS so the column stays within [25vw, 75vw]). */
.proto-mode-layout {
  display: grid;
  grid-template-columns: var(--proto-panel-w) var(--resize-handle-w) 1fr;
  height: 100%;
}
.proto-mode-layout > * { min-height: 0; min-width: 0; }
.proto-resize-handle {
  cursor: col-resize;
  background: transparent;
  border-left: 1px solid var(--nvdge-border);
  border-right: 1px solid var(--nvdge-border);
  position: relative;
  user-select: none;
}
.proto-resize-handle::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 2px; height: 28px;
  background: var(--nvdge-fg-dim);
  border-radius: 1px;
  opacity: 0.4;
  transition: opacity var(--t-fast);
}
.proto-resize-handle:hover::after,
.proto-resize-handle.is-dragging::after { opacity: 1; background: var(--nvdge-primary-hover); }
.proto-resize-handle.is-dragging { background: var(--nvdge-primary-active); }
body.is-resizing,
body.is-resizing * { cursor: col-resize !important; user-select: none !important; }
/* The cross-origin iframe at :3000 captures pointer events the moment the
 * cursor crosses into its area. Disabling pointer-events on it during a
 * drag keeps the events flowing to the parent window's drag handler so
 * the resize stays responsive across the iframe's full width. */
body.is-resizing .dev-iframe { pointer-events: none; }

/* Signed-out screen: collapse the rail and center the sign-in card.
 * The rail column inside .shell-body is fixed at var(--rail-w); the
 * is-signed-out modifier zeroes it so the sign-in screen owns the full
 * viewport width below the header. */
.shell-body.is-signed-out { grid-template-columns: 0 1fr; }
.shell-body.is-signed-out > .shell-rail { display: none; }

/* Signin overlay — sits above the rest of the shell when not authed.
 * Absolute positioning isolates it from shell-main's grid so the iframe
 * underneath can never bleed through. */
.signin-screen {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
  background: var(--nvdge-bg);
}
.signin-screen-card {
  width: 100%;
  max-width: 420px;
  background: var(--nvdge-card);
  border: 1px solid var(--nvdge-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: 28px;
  display: flex; flex-direction: column; gap: 14px;
}
.signin-screen-card h2 { font-size: 20px; line-height: 1.3; }

/* `[hidden]` override for the layout containers. Each mode-layout sets
 * `display: grid|flex` at base specificity; the user-agent
 * `[hidden] { display: none }` rule has the same specificity but earlier
 * origin, so it gets shadowed without these explicit overrides. */
.proto-mode-layout[hidden],
.logs-mode-layout[hidden],
.signin-screen[hidden] { display: none; }

/* Logs mode: horizontal tab strip across the top + content panel
 * below. No iframe pane, no resize handle — Logs is data-centric and
 * fills the full main width. Tab strip stays sticky-feel by sitting
 * directly under the existing shared header. */
.logs-mode-layout {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
  min-width: 0;
  min-height: 0;
}
.logs-tabs {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0 12px;
  background: var(--nvdge-surface-1, #161b22);
  border-bottom: 1px solid var(--nvdge-border);
  overflow-x: auto;
}
.logs-tab {
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--nvdge-fg-dim);
  padding: 10px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.logs-tab:hover { color: var(--nvdge-fg); }
.logs-tab.is-active {
  color: var(--nvdge-fg);
  border-bottom-color: var(--nvdge-primary);
}
.logs-tab:focus-visible { outline: 2px solid var(--nvdge-primary); outline-offset: -2px; }

.logs-content {
  overflow-y: auto;
  padding: 16px;
  min-height: 0;
}
.logs-empty {
  padding: 32px;
  text-align: center;
}

/* Logs > Runs list. Toolbar across the top (filters + refresh),
 * then a vertical list of run rows. Each row is a clickable card —
 * the trigger is the whole row, not a buried button. */
.logs-runs { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.logs-runs-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--nvdge-border);
}
.logs-runs-filter { display: flex; align-items: center; gap: 6px; }
.logs-runs-filter select {
  background: var(--nvdge-surface-2, #1f2937);
  color: var(--nvdge-fg);
  border: 1px solid var(--nvdge-border);
  border-radius: 4px;
  padding: 4px 8px;
  font: inherit;
  font-size: 12px;
}

.logs-runs-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.logs-run-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: var(--nvdge-surface-1, #161b22);
  border: 1px solid var(--nvdge-border);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.logs-run-row:hover,
.logs-run-row:focus-visible {
  border-color: var(--nvdge-primary);
  background: var(--nvdge-surface-2, #1f2937);
  outline: none;
}
.logs-run-row-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.logs-run-row-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.logs-run-kind {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--nvdge-surface-2, #1f2937);
  color: var(--nvdge-fg-dim);
  flex: 0 0 auto;
}
.logs-run-kind.kind-coding          { color: #4ade80; }
.logs-run-kind.kind-security_review { color: #f87171; }
.logs-run-kind.kind-change_review   { color: #fbbf24; }
.logs-run-kind.kind-sync_review     { color: #60a5fa; }
.logs-run-kind.kind-gate_review     { color: #c084fc; }

.logs-run-prompt {
  flex: 1 1 auto;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.logs-run-meta { flex: 0 0 auto; white-space: nowrap; }
.logs-run-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--nvdge-surface-2, #1f2937);
  font-size: 11px;
}
.logs-run-chip.is-error { color: #f87171; background: rgba(248, 113, 113, 0.15); }

/* Logs > Runs detail page. Replaces the list when a row is opened. */
.logs-run-detail { display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.logs-run-detail-back {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--nvdge-border);
}
.logs-run-detail-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--nvdge-border);
}
.logs-run-detail-prompt {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  line-height: 1.4;
  white-space: pre-wrap;
}
.logs-run-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.logs-run-events {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.logs-run-events .trace-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  background: var(--nvdge-surface-1, #161b22);
  border: 1px solid var(--nvdge-border);
  border-radius: 6px;
  min-width: 0;
}
.logs-run-events .trace-prompt {
  flex: 0 0 auto;
  width: 18px;
  font-family: var(--font-mono);
  color: var(--nvdge-fg-dim);
}
.logs-run-events .trace-content {
  flex: 1 1 auto;
  min-width: 0;
  word-break: break-word;
}
.logs-run-events .trace-error .trace-content { color: #fca5a5; }

.logs-run-toolcall summary,
.logs-run-toolresult summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.logs-run-toolcall summary::-webkit-details-marker,
.logs-run-toolresult summary::-webkit-details-marker { display: none; }
.logs-run-toolcall summary::before,
.logs-run-toolresult summary::before {
  content: '▸';
  display: inline-block;
  width: 12px;
  color: var(--nvdge-fg-dim);
  transition: transform 0.1s;
}
.logs-run-toolcall[open] summary::before,
.logs-run-toolresult[open] summary::before {
  transform: rotate(90deg);
}
.logs-run-toolresult { margin-top: 6px; display: block; }
.logs-run-toolresult.is-error summary { color: #fca5a5; }
.logs-run-payload {
  margin: 6px 0 0;
  padding: 8px 10px;
  background: var(--nvdge-surface-2, #1f2937);
  border: 1px solid var(--nvdge-border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow-y: auto;
}

/* Logs > Commits list. Each row: sha + headline at top, author +
 * time below, optional expandable body for multi-line commit
 * messages. No click action (commits aren't drillable yet) so rows
 * aren't styled as buttons — just informational cards. */
.logs-commits { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.logs-commits-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.logs-commit-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  background: var(--nvdge-surface-1, #161b22);
  border: 1px solid var(--nvdge-border);
  border-radius: 6px;
}
.logs-commit-row-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.logs-commit-row-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.logs-commit-sha {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--nvdge-fg-dim);
  flex: 0 0 auto;
}
.logs-commit-headline {
  flex: 1 1 auto;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.logs-commit-body {
  margin-top: 4px;
}
.logs-commit-body summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.logs-commit-body summary::-webkit-details-marker { display: none; }
.logs-commit-body summary::before {
  content: '▸';
  display: inline-block;
  width: 12px;
  color: var(--nvdge-fg-dim);
}
.logs-commit-body[open] summary::before { transform: rotate(90deg); display: inline-block; }
.logs-commit-body pre {
  margin: 6px 0 0;
  padding: 8px 10px;
  background: var(--nvdge-surface-2, #1f2937);
  border: 1px solid var(--nvdge-border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ----- Developer Panel (VS-Code-density terminal) ----- */
.dev-panel {
  display: flex;
  flex-direction: column;
  background: var(--nvdge-sidebar);
  border-right: 1px solid var(--nvdge-border);
  min-width: 0;
  font-size: 12px;
  line-height: 1.5;
}
.dev-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px;
  border-bottom: 1px solid var(--nvdge-border);
  background: var(--nvdge-sidebar-2);
}
.dev-panel-title {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--nvdge-fg-2);
}
.dev-mark {
  background: var(--nvdge-primary); color: #fff;
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  padding: 2px 6px; border-radius: 4px;
}
.dev-panel-actions {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-bottom: 1px solid var(--nvdge-border);
  background: var(--nvdge-sidebar);
}
.dev-panel-actions .model-select-wrap { margin-left: auto; }
.dev-panel-actions .btn-sm { height: 28px; }
.dev-panel-actions .model-select { height: 28px; }
.dev-panel-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
  padding: 6px 0 0;
}
.dev-panel-foot {
  border-top: 1px solid var(--nvdge-border);
  padding: 4px 10px;
  font-size: 10px; color: var(--nvdge-fg-dim);
  letter-spacing: 0.02em;
}
.dev-panel-foot code { font-family: var(--font-mono); color: var(--nvdge-fg-2); }

/* ----- RFX iframe pane ----- */
.rfx-pane {
  display: flex; flex-direction: column;
  min-width: 0;
  background: var(--nvdge-bg);
}
.rfx-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--nvdge-border);
  background: var(--nvdge-surface);
}
.rfx-title {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 14px; color: var(--nvdge-fg);
}
.rfx-mark {
  background: var(--nvdge-primary); color: #fff;
  font-size: 10px; font-weight: 700; letter-spacing: 0.05em;
  padding: 3px 8px; border-radius: 4px;
}
.dev-iframe-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1; min-height: 0;
  background: var(--nvdge-bg);
}
.dev-iframe {
  flex: 1; min-height: 0;
  width: 100%;
  border: 0; display: block;
  /* Dark default so an unset preview (about:blank) doesn't blast the user
   * with a full-pane #fff. Real previews paint over this immediately. */
  background: var(--nvdge-bg);
  color-scheme: dark;
}

/* Chrome-style address bar that sits above the iframe. Rendered only
 * when state.previewURL is set (IframeNav component returns null
 * otherwise), so the fallback overlay never has to hide it. */
.iframe-nav {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--nvdge-surface, #1a1d20);
  border-bottom: 1px solid var(--nvdge-border, rgba(255, 255, 255, 0.08));
}
.iframe-nav-btn {
  flex: 0 0 auto;
  height: 28px; min-width: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 6px;
  background: transparent;
  color: var(--nvdge-fg, #e6e6e6);
  border: 1px solid var(--nvdge-border, rgba(255, 255, 255, 0.12));
  border-radius: 6px;
  font-size: 14px; line-height: 1;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
}
.iframe-nav-btn:hover:not(:disabled) {
  background: var(--nvdge-card, rgba(255, 255, 255, 0.06));
  border-color: var(--nvdge-border-strong, rgba(255, 255, 255, 0.2));
}
.iframe-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.iframe-nav-url-wrap {
  flex: 1 1 auto;
  min-width: 0;
}
.iframe-nav-url {
  width: 100%;
  height: 28px;
  padding: 0 10px;
  background: var(--nvdge-bg, #0d0f11);
  color: var(--nvdge-fg, #e6e6e6);
  border: 1px solid var(--nvdge-border, rgba(255, 255, 255, 0.12));
  border-radius: 14px;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 12px;
  outline: none;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.iframe-nav-url:focus {
  border-color: var(--nvdge-accent, #4a8df0);
  background: var(--nvdge-surface, #1a1d20);
}
/* Preview viewport size readout (W x H) — for reporting layout issues at exact dims. */
.iframe-nav-vp {
  flex: 0 0 auto;
  white-space: nowrap;
  height: 28px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  color: var(--nvdge-fg-muted, #9aa4b0);
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--nvdge-border, rgba(255, 255, 255, 0.12));
  border-radius: 6px;
  user-select: text;
}
.dev-iframe-fallback {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--nvdge-surface);
  color: var(--nvdge-fg);
  padding: 24px; text-align: center; gap: 12px;
}
.dev-iframe-fallback-mark {
  font-size: 28px; line-height: 1;
  color: var(--nvdge-fg-dim);
  opacity: 0.7;
}
.dev-iframe-fallback h3 {
  margin: 0; font-size: 14px; font-weight: 600;
}
.dev-iframe-fallback p {
  margin: 0; max-width: 480px; font-size: 12px; line-height: 1.5;
}
/* The user-agent rule `[hidden] { display: none }` is shadowed by our
 * `.dev-iframe-fallback { display: flex }` (same specificity, later origin),
 * so the `hidden` attribute alone wouldn't hide it. Explicit override: */
.dev-iframe-fallback[hidden] {
  display: none;
}
.dev-iframe-fallback code {
  background: var(--nvdge-card); padding: 2px 6px; border-radius: 4px;
  font-family: var(--font-mono); font-size: 12px;
}

/* Layer 2 dev-server controls inside the iframe fallback. */
.devserver-start-btn {
  margin-top: 4px;
  padding: 8px 16px;
  background: var(--nvdge-accent, #4a8df0);
  color: white;
  border: none; border-radius: 6px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: opacity 0.15s ease;
}
.devserver-start-btn:hover:not(:disabled) { opacity: 0.85; }
.devserver-start-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.devserver-error {
  color: #f88; font-family: var(--font-mono); font-size: 11px;
  max-width: 480px; word-break: break-word;
}

/* Dev-server chip in the right cluster of the NVDGE header (next to
 * the notifications bell). Visible only while a Layer 2 dev server
 * is running for the active prototype. */
.devserver-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 8px 4px 10px;
  margin-right: 6px;
  background: var(--nvdge-card, #1a1d24);
  color: var(--nvdge-fg, #d8dde6);
  border: 1px solid var(--nvdge-border, #2a2e38);
  border-radius: 999px;
  font-size: 11px; font-family: var(--font-mono);
}
.devserver-chip-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #4ade80; box-shadow: 0 0 6px #4ade80;
}
.devserver-chip-label { line-height: 1; }
.devserver-chip-stop {
  background: transparent; color: inherit;
  border: 1px solid var(--nvdge-border, #2a2e38);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px; cursor: pointer;
}
.devserver-chip-stop:hover:not(:disabled) {
  background: var(--nvdge-surface, #14171c);
  border-color: var(--nvdge-fg-dim, #6a7180);
}
.devserver-chip-stop:disabled { opacity: 0.5; cursor: not-allowed; }

/* ----- NVDGE backend banner / chip ----- */
.dev-panel-banner {
  margin: 8px 10px;
  font-size: 12px;
}
.dev-user-chip {
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 2px 6px;
  background: var(--nvdge-surface);
  border: 1px solid var(--nvdge-border);
  border-radius: 4px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Sign-in form — same shape as the API-key form, just two inputs. */
.signin-form { display: flex; flex-direction: column; gap: 10px; }
.signin-input {
  font: inherit;
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--nvdge-surface);
  color: var(--nvdge-fg);
  border: 1px solid var(--nvdge-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  outline: none;
  height: 44px;
  width: 100%;
}
.signin-input:focus { border-color: var(--nvdge-primary); }
.signin-input:disabled { opacity: 0.6; cursor: not-allowed; }

/* ----- Connect stack ----- */
.connect-stack { display: flex; flex-direction: column; gap: 12px; padding: 0 10px; }
.connect-stack h3 { font-size: 16px; }
.connect-btn {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items: center;
  text-align: left;
  padding: 12px;
  height: auto;
  min-height: 56px;
}
.agent-mark {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,0.12);
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
  color: #fff;
}
.connect-label { display: flex; flex-direction: column; gap: 2px; }
.connect-name { font-size: 14px; font-weight: 600; }
.connect-sub { font-size: 12px; }

/* ----- Chat (terminal trace) ----- */
.chat {
  flex: 1;
  min-height: 0;
  display: flex; flex-direction: column;
}
/* Model selector — strips the native chrome and keeps the look in line
 * with the uppercase 10-px chat-id strip. The native arrow is replaced by
 * a CSS chevron rendered via a background image so the dropdown still
 * indicates affordance without OS-specific styling leaking through. */
.model-select-wrap {
  display: inline-flex; align-items: center;
}
.model-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background: transparent;
  background-image: linear-gradient(45deg, transparent 50%, var(--nvdge-fg-2) 50%),
                    linear-gradient(135deg, var(--nvdge-fg-2) 50%, transparent 50%);
  background-position: calc(100% - 10px) 50%, calc(100% - 6px) 50%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--nvdge-fg);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
  padding: 2px 18px 2px 6px;
  cursor: pointer;
  outline: none;
  transition: background-color var(--t-fast), border-color var(--t-fast);
}
.model-select:hover { background-color: var(--nvdge-surface-2); border-color: var(--nvdge-border); }
.model-select:focus-visible { border-color: var(--nvdge-primary); }
/* The popped-open option list inherits the page's dark color from the
 * native control's color attribute, but Chromium uses the OS theme for
 * the popup itself. We can at least give the visible <select> a tidy
 * surface; the popup's appearance is OS-controlled and acceptable. */
.model-select option { background: var(--nvdge-card); color: var(--nvdge-fg); }

.chat-thread {
  list-style: none; padding: 4px 0 4px; margin: 0;
  display: flex; flex-direction: column;
  flex: 1; min-height: 0;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
}

/* Trace rows: a thin gutter for the prefix marker, then content. */
.trace-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 6px;
  padding: 1px 10px;
  align-items: start;
}
.trace-row + .trace-row { /* tighter visual rhythm than .chat-msg gap */ }
.trace-prompt {
  font-family: var(--font-mono);
  text-align: center;
  color: var(--nvdge-fg-dim);
  font-size: 11px;
  user-select: none;
  padding-top: 1px;
}
.trace-content {
  /* Prose uses the body font; code/paths/tools stay mono via inline <code>. */
  font-family: var(--font-body);
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.trace-content code,
.trace-content .trace-tool-name {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--nvdge-accent);
}
.trace-content .trace-args { font-family: var(--font-mono); font-size: 11.5px; }
.trace-content .trace-tag {
  display: inline-block;
  margin-left: 6px;
  font-family: var(--font-mono); font-size: 10px;
  color: var(--nvdge-fg-dim);
}
.trace-italic { font-style: italic; }
.trace-cursor {
  display: inline-block;
  margin-left: 1px;
  color: var(--nvdge-primary-hover);
  animation: blink 1s steps(2) infinite;
}
/* Single status row between the chat thread and the input. Visible
 * only while the agent is streaming. Holds the pulsing asterisk
 * spinner and a single text chip with gerund + elapsed timer +
 * running cost estimate. Replaces the per-event live chip and the
 * per-message duration footer — one indicator on screen at a time. */
.chat-spinner-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-top: 1px solid var(--nvdge-border);
  background: var(--nvdge-sidebar-2);
  flex-shrink: 0;
}
.trace-spinner-star {
  display: inline-block;
  font-size: 13px;
  line-height: 1;
  color: var(--nvdge-primary-hover);
  transform-origin: center;
  animation: spinner-pulse 1.6s ease-in-out infinite;
  user-select: none;
}
@keyframes spinner-pulse {
  0%, 100% { transform: scale(0.85); opacity: 0.55; }
  50%      { transform: scale(1.1); opacity: 1; }
}
.chat-spinner-text {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--nvdge-fg-2);
  letter-spacing: 0.01em;
  flex: 1;
}
.chat-stop-btn {
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--nvdge-fg);
  background: transparent;
  border: 1px solid var(--nvdge-border);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  cursor: pointer;
  user-select: none;
}
.chat-stop-btn:hover {
  background: var(--nvdge-danger-bg);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}
.chat-stop-btn:active { transform: translateY(0.5px); }
@keyframes blink { 50% { opacity: 0; } }

/* Per-role coloring of the prompt marker. */
.trace-user .trace-prompt-user { color: var(--nvdge-primary-hover); }
.trace-agent .trace-prompt-agent { color: var(--nvdge-success); }
.trace-thinking .trace-prompt { color: var(--nvdge-fg-dim); }
.trace-tool-call .trace-prompt { color: var(--nvdge-warning); }
.trace-tool-result .trace-prompt { color: var(--nvdge-success); }
.trace-tool-result.is-error .trace-prompt,
.trace-error .trace-prompt { color: var(--nvdge-danger); }
.trace-error .trace-content { color: #fca5a5; }
.trace-system .trace-prompt { color: var(--nvdge-fg-dim); }

/* Patch trace row — compact one-liner with inline action links. */
.trace-patch .trace-prompt { color: var(--nvdge-accent); }
.trace-patch .trace-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 8px;
  row-gap: 0;
  align-items: baseline;
}
.trace-patch-summary { font-weight: 600; font-size: 12px; color: var(--nvdge-fg); }
.trace-patch-files {
  grid-column: 1 / -1;
  font-family: var(--font-mono); font-size: 11px;
}
.trace-patch-actions {
  display: inline-flex; gap: 8px; align-items: center;
  font-family: var(--font-mono); font-size: 11px;
}
/* Stale patch from a resumed (history-loaded) session — read-only,
 * dimmed to telegraph "this is from before, can't act on it." */
.trace-patch.is-stale .trace-patch-summary { color: var(--nvdge-fg-2); }
.trace-patch.is-stale .trace-prompt { opacity: 0.5; }
.trace-patch.is-stale .trace-patch-actions { color: var(--nvdge-fg-dim); }
.patch-applied {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--nvdge-success);
}
.patch-error {
  font-family: var(--font-mono); font-size: 11px;
  color: #fca5a5;
}

/* Chat form — terminal prompt feel. */
.chat-form {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 6px;
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
  background: var(--nvdge-sidebar-2);
  border-top: 1px solid var(--nvdge-border);
  align-items: start;
}
.chat-prompt-mark {
  font-family: var(--font-mono);
  color: var(--nvdge-primary-hover);
  font-size: 13px;
  padding-top: 4px;
  text-align: center;
  user-select: none;
}
.chat-input {
  grid-column: 2;
  font-family: var(--font-mono); font-size: 12px; line-height: 1.5;
  color: var(--nvdge-fg);
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 4px 0 0;
  /* Height is managed programmatically (autosizeTextarea in app.mjs); the
   * manual resize handle gets in the way of that, and overflow-y kicks in
   * once the auto-fit content height exceeds the cap. */
  resize: none;
  overflow-y: auto;
  min-height: 72px;
  max-height: 200px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  display: block;
}
.chat-input::placeholder { color: var(--nvdge-fg-dim); }
.chat-input:focus { outline: none; }
.chat-input:disabled { opacity: 0.6; cursor: not-allowed; }
.chat-form-actions {
  grid-column: 2;
  display: flex; align-items: center; justify-content: flex-end;
  gap: 8px;
  font-size: 11px;
  margin-top: 2px;
}

/* Inline-text link buttons used inside the trace. Replaces .btn for the
 * compact terminal aesthetic — no fill, no border, just colored text. */
.btn-link {
  appearance: none;
  background: transparent;
  border: 0; padding: 0;
  font: inherit;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--nvdge-fg-2);
  cursor: pointer;
  text-decoration: underline dotted transparent;
  text-underline-offset: 2px;
  transition: color var(--t-fast), text-decoration-color var(--t-fast);
}
.btn-link:hover:not(:disabled) {
  color: var(--nvdge-fg);
  text-decoration-color: var(--nvdge-fg-2);
}
.btn-link:focus-visible {
  outline: 2px solid var(--nvdge-primary);
  outline-offset: 1px; border-radius: 2px;
}
.btn-link:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-link-primary { color: var(--nvdge-primary-hover); font-weight: 600; }
.btn-link-primary:hover:not(:disabled) { color: #fff; text-decoration-color: var(--nvdge-primary-hover); }

.dot-flash {
  display: inline-block; width: 6px; height: 6px;
  background: var(--nvdge-fg-2); border-radius: 999px;
  margin-right: 4px;
  animation: dot-pulse 1.2s infinite ease-in-out;
}
.dot-flash:nth-child(2) { animation-delay: 0.15s; }
.dot-flash:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot-pulse {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

/* ----- History view (audit log) ----- */
.history-list {
  display: flex; flex-direction: column;
  flex: 1; min-height: 0;
  overflow: auto;
  padding: 4px 0;
}
.history-row {
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--nvdge-border);
  text-align: left;
  font: inherit;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--nvdge-fg);
  padding: 8px 10px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 8px;
  row-gap: 2px;
  transition: background var(--t-fast);
}
.history-row:hover { background: var(--nvdge-surface-2); }
.history-row:focus-visible { outline: 2px solid var(--nvdge-primary); outline-offset: -2px; }
.history-row-time {
  grid-column: 1; grid-row: 1;
  color: var(--nvdge-fg-2);
}
.history-row-meta {
  grid-column: 2; grid-row: 1;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px;
}
.history-row-model { color: var(--nvdge-accent); }
.history-row-status { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; }
.history-row-status.status-active { color: var(--nvdge-success); }
.history-row-status.status-ended  { color: var(--nvdge-fg-dim); }
.history-row-tokens {
  grid-column: 1; grid-row: 2;
  font-size: 10.5px;
}
.history-row-user {
  grid-column: 2; grid-row: 2;
  font-size: 10.5px;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.history-detail {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
}
.history-detail-head {
  padding: 6px 10px 8px;
  border-bottom: 1px solid var(--nvdge-border);
  background: var(--nvdge-sidebar-2);
}
.history-detail-meta {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
}
.chat-thread-history {
  /* Same shape as the live thread but no chat input below, so it owns
   * the full body height. */
  flex: 1; min-height: 0;
  overflow: auto;
  list-style: none;
  margin: 0;
  padding: 4px 0;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
}
.history-detail-foot {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--nvdge-border);
  background: var(--nvdge-sidebar-2);
}

/* ----- API key form (reuses dev-oauth modal but adds an input row) ----- */
.key-field {
  display: flex; flex-direction: column; gap: 6px;
}
.key-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: stretch;
}
.key-input-row input[type="password"],
.key-input-row input[type="text"] {
  font: inherit; font-family: var(--font-mono);
  font-size: 13px;
  background: var(--nvdge-surface);
  color: var(--nvdge-fg);
  border: 1px solid var(--nvdge-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  outline: none;
  height: 44px;
  width: 100%;
}
.key-input-row input:focus {
  border-color: var(--nvdge-primary);
}
.key-input-row .btn {
  height: 44px;
  min-width: 64px;
}

/* ----- Buttons ----- */
.btn {
  appearance: none; cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-size: 13px; font-weight: 600;
  height: 44px; padding: 0 16px;
  background: var(--nvdge-card); color: var(--nvdge-fg);
  border: 1px solid var(--nvdge-border);
  border-radius: var(--radius);
  transition: background var(--t-fast), border-color var(--t-fast);
}
.btn:hover:not(:disabled) { background: var(--nvdge-surface-2); }
.btn:active:not(:disabled) { transform: translateY(0.5px); }
.btn:focus-visible { outline: 2px solid var(--nvdge-primary); outline-offset: 2px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { height: 36px; padding: 0 12px; font-size: 12px; }
.btn-full { width: 100%; }
.btn-primary { background: var(--nvdge-primary); border-color: var(--nvdge-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--nvdge-primary-hover); border-color: var(--nvdge-primary-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--nvdge-fg-2); }
.btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,0.06); color: var(--nvdge-fg); }

.icon-x {
  background: transparent; border: 0; color: var(--nvdge-fg-2);
  font-size: 22px; line-height: 1; cursor: pointer;
  padding: 4px 8px; border-radius: 6px;
  min-height: 36px;
}
.icon-x:hover { background: var(--nvdge-surface-2); color: var(--nvdge-fg); }
.icon-x:focus-visible { outline: 2px solid var(--nvdge-primary); outline-offset: 2px; }

/* ----- Inspect outline ----- */
body.dev-inspect, body.dev-inspect * { cursor: crosshair !important; }
.dev-outline {
  position: absolute;
  z-index: 90;
  pointer-events: none;
  border: 2px solid var(--nvdge-primary);
  background: var(--nvdge-primary-wash);
  border-radius: 4px;
  box-shadow: 0 0 0 4px rgba(37,99,235,0.15);
  transition: all 80ms ease-out;
  display: none;
}

/* ----- Nudge composer (dark-mode popup) ----- */
.dev-composer {
  position: fixed; inset: 0;
  background: rgba(8, 14, 24, 0.6);
  backdrop-filter: blur(4px);
  display: grid; place-items: center;
  padding: 16px;
  z-index: 200;
  animation: fade-in 120ms ease-out;
}
.dev-composer-card {
  background: var(--nvdge-card);
  color: var(--nvdge-fg);
  border: 1px solid var(--nvdge-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  max-width: 520px; width: 100%;
  padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
}
.dev-composer-head {
  display: flex; justify-content: space-between; align-items: center;
}
.dev-composer-target {
  background: var(--nvdge-surface);
  border: 1px solid var(--nvdge-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12px; color: var(--nvdge-fg-2);
}
.dev-composer-label {
  font-size: 10px; letter-spacing: 0.12em; font-weight: 700;
  text-transform: uppercase;
  color: var(--nvdge-fg-dim); margin-bottom: 4px;
  display: flex; align-items: center; gap: 8px;
}
.dev-composer-copied {
  letter-spacing: 0.04em; text-transform: none; font-weight: 600;
  color: var(--nvdge-primary-hover);
  animation: fade-in 120ms ease-out;
}
.dev-composer-ref {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin: 0 -4px; padding: 2px 4px;
  transition: background 80ms ease-out;
}
.dev-composer-ref:hover,
.dev-composer-ref:focus-visible {
  background: var(--nvdge-primary-wash);
  outline: none;
}
.dev-composer-ref-body { min-width: 0; }
.dev-composer-copy-ic {
  flex: none; font-size: 13px; line-height: 1.2;
  color: var(--nvdge-fg-dim);
  opacity: 0.65;
}
.dev-composer-ref:hover .dev-composer-copy-ic,
.dev-composer-ref:focus-visible .dev-composer-copy-ic {
  color: var(--nvdge-primary-hover); opacity: 1;
}
/* Element display NAME (from the id->name registry): the prominent human label at
   the top of the target card. Bold + full-size so the reporter reads it first; the
   id + selector sit beneath as the machine reference. */
.dev-composer-name {
  font-weight: 600; font-size: 13px; line-height: 1.3;
  color: var(--nvdge-fg); margin-bottom: 3px;
  word-break: break-word;
}
.dev-composer-target code {
  font-family: var(--font-mono); color: var(--nvdge-primary-hover);
  font-size: 12px;
}
.dev-composer-meta strong { color: var(--nvdge-fg); font-weight: 600; }
.dev-composer-text {
  margin-top: 6px; font-style: italic; color: var(--nvdge-fg);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.dev-composer-input {
  font-family: inherit; font-size: 14px; line-height: 1.5;
  background: var(--nvdge-surface);
  border: 1px solid var(--nvdge-border); color: var(--nvdge-fg);
  border-radius: var(--radius-sm);
  padding: 12px 14px; min-height: 96px; resize: vertical; outline: none;
}
.dev-composer-input:focus { border-color: var(--nvdge-primary); }
.dev-composer-actions {
  display: flex; justify-content: flex-end; gap: 8px;
}
.dev-composer-hint { font-size: 11px; text-align: right; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ----- OAuth modal ----- */
.dev-oauth {
  position: fixed; inset: 0;
  background: rgba(8, 14, 24, 0.78);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  padding: 16px;
  z-index: 220;
  animation: fade-in 140ms ease-out;
}
.dev-oauth-card {
  background: var(--nvdge-card);
  color: var(--nvdge-fg);
  border: 1px solid var(--nvdge-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  max-width: 460px; width: 100%;
  padding: 24px;
  display: flex; flex-direction: column; gap: 14px;
}
.dev-oauth-brand {
  display: inline-flex; align-items: center; gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--nvdge-border);
}
.anthropic-mark {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: #d97757;
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700;
}
.dev-oauth-card h2 { font-size: 18px; line-height: 1.3; }
.dev-oauth-scopes { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.dev-oauth-scopes li {
  display: flex; align-items: start; gap: 10px;
  font-size: 13px; color: var(--nvdge-fg);
  background: var(--nvdge-surface);
  border: 1px solid var(--nvdge-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.check { color: var(--nvdge-success); font-weight: 700; }
.dev-oauth-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  padding-top: 6px;
}
.dev-oauth-foot { margin: 0; }
.alert {
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
}
.alert-error { background: var(--nvdge-danger-bg); color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); }
.alert-info { background: rgba(37,99,235,0.08); color: var(--nvdge-fg-2); border: 1px solid rgba(37,99,235,0.25); }

/* Create-prototype template picker. Radio cards rendered as a grid;
 * the selected card gets a brighter border + subtle wash so it reads
 * as the active choice without needing a heavy "selected" treatment. */
.template-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 8px;
  margin-top: 4px;
}
.template-card {
  position: relative;
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: var(--nvdge-surface);
  border: 1px solid var(--nvdge-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 120ms ease-out, background 120ms ease-out;
}
.template-card:hover { background: var(--nvdge-surface-2); }
.template-card.is-selected {
  border-color: var(--nvdge-primary);
  background: var(--nvdge-primary-wash);
}
.template-card input[type="radio"] {
  margin: 3px 0 0 0;
  accent-color: var(--nvdge-primary);
  flex-shrink: 0;
}
.template-card-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.template-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--nvdge-fg);
}
.template-card-desc {
  font-size: 11px;
  line-height: 1.4;
}
.template-card-meta {
  font-size: 10px;
  color: var(--nvdge-fg-dim);
  margin-top: 2px;
}

/* ----- Create-prototype tabs (Start fresh / Import from Github) ----- */
.create-proto-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 12px;
  margin-bottom: -1px;
  font-size: 13px;
  color: var(--nvdge-fg-dim);
  cursor: pointer;
}
.create-proto-tab:hover { color: var(--nvdge-fg); }
.create-proto-tab.is-active {
  color: var(--nvdge-fg);
  border-bottom-color: var(--nvdge-primary);
}
.create-proto-tab:focus-visible {
  outline: 2px solid var(--nvdge-primary);
  outline-offset: 2px;
}

/* Github repo picker — list of buttons, one per repo. */
.github-repo-row:hover { background: var(--nvdge-surface-2); }
.github-repo-row:focus-visible {
  outline: 2px solid var(--nvdge-primary);
  outline-offset: -2px;
}
.github-repo-row:last-child { border-bottom: none; }

/* ----- Toast ----- */
.dev-toast {
  position: fixed;
  top: calc(20px + env(safe-area-inset-top));
  left: 50%; transform: translateX(-50%);
  background: var(--nvdge-card);
  color: var(--nvdge-fg);
  border: 1px solid var(--nvdge-border);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow-2);
  z-index: 300;
  animation: toast-in 180ms ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to   { opacity: 0.96; transform: translate(-50%, 0); }
}

/* ----- Misc ----- */
.muted { color: var(--nvdge-fg-2); }
.small { font-size: 12px; }
code { font-family: var(--font-mono); }

/* ----- Mobile/tablet reflow ----- */
/* On phone widths the resizable split collapses — the proto panel takes
 * the full main area and the iframe is hidden until you swap modes
 * (we'll likely add a tab toggle here later). */
@media (max-width: 768px) {
  .proto-mode-layout {
    grid-template-columns: 1fr;
  }
  .proto-mode-layout > .proto-resize-handle,
  .proto-mode-layout > .dev-iframe-wrap {
    display: none;
  }
}

/* Scrollbars (dark) */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--nvdge-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--nvdge-fg-dim); }

/* ==========================================================================
   Notifications Center (Phase 4)
   — bell icon (header) + right-side slideout
   ========================================================================== */

.shell-bell-btn {
  position: relative;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--nvdge-fg-2);
  cursor: pointer;
  margin-right: 4px;
}
.shell-bell-btn:hover { color: var(--nvdge-fg); background: var(--nvdge-surface-2); }
.shell-bell-btn:focus-visible { outline: 2px solid var(--nvdge-primary); outline-offset: 2px; }
.shell-bell-btn svg { width: 18px; height: 18px; }

/* Unread count badge — small red pill on the upper-right of the bell. */
.shell-bell-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--nvdge-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  font-family: var(--font-mono);
}

/* Right-side slideout. The overlay catches outside-clicks; the
   panel is a fixed-width drawer aligned to the right edge. */
.notif-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  justify-content: flex-end;
}
.notif-panel {
  width: min(380px, 100%);
  height: 100%;
  background: var(--nvdge-card);
  border-left: 1px solid var(--nvdge-border);
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.4);
  /* Animation only on first mount via .notif-panel-fresh — see
     openNotificationsSlideout. Without this guard, every render
     that changes items (dismiss / poll) recreates the panel
     element and re-runs the animation, which visually looks like
     the slideout closes and reopens. */
}
.notif-panel-fresh {
  animation: notif-slide-in 160ms ease-out;
}
@keyframes notif-slide-in {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

.notif-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--nvdge-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.notif-title { margin: 0; font-size: 14px; font-weight: 600; }
.notif-head-actions { display: flex; align-items: center; gap: 8px; }

.notif-empty {
  padding: 32px 16px;
  text-align: center;
}

.notif-list {
  flex: 1 1 auto;
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
}
.notif-row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--nvdge-line);
  position: relative;
}
.notif-row:hover { background: var(--nvdge-surface); }

.notif-row-body {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 10px;
  padding: 10px 12px;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
}
.notif-row-body:focus-visible { outline: 2px solid var(--nvdge-primary); outline-offset: -2px; }

.notif-row-icon {
  font-family: var(--font-mono);
  color: var(--nvdge-accent);
  text-align: center;
  align-self: start;
  padding-top: 2px;
}
.notif-kind-change_drift .notif-row-icon { color: var(--nvdge-warning); }

.notif-row-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.notif-row-title {
  font-weight: 600;
  font-size: 13px;
  word-wrap: break-word;
}
.notif-row-detail { word-wrap: break-word; }
.notif-row-meta { font-size: 11px; }

.notif-row-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--nvdge-primary);
  align-self: center;
}
.notif-row-notif-row-read .notif-row-dot,
.notif-row-actioned .notif-row-dot { display: none; }

.notif-row-dismiss {
  background: transparent;
  border: 0;
  color: var(--nvdge-fg-dim);
  font-size: 16px;
  width: 28px;
  cursor: pointer;
  align-self: stretch;
}
.notif-row-dismiss:hover { color: var(--nvdge-fg); background: var(--nvdge-surface-2); }
.notif-row-dismiss:focus-visible { outline: 2px solid var(--nvdge-primary); outline-offset: -2px; }

/* Read / actioned styling — muted but still visible. */
.notif-row-read .notif-row-title,
.notif-row-actioned .notif-row-title { color: var(--nvdge-fg-2); font-weight: 500; }

/* ==========================================================================
   Promote-to-prod modal (Phase 3c)
   ========================================================================== */

/* Header trigger button — sits flush with the branch picker. */
.shell-promote-btn {
  height: 28px;
  padding: 0 12px;
  margin-left: 4px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: var(--nvdge-primary);
  border: 1px solid var(--nvdge-primary);
  border-radius: 4px;
  cursor: pointer;
}
.shell-promote-btn:hover { background: var(--nvdge-primary-hover); border-color: var(--nvdge-primary-hover); }
.shell-promote-btn:focus-visible { outline: 2px solid var(--nvdge-primary-hover); outline-offset: 2px; }

/* Submit-PR header button — visually distinct from Promote (which is
   the canonical merge-to-prod action). PR submission is staging-bound,
   so a more neutral surface treatment fits the lower-stakes action. */
.shell-pr-btn {
  height: 28px;
  padding: 0 12px;
  margin-left: 4px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--nvdge-fg);
  background: var(--nvdge-surface-2);
  border: 1px solid var(--nvdge-border);
  border-radius: 4px;
  cursor: pointer;
}
.shell-pr-btn:hover { background: var(--nvdge-surface); border-color: var(--nvdge-fg-dim); }
.shell-pr-btn:focus-visible { outline: 2px solid var(--nvdge-primary); outline-offset: 2px; }

/* Sync-with-staging header button — same neutral treatment as Submit
   PR, since it's also a staging-direction action. Sits next to PR. */
.shell-sync-btn {
  height: 28px;
  padding: 0 12px;
  margin-left: 4px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--nvdge-fg);
  background: var(--nvdge-surface-2);
  border: 1px solid var(--nvdge-border);
  border-radius: 4px;
  cursor: pointer;
}
.shell-sync-btn:hover { background: var(--nvdge-surface); border-color: var(--nvdge-fg-dim); }
.shell-sync-btn:focus-visible { outline: 2px solid var(--nvdge-primary); outline-offset: 2px; }

/* Sync modal — chat column reuses .chat-thread / .chat-form from the
   live coding chat, but constrained to the modal's right-side panel
   so the thread scrolls inside the section instead of the whole modal.
   The .promote-review section becomes a flex column when it hosts a
   .sync-chat so the chat input can anchor to the bottom while the
   thread above scrolls inside its own overflow box. */
.promote-review:has(.sync-chat) {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sync-chat {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
}
.sync-chat .chat-thread {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
.sync-chat .chat-form { flex: 0 0 auto; }
.sync-chat .chat-spinner-row { flex: 0 0 auto; }

/* Findings sub-section heading — smaller than .promote-section-title,
   used for the three sync-finding categories (must / will / watch). */
.promote-section-subtitle {
  margin: 12px 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--nvdge-fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Modal sizing — wider than the create-prototype modal because we
   render two columns (deploy summary + streaming review) side by side
   on viewports ≥900px, falling back to stacked on narrower screens. */
.promote-overlay { padding: 24px; }
.promote-card {
  background: var(--nvdge-card);
  border: 1px solid var(--nvdge-border);
  border-radius: 8px;
  width: min(960px, 100%);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}

.promote-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--nvdge-border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.promote-head h2 { margin: 0 0 4px 0; font-size: 16px; }
.promote-head h2 code {
  font-family: var(--font-mono);
  background: var(--nvdge-surface-2);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 13px;
}
.promote-drift { color: var(--nvdge-warning); }

.promote-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  overflow: hidden;
}
@media (max-width: 900px) {
  .promote-body { grid-template-columns: 1fr; }
}

.promote-summary,
.promote-review {
  padding: 16px 20px;
  overflow-y: auto;
  min-height: 0;
}
.promote-summary { border-right: 1px solid var(--nvdge-border); background: var(--nvdge-surface); }
@media (max-width: 900px) {
  .promote-summary { border-right: none; border-bottom: 1px solid var(--nvdge-border); }
}

.promote-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--nvdge-fg-2);
  margin: 0 0 12px 0;
}
.promote-subhead {
  font-size: 12px;
  font-weight: 600;
  margin: 16px 0 8px 0;
  color: var(--nvdge-fg-2);
}

/* File list */
.promote-files { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.promote-file {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  font-family: var(--font-mono);
}
.promote-file-status {
  width: 18px;
  text-align: center;
  font-weight: 700;
  font-size: 11px;
}
.promote-file[data-status="added"]    .promote-file-status { color: var(--nvdge-success); }
.promote-file[data-status="deleted"]  .promote-file-status { color: var(--nvdge-danger); }
.promote-file[data-status="renamed"]  .promote-file-status { color: var(--nvdge-warning); }
.promote-file[data-status="modified"] .promote-file-status { color: var(--nvdge-accent); }
.promote-file-path { word-break: break-all; }
.promote-file-stat { color: var(--nvdge-fg-dim); white-space: nowrap; }
.promote-file-truncated { padding: 4px 0; }

/* Commit list */
.promote-commits { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.promote-commit {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: baseline;
  font-size: 12px;
}
.promote-commit-sha {
  font-family: var(--font-mono);
  color: var(--nvdge-accent);
  font-size: 11px;
}
.promote-commit-msg {
  color: var(--nvdge-fg);
  word-break: break-word;
}
.promote-commit-author { font-size: 11px; }

/* Decision banner */
.promote-decision {
  padding: 10px 12px;
  border-radius: 4px;
  margin-bottom: 12px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  border: 1px solid transparent;
}
.promote-decision.is-block { background: var(--nvdge-danger-bg); border-color: var(--nvdge-danger); }
.promote-decision.is-ack   { background: rgba(245,158,11,0.10); border-color: var(--nvdge-warning); }
.promote-decision.is-allow { background: rgba(16,185,129,0.10); border-color: var(--nvdge-success); }
.promote-decision-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 3px;
  background: rgba(0,0,0,0.3);
}
.promote-decision.is-block .promote-decision-tag { color: #fff; background: var(--nvdge-danger); }
.promote-decision.is-ack   .promote-decision-tag { color: var(--nvdge-bg); background: var(--nvdge-warning); }
.promote-decision.is-allow .promote-decision-tag { color: #fff; background: var(--nvdge-success); }
.promote-decision-summary { font-size: 13px; flex: 1 1 200px; }

/* Findings list */
.promote-findings { list-style: none; padding: 0; margin: 0 0 12px 0; display: flex; flex-direction: column; gap: 8px; }
.promote-finding {
  border: 1px solid var(--nvdge-border);
  border-left-width: 3px;
  border-radius: 4px;
  padding: 10px 12px;
  background: var(--nvdge-surface);
}
.promote-finding.sev-critical { border-left-color: var(--nvdge-danger); }
.promote-finding.sev-high     { border-left-color: var(--nvdge-danger); }
.promote-finding.sev-medium   { border-left-color: var(--nvdge-warning); }
.promote-finding.sev-low      { border-left-color: var(--nvdge-fg-dim); }
.promote-finding-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.promote-finding-id  { font-family: var(--font-mono); font-size: 11px; color: var(--nvdge-fg-dim); }
.promote-finding-sev {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 3px;
}
.promote-finding.sev-critical .promote-finding-sev,
.promote-finding.sev-high     .promote-finding-sev { background: var(--nvdge-danger); color: #fff; }
.promote-finding.sev-medium   .promote-finding-sev { background: var(--nvdge-warning); color: var(--nvdge-bg); }
.promote-finding.sev-low      .promote-finding-sev { background: var(--nvdge-border); color: var(--nvdge-fg-2); }
.promote-finding-title { font-weight: 600; flex: 1 1 200px; }
.promote-finding-loc { margin: 4px 0; font-size: 12px; }
.promote-finding-loc code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--nvdge-surface-2);
  padding: 1px 4px;
  border-radius: 3px;
}
.promote-finding-why    { margin: 4px 0; font-size: 13px; }
.promote-finding-impact { margin: 4px 0; }
.promote-finding-rem    { margin: 6px 0 0 0; font-size: 13px; }
.promote-finding-rem strong { color: var(--nvdge-fg-2); font-weight: 600; }

/* Tool trace inside the streaming view */
/* Always-mounted in the merge modal so transitions from
   "before-stream" to "streaming" don't change HTML and force a
   modal rewrite. :empty hides the unused container so we don't
   render an empty bordered box with no content. */
.promote-trace { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 4px; font-family: var(--font-mono); font-size: 11px; }
.promote-trace:empty { display: none; margin: 0; }
.promote-trace-row { display: flex; align-items: baseline; gap: 8px; }
.promote-trace-prompt { color: var(--nvdge-fg-dim); flex-shrink: 0; }
.promote-trace-tool code { color: var(--nvdge-accent); }
.promote-trace-tool-result.is-error .promote-trace-prompt { color: var(--nvdge-danger); }

/* Streaming text — show pre-formatted while review is in flight.
   :empty hides the box when there's no streamed content yet
   (modal-open before stream starts, or completed-review with no
   raw text). Avoids the modal rewrite that would otherwise mount
   this container at stream-start. */
.promote-stream-text {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--nvdge-surface);
  border: 1px solid var(--nvdge-border);
  border-radius: 4px;
  padding: 10px 12px;
  margin: 8px 0 0 0;
  line-height: 1.55;
  max-height: 360px;
  overflow-y: auto;
}
.promote-stream-text:empty { display: none; margin: 0; padding: 0; border: 0; }

/* Footer + action bar */
.promote-foot {
  border-top: 1px solid var(--nvdge-border);
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--nvdge-sidebar);
}
.promote-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.promote-ack-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ==========================================================================
   Merge modal — Conflict / Non-conflict selection rows (Phase D)
   ========================================================================== */

.merge-changes { list-style: none; padding: 0; margin: 0 0 16px 0; display: flex; flex-direction: column; gap: 6px; }
.merge-change {
  border: 1px solid var(--nvdge-border);
  border-left-width: 3px;
  border-radius: 4px;
  background: var(--nvdge-surface);
  transition: border-color 100ms ease, background 100ms ease;
}
.merge-change.sev-blocking,
.merge-change.sev-high     { border-left-color: var(--nvdge-danger); }
.merge-change.sev-medium   { border-left-color: var(--nvdge-warning); }
.merge-change.sev-coordination { border-left-color: var(--nvdge-fg-dim); }
.merge-change.is-selected  { background: var(--nvdge-surface-2); }

.merge-change-row {
  display: grid;
  /* Single full-width column by default — for the sync findings list,
   * which has no checkbox. The merge modal's selection rows include a
   * checkbox and bump to a 24px+1fr grid via the :has() rule below. */
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 10px 12px;
  align-items: start;
}
/* Two columns + pointer cursor only when the row is actually
 * interactive (i.e., has a selection checkbox — merge modal). Without
 * this, the body lands in the empty 24px column and gets squeezed
 * to a narrow strip while the 1fr column stays blank. */
.merge-change-row:has(input[type="checkbox"]) {
  grid-template-columns: 24px 1fr;
  cursor: pointer;
}
.merge-change-row input[type="checkbox"] {
  margin-top: 4px;
  width: 16px;
  height: 16px;
  accent-color: var(--nvdge-primary);
}
.merge-change-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.merge-change-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.merge-change-id { font-family: var(--font-mono); font-size: 11px; color: var(--nvdge-fg-dim); }
.merge-change-sev {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 3px;
}
.merge-change.sev-blocking .merge-change-sev,
.merge-change.sev-high     .merge-change-sev { background: var(--nvdge-danger); color: #fff; }
.merge-change.sev-medium   .merge-change-sev { background: var(--nvdge-warning); color: var(--nvdge-bg); }
.merge-change.sev-coordination .merge-change-sev { background: var(--nvdge-border); color: var(--nvdge-fg-2); }
.merge-change-file {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--nvdge-fg);
  word-break: break-all;
}

/* Pre-emptive textual-conflict tag — shows when staging modified
   the file since fork. Distinct from the agent's severity badge
   (which speaks to semantic conflict). */
.merge-change-conflict-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--nvdge-danger);
  color: #fff;
}
.merge-change.has-textual-conflict {
  border-left-color: var(--nvdge-danger);
}
.merge-change-detail {
  display: block; /* span by default → inline; need block so long text
                   * fills the row's full width instead of wrapping
                   * into a column-sized blob. */
  font-size: 12px;
  color: var(--nvdge-fg);
}

/* Sync conflict resolver — disclosure chevron + expandable details
 * panel for each conflict row. Default: row collapsed, chevron right.
 * Expanded: chevron points down, details panel renders below the
 * row's button strip. */
.merge-change-disclosure {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--nvdge-fg-dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
}
.merge-change-disclosure:hover { color: var(--nvdge-fg); background: var(--nvdge-surface-2); }
.merge-change-disclosure:focus-visible { outline: 2px solid var(--nvdge-primary); outline-offset: 1px; }
.merge-change-disclosure svg { width: 10px; height: 10px; }
/* Reserves the same horizontal slot as the disclosure button so file
 * paths line up between rows that have details and rows that don't. */
.merge-change-disclosure-spacer {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  display: inline-block;
}

/* Per-conflict expandable details — sits below the button strip.
 * Indented to align under the file path (skipping the disclosure
 * column) so the eye reads "this file's details" rather than "page
 * heading." */
.merge-change-details {
  padding: 8px 12px 4px 38px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-top: 1px dashed var(--nvdge-border);
  margin-top: 6px;
  background: var(--nvdge-surface);
}

/* Star badge on "Use agent's" when the agent has staged a patch but
 * the user hasn't picked it yet — soft hint that there's a
 * recommendation here. Disappears once selected (the selected-state
 * styling already conveys "you picked this"). */
.merge-change-recommended-badge {
  display: inline-block;
  margin-left: 4px;
  font-size: 10px;
  color: var(--nvdge-warning);
  line-height: 1;
}
.merge-change-detail strong { color: var(--nvdge-fg-2); font-weight: 600; }
.merge-change-rationale, .merge-change-coupling {
  display: block;
}

/* Merge-conflict list (Phase F) — surfaced in the merge modal when
   /merge returns 409 merge_conflicts. Compact list of file paths
   with one-line reasons. The action bar swaps to "Send to coding
   agent" when this is visible. */
.merge-conflicts {
  list-style: none;
  padding: 0;
  margin: 8px 0 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.merge-conflict {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 10px;
  background: var(--nvdge-danger-bg);
  border-left: 3px solid var(--nvdge-danger);
  border-radius: 3px;
}
.merge-conflict-path { font-family: var(--font-mono); font-size: 12px; word-break: break-all; }
.merge-conflict-reason { flex: 1 1 auto; }

/* Textual merge-conflict list inside the merge modal — surfaced
   when /merge returns 409 merge_conflicts. */
.merge-conflicts {
  list-style: none;
  padding: 0;
  margin: 12px 0 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.merge-conflict {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 8px 10px;
  background: var(--nvdge-surface);
  border: 1px solid var(--nvdge-border);
  border-left: 3px solid var(--nvdge-danger);
  border-radius: 3px;
  align-items: baseline;
}
.merge-conflict-path {
  font-family: var(--font-mono);
  font-size: 12px;
  word-break: break-all;
}

/* ==========================================================================
   Security-handoff message (in coding chat)
   ========================================================================== */

.trace-row.trace-handoff .trace-content { width: 100%; }
.handoff-card {
  border: 1px solid var(--nvdge-border);
  border-left-width: 3px;
  border-radius: 4px;
  padding: 10px 12px;
  background: var(--nvdge-surface);
  margin: 4px 0;
}
.handoff-card.is-block { border-left-color: var(--nvdge-danger); }
.handoff-card.is-ack   { border-left-color: var(--nvdge-warning); }
.handoff-card.is-allow { border-left-color: var(--nvdge-success); }
.handoff-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.handoff-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(0,0,0,0.3);
  color: var(--nvdge-fg);
}
.handoff-card.is-block .handoff-tag { background: var(--nvdge-danger); color: #fff; }
.handoff-card.is-ack   .handoff-tag { background: var(--nvdge-warning); color: var(--nvdge-bg); }
.handoff-card.is-allow .handoff-tag { background: var(--nvdge-success); color: #fff; }
.handoff-summary { font-size: 13px; flex: 1 1 200px; }
.handoff-findings { list-style: none; padding: 0; margin: 6px 0; display: flex; flex-direction: column; gap: 4px; }
.handoff-finding {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 12px;
  flex-wrap: wrap;
}
.handoff-finding-id  { font-family: var(--font-mono); font-size: 11px; color: var(--nvdge-fg-dim); min-width: 48px; }
.handoff-finding-sev {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 3px;
}
.handoff-finding.sev-critical .handoff-finding-sev,
.handoff-finding.sev-high     .handoff-finding-sev { background: var(--nvdge-danger); color: #fff; }
.handoff-finding.sev-medium   .handoff-finding-sev { background: var(--nvdge-warning); color: var(--nvdge-bg); }
.handoff-finding.sev-low      .handoff-finding-sev { background: var(--nvdge-border); color: var(--nvdge-fg-2); }
.handoff-finding-title { flex: 1 1 200px; }
.handoff-finding-loc { font-family: var(--font-mono); font-size: 11px; color: var(--nvdge-fg-2); }
.handoff-foot { margin: 6px 0 0 0; }
