/* Flyway: quiet workspace. Surfaces 16px, controls 10px, status labels pill-shaped.
   Layer scale: video 2-4, marking toolbar 30, scrim 40, settings 50, toast 100.
   Camera pixels and their overlays retain a fixed dark palette in either theme. */
:root {
  color-scheme: dark;
  --bg: #11191e;
  --panel: #182328;
  --panel2: #202e34;
  --border: #35474f;
  --text: #e6eeef;
  --muted: #a3b5bb;
  --cyan: #76d8c7;
  --accent-hover: #95e4d6;
  --accent-ink: #102c27;
  --accent-soft: #203e38;
  --orange: #eac28a;
  --warn-soft: #382f23;
  --red: #ffaaa9;
  --error-soft: #40292c;
  --field: #172329;
  --field-border: #60747d;
  --plot-bg: #11191e;
  --plot-grid: #2a3b43;
  --plot-text: #a3b5bb;
  --plot-reference: #b2ace2;
  --plot-drop: #76d8c720;
  --shadow: 0 16px 64px #06101533;
}
:root[data-theme=light] {
  color-scheme: light;
  --bg: #f7f9f9;
  --panel: #fdfefe;
  --panel2: #edf2f2;
  --border: #dce4e5;
  --text: #23363b;
  --muted: #566c72;
  --cyan: #08796c;
  --accent-hover: #066457;
  --accent-ink: #fdfefe;
  --accent-soft: #e2f1eb;
  --orange: #815718;
  --warn-soft: #f7efdf;
  --red: #ad3843;
  --error-soft: #fbe9e9;
  --field: #fdfefe;
  --field-border: #83979d;
  --plot-bg: #f7f9f9;
  --plot-grid: #e0e8e9;
  --plot-text: #566c72;
  --plot-reference: #6654a7;
  --plot-drop: #08796c20;
  --shadow: 0 16px 64px #23363b14;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.6 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; -webkit-font-smoothing: antialiased; }
button,input,select,textarea { font: inherit; }
button,a { touch-action: manipulation; }
button { border: 1px solid transparent; border-radius: 10px; padding: 10px 15px; min-height: 42px; background: var(--panel2); color: var(--text); cursor: pointer; font-size: 13px; font-weight: 600; line-height: 1.4; transition: background .15s,transform .15s; }
button:hover { background: var(--border); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--cyan); color: var(--accent-ink); }
button.primary:hover { background: var(--accent-hover); }
button.ghost,.textbutton { background: transparent; }
button.ghost:hover,.textbutton:hover { background: var(--panel2); }
.textbutton { color: var(--cyan); }
.tiny { min-height: 34px; padding: 6px 10px; font-size: 12px; }
.danger { color: var(--red); }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
[hidden] { display: none!important; }
h1,h2,h3,p { margin: 0; }
h1,h2,h3 { text-wrap: balance; }
.skip-link { position: fixed; top: 12px; left: 16px; z-index: 100; transform: translateY(-160%); background: var(--panel); padding: 12px 18px; border-radius: 10px; }
.skip-link:focus { transform: none; }
h1 { font-size: 30px; line-height: 1.25; font-weight: 650; letter-spacing: -1px; }
h2,h3 { font-size: 15px; font-weight: 650; line-height: 1.4; }
p { margin-top: 8px; color: var(--muted); }
.topbar { min-height: 76px; max-width: 1440px; margin: auto; padding: 0 36px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 24px; font-weight: 750; letter-spacing: -.8px; }
.brand:hover { text-decoration: none; }
.brand svg { width: 34px; fill: none; stroke: var(--cyan); stroke-width: 2; }
.brand small { display: block; font-size: 8px; font-weight: 600; letter-spacing: 1.8px; color: var(--muted); line-height: 1.5; }
.topstatus { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.dot { width: 6px; height: 6px; background: var(--muted); border-radius: 50%; }
.dot.on { background: var(--cyan); }
.version { margin-left: 8px; font-size: 10px; }
.topactions { display: flex; gap: 6px; }
.key { margin-left: 9px; font-size: 10px; color: var(--muted); }
#btnTheme { display: inline-flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap; }
#btnTheme svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; flex-shrink: 0; }
#btnTheme[aria-pressed=true] { color: var(--cyan); }
main { max-width: 1440px; margin: auto; padding: 30px 36px 0; }
.pagehead { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 26px; }
.pagehead p { font-size: 13px; max-width: 68ch; }
.eyebrow { color: var(--muted); font-size: 11px; font-weight: 500; letter-spacing: .2px; }
.device-strip { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 20px; margin-bottom: 24px; padding: 0; }
.device-strip-title { display: flex; flex-direction: column; min-width: 145px; }
.device-strip-title b { font-size: 13px; }
.device-strip-title small { font-size: 11px; color: var(--muted); }
.device-pills { display: flex; flex: 1; gap: 6px; flex-wrap: wrap; }
.device-pill { font-size: 11px; font-weight: 550; background: var(--panel2); padding: 5px 9px; border-radius: 999px; color: var(--muted); overflow-wrap: anywhere; }
.device-pill[data-phase=live] { color: var(--cyan); background: var(--accent-soft); }
.device-pill:is([data-phase=requesting],[data-phase=waiting],[data-phase=stale],[data-phase=muted]) { color: var(--orange); background: var(--warn-soft); }
.device-pill:is([data-phase=denied],[data-phase=error],[data-phase=insecure]) { color: var(--red); background: var(--error-soft); }
.device-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.location-feedback { flex-basis: 100%; margin: 0; order: 4; }
.tabs { display: flex; align-items: center; gap: 6px; margin-bottom: 24px; }
.tabs button { background: transparent; color: var(--muted); padding: 10px 16px; }
.tabs button:hover { background: var(--panel2); }
.tabs button.active { background: var(--accent-soft); color: var(--cyan); }
#countBadge { font-size: 10px; margin-left: 5px; font-variant-numeric: tabular-nums; }
.tabnote { margin-left: auto; color: var(--muted); font-size: 11px; max-width: 40%; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.tab { display: none; }
.tab.active { display: block; }
.dashboard { display: grid; grid-template-columns: minmax(0,1fr) 320px; gap: 32px; }
.maincol,.sidecol { min-width: 0; }
.panel { min-width: 0; }
.panelhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 0 16px; min-height: 42px; }
.panelhead .buttonrow { align-items: center; }
.badges { display: flex; gap: 7px; }
.badge { font-size: 10px; font-weight: 550; color: var(--muted); background: var(--panel2); padding: 4px 8px; border-radius: 999px; white-space: nowrap; }
.badge.good { color: var(--cyan); background: var(--accent-soft); }
.badge.warn { color: var(--orange); background: var(--warn-soft); }
.stage { width: 100%; aspect-ratio: 16/9; position: relative; border-radius: 16px; background: #0b141b; overflow: hidden; user-select: none; isolation: isolate; }
.stage video,.stage #synthetic { position: absolute; width: 100%; height: 100%; object-fit: contain; }
.stage #overlay { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: pan-y; z-index: 2; }
.empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 3; background: var(--panel2); padding: 24px; }
.empty h2 { font-size: 24px; font-weight: 600; letter-spacing: -.6px; }
.empty p { text-align: center; font-size: 13px; line-height: 1.75; margin: 10px 0 24px; }
.sourcebuttons { display: flex; gap: 10px; margin-bottom: 10px; }
.sourcebuttons button:not(.primary) { background: var(--panel); }
.empty small { font-size: 10px; color: var(--muted); margin-top: 12px; text-align: center; }
.videoHUD { position: absolute; z-index: 3; bottom: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; pointer-events: none; font: 11px ui-monospace,monospace; color: #e8eef6; }
.videoHUD span,.stage-label { background: #101e29ed; border-radius: 8px; padding: 6px 9px; }
.stage-label { position: absolute; z-index: 3; left: 12px; top: 12px; max-width: calc(100% - 24px); font-size: 10px; color: #f2c182; pointer-events: none; }
.selection-hint { position: absolute; z-index: 4; top: 10px; left: 50%; transform: translateX(-50%); background: #102c27f5; border-radius: 10px; color: #95e4d6; font-size: 12px; padding: 10px 14px; max-width: 90%; text-align: center; pointer-events: none; }
.transport { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.transport button { min-width: 40px; padding: 5px; background: transparent; font-size: 14px; }
.transport input { flex: 1; min-width: 30px; accent-color: var(--cyan); height: 4px; }
.transport select { width: 64px; font-size: 12px; padding: 6px; min-height: 34px; }
.transport span { font: 11px ui-monospace,monospace; color: var(--muted); white-space: nowrap; }
.analysisbar { display: flex; align-items: start; gap: 8px; padding: 4px 0 16px; flex-wrap: wrap; }
.extra-controls { flex-basis: 100%; min-width: 0; }
.extra-controls summary { display: inline-flex; align-items: center; min-height: 40px; font-size: 12px; color: var(--muted); }
.extra-controls summary::before { content: '＋'; margin-right: 7px; }
.extra-controls[open] summary { margin-bottom: 6px; }
.extra-controls[open] summary::before { content: '−'; }
.extra-controls .buttonrow { padding-bottom: 3px; }
.notice { padding: 13px 16px; background: var(--panel2); color: var(--muted); font-size: 12px; line-height: 1.65; border-radius: 12px; }
.notice.warn { background: var(--warn-soft); color: var(--orange); }
.notice.good { background: var(--accent-soft); color: var(--cyan); }
.calibration-state { padding: 20px; background: var(--accent-soft); border-radius: 16px; }
.calibration-state>div { display: flex; gap: 9px; align-items: center; font-size: 13px; }
.status-ring { width: 8px; height: 8px; border: 1.5px solid var(--orange); border-radius: 50%; flex-shrink: 0; }
.status-ring.good { background: var(--cyan); border-color: var(--cyan); }
.calibration-state p { font-size: 12px; margin: 12px 0 16px; }
.widebutton { width: 100%; }
.calibration-state .widebutton { color: var(--cyan); background: var(--panel); font-size: 12px; margin-top: 6px; }
.calibration-state .widebutton:hover { background: var(--bg); }
.metricgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px 18px; margin: 30px 0 32px; }
.metric { min-width: 0; }
.metric>span { display: block; font-size: 11px; color: var(--muted); min-height: 36px; line-height: 1.5; }
.metric strong { display: block; font-size: 30px; line-height: 1.3; font-weight: 600; letter-spacing: -1px; font-variant-numeric: tabular-nums; white-space: nowrap; margin-top: 4px; }
.metric strong em { font-size: 13px; font-style: normal; color: var(--muted); letter-spacing: 0; margin-left: 3px; }
.metric small { display: block; color: var(--muted); font-size: 10px; line-height: 1.6; margin-top: 6px; }
.trajectory #world { height: 250px; width: 100%; display: block; touch-action: none; cursor: grab; }
.worldlegend { display: flex; justify-content: center; gap: 18px; color: var(--muted); font-size: 10px; }
.micro { font-size: 11px; color: var(--muted); line-height: 1.75; }
.trajectory .micro { font-size: 10px; margin-top: 12px; }
.diagnostics { margin-top: 30px; }
.diagnostics dl { display: grid; grid-template-columns: 1fr 1.1fr; font-size: 11px; margin: 0; gap: 10px 12px; }
.diagnostics dt { color: var(--muted); }
.diagnostics dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
#tuningPanel { margin-top: 32px; }
.tuning .panelhead { flex-wrap: wrap; }
.tuningbody { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 16px; min-width: 0; }
.tuner { min-width: 0; }
.tuner label { display: block; min-height: 36px; margin: 0; font-size: 11px; }
.tuner input[type=number] { width: 100%; margin: 4px 0; font-variant-numeric: tabular-nums; }
.tuner input[type=range] { width: 100%; height: 24px; padding: 0; margin: 6px 0 0; accent-color: var(--cyan); cursor: pointer; }
.tuningbody>p,.tuningbody>.buttonrow { grid-column: 1/-1; margin: 0; }
.recalcstatus { color: var(--cyan); font-size: 12px; line-height: 1.6; }
.lowergrid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 36px; }
.roi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.roi-grid>div { min-width: 0; }
.roi-grid canvas { width: 100%; aspect-ratio: 1.7; background: #0b141b; border-radius: 10px; object-fit: contain; }
.roi-grid small { font-size: 10px; color: var(--muted); display: block; margin-top: 6px; }
.lowergrid .micro { margin-top: 12px; }
.chart { width: 100%; height: 180px; display: block; }
.chartlegend { display: flex; gap: 6px; align-items: center; font-size: 10px; color: var(--muted); padding-top: 10px; }
.chartlegend i { width: 11px; height: 2px; background: var(--cyan); }
.chartlegend span { margin-left: auto; font-size: 9px; }
.tablewrap { overflow: auto; max-height: 600px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
th,td { padding: 13px 16px; text-align: right; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
th { color: var(--muted); font-size: 11px; background: var(--panel2); position: sticky; top: 0; }
th:first-child,td:first-child { text-align: left; }
.placeholder { text-align: center!important; padding: 80px 20px; color: var(--muted); }
.buttonrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pad { padding: 14px 0!important; }
.logpanel { margin-top: 32px; }
.logpanel pre { max-height: 300px; overflow: auto; color: var(--muted); font-size: 11px; white-space: pre-wrap; line-height: 1.8; }
.sourceintro { max-width: 85ch; padding: 8px 0 24px; }
.sourceintro h2 { font-size: 20px; }
.sourceintro p { font-size: 13px; }
.sourcecards { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.sourcecard { min-width: 0; }
.sourcevisual { height: 150px; background: var(--panel2); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; justify-content: space-between; margin-bottom: 18px; }
.sourcevisual span { font-size: 11px; color: var(--muted); }
.sourcevisual b { font-size: 30px; letter-spacing: -.6px; font-weight: 600; }
.sourcevisual small { font-size: 10px; color: var(--muted); }
.sourcevisual.third { background: var(--accent-soft); }
.sourcecard h2 { font-size: 17px; }
.sourcecard p { font-size: 12px; line-height: 1.75; }
.sourcecard .buttonrow,.sourcecard>button { margin: 16px 0; }
.sourcecard a { font-size: 12px; }
.sourcecard>small { display: block; font-size: 11px; color: var(--muted); }
.sources-method { margin-top: 36px; font-size: 12px; }
footer { padding: 32px 0; display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font-size: 11px; margin-top: 24px; }
/* Settings and dialogs use a single surface; internal groups are spaced, not boxed. */
.scrim { position: fixed; inset: 0; background: #07151e66; z-index: 40; }
.drawer { position: fixed; right: 0; top: 0; bottom: 0; width: 475px; max-width: 100%; z-index: 50; background: var(--panel); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.drawerhead { display: flex; align-items: center; justify-content: space-between; padding: 24px; gap: 12px; }
.drawerhead h2 { font-size: 25px; margin-top: 5px; }
.drawerhead button,.dialoghead button { background: transparent; font-size: 20px; flex-shrink: 0; min-width: 44px; }
.drawerbody { overflow-y: auto; overscroll-behavior: contain; padding: 0 24px calc(40px + env(safe-area-inset-bottom)); }
.drawer details { padding: 22px 0; border-bottom: 1px solid var(--border); }
summary { cursor: pointer; font-size: 14px; font-weight: 600; }
details[open]>summary { margin-bottom: 18px; }
label { display: block; color: var(--muted); font-size: 12px; margin: 12px 0 4px; }
label input:not([type=checkbox]),label select,label textarea { margin-top: 6px; }
input:not([type=range]):not([type=checkbox]):not([type=radio]),select,textarea { display: block; background: var(--field); color: var(--text); border: 1px solid var(--field-border); border-radius: 10px; padding: 10px 12px; width: 100%; min-height: 42px; min-width: 0; font-size: 13px; }
input::placeholder,textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus,select:focus,textarea:focus { border-color: var(--cyan); }
input:invalid:not(:placeholder-shown) { border-color: var(--red); }
input[type=checkbox],input[type=radio] { accent-color: var(--cyan); }
textarea { resize: vertical; font-family: ui-monospace,monospace; font-size: 12px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.check { display: flex; align-items: center; gap: 9px; font-size: 12px; margin: 16px 0; }
.check input { width: 18px; height: 18px; flex-shrink: 0; }
.drawer details>button { margin-top: 10px; font-size: 12px; }
.drawer .micro { margin: 10px 0; }
.step { display: flex; gap: 12px; margin-top: 20px; }
.step>b { display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--cyan); width: 26px; height: 26px; flex: none; font-size: 12px; }
.step strong { font-size: 13px; }
.step p { font-size: 12px; margin-top: 5px; }
.sensorgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 12px; margin: 20px 0; min-width: 0; }
.sensorgrid>div { min-width: 0; }
.sensorgrid small { font-size: 11px; color: var(--muted); display: block; }
.sensorgrid b { display: block; font-size: 13px; margin-top: 5px; overflow-wrap: anywhere; font-weight: 500; }
.deviceinfo { white-space: pre-wrap; overflow-wrap: anywhere; padding: 14px; background: var(--panel2); border-radius: 12px; font-size: 12px; }
.opticsbox { min-width: 0; padding: 16px; background: var(--panel2); border-radius: 12px; margin: 16px 0; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--panel); color: var(--text); padding: 14px 20px; box-shadow: var(--shadow); border: 1px solid var(--border); border-radius: 12px; z-index: 100; max-width: min(90vw,600px); font-size: 13px; }
dialog { background: var(--panel); color: var(--text); border: 0; border-radius: 16px; max-width: 650px; width: calc(100% - 32px); max-height: calc(100dvh - 32px); padding: 28px; box-shadow: var(--shadow); }
dialog::backdrop { background: #07151e80; }
.dialoghead { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.dialoghead h2 { font-size: 22px; }
dialog p { font-size: 13px; margin: 16px 0; }
.helpsteps { padding-left: 22px; margin: 24px 0; }
.helpsteps li { padding: 8px 0; color: var(--muted); font-size: 13px; }
.helpsteps b { color: var(--text); }
.flyway-dialog { width: min(680px,calc(100vw - 32px)); overflow-y: auto; overscroll-behavior: contain; }
.flyway-dialog .dialoghead { margin-bottom: 18px; }
.flyway-dialog .dialoghead h2 { margin-top: 4px; }
.flyway-dialog small { color: var(--muted); }
.flyway-dialog .buttonrow button { max-width: 100%; }
.reset-options { display: grid; gap: 8px; }
.reset-options>label { display: flex; gap: 12px; border: 1px solid transparent; border-radius: 12px; padding: 16px; cursor: pointer; margin: 0; }
.reset-options>label:hover { background: var(--panel2); }
.reset-options>label:has(input:checked) { background: var(--accent-soft); }
.reset-options input { width: 18px; height: 18px; flex: 0 0 18px; margin: 3px 0; }
.reset-options span { display: flex; flex-direction: column; gap: 5px; }
.reset-options b { color: var(--text); }
.reset-options small { font-size: 12px; font-weight: 400; }
.dialog-actions { justify-content: flex-end; margin-top: 20px; }
.device-select { display: flex; gap: 20px; flex-wrap: wrap; padding: 8px 0; }
.device-rows { display: grid; gap: 28px; margin: 28px 0; }
.device-row { min-width: 0; }
.device-row-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.device-row p { margin: 10px 0; }
.device-row .buttonrow { margin-top: 14px; }
.device-reading { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--cyan); overflow-wrap: anywhere; }
.device-troubleshooting { margin: 24px 0; padding-top: 8px; }
/* Calibration keeps the image at its native aspect ratio. */
#paperCalDialog { width: min(1180px,96vw); max-width: 1180px; max-height: 94dvh; padding: 0; overflow: auto; }
#paperCalDialog .dialoghead { position: sticky; top: 0; z-index: 2; background: var(--panel); padding: 20px 24px; }
#paperCalDialog h2 { font-size: 22px; margin: 4px 0; }
.paper-intro { padding: 0 24px; font-size: 13px; color: var(--muted); line-height: 1.7; }
.paper-layout { display: grid; grid-template-columns: minmax(0,1fr) 335px; gap: 28px; padding: 24px; }
.paper-view,.paper-controls { min-width: 0; }
.paper-controls { padding: 18px; background: var(--panel2); border-radius: 16px; }
.paper-stage { position: relative; border-radius: 12px; overflow: hidden; background: #0b141b; margin-top: 16px; }
#pcCanvas,#pcCorrected { display: block; width: 100%; height: auto; touch-action: none; }
#pcCanvas { cursor: crosshair; }
#pcLoupe { position: absolute; right: 8px; top: 8px; width: 110px; height: 110px; border: 2px solid var(--cyan); border-radius: 10px; pointer-events: none; }
.paper-inline { font-size: 12px; margin: 0; }
.paper-inline select { padding: 6px; font-size: 12px; }
.paper-controls .widebutton { margin-top: 10px; }
.paper-controls .notice p { margin: 0 0 10px; }
.paper-controls .notice p:last-child { margin: 0; }
.shotlist { max-height: 180px; overflow: auto; padding: 0; list-style: none; font-size: 12px; }
.shotlist li { display: flex; justify-content: space-between; gap: 6px; align-items: center; padding: 8px 0; }
#pcMarkStatus { min-height: 1.75em; margin: 12px 0; }
#pcPreviewDetails { margin-top: 20px; }
#paperCalDialog input,#paperCalDialog select { max-width: 100%; min-width: 0; }
#markToolbar { position: fixed; z-index: 30; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow); max-width: 96vw; }
#markToolbar span { color: var(--cyan); font-size: 12px; margin-right: 8px; min-width: 140px; }
#markToolbar button { min-height: 38px; font-size: 12px; }
body.marking .stage #overlay { cursor: crosshair; touch-action: none; }
body.marking .stage { outline: 2px solid var(--cyan); outline-offset: 3px; }
@media (max-width: 1100px) {
  .topbar { padding: 0 24px; }
  .topstatus .version { display: none; }
  main { padding: 24px 24px 0; }
  .dashboard { grid-template-columns: minmax(0,1fr) 285px; gap: 24px; }
  .tuningbody { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .lowergrid { grid-template-columns: 1fr; }
  .device-pills { flex-basis: 50%; }
  .device-actions { margin-left: auto; }
}
@media (max-width: 820px) {
  .topstatus { display: none; }
  .dashboard { display: flex; flex-direction: column; gap: 28px; }
  .maincol { display: contents; }
  .video-panel { order: 0; }
  #tuningPanel { order: 1; margin-top: 0; }
  .sidecol { order: 2; display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
  .metricgrid { margin: 0; }
  .diagnostics { margin-top: 0; }
  .lowergrid { order: 3; margin-top: 0; grid-template-columns: 1fr 1fr; }
  .device-pills { order: 3; flex-basis: 100%; }
  .device-actions { margin-left: 0; }
  .tabnote { display: none; }
  .paper-layout { grid-template-columns: 1fr; padding: 20px; gap: 24px; }
  #paperCalDialog { width: 100vw; max-width: none; max-height: 100dvh; border-radius: 0; margin: 0; min-height: 100dvh; }
  #paperCalDialog .dialoghead { padding: 16px 20px; }
  .paper-intro { padding: 0 20px; }
  #paperCalDialog h2 { font-size: 19px; }
  #pcLoupe { width: 90px; height: 90px; }
}
@media (max-width: 550px) {
  .topbar { min-height: 68px; padding: 0 16px; gap: 8px; }
  .brand { font-size: 21px; gap: 7px; }
  .brand svg { width: 28px; }
  .brand small { font-size: 7px; letter-spacing: 1.3px; }
  .topactions { gap: 2px; }
  .topactions button { padding: 10px; font-size: 12px; }
  .topactions #btnHelp,.key,#btnTheme span { display: none; }
  .topactions #btnTheme { width: 44px; min-height: 44px; padding: 10px; }
  main { padding: 24px 16px 0; }
  .pagehead { flex-wrap: wrap; gap: 10px; margin-bottom: 24px; }
  h1 { font-size: 26px; letter-spacing: -.8px; }
  .pagehead p { font-size: 12px; line-height: 1.7; }
  .pagehead>button { padding-left: 0; min-height: 36px; font-size: 12px; }
  .device-strip { gap: 12px; margin-bottom: 24px; }
  .device-strip-title { width: 100%; }
  .device-strip-title small { font-size: 11px; }
  .device-pills { order: 0; gap: 6px; }
  .device-pill { font-size: 10px; padding: 5px 8px; }
  .device-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .device-actions button { min-height: 44px; font-size: 12px; padding: 9px 8px; }
  .tabs { gap: 0; justify-content: space-between; margin-bottom: 24px; }
  .tabs button { padding: 10px; min-height: 44px; font-size: 12px; }
  .panelhead { flex-wrap: wrap; gap: 10px; padding-bottom: 14px; }
  .panelhead h2 { font-size: 14px; }
  .badge { font-size: 10px; }
  .stage { min-height: 310px; }
  .stage.has-source { min-height: 0; }
  .empty { padding: 20px 12px; }
  .empty h2 { font-size: 21px; }
  .empty p { font-size: 12px; margin: 10px 0 20px; }
  .sourcebuttons { gap: 8px; }
  .sourcebuttons button { font-size: 12px; min-height: 44px; padding: 10px; }
  .empty .textbutton { font-size: 12px; }
  .empty small { font-size: 10px; max-width: 28ch; margin-top: 8px; }
  .transport { gap: 6px; }
  .transport span { font-size: 10px; }
  .transport select { width: 58px; font-size: 12px; min-height: 44px; padding: 6px; }
  .transport button { min-height: 44px; }
  .analysisbar>button { flex: 1; min-height: 44px; font-size: 12px; padding: 10px; }
  .analysisbar .extra-controls button { min-height: 44px; font-size: 12px; }
  .extra-controls summary { min-height: 44px; }
  .notice { padding: 14px; font-size: 12px; }
  .tuningbody { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px 12px; }
  .tuner:has([data-setting=focalScale]) { grid-column: 1/-1; }
  .tuner label { min-height: 0; }
  .tuner input[type=range] { height: 28px; }
  .tuning .buttonrow button { font-size: 12px; min-height: 44px; }
  .sidecol { display: flex; flex-direction: column; gap: 28px; }
  .metricgrid { gap: 24px; }
  .metric strong { font-size: 30px; }
  .metric>span { font-size: 12px; }
  .metric small { font-size: 11px; }
  .trajectory #world { height: 270px; }
  .diagnostics dl { font-size: 12px; }
  .lowergrid,.sourcecards { grid-template-columns: 1fr; gap: 28px; }
  .sourceintro h2 { font-size: 19px; }
  .sourcecard p,.sourcecard>small { font-size: 12px; }
  .drawerhead { padding: 20px 16px; }
  .drawerbody { padding: 0 16px calc(32px + env(safe-area-inset-bottom)); }
  input:not([type=range]):not([type=checkbox]):not([type=radio]),select,textarea { font-size: 16px; min-height: 44px; }
  .fields { gap: 0 10px; }
  .buttonrow button { font-size: 12px; min-height: 44px; }
  .videoHUD { font-size: 10px; bottom: 8px; left: 8px; right: 8px; }
  .stage-label { font-size: 9px; top: 8px; left: 8px; max-width: calc(100% - 16px); }
  .selection-hint { font-size: 11px; top: 7px; padding: 8px 10px; }
  .tablewrap { max-height: 460px; }
  footer { flex-direction: column; gap: 8px; font-size: 10px; margin-top: 16px; padding: 24px 0; }
  dialog { padding: 20px 16px; }
  .dialoghead h2 { font-size: 20px; }
  .flyway-dialog .buttonrow button { flex: 1; min-width: 110px; white-space: normal; }
  .device-select { gap: 4px 16px; }
  .device-row-head { align-items: flex-start; }
  .reset-options>label { padding: 12px; }
  #paperCalDialog button { min-height: 44px; }
  .paper-layout { padding: 16px; }
  .paper-controls { padding: 16px; }
  #paperCalDialog .dialoghead { padding: 16px; }
  .paper-intro { padding: 0 16px; }
  #markToolbar { bottom: 12px; flex-wrap: wrap; justify-content: center; width: 94vw; padding: 10px; gap: 6px; }
  #markToolbar span { width: 100%; text-align: center; margin: 0; }
  #markToolbar button { min-height: 44px; font-size: 11px; padding: 8px; }
}
@media (max-width: 390px) {
  .drawer .fields { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto!important; transition: none!important; }
  button:active:not(:disabled) { transform: none; }
}
@media (forced-colors: active) {
  button,.badge,.device-pill,.reset-options>label:has(input:checked) { border: 1px solid ButtonText; }
  .tabs button.active { outline: 2px solid Highlight; }
}
@media print {
  .topbar,.tabs,.transport,.analysisbar,.drawer,button,#tab-sources,footer { display: none!important; }
  body,main { background: white; color: black; }
  .dashboard { display: block; }
  .panel { break-inside: avoid; }
  .metricgrid { display: flex; }
  .metric { flex: 1; }
}
