/* Demo Builder — three-pane view styling.
 *
 * Theme-matched to the rest of salesbot (dark green palette defined in
 * /styles.css). The published demo itself renders inside the preview
 * iframe with its own styles, so the iframe is the only bright surface
 * — everything around it matches the app chrome.
 */

/* Bulletproof ``[hidden]`` — several of the elements below use
 * ``display: flex`` which has higher specificity than the user-agent
 * rule ``[hidden] { display: none }``. JS toggles ``el.hidden = true``
 * expecting elements to vanish; without this !important rule the empty
 * state and the iframe end up stacked on top of each other.
 */
.main-view-demobuilder [hidden] { display: none !important; }
.db-modal[hidden] { display: none !important; }

.main-view-demobuilder {
  display: grid;
  grid-template-columns: 300px 1fr;       /* 2-col default — no preview */
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  overflow: hidden;
}
.main-view-demobuilder.is-preview-open {
  grid-template-columns: 300px minmax(360px, 1fr) minmax(420px, 1.4fr);
}

/* ── History pane ─────────────────────────────────────────────────── */

.db-history-pane {
  border-right: 1px solid var(--border);
  padding: 18px 16px;
  overflow-y: auto;
  background: var(--sidebar-bg);
}
.db-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 8px;
}
.db-history-title {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  margin: 0;
  color: var(--text-secondary);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.db-new-demo-icon {
  width: 26px;
  height: 26px;
  border-radius: var(--r-xs);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.db-new-demo-icon:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.db-background-builds-badge {
  margin-left: auto;
  padding: 3px 9px;
  border-radius: var(--r-full);
  background: var(--gold-dim);
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  animation: db-pulse 1.4s ease-in-out infinite;
}
.db-history-filters {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}
.db-history-filters button {
  background: transparent;
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.db-history-filters button:hover {
  background: var(--surface);
  color: var(--text);
}
.db-history-filters button.is-active {
  background: var(--accent);
  color: var(--on-accent);
  border-color: transparent;
  box-shadow: var(--glow-accent);
}
.db-history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.db-history-row {
  position: relative;
  padding: 9px 12px 11px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease);
  background: transparent;
  color: var(--text);
}
.db-history-row:hover {
  background: var(--surface-hover);
  border-color: var(--border);
}
.db-history-row.is-active {
  background: var(--surface-hover);
  border-color: var(--accent-soft);
  box-shadow: inset 2px 0 0 var(--accent);
}
.db-row-main {
  display: flex;
  align-items: center;
  gap: 8px;
}
.db-row-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--border);
}
.db-dot-ready    { background: var(--accent); box-shadow: 0 0 6px var(--accent-soft); }
.db-dot-building { background: var(--gold); animation: db-pulse 1.4s ease-in-out infinite; }
.db-dot-failed   { background: var(--danger); }
.db-dot-interrupted { background: var(--gold); animation: db-pulse 2.2s ease-in-out infinite; }
.db-dot-partial     { background: var(--gold); animation: db-pulse 2.2s ease-in-out infinite; }
.db-dot-awaiting_review { background: var(--gold); animation: db-pulse 2.2s ease-in-out infinite; }
.db-dot-cancelled { background: var(--muted); }
@keyframes db-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* Chat-only history rows — a thread with no backing demo yet.
 * Subtler than demo rows: muted chat-bubble glyph instead of a
 * coloured status dot, so the SE can tell at a glance "this is a
 * chat in progress, not a built demo." */
.db-history-row.is-chat-only .db-row-title {
  color: var(--text-secondary);
}
.db-history-row.is-chat-only.is-active .db-row-title {
  color: var(--text);
}
.db-row-chat-glyph {
  width: 14px;
  text-align: center;
  font-size: 11px;
  line-height: 1;
  flex-shrink: 0;
  color: var(--text-secondary);
  opacity: 0.75;
}
.db-history-row.is-chat-only:hover .db-row-chat-glyph {
  opacity: 1;
}
.db-row-chip-muted {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-soft);
}
.db-row-title {
  flex: 1;
  font-weight: 500;
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 3-dot menu button on each row. Like Recents in salesbot main. */
.db-row-menu {
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1;
  width: 24px;
  height: 24px;
  border-radius: var(--r-xs);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.db-history-row:hover .db-row-menu,
.db-row-menu[aria-expanded="true"] {
  opacity: 1;
}
.db-row-menu:hover {
  background: var(--surface);
  color: var(--text);
}

/* Popup menu — body-anchored absolute positioning, like the
 * salesbot Recents row menu in your screenshot. */
.db-row-menu-popup {
  position: fixed;
  z-index: 1100;
  min-width: 180px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 4px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 1px;
  animation: db-fadeIn var(--dur-fast) var(--ease);
}
.db-row-menu-popup button {
  background: transparent;
  border: 0;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  padding: 8px 12px;
  border-radius: var(--r-xs);
  cursor: pointer;
  width: 100%;
  display: block;
  transition: background var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease);
}
.db-row-menu-popup button:hover {
  background: var(--surface-hover);
}
.db-row-menu-popup button.is-danger {
  color: var(--danger);
}
.db-row-menu-popup button.is-danger:hover {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  color: var(--danger);
}
/* Disabled menu items render half-bright, sit dead to clicks, but the
 * row stays in flow so the menu shape is stable as features come
 * online. Pair this with the inline ``aria-disabled`` + ``disabled``
 * attrs on the button so assistive tech reads the state correctly. */
.db-row-menu-popup button.is-disabled,
.db-row-menu-popup button[disabled] {
  color: var(--text-secondary);
  cursor: not-allowed;
  opacity: 0.55;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.db-row-menu-popup button.is-disabled:hover,
.db-row-menu-popup button[disabled]:hover {
  background: transparent;     /* no hover flash on disabled items */
}
/* "Coming soon" pill — small amber/yellow badge next to a feature
 * we're gating off the SE-facing surface area until it's polished
 * enough for them. The yellow signals "this exists, just not yet"
 * vs. red/danger ("don't touch this") or green ("ready"). */
.db-row-menu-pill {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 999px;
  white-space: nowrap;
}
.db-row-menu-pill-soon {
  background: var(--gold-dim);
  color: var(--gold);
  border: 1px solid color-mix(in srgb, var(--gold) 40%, transparent);
}
.db-row-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 6px 0 0 15px;     /* line up under the title (dot is 7px + 8px gap) */
}
/* Inferred sales intent label on a demo row (Phase 1 infer-and-confirm).
   Only rendered for specific (non-general) intents to avoid clutter. */
.db-row-intent {
  margin: 5px 0 0 15px;
  font-family: var(--font-mono, inherit);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent, #16a34a);
}
.db-row-chip {
  font-size: 10px;
  padding: 1px 7px;
  border-radius: var(--r-xs);
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-soft);
}
.db-row-time {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 10px;
  letter-spacing: 0.01em;
  color: var(--muted);
  margin: 4px 0 0 15px;
}
.db-row-owner {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-secondary);
  margin: 5px 0 0 15px;     /* line up under the title, same as topics/time */
}
.db-row-owner-glyph {
  font-size: 10px;
  opacity: 0.7;
}
.db-empty {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 24px;
  text-align: center;
}

/* ── Composer pane ─────────────────────────────────────────────────── */

.db-composer-pane {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-soft);
  background: var(--bg);
  min-height: 0;
  position: relative;
}

/* ── Composer toolbar (replaces the floating "Show preview" button) ──
 *
 * The toolbar is PINNED at the top of the composer column (``position:
 * sticky; top: 0;``) with a high ``z-index`` so it stays visible under any
 * vertical pressure or scroll context. Without sticky positioning, when
 * the build-progress panel inserts itself below (also full-width, also
 * elevated background) the eye reads the two stacked bars as a single
 * task bar — and if the toolbar's right side ever became empty (e.g. the
 * Preview button hidden), users perceived the toolbar as "disappearing".
 * Sticky + a guaranteed-visible action on the right side cures both.
 */
.db-composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  min-height: 40px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  background-image: var(--grad-sheen);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 11;
}
.db-composer-toolbar-left {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}
.db-composer-toolbar-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.02em;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.db-composer-toolbar-sub {
  font-size: 10.5px;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.db-composer-toolbar-sub:empty { display: none; }
/* "What this demo is for" intent chip (Phase 1 infer-and-confirm). A small
   pill-styled native select so the SE can confirm/override at a glance. */
.db-intent-chip {
  margin-top: 3px;
  align-self: flex-start;
  max-width: 220px;
  font-family: var(--font-mono, inherit);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: var(--accent, #16a34a);
  background: var(--accent-soft, rgba(22,163,74,0.08));
  border: 1px solid color-mix(in srgb, var(--accent, #16a34a) 30%, transparent);
  border-radius: 999px;
  padding: 2px 8px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.db-intent-chip:hover {
  border-color: color-mix(in srgb, var(--accent, #16a34a) 55%, transparent);
}
.db-intent-chip:focus-visible {
  outline: 2px solid var(--accent, #16a34a);
  outline-offset: 1px;
}
.db-composer-toolbar-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Preview button is a TOGGLE — visible in both states so the toolbar's
 * right side is never empty. The two labels are rendered inside the
 * button and swapped via the parent ``.is-preview-open`` class. JS just
 * delegates open / close based on the same class. */
#db-composer-show-preview .db-toolbar-btn-label-hide { display: none; }
.main-view-demobuilder.is-preview-open #db-composer-show-preview .db-toolbar-btn-label-show {
  display: none;
}
.main-view-demobuilder.is-preview-open #db-composer-show-preview .db-toolbar-btn-label-hide {
  display: inline;
}

/* Generic toolbar button — used in composer toolbar AND preview header
 * actions row. Tighter than the global .btn so the row of 7 actions
 * doesn't wrap on a 1440 monitor. */
.db-toolbar-btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  font-size: 11.5px;
  font-weight: 500;
  padding: 5px 11px;
  line-height: 1.4;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  white-space: nowrap;
}
.db-toolbar-btn:hover {
  background: var(--surface-hover);
  border-color: var(--muted);
  color: var(--text);
}
.db-toolbar-btn:active { transform: translateY(0.5px); }
.db-toolbar-btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.db-toolbar-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.db-toolbar-btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
  font-weight: 600;
  box-shadow: var(--glow-accent);
}
.db-toolbar-btn-primary:hover {
  background: var(--accent);
  filter: brightness(1.1);
  color: var(--on-accent);
}
/* Destructive variant — used for Rebuild because it overwrites
 * already-rendered sections. Red border + text, fills on hover. */
.db-toolbar-btn-danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
}
.db-toolbar-btn-danger:hover {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 70%, transparent);
}
/* Icon-only toolbar variant — narrower so the SVG sits in a square. */
.db-toolbar-btn-icon {
  padding: 5px 8px;
  width: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.db-toolbar-btn-icon svg {
  display: block;
  color: var(--text-secondary);
  transition: color 0.12s;
}
.db-toolbar-btn-icon:hover svg { color: var(--text); }
.db-toolbar-icon {
  font-size: 11px;
  opacity: 0.7;
  line-height: 1;
}
/* ── Welcome panel (replaces the old single-line empty state) ──── */

/* ════════════════════════════════════════════════════════════════════
   Welcome — the Demo Builder's first impression. "Bold dark console":
   aurora-lit canvas, oversized display headline, a connected build
   pipeline, and premium starter cards. (2026 flagship redesign.)
   ════════════════════════════════════════════════════════════════════ */
.db-composer-welcome {
  position: relative;
  flex: 1 1 auto;
  overflow-y: auto;
  padding: clamp(40px, 6vh, 86px) clamp(28px, 6vw, 92px) 76px;
  background: var(--bg);
  isolation: isolate;
}
/* Atmosphere — green aurora glow + fading dot grid behind the hero */
.db-welcome-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.db-welcome-bg::before {
  content: "";
  position: absolute;
  top: -24%;
  left: 50%;
  width: min(1180px, 120%);
  height: 760px;
  transform: translateX(-50%);
  background:
    radial-gradient(58% 58% at 50% 40%, rgba(0, 237, 100, 0.17), transparent 70%),
    radial-gradient(42% 52% at 20% 26%, rgba(0, 168, 107, 0.13), transparent 72%);
  filter: blur(6px);
}
.db-welcome-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1.4px);
  background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(120% 72% at 50% 0%, #000 32%, transparent 78%);
  mask-image: radial-gradient(120% 72% at 50% 0%, #000 32%, transparent 78%);
}
.db-welcome-inner {
  position: relative;
  z-index: 1;
  max-width: 1040px;
  margin: 0 auto;
  color: var(--text);
}

/* Entrance choreography */
@keyframes dbRise {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: none; }
}
.db-welcome-hero,
.db-welcome-grid,
.db-welcome-inner > .db-welcome-section {
  animation: dbRise var(--dur-slow) var(--ease-out) both;
}
.db-welcome-hero { animation-delay: 40ms; }
.db-welcome-grid { animation-delay: 150ms; }
.db-welcome-inner > .db-welcome-section { animation-delay: 250ms; }

/* Hero */
.db-welcome-hero {
  margin-bottom: clamp(34px, 5vh, 56px);
  max-width: 900px;
}
.db-welcome-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  padding: 5px 12px 5px 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: var(--r-full);
  background: var(--accent-soft);
  margin-bottom: 22px;
}
.db-welcome-eyebrow-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: dbPulse 2.4s var(--ease) infinite;
}
@keyframes dbPulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 237, 100, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(0, 237, 100, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 237, 100, 0); }
}
.db-welcome-title {
  font-family: var(--font-display);
  font-size: clamp(34px, 4.4vw, 58px);
  line-height: 1.04;
  letter-spacing: -0.035em;
  font-weight: 700;
  margin: 0 0 20px;
  color: var(--text);
  text-wrap: balance;
}
.db-welcome-title em {
  font-style: normal;
  background: linear-gradient(100deg, var(--accent), var(--green-bright));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.db-welcome-lede {
  font-size: clamp(15px, 1.25vw, 17px);
  line-height: 1.62;
  color: var(--text-secondary);
  margin: 0 0 22px;
  max-width: 60ch;
}
/* "Need it now?" — slimmed to a single refined inline line */
.db-welcome-shortcut {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
}
.db-welcome-shortcut-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin: 0;
}
.db-welcome-shortcut-lede {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.db-welcome-shortcut-fineprint { display: none; }
.db-welcome-shortcut-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur) var(--ease);
}
.db-welcome-shortcut-link:hover { border-bottom-color: var(--accent); }

/* The 4 steps, re-cast as a connected build PIPELINE (signature motif) */
.db-welcome-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 0 0 clamp(34px, 5vh, 52px);
}
@media (max-width: 1080px) { .db-welcome-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .db-welcome-grid { grid-template-columns: 1fr; } }
.db-welcome-card {
  position: relative;
  padding: 20px 16px 18px;
  background: var(--grad-sheen), linear-gradient(180deg, var(--surface), var(--bg-elevated));
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: transform var(--dur) var(--ease),
    border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.db-welcome-card::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent,
    color-mix(in srgb, var(--accent) 50%, transparent), transparent);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.db-welcome-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 32%, var(--border));
  box-shadow: var(--shadow-lg);
}
.db-welcome-card:hover::after { opacity: 1; }
/* connector chevrons between consecutive nodes (desktop row only) */
.db-welcome-card + .db-welcome-card::before {
  content: "";
  position: absolute;
  left: -11px;
  top: 31px;
  width: 8px;
  height: 8px;
  border-top: 1.5px solid var(--muted);
  border-right: 1.5px solid var(--muted);
  transform: rotate(45deg);
  opacity: 0.6;
}
@media (max-width: 1080px) { .db-welcome-card + .db-welcome-card::before { display: none; } }
.db-welcome-step {
  position: static;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%,
    color-mix(in srgb, var(--accent) 32%, transparent), var(--accent-soft));
  border: 1px solid color-mix(in srgb, var(--accent) 42%, transparent);
  box-shadow: 0 0 20px -4px rgba(0, 237, 100, 0.45);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 14px;
}
.db-welcome-card h3 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}
.db-welcome-card p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-secondary);
}

/* Sections + subheads */
.db-welcome-section { margin-bottom: 30px; }
.db-welcome-subhead {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.db-welcome-subhead::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
}
.db-welcome-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-secondary);
}
.db-welcome-list code,
.db-welcome-card code,
.db-welcome-lede code {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  padding: 1px 5px;
  border-radius: var(--r-xs);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
}

/* Example starter cards — inviting, with monogram + arrow affordance.
   NOTE: the button's textContent must stay = the prompt (JS drops it
   into the chat verbatim), so the monogram comes from data-mono via a
   pseudo-element and the arrow is a pseudo-element too — neither is in
   the DOM text. */
.db-welcome-examples {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 760px) { .db-welcome-examples { grid-template-columns: 1fr; } }
.db-welcome-example {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 11px;
  text-align: left;
  background: linear-gradient(180deg, var(--surface), var(--bg-elevated));
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 16px 42px 16px 16px;
  border-radius: var(--r-lg);
  font-size: 13px;
  line-height: 1.5;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease),
    border-color var(--dur) var(--ease), color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}
.db-welcome-example::before {
  content: attr(data-mono);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.db-welcome-example::after {
  content: "→";
  position: absolute;
  right: 16px;
  top: 17px;
  color: var(--muted);
  font-size: 15px;
  transition: transform var(--dur) var(--ease), color var(--dur) var(--ease);
}
.db-welcome-example:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  color: var(--text);
  box-shadow: var(--shadow-md), var(--glow-accent);
}
.db-welcome-example:hover::after {
  transform: translateX(3px);
  color: var(--accent);
}
.db-welcome-hint {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

@media (prefers-reduced-motion: reduce) {
  .db-welcome-hero,
  .db-welcome-grid,
  .db-welcome-inner > .db-welcome-section { animation: none; }
  .db-welcome-eyebrow-dot { animation: none; }
}

.db-chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;   /* fills remaining height when welcome is [hidden] */
}
/* When the welcome panel takes the upper section, the messages list
 * collapses entirely so the chat shrinks to just the textarea + Send.
 * The welcome panel itself is the scrollable surface in that mode. */
.db-chat-messages.is-hidden-when-welcome { display: none; }
.db-composer-welcome { flex: 1 1 auto; min-height: 0; }
.db-chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  position: relative;
  isolation: isolate;
}
/* Atmosphere — a faint accent wash bleeds down from the top of the
 * thread so the conversation sits on a lit canvas, not a flat panel.
 * Pinned, non-scrolling, behind the bubbles. */
.db-chat-messages::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 220px;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(90% 140% at 50% -30%, rgba(0, 237, 100, 0.07), transparent 70%);
}
.db-msg {
  padding: 11px 15px;
  border-radius: var(--r-md);
  max-width: 86%;
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 13px;
  position: relative;
  animation: dbMsgIn var(--dur) var(--ease-out) both;
}
@keyframes dbMsgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
/* User — confident accent bubble with depth + a subtle gradient so the
 * green reads as a lit surface, not a flat fill. */
.db-msg-user {
  align-self: flex-end;
  background: linear-gradient(165deg, var(--green-bright), var(--accent) 55%, var(--green-dark));
  color: var(--on-accent);
  font-weight: 500;
  border-bottom-right-radius: var(--r-xs);
  box-shadow: var(--shadow-md),
    0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.db-msg-user a { color: var(--on-accent); text-decoration: underline; }
/* Assistant — elevated card: hairline border, layered shadow, top sheen. */
.db-msg-assistant {
  align-self: flex-start;
  background: var(--grad-sheen),
    linear-gradient(180deg, var(--surface), var(--bg-elevated));
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: var(--r-xs);
  box-shadow: var(--shadow-md);
}
.db-msg-assistant p { margin: 0 0 8px; }
.db-msg-assistant p:last-child { margin-bottom: 0; }
.db-msg-assistant ul, .db-msg-assistant ol { margin: 4px 0 8px; padding-left: 22px; }
.db-msg-assistant li { margin: 2px 0; }
.db-msg-assistant code {
  background: var(--surface-hover);
  border: 1px solid var(--border-soft);
  padding: 1px 5px;
  border-radius: var(--r-xs);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
}
.db-msg-assistant pre {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  padding: 10px 12px;
  border-radius: var(--r-sm);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  line-height: 1.55;
  margin: 8px 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
.db-msg-assistant pre code { background: transparent; border: 0; padding: 0; color: #cfeadc; }
.db-msg-assistant a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  transition: border-color var(--dur-fast) var(--ease);
}
.db-msg-assistant a:hover { border-bottom-color: var(--accent); }
.db-msg-assistant h1, .db-msg-assistant h2, .db-msg-assistant h3 {
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: -0.015em;
  margin: 12px 0 5px;
  font-weight: 600;
  color: var(--text);
}
.db-msg-assistant hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 10px 0;
}
.db-msg-status {
  align-self: flex-start;
  background: transparent;
  color: var(--text-secondary);
  font-style: italic;
  font-size: 12px;
  padding: 3px 14px 3px 22px;
  max-width: 100%;
  position: relative;
}
/* Pulsing accent dot — signals "the agent is working" without markup. */
.db-msg-status::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: db-pulse 1.4s ease-in-out infinite;
}
/* Sender attribution for collaborator messages (real-time collab). */
.db-msg-sender {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.85;
  margin-bottom: 4px;
  color: var(--accent);
}
.db-msg-user .db-msg-sender { color: var(--on-accent); opacity: 0.7; }
/* Presence bar: who else is in this shared demo's chat room. */
.db-presence {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 18px;
  font-size: 12px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, var(--bg-elevated), transparent);
}
.db-presence[hidden] { display: none; }
.db-presence-avatars { display: inline-flex; }
.db-presence-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-left: -6px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, var(--green-bright), var(--accent));
  color: var(--on-accent);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  border: 2px solid var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}
.db-presence-avatar:first-child { margin-left: 0; }
.db-presence-avatar.is-typing {
  box-shadow: 0 0 0 2px var(--bg-elevated), 0 0 0 4px var(--accent), var(--glow-accent);
  animation: db-pulse 1.6s ease-in-out infinite;
}
.db-presence-label { font-style: italic; color: var(--text-secondary); }

@media (prefers-reduced-motion: reduce) {
  .db-msg { animation: none; }
  .db-msg-status::before,
  .db-presence-avatar.is-typing { animation: none; }
}
.db-chat-form {
  display: flex;
  gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--border);
  background:
    var(--grad-sheen),
    linear-gradient(180deg, var(--bg-elevated), var(--bg));
}
.db-chat-form textarea {
  flex: 1;
  min-height: 46px;
  max-height: 200px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 11px 13px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  background:
    var(--grad-sheen),
    linear-gradient(180deg, var(--surface), var(--bg-elevated));
  color: var(--text);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.02);
  transition: border-color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
}
.db-chat-form textarea::placeholder {
  color: var(--muted);
}
.db-chat-form textarea:hover {
  border-color: var(--muted);
}
.db-chat-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring), var(--shadow-sm);
}
/* Disabled composer — while a build is mid-flight, the form dims and
 * sits dead to input. JS sets `disabled` on the textarea and toggles
 * `.is-disabled` on the form. */
.db-chat-form.is-disabled,
.db-chat-form textarea:disabled,
.db-chat-form textarea.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.db-chat-form textarea:disabled { resize: none; }

/* Composer actions row — sits to the right of the textarea, holds the
 * paperclip + Send buttons stacked vertically when the form is narrow,
 * or side-by-side at the default width. The paperclip is intentionally
 * subdued; the green Send button is the primary action. */
.db-chat-form-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.db-chat-attach-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 16px;
  width: 42px;
  height: 42px;
  border-radius: var(--r-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: background var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}
.db-chat-attach-btn:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}
.db-chat-attach-btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

/* Chip row showing files the SE has staged for the next turn. Sits
 * between the form and the chat-messages area so it's the last thing
 * before Send. Chips are clickable on the × to remove. */
.db-composer-attach-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px dashed var(--border-soft);
  background: var(--bg-elevated);
}
/* "Rendering with: <model>" pill — always visible, sits directly
 * above the chat textarea so the SE knows what model is producing
 * the current demo while typing the next message. Distinct from the
 * toolbar's model badge (also visible up top); having it in two
 * places is intentional — the SE asked for it to be in the chat. */
.db-chat-model-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-soft);
}
.db-chat-model-label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--text-tertiary, var(--text-secondary));
  opacity: 0.85;
}
.db-chat-model-value {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 600;
  padding: 1px 8px;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: var(--r-full);
  background: var(--accent-soft);
}
/* Slight visual cue when we're showing the default model (no demo
 * choice latched yet) — same shape so the SE reads "model: x" the
 * same way, but the chip border + label go dimmer to make clear it's
 * the *will-use* default, not a chosen-for-this-demo selection. */
.db-chat-model-footer.is-fallback .db-chat-model-value {
  color: var(--text-secondary);
  border-color: var(--border-soft);
  background: transparent;
}
.db-chat-model-footer.is-fallback .db-chat-model-label::after {
  content: " (until first build)";
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  opacity: 0.7;
  margin-left: 2px;
}
.db-composer-attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--text);
  max-width: 320px;
}
.db-composer-attach-chip-icon {
  font-size: 13px;
  line-height: 1;
}
.db-composer-attach-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.db-composer-attach-chip-x {
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  margin-left: 2px;
  border-radius: 4px;
}
.db-composer-attach-chip-x:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}
/* ── Build progress banner ─────────────────────────────────────
 *
 * Compact build banner that sits at the TOP of the composer pane
 * (above the welcome / chat). Single source of build status:
 * coloured state-pill (amber building / green done / red failed),
 * one-line title + counter, thin progress bar, click-to-expand
 * detail with the stage list and log.
 *
 * Position: inserted right after the composer toolbar so it spans
 * the full composer column and is always visible regardless of
 * whether the SE has scrolled the chat or is looking at the
 * welcome panel.
 *
 * Colour is driven by ONE local CSS var (``--db-prog`` + soft
 * variant). State classes (``.is-building`` / ``.is-done`` /
 * ``.is-failed`` / ``.is-cancelled``) swap the var; everything
 * else reads it.
 */
/* Sticky stack wrapper that hosts one ``.db-progress-panel`` per
 * in-flight build. Multiple parallel builds slot in here as
 * siblings and stack vertically — the wrapper itself is what
 * sticks just below the composer toolbar so the panels don't fight
 * each other for the same ``top: 40px`` slot. */
.db-progress-stack {
  position: sticky;
  top: 40px;                                /* matches toolbar min-height */
  z-index: 10;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.db-progress-stack .db-progress-panel + .db-progress-panel {
  margin-top: 1px;
}

.db-progress-panel {
  /* accent/amber default (building) — accent drives the animated state */
  --db-prog: var(--accent);
  --db-prog-soft: var(--accent-soft);
  --db-prog-bg: color-mix(in srgb, var(--accent) 7%, transparent);

  position: relative;
  margin: 0 0 1px;
  padding: 11px 16px;
  background: var(--db-prog-bg);
  border-bottom: 1px solid var(--db-prog-soft);
  font-size: 12px;
  flex-shrink: 0;
  overflow: hidden;
  transition: background var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
}
.db-progress-panel.is-building {
  /* live build — sharp accent green, animated shimmer */
  --db-prog: var(--accent);
  --db-prog-soft: var(--accent-soft);
  --db-prog-bg: color-mix(in srgb, var(--accent) 7%, transparent);
}
.db-progress-panel.is-done {
  --db-prog: var(--leaf);
  --db-prog-soft: var(--leaf-dim);
  --db-prog-bg: color-mix(in srgb, var(--leaf) 7%, transparent);
}
.db-progress-panel.is-failed {
  --db-prog: var(--danger);
  --db-prog-soft: color-mix(in srgb, var(--danger) 25%, transparent);
  --db-prog-bg: color-mix(in srgb, var(--danger) 7%, transparent);
}
.db-progress-panel.is-cancelled {
  /* cancelled is a calm, muted terminal state — distinct from failure */
  --db-prog: var(--muted);
  --db-prog-soft: color-mix(in srgb, var(--muted) 25%, transparent);
  --db-prog-bg: color-mix(in srgb, var(--muted) 8%, transparent);
}
/* Indeterminate shimmer accent — only visible while building. */
.db-progress-panel::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg,
    transparent, var(--db-prog), transparent);
  background-size: 50% 100%;
  background-repeat: no-repeat;
  animation: db-prog-shimmer 1.8s linear infinite;
  pointer-events: none;
  opacity: 1;
}
.db-progress-panel.is-done::before,
.db-progress-panel.is-failed::before,
.db-progress-panel.is-cancelled::before {
  animation: none;
  background: var(--db-prog);
}
@keyframes db-prog-shimmer {
  0%   { background-position: -50% 0; }
  100% { background-position: 150% 0; }
}
.db-progress-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
/* Status icon — animated ring while building, ✓ when done, ✗ on
 * failure / cancellation. Single element, glyph swapped via ::after
 * + state classes. */
.db-progress-status-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  border: 2px solid var(--db-prog-soft);
  border-top-color: var(--db-prog);
  animation: db-spin 0.9s linear infinite;
  box-sizing: border-box;
}
.db-progress-panel.is-done .db-progress-status-icon,
.db-progress-panel.is-failed .db-progress-status-icon,
.db-progress-panel.is-cancelled .db-progress-status-icon {
  animation: none;
  border: 0;
  background: var(--db-prog);
}
.db-progress-panel.is-done .db-progress-status-icon::after,
.db-progress-panel.is-failed .db-progress-status-icon::after,
.db-progress-panel.is-cancelled .db-progress-status-icon::after {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
.db-progress-panel.is-done .db-progress-status-icon::after { content: "✓"; }
.db-progress-panel.is-failed .db-progress-status-icon::after,
.db-progress-panel.is-cancelled .db-progress-status-icon::after { content: "✕"; }
@keyframes db-spin { to { transform: rotate(360deg); } }

.db-progress-title {
  flex: 1;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text);
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease);
}
.db-progress-title:hover {
  color: var(--db-prog);
}
.db-progress-counter {
  color: var(--db-prog);
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  flex-shrink: 0;
}
.db-progress-stop {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  padding: 3px 12px;
  border-radius: var(--r-xs);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.db-progress-stop:hover {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 50%, transparent);
}
.db-progress-stop:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.db-progress-stop[hidden] { display: none; }

.db-progress-dismiss {
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.12s;
}
.db-progress-dismiss:hover { color: var(--text); }
.db-progress-dismiss[hidden] { display: none; }

.db-progress-bar {
  margin-top: 8px;
  height: 3px;
  background: var(--surface-hover);
  border-radius: var(--r-full);
  overflow: hidden;
}
.db-progress-bar-fill {
  height: 100%;
  background: var(--db-prog);
  box-shadow: 0 0 8px var(--db-prog-soft);
  width: 0%;
  transition: width var(--dur-slow) var(--ease), background var(--dur) var(--ease);
}

/* Expand/details: chevron rotates, body collapses with max-height
 * transition so the click feels responsive even when the log is
 * still empty early in a build. */
.db-progress-expand {
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  padding: 2px 6px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.db-progress-expand:hover { color: var(--text); }
.db-progress-expand-chevron {
  font-size: 10px;
  transition: transform 0.18s ease;
  display: inline-block;
}
.db-progress-panel.is-expanded .db-progress-expand-chevron {
  transform: rotate(180deg);
}
.db-progress-detail {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.22s ease;
}
.db-progress-panel.is-expanded .db-progress-detail {
  max-height: 220px;
}

.db-progress-steps {
  list-style: none;
  margin: 10px 0 8px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 16px;
}
.db-progress-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
}
.db-progress-step-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  transition: background 0.2s ease;
}
.db-progress-step.is-active .db-progress-step-dot {
  background: var(--db-prog);
  box-shadow: 0 0 0 3px var(--db-prog-soft);
  animation: db-pulse 1.4s ease-in-out infinite;
}
.db-progress-step.is-active .db-progress-step-label {
  color: var(--text);
  font-weight: 500;
}
.db-progress-step.is-done .db-progress-step-dot {
  background: var(--db-prog);
  opacity: 0.55;
}
.db-progress-step.is-done .db-progress-step-label {
  color: var(--text-secondary);
}

.db-progress-log {
  max-height: 100px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--text-secondary);
  padding: 8px 10px;
  background: var(--bg);
  border-radius: var(--r-xs);
  border: 1px solid var(--border-soft);
}
.db-progress-log:empty::before {
  content: "(waiting for first build event…)";
  opacity: 0.5;
  font-style: italic;
}
.db-progress-log-row {
  padding: 1px 0;
  line-height: 1.5;
}
/* Live terminal caret on the most recent log line while building — the
 * small "this is streaming right now" deploy-console cue. */
.db-progress-panel.is-building .db-progress-log-row:last-child::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 1.02em;
  margin-left: 5px;
  vertical-align: text-bottom;
  background: var(--db-prog);
  box-shadow: 0 0 8px -1px var(--db-prog);
  animation: db-caret 1.1s steps(1) infinite;
}
@keyframes db-caret {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .db-progress-panel.is-building .db-progress-log-row:last-child::after { animation: none; }
}

/* ── Post-build "Edit a section?" card ─────────────────────────
 *
 * Shows in the chat right after a build's terminal ``ready`` event.
 * Lists every built section as a clickable chip — click → pre-fills
 * the chat input with an edit prompt anchored on that section's
 * title + position. Cheaper than rebuilding the whole demo for a
 * single-section tweak. */

.db-postbuild-card {
  margin: 10px 16px 0;
  padding: 14px 16px;
  background: linear-gradient(180deg,
    var(--accent-soft),
    color-mix(in srgb, var(--accent) 2%, transparent));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  animation: db-slideUp var(--dur) var(--ease);
}
.db-postbuild-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 6px;
}
.db-postbuild-glyph {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.db-postbuild-title {
  flex: 1;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.db-postbuild-dismiss {
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.12s;
}
.db-postbuild-dismiss:hover { color: var(--text); }
.db-postbuild-hint {
  margin: 0 0 10px;
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.45;
}
.db-postbuild-chips,
.db-postbuild-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
/* Each row pairs the existing edit-chip (left, flex: 1) with a new
 * per-section "Looks good" confirm button on the right so the SE can
 * tick off sections one at a time after a full build. */
.db-postbuild-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.db-postbuild-row.is-confirmed .db-postbuild-chip-edit {
  opacity: 0.55;
}
.db-postbuild-row.is-confirmed {
  /* Subtle dim so the SE's eye lands on un-reviewed rows first. */
  opacity: 0.95;
}
.db-postbuild-row .db-postbuild-chip {
  flex: 1;
  min-width: 0;
}
.db-postbuild-row-confirm {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, opacity 0.12s ease;
}
.db-postbuild-row-confirm:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-color: var(--accent);
}
.db-postbuild-row-confirm:disabled,
.db-postbuild-row-confirm.is-confirmed {
  cursor: default;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  border-color: var(--accent);
  color: var(--accent);
  opacity: 0.85;
}
.db-postbuild-row-confirm-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-size: 12px;
  line-height: 1;
}
.db-postbuild-row-confirm-label {
  font-family: inherit;
}
.db-postbuild-progress {
  flex: 1;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: left;
  letter-spacing: 0.02em;
}
.db-postbuild-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 12px;
  transition: background var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease);
}
.db-postbuild-chip:hover {
  background: var(--surface-hover);
  border-color: var(--accent-soft);
}
.db-postbuild-chip-kind {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 7px;
  border-radius: var(--r-xs);
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.db-postbuild-chip-title {
  flex-shrink: 0;
  font-weight: 600;
  color: var(--text);
}
.db-postbuild-chip-summary {
  flex: 1;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.db-postbuild-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

/* ── Section-review card (human-in-loop) ────────────────────── */

.db-review-card {
  margin: 8px 16px 0;
  padding: 14px 16px;
  background: linear-gradient(180deg,
    var(--accent-soft),
    color-mix(in srgb, var(--accent) 1%, transparent));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  animation: db-slideUp var(--dur) var(--ease);
}
.db-review-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 6px;
}
.db-review-glyph {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.db-review-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.01em;
  color: var(--text);
}
.db-review-attempt {
  margin-left: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold);
  font-weight: 500;
}
.db-review-hint {
  margin: 0 0 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.db-review-actions {
  display: flex;
  gap: 8px;
}
.db-review-revise {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.db-review-revise textarea {
  width: 100%;
  resize: vertical;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 12.5px;
  line-height: 1.45;
  font-family: inherit;
}
.db-review-revise textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.db-review-revise-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

/* Nav-choice card — parallel to .db-review-card. Surfaces during the
   awaiting_nav_choice pause so the SE can state their navigation
   preference in plain English before the hero renders. */
.db-nav-choice-card {
  margin: 8px 16px 0;
  padding: 14px 16px;
  background: linear-gradient(180deg,
    var(--accent-soft),
    color-mix(in srgb, var(--accent) 1%, transparent));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  animation: db-slideUp var(--dur) var(--ease);
}
.db-nav-choice-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 6px;
}
.db-nav-choice-glyph {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.db-nav-choice-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.01em;
  color: var(--text);
}
.db-nav-choice-body {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-secondary);
}
.db-nav-choice-body strong { color: var(--text); }
.db-nav-choice-body em { color: var(--text); font-style: normal; opacity: 0.85; }
.db-nav-choice-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.db-nav-choice-form textarea {
  width: 100%;
  resize: vertical;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 12.5px;
  line-height: 1.45;
  font-family: inherit;
  min-height: 48px;
}
.db-nav-choice-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.db-nav-choice-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

/* ── Build-mode dialog (Autopilot vs Guided) ─────────────────────── */
.db-build-mode-card {
  margin: 8px 16px 0;
  padding: 16px 16px 15px;
  /* Accent-tinted, like the other decision cards — this one BLOCKS the
   * build, so it must read as "waiting on you", not blend into the chat. */
  background: linear-gradient(180deg,
    var(--accent-soft),
    color-mix(in srgb, var(--accent) 2%, transparent));
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md), var(--glow-accent);
  /* One-shot attention pulse on appear so the SE notices the build paused. */
  animation: db-slideUp var(--dur) var(--ease),
    db-attention-pulse 1.4s var(--ease) 2;
}
@keyframes db-attention-pulse {
  0%, 100% { box-shadow: var(--shadow-md), 0 0 0 0 transparent; }
  50% { box-shadow: var(--shadow-md),
    0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
}
.db-build-mode-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 4px;
}
.db-build-mode-glyph {
  width: 18px; height: 18px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.db-build-mode-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
  color: var(--text);
}
/* "Waiting on you" pill — the unmistakable signal the build is paused. */
.db-build-mode-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--on-accent);
  background: var(--accent);
  padding: 3px 8px;
  border-radius: 999px;
  box-shadow: var(--glow-accent);
}
.db-build-mode-hint {
  margin: 0 0 11px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.db-build-mode-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.db-build-mode-option {
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  padding: 11px 13px;
  /* Raised lighter fill so each option reads as an elevated, clickable
   * surface even off the card; accent border marks it interactive. No glow
   * at rest — the lift + accent edge carry it (the card behind adds depth). */
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-family: inherit;
  transition: border-color var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.db-build-mode-option:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--surface-hover);
}
.db-build-mode-option:disabled { cursor: default; opacity: 0.55; }
.db-build-mode-option.is-chosen {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: var(--glow-accent);
  opacity: 1;
}
.db-build-mode-option-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}
.db-build-mode-option-desc {
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* ── Reuse-suggestion picker (find_similar_demos) ────────────────── */
.db-reuse-card {
  margin: 8px 16px 0;
  padding: 14px 16px;
  background: linear-gradient(180deg,
    var(--accent-soft),
    color-mix(in srgb, var(--accent) 1.5%, transparent));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  animation: db-slideUp var(--dur) var(--ease);
}
.db-reuse-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
}
.db-reuse-glyph { font-size: 14px; }
.db-reuse-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.01em;
  color: var(--text);
}
.db-reuse-rows {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.db-reuse-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
}
.db-reuse-row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.db-reuse-row-title {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.db-reuse-row-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
}
.db-reuse-pct {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: var(--r-full);
  letter-spacing: 0.02em;
}
.db-reuse-pct.is-strong {
  background: var(--accent-soft);
  color: var(--accent);
}
.db-reuse-pct.is-moderate {
  background: var(--gold-dim);
  color: var(--gold);
}
.db-reuse-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.db-reuse-open {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 5px 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.db-reuse-open:hover { background: var(--bg-elevated); }
/* .db-reuse-fork / .db-reuse-fresh are JS hooks only — the visual is
 * driven by the shared .db-toolbar-btn system so every action button
 * across the builder (reuse / review / nav-choice) reads the same. */
.db-reuse-footer {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

/* Queued action — a button clicked while a turn is still streaming. We
 * keep it visibly "working" (the click was registered, it'll fire when
 * the turn frees) rather than a dead disabled control. Shared across all
 * .db-toolbar-btn action buttons. */
.db-toolbar-btn.is-queued {
  opacity: 0.85;
  cursor: progress;
  position: relative;
}
.db-toolbar-btn.is-queued::after {
  content: "";
  width: 9px;
  height: 9px;
  margin-left: 2px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  display: inline-block;
  vertical-align: -1px;
  animation: db-spin 0.6s linear infinite;  /* db-spin defined above */
}

.db-chat-form textarea:disabled,
.db-chat-form textarea.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  border-color: var(--border-soft);
  background: var(--bg-elevated);
}
.db-chat-form button[type="submit"]:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.db-chat-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

/* ── Preview pane ─────────────────────────────────────────────────── */

.db-preview-pane {
  display: none;       /* hidden until .is-preview-open is set on the parent */
  flex-direction: column;
  background:
    linear-gradient(180deg, var(--bg-elevated), var(--bg) 60%);
  position: relative;
  min-width: 0;
  border-left: 1px solid var(--border);
}
.main-view-demobuilder.is-preview-open .db-preview-pane {
  display: flex;
}
/* Signature: the preview is framed like a premium product surface —
 * the header is the refined "browser chrome" wrapping the live demo.
 * A hairline accent line glows along the very top edge of the pane. */
.db-preview-header {
  display: flex;
  flex-direction: column;
  padding: 11px 16px 9px;
  gap: 9px;
  border-bottom: 1px solid var(--border);
  background:
    var(--grad-sheen),
    linear-gradient(180deg, var(--bg-elevated), color-mix(in srgb, var(--bg-elevated) 70%, var(--bg)));
  flex-shrink: 0;
  position: relative;
}
.db-preview-header[hidden] { display: none; }
.db-preview-header::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent,
    color-mix(in srgb, var(--accent) 55%, transparent) 30%,
    color-mix(in srgb, var(--accent) 55%, transparent) 70%, transparent);
  opacity: 0.7;
}
.db-preview-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.db-preview-titleblock {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}
.db-preview-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.02em;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.db-preview-cost {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
/* Per-source cost breakdown — collapsed by default. The <summary> is
 * the tiny chevron-prefixed "Cost breakdown" link below the meta
 * line; expanding it reveals a small table-like grid of source ·
 * calls · tokens · $. Borderless to keep the preview header visually
 * quiet when collapsed. */
.db-preview-cost-breakdown {
  margin-top: 2px;
  font-size: 10.5px;
  color: var(--text-secondary);
}
.db-preview-cost-breakdown-summary {
  cursor: pointer;
  padding: 1px 0;
  letter-spacing: 0.02em;
  font-weight: 500;
  list-style: none;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.db-preview-cost-breakdown-summary::-webkit-details-marker { display: none; }
.db-preview-cost-breakdown-summary::before {
  content: "▸";
  font-size: 8px;
  opacity: 0.7;
  transition: transform 0.12s ease;
}
.db-preview-cost-breakdown[open] .db-preview-cost-breakdown-summary::before {
  transform: rotate(90deg);
}
.db-preview-cost-breakdown-summary:hover { color: var(--text); }
.db-preview-cost-breakdown-body {
  margin-top: 4px;
  padding: 6px 8px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-xs);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.db-preview-cost-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1.6fr 0.7fr;
  gap: 8px;
  align-items: baseline;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.db-preview-cost-row-label { color: var(--text); }
.db-preview-cost-row-calls,
.db-preview-cost-row-tokens { color: var(--text-secondary); opacity: 0.8; }
.db-preview-cost-row-usd {
  text-align: right;
  color: var(--accent);
  font-weight: 600;
}
.db-preview-cost-row-total {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed var(--border-soft, rgba(255, 255, 255, 0.1));
}
.db-preview-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.db-preview-actions {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Preview / Code tabs ─────────────────────────────────────── */

.db-preview-tabs {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 3px;
  gap: 2px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
}
.db-preview-tab {
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  padding: 5px 16px;
  border-radius: var(--r-sm);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.db-preview-tab:hover { color: var(--text); }
.db-preview-tab:focus-visible { outline: none; box-shadow: var(--ring); }
/* Active tab — a lifted, lit segment so the current view is unmistakable. */
.db-preview-tab.is-active {
  background: var(--grad-sheen),
    linear-gradient(180deg, var(--surface-hover), var(--surface));
  color: var(--accent);
  box-shadow: var(--shadow-sm),
    inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent),
    0 0 16px -6px var(--accent);
}
.db-preview-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  border-radius: var(--r-xs);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  margin-left: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.db-preview-close:hover {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 50%, transparent);
}
.db-preview-close:focus-visible { outline: none; box-shadow: var(--ring); }
.db-preview-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  color: var(--text-secondary);
  padding: 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.db-preview-empty[hidden] { display: none; }
/* Atmosphere — a soft green aurora + fading dot-grid behind the empty
 * prompt, mirroring the welcome canvas so an unloaded preview still
 * feels like part of the product, not a blank panel. */
.db-preview-empty::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(60% 50% at 50% 38%, rgba(0, 237, 100, 0.14), transparent 72%);
}
.db-preview-empty::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1.4px);
  background-size: 24px 24px;
  -webkit-mask-image: radial-gradient(80% 60% at 50% 42%, #000 25%, transparent 75%);
  mask-image: radial-gradient(80% 60% at 50% 42%, #000 25%, transparent 75%);
}
.db-preview-empty-inner {
  max-width: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.db-preview-empty-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  font-size: 28px;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 10px;
  border-radius: var(--r-lg);
  background: radial-gradient(circle at 36% 28%,
    color-mix(in srgb, var(--accent) 26%, transparent), var(--accent-soft));
  border: 1px solid color-mix(in srgb, var(--accent) 38%, transparent);
  box-shadow: 0 0 32px -6px rgba(0, 237, 100, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  animation: dbEmptyFloat 4.5s var(--ease) infinite;
}
@keyframes dbEmptyFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
.db-preview-empty-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0;
}
.db-preview-empty-hint {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-secondary);
  margin: 0;
}
@media (prefers-reduced-motion: reduce) {
  .db-preview-empty-glyph { animation: none; }
}
/* Floating close shown when the preview pane is open but no demo is
 * loaded yet (the regular header — and its × — only render once a
 * demo loads). Hidden as soon as the header takes over so we never
 * stack two close buttons in the corner. */
.db-preview-close-floating {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 28px;
  height: 28px;
  border-radius: var(--r-xs);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: background var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.db-preview-close-floating:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--accent);
}
/* When the real header is visible (a demo has loaded), the header's
 * own × takes over and the floating one would be a duplicate. */
.db-preview-pane:has(.db-preview-header:not([hidden])) .db-preview-close-floating {
  display: none;
}
/* ── Themed modal (confirm / alert / prompt replacement) ─────── */

.db-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.db-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 8, 5, 0.62);
  backdrop-filter: blur(3px);
  animation: db-fadeIn var(--dur-fast) var(--ease);
}
.db-modal-panel {
  position: relative;
  background: var(--bg-elevated);
  background-image: var(--grad-sheen);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px 22px 18px;
  width: min(440px, 100%);
  box-shadow: var(--shadow-xl);
  animation: db-slideUp var(--dur) var(--ease);
}
@keyframes db-fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes db-slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.db-modal-title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}
.db-modal-body {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-secondary);
}
.db-modal-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  color: var(--text);
  font-size: 13px;
  margin-bottom: 16px;
  outline: none;
  transition: border-color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
}
.db-modal-input:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.db-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.db-share-intro {
  margin: 0 0 14px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-secondary);
}
.db-share-subhead {
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  margin: 14px 0 6px;
}
.db-share-empty {
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
  padding: 6px 2px;
}
.db-share-unknown {
  margin: 12px 0 0;
  font-size: 11.5px;
  color: var(--gold);
  background: var(--gold-dim);
  border: 1px solid color-mix(in srgb, var(--gold) 22%, transparent);
  border-radius: var(--r-xs);
  padding: 8px 10px;
}

/* Typeahead input + suggestion dropdown */
.db-share-typeahead {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 5px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  transition: border-color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
}
.db-share-typeahead:focus-within {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.db-share-chips {
  display: contents;
}
.db-share-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: var(--r-xs);
  padding: 1px 4px 1px 8px;
  font-size: 11.5px;
  font-weight: 500;
}
.db-share-chip-x {
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  font-size: 11px;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.7;
}
.db-share-chip-x:hover { opacity: 1; }
.db-share-input {
  flex: 1 1 140px;
  min-width: 100px;
  background: transparent;
  border: 0;
  color: var(--text);
  font-size: 13px;
  padding: 5px 4px;
  outline: none;
}
.db-share-input::placeholder { color: var(--text-secondary); opacity: 0.6; }
.db-share-suggest {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
  z-index: 10;
  max-height: 220px;
  overflow-y: auto;
}
.db-share-suggest-row {
  font-size: 12.5px;
  padding: 6px 10px;
  border-radius: var(--r-xs);
  cursor: pointer;
  color: var(--text);
}
.db-share-suggest-row:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Status line beneath the typeahead — surfaces 'Searching…',
   'No matches', or transient errors. Sits below the typeahead
   box so the suggestion dropdown (positioned absolute over the
   page) and the status can both be visible at once. */
.db-share-status {
  margin: 6px 4px 0;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--text-secondary);
}
.db-share-status-empty { color: var(--text-secondary); }
.db-share-status-error { color: var(--danger); }

.db-share-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
  max-height: 180px;
  overflow-y: auto;
}
.db-share-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-xs);
  font-size: 12px;
  color: var(--text);
}
.db-share-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.db-share-revoke {
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  padding: 3px 7px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.db-share-revoke:hover {
  background: color-mix(in srgb, var(--danger) 16%, transparent);
  color: var(--danger);
}

.db-stale-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  background: var(--gold-dim);
  border-bottom: 1px solid color-mix(in srgb, var(--gold) 38%, transparent);
  color: var(--gold);
  font-size: 12px;
}
.db-stale-rebuild {
  background: var(--gold);
  border: 0;
  color: #2a2110;
  font-weight: 600;
  font-size: 11px;
  padding: 5px 12px;
  border-radius: var(--r-xs);
  cursor: pointer;
  white-space: nowrap;
  transition: filter var(--dur-fast) var(--ease);
}
.db-stale-rebuild:hover { filter: brightness(1.1); }

/* Resume banner — shown when the SE opens a demo whose build was
 * interrupted or left in awaiting-review. Distinct from the stale-
 * format banner (amber): this one uses the build-progress yellow
 * palette to signal "paused, awaiting your attention" with two
 * actions (Resume preserves approvals; Rebuild starts fresh). */
.db-resume-banner {
  padding: 12px 18px;
  background: rgba(251, 191, 36, 0.08);
  border-bottom: 1px solid rgba(251, 191, 36, 0.32);
  color: #fde68a;
}
.db-resume-banner-inner {
  display: flex;
  align-items: center;
  gap: 14px;
}
.db-resume-banner-glyph {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(251, 191, 36, 0.18);
  color: #fbbf24;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.db-resume-banner-body {
  flex: 1;
  min-width: 0;
}
.db-resume-banner-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 2px;
}
.db-resume-banner-sub {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
}
.db-resume-banner-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
/* Body wrapper holds the iframe / code / plan tabs as siblings.
 * Either one is shown at a time via JS. ``min-height: 0`` lets the
 * inner scroll containers be smaller than their content (the classic
 * flex trap), and ``overflow: hidden`` clamps anything that fails to
 * honor min-height-0 — without this, the code/plan bodies grow to
 * their content height and the whole pane never scrolls. */
.db-preview-body {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  overflow: hidden;
  position: relative;
  background: var(--bg);
}
/* Inner shadow frames the live demo as a recessed product surface
 * inside the browser-chrome header above it. */
.db-preview-body::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.4),
    inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}
/* The body is ``position: relative`` — pin code/plan absolutely so
 * they get an explicit ``inset: 0`` container, which then gives the
 * inner scroll panes a real height to work against. The pure-flex
 * version kept losing height somewhere in the cascade. */
.db-preview-iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  /* Dark canvas during load instead of a jarring white flash — the demo's
     own page background paints over this once it loads. */
  background: var(--bg);
}

/* ── Code view ─────────────────────────────────────────────── */

.db-preview-code {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #0a120e;
}
.db-preview-code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-elevated);
  flex-shrink: 0;
}
.db-preview-code-meta {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.db-preview-code-pre {
  margin: 0;
  flex: 1 1 auto;
  min-height: 0;       /* allow shrinking inside flex column */
  overflow: auto;
  padding: 14px 16px 32px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.6;
  color: #cfeadc;
  background: transparent;
  white-space: pre;
  tab-size: 2;
}
.db-preview-code-pre code { color: inherit; }
.db-preview-code-pre::-webkit-scrollbar { width: 10px; height: 10px; }
.db-preview-code-pre::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 5px;
}
.db-preview-code-pre::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* ── Plan view (renders plan.md inline) ─────────────────────── */

.db-preview-plan {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
}
.db-preview-plan-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-elevated);
  flex-shrink: 0;
}
.db-preview-plan-meta {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.db-preview-plan-body {
  flex: 1 1 auto;
  min-height: 0;       /* allow shrinking inside flex column */
  overflow-y: auto;
  padding: 24px 32px 48px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.65;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
}
.db-preview-plan-body h1,
.db-preview-plan-body h2,
.db-preview-plan-body h3,
.db-preview-plan-body h4 {
  font-family: var(--font-display);
  color: var(--text);
  margin: 24px 0 8px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.db-preview-plan-body h1 {
  font-size: 24px;
  margin-top: 4px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-soft);
}
.db-preview-plan-body h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  font-weight: 600;
  margin-top: 28px;
}
.db-preview-plan-body h3 { font-size: 14px; }
.db-preview-plan-body h4 { font-size: 13px; }
.db-preview-plan-body p {
  margin: 0 0 12px;
  color: var(--text-secondary);
}
.db-preview-plan-body ul {
  margin: 0 0 14px;
  padding-left: 22px;
  color: var(--text-secondary);
}
.db-preview-plan-body li {
  margin: 3px 0;
  line-height: 1.6;
}
.db-preview-plan-body li.indent {
  list-style: none;
  margin-left: -6px;
  padding-left: 16px;
  color: var(--text-secondary);
  font-size: 12px;
  opacity: 0.85;
}
.db-preview-plan-body strong {
  color: var(--text);
  font-weight: 600;
}
.db-preview-plan-body code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  padding: 1px 6px;
  border-radius: var(--r-xs);
  color: var(--accent);
}
.db-preview-plan-body .footer-note {
  margin-top: 32px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
  font-size: 11px;
  font-style: italic;
  color: var(--text-secondary);
}

/* Section overlay controls REMOVED — see ``bindOverlays`` in view.js
 * for the rationale. SEs can still rebuild / remove via chat. */

/* Composer-pane banner. Two variants:
 *   .is-inflight  → a build is STILL running (emerald palette).
 *   .is-resumable → a build needs the SE's action to continue:
 *                   interrupted by a restart, paused for review,
 *                   or finished partially with missing sections
 *                   (amber palette).
 * Clickable: loads the demo so the preview-pane resume banner can
 * surface the explicit Resume / Rebuild buttons. */
.db-inflight-builds-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid transparent;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.db-inflight-builds-banner.is-inflight {
  background: linear-gradient(
    90deg,
    rgba(16, 185, 129, 0.10) 0%,
    rgba(20, 184, 166, 0.08) 100%
  );
  border-bottom-color: rgba(16, 185, 129, 0.32);
  color: #6ee7b7;
}
.db-inflight-builds-banner.is-inflight:hover {
  background: linear-gradient(
    90deg,
    rgba(16, 185, 129, 0.16) 0%,
    rgba(20, 184, 166, 0.12) 100%
  );
  border-bottom-color: rgba(16, 185, 129, 0.55);
}
.db-inflight-builds-banner.is-inflight .db-inflight-label { color: #d1fae5; }
.db-inflight-builds-banner.is-inflight .db-inflight-cta   { color: #6ee7b7; }
.db-inflight-builds-banner.is-inflight .db-inflight-dot {
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.7);
  animation: db-inflight-pulse 1.4s ease-in-out infinite;
}
.db-inflight-builds-banner.is-resumable {
  background: linear-gradient(
    90deg,
    rgba(251, 191, 36, 0.10) 0%,
    rgba(245, 158, 11, 0.08) 100%
  );
  border-bottom-color: rgba(251, 191, 36, 0.40);
  color: #fde68a;
}
.db-inflight-builds-banner.is-resumable:hover {
  background: linear-gradient(
    90deg,
    rgba(251, 191, 36, 0.18) 0%,
    rgba(245, 158, 11, 0.14) 100%
  );
  border-bottom-color: rgba(251, 191, 36, 0.65);
}
.db-inflight-builds-banner.is-resumable .db-inflight-label { color: #fef3c7; }
.db-inflight-builds-banner.is-resumable .db-inflight-cta {
  /* Make the CTA actually look like a button — the prior
   * implementation was a plain text span and SEs read past it
   * looking for an explicit Resume button that didn't exist. */
  background: #fbbf24;
  color: #2a2110;
  padding: 6px 14px;
  border-radius: 6px;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
  transition: background 0.15s ease, transform 0.05s ease;
}
.db-inflight-builds-banner.is-resumable:hover .db-inflight-cta {
  background: #fcd34d;
}
.db-inflight-builds-banner.is-resumable:active .db-inflight-cta {
  transform: translateY(1px);
}
.db-inflight-builds-banner.is-resumable .db-inflight-dot {
  background: #fbbf24;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.7);
  /* Slower / steadier pulse than the inflight dot — "waiting for you"
   * rather than "I'm working". */
  animation: db-inflight-pulse 2.2s ease-in-out infinite;
}
.db-inflight-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
@keyframes db-inflight-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(1.25); }
}
.db-inflight-label {
  flex: 1;
  font-weight: 500;
}
.db-inflight-cta {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ── Reduced-motion guard ──────────────────────────────────────────
 * Honour the user's OS preference: drop the looping/entrance animations
 * introduced or retained above. The progress shimmer, status-icon spin,
 * pulsing dots, and slide/fade entrances all collapse to a static frame
 * so nothing animates while functional state (colour, layout) is intact. */
@media (prefers-reduced-motion: reduce) {
  .db-background-builds-badge,
  .db-dot-building,
  .db-dot-interrupted,
  .db-dot-partial,
  .db-dot-awaiting_review,
  .db-progress-panel::before,
  .db-progress-status-icon,
  .db-progress-step.is-active .db-progress-step-dot,
  .db-inflight-builds-banner.is-inflight .db-inflight-dot,
  .db-inflight-builds-banner.is-resumable .db-inflight-dot,
  .db-row-menu-popup,
  .db-postbuild-card,
  .db-review-card,
  .db-nav-choice-card,
  .db-build-mode-card,
  .db-reuse-card,
  .db-modal-backdrop,
  .db-modal-panel {
    animation: none !important;
  }
}
