:root {
  color-scheme: dark;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  color: #eef2ed;
  background: #111717;
  font-synthesis: none;
  --surface: #192020;
  --stroke: #303a39;
  --soft: #9aa8a6;
  --accent: #c5ee9c;
  --accent-dim: #243425;
  --danger: #ffc0af;
  --warning: #eed29a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 315px; }
button, select, input { font: inherit; }
button { cursor: pointer; color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button:hover { filter: brightness(1.13); }
h1, h2, p { margin: 0; }
h2 { font-size: 15px; font-weight: 650; letter-spacing: -.015em; }

.shell {
  min-height: 100dvh;
  max-width: 1680px;
  margin: 0 auto;
  padding: clamp(14px, 2.2vw, 32px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 18px;
}
.topbar, .top-actions, .wordmark, .camera-bar, .camera-title, .camera-actions,
.radio-row, .drive-header, .axis-caption, .footer, .shortcut { display: flex; align-items: center; }
.topbar { justify-content: space-between; gap: 18px; min-height: 43px; }
.wordmark { gap: 10px; white-space: nowrap; color: inherit; text-decoration: none; }
.wordmark h1 { font-size: 23px; letter-spacing: -.056em; font-weight: 780; }
.wordmark h1 span { color: var(--accent); }
.brand-icon, .lens-icon { display: grid; place-items: center; }
.brand-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); }
.brand-icon i { width: 18px; height: 18px; border: 2px solid #253826; border-radius: 50%; position: relative; }
.brand-icon i::before, .brand-icon i::after { content: ""; position: absolute; background: #253826; }
.brand-icon i::before { width: 12px; height: 2px; left: 1px; top: 5px; }
.brand-icon i::after { width: 2px; height: 8px; left: 6px; top: 6px; }
.top-actions { gap: 8px; }
.chip, .settings-button, .icon-button, .secondary-button, .primary-button {
  border: 1px solid var(--stroke);
  border-radius: 9px;
  padding: 8px 11px;
  background: var(--surface);
}
.chip, .settings-button { min-height: 36px; display: inline-flex; align-items: center; gap: 8px; font-size: 12px; white-space: nowrap; }
.chip { color: var(--soft); }
.settings-button > span { font-size: 18px; line-height: 16px; }
.download { color: var(--accent); text-decoration: none; }
.dot { display: inline-block; flex: 0 0 7px; width: 7px; height: 7px; border-radius: 50%; background: #70807d; }
.dot[data-status="ok"] { background: var(--accent); box-shadow: 0 0 9px #bde68b55; }
.dot[data-status="warn"] { background: var(--warning); }
.dot[data-status="bad"] { background: var(--danger); }
.deck { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) clamp(254px, 25vw, 318px); }
.camera-panel, .panel, .footer { border: 1px solid var(--stroke); border-radius: 14px; background: var(--surface); }
.camera-panel { min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.camera-bar { padding: 8px 13px 8px 16px; justify-content: space-between; gap: 8px; min-height: 51px; }
.camera-title, .camera-actions { gap: 10px; }
.camera-icon { display: inline-block; width: 17px; height: 13px; border: 1.5px solid var(--soft); border-radius: 3px; position: relative; }
.camera-icon::after { content: ""; width: 5px; height: 5px; border: 1.5px solid var(--soft); border-radius: 50%; position: absolute; top: 2px; left: 4px; }
.camera-status { display: inline-flex; align-items: center; gap: 7px; color: var(--soft); font-size: 12px; }
.icon-button { min-width: 32px; min-height: 32px; padding: 4px; display: grid; place-items: center; font-size: 20px; }
.expand-icon {
  width: 13px;
  height: 13px;
  background: linear-gradient(currentColor, currentColor) left top / 4px 1px,
              linear-gradient(currentColor, currentColor) right top / 4px 1px,
              linear-gradient(currentColor, currentColor) left bottom / 4px 1px,
              linear-gradient(currentColor, currentColor) right bottom / 4px 1px,
              linear-gradient(currentColor, currentColor) left top / 1px 4px,
              linear-gradient(currentColor, currentColor) right top / 1px 4px,
              linear-gradient(currentColor, currentColor) left bottom / 1px 4px,
              linear-gradient(currentColor, currentColor) right bottom / 1px 4px;
  background-repeat: no-repeat;
}
.viewfinder {
  flex: 1;
  min-height: 360px;
  position: relative;
  display: grid;
  place-items: center;
  border-top: 1px solid var(--stroke);
  isolation: isolate;
  background:
    radial-gradient(ellipse at 50% 43%, #23302a66, #0b111100 62%),
    radial-gradient(#34423d 1px, transparent 1px),
    #0c1212;
  background-size: auto, 21px 21px, auto;
}
.viewfinder canvas { visibility: hidden; position: absolute; width: 100%; height: 100%; object-fit: contain; }
.viewfinder.live canvas { visibility: visible; }
.viewfinder.live { background: #080c0b; }
.viewfinder canvas[data-orientation="flip"] { transform: scaleY(-1); }
.viewfinder canvas[data-orientation="rotate"] { transform: rotate(180deg); }
.camera-guides { position: absolute; inset: 20px; pointer-events: none; }
.camera-guides i { position: absolute; width: 22px; height: 22px; border: solid #8da49a72; }
.camera-guides i:nth-child(1) { top: 0; left: 0; border-width: 1px 0 0 1px; }
.camera-guides i:nth-child(2) { top: 0; right: 0; border-width: 1px 1px 0 0; }
.camera-guides i:nth-child(3) { bottom: 0; left: 0; border-width: 0 0 1px 1px; }
.camera-guides i:nth-child(4) { bottom: 0; right: 0; border-width: 0 1px 1px 0; }
.camera-placeholder { position: relative; display: grid; justify-items: center; text-align: center; padding: 40px; }
.lens-icon { width: 57px; height: 57px; border: 1px solid #41524a; border-radius: 15px; background: #1d2924; margin-bottom: 16px; }
.lens-icon i { width: 26px; height: 20px; border: 1.5px solid #aebfb7; border-radius: 5px; display: grid; place-items: center; }
.lens-icon i::after { content: ""; width: 9px; height: 9px; border: 1.5px solid #aebfb7; border-radius: 50%; }
#camera-title { font-size: clamp(20px, 2.2vw, 30px); letter-spacing: -.04em; font-weight: 690; }
#camera-hint { color: var(--soft); max-width: 270px; margin: 8px 0 18px; font-size: 13px; line-height: 1.55; }
.secondary-button { background: #202a28; font-size: 13px; min-height: 35px; }
.camera-address { position: absolute; bottom: 20px; right: 30px; background: #0e1715d9; padding: 5px 8px; border-radius: 5px; font: 11px ui-monospace, monospace; color: #c1cdca; }
.camera-panel:fullscreen { border-radius: 0; height: 100%; }
.sidebar { display: flex; flex-direction: column; gap: 14px; }
.panel { padding: 15px; min-width: 0; }
.car-buttons { display: grid; gap: 7px; margin: 13px 0; max-height: 238px; overflow-y: auto; }
.compact-button { border: 1px solid var(--stroke); background: #202a28; border-radius: 7px; font-size: 12px; padding: 5px 8px; }
.car {
  display: grid;
  grid-template-columns: 35px minmax(0, 1fr) 12px;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 54px;
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid var(--stroke);
  background: #151c1c;
  text-align: left;
}
.car[aria-pressed="true"] { border-color: #709068; background: #253428; }
.car-name { font-size: 13px; font-weight: 680; }
.car-name span { display: block; font-size: 11px; font-weight: 450; margin-top: 2px; color: var(--soft); }
.car-choice { border: 1px solid #71817b; width: 12px; height: 12px; border-radius: 50%; }
.car[aria-pressed="true"] .car-choice { border: 3px solid var(--accent); }
.car-icon { background: #252e2e; width: 34px; height: 34px; border-radius: 7px; display: grid; place-items: center; }
.car-icon.yellow { color: #f1ce7d; background: #3a3222; }
.car-icon.red { color: #f49b8e; background: #392a29; }
.car-icon.omni { color: #a4cbd0; background: #263638; }
.car-icon i { width: 18px; height: 9px; border-radius: 3px 4px 2px 2px; background: currentColor; position: relative; }
.car-icon i::before { content: ""; position: absolute; width: 10px; height: 5px; top: -4px; left: 4px; border: 1.5px solid currentColor; border-radius: 3px 4px 0 0; }
.car-icon i::after { content: ""; position: absolute; width: 5px; height: 5px; top: 6px; left: 2px; background: #151a1a; border-radius: 50%; box-shadow: 9px 0 #151a1a; }
.radio-row { gap: 6px; justify-content: space-between; color: var(--soft); font-size: 11px; min-height: 20px; }
.radio-row > span:first-child { display: inline-flex; align-items: center; gap: 7px; }
#radio-channel { white-space: nowrap; font-family: ui-monospace, monospace; }
.drive-panel { flex: 1; display: flex; flex-direction: column; }
.drive-header, .axis-caption { justify-content: space-between; gap: 8px; }
.speed-label { background: #27322e; color: #bed0c5; padding: 4px 7px; border-radius: 5px; white-space: nowrap; font-size: 11px; }
.axis { margin-top: 17px; }
.axis-caption { color: var(--soft); font-size: 12px; }
.axis-caption output { font: 600 12px ui-monospace, monospace; color: #d6dfdb; }
.meter { margin-top: 7px; height: 5px; border-radius: 6px; background: #333f3c; position: relative; }
.meter::before { position: absolute; left: calc(50% - 1px); top: -2px; height: 9px; width: 2px; background: #84918b; content: ""; z-index: 1; }
.meter > span { position: absolute; height: 100%; border-radius: 6px; width: var(--meter-size, 0%); left: var(--meter-start, 50%); background: var(--accent); }
.drive-state { margin-top: auto; padding: 15px 0 0; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--soft); min-height: 41px; }
.drive-state[data-status="ok"], .drive-state[data-status="ok"] i { color: var(--accent); }
.drive-state[data-status="ok"] i { background: var(--accent); }
.drive-state[data-status="warn"], .drive-state[data-status="warn"] i { color: var(--warning); }
.drive-state[data-status="warn"] i { background: var(--warning); }
.footer { gap: clamp(10px, 2.5vw, 31px); padding: 8px 11px 8px 15px; }
.shortcut { gap: 8px; color: var(--soft); font-size: 12px; }
kbd { display: inline-grid; place-items: center; min-width: 28px; height: 25px; padding: 0 4px; background: #263130; border: 1px solid #3e4d49; border-radius: 6px; color: #dce6e1; font: 600 11px ui-monospace, monospace; }
.stop-button { margin-left: auto; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; border-radius: 8px; padding: 5px 10px 5px 6px; background: #352726; border: 1px solid #65433e; color: var(--danger); font-size: 13px; font-weight: 650; }
.stop-button kbd { min-width: 24px; color: var(--danger); background: #48322e; border-color: #65433e; }

dialog { padding: 0; border: 1px solid var(--stroke); border-radius: 15px; background: var(--surface); color: inherit; width: min(460px, calc(100vw - 24px)); }
dialog::backdrop { background: #080d0dd0; }
.dialog-header, .dialog-actions { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 17px 19px; }
.dialog-header { border-bottom: 1px solid var(--stroke); }
.dialog-header h2 { font-size: 20px; }
.dialog-header p { color: var(--soft); margin-top: 3px; font-size: 12px; }
.fields { display: grid; gap: 12px; padding: 16px 19px; font-size: 13px; }
dialog form { display: flex; flex-direction: column; max-height: min(94dvh, 830px); }
.fields { overflow: auto; }
.fields fieldset { display: grid; gap: 11px; min-width: 0; margin: 0; border: 1px solid var(--stroke); border-radius: 8px; padding: 10px; }
.fields legend { padding: 0 5px; font-weight: 650; color: var(--accent); }
.field-hint { color: var(--soft); font-size: 12px; line-height: 1.4; }
.extra-action { display: grid; grid-template-columns: 90px 1fr 30px; gap: 6px; margin-bottom: 5px; align-items: end; }
.extra-action button { height: 34px; }
.fields label { display: block; min-width: 0; }
.fields input:not([type="checkbox"]), .fields select {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 8px 10px;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  color: inherit;
  background: #111919;
}
.fields input[type="range"] { padding: 0; accent-color: var(--accent); }
.fields label output { float: right; color: var(--accent); }
.select { display: block; position: relative; }
.select select { appearance: none; padding-right: 28px; }
.select::after { content: ""; pointer-events: none; position: absolute; right: 10px; top: 50%; width: 7px; height: 7px; border: solid var(--soft); border-width: 0 1.5px 1.5px 0; transform: translateY(-70%) rotate(45deg); }
.checks, .field-pair { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.checks input { accent-color: var(--accent); vertical-align: middle; }
.field-pair { grid-template-columns: 2fr 1fr; }
.field-pair.equal { grid-template-columns: 1fr 1fr; }
.form-error { color: var(--danger); }
.dialog-actions { justify-content: flex-end; border-top: 1px solid var(--stroke); }
.primary-button { background: var(--accent); color: #1b2b1d; font-weight: 650; min-height: 35px; font-size: 13px; }
.delete-car { margin-right: auto; color: var(--danger); }

@media (min-width: 901px) {
  .shell { height: 100dvh; min-height: 580px; }
}
@media (max-width: 900px) {
  .viewfinder { min-height: 350px; }
  .shell { gap: 12px; }
  .deck { gap: 11px; }
}
@media (max-width: 640px) {
  .deck { grid-template-columns: minmax(0, 1fr); }
  .topbar { align-items: flex-start; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  .chip, .settings-button { min-height: 30px; padding: 4px 7px; font-size: 11px; }
  .viewfinder { min-height: 270px; }
  .sidebar { gap: 11px; }
  .footer { flex-wrap: wrap; }
  .shortcut { font-size: 11px; }
}
