:root {
  --bg: #111418; --panel: #1a1f26; --raised: #242b35; --line: #323a46;
  --text: #e8eaed; --muted: #8b949e; --accent: #ff5c8a; --accent-ink: #14060b;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { display: flex; flex-direction: column; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--raised); border-radius: 6px; padding: 8px 12px; min-height: 40px; }
button:hover { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.ghost { background: transparent; }
button.danger { border-color: #7a2c3f; color: #ff9db5; }
button.on { border-color: var(--accent); color: var(--accent); }
button.small { min-height: 30px; padding: 3px 8px; font-size: 13px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=text] { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; min-height: 40px; }
input[type=range] { accent-color: var(--accent); }
label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.muted { color: var(--muted); font-size: 13px; }
.note { background: var(--raised); border-radius: 6px; padding: 8px 10px; font-size: 13px; color: var(--muted); }

#bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
#bar h1 { font-size: 17px; margin: 0; white-space: nowrap; }
.spacer { flex: 1; }
#nickBtn { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#banner { background: #5a3d00; color: #ffe2a8; text-align: center; padding: 4px 8px; font-size: 13px; }

main { flex: 1; display: flex; min-height: 0; }
#map { flex: 1; min-width: 0; background: #0c0e11; }
#panel { width: 380px; background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
#panel h2 { margin: 0; font-size: 18px; overflow-wrap: anywhere; }
#panel p { margin: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 0; }
.field { display: flex; flex-direction: column; }
.results { display: flex; flex-direction: column; gap: 4px; }
.results button { text-align: left; min-height: 0; font-size: 13px; }
.seg { display: flex; }
.seg button { flex: 1; border-radius: 0; }
.seg button:first-child { border-radius: 6px 0 0 6px; }
.seg button:last-child { border-radius: 0 6px 6px 0; border-left: 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.tile { position: relative; aspect-ratio: 4 / 3; background: var(--bg); border: 2px solid var(--line); border-radius: 6px; overflow: hidden;
  display: flex; align-items: center; justify-content: center; }
.tile.speaking { border-color: var(--accent); }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile .letter { font-size: 28px; color: var(--muted); text-transform: uppercase; }
.tile .name { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 6px; font-size: 12px; background: rgba(0,0,0,.6);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .badge { color: var(--accent); }
.tile .actions { position: absolute; top: 4px; right: 4px; display: none; gap: 4px; }
.tile:hover .actions, .tile:focus-within .actions { display: flex; }
@media (hover: none) { .tile .actions { display: flex; } }
.tile .actions button { background: rgba(0,0,0,.7); }
.controls { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.now { font-size: 14px; overflow-wrap: anywhere; }
.now::before { content: "♫ "; color: var(--accent); }

.pin { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 13px; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.6); }
.pin.private { background: #5b6370; color: #fff; }
.pin.you { width: 16px; height: 16px; background: #3ea6ff; }
.pin.exact { width: 22px; height: 22px; background: #fff; border: 5px solid var(--accent); }
.pin.pick { background: #fff; color: #000; cursor: grab; }
.leaflet-div-icon { background: none; border: 0; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--text); }
.leaflet-popup-content { margin: 12px; min-width: 150px; display: flex; flex-direction: column; gap: 6px; }
.leaflet-popup-content strong { overflow-wrap: anywhere; }
.leaflet-container { font: inherit; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 16px; width: min(360px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog form { display: flex; flex-direction: column; gap: 12px; }
dialog h2 { margin: 0; font-size: 17px; }
dialog p { margin: 0; color: var(--muted); }
#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #000; border: 1px solid var(--line);
  padding: 10px 14px; border-radius: 6px; max-width: calc(100vw - 32px); z-index: 2000; }

@media (max-width: 720px) {
  main { flex-direction: column; }
  #map { flex: none; height: 45vh; }
  #panel { width: auto; flex: 1; border-left: 0; border-top: 1px solid var(--line); }
  #bar h1 { font-size: 15px; }
}
