/* Expanso Playground — kurate.cloud design system applied.
   Tool UI context: dark mode, Figtree + JetBrains Mono,
   4px radius, 8px grid, semantic color only. */

:root {
  /* Surfaces */
  --bg:          #141414;
  --surface:     #1e1e1e;
  --surface-alt: #252525;
  --border:      rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);

  /* Text — WCAG AA on #141414 */
  --text-primary:   #e8e8e8;
  --text-secondary: #a0a0a0;
  --text-tertiary:  #6b6b6b;

  /* Semantic */
  --accent:       #9259ED;
  --accent-hover: #a370f7;
  --interactive:  #0055FF;
  --success:      #52CD42;
  --error:        #FF4A0E;
  --warning:      #F5A623;

  /* Spacing (8px grid) */
  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 16px;
  --sp-lg: 24px;

  /* Type */
  --font-sans: 'Figtree', -apple-system, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SF Mono', monospace;
  --radius: 4px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ===== HEADER ===== */

header {
  height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-md);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

.logo-icon { flex-shrink: 0; }

.logo-text {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

.divider-v {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 var(--sp-xs);
}

/* ===== BUTTONS ===== */

.btn {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 5px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-primary);
  background: var(--surface-alt);
  outline: none;
}
.btn:hover { background: #2e2e2e; }
.btn:focus-visible { box-shadow: 0 0 0 2px var(--interactive); }
.btn:active { background: #353535; }

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-accent:active { background: #7d45d6; }
.btn-accent:disabled { opacity: 0.5; cursor: default; }

.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover { background: var(--surface-alt); border-color: var(--border); }

.spinner {
  width: 12px; height: 12px;
  border: 2px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}
.spinner[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.run-icon[hidden] { display: none; }

/* ===== DROPDOWN ===== */

.dropdown { position: relative; }

.dropdown-panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 50;
  min-width: 280px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: var(--sp-xs) 0;
}
.dropdown-panel[hidden] { display: none; }

.drop-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--sp-sm) var(--sp-md);
  border: none;
  background: none;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  line-height: 1.4;
}
.drop-item:hover { background: rgba(146, 89, 237, 0.08); }
.drop-item.active { background: rgba(146, 89, 237, 0.12); }

/* "Modified" dot on the active sample when edits diverge from canonical.
   Kurate-compliant: uses --text-secondary (not a semantic color) because
   modification isn't success or failure — just a state. */
.drop-item-modified::after {
  content: "•";
  margin-left: 6px;
  color: var(--text-secondary);
}

.drop-item-sub {
  display: block;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* Display settings panel — font-size slider + reset. Same dropdown
   surface as Examples so the visual language stays consistent. */
.display-panel {
  min-width: 240px;
  padding: var(--sp-md);
}

.display-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: var(--sp-sm);
}

.display-label {
  font-weight: 500;
}

.display-value {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
}

.display-range {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: var(--border-strong);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.display-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--text-primary);
  border-radius: 50%;
  border: none;
  cursor: pointer;
}
.display-range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--text-primary);
  border-radius: 50%;
  border: none;
  cursor: pointer;
}
.display-range:focus-visible { box-shadow: 0 0 0 2px var(--interactive); }

.display-accent-row {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}
.display-color {
  width: 32px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
}
.display-color::-webkit-color-swatch-wrapper { padding: 0; }
.display-color::-webkit-color-swatch { border: none; border-radius: 2px; }
.display-color::-moz-color-swatch { border: none; border-radius: 2px; }
.display-accent-hint {
  font-size: 11px;
  color: var(--text-tertiary);
}

.display-divider {
  height: 1px;
  background: var(--border);
  margin: var(--sp-md) 0;
}

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

.display-shortcuts {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-size: 12px;
  line-height: 1.4;
}
.display-shortcuts dt {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  white-space: nowrap;
}
.display-shortcuts dd {
  margin: 0;
  color: var(--text-primary);
}

.display-action {
  width: 100%;
  text-align: left;
  padding: var(--sp-xs) 0;
  border: none;
  background: none;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}
.display-action:hover { color: var(--text-primary); }

/* ===== STATUS PIP ===== */

.status-pip {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pip-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
}
.pip-dot.ok  { background: var(--success); }
.pip-dot.bad { background: var(--error); }

.pip-text {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
}

/* ===== MAIN LAYOUT ===== */

main {
  flex: 1;
  display: flex;
  min-height: 0;
}

.panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.panel-left  { border-right: 1px solid var(--border); }

/* ===== PANES ===== */

.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.pane-input {
  flex: 0 0 160px;
  border-bottom: 1px solid var(--border);
}

.pane-mapping {
  flex: 1;
  min-height: 0;
}

.pane-output {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.pane-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-sm) var(--sp-md);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.pane-title {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.pane-link {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  text-decoration: none;
  letter-spacing: 0.02em;
}
.pane-link:hover { color: var(--interactive); }

.pane-link-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  margin-left: var(--sp-sm);
}
.pane-link-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--interactive);
  border-radius: 2px;
}

/* Live-mode toggle in the Sample Log pane-bar. Semantic green only
   when active — it's signaling a pulsing stream. When off, grays out
   and looks like any other pane-link. */
.live-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
  flex-shrink: 0;
}
.live-toggle[aria-pressed="true"] { color: var(--text-primary); }
.live-toggle[aria-pressed="true"] .live-dot {
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(82, 205, 66, 0.6);
  animation: live-pulse 1.8s ease-in-out infinite;
}
@keyframes live-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(82, 205, 66, 0.6); }
  70%  { box-shadow: 0 0 0 5px rgba(82, 205, 66, 0);   }
  100% { box-shadow: 0 0 0 0   rgba(82, 205, 66, 0);   }
}

/* Tracer toggle: sibling of Live in the Sample Log pane-bar. Uses Ice
   (non-semantic accent) instead of success-green so the two toggles
   are visually distinct at a glance — Live is "green: data is flowing",
   Tracer is "blue: watch the record move through the rail". */
.trace-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.trace-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
  flex-shrink: 0;
}
.trace-toggle[aria-pressed="true"] { color: var(--text-primary); }
.trace-toggle[aria-pressed="true"] .trace-dot {
  background: var(--ice);
  box-shadow: 0 0 0 0 rgba(51, 204, 255, 0.6);
  animation: trace-pulse 1.0s ease-in-out infinite;
}
@keyframes trace-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(51, 204, 255, 0.6); }
  70%  { box-shadow: 0 0 0 5px rgba(51, 204, 255, 0);   }
  100% { box-shadow: 0 0 0 0   rgba(51, 204, 255, 0);   }
}

/* Per-stage readouts rendered under each rail dot when Tracer is on.
   Single-line, monospace, ellipsis on overflow — the rail is a
   horizontal scroller when tight. A `.stage-readout.updated` class
   applied briefly on every tick gives a subtle flash so the user
   sees which stage just refreshed. */
.stage-readout {
  display: block;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 2px 4px;
  margin-top: 4px;
  border-radius: 2px;
  background: rgba(51, 204, 255, 0.04);
  transition: background 400ms ease;
}
.stage-readout.updated {
  background: rgba(51, 204, 255, 0.18);
  color: var(--text-primary);
}
.stage-readout.errored {
  background: rgba(255, 74, 14, 0.08);
  color: var(--error);
}
.stage-readout-empty {
  color: var(--text-tertiary);
  font-style: italic;
}

/* Slide-out panel for Rung-3 job YAML preview. Fixed-position overlay,
   slides in from the right, above everything. Close via × button or
   Escape key. Kurate: dark surface (#1e1e1e), 4px radius, no shadow
   (border does elevation). */
.slide-panel {
  position: fixed;
  top: 48px;  /* below the header */
  right: 0;
  bottom: 0;
  width: min(560px, 50vw);
  background: var(--surface);
  border-left: 1px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transform: translateX(0);
  transition: transform 120ms ease-out;
}
.slide-panel[hidden] {
  display: flex;
  transform: translateX(100%);
  pointer-events: none;
}

.slide-panel-bar {
  display: flex;
  align-items: center;
  padding: var(--sp-sm) var(--sp-md);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: var(--sp-sm);
}
.slide-panel-bar > .pane-meta { flex: 1; }

.slide-panel-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: var(--radius);
}
.slide-panel-close:hover {
  color: var(--text-primary);
  background: var(--surface-alt);
}
.slide-panel-close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--interactive);
}

.slide-panel-body {
  flex: 1;
  margin: 0;
  padding: var(--sp-md);
  font-family: var(--font-mono);
  font-size: var(--code-font-size);
  line-height: 1.55;
  color: var(--text-primary);
  background: var(--bg);
  overflow: auto;
  white-space: pre;
  word-break: normal;
}

.pane-bar > .pane-title + .pane-meta { margin-left: var(--sp-sm); }
.pane-bar > .pane-title + .pane-dropdown { margin-left: var(--sp-sm); }
.pane-bar > .pane-dropdown + .pane-meta { margin-left: var(--sp-sm); }
.pane-bar > .pane-meta + .pane-link { margin-left: auto; }

/* In-pane-bar dropdown — lighter than the header .btn-ghost so it
   doesn't dominate the pane-bar visually. Same dropdown-panel for
   the menu itself; just the trigger is restyled. */
.pane-dropdown { position: relative; }
.pane-dropdown-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-primary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px 8px;
  cursor: pointer;
}
.pane-dropdown-btn:hover {
  background: var(--surface-alt);
  border-color: var(--border-strong);
}
.pane-dropdown-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--interactive);
}
.pane-dropdown-btn svg { opacity: 0.6; }

.pane-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
}
.pane-meta.ok  { color: var(--success); }
.pane-meta.bad { color: var(--error); }

/* Pipeline stage rail — groundwork for M2 visual pipeline.
   Each processor in the YAML is one dot; dots connect with 1px lines.
   Hidden when the pipeline is empty or unparseable. No rainbow colors:
   kurate rule, stages are all the same tier visually. Hover a dot to
   see the processor type. */
.stage-rail {
  display: flex;
  align-items: center;
  gap: 0;
  min-height: 28px;
  padding: 0 var(--sp-md);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  overflow-x: auto;
}
.stage-rail[hidden],
.stage-rail:empty { display: none; }

.stage-rail .stage-dot {
  width: 10px;
  height: 10px;
  padding: 0;
  border-radius: 50%;
  background: var(--text-tertiary);
  border: 1px solid transparent;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 80ms linear, border-color 80ms linear;
}
.stage-rail .stage-dot:hover { background: var(--text-secondary); }
.stage-rail .stage-dot:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--interactive);
}
.stage-rail .stage-dot.active {
  background: var(--text-primary);
  border-color: var(--ice);
}

.stage-rail .stage-line {
  height: 1px;
  width: 24px;
  background: var(--border-strong);
  flex-shrink: 0;
}

.stage-rail .stage-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  margin-left: 6px;
  margin-right: 4px;
  white-space: nowrap;
}

/* Group wraps dot + label + delete button so the delete reveals on
   hover-of-the-whole-stage, not just on hover of the × itself — much
   easier target discovery. */
.stage-group {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.stage-rail .stage-del {
  width: 14px;
  height: 14px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 80ms linear, color 80ms linear;
  border-radius: 50%;
}
.stage-group:hover .stage-del,
.stage-rail .stage-del:focus-visible { opacity: 1; }
.stage-rail .stage-del:hover { color: var(--error); }
.stage-rail .stage-del:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--interactive);
}

/* "+ Add stage" trigger — the Rung-2 recipe affordance. Keeps the
   dashed-outline ghost-button shape so it reads as "add a new thing"
   rather than an existing stage. Dropdown menu reuses the existing
   .dropdown-panel visual language. */
.stage-add-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.stage-rail .stage-add-btn {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 80ms linear, border-color 80ms linear;
}
.stage-rail .stage-add-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
  border-style: solid;
}
.stage-rail .stage-add-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--interactive);
}

.stage-add-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 50;
  min-width: 260px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: var(--sp-xs) 0;
}
.stage-add-menu[hidden] { display: none; }

/* Inline-form recipes (Mask) inside the + Add dropdown. Replaces the
   hover-a-menu-item-and-click flow with type-and-submit. */
.drop-item-form {
  display: block;
  padding: var(--sp-sm) var(--sp-md);
  cursor: default;
}
.drop-item-form:hover {
  /* The form is a composite target; highlighting the whole row while
     the user is interacting with its input is visually noisy. */
  background: transparent;
}
.drop-item-head {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 6px;
}
.drop-item-formrow {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.drop-item-input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-primary);
  outline: none;
}
.drop-item-input::placeholder { color: var(--text-tertiary); }
.drop-item-input:focus-visible {
  border-color: var(--interactive);
  box-shadow: 0 0 0 1px var(--interactive);
}
.drop-item-submit {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-alt);
  color: var(--text-primary);
  cursor: pointer;
}
.drop-item-submit:hover { background: #2e2e2e; }
.drop-item-submit:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--interactive);
}

/* ===== ACE EDITOR CONTAINERS ===== */

.ace-wrap {
  flex: 1;
  min-height: 0;
  width: 100%;
  position: relative;
}

/* Override Ace's tomorrow-night theme to match our palette */
.ace-tomorrow-night {
  background: var(--bg) !important;
  color: var(--text-primary) !important;
}
.ace-tomorrow-night .ace_gutter {
  background: var(--surface) !important;
  color: var(--text-tertiary) !important;
  border-right: 1px solid var(--border) !important;
}
.ace-tomorrow-night .ace_cursor {
  color: var(--text-primary) !important;
}
.ace-tomorrow-night .ace_marker-layer .ace_active-line {
  background: rgba(255, 255, 255, 0.04) !important;
}
.ace-tomorrow-night .ace_marker-layer .ace_selection {
  background: rgba(146, 89, 237, 0.2) !important;
}
.ace-tomorrow-night .ace_placeholder {
  color: var(--text-tertiary) !important;
  font-family: var(--font-mono) !important;
}

/* ===== OUTPUT (read-only, still a <pre>) ===== */

.editor {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg);
  border: none;
  outline: none;
  resize: none;
  padding: var(--sp-sm) var(--sp-md);
  tab-size: 2;
  width: 100%;
}

.editor-output {
  flex: 1;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 0;
  color: #ffffff;
}
.editor-output.stale {
  color: #666666;
}

/* Per-event blocks + JSON syntax highlighting.
   Keys stay bound to Ice (--ice, user-customizable via the Display menu's
   accent picker). Values get a light pastel palette — each token type
   reads at a glance without any color yelling: mint for strings, peach
   for numbers, lavender for booleans. Null stays dim italic to signal
   absence. All pastel values clear ~8:1 contrast on the #141414 bg. */
:root {
  --ice: #33CCFF;
  --j-str:  #A7F3D0;
  --j-num:  #FDBA74;
  --j-bool: #F0ABFC;
  --j-null: #9CA3AF;
  /* Display settings (overridable per-user via the Display menu). The
     editors + output pane all read from this so one slider drives the
     whole UI density. Default 13px matches Ace's canonical tool-UI size. */
  --code-font-size: 13px;
}

.out-event {
  padding: var(--sp-sm) 0;
}
.out-event + .out-event {
  border-top: 1px solid var(--border);
}
.out-event:first-child { padding-top: 0; }
.out-event:last-child { padding-bottom: 0; }

.out-event-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  flex-shrink: 0;
}

details.out-event > summary.out-event-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: var(--sp-sm);
  user-select: none;
  padding: 2px 0;
}
details.out-event > summary.out-event-summary::-webkit-details-marker { display: none; }
details.out-event > summary.out-event-summary::before {
  content: '';
  width: 0;
  height: 0;
  border-left: 4px solid var(--text-secondary);
  border-top: 3px solid transparent;
  border-bottom: 3px solid transparent;
  transition: transform 0.12s ease;
  flex-shrink: 0;
  transform: translateY(-1px);
}
details.out-event[open] > summary.out-event-summary::before {
  transform: rotate(90deg) translateX(-1px);
}

.out-event-preview {
  font-family: var(--font-mono);
  font-size: var(--code-font-size);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

details.out-event[open] > .out-event-body {
  margin-top: var(--sp-xs);
}

.out-event-body {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--code-font-size);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-primary);
}

.j-key  { color: var(--ice); }
.j-str  { color: var(--j-str); }
.j-num  { color: var(--j-num); }
.j-bool { color: var(--j-bool); }
.j-null { color: var(--j-null); font-style: italic; }

/* ===== ERROR STRIP ===== */

.error-strip {
  border-top: 1px solid rgba(255, 74, 14, 0.25);
  background: rgba(255, 74, 14, 0.06);
  max-height: 140px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.error-strip[hidden] { display: none; }

.error-strip-bar {
  padding: var(--sp-xs) var(--sp-md);
  border-bottom: 1px solid rgba(255, 74, 14, 0.15);
  flex-shrink: 0;
}

.error-title { color: var(--error); }

.editor-error {
  color: var(--error);
  background: transparent;
  font-size: 12px;
  overflow: auto;
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: var(--sp-sm) var(--sp-md);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ===== CHAPTERS =====
   A narrow narrative spine over existing samples. The strip is a single
   line pinned above <main> on first visit; the scene-setter + Next/Prev
   live inside existing pane-bars. No overlays, no modals, no backdrops —
   if any rule below grows a fixed/absolute position, the anti-tutorial
   stance (add-log-playground/spec.md:7) has been violated. */
.chapter-banner {
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-md);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: var(--sp-md);
}
.chapter-banner[hidden] { display: none; }

.chapter-banner-copy {
  font-size: 12px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

.chapter-banner-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  flex-shrink: 0;
}

.chapter-banner .btn {
  height: 22px;
  padding: 0 10px;
  font-size: 11px;
}

/* Scene-setter nests inside the Sample Log pane-bar, between the
   input-meta count and the Live toggle. Takes the remaining horizontal
   space; truncates with ellipsis when narrow. Tooltip carries full text. */
.chapter-scene {
  font-size: 11px;
  color: var(--text-secondary);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
  margin: 0 var(--sp-sm);
}
.chapter-scene[hidden] { display: none; }

/* Next/Prev affordances live in the Output pane-bar. They reuse the
   pane-link-btn styling (same size/weight/color as Download) so they
   read as standard pane chrome, not a highlighted CTA. */
.chapter-nav[hidden] { display: none; }

/* Rail badges — cardinality + branched final stop. Rendered by
   updateRailBadges() after every successful run. Only appear when the
   pipeline actually reshapes cardinality or branches by sink — no
   noise for single-in/single-out samples. */
.rail-cardinality {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--j-num);              /* peach — matches the cost act's narrative */
  background: rgba(253, 186, 116, 0.08);
  border: 1px solid rgba(253, 186, 116, 0.25);
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: var(--sp-sm);
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.rail-branch {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-xs);
  margin-left: var(--sp-sm);
  flex-shrink: 0;
}
.rail-branch-lane {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--j-bool);             /* lavender — governance act hue */
  background: rgba(240, 171, 252, 0.08);
  border: 1px solid rgba(240, 171, 252, 0.25);
  padding: 1px 6px;
  border-radius: 3px;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.rail-branch-lane + .rail-branch-lane::before {
  content: '';                      /* flex gap handles spacing; no ASCII glyph */
}

/* ===== PASTE PICKER =====
   Inline strip that appears above the Sample Log ace editor when the
   format detector can't confidently pick one format. Ordered chips by
   confidence + a Generic passthrough fallback chip. × button dismisses
   to Generic passthrough. Intentionally light chrome — a single row of
   buttons, no modal, no overlay. */
.paste-picker {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-xs) var(--sp-md);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 30px;
}
.paste-picker[hidden] { display: none; }

.paste-picker-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.paste-picker-chips {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}

.paste-chip {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-primary);
  background: var(--surface-alt);
  border: 1px solid var(--border-strong);
  padding: 2px 8px;
  border-radius: 3px;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: background 0.08s ease, border-color 0.08s ease;
}
.paste-chip:hover { background: var(--border); border-color: var(--border-strong); }
.paste-chip.recommended {
  border-color: var(--ice);
  color: var(--ice);
}
.paste-chip-conf {
  font-size: 10px;
  color: var(--text-secondary);
  margin-left: 4px;
}

.paste-picker-dismiss {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
}
.paste-picker-dismiss:hover { color: var(--text-primary); }

/* ===== FOOTER =====
   The only chrome below <main>. Go-Playground ethos: editor above,
   a thin line of exits below. 28px tall, no border-top bling, no
   CTA colors — just typography. The "guided tour" link gets a
   subtle arrow that reveals on hover to telegraph "click for more"
   without being a colored button. */
.playground-footer {
  height: 28px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-md);
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 11px;
}

.footer-left { display: flex; align-items: center; min-width: 0; }
.footer-right {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  flex-shrink: 0;
}

/* Primary exit: the tour link. Deliberately UNDERSTATED — no button
   styling, no accent color. The text is the affordance. Hover reveals
   an underline so it reads as a link without shouting on arrival. */
.footer-tour-link {
  color: var(--text-secondary);
  text-decoration: none;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.footer-tour-link:hover { color: var(--text-primary); text-decoration: underline; }
.footer-tour-link > span {
  margin-left: 4px;
  opacity: 0.6;
  transition: transform 120ms ease, opacity 120ms ease;
  display: inline-block;
}
.footer-tour-link:hover > span { opacity: 1; transform: translateX(2px); }

/* Secondary exits: three quiet text links with middle-dot separators.
   Same kurate rule as the Pipeline pane's Docs link — plain color,
   underline on hover, nothing else. */
.footer-link {
  color: var(--text-tertiary);
  text-decoration: none;
  letter-spacing: 0.02em;
}
.footer-link:hover { color: var(--text-primary); text-decoration: underline; }

.footer-sep {
  color: var(--text-tertiary);
  opacity: 0.5;
  user-select: none;
}

/* ===== RESPONSIVE ===== */

@media (max-width: 768px) {
  main { flex-direction: column; }
  .panel-left { border-right: none; border-bottom: 1px solid var(--border); flex: none; height: 50vh; }
  /* Drop the external-links row on tight viewports — the tour link
     is load-bearing, the rest are nice-to-have. Keeps the footer
     readable instead of crammed. */
  .footer-right { display: none; }
}
