:root, [data-theme="light"] {
  color-scheme: light;
  --page: #e7e8eb;
  --bg: #f5f5f7;
  --surface-subtle: #eceef1;
  --surface-selected: #e8eaee;
  --surface-elevated: #ffffff;
  --fg: #24292f;
  --text-soft: #4e535a;
  --muted: #5c6068;
  --attention: #0558b8;
  --live: #186833;
  --idle-dot: #85878d;
  --line: #dfe2e6;
  --line-strong: #c4c9d0;
  --window-shadow: 0 16px 40px rgb(16 18 22 / 0.08), 0 2px 8px rgb(16 18 22 / 0.04);
  --tab-shadow: 0 1px 3px rgb(16 18 22 / 0.08);
}

[data-theme="dark"] {
  color-scheme: dark;
  --page: #242527;
  --bg: #161719;
  --surface-subtle: #1d1f23;
  --surface-selected: #23252a;
  --surface-elevated: #282a30;
  --fg: #f1f1f2;
  --text-soft: #c3c4c7;
  --muted: #9c9ea3;
  --attention: #58a6ff;
  --live: #65c888;
  --idle-dot: #85878d;
  --line: #2a2c31;
  --line-strong: #3c3f46;
  --window-shadow: 0 20px 44px rgb(0 0 0 / 0.36), 0 4px 12px rgb(0 0 0 / 0.2);
  --tab-shadow: 0 1px 3px rgb(0 0 0 / 0.28);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #242527;
    --bg: #161719;
    --surface-subtle: #1d1f23;
    --surface-selected: #23252a;
    --surface-elevated: #282a30;
    --fg: #f1f1f2;
    --text-soft: #c3c4c7;
    --muted: #9c9ea3;
    --attention: #58a6ff;
    --live: #65c888;
    --idle-dot: #85878d;
    --line: #2a2c31;
    --line-strong: #3c3f46;
    --window-shadow: 0 20px 44px rgb(0 0 0 / 0.36), 0 4px 12px rgb(0 0 0 / 0.2);
    --tab-shadow: 0 1px 3px rgb(0 0 0 / 0.28);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  background-color: var(--page);
}

body {
  margin: 0;
  background-color: var(--page);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", sans-serif;
  font-size: 13.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 2px solid var(--attention);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

body[data-layout="full"] .view-panel[hidden] {
  display: block !important;
}

code, pre, kbd, .code-token {
  font-family: Menlo, Consolas, "Courier New", Courier;
  font-size: 0.88em;
}

code {
  background-color: var(--surface-subtle);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.08em 0.38em;
  overflow-wrap: break-word;
}

kbd {
  color: var(--text-soft);
  background-color: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 5px;
  font-size: 11px;
  line-height: 1.45;
}

.num, td.num, th.num {
  font-variant-numeric: tabular-nums;
}

.page-shell {
  max-width: 80rem;
  margin: 0 auto;
  padding: 20px 24px 36px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.top-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 18px;
  padding: 0 2px;
}

.note-brand {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  min-width: 0;
}

h1 {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
  font-weight: 600;
  color: var(--fg);
}

.note-sub {
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
}

.preview-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.pill-track {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 2px;
  background-color: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 14px;
  max-width: 100%;
}

.pill-seg {
  appearance: none;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.25;
  font-weight: 500;
  color: var(--muted);
  background-color: transparent;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 4px 10px;
  min-height: 24px;
  cursor: pointer;
}

.pill-seg:hover {
  color: var(--fg);
  background-color: var(--surface-selected);
}

.pill-seg[aria-pressed="true"],
.pill-seg[aria-selected="true"] {
  background-color: var(--surface-elevated);
  color: var(--fg);
  border-color: var(--line-strong);
  box-shadow: var(--tab-shadow);
  font-weight: 600;
}

.chrome-btn {
  appearance: none;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.25;
  font-weight: 500;
  color: var(--text-soft);
  background-color: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 5px 12px;
  min-height: 28px;
  cursor: pointer;
}

.chrome-btn:hover {
  color: var(--fg);
  border-color: var(--line-strong);
  background-color: var(--surface-selected);
}

.chrome-btn[aria-pressed="true"],
.chrome-btn[aria-expanded="true"] {
  background-color: var(--surface-elevated);
  color: var(--attention);
  border-color: var(--attention);
  font-weight: 600;
}

.stage-window {
  background-color: var(--bg);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--window-shadow);
  overflow: hidden;
  min-width: 0;
}

.window-chrome {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
}

.view-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.vtab {
  appearance: none;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.25;
  font-weight: 500;
  color: var(--muted);
  background-color: var(--surface-subtle);
  border: 1px solid transparent;
  border-radius: 17px;
  height: 34px;
  padding: 0 10px 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.vtab:hover {
  color: var(--fg);
  background-color: var(--surface-selected);
}

.vtab[aria-selected="true"] {
  background-color: var(--surface-elevated);
  color: var(--fg);
  border-color: var(--line-strong);
  box-shadow: var(--tab-shadow);
  font-weight: 600;
}

.key-badge {
  width: 18px;
  height: 18px;
  border-radius: 9px;
  background-color: var(--surface-selected);
  color: var(--muted);
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  flex: none;
}

.vtab[aria-selected="true"] .key-badge {
  background-color: var(--surface-subtle);
  color: var(--fg);
}

body.cmd-held .key-badge {
  background-color: var(--surface-elevated);
  color: var(--attention);
  border: 1px solid var(--attention);
  line-height: 16px;
}

.quota-strip {
  min-height: 28px;
  border-radius: 14px;
  padding: 4px 12px;
  background-color: var(--surface-subtle);
  border: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  font-size: 12px;
  line-height: 1.3;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.quota-item b {
  color: var(--fg);
  font-weight: 600;
}

.view-panel {
  background-color: var(--bg);
  padding: 0;
  min-width: 0;
}

body[data-layout="full"] .view-panel + .view-panel {
  border-top: 2px solid var(--line-strong);
}

.pane-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

h2 {
  margin: 0 0 3px;
  font-size: 15px;
  line-height: 1.35;
  font-weight: 600;
  color: var(--fg);
}

h3 {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.4;
  font-weight: 600;
  color: var(--fg);
}

.view-lead {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

.scenario-bar {
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scenario-summary {
  margin: 0;
  padding: 8px 12px;
  background-color: var(--surface-subtle);
  border-left: 2px solid var(--line-strong);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-soft);
}

.master-detail {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(20rem, 1fr);
  gap: 0;
  align-items: stretch;
}

.master-detail > * {
  min-width: 0;
}

.dag-canvas,
.tier-tree {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lane-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 6px 12px;
  margin-top: 4px;
}

.lane-label {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.lane-row {
  display: grid;
  grid-template-columns: var(--lane-cols, minmax(0, 1fr));
  gap: 4px;
  align-items: stretch;
}

.pipe-h {
  width: 14px;
  height: 1px;
  background-color: var(--line-strong);
  align-self: center;
}

.pipe-v-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 1px 0;
}

.pipe-v {
  width: 1px;
  height: 8px;
  background-color: var(--line-strong);
}

.bridge-token {
  padding: 2px 10px;
  background-color: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--muted);
  text-align: center;
  max-width: 100%;
}

.parallel-fork {
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background-color: var(--surface-subtle);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fork-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--attention);
}

.fork-tracks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 6px;
}

.fork-track-pill {
  padding: 5px 8px;
  background-color: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 11.5px;
  color: var(--text-soft);
  overflow-wrap: anywhere;
}

.dag-node[aria-pressed="true"] .fork-track-pill {
  background-color: var(--bg);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 3px;
  background-color: var(--idle-dot);
  flex: none;
  display: inline-block;
}

.status-dot.is-live {
  background-color: var(--live);
}

.status-dot.is-attention {
  background-color: var(--attention);
}

.dag-node {
  width: 100%;
  appearance: none;
  font-family: inherit;
  text-align: left;
  background-color: var(--surface-subtle);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 11px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dag-node:hover {
  border-color: var(--line-strong);
  background-color: var(--surface-selected);
}

.dag-node[aria-pressed="true"] {
  background-color: var(--surface-elevated);
  border-color: var(--attention);
  box-shadow: var(--tab-shadow);
}

.dag-node-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.dag-node-num {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dag-node[aria-pressed="true"] .dag-node-top {
  color: var(--attention);
}

.state-pill {
  font-size: 11px;
  font-weight: 500;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background-color: var(--bg);
  color: var(--text-soft);
  max-width: 100%;
  overflow-wrap: anywhere;
}

.dag-node-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--fg);
}

.dag-node-sub {
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.loop-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 8px;
  margin-top: 4px;
}

.loop-chip {
  padding: 8px 10px;
  background-color: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--muted);
}

.loop-chip strong {
  display: block;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 2px;
}

.readout-pane {
  border-left: 1px solid var(--line);
  padding: 16px 18px;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.readout-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.readout-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
}

.badge-signal {
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--attention);
  background-color: var(--surface-subtle);
  color: var(--attention);
  max-width: 100%;
  overflow-wrap: anywhere;
}

.token-box {
  padding: 8px 12px;
  background-color: var(--surface-subtle);
  border-left: 2px solid var(--attention);
}

.token-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--attention);
  margin-bottom: 3px;
}

.token-value {
  font-size: 13px;
  line-height: 1.45;
  color: var(--fg);
  overflow-wrap: anywhere;
}

.kv-stack {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kv-item dt {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 2px;
}

.kv-item dd {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--fg);
  overflow-wrap: anywhere;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
