:root {
  color-scheme: light;
  --paper: #ece9e1;
  --paper-bright: #f5f3ed;
  --ink: #111313;
  --muted: #777872;
  --line: rgba(17, 19, 19, 0.14);
  --line-strong: rgba(17, 19, 19, 0.3);
  --acid: #d2ff45;
  --rail-width: 312px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
}

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

.app-shell { display: grid; grid-template-columns: var(--rail-width) minmax(0, 1fr); height: 100vh; }

.control-rail {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 34px 28px 24px;
  background: var(--ink);
  color: var(--paper-bright);
  overflow-y: auto;
}

.brand-lockup { display: flex; gap: 14px; align-items: flex-start; }
.brand-mark { position: relative; width: 30px; height: 30px; margin-top: 2px; }
.brand-mark span { position: absolute; display: block; width: 8px; height: 8px; border-radius: 50%; background: var(--acid); }
.brand-mark span:nth-child(1) { left: 0; top: 12px; }
.brand-mark span:nth-child(2) { left: 11px; top: 3px; }
.brand-mark span:nth-child(3) { left: 20px; top: 16px; }

.eyebrow, .section-heading, .header-note, .rail-footer, .viewport-footer, .axis-label, .canvas-hud, .message-kicker {
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.eyebrow { margin: 0 0 8px; color: var(--muted); font-weight: 700; }
.control-rail .eyebrow { color: #8b8d85; }
h1 { margin: 0; font-size: 29px; line-height: .9; letter-spacing: -.075em; font-weight: 800; }
h1 em { color: var(--acid); font-style: normal; font-weight: 500; }
.intro-copy { max-width: 235px; margin-top: -2px; }
.intro-copy p { margin: 0; color: #b5b6ad; font-size: 13px; line-height: 1.55; }

.control-section { border-top: 1px solid rgba(245, 243, 237, .16); padding-top: 16px; }
.compact-section { padding-top: 15px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; color: #8e9088; font-weight: 700; }
.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; letter-spacing: .05em; }
.rule-list { display: grid; gap: 7px; margin-top: 12px; }
.rule-card { display: grid; grid-template-columns: 32px 1fr auto; gap: 10px; align-items: center; min-height: 52px; padding: 8px 10px; border: 1px solid rgba(245, 243, 237, .14); background: transparent; text-align: left; cursor: pointer; transition: border-color .18s, background .18s, transform .18s; }
.rule-card:hover { border-color: rgba(245, 243, 237, .46); transform: translateX(2px); }
.rule-card[aria-selected="true"] { border-color: var(--acid); background: rgba(210, 255, 69, .1); }
.rule-index { display: grid; place-items: center; width: 25px; height: 25px; border: 1px solid rgba(245, 243, 237, .25); border-radius: 50%; color: #aeb0a7; font-size: 10px; }
.rule-card[aria-selected="true"] .rule-index { border-color: var(--acid); color: var(--acid); }
.rule-name { display: block; font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.rule-description { display: block; margin-top: 3px; color: #8e9088; font-size: 11px; line-height: 1.25; }
.rule-byte { color: var(--acid); font-size: 10px; }
.control-hint { margin: 11px 0 0; color: #74776e; font-size: 9px; letter-spacing: .08em; line-height: 1.55; }

.range-label { display: flex; justify-content: space-between; gap: 10px; margin: 16px 0 10px; color: #b5b6ad; font-size: 12px; }
input[type="range"] { width: 100%; accent-color: var(--acid); cursor: pointer; }
select { width: 100%; min-height: 34px; padding: 0 9px; border: 1px solid rgba(245, 243, 237, .22); border-radius: 0; background: var(--ink); color: var(--paper-bright); font-size: 11px; letter-spacing: .08em; cursor: pointer; }
select:focus { outline: 1px solid var(--acid); outline-offset: 2px; }
.performance-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 13px; }
.performance-grid div { min-width: 0; padding: 9px 7px; border: 1px solid rgba(245, 243, 237, .13); }
.performance-grid span { display: block; overflow: hidden; color: #777a72; font-size: 8px; letter-spacing: .1em; text-overflow: ellipsis; white-space: nowrap; }
.performance-grid strong { display: block; overflow: hidden; margin-top: 5px; color: var(--acid); font-size: 10px; letter-spacing: -.03em; text-overflow: ellipsis; white-space: nowrap; }
.iteration-actions { display: grid; grid-template-columns: 1.15fr 1fr 1fr; gap: 6px; margin-top: 14px; }
.action-button { display: flex; align-items: center; justify-content: space-between; min-height: 38px; padding: 0 10px; border: 1px solid rgba(245, 243, 237, .22); background: transparent; color: #c7c8c0; font-size: 10px; letter-spacing: .1em; font-weight: 800; cursor: pointer; }
.action-button:hover { border-color: rgba(245, 243, 237, .62); color: var(--paper-bright); }
.action-button.primary { border-color: var(--acid); color: var(--ink); background: var(--acid); }
.action-button.primary:hover { background: #e2ff88; }
.play-glyph { font-size: 9px; }
.button-key { color: #777a70; font-family: monospace; font-size: 11px; }
.primary .button-key { color: #4a5d10; }
.rail-footer { display: flex; flex-direction: column; gap: 12px; margin-top: auto; padding-top: 20px; color: #777a72; }
.rail-footer p { margin: 0; font-size: 9px; letter-spacing: .13em; }
.status-line { display: flex; align-items: center; gap: 8px; color: #b5b6ad; font-size: 10px; font-weight: 700; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #c9c9c1; }
.status-dot.ready { background: var(--acid); box-shadow: 0 0 0 4px rgba(210, 255, 69, .12); }
.status-dot.error { background: #ff8a64; }

.viewport-shell { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; background: var(--paper); }
.viewport-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 29px 36px 21px; border-bottom: 1px solid var(--line); }
.viewport-header .eyebrow { color: var(--ink); margin-bottom: 6px; }
.header-note { margin: 0; color: var(--muted); letter-spacing: .08em; text-transform: none; }
.header-readout { display: flex; gap: 28px; }
.header-readout div { display: grid; gap: 5px; text-align: right; }
.header-readout span { color: var(--muted); font-size: 9px; letter-spacing: .14em; }
.header-readout strong { font-family: "SFMono-Regular", Consolas, monospace; font-size: 14px; letter-spacing: -.03em; font-weight: 500; }

.canvas-stage { position: relative; min-height: 0; overflow: hidden; background: var(--paper-bright); cursor: grab; }
.canvas-stage.is-dragging { cursor: grabbing; }
#gpuCanvas { display: block; width: 100%; height: 100%; }
.canvas-overlay { position: absolute; inset: 20px; pointer-events: none; }
.axis-label { position: absolute; color: rgba(17, 19, 19, .38); font-size: 9px; }
.axis-top { top: 0; left: 50%; transform: translateX(-50%); }
.axis-bottom { bottom: 0; left: 50%; transform: translateX(-50%); }
.axis-left { top: 50%; left: 0; transform: translateY(-50%); }
.axis-right { top: 50%; right: 0; transform: translateY(-50%); }
.center-cross { position: absolute; top: 50%; left: 50%; width: 18px; height: 18px; transform: translate(-50%, -50%); opacity: .3; }
.center-cross span { position: absolute; background: var(--ink); }
.center-cross span:first-child { left: 8px; top: 0; bottom: 0; width: 1px; }
.center-cross span:last-child { left: 0; top: 8px; right: 0; height: 1px; }
.canvas-hud { position: absolute; bottom: 21px; display: flex; align-items: center; gap: 9px; color: var(--muted); pointer-events: none; }
.canvas-hud strong { color: var(--ink); font-family: "SFMono-Regular", Consolas, monospace; font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.bottom-left { left: 28px; }
.bottom-right { right: 28px; }
.canvas-hud button { padding: 0; border: 0; background: transparent; color: var(--ink); font-family: "SFMono-Regular", Consolas, monospace; font-size: 10px; letter-spacing: .05em; cursor: pointer; pointer-events: auto; }
.canvas-hud button:hover { color: #566c0b; }
.canvas-hud button span { margin-left: 8px; color: var(--muted); }
.webgpu-message { position: absolute; top: 50%; left: 50%; width: min(380px, calc(100% - 48px)); transform: translate(-50%, -50%); padding: 26px; border: 1px solid var(--line-strong); background: rgba(245, 243, 237, .92); text-align: center; }
.webgpu-message[hidden] { display: none; }
.message-kicker { color: #bd5e3f; font-weight: 800; }
.webgpu-message h2 { margin: 10px 0 9px; font-size: 20px; letter-spacing: -.04em; }
.webgpu-message p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }

.viewport-footer { display: flex; justify-content: space-between; align-items: center; min-height: 42px; padding: 0 36px; border-top: 1px solid var(--line); color: var(--muted); font-size: 9px; letter-spacing: .12em; }
.viewport-footer p { margin: 0; }
.legend-swatch { display: inline-block; width: 8px; height: 8px; margin: 0 5px 0 12px; border: 1px solid var(--ink); border-radius: 50%; vertical-align: -1px; }
.legend-swatch:first-child { margin-left: 0; }
.legend-swatch.black { background: var(--ink); }
.legend-swatch.white { background: var(--paper-bright); }
.legend-swatch.ghost { border-color: rgba(17, 19, 19, .22); background: rgba(17, 19, 19, .08); }

@media (max-width: 820px) {
  body { overflow: auto; }
  .app-shell { display: block; height: auto; min-height: 100vh; }
  .control-rail { gap: 22px; min-height: auto; padding: 24px 20px 22px; }
  .rail-footer { margin-top: 4px; }
  .viewport-shell { height: 70vh; min-height: 520px; }
  .viewport-header { padding: 20px; }
  .viewport-footer { padding: 0 20px; }
  .canvas-overlay { inset: 14px; }
}

@media (max-width: 480px) {
  .header-readout { gap: 14px; }
  .header-note { font-size: 9px; }
  .viewport-footer p:first-child { max-width: 220px; line-height: 1.8; }
  .viewport-footer { align-items: flex-start; padding-top: 9px; }
}
