:root {
  color-scheme: dark;
  --bg: #070A0F;
  --surface: #0D121A;
  --line: rgba(148,179,214,0.16);
  --ink: #edf4f8;
  --muted: #a9b8c6;
  --mint: #38E8B0;
  --blue: #5DA9FF;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box }
[hidden] { display: none !important }
body { margin: 0; min-width: 280px }
a { color: inherit; text-decoration: none }
button, input, select { font: inherit; color: inherit }
button, select, input[type=number] {
  border: 1px solid #40505d; border-radius: 7px; background: #0D121A; padding: 8px 12px; min-height: 38px;
}
button, select, summary, input[type=checkbox] { cursor: pointer }
button, select { transition: border-color .15s, background-color .15s }
button:where(:hover):not(:disabled), select:hover:not(:disabled) { border-color: rgba(148,179,214,0.45); background-color: rgba(255,255,255,0.04) }
a:hover { color: white }
button:disabled, input:disabled, select:disabled { cursor: default; opacity: .52 }
.primary { background: var(--mint); color: #09261d; border-color: var(--mint); font-weight: 650 }
button.primary:hover:not(:disabled) { background: #87ffd4; color: #09261d }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 3px }
h1, h2, h3, p { margin: 0 }
.masthead {
  height: 64px; padding: 0 clamp(16px, 2.5vw, 42px); display: flex; align-items: center; gap: 20px;
  border-bottom: 1px solid var(--line); background: #0a1016;
}
.brand { display: inline-flex; align-items: center; gap: 9px; font-size: 24px; font-weight: 680; letter-spacing: -.04em }
.brand img { width: 42px; height: 42px; object-fit: contain }
.masthead h1 { font-size: 17px; font-weight: 480; letter-spacing: -.02em; border-left: 1px solid #425060; padding-left: 20px }
#status { margin-left: auto; max-width: min(35vw,480px); font-size: 13px; color: var(--muted); overflow-wrap: anywhere; line-height: 1.3 }
.studio-link { border-left: 1px solid var(--line); padding-left: 18px; font-size: 14px; font-weight: 550; white-space: nowrap }
.studio-link .external-arrow { color: var(--mint) }
main { height: calc(100vh - 64px); height: calc(100dvh - 64px); display: flex; flex-direction: column; }
.workbench { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) clamp(314px, 28vw, 422px) }
.stage { min-width: 0; min-height: 0; display: flex; flex-direction: column; padding: clamp(16px,2vw,32px); background: radial-gradient(ellipse at 47% 38%, #101a23 0%, #070A0F 70%) }
.stage-head, .stage-strip, .transport, .actions, .coordinates, .event-toolbar { display: flex; align-items: center; gap: 10px }
.stage-head { justify-content: space-between; margin-bottom: 18px }
.stage-head h2 { font-size: clamp(22px,2.1vw,32px); letter-spacing: -.04em; font-weight: 550 }
input { accent-color: var(--mint) }
.chart {
  position: relative; flex: 1; min-height: 0; overflow: hidden; isolation: isolate; border: 1px solid var(--line); border-radius: 2px;
  background-color: #090f16; background-image: linear-gradient(#34465740 1px,transparent 1px),linear-gradient(90deg,#34465740 1px,transparent 1px);
  background-size: 7.14% 10%;
}
#profile-ref { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: .18; pointer-events: none }

#lines { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none }
.chart-key { position: absolute; top: 12px; right: 14px; display: flex; gap: 12px; pointer-events: none; font-size: 11px; color: #d9e5eb; background: #090f16dd; border-radius: 4px; padding: 4px 7px }
.chart-key span { display: inline-flex; align-items: center; gap: 5px }
.chart-key span::before { content: ""; width: 16px; height: 3px; background: var(--mint); border-radius: 3px }
.chart-key span:nth-child(2)::before { background: var(--blue) }
.stage-strip { flex-wrap: wrap; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); gap: 12px 16px }
.transport { flex-wrap: wrap; gap: 6px }
.transport button, .transport select { font-size: 13px; padding: 8px 10px }
#play { min-width: 75px }
.paw-telemetry, .stifle { padding-left: 14px; border-left: 1px solid var(--line) }
.stage-strip h3 { font-size: 11px; font-weight: 600; margin-bottom: 4px; color: var(--muted) }
#paw-loads { display: flex; gap: 8px }
#paw-loads label { display: grid; gap: 1px; min-width: 24px; font: 11px/1.3 ui-monospace, monospace }
#paw-loads meter { height: 6px; width: 32px }
meter { appearance: none; background: #283441; border: 0; border-radius: 5px; overflow: hidden }
meter::-webkit-meter-bar { background: #283441; border: 0 }
meter::-webkit-meter-optimum-value { background: var(--mint) }
meter::-moz-meter-bar { background: var(--mint) }
.stifle div { display: flex; align-items: center; gap: 6px }
#stifle { font-size: 17px; color: var(--ink); font-variant-numeric: tabular-nums }
.stifle small { font-size: 10px; color: var(--muted) }
#stifle-gauge { width: 100%; height: 4px; display: block; margin-top: 5px }
.inspector { border-left: 1px solid var(--line); min-width: 0; min-height: 0; overflow: auto; scrollbar-width: thin; scrollbar-color: #456071 transparent }
.inspector > summary { display: none }
.inspector-body { padding: 22px clamp(14px,1.8vw,28px) }
.tab-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; border-bottom: 1px solid var(--line); padding-bottom: 20px; margin-bottom: 19px }
.tab-grid button { display: inline-flex; align-items: center; gap: 10px; font-size: 15px; justify-content: flex-start; padding: 11px 15px; min-height: 45px }
.tab-grid svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round }
button:is([aria-selected=true],[aria-checked=true],[aria-pressed=true]:not(#play),.is-active) { background: #102b26; color: var(--mint); border-color: var(--mint) }
[role=tabpanel] > h2 { font-size: 21px; letter-spacing: -.035em; font-weight: 580; margin-bottom: 14px }
[role=tabpanel] p { margin: 8px 0 14px; font-size: 13px; color: var(--muted); line-height: 1.5 }
.selectors { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 0 0 5px }
.selectors label, .field-label, .coordinates label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 550 }
.selectors select, .field-label select, .coordinates input { width: 100%; min-width: 0; color: var(--ink); font-size: 14px; font-weight: 450 }
.ranges label { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 4px 8px; align-items: center; margin: 13px 0 0; font-size: 13px }
.ranges input[type=range] { width: 100%; grid-column: 1/-1; grid-row: 2; margin: 0; height: 21px; cursor: pointer }
.ranges output { grid-column: 2; grid-row: 1; color: var(--mint); font: 12px/1.3 ui-monospace,monospace }
.presets, .chips { display: flex; flex-wrap: wrap; gap: 5px }
.presets button, .chips button { min-height: 31px; font-size: 12px; padding: 4px 10px }
.subhead { font-size: 14px; padding-top: 14px; margin-top: 17px; border-top: 1px solid var(--line) }
.coordinates { margin-top: 13px }
.coordinates label, .actions button { flex: 1; min-width: 0 }
.actions { margin: 15px 0 10px }
.reset { font-size: 12px; color: var(--muted); margin-top: 8px }
.payload { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 14px }
.payload summary, .drawer > summary, .inspector summary { font-weight: 550; font-size: 14px }
.drawer { border-top: 1px solid var(--line); background: #0c1219; overflow: auto; max-height: 43%; flex: none }
.drawer > summary, .inspector > summary { padding: 12px clamp(16px,2vw,32px); min-height: 43px }
.drawer-content { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 0 clamp(16px,2vw,32px) 16px }
.drawer-content section { min-width: 0 }
.drawer h2 { font-size: 14px; margin-bottom: 8px }
.event-toolbar button, .event-toolbar select, .payload button { font-size: 12px; min-height: 30px }
pre { max-height: 210px; overflow: auto; padding: 12px; background: #060b11; color: #bad5e3; border: 1px solid var(--line); border-radius: 6px; font: 12px/1.5 ui-monospace,monospace; white-space: pre-wrap; overflow-wrap: anywhere }
@media(min-width: 761px) and (max-width: 1140px) {
  .workbench { grid-template-columns: minmax(0,1fr) minmax(280px,32%) }
  .stage { padding: 16px }
  .transport { width: 100% }
  .paw-telemetry { padding-left: 0; border: 0 }
}
@media(max-width: 760px), (max-width: 900px) and (orientation: portrait) {
  .masthead { height: 53px; padding: 0 13px; gap: 10px; flex-wrap: nowrap }
  .brand { font-size: 20px; gap: 4px }
  .brand img { width: 32px; height: 32px }
  .masthead h1 { font-size: 13px; padding-left: 10px }
  #status { font-size: 10px; max-width: 24vw; max-height: 37px; overflow: auto }
  .studio-link { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; min-height: 44px; padding: 2px; border: 0 }
  .studio-link .open-word { display: none }
  main { height: calc(100vh - 53px); height: calc(100dvh - 53px) }
  .workbench { display: flex; flex-direction: column }
  .stage { flex: 0 0 min(48vh, 410px); flex-basis: min(48dvh, 410px); padding: 9px 12px }
  .stage-head { margin-bottom: 5px }
  .stage-head h2 { font-size: 21px }

  .stage-strip { margin-top: 5px; padding-top: 5px; gap: 5px 12px }
  .transport { width: 100%; flex-wrap: nowrap }
  .transport button, .transport select { min-height: 36px; flex: 1; padding: 5px; white-space: nowrap }
  #play { min-width: 0 }
  .paw-telemetry, .stifle { display: flex; gap: 5px; align-items: center; padding: 0; border: 0 }
  .stage-strip h3 { font-size: 10px; margin: 0 }
  #paw-loads { gap: 5px }
  #paw-loads label { min-width: 12px; font-size: 9px; display: flex; align-items: center; gap: 2px }
  #paw-loads meter { width: 12px; height: 4px }
  #paw-loads output { display: none }
  #stifle { font-size: 12px }
  .stifle small { font-size: 9px }
  #stifle-gauge { display: none }
  .chart-key { font-size: 9px; top: 4px; right: 4px; gap: 7px }
  .inspector { flex: 1; min-height: 0; border-left: 0; border-top: 1px solid var(--line) }
  .inspector:not([open]) { flex: none }
  .workbench:has(.inspector:not([open])) .stage { flex: 1 }
  .inspector > summary { display: list-item; position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 8px 14px; min-height: 36px }
  .inspector-body { padding: 2px 12px 16px }
  .tab-grid { grid-template-columns: repeat(4,minmax(0,1fr)); padding: 4px 0 10px; margin-bottom: 12px; gap: 5px }
  .tab-grid button { gap: 4px; min-height: 42px; padding: 5px 2px; justify-content: center; font-size: 12px }
  .tab-grid svg { width: 16px; height: 16px }

  .drawer { max-height: min(32dvh, 240px) }
  .drawer > summary { min-height: 38px; padding: 8px 14px }
  .drawer-content { grid-template-columns: 1fr }
}
@media(max-height: 560px) and (max-width:760px) {
  main { height: auto; min-height: calc(100vh - 53px) }
  .stage { min-height: 235px }
}
@media(prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important }
}
.inspector:not([open]) > summary { display: list-item }
.tab-grid { position: sticky; top: 0; z-index: 1; background: var(--surface) }
@media(max-width: 760px), (max-width: 900px) and (orientation: portrait) {
  .tab-grid { top: 36px }
  .transport button, .transport select, .tab-grid button, .actions button, .chips button, .presets button { min-height: 44px }
  #paw-loads label { display: grid; grid-template-columns: auto auto }
  #paw-loads output { display: inline; grid-column: 2; grid-row: 1; font-size: 9px }
  #paw-loads meter { width: 100%; grid-column: 1 / -1; grid-row: 2 }
}
#guide-list:not(:empty) { margin-top: 15px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden }
#guide-list button { width: 100%; display: flex; align-items: center; gap: 8px; border: 0; border-radius: 0; min-height: 42px; padding: 7px 9px; font-size: 13px; text-align: left }
#guide-list button + button { border-top: 1px solid var(--line) }
#guide-list button span:last-child { margin-left: auto; font: 11px ui-monospace, monospace }
#guide-list button::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 1px solid currentColor }
#guide-list button[aria-checked=true]::before { background: var(--mint); box-shadow: inset 0 0 0 2px #123e33 }
#status::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: #a5afb4 }
#status[data-ready=true]::before { background: var(--mint) }
@media(max-width: 760px), (max-width: 900px) and (orientation: portrait) {
  .stage-strip { justify-content: space-between }
  #paw-loads label { font-size: 10px; gap: 1px 3px }
  #paw-loads output { font-size: 10px }
  .stage-strip h3 { font-size: 11px }

}

.brand img { flex: none; color: var(--ink) }
.masthead, .inspector, .drawer { background-color: var(--surface) }
.stage-head { margin-bottom: 10px }
.rig-actions, .stage-options, .transport-modes, .backdrop-control, .skeleton-switch { display: flex; align-items: center; gap: 8px }
.rig-actions button, .stage-options select, .transport-modes select { font-size: 12px; min-height: 34px; padding: 5px 9px }
.stage-options { justify-content: space-between; gap: 8px; margin-bottom: 10px; font-size: 12px; color: var(--muted) }
.backdrop-control select { border-radius: 18px; padding-inline: 10px }
.skeleton-switch { cursor: pointer }
.skeleton-switch input { margin: 0; width: 16px; height: 16px }
#backdrop-badge { position: absolute; left: 8px; bottom: 22px; background: #0d121aee; color: #d1dce5; padding: 4px 8px; border: 1px solid var(--line); font-size: 10px; border-radius: 10px; z-index: 1; pointer-events: none }
.chart { border-radius: 12px }
.transport-modes { flex-wrap: wrap }
.transport-modes label { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted) }
.transport-modes select { color: var(--ink); min-width: 0 }
.stage-strip { gap: 10px 12px }
.stage-strip .transport { width: auto }
.subhead code { font-size: 11px; color: var(--muted); font-weight: 400 }
#open-guides { color: var(--blue); font-size: 12px; background: transparent; border: none; padding: 4px 0; min-height: 32px }
.ranges .bipolar { appearance: none; background: transparent }
.bipolar::-webkit-slider-runnable-track { height: 4px; border-radius: 3px; background: linear-gradient(to right,#394450 var(--from),var(--mint) var(--from) var(--to),#394450 var(--to)) }
.bipolar::-moz-range-track { height: 4px; border-radius: 3px; background: linear-gradient(to right,#394450 var(--from),var(--mint) var(--from) var(--to),#394450 var(--to)) }
.bipolar::-webkit-slider-thumb { appearance: none; width: 14px; height: 14px; border-radius: 50%; margin-top: -5px; background: var(--mint) }
.bipolar::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; border: none; background: var(--mint) }
#events { padding: 0; list-style: none; max-height: 160px; overflow: auto; white-space: nowrap; font: 12px/1.5 ui-monospace,monospace }
#events li { padding: 4px 2px; border-bottom: 1px solid var(--line) }
#summary { display: flex; flex-wrap: wrap; gap: 10px 16px; margin: 12px 0 }
#summary dt { color: var(--muted); font: 11px ui-monospace,monospace }
#summary dd { margin: 4px 0; color: var(--mint); font: 14px ui-monospace,monospace }
.raw summary { cursor: pointer; padding: 8px 0 }
meter, output, #events, #summary { font-variant-numeric: tabular-nums }
@media (max-width: 900px) {
  #status.connected { font-size: 0; white-space: nowrap; overflow: visible; max-width: none }
  #status.connected::after { content: attr(data-compact); font: 12px ui-monospace,monospace }
}
@media (max-width: 600px) {
  .masthead h1 { display: none }
  .stage-options { margin-bottom: 5px }
  .rig-actions button { min-height: 32px }
  .transport-modes { width: 100% }
  .transport-modes label { flex: 1 }
  .transport-modes select { flex: 1; min-height: 32px }
  .stage-strip .transport { width: 100% }
  #paw-loads output, #paw-loads label { font-size: 11px }
  .stage { flex-basis: min(52dvh, 440px) }
}
