:root {
  --bg: #12151a; --panel: #1a1f27; --panel2: #222935; --line: #2e3745;
  --text: #e8ecf1; --dim: #8d99ab; --amber: #f5a524; --amber-ink: #1d1400;
  --green: #3ecf8e; --red: #ff4d4f; --blue: #5aa9ff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px;
}
* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel2); border-radius: 6px; padding: 6px 12px; }
button:hover { border-color: var(--dim); }
button.primary { background: var(--amber); color: var(--amber-ink); border-color: var(--amber); font-weight: 600; }
button.danger { color: var(--red); }
button.link { border: 0; background: none; color: var(--blue); padding: 0; }
input, select { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; width: 100%; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }
label { display: block; color: var(--dim); font-size: 12px; margin: 10px 0 4px; }
h1, h2, h3 { margin: 0; font-weight: 600; }
.muted { color: var(--dim); }
.row { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; min-width: 0; }

/* sign-in */
.auth { max-width: 360px; margin: 9vh auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; }
.auth h1 { font-size: 26px; text-align: center; }
.auth h1 + .muted { text-align: center; }
.auth h1 b { color: var(--amber); }
.auth .err, .err { color: var(--red); min-height: 18px; margin-top: 10px; font-size: 13px; }
.auth button.primary { width: 100%; margin-top: 16px; padding: 9px; }

/* shell */
.shell { display: grid; grid-template-columns: 270px 1fr 340px; grid-template-rows: 46px 1fr; height: 100%; }
.top { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; font-size: 17px; display: flex; align-items: center; }
.brand img { height: 32px; margin-right: 6px; }
.auth-logo { height: 96px; display: block; margin: 0 auto 6px; }
.brand b { color: var(--amber); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dim); display: inline-block; flex: none; }
.dot.on { background: var(--green); }
.dot.tx { background: var(--amber); box-shadow: 0 0 0 4px rgba(245,165,36,.25); }
.sos-bar { grid-column: 1 / -1; background: var(--red); color: #fff; font-weight: 700; padding: 10px 16px; display: flex; gap: 14px; align-items: center; animation: flash 1s infinite; }
.sos-bar button { background: #fff; color: var(--red); border: 0; font-weight: 700; }
@keyframes flash { 50% { background: #b3191b; } }
@media (prefers-reduced-motion: reduce) { .sos-bar { animation: none; } }

.side { background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column; }
.side .actions { padding: 10px; display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--line); }
.side .actions button { font-size: 12px; padding: 5px 9px; }
.group { padding: 12px 14px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--dim); }
.chan { display: flex; align-items: center; gap: 9px; padding: 8px 14px; cursor: pointer; border-left: 3px solid transparent; }
.chan:hover { background: var(--panel2); }
.chan.sel { background: var(--panel2); border-left-color: var(--amber); }
.chan .name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chan .who { font-size: 11px; color: var(--amber); }
.badge { background: var(--blue); color: #001; border-radius: 9px; font-size: 11px; padding: 0 6px; font-weight: 700; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.main header { padding: 12px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.main header h2 { font-size: 17px; }
.log { flex: 1; overflow-y: auto; padding: 14px 18px; display: flex; flex-direction: column; gap: 8px; }
.msg { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; max-width: 640px; }
.msg .meta { font-size: 11px; color: var(--dim); margin-bottom: 3px; display: flex; gap: 8px; }
.msg .meta b { color: var(--text); font-weight: 600; }
.msg.mine { align-self: flex-end; background: #232c1f; border-color: #36452e; }
.msg.sos { border-color: var(--red); background: #3a1517; }
.msg img { max-width: 320px; max-height: 260px; border-radius: 6px; display: block; margin-top: 4px; }
.voice { display: flex; align-items: center; gap: 10px; }
.voice button { border-radius: 50%; width: 32px; height: 32px; padding: 0; }
.voice .bar { height: 4px; border-radius: 2px; background: var(--amber); opacity: .7; }
.ptt-zone { border-top: 1px solid var(--line); padding: 14px 18px; display: flex; gap: 18px; align-items: center; background: var(--panel); }
.ptt { width: 108px; height: 108px; border-radius: 50%; border: 4px solid var(--amber); background: #2a2110; color: var(--amber);
  font-weight: 800; font-size: 15px; letter-spacing: 1px; user-select: none; touch-action: none; flex: none; }
.ptt.tx { background: var(--amber); color: var(--amber-ink); box-shadow: 0 0 0 8px rgba(245,165,36,.2); }
.ptt.rx { border-color: var(--green); color: var(--green); background: #10261c; }
.ptt.wait { opacity: .7; }
.ptt-info { flex: 1; min-width: 0; }
.ptt-info .status { font-size: 16px; font-weight: 600; min-height: 22px; }
.compose { display: flex; gap: 8px; margin-top: 10px; }
.check { display: inline-flex; gap: 6px; align-items: center; color: var(--dim); font-size: 12px; margin-top: 8px; }
.check input { width: auto; }

.right { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; border: 0; border-radius: 0; background: none; padding: 11px 0; color: var(--dim); border-bottom: 2px solid transparent; }
.tabs button.sel { color: var(--text); border-bottom-color: var(--amber); }
.pane { flex: 1; overflow-y: auto; padding: 12px 14px; min-height: 0; }
.pane.map { padding: 0; }
#map { height: 100%; min-height: 300px; }
.member { display: flex; align-items: center; gap: 9px; padding: 6px 0; }
.member .role { font-size: 11px; color: var(--dim); }
.member select { width: auto; padding: 3px 6px; font-size: 12px; }
.card { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.card h3 { font-size: 13px; margin-bottom: 6px; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 16px; letter-spacing: 2px; color: var(--amber); }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 22px; width: 380px; max-width: 92vw; }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h3 { margin-bottom: 6px; font-size: 16px; }
dialog .row { margin-top: 16px; justify-content: flex-end; }
.result { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.empty { color: var(--dim); text-align: center; margin: auto; max-width: 320px; line-height: 1.5; }
.leaflet-container { background: #0e1116; }
.who-label { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; font-size: 12px; white-space: nowrap; }
.who-label.off { opacity: .55; }

@media (max-width: 1000px) { .shell { grid-template-columns: 220px 1fr; } .right { display: none; } }

.msg a { color: var(--blue); display: inline-block; margin-top: 4px; }
dialog .result { font-size: 13px; }
dialog { max-height: 90vh; overflow-y: auto; }
