:root {
  --bg: #050b13; --panel: #0d1927; --panel2: #13253a; --line: #1f3852;
  --fg: #e9f2fc; --dim: #7a93ae; --accent: #38c8ff; --acc: 56, 200, 255;
  --ok: #3ddc97; --warn: #ffb53d; --crit: #ff5252; --beam: 255, 232, 170;
  --btn-top: #1d3752; --btn-bot: #142a42;
  font-family: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, sans-serif;
}
body[data-theme="night"] {
  --bg: #02060a; --panel: #07111a; --panel2: #0c1b28; --line: #142738;
  --fg: #8aa2b8; --dim: #46596c; --accent: #2b86ba; --acc: 43, 134, 186;
  --ok: #2c9c6a; --warn: #a97a1c; --crit: #a83a3a; --beam: 150, 138, 100;
  --btn-top: #0f2234; --btn-bot: #0a1824;
}
body[data-theme="red"] {
  --bg: #070202; --panel: #110504; --panel2: #1b0907; --line: #371510;
  --fg: #d44c3d; --dim: #7a2c24; --accent: #e8442f; --acc: 232, 68, 47;
  --ok: #c9482e; --warn: #d65a2b; --crit: #ff3b2b; --beam: 210, 60, 40;
  --btn-top: #240d0a; --btn-bot: #180806;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; color: var(--fg); user-select: none; -webkit-user-select: none; overflow: hidden; touch-action: manipulation;
  background: radial-gradient(1200px 700px at 30% 20%, rgba(var(--acc), .10), transparent 60%), radial-gradient(900px 600px at 90% 100%, rgba(var(--acc), .06), transparent 60%), var(--bg);
  font-size: 15px; line-height: 1.3; }
.ico { width: 1.25em; height: 1.25em; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button { font: inherit; color: var(--fg); min-height: 48px; padding: 0 14px; cursor: pointer; touch-action: none;
  background: linear-gradient(180deg, var(--btn-top), var(--btn-bot)); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07), 0 2px 6px rgba(0,0,0,.35); transition: transform .08s, filter .15s, box-shadow .2s, background .2s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; letter-spacing: .04em; }
button:active { transform: scale(.97); filter: brightness(1.3); }
button.on, button.active { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, #fff), var(--accent));
  border-color: color-mix(in srgb, var(--accent) 70%, #fff); color: #04131d; font-weight: 800;
  box-shadow: 0 0 0 1px rgba(var(--acc), .3), 0 0 22px rgba(var(--acc), .45), inset 0 1px 0 rgba(255,255,255,.5); }
body[data-theme="red"] button.on { color: #1a0402; }
button:disabled { opacity: .3; pointer-events: none; }
#app { height: 100%; display: flex; flex-direction: column; }
.glass { background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,0) 40%), color-mix(in srgb, var(--panel) 88%, transparent);
  border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 14px 40px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.05); backdrop-filter: blur(8px); }

/* header */
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 18px 4px; flex: 0 0 auto; }
.brand { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.logo { width: 38px; height: 38px; filter: drop-shadow(0 0 10px rgba(var(--beam), .5)); }
.brand b { display: block; font-size: 18px; font-weight: 800; letter-spacing: .24em; }
.brand small { display: block; color: var(--dim); font-size: 10.5px; letter-spacing: .18em; margin-top: 1px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.chip { position: relative; background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.01)); border: 1px solid var(--line);
  border-radius: 12px; padding: 4px 12px 5px 14px; min-width: 76px; }
.chip::before { content: ""; position: absolute; top: 9px; left: 7px; width: 5px; height: 5px; border-radius: 50%; background: var(--dim); }
.chip label { display: block; font-size: 9.5px; color: var(--dim); letter-spacing: .16em; }
.chip b { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chip.ok::before { background: var(--ok); box-shadow: 0 0 8px var(--ok); } .chip.ok b { color: var(--ok); }
.chip.warn::before { background: var(--warn); box-shadow: 0 0 8px var(--warn); } .chip.warn b { color: var(--warn); }
.chip.crit::before { background: var(--crit); box-shadow: 0 0 8px var(--crit); animation: blink 1s infinite; } .chip.crit b { color: var(--crit); }
.chip.mode.ok b { color: var(--accent); } .chip.mode.ok::before { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
@keyframes blink { 50% { opacity: .25; } }

#banner { margin: 6px 18px 0; padding: 10px 16px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  border-radius: 12px; animation: slide .25s ease-out; }
#banner.warn { background: linear-gradient(90deg, #6a4300, #3b2600); border: 1px solid var(--warn); color: #ffd890; }
#banner.crit { background: linear-gradient(90deg, #6b1414, #3a0b0b); border: 1px solid var(--crit); color: #ffc4c4; }
#banner button { min-height: 34px; background: rgba(255,255,255,.14); color: #fff; }
@keyframes slide { from { transform: translateY(-8px); opacity: 0; } }

main { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 196px 410px; gap: 12px; padding: 8px 18px 16px; }
#dialSec, #tiltSec, aside { min-height: 0; position: relative; }
#dialSec { display: flex; align-items: center; justify-content: center; padding: 6px;
  background: radial-gradient(closest-side at 50% 50%, rgba(var(--acc), .10), transparent 80%), linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,0) 40%), color-mix(in srgb, var(--panel) 88%, transparent); }
#dial { height: 100%; max-width: 100%; aspect-ratio: 1; touch-action: none; }
#tiltSec { padding: 6px; display: flex; justify-content: center; }
#tilt { height: 100%; max-width: 100%; touch-action: none; }
.readout { position: absolute; top: 14px; z-index: 2; pointer-events: none; }
.readout.left { left: 20px; } .readout.right { right: 20px; text-align: right; }
.readout label { display: block; font-size: 10.5px; color: var(--dim); letter-spacing: .18em; }
.readout b { font-size: 48px; font-weight: 300; font-variant-numeric: tabular-nums; letter-spacing: -.02em; text-shadow: 0 0 24px rgba(var(--acc), .35); }
.dialHint { position: absolute; bottom: 10px; left: 0; right: 0; text-align: center; font-size: 11.5px; color: var(--dim); letter-spacing: .06em; pointer-events: none; }
.beamTag { position: absolute; right: 18px; bottom: 14px; z-index: 2; text-align: right; background: rgba(0,0,0,.25); border: 1px solid var(--line); border-radius: 12px; padding: 5px 12px; backdrop-filter: blur(6px); }
.beamTag label { display: block; font-size: 9.5px; letter-spacing: .18em; color: var(--dim); }
.beamTag b { font-size: 15px; font-weight: 700; color: rgb(var(--beam)); letter-spacing: .06em; }
#camHud { display: none; position: absolute; top: 16px; left: 50%; transform: translateX(-50%); z-index: 3; font-size: 11px; font-weight: 700; letter-spacing: .2em; padding: 5px 14px;
  border-radius: 20px; background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.18); color: #fff; backdrop-filter: blur(6px); pointer-events: none; white-space: nowrap; }
#camHud i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #ff4d4d; margin-right: 8px; animation: blink 1.2s infinite; box-shadow: 0 0 8px #ff4d4d; }
#dialSec.cam #camHud { display: block; }
.seg.beam button { flex-direction: column; gap: 0; min-height: 46px; font-size: 14px; letter-spacing: .1em; }
.seg.beam small { font-size: 10px; font-weight: 500; letter-spacing: .06em; opacity: .75; }
.camBtn { position: absolute; left: 16px; bottom: 16px; min-height: 44px; z-index: 2; }

aside { display: flex; flex-direction: column; overflow: hidden; }
#tabs { display: flex; gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); }
#tabs button { flex: 1; flex-direction: column; gap: 3px; min-height: 56px; padding: 6px 0; font-size: 10.5px; letter-spacing: .1em; background: transparent; border-color: transparent; box-shadow: none; color: var(--dim); }
#tabs button.on { background: rgba(var(--acc), .14); color: var(--accent); border-color: rgba(var(--acc), .4); box-shadow: inset 0 -2px 0 var(--accent); }
.panel { display: none; padding: 12px; overflow-y: auto; flex: 1; }
.panel.on { display: block; animation: fade .2s; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }
.panel::-webkit-scrollbar { width: 6px; } .panel::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.big { width: 100%; min-height: 72px; font-size: 23px; letter-spacing: .14em; border-radius: 18px; gap: 12px; }
.big .ico { width: 34px; height: 34px; }
.big b { font-weight: 800; } .big span { font-size: 13px; letter-spacing: .12em; opacity: .75; padding: 3px 10px; border-radius: 20px; background: rgba(255,255,255,.08); }
.big.on { background: linear-gradient(180deg, rgb(var(--beam)), color-mix(in srgb, rgb(var(--beam)) 80%, #ff9a1f)); color: #2a1c00; border-color: rgba(255,255,255,.6);
  box-shadow: 0 0 0 1px rgba(var(--beam), .5), 0 0 38px rgba(var(--beam), .55), inset 0 1px 0 rgba(255,255,255,.7); }
.big.on span { background: rgba(0,0,0,.12); }
.row { margin-top: 10px; } .row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lbl { display: flex; justify-content: space-between; align-items: baseline; font-size: 11px; color: var(--dim); letter-spacing: .16em; margin-bottom: 6px; }
.lbl b { color: var(--fg); font-size: 16px; letter-spacing: 0; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 40px; background: transparent; touch-action: none; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 10px; border-radius: 6px; border: 1px solid var(--line);
  background: linear-gradient(90deg, var(--accent) var(--p, 50%), var(--bg) var(--p, 50%)); box-shadow: inset 0 1px 3px rgba(0,0,0,.6); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 32px; height: 32px; margin-top: -12px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #cfe3f2); border: 3px solid var(--accent); box-shadow: 0 0 16px rgba(var(--acc), .6), 0 2px 6px rgba(0,0,0,.5); }
input[type=range]::-moz-range-track { height: 10px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); }
input[type=range]::-moz-range-progress { height: 10px; border-radius: 6px; background: var(--accent); }
input[type=range]::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); }
.seg { display: flex; gap: 3px; padding: 3px; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; box-shadow: inset 0 1px 4px rgba(0,0,0,.5); }
.seg button { flex: 1; min-height: 38px; padding: 0 6px; font-size: 12.5px; background: transparent; border-color: transparent; box-shadow: none; border-radius: 11px; color: var(--dim); }
.seg button.on { color: #04131d; background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, #fff), var(--accent)); box-shadow: 0 0 14px rgba(var(--acc), .45), inset 0 1px 0 rgba(255,255,255,.5); }
#tabs .ico { width: 1.5em; height: 1.5em; }
.seg.vert { flex-direction: column; width: 74px; }
.jogwrap { display: flex; gap: 12px; align-items: stretch; }
.jog { display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 46px; gap: 6px; flex: 1; padding: 7px; border-radius: 26px;
  background: radial-gradient(circle, rgba(var(--acc), .08), transparent 70%), var(--bg); border: 1px solid var(--line); box-shadow: inset 0 2px 8px rgba(0,0,0,.5); }
.jog button { min-height: 0; padding: 0; border-radius: 16px; font-size: 22px; }
.jog .ico { width: 30px; height: 30px; stroke-width: 2.4; }
.jog button.hold:active, .jog button.held { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, #fff), var(--accent)); color: #04131d; box-shadow: 0 0 22px rgba(var(--acc), .55); }
.jog .stop { font-size: 12px; font-weight: 800; letter-spacing: .1em; border-radius: 50%; background: linear-gradient(180deg, #8a2a2a, #5a1717); border-color: #b04040; color: #fff; box-shadow: 0 0 16px rgba(255,60,60,.25); }
.quick { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.quick button { min-height: 44px; font-size: 12px; padding: 0 4px; letter-spacing: .02em; }
.quick .park { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }

.card { background: linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,0)), var(--panel2); border: 1px solid var(--line); border-radius: 16px; padding: 12px; margin-bottom: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.cardhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 8px; }
h3 { margin: 0; font-size: 11px; letter-spacing: .2em; color: var(--dim); font-weight: 700; }
p { margin: 6px 0 0; font-size: 13px; } p.dim, .dim { color: var(--dim); }
button.small { min-height: 38px; font-size: 12.5px; padding: 0 14px; }
.btnpair { display: flex; gap: 6px; }
button.mob { min-height: 38px; font-size: 12.5px; background: linear-gradient(180deg, #d63a3a, #a82424); border-color: #ff7a7a; color: #fff; font-weight: 800; box-shadow: 0 0 14px rgba(255,60,60,.3); }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 8px 0; font-size: 13.5px; } .kv .seg { width: 215px; }

.trow { display: grid; grid-template-columns: 1fr auto 86px; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.trow:first-child { border-top: 0; }
.trow small { color: var(--dim); display: block; font-variant-numeric: tabular-nums; font-size: 12px; }
.trow button { min-height: 40px; font-size: 12px; }
.steppers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.stepper { display: grid; grid-template-columns: 1fr 1.3fr 1fr; grid-template-rows: auto auto; gap: 4px; align-items: center; text-align: center; }
.stepper label { grid-column: 1 / -1; font-size: 10.5px; color: var(--dim); letter-spacing: .16em; }
.stepper button { min-height: 42px; padding: 0; font-size: 20px; } .stepper b { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }

#presetGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#presetGrid button { min-height: 80px; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; padding: 8px 14px; text-align: left; border-radius: 16px; }
#presetGrid button b { font-size: 16px; letter-spacing: .02em; } #presetGrid button small { opacity: .7; font-variant-numeric: tabular-nums; font-weight: 500; font-size: 12px; letter-spacing: 0; }
#presetGrid button.saving { border-style: dashed; border-color: var(--warn); animation: blink 1.4s infinite; }

.meter { display: grid; grid-template-columns: 84px 1fr 66px; gap: 10px; align-items: center; margin: 9px 0; font-size: 13px; }
.meter label { color: var(--dim); font-size: 12px; } .meter b { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.bar { height: 10px; background: var(--bg); border-radius: 6px; overflow: hidden; border: 1px solid var(--line); box-shadow: inset 0 1px 3px rgba(0,0,0,.6); }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, rgba(var(--acc), .5), var(--accent)); border-radius: 6px; transition: width .2s; }
.simbtns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

#toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; z-index: 10; }
.toast { background: linear-gradient(180deg, #17304a, #0f2237); border: 1px solid var(--accent); padding: 11px 20px; border-radius: 14px; font-weight: 600; letter-spacing: .02em;
  box-shadow: 0 8px 30px rgba(0,0,0,.6), 0 0 18px rgba(var(--acc), .25); animation: slide .25s ease-out; }
.toast.warn { border-color: var(--warn); } .toast.crit { border-color: var(--crit); background: linear-gradient(180deg, #4a1717, #2b0c0c); }

/* dial svg */
.d-bezel { fill: url(#bezel); stroke: var(--line); stroke-width: 2; }
.d-rr { fill: none; stroke: rgba(var(--acc), .16); stroke-width: 1.5; stroke-dasharray: 3 8; }
.d-cross { stroke: rgba(var(--acc), .12); stroke-width: 1.5; }
.d-tick { stroke: var(--dim); stroke-width: 1.5; opacity: .6; } .d-tick.mid { opacity: .9; stroke-width: 2; } .d-tick.maj { stroke: var(--fg); stroke-width: 3; opacity: 1; }
.d-num { fill: var(--dim); font-size: 21px; text-anchor: middle; dominant-baseline: central; font-weight: 500; font-variant-numeric: tabular-nums; }
.d-card { fill: var(--accent); font-size: 19px; text-anchor: middle; dominant-baseline: central; font-weight: 800; letter-spacing: .12em; }
.d-ptr { stroke: var(--accent); stroke-width: 3; stroke-linecap: round; }
.d-tgt { fill: none; stroke: var(--warn); stroke-width: 4; stroke-linejoin: round; }
.d-sweep { fill: none; stroke: var(--accent); stroke-width: 12; opacity: .3; stroke-linecap: round; }
.d-nbadge { fill: var(--crit); } .d-ntxt { fill: #fff; font-weight: 800; font-size: 17px; text-anchor: middle; dominant-baseline: central; }
#dTgt { animation: pulse 1.4s ease-in-out infinite; } @keyframes pulse { 50% { opacity: .45; } }
.t-lamp { fill: url(#tLampG); stroke: var(--dim); stroke-width: 2; }
.t-track { stroke: var(--bg); stroke-width: 14; stroke-linecap: round; } .t-trackb { stroke: var(--line); stroke-width: 16; stroke-linecap: round; }
.t-fill { stroke: var(--accent); stroke-width: 8; stroke-linecap: round; opacity: .55; }
.t-handle { fill: radial-gradient(circle, #fff, #cde); fill: #fff; stroke: var(--accent); stroke-width: 5; }
.t-tgt { fill: none; stroke: var(--warn); stroke-width: 4; animation: pulse 1.4s ease-in-out infinite; }
.t-tick { stroke: var(--dim); stroke-width: 1.5; opacity: .7; } .t-num { fill: var(--dim); font-size: 15px; dominant-baseline: central; font-variant-numeric: tabular-nums; }
.t-hor { stroke: rgba(var(--acc), .4); stroke-width: 1.5; stroke-dasharray: 6 6; }
.t-readout { fill: var(--fg); font-size: 34px; font-weight: 300; text-anchor: middle; font-variant-numeric: tabular-nums; }
.t-cap { fill: var(--dim); font-size: 11px; letter-spacing: .2em; text-anchor: middle; }

/* camera mode */
#dial.cam .d-boat, #dial.cam .d-boatx { display: none; }
#dial.cam .d-bezel { fill: none; }
#dial.cam .d-num { fill: #fff; stroke: #000; stroke-width: 5px; paint-order: stroke; }
#dial.cam .d-card { stroke: #000; stroke-width: 5px; paint-order: stroke; }
#dial.cam .d-tick { stroke: #fff; opacity: 1; }
#dial.cam .d-rr, #dial.cam .d-cross { stroke: rgba(255,255,255,.25); }
#dial.cam #dBeam { mix-blend-mode: screen; }

@media (max-height: 790px) {
  .panel { padding: 9px 12px; }
  .big { min-height: 54px; font-size: 20px; } .big .ico { width: 28px; height: 28px; }
  .row { margin-top: 7px; } .lbl { margin-bottom: 3px; }
  input[type=range] { height: 30px; }
  .seg button { min-height: 32px; } .seg.beam button { min-height: 38px; }
  .row.two button { min-height: 40px; }
  .jog { grid-auto-rows: 38px; gap: 5px; padding: 6px; border-radius: 22px; } .jog .ico { width: 24px; height: 24px; }
  .quick button { min-height: 38px; }
  #tabs button { min-height: 48px; } #tabs .ico { width: 1.3em; height: 1.3em; }
  .card { padding: 10px; margin-bottom: 9px; }
  header { padding-top: 6px; } .readout b { font-size: 40px; }
}
@media (max-width: 1100px), (max-height: 640px) {
  main { grid-template-columns: minmax(0, 1fr) 100px 350px; gap: 8px; padding: 6px 10px 10px; }
  .readout b { font-size: 30px; } .chip { min-width: 58px; padding: 2px 8px 3px 12px; } .chip b { font-size: 14px; }
  .big { min-height: 64px; font-size: 20px; } .jog { grid-auto-rows: 46px; } .brand small { display: none; }
  header { padding: 6px 10px 2px; }
}
