/* Pult tokens. Colour is a word: accent = selected, ok = live, warn = attention, error = fault. */
.app {
  --ground: #ebe5d8; --panel: #f6f1e6; --well: #dcd5c5; --line: #c8bfac;
  --ink: #1c1a16; --muted: #5f594e;
  --accent: #e8440a; --ok: #2f8a4a; --warn: #e2a400; --error: #a52018;
  --node: #fbf8f1; --node-line: #b3a98f;
  --bar: #1c1a16; --bar-ink: #fbf9f4;
  --sans: "PP Neue Montreal", "Inter Tight", -apple-system, "Helvetica Neue", sans-serif;
  --display: "PP Neue Machina", "PP Neue Montreal", "Inter Tight", -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
.app.night {
  --ground: #17150f; --panel: #201d17; --well: #2b2721; --line: #3b362e;
  --ink: #ece5d6; --muted: #a0978a;
  --accent: #ff6a1f; --ok: #4cc06e; --warn: #f5c52b; --error: #ff4a3d;
  --node: #353029; --node-line: #544c40;
  --bar: #0c0b08;
  color-scheme: dark;
}

html, body { margin: 0; height: 100%; overflow: hidden; background: #17150f; }
* { box-sizing: border-box; }

.app {
  height: 100vh; min-height: 560px;
  display: grid; grid-template-areas: "title" "main" "status"; grid-template-rows: 36px minmax(0, 1fr) 22px;
  background: var(--ground); color: var(--ink);
  font: 12px/16px var(--sans);
}
.app button, .app input, .app select { font: inherit; color: inherit; }
.app :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.app h1, .app h2, .app h3, .app h4, .app p { margin: 0; }

.app * { scrollbar-width: thin; scrollbar-color: transparent transparent; }
.app :hover { scrollbar-color: var(--line) transparent; }
.app ::-webkit-scrollbar { width: 8px; height: 8px; }
.app ::-webkit-scrollbar-track, .app ::-webkit-scrollbar-corner { background: transparent; }
.app ::-webkit-scrollbar-thumb { background: transparent; border: 2px solid transparent; border-radius: 999px; background-clip: padding-box; }
.app :hover::-webkit-scrollbar-thumb { background-color: var(--line); }
.app ::-webkit-scrollbar-thumb:hover { background-color: var(--muted); }

/* Type */
.t-title { font: 800 12px/14px var(--display); letter-spacing: .01em; }
.t-label { font: 500 9px/11px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.t-value { font: 500 11px/14px var(--mono); font-variant-numeric: tabular-nums; }
.t-addr { font: 400 10px/13px var(--mono); color: var(--muted); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.error-text { color: var(--error); }
.grow { flex: 1; }
.pad { padding: 12px 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Controls */
.btn { height: 24px; padding: 0 10px; display: inline-flex; align-items: center; gap: 6px; border-radius: 2px; border: 1px solid var(--line); background: transparent; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--well); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--ground); }
.btn.primary:hover:not(:disabled) { background: var(--ink); opacity: .88; }
.btn.ghost { border-color: transparent; }
.btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--ground); }
.tool { width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 2px; background: transparent; cursor: pointer; }
.tool:hover { background: var(--well); }
.tool.on, .tool[aria-pressed="true"] { background: var(--ink); color: var(--ground); }
.field { height: 24px; width: 100%; padding: 0 8px; border: 1px solid var(--line); border-radius: 2px; background: var(--well); }
.field.compact { width: auto; }
.field-label { display: grid; gap: 4px; }
.seg-group { display: flex; gap: 2px; padding: 2px; background: var(--well); border-radius: 2px; }
.seg { height: 20px; padding: 0 10px; border: 0; border-radius: 2px; background: transparent; font-weight: 500; cursor: pointer; }
.seg.on { background: var(--ink); color: var(--ground); }
.check { display: flex; align-items: center; gap: 8px; }
.check input { accent-color: var(--ink); margin: 0; }
.row { display: flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 2px; }
.row.sel { background: var(--well); font-weight: 500; }
.led { width: 6px; height: 6px; border-radius: 999px; background: var(--muted); flex: none; }
.led.ok { background: var(--ok); } .led.warn { background: var(--warn); } .led.error { background: var(--error); }

/* Floating panels */
.float { position: relative; z-index: 2; min-height: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; }
.panel-head { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 8px 0 12px; border-bottom: 1px solid var(--line); }
.section { display: grid; gap: 10px; padding: 12px; border-bottom: 1px solid var(--line); }
.section:last-child { border-bottom: 0; }
.tabs { display: flex; gap: 2px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tab { height: 22px; padding: 0 10px; border: 0; border-radius: 2px; background: transparent; font-weight: 500; color: var(--muted); cursor: pointer; }
.tab.on { background: var(--well); color: var(--ink); }

/* Shell */
.titlebar { grid-area: title; display: flex; align-items: center; gap: 12px; padding: 0 8px 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; overflow-x: auto; }
.brand { font: 800 13px/1 var(--display); letter-spacing: .01em; color: var(--ink); text-decoration: none; white-space: nowrap; }
.titlebar-doc { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 120px; white-space: nowrap; }
.doc-name { font-weight: 500; }

.statusbar { grid-area: status; display: flex; align-items: center; gap: 16px; padding: 0 12px; background: var(--bar); color: var(--bar-ink); font: 10px/13px var(--mono); white-space: nowrap; overflow: hidden; }
.status-led { width: 6px; height: 6px; border-radius: 999px; background: #8a8275; }
.status-led[data-live="true"] { background: var(--ok); }
.statusbar-note { opacity: .7; }

.workspace { grid-area: main; min-height: 0; position: relative; }
.graph-workspace {
  display: grid; grid-template-columns: 248px minmax(0, 1fr) 296px; grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "left . right";
}
.graph-workspace > .graph-canvas { grid-area: 1 / 1 / -1 / -1; }
.graph-workspace > .layers { grid-area: left; margin: 12px 0 12px 12px; display: grid; grid-template-rows: minmax(0, 1fr); overflow: hidden; }
.right-column { grid-area: right; position: relative; z-index: 2; display: flex; flex-direction: column; gap: 12px; margin: 12px 12px 12px 0; min-height: 0; }
.inspector { flex: 0 1 auto; display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; }
.inspector-body { overflow-y: auto; min-height: 0; }
.tune-workspace { display: grid; }

.announcement { position: fixed; z-index: 10; left: 50%; bottom: 36px; transform: translateX(-50%); max-width: min(560px, calc(100vw - 32px)); padding: 8px 12px; border-radius: 4px; background: var(--bar); color: var(--bar-ink); border: 1px solid var(--line); }
.announcement[data-error="true"] { border-color: var(--error); }
.announcement[hidden] { display: none; }

@media (max-width: 900px) {
  .app { height: auto; min-height: 100vh; }
  html, body { overflow: auto; }
  .graph-workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: 420px auto auto; grid-template-areas: "." "left" "right"; }
  .graph-workspace > .graph-canvas { grid-area: 1 / 1 / 2 / 2; }
  .graph-workspace > .layers { margin: 12px 12px 0; max-height: 320px; }
  .right-column { margin: 12px; }
}
