:root {
  --bg: #f4f4f1;
  --bg-2: #ecece8;
  --surface: #ffffff;
  --text: #161615;
  --muted: #6f6f69;
  --line: #e4e4de;
  --line-strong: #d0d0c8;
  --accent: #2f6fed;
  --accent-dim: rgba(47, 111, 237, 0.12);
  --live: #1f7a45;
  --live-dim: rgba(31, 122, 69, 0.12);
  --warn: #9a6700;
  --danger: #b42318;
  --shadow: 0 1px 0 rgba(22, 22, 21, 0.04), 0 8px 24px rgba(22, 22, 21, 0.05);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --chrome: 0px;
  --slates-open: 196px;
  --slates: var(--slates-open);
  --slates-rail: 32px;
  --slates-x: 12px;
  --slates-y: 12px;
  --command: 56px;
  --radius: 10px;
}

[data-theme="dark"] {
  --bg: #101010;
  --bg-2: #171717;
  --surface: #1c1c1c;
  --text: #ecece8;
  --muted: #8a8a82;
  --line: #2a2a28;
  --line-strong: #3a3a36;
  --accent: #6b93f5;
  --accent-dim: rgba(107, 147, 245, 0.16);
  --live: #3ecf8e;
  --live-dim: rgba(62, 207, 142, 0.14);
  --warn: #d4a017;
  --danger: #f07171;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.45;
  overflow: hidden;
}
body {
  display: flex;
}
html.slates-collapsed,
body.slates-collapsed {
  --slates: var(--slates-rail);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 11px;
}
.mono {
  font-family: var(--mono);
  font-size: 12px;
}

/* —— slates rail —— */
.slates {
  position: relative;
  width: var(--slates);
  height: 100%;
  flex-shrink: 0;
  display: flex;
  background: var(--surface);
  border-right: 1px solid var(--line);
  z-index: 20;
  overflow: visible;
  will-change: width, left, top;
  transition: width 0.22s cubic-bezier(0.32, 0.72, 0, 1);
}
html.slates-collapsed .slates,
body.slates-collapsed .slates {
  width: var(--slates-rail);
}
.slates-rail {
  width: var(--slates-rail);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0 12px;
  cursor: grab;
  touch-action: none;
}
.slates-toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: none;
  border: 0;
  padding: 4px 0;
  cursor: grab;
  color: var(--muted);
}
.slates-toggle:hover,
.slates-toggle:focus-visible {
  color: var(--text);
  outline: none;
}
.slates-toggle-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 10px;
}
.slates-body {
  flex: 1;
  min-width: 0;
  width: calc(var(--slates) - var(--slates-rail));
  display: flex;
  flex-direction: column;
  padding: 10px 10px 8px;
  overflow: hidden;
  opacity: 1;
  transform: translateX(0);
  transition:
    opacity 0.16s ease 0.04s,
    transform 0.22s cubic-bezier(0.32, 0.72, 0, 1);
}
html.slates-collapsed .slates-body,
body.slates-collapsed .slates-body {
  opacity: 0;
  width: 0;
  padding: 0;
  overflow: hidden;
  transform: none;
  pointer-events: none;
  transition:
    opacity 0.12s ease,
    width 0.2s cubic-bezier(0.32, 0.72, 0, 1);
}
.slates-resize {
  position: absolute;
  top: 0;
  right: -10px;
  width: 20px;
  height: 100%;
  cursor: ew-resize;
  z-index: 4;
  touch-action: none;
}
.slates-resize::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 9px;
  width: 2px;
  border-radius: 1px;
  background: transparent;
}
.slates-resize:hover::after,
html.slates-resizing .slates-resize::after {
  background: var(--accent);
}
html.slates-right:not(.slates-float) body {
  flex-direction: row-reverse;
}
html.slates-right:not(.slates-float) .slates {
  flex-direction: row-reverse;
  border-right: 0;
  border-left: 1px solid var(--line);
}
html.slates-right:not(.slates-float) .slates-resize {
  left: -10px;
  right: auto;
}
html.slates-right:not(.slates-float) .slates-resize::after {
  left: 9px;
  right: auto;
}
html.slates-float .slates {
  position: fixed;
  left: var(--slates-x);
  top: var(--slates-y);
  height: calc(100vh - var(--slates-y) - 12px);
  min-height: 200px;
  max-height: calc(100vh - 12px);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 28;
}
html.slates-dragging .slates,
html.slates-resizing .slates,
html.slates-dragging .slates-body,
html.slates-resizing .slates-body {
  transition: none;
}
html.slates-dragging,
html.slates-dragging .slates-rail,
html.slates-dragging .slates-toggle {
  cursor: grabbing;
}
html.slates-dragging,
html.slates-resizing {
  user-select: none;
}
html.slates-resizing,
html.slates-resizing * {
  cursor: ew-resize !important;
}
.slate-current {
  flex-shrink: 0;
  min-width: 0;
  margin-bottom: 10px;
}
.slate-current strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.slate-current .muted {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.slate-new {
  flex-shrink: 0;
  align-self: flex-start;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.slate-new:hover,
.slate-new:focus-visible {
  color: var(--text);
  background: none;
  border: 0;
  outline: none;
}
.slate-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-top: 4px;
}
.slates-foot {
  display: flex;
  justify-content: flex-start;
  margin-top: auto;
  padding-top: 10px;
  flex-shrink: 0;
}
.connect-toggle.is-on {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  color: var(--accent);
}
.slate-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.slate-icon svg {
  width: 14px;
  height: 14px;
}
.slate-icon:hover,
.slate-icon:focus-visible {
  color: var(--text);
  outline: none;
}
.library-save {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  flex-shrink: 0;
}
.library-save input,
.library-save select {
  min-width: 0;
  width: 100%;
  max-width: none;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 6px;
  padding: 5px 8px;
  color: var(--text);
}
.library-save select {
  cursor: pointer;
}
.library-save-actions {
  display: flex;
  gap: 10px;
}
.library-save-actions .ghost {
  padding: 0;
  border: 0;
}
.library-save-actions .ghost:hover,
.library-save-actions .ghost:focus-visible,
.library-row .ghost:hover,
.library-row .ghost:focus-visible {
  background: none;
  border: 0;
}
.library-list {
  flex: 0 1 auto;
  min-height: 0;
  max-height: 100%;
  overflow: auto;
  display: flex;
  flex-direction: column;
  position: relative;
}
.library-row {
  display: flex;
  align-items: center;
  margin: 0;
  border: 0;
  padding-left: calc(var(--depth, 0) * 16px);
  cursor: grab;
  user-select: none;
  -webkit-user-drag: none;
  border-radius: 6px;
}
.library-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: none;
  border: 0;
  padding: 5px 2px;
  text-align: left;
  cursor: inherit;
  color: inherit;
}
.library-row.is-folder .library-row-main {
  justify-content: flex-start;
  gap: 6px;
}
.library-ico {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.7;
  pointer-events: none;
}
.library-rename {
  flex: 1;
  min-width: 0;
  height: 22px;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 0 2px;
  outline: none;
  cursor: text;
  user-select: text;
}
.library-row.is-creating,
.library-row.is-renaming {
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--line);
}
.library-row.is-creating {
  animation: library-in 0.16s ease;
}
@keyframes library-in {
  from {
    opacity: 0;
    transform: translateY(-3px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.library-row.is-dragging {
  opacity: 0.32;
}
.library-row.is-drag-hidden {
  display: none;
}
.library-row.is-drop-into {
  background: var(--accent-dim);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
}
.library-drop-line {
  position: absolute;
  right: 4px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
  pointer-events: none;
  z-index: 5;
}
.library-drop-line::before {
  content: "";
  position: absolute;
  left: -5px;
  top: -3px;
  width: 8px;
  height: 8px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--surface);
}
.library-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow), 0 0 0 1px var(--line);
  pointer-events: none;
  opacity: 0.92;
  font-size: 13px;
}
.library-ghost .library-ico {
  opacity: 0.85;
}
.library-ghost strong {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.library-ghost .muted {
  font-size: 11px;
}
body.is-library-dragging,
body.is-library-dragging .library-row {
  cursor: grabbing;
}
body.is-library-dragging {
  user-select: none;
}
.library-row-main strong {
  font-size: 13px;
  font-weight: 450;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.library-row-main .muted {
  flex-shrink: 0;
  max-width: 46%;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.library-row.is-active strong {
  font-weight: 600;
}
.library-row .ghost {
  flex-shrink: 0;
  opacity: 0;
  padding: 0 2px;
  border: 0;
  cursor: pointer;
}
.library-row:hover .ghost,
.library-row:focus-within .ghost {
  opacity: 1;
}

.mark {
  width: 7px;
  height: 7px;
  border-radius: 1.5px;
  background: var(--muted);
}
body.is-live .mark {
  background: var(--live);
  box-shadow: 0 0 0 4px var(--live-dim);
}

.brand {
  font-weight: 600;
  letter-spacing: -0.02em;
}

.chrome-metric {
  font-family: var(--mono);
  font-size: 12px;
}

.ghost,
.ghost-select {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--muted);
}
.ghost:hover,
.ghost-select:hover,
.ghost:focus-visible {
  border-color: var(--line);
  color: var(--text);
  background: var(--surface);
  outline: none;
}
a.ghost {
  display: inline-block;
  text-decoration: none;
}

.ghost-select {
  max-width: 180px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
  background: var(--bg-2);
}
.pill-live {
  color: var(--live);
  border-color: color-mix(in srgb, var(--live) 35%, var(--line));
  background: var(--live-dim);
}
.pill-warn {
  color: var(--warn);
}
.pill-pass {
  color: var(--live);
  background: var(--live-dim);
  border-color: transparent;
}
.pill-fail {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  border-color: transparent;
}
.pill-active {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: transparent;
}
.pill-done,
.pill-pending {
  background: var(--bg-2);
}

/* —— board —— */
.app-main {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}
.board {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  cursor: grab;
  outline: none;
  touch-action: none;
}
.board.is-panning,
.board.is-drag {
  cursor: grabbing;
}
.board.is-selecting,
.board.is-selecting * {
  cursor: crosshair !important;
}
.board.is-connecting {
  cursor: crosshair;
}
.board.is-connecting .node,
.board.is-connecting .node-bar {
  cursor: crosshair;
}
.board.is-drop-target {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.drop-hint {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  z-index: 4;
  pointer-events: none;
  color: var(--text);
  font-size: 16px;
}
.board.is-drop-target .empty-hint {
  opacity: 0;
}

.board-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(var(--line-strong) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: 0.55;
}

.world {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.wires {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  overflow: visible;
  pointer-events: none;
  z-index: 0;
}
.wire-hull {
  fill: color-mix(in srgb, var(--accent) 7%, transparent);
  stroke: color-mix(in srgb, var(--accent) 40%, var(--line));
  stroke-width: 1.25;
  stroke-dasharray: 5 4;
  pointer-events: none;
}
.wire {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.75;
  stroke-linecap: round;
  pointer-events: stroke;
  cursor: pointer;
}
.wire.is-selected {
  stroke: var(--accent);
  stroke-width: 2.25;
}
.wire-preview {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-dasharray: 6 4;
  pointer-events: none;
}
.wire-port {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 1.25;
  pointer-events: none;
}
.wire-tip {
  fill: var(--muted);
}
.wire-tip.is-selected {
  fill: var(--accent);
}

.empty-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  pointer-events: none;
  color: var(--text);
  letter-spacing: -0.02em;
  padding-bottom: calc(var(--command) + 12px);
}
.empty-hint p {
  margin: 0;
  font-size: 15px;
}
.empty-hint .muted {
  margin-top: 6px;
  font-size: 12px;
}
.empty-hint[hidden] {
  display: none;
}

/* —— nodes —— */
.node {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 160px;
  min-height: 56px;
  color: var(--text);
  cursor: default;
}
.node.is-link-from {
  outline: 1.5px solid var(--accent);
  outline-offset: 2px;
}
.node.is-link-target {
  outline: 1.5px dashed var(--accent);
  outline-offset: 2px;
}
.node.is-selected {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent), var(--shadow);
}
.node.is-primary {
  box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--accent) 70%, transparent), var(--shadow);
}
.node.is-arranging {
  transition:
    left 0.22s cubic-bezier(0.32, 0.72, 0, 1),
    top 0.22s cubic-bezier(0.32, 0.72, 0, 1),
    width 0.22s cubic-bezier(0.32, 0.72, 0, 1),
    height 0.22s cubic-bezier(0.32, 0.72, 0, 1);
}
.node.is-dragging {
  opacity: 0.96;
}
.node.is-drop {
  border-color: var(--accent);
}
.node.is-collapsed {
  min-height: 32px;
}
.node.is-collapsed .node-body,
.node.is-collapsed .handle {
  display: none;
}
.node.is-collapsed .node-bar {
  border-bottom: 0;
}

.node-bar {
  height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 10px;
  border-bottom: 1px solid var(--line);
  cursor: grab;
  user-select: none;
  background: color-mix(in srgb, var(--bg) 55%, var(--surface));
}
.node-bar:active {
  cursor: grabbing;
}
.node-title {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 550;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.node-dataset {
  flex: 0 1 auto;
  max-width: 28%;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.node-follow {
  color: var(--muted);
  font-size: 10px;
  font-family: var(--mono);
  max-width: 36%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.node-bar .ghost {
  padding: 2px 6px;
  font-size: 12px;
}

.node-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
}

.node-tools {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}

.note-body {
  flex: 1;
  min-height: 0;
  display: flex;
}
.note-body textarea {
  flex: 1;
  width: 100%;
  min-height: 0;
  resize: none;
  border: 0;
  background: transparent;
  padding: 0;
  outline: none;
  line-height: 1.5;
}
.log-compose {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.log-compose input {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 8px;
  padding: 6px 8px;
}
tr.is-active td {
  background: var(--accent-dim);
}

.node-body:has(.media-fill),
.node-body:has(.media-pdf) {
  padding: 0;
  overflow: hidden;
}
.media-fill {
  width: 100%;
  height: 100%;
  min-height: 0;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: color-mix(in srgb, var(--text) 5%, transparent);
}
.media-fill img,
.media-fill video {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.media-fill.media-video {
  background: #111;
}
.media-pdf {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  flex: 1;
  border: none;
  background: var(--bg);
}
.media-file-name {
  margin: 0 0 6px;
  font-weight: 600;
}

.handle {
  position: absolute;
  z-index: 2;
}
.handle.n,
.handle.s {
  left: 12px;
  right: 12px;
  height: 6px;
  cursor: ns-resize;
}
.handle.e,
.handle.w {
  top: 12px;
  bottom: 12px;
  width: 6px;
  cursor: ew-resize;
}
.handle.n {
  top: -2px;
}
.handle.s {
  bottom: -2px;
}
.handle.e {
  right: -2px;
}
.handle.w {
  left: -2px;
}
.handle.nw,
.handle.ne,
.handle.sw,
.handle.se {
  width: 10px;
  height: 10px;
}
.handle.nw {
  top: -2px;
  left: -2px;
  cursor: nwse-resize;
}
.handle.ne {
  top: -2px;
  right: -2px;
  cursor: nesw-resize;
}
.handle.sw {
  bottom: -2px;
  left: -2px;
  cursor: nesw-resize;
}
.handle.se {
  bottom: -2px;
  right: -2px;
  cursor: nwse-resize;
}

/* —— widgets —— */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
}
.stat {
  min-width: 0;
}
.kpi {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
  min-height: 0;
  gap: 2px;
}
.kpi .k {
  color: var(--muted);
  font-size: 11px;
}
.kpi .v {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.kpi .s {
  color: var(--muted);
  font-size: 11px;
}
.kpi.is-live .v {
  color: var(--live);
}
.kpi.is-warn .v {
  color: var(--warn);
}
.kpi.is-muted .v {
  color: var(--muted);
}

.card-head {
  margin-bottom: 8px;
}
.card-head .v {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.card-head .s {
  color: var(--muted);
  font-size: 11px;
}

.caption-body {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
}
.caption-body input {
  width: 100%;
  border: 0;
  background: transparent;
  font-size: 16px;
  font-weight: 550;
  letter-spacing: -0.02em;
  outline: none;
  padding: 0;
}
.node[data-type="caption"] .node-body {
  padding: 6px 12px 10px;
}

.check-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.check-item:hover {
  background: var(--bg);
}
.check-mark {
  width: 14px;
  height: 14px;
  border: 1px solid var(--line-strong, var(--line));
  border-radius: 4px;
  flex: 0 0 auto;
  background: var(--bg);
}
.check-item.is-done .check-mark {
  background: var(--accent);
  border-color: var(--accent);
}
.check-item.is-done .check-text {
  color: var(--muted);
  text-decoration: line-through;
}
.check-text {
  flex: 1;
  min-width: 0;
}
.check-item .ghost {
  opacity: 0;
  padding: 0 6px;
}
.check-item:hover .ghost,
.check-item .ghost:focus-visible {
  opacity: 1;
}

.stat .k {
  color: var(--muted);
  font-size: 11px;
}
.stat .v {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.stat .s {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.launch-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
}
.launch-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.launch-field span {
  color: var(--muted);
  font-size: 11px;
}
.launch-field input,
.launch-field .ghost-select {
  width: 100%;
  max-width: none;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 6px;
  padding: 5px 8px;
}
.launch-field input:focus,
.launch-field .ghost-select:focus-visible {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}
.launch-status {
  grid-column: 1 / -1;
  margin: 2px 0 0;
}
.launch-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
}
.launch-go {
  color: var(--text);
  border-color: var(--line-strong);
}
.launch-go:disabled,
.launch-actions .ghost:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
}
.kv span {
  color: var(--muted);
}
.kv strong {
  font-weight: 550;
  text-align: right;
}

.bar {
  height: 6px;
  border-radius: 99px;
  background: var(--bg-2);
  overflow: hidden;
  border: none;
  padding: 0;
  width: 100%;
}
.bar-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: inherit;
}
body.is-live .bar-fill {
  background: var(--live);
}

.metric-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.chip {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 7px;
  background: var(--bg);
}
.chip .k {
  display: block;
  color: var(--muted);
  font-size: 10px;
}
.chip .v {
  font-family: var(--mono);
  font-size: 12px;
}
.delta-pos .v {
  color: var(--live);
}
.delta-neg .v {
  color: var(--danger);
}

.table-wrap {
  overflow: auto;
  max-height: 100%;
  flex: 1;
  min-height: 0;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
th,
td {
  text-align: left;
  padding: 5px 6px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th {
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  position: sticky;
  top: 0;
  background: var(--surface);
}
tr[data-run-id] {
  cursor: pointer;
}
tr[data-run-id]:hover {
  background: var(--bg);
}
tr.is-selected {
  background: var(--accent-dim);
}
tr.is-best td:first-child {
  color: var(--accent);
}

.filter,
.run-note,
.inspector-body input[type="text"],
.inspector-body input[type="search"],
.inspector-body textarea,
.inspector-body select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 6px;
  padding: 5px 8px;
}

.empty-block {
  color: var(--muted);
  font-size: 12px;
  padding: 12px 0;
}
.empty-block code,
.help kbd,
.cmd-hint,
.node-body code {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 4px;
}

.log {
  margin: 0;
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  flex: 1;
  overflow: auto;
}
.log-line {
  display: block;
  cursor: pointer;
}
.log-line:hover {
  background: var(--bg);
}
.log-err {
  color: var(--danger);
}
.log-warn {
  color: var(--warn);
}
.log-ok {
  color: var(--live);
}

.findings h3,
.findings h4 {
  margin: 14px 0 6px;
  font-size: 12px;
}
.findings {
  flex: 1;
  overflow: auto;
}
.findings p,
.findings li {
  margin: 0 0 6px;
  color: var(--text);
}
.findings .hl {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
}

.chart-host {
  position: relative;
  flex: 1;
  min-height: 160px;
}
.chart-host canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.stats-kpis {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: minmax(110px, 1fr) minmax(120px, 1fr);
  gap: 8px;
  flex: 1;
  min-height: 220px;
  margin: 8px 0;
}
.stats-grid .chart-host {
  min-height: 0;
  flex: unset;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
}
.chart-tip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 7px;
  font-family: var(--mono);
  font-size: 11px;
  box-shadow: var(--shadow);
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}
.preview-grid figure {
  margin: 0;
}
.preview-grid img {
  width: 100%;
  border-radius: 6px;
  display: block;
  border: 1px solid var(--line);
  cursor: zoom-in;
}
.preview-grid figcaption {
  color: var(--muted);
  font-size: 10px;
  margin-top: 4px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.q-chip,
.anomaly-chip {
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 99px;
  padding: 2px 8px;
  cursor: pointer;
  color: var(--muted);
}
.q-chip.on,
.anomaly-chip.is-active {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-dim);
}

/* —— command / menus —— */
.marquee {
  position: absolute;
  border: 1px solid var(--accent);
  background: var(--accent-dim);
  pointer-events: none;
  z-index: 40;
}

.nudge {
  position: absolute;
  left: 50%;
  bottom: calc(var(--command) + 18px);
  transform: translateX(-50%);
  z-index: 28;
  max-width: 720px;
  width: calc(100% - 32px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.nudge span {
  flex: 1;
}

.command {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  height: auto;
  width: min(720px, calc(100% - 32px));
  max-width: 720px;
  margin: 0;
  padding: 0;
}
.command .prompt {
  color: var(--muted);
  font-family: var(--mono);
}
#cmd-input {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 9px 48px 9px 12px;
  box-shadow: var(--shadow);
  outline: none;
}
#cmd-input:focus {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
}
#cmd-input:focus + .cmd-hint {
  display: none;
}
.cmd-hint {
  position: absolute;
  right: 12px;
  color: var(--muted);
  pointer-events: none;
}

.cmd-menu,
.menu {
  position: fixed;
  z-index: 50;
  min-width: 220px;
  max-width: 360px;
  max-height: 360px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
}
.cmd-item,
.menu button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 7px;
  padding: 7px 8px;
  cursor: pointer;
}
.cmd-item:hover,
.cmd-item.is-active,
.menu button:hover {
  background: var(--bg);
}
.cmd-item .meta,
.menu .group {
  color: var(--muted);
  font-size: 11px;
}
.menu .group {
  padding: 8px 8px 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.menu-cat {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.menu-cat .meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.menu-cat .meta i {
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-top: 4px solid currentColor;
  opacity: 0.7;
  transform: rotate(-90deg);
  transition: transform 0.14s cubic-bezier(0.32, 0.72, 0, 1);
}
.menu-cat.is-open,
.menu-cat:hover {
  color: var(--text);
}
.menu-cat.is-open .meta i {
  transform: rotate(0deg);
}
.menu-add {
  padding-left: 16px;
}

.toast {
  position: fixed;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 7px 12px;
  border-radius: 8px;
  z-index: 60;
  font-size: 12px;
}

.help {
  position: fixed;
  right: 16px;
  bottom: 72px;
  width: 280px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  z-index: 55;
}
.help h3 {
  margin: 0 0 8px;
  font-size: 13px;
}
.help ul {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}
.help li {
  margin: 6px 0;
  color: var(--muted);
}

.inspector {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 260px;
  max-height: calc(100% - var(--command) - 36px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 25;
  padding: 10px 12px 14px;
}
.inspector-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.inspector-body label {
  display: block;
  margin: 8px 0;
  color: var(--muted);
  font-size: 11px;
}
.inspector-body .row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 6px 0;
}

/* —— explore overlay —— */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 40;
  display: flex;
  flex-direction: column;
  padding: 16px 20px 0;
}
.overlay-bar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 12px;
}
.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.overlay-bar h2 {
  margin: 2px 0 0;
  font-size: 20px;
  letter-spacing: -0.03em;
}
.overlay-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.explore-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}
.explore-kpis.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.explore-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.explore-filters .filter {
  width: 220px;
}
.explore-grid-viewport {
  flex: 1;
  overflow: auto;
  min-height: 80px;
  padding-bottom: 8px;
}
.node:not(.is-expanded) .explore-grid {
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
}
.node.is-expanded .explore-grid {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
.explore-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.explore-card {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  cursor: pointer;
}
.explore-card.is-selected {
  border-color: var(--accent);
}
.explore-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}
.explore-card figcaption {
  padding: 6px 8px;
  font-size: 11px;
  color: var(--muted);
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.72);
  z-index: 70;
  display: grid;
  place-items: center;
}
.lightbox-media {
  position: relative;
  max-width: min(92vw, 1100px);
  max-height: 80vh;
}
.lightbox-media img {
  max-width: 92vw;
  max-height: 80vh;
  display: block;
}
.lightbox-media canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  color: #fff;
}
#lightbox-cap {
  position: absolute;
  bottom: 20px;
  color: #ddd;
}

.run-link {
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--muted) 50%, transparent);
  text-underline-offset: 3px;
}
.run-link:hover,
.run-link:focus-visible {
  color: var(--accent);
  text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent);
  outline: none;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 72;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--text) 28%, transparent);
}
.sheet-panel {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  max-height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.sheet-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
}
.sheet-head h2 {
  margin: 2px 0 0;
  font-size: 20px;
  letter-spacing: -0.03em;
}
.sheet-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.sheet-body {
  overflow: auto;
  padding: 12px 18px 20px;
  min-height: 0;
}
.sheet-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
  margin: 0 0 16px;
}
.sheet-section {
  margin: 0 0 16px;
}
.sheet-section h3 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 550;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.sheet-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 24px;
}
.xform-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 20px;
}
.xform {
  min-width: 0;
}
.xform-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  margin-bottom: 4px;
}
.xform-head span {
  color: var(--muted);
}
.xform.is-off {
  opacity: 0.45;
}
.sheet-note {
  margin: 0;
  color: var(--text);
  white-space: pre-wrap;
}
.sheet-loss-legend {
  display: flex;
  gap: 14px;
  margin: 0 0 8px;
  font-size: 11px;
  color: var(--muted);
}
.sheet-loss-legend .leg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sheet-loss-legend .leg::before {
  content: "";
  width: 14px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
}
.leg-box {
  color: var(--text);
}
.leg-cls {
  color: var(--accent);
}
.leg-dfl {
  color: var(--muted);
}
.sheet-loss-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 8px;
}
.sheet-chart-label {
  margin: 0 0 4px;
  font-size: 11px;
  color: var(--muted);
}
.sheet-chart-host {
  height: 148px;
  min-height: 148px;
  flex: unset;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
}
@media (max-width: 640px) {
  .sheet-grid,
  .xform-grid,
  .sheet-loss-grid {
    grid-template-columns: 1fr;
  }
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

@media (prefers-reduced-motion: reduce) {
  .slates,
  .slates-body,
  .node.is-arranging {
    transition: none;
  }
}

@media (max-width: 720px) {
  .stat-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .inspector {
    display: none;
  }
  .explore-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
