:root {
  --black: #0a0a0a;
  --ink: #1a1a1a;
  --mid: #4d4d4d;
  --soft: #8c8c8c;
  --line: #e5e5e5;
  --off: #f5f5f5;
  --white: #fff;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: "Arial Black", "Helvetica Neue", var(--sans);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sidebar: 224px;
  --log: 320px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light; scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--white); color: var(--black); font-family: var(--sans); font-size: 14px; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.app-shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr) var(--log); min-height: 100vh; }
.sidebar { position: sticky; top: 0; z-index: 20; display: flex; height: 100vh; flex-direction: column; padding: 28px 20px 22px; background: var(--black); color: var(--white); }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; font: 800 24px/1 var(--display); letter-spacing: -.04em; text-decoration: none; }
.brand-mark { width: 25px; height: 25px; border: 2px solid var(--white); background: linear-gradient(135deg, transparent 43%, var(--white) 44% 55%, transparent 56%); }
.brand-note { margin: 8px 0 40px 36px; color: #aaa; font: 10px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.module-nav { display: grid; gap: 4px; }
.nav-item { display: grid; grid-template-columns: 35px 1fr; min-height: 48px; align-items: center; border: 1px solid transparent; background: transparent; color: #bbb; text-align: left; cursor: pointer; }
.nav-item:hover, .nav-item.is-active { border-color: var(--white); background: var(--white); color: var(--black); }
.nav-index { font: 10px var(--mono); }
.sidebar-actions { display: grid; gap: 8px; margin-top: auto; }
.runtime-status { display: grid; gap: 8px; margin: 24px 0 0; padding-top: 18px; border-top: 1px solid #444; }
.runtime-status div { display: flex; justify-content: space-between; gap: 8px; }
.runtime-status dt { color: #999; }
.runtime-status dd { margin: 0; font: 11px var(--mono); text-align: right; }
#connection-status::before { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border: 1px solid currentColor; border-radius: 50%; content: ""; }
#connection-status[data-state="online"]::before { background: currentColor; }
#connection-status[data-state="offline"] { color: #aaa; }

.main { min-width: 0; padding: 30px clamp(22px, 3vw, 48px) 70px; transition: opacity .2s ease, transform .2s ease; }
body.presentation-shift .main { opacity: .35; transform: translateY(7px); }
.pulse-header { margin-bottom: 28px; border-bottom: 2px solid var(--black); }
.pulse-heading, .section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; }
.pulse-heading h1, .section-heading h2, .log-heading h2, .dialog-heading h2 { margin: 3px 0 0; font: 800 clamp(22px, 3vw, 36px)/1 var(--display); letter-spacing: -.045em; text-transform: uppercase; }
.eyebrow { margin: 0; color: var(--mid); font: 700 10px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; }
#pulse-canvas { display: block; width: 100%; height: 72px; margin-top: 10px; }
.log-trigger { display: none; }
.mobile-nav { display: none; }
.mobile-global-actions { display: none; }
.module[hidden] { display: none !important; }
.module { animation: enter .2s ease-out both; }
.section-heading { margin-bottom: 22px; }
.section-heading h2 { font-size: clamp(28px, 4vw, 52px); }
.module-summary { max-width: 58ch; margin: 9px 0 0; color: var(--mid); font-size: 12px; line-height: 1.45; }

.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; padding: 9px 15px; border: 1px solid var(--black); background: var(--white); color: var(--black); font-weight: 700; line-height: 1.1; text-decoration: none; cursor: pointer; }
.button:hover, .button:focus-visible, .button-dark { background: var(--black); color: var(--white); }
.button-dark:hover, .button-dark:focus-visible { background: var(--white); color: var(--black); }
.button-light { border-color: var(--white); background: var(--white); color: var(--black); }
.button-light:hover { background: var(--black); color: var(--white); }
.button-ghost-dark { border-color: #555; background: transparent; color: var(--white); }
.button-ghost-dark:hover { border-color: var(--white); background: var(--white); color: var(--black); }
.button:disabled { border-color: var(--line); background: var(--off); color: var(--soft); cursor: not-allowed; }

.process-lanes { display: grid; border: 1px solid var(--black); }
.process-lane { display: grid; grid-template-columns: 112px minmax(0, 1fr); min-height: 94px; border-bottom: 1px solid var(--black); }
.process-lane:last-child { border-bottom: 0; }
.lane-label { display: flex; flex-direction: column; justify-content: space-between; padding: 15px; border-right: 1px solid var(--black); font-weight: 800; text-transform: uppercase; }
.lane-label b { font: 22px var(--mono); }
.lane-track { display: flex; min-width: 0; align-items: center; gap: 8px; overflow-x: auto; padding: 13px; }
.empty-state { margin: auto; color: var(--soft); font-size: 12px; }
.process-chip { flex: 0 0 auto; min-width: 76px; padding: 12px; border: 2px solid var(--black); background: var(--white); text-align: center; transition: transform .24s ease-out, opacity .2s; }
.process-chip strong { display: block; font: 800 15px var(--mono); }
.process-chip small { display: block; margin-top: 5px; color: var(--mid); font: 10px var(--mono); }
.process-chip[data-state="RUNNING"] { background: var(--black); color: var(--white); }
.process-chip[data-state="RUNNING"] small { color: var(--line); }
.process-chip[data-state="WAITING"] { background: repeating-linear-gradient(135deg, var(--white) 0 5px, var(--line) 5px 7px); }
.process-chip[data-state="TERMINATED"] { position: relative; border-color: var(--soft); background: var(--line); opacity: .62; }
.process-chip[data-state="TERMINATED"]::after { position: absolute; inset: 50% 4px auto; height: 1px; background: var(--black); content: ""; transform: rotate(-10deg); }

.table-wrap { width: 100%; margin-top: 20px; overflow-x: auto; border: 1px solid var(--black); }
table { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
th { background: var(--black); color: var(--white); font-size: 10px; letter-spacing: .08em; text-align: left; text-transform: uppercase; }
th, td { height: 44px; padding: 9px 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
th:last-child, td:last-child { border-right: 0; }
tr:last-child td { border-bottom: 0; }
td { font-family: var(--mono); }
.table-empty { color: var(--soft); font-family: var(--sans); text-align: center; }
.state-badge { display: inline-block; min-width: 74px; padding: 4px 7px; border: 1px solid var(--black); font: 700 9px var(--mono); text-align: center; }
.state-badge[data-state="RUNNING"] { background: var(--black); color: var(--white); }
.state-badge[data-state="WAITING"] { background: repeating-linear-gradient(135deg, var(--white) 0 4px, var(--line) 4px 6px); }
.state-badge[data-state="TERMINATED"] { border-color: var(--soft); background: var(--line); text-decoration: line-through; }
.row-actions { display: flex; gap: 5px; }
.row-action { min-height: 28px; padding: 3px 7px; border: 1px solid var(--black); background: var(--white); font: 10px var(--sans); font-weight: 700; cursor: pointer; }
.row-action:hover { background: var(--black); color: var(--white); }

.metric-inline, .memory-metrics { display: flex; gap: 26px; }
.metric-inline { flex-direction: column; gap: 3px; text-align: right; }
.metric-inline span, .memory-metrics span { color: var(--mid); font-size: 10px; text-transform: uppercase; }
.metric-inline strong, .memory-metrics strong { display: block; margin-top: 4px; font: 800 18px var(--mono); }
.control-card { display: flex; align-items: end; gap: 24px; margin-bottom: 20px; padding: 18px; border: 1px solid var(--black); background: var(--off); }
.control-group { display: grid; gap: 8px; }
.control-wide { flex: 1; }
.control-label, .range-control span, .number-control { font-size: 11px; font-weight: 700; text-transform: uppercase; }
.segmented { display: inline-flex; flex-wrap: wrap; }
.segmented button { min-height: 38px; padding: 8px 16px; border: 1px solid var(--black); border-right: 0; background: var(--white); cursor: pointer; }
.segmented button:last-child { border-right: 1px solid var(--black); }
.segmented button:hover, .segmented button.is-active { background: var(--black); color: var(--white); }
.range-control { display: grid; min-width: 200px; gap: 9px; }
.range-control span { display: flex; justify-content: space-between; gap: 12px; }
output { font-family: var(--mono); font-weight: 400; text-transform: none; }
input[type="range"] { width: 100%; accent-color: var(--black); }
input[type="range"]:disabled { opacity: .35; }
.canvas-panel { position: relative; min-height: 185px; overflow-x: hidden; border: 1px solid var(--black); background-image: linear-gradient(var(--line) 1px, transparent 1px); background-size: 100% 32px; }
.canvas-panel canvas { display: block; width: 100%; height: 185px; }
.canvas-empty { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: var(--soft); pointer-events: none; }
.action-bar { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin-top: 20px; padding: 14px; border: 1px solid var(--black); }
.speed-control { min-width: 210px; margin-left: auto; }

.counter { max-width: 100%; overflow: hidden; font: 800 clamp(24px, 4vw, 46px)/1 var(--mono); letter-spacing: -.05em; text-overflow: ellipsis; }
.sync-controls { display: grid; grid-template-columns: 1.3fr 1fr 1fr; align-items: center; }
.mode-control { display: flex; gap: 9px; margin: 0; padding: 0; border: 0; }
.mode-control legend { margin-bottom: 9px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.mode-control label { position: relative; display: grid; min-width: 112px; padding: 9px 12px 9px 32px; border: 1px solid var(--black); background: var(--white); cursor: pointer; }
.mode-control input { position: absolute; top: 14px; left: 11px; accent-color: var(--black); }
.mode-control label:has(input:checked) { background: var(--black); color: var(--white); }
.mode-control small { margin-top: 2px; color: var(--soft); font-size: 10px; }
.worker-panel { min-height: 190px; padding: 16px; border: 1px solid var(--black); }
.worker-header { display: flex; justify-content: space-between; margin-bottom: 13px; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.worker-strips { display: grid; gap: 6px; }
.worker-row { display: grid; grid-template-columns: 70px 1fr; align-items: center; gap: 10px; font: 10px var(--mono); }
.worker-bar { height: 12px; border: 1px solid var(--black); background: var(--white); transition: background .08s; }
.worker-row.is-active .worker-bar { background: var(--black); }
.worker-row.is-holder .worker-bar { background: repeating-linear-gradient(90deg, var(--black) 0 9px, var(--white) 9px 11px); }

.memory-metrics { text-align: right; }
.memory-controls { align-items: end; }
.number-control { display: grid; min-width: 135px; gap: 8px; }
input[type="number"], input[type="text"], select { width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid var(--black); border-radius: 0; background: var(--white); color: var(--black); font-family: var(--mono); }
.memory-panel { min-height: 240px; background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 24px 24px; }
.memory-panel canvas { height: 240px; }
.memory-legend { display: flex; flex-wrap: wrap; gap: 15px; padding: 10px 0; font: 10px var(--mono); }
.memory-legend span { display: inline-flex; align-items: center; gap: 6px; }
.memory-legend i { width: 13px; height: 13px; border: 1px solid var(--black); }
.legend-free { background: var(--white); }

.live-log { position: sticky; top: 0; z-index: 30; display: flex; height: 100vh; min-width: 0; flex-direction: column; padding: 26px 18px 18px; background: var(--ink); color: var(--white); }
.log-heading { display: flex; align-items: flex-start; justify-content: space-between; }
.log-heading .eyebrow { color: #aaa; }
.log-heading h2 { font-size: 27px; }
.icon-button { display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid currentColor; background: transparent; color: inherit; font-size: 25px; line-height: 1; cursor: pointer; }
#log-close { display: none; }
.log-toolbar { display: flex; min-height: 54px; align-items: center; justify-content: space-between; margin-top: 18px; border-block: 1px solid #444; }
.switch { font-size: 11px; }
.switch input { margin: 0 7px 0 0; accent-color: var(--white); }
.text-button { border: 0; background: transparent; color: #bbb; font-size: 11px; text-decoration: underline; cursor: pointer; }
.filter-chips { display: flex; gap: 5px; overflow-x: auto; padding: 13px 0; }
.filter-chips button { flex: 0 0 auto; padding: 5px 8px; border: 1px solid #555; background: transparent; color: #bbb; font-size: 10px; cursor: pointer; }
.filter-chips button.is-active { border-color: var(--white); background: var(--white); color: var(--black); }
.log-list { display: flex; min-height: 0; flex: 1; flex-direction: column; gap: 12px; margin: 0; overflow-y: auto; padding: 5px 4px 20px 0; list-style: none; }
.log-list li { padding-left: 10px; border-left: 2px solid #555; color: #ddd; font: 10px/1.55 var(--mono); overflow-wrap: anywhere; }
.log-list time { display: block; margin-bottom: 2px; color: #888; }
.log-placeholder { margin-top: 20px; border: 0 !important; color: #888 !important; text-align: center; }
.scrim { display: none; }

dialog { width: min(460px, calc(100vw - 30px)); padding: 0; border: 2px solid var(--black); border-radius: 0; box-shadow: 16px 16px 0 rgba(0,0,0,.2); }
dialog::backdrop { background: rgba(0,0,0,.7); }
#process-form { display: grid; gap: 17px; padding: 23px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; }
.dialog-heading h2 { font-size: 29px; }
#process-form > label { display: grid; gap: 7px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.input-row { display: grid; grid-template-columns: 1fr 58px; align-items: center; border: 1px solid var(--black); }
.input-row input { border: 0; }
.input-row small { font: 10px var(--mono); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.form-message { min-height: 18px; margin: -4px 0; color: var(--mid); font-size: 12px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 100; max-width: min(360px, calc(100vw - 48px)); padding: 12px 15px; background: var(--black); color: var(--white); font-size: 12px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: .2s; }
.toast.is-visible { opacity: 1; transform: none; }

.presentation-launch { position: fixed; right: 24px; bottom: 24px; z-index: 110; min-height: 48px; box-shadow: 8px 8px 0 rgba(255,255,255,.22); }
.presentation-panel { position: fixed; top: 16px; left: 16px; z-index: 120; display: grid; width: min(420px, calc(100vw - 32px)); max-height: calc(100vh - 32px); grid-template-rows: auto auto minmax(0, 1fr) auto; overflow: hidden; padding: 20px; border: 2px solid var(--white); background: var(--black); color: var(--white); box-shadow: 14px 14px 0 rgba(0,0,0,.24); opacity: 0; transform: translateY(18px) scale(.98); transition: opacity .24s ease, transform .28s ease-out, top .28s ease-out, left .28s ease-out; }
.presentation-panel.is-open { opacity: 1; transform: none; }
.presentation-panel.is-dragging { box-shadow: 8px 8px 0 rgba(0,0,0,.2); transition: none; }
.presentation-topline { display: flex; min-height: 30px; align-items: center; justify-content: space-between; gap: 18px; color: #bbb; font: 700 10px var(--mono); letter-spacing: .14em; cursor: grab; touch-action: none; user-select: none; }
.presentation-panel.is-dragging .presentation-topline { cursor: grabbing; }
.presentation-drag-label { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 12px; }
.presentation-drag-hint { color: #777; font-size: 8px; }
.presentation-close { display: grid; width: 32px; height: 32px; place-items: center; padding: 0; border: 1px solid #777; background: transparent; color: var(--white); font-size: 21px; cursor: pointer; }
.presentation-close:hover, .presentation-close:focus-visible { border-color: var(--white); background: var(--white); color: var(--black); }
.presentation-meter { height: 3px; margin: 7px 0 16px; overflow: hidden; background: #444; }
.presentation-meter span { display: block; width: 0; height: 100%; background: var(--white); transition: width .35s ease-out; }
.presentation-copy-wrap { min-height: 0; overflow-y: auto; }
.presentation-panel h2 { margin: 0; font: 800 clamp(22px, 3vw, 34px)/1 var(--display); letter-spacing: -.035em; text-transform: uppercase; }
.presentation-label { display: block; margin-top: 14px; color: #999; font: 700 9px var(--mono); letter-spacing: .14em; }
.presentation-panel p { max-width: 55ch; margin: 5px 0 18px; color: #eee; font-size: 15px; line-height: 1.5; }
.presentation-actions { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding-top: 15px; border-top: 1px solid #555; }
.presentation-observe { display: grid; gap: 4px; }
.presentation-observe b { color: #888; font: 700 9px var(--mono); letter-spacing: .12em; }
.presentation-observe span { color: #ddd; font: 11px/1.4 var(--mono); }
.presentation-next { min-width: 150px; min-height: 48px; padding: 10px 18px; border: 1px solid var(--white); background: var(--white); color: var(--black); font-weight: 800; cursor: pointer; }
.presentation-next:hover, .presentation-next:focus-visible { background: var(--black); color: var(--white); }
.presentation-next:disabled { border-color: #555; background: #333; color: #999; cursor: wait; }
.presentation-focus { position: relative; z-index: 2; animation: presentation-focus 1.1s ease-out 2; outline: 3px solid var(--black); outline-offset: 6px; }

@keyframes presentation-focus {
  0%, 100% { outline-offset: 6px; }
  50% { outline-offset: 13px; }
}

@keyframes enter { from { opacity: 0; transform: translateY(5px); } }

@media (max-width: 1199px) {
  :root { --sidebar: 184px; }
  .app-shell { grid-template-columns: var(--sidebar) minmax(0, 1fr); }
  .sidebar { padding-inline: 15px; }
  .live-log { position: fixed; right: 0; width: min(360px, 88vw); transform: translateX(102%); transition: transform .25s ease-out; }
  .live-log.is-open { transform: none; }
  #log-close, .log-trigger { display: inline-grid; }
  .scrim { position: fixed; inset: 0; z-index: 25; background: rgba(0,0,0,.52); }
  .scrim.is-open { display: block; }
  .sync-controls { grid-template-columns: 1fr 1fr; }
  .mode-control { grid-column: 1 / -1; }
}

@media (max-width: 767px) {
  .app-shell { display: block; }
  .sidebar { position: static; display: flex; width: 100%; height: auto; flex-direction: row; align-items: center; padding: 15px 16px; }
  .brand { font-size: 20px; }
  .brand-mark { width: 21px; height: 21px; }
  .brand-note, .module-nav, .sidebar-actions, .runtime-status { display: none; }
  .main { padding: 18px 14px 50px; }
  .pulse-header { margin-bottom: 12px; }
  .pulse-heading { align-items: center; }
  .pulse-heading h1 { font-size: 20px; }
  #pulse-canvas { height: 50px; }
  .mobile-nav { display: flex; gap: 6px; margin: 0 -14px 24px; overflow-x: auto; padding: 6px 14px 8px; }
  .mobile-nav .nav-item { display: inline-flex; min-height: 44px; flex: 0 0 auto; gap: 7px; padding: 0 13px; border-color: var(--black); background: var(--white); color: var(--black); }
  .mobile-nav .nav-item.is-active { background: var(--black); color: var(--white); }
  .mobile-global-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: -16px 0 24px; }
  .mobile-global-actions .button { min-width: 0; min-height: 44px; padding-inline: 7px; font-size: 11px; }
  .section-heading { align-items: flex-start; }
  .section-heading h2 { font-size: 31px; }
  .module-summary { max-width: 42ch; font-size: 11px; }
  .section-heading > .button { min-width: 44px; padding-inline: 10px; }
  .process-lane { grid-template-columns: 82px minmax(0, 1fr); }
  .lane-label { padding: 12px 9px; font-size: 10px; }
  .control-card, .sync-controls, .memory-controls { display: grid; grid-template-columns: 1fr; gap: 18px; }
  .mode-control { display: grid; grid-template-columns: 1fr 1fr; grid-column: auto; }
  .mode-control legend { grid-column: 1 / -1; }
  .range-control { min-width: 0; }
  .segmented { display: grid; grid-template-columns: repeat(2, 1fr); }
  .segmented button, .segmented button:last-child { min-height: 44px; border: 1px solid var(--black); }
  .action-bar { position: sticky; bottom: 0; z-index: 10; margin-inline: -14px; padding-inline: 14px; background: var(--white); box-shadow: 0 -7px 0 rgba(255,255,255,.9); }
  .action-bar .button { min-width: 44px; min-height: 44px; flex: 1; }
  .speed-control { width: 100%; margin: 8px 0 0; }
  .memory-metrics { display: grid; gap: 8px; }
  .memory-metrics strong { font-size: 13px; }
  .worker-row { grid-template-columns: 54px 1fr; }
  .live-log { top: auto; bottom: 0; left: 0; width: 100%; height: min(68vh, 580px); transform: translateY(102%); }
  .live-log.is-open { transform: none; }
  .toast { right: 14px; bottom: 14px; max-width: calc(100vw - 28px); }
  .presentation-launch { right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); min-height: 48px; }
  .presentation-panel { top: 8px; left: 8px; width: calc(100vw - 16px); max-height: min(58vh, 430px); padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); box-shadow: 7px 7px 0 rgba(0,0,0,.22); }
  .presentation-panel h2 { font-size: 24px; }
  .presentation-panel p { margin-bottom: 14px; font-size: 13px; }
  .presentation-actions { display: grid; grid-template-columns: 1fr; gap: 11px; }
  .presentation-next { width: 100%; min-height: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
