/* MyUGV — 어두운 조종석 톤 (DJI Fly 계열).
   Layout: 일반 화면은 얇은 상단 바 + 1240px 본문. 조종 화면은 상단 바 없이 영상이 화면 전체를 채우고,
   HUD(상단 상태 띠·나침반·좌우 궤도 눈금·미니맵·조작부)를 겹치며, 카메라/보정/상태는 오른쪽 패널로 연다.
   상태 색은 보드 LED 색과 같은 의미다 (펌웨어 tank_pwm.ino). */
:root {
  color-scheme: dark;
  --bg: #07090B;
  --paper: #0B0E11;          /* 입력칸 바탕 */
  --surface: #11161A;
  --raise: #182026;
  --sunken: #0A0D10;
  --line: #222A31;
  --line-strong: #34404A;
  --ink: #E9EEF2;
  --muted: #8C98A3;
  --dim: #5D6873;
  --accent: #8CC8FF;         /* 링크·포커스·선택 표시에만 */
  --accent-soft: rgba(140, 200, 255, 0.12);
  --on-accent: #06121D;
  --primary: #F1F4F6;        /* 주 버튼은 흰 알약 */
  --on-primary: #07090B;
  --led-wait: #4C9BFF;
  --led-idle: #3DDC84;
  --led-drive: #FFC233;
  --led-fail: #FF4D4F;
  --led-ota: #B07CFF;
  --led-off: #5D6873;
  --track-l: #8CC8FF;
  --track-r: #3FD0C4;
  --hud-bg: rgba(6, 8, 10, 0.58);
  --hud-line: rgba(255, 255, 255, 0.16);
  --hud-ink: #F4F7F9;
  --font-display: "Barlow Semi Condensed", "IBM Plex Sans KR", "Arial Narrow", sans-serif;
  --font-body: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --r: 14px;
  --top-h: 56px;
  --sl: env(safe-area-inset-left, 0px);
  --sr: env(safe-area-inset-right, 0px);
  --st: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 15px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.25; text-wrap: balance; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }
.label { font-size: 12px; letter-spacing: 0.06em; color: var(--muted); font-weight: 500; }
.eyebrow {
  margin: 0 0 6px; font-family: var(--font-display); font-weight: 600; font-size: 13px;
  letter-spacing: 0.24em; color: var(--muted); text-transform: uppercase;
}

/* 뷰파인더 모서리 (카드·히어로 공통) */
.vf { --vf: rgba(255, 255, 255, 0.32); --vl: 16px; --vi: 12px; position: relative; }
.vf::before {
  content: ""; position: absolute; inset: var(--vi); pointer-events: none;
  background:
    linear-gradient(var(--vf), var(--vf)) top left / var(--vl) 1.5px no-repeat,
    linear-gradient(var(--vf), var(--vf)) top left / 1.5px var(--vl) no-repeat,
    linear-gradient(var(--vf), var(--vf)) top right / var(--vl) 1.5px no-repeat,
    linear-gradient(var(--vf), var(--vf)) top right / 1.5px var(--vl) no-repeat,
    linear-gradient(var(--vf), var(--vf)) bottom left / var(--vl) 1.5px no-repeat,
    linear-gradient(var(--vf), var(--vf)) bottom left / 1.5px var(--vl) no-repeat,
    linear-gradient(var(--vf), var(--vf)) bottom right / var(--vl) 1.5px no-repeat,
    linear-gradient(var(--vf), var(--vf)) bottom right / 1.5px var(--vl) no-repeat;
}

/* ── 상단 바 ── */
.topbar {
  position: sticky; top: 0; z-index: 20; padding-top: var(--st);
  background: rgba(7, 9, 11, 0.84); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  max-width: 1240px; margin-inline: auto; padding-inline: 20px; height: var(--top-h);
  display: flex; align-items: center; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand svg { flex: none; }
.brand .wm { font-family: var(--font-display); font-weight: 700; font-size: 24px; letter-spacing: 0.06em; }
.brand .wm-sub { font-size: 13px; color: var(--muted); font-weight: 500; padding-left: 10px; border-left: 1px solid var(--line-strong); }
.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; align-self: stretch; }
.nav a {
  position: relative; display: flex; align-items: center; padding-inline: 12px;
  color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap;
}
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); }
.nav a[aria-current="page"]::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; background: var(--ink); border-radius: 2px;
}
.me { display: flex; align-items: center; gap: 10px; font-size: 13px; white-space: nowrap; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--raise); border: 1px solid var(--line-strong); color: var(--muted); overflow: hidden;
}
.avatar svg { width: 26px; height: 26px; margin-top: 6px; }
.avatar:hover, .avatar[aria-current] { color: var(--ink); border-color: var(--muted); }

main { max-width: 1240px; margin-inline: auto; padding-inline: 20px; padding-block: 36px 72px; }
.foot {
  max-width: 1240px; margin-inline: auto; padding: 24px 20px 40px; display: flex; gap: 18px; flex-wrap: wrap;
  font-size: 13px; color: var(--dim); border-top: 1px solid var(--line);
}
.foot a { color: var(--muted); text-decoration: none; }
.foot a:hover { color: var(--ink); }

/* 조종 화면에서는 상단 바·바닥글 없이 화면 전체를 쓴다 */
body[data-route="drive"] .topbar, body[data-route="drive"] .foot { display: none; }
body[data-route="drive"] main { max-width: none; padding: 0; }
body[data-route="drive"] { overflow: hidden; }

/* ── 버튼 ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 18px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: transparent; color: var(--ink);
  font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s;
}
.btn:hover { border-color: var(--muted); background: rgba(255, 255, 255, 0.04); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: #FFFFFF; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.38; cursor: not-allowed; pointer-events: none; }
.btn.small { min-height: 32px; padding: 4px 12px; font-size: 13px; }
.btn.danger { color: var(--led-fail); border-color: color-mix(in srgb, var(--led-fail) 50%, transparent); }
.btn.danger:hover { background: color-mix(in srgb, var(--led-fail) 12%, transparent); }

/* ── 상태 칩 · 점 ── */
.chip {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600;
  padding: 3px 11px 3px 9px; border-radius: 999px; white-space: nowrap;
  background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--c);
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.chip.blink::before { animation: blink 1s steps(1) infinite; }
.chip.fast::before { animation: blink 0.3s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0.15; } }
.c-wait { --c: var(--led-wait); } .c-idle { --c: var(--led-idle); } .c-drive { --c: var(--led-drive); }
.c-fail { --c: var(--led-fail); } .c-ota { --c: var(--led-ota); } .c-off { --c: var(--led-off); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--led-off)); flex: none; }
.dot:not(.c-off) { box-shadow: 0 0 7px var(--c); }

/* ── 공통 입력 ── */
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: 14px; }
.field .help { font-size: 13px; color: var(--muted); }
.field input[type="text"], .field input[type="password"], .field select {
  border: 1px solid var(--line-strong); background: var(--paper); border-radius: 10px; padding: 10px 12px; max-width: 100%;
}
.field input:focus, .field select:focus { border-color: var(--accent); outline: none; }
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row input { flex: 1; accent-color: var(--primary); min-width: 0; }
.range-row output { font-family: var(--font-mono); font-size: 13px; min-width: 5.5em; text-align: right; white-space: nowrap; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check input, .banner input { accent-color: var(--primary); width: 16px; height: 16px; }
.form-err { margin: 0; color: var(--led-fail); font-size: 14px; }
.store { font-size: 13px; color: var(--muted); margin: 0; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--sb)); transform: translateX(-50%); z-index: 60;
  background: var(--primary); color: var(--on-primary); padding: 10px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 500; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); max-width: calc(100% - 32px); text-align: center;
}
kbd {
  font-family: var(--font-mono); font-size: 11.5px; border: 1px solid rgba(255, 255, 255, 0.28); border-bottom-width: 2px;
  border-radius: 5px; padding: 0 6px; background: rgba(0, 0, 0, 0.35); color: #FFFFFF;
}

/* ── 페이지 머리 ── */
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.page-head h1 { font-size: 32px; font-weight: 700; letter-spacing: -0.01em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-head .eyebrow { margin: 0 0 4px; }

/* ── 로그인 ── */
.login { display: grid; grid-template-columns: 1.25fr 0.75fr; gap: 24px; align-items: stretch; }
.hero {
  --vi: 18px; --vl: 22px;
  border: 1px solid var(--line); border-radius: var(--r); padding: 48px;
  min-height: 460px; display: grid; align-content: space-between; gap: 36px; overflow: hidden;
  background:
    radial-gradient(90% 80% at 15% 0%, rgba(140, 200, 255, 0.10), transparent 60%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 44px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 44px),
    var(--sunken);
}
.hero h1 { font-size: clamp(32px, 4.2vw, 54px); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.hero .lede { color: var(--muted); font-size: 17px; max-width: 32em; margin: 18px 0 0; }
.hero .rec { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 600; letter-spacing: 0.2em; font-size: 13px; color: var(--muted); }
.hero .rec::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--led-fail); box-shadow: 0 0 8px var(--led-fail); }
.spec { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 0; border-top: 1px solid var(--line); padding-top: 22px; }
.spec div { display: grid; gap: 2px; }
.spec dt { font-size: 12.5px; color: var(--muted); }
.spec dd { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 40px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.spec small { font-size: 16px; color: var(--muted); margin-left: 3px; font-weight: 500; }
.signin {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 36px 32px;
  display: grid; gap: 16px; align-content: center;
}
.signin h2 { font-size: 22px; }
.signin p { margin: 0; color: var(--muted); font-size: 14px; }
.gbtn { width: 100%; min-height: 50px; font-size: 15.5px; gap: 12px; background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.gbtn:hover { background: #FFFFFF; }
.signin-note { margin: 0; color: var(--muted); font-size: 14px; }
.fine { font-size: 12.5px; color: var(--dim) !important; border-top: 1px solid var(--line); padding-top: 14px; }
.fine a { color: var(--muted); }

/* ── 차고 ── */
.cars { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 20px; }
.car { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; display: grid; }
.car-view {
  --vi: 12px; display: grid; align-content: space-between; gap: 34px; padding: 26px 26px 24px; min-height: 200px;
  color: var(--ink); text-decoration: none;
  background:
    radial-gradient(80% 110% at 90% 115%, color-mix(in srgb, var(--c) 24%, transparent), transparent 62%),
    linear-gradient(180deg, #0F151A, #0A0E12);
}
.car.off .car-view { background: linear-gradient(180deg, #0E1114, #0A0C0E); }
a.car-view:hover h3 { color: #FFFFFF; }
.car-view-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.car-fw { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.car h3 { font-family: var(--font-display); font-weight: 700; font-size: 44px; letter-spacing: 0.05em; line-height: 0.95; text-transform: uppercase; overflow-wrap: anywhere; }
.car.off h3 { color: var(--muted); }
.car-model { color: var(--muted); font-size: 13px; margin-top: 8px; }
.car-tele { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; border-top: 1px solid var(--line); }
.car-tele div { padding: 14px 16px; border-right: 1px solid var(--line); display: grid; gap: 2px; min-width: 0; }
.car-tele div:last-child { border-right: 0; }
.car-tele dt { font-size: 11.5px; color: var(--muted); }
.car-tele dd {
  margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 20px; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums;
}
.car-tele small { font-size: 12px; color: var(--muted); margin-left: 2px; font-weight: 500; }
.car-tele .chg { color: var(--led-idle); margin-left: 2px; }
.car-actions { display: flex; gap: 10px; padding: 16px; border-top: 1px solid var(--line); }
.car-actions .go { flex: 1; min-height: 48px; font-size: 15px; }
.empty {
  --vi: 14px; border: 1px dashed var(--line-strong); border-radius: 18px; padding: 48px 40px;
  display: grid; gap: 12px; justify-items: start; background: var(--sunken);
}
.empty h2 { font-size: 20px; }
.empty p { margin: 0; color: var(--muted); max-width: 36em; }

/* ── 차량 추가 ── */
.pair { display: grid; grid-template-columns: 1fr 380px; gap: 32px; align-items: start; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; counter-reset: s; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 44px 1fr; gap: 14px; padding-block: 20px; border-bottom: 1px solid var(--line); }
.steps li:first-child { padding-top: 0; }
.steps li::before {
  content: counter(s, decimal-leading-zero); font-family: var(--font-display); font-weight: 600; font-size: 22px;
  color: var(--dim); line-height: 1.1; letter-spacing: 0.04em;
}
.steps li.now::before { color: var(--ink); }
.steps li.done::before { content: "✓"; color: var(--led-idle); }
.steps h3 { font-size: 16px; font-weight: 600; }
.steps p { margin: 4px 0 0; color: var(--muted); font-size: 14px; max-width: 46em; }
.steps .btn { margin-top: 10px; }
.qr-card {
  position: sticky; top: calc(var(--top-h) + 20px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 26px;
  display: grid; gap: 18px; justify-items: center; text-align: center;
}
.qr-box { --vf: rgba(255, 255, 255, 0.55); --vi: -10px; --vl: 18px; background: #FFFFFF; padding: 14px; border-radius: 12px; margin: 10px; }
.qr { width: 220px; height: 220px; max-width: 100%; }
.qr svg, .qr img { width: 100%; height: 100%; display: block; }
.pin { font-family: var(--font-display); font-weight: 700; font-size: 54px; letter-spacing: 0.12em; line-height: 1; margin-top: 4px; font-variant-numeric: tabular-nums; }
.timer { font-family: var(--font-display); font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums; }
.timer.low { color: var(--led-fail); }
.waiting { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.spin { width: 14px; height: 14px; border: 2px solid var(--line-strong); border-top-color: var(--ink); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.approve { width: 100%; display: grid; gap: 12px; text-align: left; border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 12px; padding: 16px; }
.approve p { margin: 0; font-size: 14px; }
.approve .req { display: grid; }
.approve .req b { font-size: 18px; }
.approve .req span { font-size: 13px; color: var(--muted); }
.row-actions { display: flex; gap: 8px; width: 100%; }
.row-actions .btn { flex: 1; }
.note { font-size: 13px; color: var(--muted); background: var(--sunken); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; text-align: left; margin: 0; }

/* ── 설명서 (보드 준비) ── */
.board-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.sec-title { font-size: 17px; font-weight: 700; margin-bottom: 12px; }
.needs { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.needs li { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); align-items: start; }
.needs li:last-child { border-bottom: 0; }
.needs b { font-weight: 600; }
.needs .sub { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.who { font-size: 12px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--muted); white-space: nowrap; }
.who.kit { border-color: var(--accent); color: var(--accent); }
.wiring { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: grid; gap: 14px; }
.wire-wrap { overflow-x: auto; }
.wire { width: 100%; height: auto; display: block; min-width: 520px; }
.wire-m { display: none; width: 100%; max-width: 420px; height: auto; margin-inline: auto; }
@media (max-width: 600px) { .wire { display: none; } .wire-m { display: block; } }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 4px; border-radius: 2px; background: var(--c); display: inline-block; }
.warns { margin: 0; padding-left: 18px; font-size: 13.5px; display: grid; gap: 4px; }
.warns li::marker { color: var(--led-fail); }

/* ── 설정 · 계정 · 문서 ── */
.settings { display: grid; gap: 16px; max-width: 760px; }
.form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 24px; display: grid; gap: 18px; }
.form h2 { font-size: 16px; }
.form .desc { margin: 0; color: var(--muted); font-size: 14px; }
.danger-zone { border-color: color-mix(in srgb, var(--led-fail) 35%, var(--line)); }
.confirm { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 14px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-family: var(--font-mono); font-size: 13.5px; overflow-wrap: anywhere; }
.doc { max-width: 760px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 32px 36px; line-height: 1.8; }
.doc h1 { font-size: 28px; }
.doc h2 { font-size: 17px; margin-top: 28px; }
.doc p, .doc li { font-size: 15px; color: #CDD5DC; }
.doc-meta { color: var(--muted) !important; font-size: 13px !important; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 14px; display: block; overflow-x: auto; }
.doc-table th, .doc-table td { border-bottom: 1px solid var(--line); padding: 9px 10px; text-align: left; vertical-align: top; }
.doc-table th { color: var(--muted); font-weight: 600; }
.todo { background: color-mix(in srgb, var(--led-drive) 22%, transparent); color: var(--led-drive); padding: 0 4px; border-radius: 4px; }

/* ═════════ 조종 화면 ═════════ */
.cockpit {
  position: relative; height: 100vh; height: 100dvh; overflow: hidden;
  background: #000000; color: var(--hud-ink); user-select: none; -webkit-user-select: none;
}
.feed { position: absolute; inset: 0; background: #000000; }
.feed video { width: 100%; height: 100%; display: block; object-fit: contain; background: #000000; }
.feed.warn { box-shadow: inset 0 0 0 3px var(--led-drive); }
.reticle { position: absolute; left: 50%; top: 50%; width: 72px; height: 72px; transform: translate(-50%, -50%); pointer-events: none; opacity: 0.55; z-index: 1; }
.reticle::before, .reticle::after { content: ""; position: absolute; background: #FFFFFF; }
.reticle::before { left: 0; right: 0; top: 50%; height: 1px; -webkit-mask: linear-gradient(90deg, #000 0 36%, transparent 36% 64%, #000 64%); mask: linear-gradient(90deg, #000 0 36%, transparent 36% 64%, #000 64%); }
.reticle::after { top: 0; bottom: 0; left: 50%; width: 1px; -webkit-mask: linear-gradient(#000 0 36%, transparent 36% 64%, #000 64%); mask: linear-gradient(#000 0 36%, transparent 36% 64%, #000 64%); }
.hud-shadow { text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85); }

/* 상단 상태 띠 */
.hud-top {
  position: absolute; left: 0; right: 0; top: 0; z-index: 7;
  display: flex; align-items: center; gap: 14px;
  padding: calc(10px + var(--st)) calc(14px + var(--sr)) 28px calc(14px + var(--sl));
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.74), rgba(0, 0, 0, 0));
  font-size: 13px;
}
.hud-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hud-id .chip { flex: none; }
.hud-links { flex: none; }
.hud-id .name {
  font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: 0.07em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}
.hud-top .chip { background: rgba(0, 0, 0, 0.5); }
.hud-links { display: flex; gap: 6px; align-items: center; padding: 7px 10px; border: 1px solid var(--hud-line); border-radius: 999px; background: var(--hud-bg); }
.hud-sp { flex: 1; }
.hud-stat { display: grid; line-height: 1.15; text-align: right; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85); }
.hud-stat .k { font-size: 10.5px; letter-spacing: 0.1em; color: rgba(255, 255, 255, 0.62); }
.hud-stat .v { font-family: var(--font-display); font-weight: 600; font-size: 16px; white-space: nowrap; }
.rtt { font-family: var(--font-display); font-weight: 700; font-size: 26px; line-height: 1; }
.rtt small { font-size: 13px; margin-left: 2px; opacity: 0.7; font-weight: 500; }
.hud-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 40px; height: 40px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--hud-line); background: var(--hud-bg); color: var(--hud-ink);
  backdrop-filter: blur(8px); font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.hud-btn:hover { background: rgba(0, 0, 0, 0.82); }
.hud-btn[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.hud-btn.icon { padding: 0; width: 40px; font-size: 18px; }
.hud-btn.rec { gap: 8px; padding: 0 13px; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--led-fail); flex: none; }
.hud-btn.rec[aria-pressed="true"] { background: rgba(255, 77, 79, 0.22); border-color: var(--led-fail); color: #FFFFFF; }
.hud-btn.rec[aria-pressed="true"] .rec-dot { animation: blink 1s steps(1) infinite; box-shadow: 0 0 8px var(--led-fail); }
.rec-time { font-family: var(--font-display); font-weight: 600; font-size: 15px; }
.radio-row { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 14px; }
.radio-row label { display: flex; align-items: center; gap: 7px; cursor: pointer; }
.radio-row input { accent-color: var(--primary); width: 16px; height: 16px; margin: 0; }
.hud-btn svg { width: 18px; height: 18px; flex: none; }

/* 나침반 · 속도 */
.hud-compass {
  position: absolute; top: calc(70px + var(--st)); left: 50%; transform: translateX(-50%); z-index: 3;
  text-align: center; pointer-events: none; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
}
.hud-compass .hdg { font-family: var(--font-display); font-weight: 700; font-size: 20px; letter-spacing: 0.1em; line-height: 1.1; }
.hud-compass .ticks {
  width: 200px; height: 9px; margin: 3px auto;
  background:
    linear-gradient(#FFFFFF, #FFFFFF) center / 2px 9px no-repeat,
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.55) 0 1px, transparent 1px 12px);
  -webkit-mask: linear-gradient(90deg, transparent, #000 28%, #000 72%, transparent);
  mask: linear-gradient(90deg, transparent, #000 28%, #000 72%, transparent);
}
.hud-compass .spd { font-family: var(--font-display); font-weight: 600; font-size: 14px; letter-spacing: 0.06em; opacity: 0.85; }

/* 좌우 궤도 출력 눈금 (화면 양쪽 가장자리) */
.scale { position: absolute; top: 50%; transform: translateY(-50%); z-index: 3; display: grid; justify-items: center; gap: 8px; pointer-events: none; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85); }
.scale-l { left: calc(20px + var(--sl)); }
.scale-r { right: calc(20px + var(--sr)); }
.scale .bar {
  position: relative; width: 12px; height: min(38vh, 280px); border-radius: 6px; overflow: hidden;
  background: repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.22) 0 1px, transparent 1px 10%), rgba(0, 0, 0, 0.35);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}
.scale .bar::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 2px; margin-top: -1px; background: #FFFFFF; }
.scale .fill { position: absolute; left: 0; right: 0; height: 0; top: 50%; transition: height 0.08s linear, top 0.08s linear; }
.scale-l .fill { background: var(--track-l); }
.scale-r .fill { background: var(--track-r); }
.scale .v { font-family: var(--font-display); font-weight: 700; font-size: 22px; line-height: 1; min-width: 2.4em; text-align: center; }
.scale .k { font-family: var(--font-display); font-weight: 600; font-size: 11px; letter-spacing: 0.18em; opacity: 0.7; }

/* 오른쪽 아래: 영상 정보 · 기울기 */
.hud-br {
  position: absolute; right: calc(16px + var(--sr)); bottom: calc(18px + var(--sb)); z-index: 3;
  display: grid; gap: 2px; text-align: right; pointer-events: none;
  font-family: var(--font-mono); font-size: 11.5px; color: rgba(255, 255, 255, 0.78); text-shadow: 0 1px 2px #000000;
}
.tilt-warn { color: #FFB25A; }

/* 왼쪽 아래: 미니맵 */
.minimap {
  position: absolute; left: calc(16px + var(--sl)); bottom: calc(18px + var(--sb)); z-index: 4;
  width: min(300px, 32vw); height: min(196px, 30vh); border-radius: 14px; overflow: hidden;
  border: 1px solid var(--hud-line); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55); background: #101418;
}
.minimap .map-slot, .minimap .map { height: 100%; }
.minimap .map { z-index: 0; background: #101418; }
.minimap .follow { position: absolute; right: 8px; top: 8px; z-index: 500; height: 32px; padding: 0 12px; font-size: 12px; }
.minimap .leaflet-control-attribution { font-size: 9px; background: rgba(0, 0, 0, 0.55) !important; color: #CCCCCC; }
.minimap .leaflet-control-attribution a { color: #FFFFFF; }
.leaflet-container { font-family: var(--font-body); }
.car-arrow { width: 28px; height: 28px; display: grid; place-items: center; }
.car-arrow svg { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5)); }

/* 아래 가운데: 키보드·게임패드용 조작부 */
.ctl-desk {
  position: absolute; left: 50%; bottom: calc(20px + var(--sb)); transform: translateX(-50%); z-index: 7;
  display: grid; justify-items: center; gap: 10px;
}
.ctl-row { display: flex; gap: 10px; align-items: center; }
.speed {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: 999px;
  background: var(--hud-bg); border: 1px solid var(--hud-line); backdrop-filter: blur(8px);
}
.speed .k { font-size: 12px; color: rgba(255, 255, 255, 0.7); padding: 0 8px 0 10px; }
.speed button {
  border: 0; background: none; color: var(--hud-ink); border-radius: 999px; cursor: pointer;
  font-family: var(--font-display); font-weight: 600; font-size: 15px; min-width: 52px; height: 32px; padding: 0 10px;
}
.speed button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
.speed.compact { justify-self: center; padding: 2px; }
.speed.compact .k { display: none; }
.speed.compact button { min-width: 0; font-size: 12px; height: 28px; padding: 0 5px; }
.ctl-desk .btn { min-height: 54px; min-width: 150px; font-size: 15px; }
.cockpit .btn:not(.primary) { background: var(--hud-bg); border-color: var(--hud-line); color: var(--hud-ink); backdrop-filter: blur(8px); }
.stop {
  border: 0; border-radius: 999px; cursor: pointer; background: var(--led-fail); color: #FFFFFF;
  font-family: var(--font-display); font-weight: 700; font-size: 26px; letter-spacing: 0.18em;
  min-height: 54px; padding: 0 38px; box-shadow: 0 8px 24px rgba(255, 77, 79, 0.35);
}
.stop:hover { filter: brightness(1.08); }
.stop:active { transform: scale(0.98); }
.arm-help { margin: 0; font-size: 12px; color: rgba(255, 255, 255, 0.78); text-shadow: 0 1px 2px #000000; text-align: center; }
.keys { display: flex; gap: 4px 14px; flex-wrap: wrap; justify-content: center; font-size: 11.5px; color: rgba(255, 255, 255, 0.7); text-shadow: 0 1px 2px #000000; }
.keys span { display: inline-flex; align-items: center; gap: 4px; }

/* 터치 조작부: 좌우 궤도 세로 패드 (위로 밀면 전진, 손을 떼면 0) */
.touch {
  position: absolute; left: 0; right: 0; bottom: calc(14px + var(--sb)); z-index: 7;
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: end;
  padding-inline: calc(14px + var(--sl)) calc(14px + var(--sr));
  touch-action: none; pointer-events: none;
}
.touch > * { pointer-events: auto; }
.pad {
  position: relative; width: 100%; max-width: 150px; height: min(250px, 42vh); justify-self: start;
  border-radius: 22px; background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.24);
  backdrop-filter: blur(3px); display: grid; place-items: end center; padding-bottom: 8px; touch-action: none;
}
.pad[data-side="R"] { justify-self: end; }
.pad::before { content: ""; position: absolute; left: 14%; right: 14%; top: 50%; border-top: 1px dashed rgba(255, 255, 255, 0.5); }
.pad .knob {
  position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.92); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45); transition: transform 0.08s;
}
.pad.on .knob { transition: none; }
.pad .label { color: #FFFFFF; font-family: var(--font-display); font-weight: 600; letter-spacing: 0.14em; font-size: 12px; opacity: 0.8; }
.touch-mid { display: grid; gap: 10px; align-content: end; width: 120px; }
.touch-mid .stop { padding: 0 8px; min-height: 60px; font-size: 22px; }
.touch-mid .btn { min-height: 46px; padding-inline: 8px; }

/* 터치 기기: 조작부는 패드로, 미니맵·영상 정보는 위로 */
.is-touch .ctl-desk, .is-touch .scale { display: none; }
.is-touch .minimap { top: calc(70px + var(--st)); bottom: auto; width: min(260px, 42vw); height: min(170px, 28vh); }
.is-touch .hud-br { top: calc(70px + var(--st)); bottom: auto; }

/* 연결 끊김 덮개 */
.lost {
  position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; text-align: center; padding: 24px;
  background: radial-gradient(closest-side, rgba(110, 0, 0, 0.72), rgba(40, 0, 0, 0.6)); color: #FFFFFF;
}
.lost b { display: block; font-family: var(--font-display); font-weight: 700; font-size: 44px; letter-spacing: 0.1em; line-height: 1.1; }
.lost span { display: block; max-width: 30em; margin-top: 8px; font-size: 15px; font-weight: 500; }

/* 오른쪽 패널: 상태 · 카메라 · 좌우 보정 */
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; z-index: 9; width: min(390px, 100%);
  display: flex; flex-direction: column; color: var(--ink); user-select: text; -webkit-user-select: text;
  background: rgba(10, 13, 16, 0.94); backdrop-filter: blur(18px); border-left: 1px solid var(--hud-line);
  box-shadow: -20px 0 40px rgba(0, 0, 0, 0.45);
}
.drawer-head { display: flex; align-items: center; gap: 8px; padding: calc(12px + var(--st)) calc(14px + var(--sr)) 12px 14px; border-bottom: 1px solid var(--line); }
.seg { display: flex; flex: 1; background: var(--sunken); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg .tab { flex: 1; border: 0; background: none; border-radius: 999px; padding: 7px 8px; color: var(--muted); font-weight: 600; cursor: pointer; font-size: 13px; white-space: nowrap; }
.seg .tab[aria-selected="true"] { background: var(--primary); color: var(--on-primary); }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px calc(16px + var(--sr)) calc(24px + var(--sb)) 16px; display: grid; gap: 14px; align-content: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: grid; gap: 12px; }
.panel h2 { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; color: var(--muted); }
.safety { display: grid; margin: 0; padding: 0; list-style: none; }
.safety li { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center; padding-block: 9px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.safety li:last-child { border-bottom: 0; }
.safety .lim { color: var(--muted); font-size: 12px; }
.safety .age { font-family: var(--font-mono); font-size: 12.5px; text-align: right; }
.sens { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; margin: 0; }
.sens div { display: grid; min-width: 0; }
.sens dt { font-size: 12px; color: var(--muted); }
.sens dd { margin: 0; font-family: var(--font-mono); font-size: 13.5px; overflow-wrap: anywhere; }
.sens .wide { grid-column: 1 / -1; }
.banner {
  display: grid; gap: 10px; font-size: 14px; border-radius: 12px; padding: 14px;
  background: color-mix(in srgb, var(--led-drive) 12%, transparent); border: 1px solid color-mix(in srgb, var(--led-drive) 45%, transparent);
}
.banner label { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.mini { display: grid; gap: 4px; }
.mini label { font-size: 13px; font-weight: 600; }
.mini .help { font-size: 12.5px; color: var(--muted); }
.tests { display: flex; flex-wrap: wrap; gap: 8px; }
.drawer .row-actions { width: auto; }

/* ── 반응형 ── */
@media (max-width: 1100px) {
  .hud-stat.opt { display: none; }
}
@media (max-width: 960px) {
  .login, .pair, .board-grid { grid-template-columns: 1fr; }
  .qr-card { position: static; }
  .hero { min-height: 0; }
}
@media (max-width: 720px) {
  .brand .wm-sub, .me #logout { display: none; }
  .topbar-in { gap: 14px; }
  .nav a { padding-inline: 8px; }
  .nav a[aria-current="page"]::after { left: 8px; right: 8px; }
  .hud-compass { display: none; }
  .hud-top { gap: 8px; }
  .hud-btn .lbl { display: none; }
  .hud-btn:has(.lbl) { padding: 0; width: 40px; }
  .hud-links { padding: 6px 8px; gap: 5px; }
  .hud-links .dot { width: 7px; height: 7px; }
  .rtt { font-size: 22px; }
  /* 좁은 화면(키보드 사용 시): 조작부와 겹치지 않게 미니맵·영상 정보는 위로, 키 안내는 숨김 */
  .keys { display: none; }
  .minimap { top: calc(70px + var(--st)); bottom: auto; width: min(260px, 42vw); height: min(170px, 28vh); }
  .hud-br { top: calc(70px + var(--st)); bottom: auto; }
}
@media (max-width: 560px) {
  .topbar-in { padding-inline: 16px; }
  main { padding-inline: 16px; padding-block: 24px 56px; }
  .page-head h1 { font-size: 26px; }
  .cars { grid-template-columns: 1fr; }
  .car-tele { grid-template-columns: 1fr 1fr; }
  .car-tele div:nth-child(2) { border-right: 0; }
  .car-tele div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .car h3 { font-size: 36px; }
  .hero { padding: 28px 24px; }
  .spec dd { font-size: 28px; }
  .signin { padding: 28px 22px; }
  .doc { padding: 22px 18px; }
  .needs li { grid-template-columns: 1fr; }
  .needs .who { justify-self: start; }
  .hud-id .name { font-size: 18px; max-width: 28vw; }
  .hud-links { display: none; }   /* 안전 체인은 설정 → 상태 패널에서 */
  /* 상단 띠가 한 줄에 다 들어가지 않으므로 차량 이름·상태는 둘째 줄로 */
  .hud-top { flex-wrap: wrap; row-gap: 6px; }
  .hud-id { order: 10; flex-basis: 100%; }
  .minimap, .is-touch .minimap, .hud-br, .is-touch .hud-br { top: calc(108px + var(--st)); }
  .lost b { font-size: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  .chip::before, .spin { animation: none !important; }
  .scale .fill, .pad .knob { transition: none; }
}

/* 지도 타일을 조종석 톤에 맞춰 어둡게 (OSM 밝은 타일 반전) */
.minimap .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.92) contrast(0.88) saturate(0.6); }

/* 설명서 준비물 사진·구매 링크 */
.needs .gear { display: block; width: 100%; max-width: 240px; height: auto; margin-top: 10px; border-radius: 8px; background: #fff; }
.needs .buy { font-weight: 600; }

/* 좁은 화면(폰)에서도 연결 경로(P2P/TURN)는 항상 보이게 작게 표시 */
@media (max-width: 1100px) {
  .hud-stat.path .k { font-size: 9px; letter-spacing: 0.04em; }
  .hud-stat.path .v { font-size: 12px; }
}

/* 언어 선택 (푸터) */
.lang-sel { margin-left: auto; background: transparent; color: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; font: inherit; font-size: 13px; }
html[lang=ja] { --font-body: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, sans-serif; --font-display: "Barlow Semi Condensed", "Noto Sans JP", sans-serif; }
html[lang=zh-CN] { --font-body: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; --font-display: "Barlow Semi Condensed", "Noto Sans SC", sans-serif; }
