:root {
  --bg: #05090e; --panel: #111922; --panel-2: #1a2531; --line: #26323f;
  --text: #e8eef4; --muted: #92a2b3; --accent: #4cc2ff; --accent-ink: #04202f;
  --ok: #4fd18b; --warn: #ffb547; --danger: #ff6b6b;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
button, textarea, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px; padding: 8px 14px; min-height: 44px; }
button:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.ghost { background: transparent; color: var(--muted); }

.login { max-width: 380px; margin: 18vh auto 0; padding: 0 16px; display: grid; gap: 12px; }
.login h1 { margin: 0; letter-spacing: .08em; }
.login p { margin: 0; color: var(--muted); }
.login input { padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); }
.error { color: var(--danger) !important; min-height: 1.4em; }

.app { height: 100dvh; display: flex; flex-direction: column; }
.bar { display: flex; align-items: center; gap: 8px; padding: 6px 16px; padding-top: max(6px, env(safe-area-inset-top)); }
.brand { display: flex; align-items: center; gap: 10px; letter-spacing: .08em; flex: 1; min-width: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); flex: none; }
.dot.on { background: var(--ok); }
.dot.busy { background: var(--accent); animation: pulse 1s infinite; }
.pc-state { color: var(--muted); font-size: 12px; white-space: nowrap; }
.pc-state.on { color: var(--ok); }
@media (max-width: 480px) { .spent { display: none; } }
.spent { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .dot.busy { animation: none; } }

.main { flex: 1; min-height: 0; position: relative; display: flex; }
.stage { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; align-items: center; padding: 0 16px 8px; }
.eye { flex: 1; min-height: 0; width: 100%; padding: 0; border: 0; background: transparent; border-radius: 24px; display: block; -webkit-tap-highlight-color: transparent; }
.eye canvas { display: block; width: 100%; height: 100%; }
.stage-status { margin: 4px 0 2px; font-size: 15px; letter-spacing: .04em; color: var(--accent); text-align: center; }
.stage[data-state="off"] .stage-status { color: var(--muted); }
.stage[data-state="listening"] .stage-status { color: #5af0c8; }
.stage[data-state="thinking"] .stage-status { color: #a98bff; }
.stage[data-state="approval"] .stage-status { color: var(--warn); }
.caption { margin: 0; width: 100%; max-width: 720px; min-height: 3em; max-height: 24dvh; overflow-y: auto; text-align: center; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }

.stage { position: relative; }
.display { flex: 1; min-height: 0; width: 100%; position: relative; border-radius: 16px; overflow: hidden; background: #000; }
#map { position: absolute; inset: 0; }
.stage.showing .eye { position: absolute; top: 8px; left: 24px; width: 72px; height: 72px; flex: none; z-index: 4; }
.stage.showing .caption { min-height: 0; max-height: 14dvh; }
.display-close { position: absolute; top: 8px; right: 8px; z-index: 4; background: rgba(5, 9, 14, .78); }
.display-info { position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 4; max-width: 420px; max-height: 58%; overflow-y: auto; padding: 10px 12px; border-radius: 12px; background: rgba(5, 9, 14, .84); overflow-wrap: anywhere; }
.display-info h3 { margin: 0 0 2px; font-size: 17px; }
.display-info p { margin: 0 0 4px; font-size: 14px; }
.display-info small { color: var(--muted); }
.plane-photo { display: block; width: 100%; max-height: 180px; object-fit: cover; border-radius: 8px; margin-bottom: 2px; }
.pin { width: 16px; height: 16px; border-radius: 50%; background: var(--warn); border: 2px solid #fff; box-shadow: 0 0 12px var(--warn); }
.me { width: 14px; height: 14px; border-radius: 50%; background: #5af0c8; border: 2px solid #fff; box-shadow: 0 0 14px #5af0c8; }
.plane { display: flex; flex-direction: column; align-items: center; min-height: 44px; min-width: 44px; padding: 0; border: 0; background: transparent; color: #fff; }
.plane-icon { width: 26px; height: 26px; display: block; }
.plane-icon svg { width: 100%; height: 100%; fill: #fff; stroke: #05090e; stroke-width: 1; display: block; }
.plane.heli .plane-icon svg { fill: var(--warn); }
.plane.military .plane-icon svg { fill: var(--danger); }
.plane.selected .plane-icon svg { fill: #5af0c8; }
.plane-label { font-size: 11px; line-height: 1.2; padding: 0 4px; border-radius: 4px; background: rgba(5, 9, 14, .72); white-space: nowrap; }
.panel { position: absolute; inset: 0; overflow-y: auto; padding: 56px 16px 16px; display: grid; gap: 10px; align-content: start; background: var(--panel); }
.cams { position: absolute; inset: 0; display: grid; gap: 4px; padding-top: 0; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); grid-auto-rows: minmax(160px, 1fr); overflow-y: auto; background: #000; }
.cam { position: relative; min-height: 0; background: #000; }
.cam iframe, .cam img { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; object-fit: contain; }
.cam-title { position: absolute; left: 96px; bottom: 6px; max-width: calc(100% - 104px); z-index: 2; padding: 2px 8px; border-radius: 6px; background: rgba(5, 9, 14, .78); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; pointer-events: none; }
.hud { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
.air-overlay { position: absolute; inset: 0; z-index: 2; pointer-events: none; color: #ffe2bd; font-variant-numeric: tabular-nums; }
.air-title { position: absolute; top: 14px; left: 96px; margin: 0; font-size: 11px; letter-spacing: .22em; opacity: .75; }
.air-count { position: absolute; left: 0; right: 0; bottom: 34px; text-align: center; text-shadow: 0 0 14px rgba(255, 150, 60, .75); }
.air-count strong { display: block; font-size: clamp(30px, 7vw, 46px); line-height: 1; font-weight: 600; }
.air-count span { font-size: 11px; letter-spacing: .08em; }
.air-photo { position: absolute; top: 88px; left: 8px; width: min(44%, 320px); margin: 0; border: 1px solid rgba(255, 180, 100, .55); border-radius: 6px; overflow: hidden; background: rgba(5, 9, 14, .8); }
.air-photo img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.air-photo figcaption { padding: 2px 6px; font-size: 10px; color: var(--muted); }
.air-data { position: absolute; top: 60px; right: 8px; width: min(46%, 270px); padding: 8px 10px; border: 1px solid rgba(255, 180, 100, .55); border-radius: 6px; background: rgba(5, 9, 14, .84); font: 12px/1.45 ui-monospace, Consolas, monospace; }
.air-data div { display: flex; justify-content: space-between; gap: 10px; }
.air-data dt, .air-data span:first-child { color: #d9a877; }
.air-data span:last-child { text-align: right; overflow-wrap: anywhere; }
.air-plate { position: absolute; left: 50%; bottom: 34px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; max-width: calc(100% - 16px); padding: 6px 14px; border: 1px solid rgba(255, 180, 100, .55); border-radius: 6px; background: rgba(5, 9, 14, .84); }
.air-plate svg { width: 44px; height: 44px; fill: #ffb547; flex: none; }
.air-plate h3 { margin: 0; font-size: 16px; color: #fff; overflow-wrap: anywhere; }
.air-plate p { margin: 0; font-size: 12px; overflow-wrap: anywhere; }
.lock { position: relative; width: 72px; height: 72px; pointer-events: none; }
.lock i { position: absolute; width: 16px; height: 16px; border: 2px solid #ff8a3c; }
.lock i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.lock i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.lock i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; }
.lock i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; }
.lock b { position: absolute; inset: 18px; border-radius: 50%; background: radial-gradient(circle, #ffd9b0 0, #ff6a2b 70%, rgba(255, 106, 43, .3) 100%); box-shadow: 0 0 22px #ff6a2b; animation: lockpulse 1.4s infinite; }
@keyframes lockpulse { 50% { transform: scale(.82); } }
@media (prefers-reduced-motion: reduce) { .lock b { animation: none; } }
.panel h2 { margin: 0; font-size: 20px; }
.panel-card { background: var(--panel-2); border-radius: 12px; padding: 12px; overflow-wrap: anywhere; }
.panel-card h3 { margin: 0 0 4px; font-size: 16px; }
.panel-card p { margin: 0 0 6px; color: var(--muted); }
.panel-card a { color: var(--accent); }
.panel-tag { color: var(--warn); font-size: 13px; }

.log { display: none; overflow-y: auto; padding: 16px; flex-direction: column; gap: 10px; background: var(--bg); }
.chat-open .log { display: flex; position: absolute; inset: 0; z-index: 2; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); }
.msg.assistant { align-self: flex-start; background: var(--panel); }
.msg a { color: var(--accent); }
.tool { align-self: flex-start; color: var(--muted); font-size: 14px; padding-left: 4px; overflow-wrap: anywhere; }
.tool.fail { color: var(--danger); }
.notice { border-left: 3px solid var(--warn); background: var(--panel); padding: 8px 12px; border-radius: 6px; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.notice.error { border-color: var(--danger); }
.notice b { display: block; }

@media (min-width: 900px) {
  .chat-open .log { position: static; width: 400px; flex: none; border-left: 1px solid var(--line); }
}

.approvals { display: grid; gap: 10px; padding: 0 16px; max-height: 62dvh; overflow-y: auto; }
.card { background: var(--panel-2); border: 1px solid var(--warn); border-radius: 12px; padding: 12px; margin-bottom: 8px; }
.card h2 { margin: 0 0 6px; font-size: 15px; color: var(--warn); }
.card p { margin: 0 0 8px; overflow-wrap: anywhere; }
.card pre { margin: 0 0 10px; padding: 10px; background: var(--bg); border-radius: 8px; max-height: 34dvh; overflow: auto; font: 13px/1.4 ui-monospace, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions button { flex: 1 1 110px; }

.composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 16px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.composer textarea { flex: 1; min-width: 0; resize: none; max-height: 140px; padding: 10px 12px; min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); }
.round { min-width: 48px; padding: 8px 10px; border-radius: 12px; }
#voice[aria-pressed="true"] { background: #123a33; color: #5af0c8; border-color: #5af0c8; }
