:root {
  color-scheme: dark;
  --bg: #0e1218;
  --panel: rgba(18, 22, 28, 0.94);
  --line: rgba(255, 255, 255, 0.1);
  --accent: #3d6a9e;
  --accent-bright: #6b9fd4;
  --text: #e8eaed;
  --muted: #8a939e;
  --danger: #c45a6a;
  --ok: #4ade80;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(61, 106, 158, 0.16), transparent 28rem),
    linear-gradient(180deg, #0e1218 0%, #121820 55%, #0c1016 100%);
}

button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-card {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  text-align: center;
}
.gate-card h1 { margin: 12px 0 8px; font-size: 1.6rem; }
.gate-card p { color: var(--muted); margin: 0 0 18px; }

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: var(--accent);
  border: 1px solid rgba(255,255,255,0.12);
  font-weight: 800;
}
.brand-mark.sm { width: 42px; height: 42px; font-size: 0.9rem; }

.app {
  width: min(1200px, calc(100% - 24px));
  margin: 0 auto;
  padding: 18px 0 40px;
  display: grid;
  gap: 14px;
}

.topbar, .filters, .timeline-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px 18px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand h1 { margin: 0; font-size: 1.25rem; }
.brand p, #whoami { margin: 2px 0 0; color: var(--muted); font-size: 0.85rem; }
.top-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.filters {
  position: sticky;
  top: 8px;
  z-index: 20;
  padding: 14px 16px;
  backdrop-filter: blur(10px);
}
.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.filter-grid label, .toggle {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.filter-grid .span-2 { grid-column: span 2; }
.filter-grid input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0,0,0,0.28);
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  font-size: 0.95rem;
}
.filter-grid input:focus {
  outline: none;
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 3px rgba(107, 159, 212, 0.14);
}

.category-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.cat-chip {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0,0,0,0.22);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}
.cat-chip.is-on {
  color: var(--text);
  border-color: rgba(107, 159, 212, 0.45);
  background: rgba(61, 106, 158, 0.28);
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}
.toggle {
  grid-auto-flow: column;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}
.toggle input { width: auto; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.btn:hover { background: rgba(255,255,255,0.06); }
.btn.primary { background: var(--accent); border-color: var(--accent); }
.btn.ghost { color: var(--accent-bright); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}
.live-pill.is-on {
  color: #0c1016;
  background: var(--ok);
  border-color: transparent;
}
.live-pill.is-on::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: #0c1016;
}

.timeline-wrap { padding: 12px; }
.status-bar {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 4px 6px 10px;
}
.timeline { display: grid; gap: 8px; }

.event {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0,0,0,0.18);
  overflow: hidden;
}
.event.is-new {
  border-color: rgba(107, 159, 212, 0.45);
  box-shadow: 0 0 0 1px rgba(107, 159, 212, 0.12);
}
.event-main {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 12px 14px;
}
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(61, 106, 158, 0.28);
  color: var(--accent-bright);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge.cat-ban, .badge.cat-kick, .badge.cat-shadowmute { background: rgba(196,90,106,0.22); color: #f0d4d8; }
.badge.cat-dupe, .badge.cat-antivpn { background: rgba(196,140,60,0.2); color: #e8d4a8; }
.badge.cat-join, .badge.cat-leave { background: rgba(74,222,128,0.12); color: #9be7b5; }
.badge.cat-chat, .badge.cat-private_message { background: rgba(107,159,212,0.18); color: #b7d3ef; }

.summary { margin: 0 0 6px; font-size: 0.98rem; line-height: 1.4; word-break: break-word; }
.meta { display: flex; flex-wrap: wrap; gap: 8px 12px; color: var(--muted); font-size: 0.8rem; }
.meta a, .player-link, .coord-link {
  color: var(--accent-bright);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 0.78rem;
}
.meta a:hover, .player-link:hover, .coord-link:hover { color: #fff; text-decoration: underline; }
.time {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.expand {
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 0 14px 12px;
}
.expand summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 0 8px;
}
.expand pre {
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  background: rgba(0,0,0,0.35);
  color: #c5cdd6;
  font-family: var(--mono);
  font-size: 0.75rem;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.load-more-wrap { display: flex; justify-content: center; padding: 14px 0 4px; }

@media (max-width: 900px) {
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .filter-grid .span-2 { grid-column: span 2; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .event-main { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .filter-grid { grid-template-columns: 1fr; }
  .filter-grid .span-2 { grid-column: span 1; }
  .filters { position: static; }
}


.tz-label {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.time-stack {
  display: grid;
  gap: 2px;
  text-align: right;
}
.time-rel {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}
.time-abs {
  color: var(--muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0,0,0,0.72);
}
.overlay-card {
  width: min(760px, 100%);
  max-height: calc(100vh - 32px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0,0,0,0.45);
}
.overlay-card.wide { width: min(980px, 100%); }
.overlay-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.overlay-head h2 { margin: 0; font-size: 1.2rem; }
.overlay-sub { margin: 4px 0 0; color: var(--muted); font-size: 0.85rem; }
.overlay-body {
  padding: 16px 18px 20px;
  overflow: auto;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.stat-card {
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  background: rgba(0,0,0,0.18);
}
.stat-card em {
  display: block;
  color: var(--muted);
  font-style: normal;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.stat-card strong { font-size: 1.05rem; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 16px; }
.mini-chip {
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.2);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}
.heat-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 16px;
}
.heat-grid {
  display: grid;
  gap: 2px;
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0,0,0,0.25);
}
.heat-cell {
  min-width: 0;
  min-height: 0;
}
.player-heat-list { display: grid; gap: 8px; align-content: start; }
.player-heat-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  background: rgba(0,0,0,0.16);
}
.dossier-recent { display: grid; gap: 8px; }
@media (max-width: 800px) {
  .heat-layout { grid-template-columns: 1fr; }
  .time-stack { text-align: left; }
}
