:root {
  color-scheme: dark;
  --bg: #07100f;
  --panel: #111a18;
  --panel-2: #17211f;
  --text: #effcf7;
  --muted: #9fb8af;
  --line: #29403b;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --cyan: #22d3ee;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: inherit; }
button, input {
  font: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(310px, 380px) 1fr;
}

.chaser-shell {
  min-height: 100vh;
  display: grid;
  place-items: stretch center;
  padding: 16px;
}

.chaser-shell .sidebar {
  width: min(560px, 100%);
  min-height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card, .sidebar, .panel, dialog {
  background: color-mix(in srgb, var(--panel) 94%, black);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.auth-card {
  width: min(560px, 100%);
  padding: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.brand img { width: 42px; height: 42px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 28px; letter-spacing: 0; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
.muted { color: var(--muted); }

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
}

.tabs button, .seg button {
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  cursor: pointer;
}

.tabs button.active, .seg button.active {
  color: var(--text);
  border-color: var(--green);
  background: rgba(34, 197, 94, .14);
}

form { display: grid; gap: 12px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #071412;
  color: var(--text);
  padding: 11px 12px;
}

.password-row {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 8px;
  align-items: center;
}

.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}

.icon-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.primary, .danger, .ghost, .radio-button {
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  min-height: 42px;
  padding: 10px 14px;
}

.primary { background: #0f766e; }
.danger { background: #991b1b; }
.ghost { background: var(--panel-2); border-color: var(--line); }
.radio-button {
  background: #b91c1c;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  font-weight: 800;
  text-transform: uppercase;
}
.radio-button.recording { background: #dc2626; box-shadow: 0 0 0 3px rgba(239,68,68,.28); }

.sidebar {
  min-height: 100vh;
  border-radius: 0;
  border-width: 0 1px 0 0;
  padding: 18px;
  overflow: auto;
}

.main {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 16, 15, .88);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.panel {
  padding: 14px;
  margin-bottom: 12px;
}

.map {
  min-height: calc(100vh - 64px);
  background: #061311;
}

.video {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #020807;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: cover;
}

.list {
  display: grid;
  gap: 8px;
}

.row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255,255,255,.025);
}

.avatar, .map-avatar {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  object-fit: cover;
  background: #21302d;
  border: 3px solid var(--green);
}

.avatar.lost, .map-avatar.lost { border-color: var(--red); }
.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  margin-right: 5px;
  background: var(--green);
}
.status-dot.red { background: var(--red); }
.status-dot.amber { background: var(--amber); }

.leaflet-marker-icon { background: transparent; border: none; }
.map-pin { position: relative; width: 48px; height: 48px; }
.map-pin .map-avatar { width: 48px; height: 48px; }
.map-pin::after {
  content: "";
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--green);
  border: 2px solid #07100f;
}
.map-pin.lost::after { background: var(--red); }

.download-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.notice {
  border-left: 3px solid var(--cyan);
  padding: 10px 12px;
  background: rgba(34, 211, 238, .08);
  color: var(--muted);
}

dialog {
  color: var(--text);
  width: min(440px, calc(100% - 24px));
  padding: 18px;
}
dialog::backdrop { background: rgba(0, 0, 0, .68); }

@media (max-width: 850px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; border-width: 0 0 1px 0; }
  .map { min-height: 62vh; }
  .grid, .download-grid { grid-template-columns: 1fr; }
  .topbar { height: auto; min-height: 64px; align-items: flex-start; flex-direction: column; gap: 8px; padding: 12px 16px; }
}
