:root {
  --bg: #16181c;
  --panel: #1f2228;
  --panel-2: #282c34;
  --text: #e8e4da;
  --muted: #9a958a;
  --accent: #c8a45a;
  --danger: #c0504d;
  --border: #353a43;
  --sidebar-w: 300px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}

body { display: flex; }

#sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  height: 100%;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#map { flex: 1; height: 100%; background: #0e0f11; }
#no-map { flex: 1; display: grid; place-items: center; color: var(--muted); padding: 16px; text-align: center; }
#map.editing, #map.editing .leaflet-interactive { cursor: crosshair; }

header h1 {
  margin: 0 0 8px;
  font-size: 20px;
  letter-spacing: .08em;
  color: var(--accent);
  text-transform: uppercase;
}

select, button {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 8px;
}
select { width: 100%; }
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button.danger { color: var(--danger); }
button.primary { background: var(--accent); color: #1b1b1b; border-color: var(--accent); }

.overall-row { display: flex; justify-content: space-between; margin-bottom: 4px; }
#overall-pct { color: var(--accent); font-weight: 600; }

.bar { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.controls { display: flex; flex-direction: column; gap: 8px; }
.controls label:not(.check) { display: flex; flex-direction: column; gap: 4px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.check small { color: var(--muted); }
.buttons { display: flex; gap: 6px; }
.buttons button { flex: 1; }

#categories h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin: 12px 0 4px;
}

.cat {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 6px;
  padding: 4px 2px;
  cursor: pointer;
  border-radius: 4px;
}
.cat:hover { background: var(--panel-2); }
.cat .dot { width: 10px; height: 10px; border-radius: 50%; border: 1px solid #0006; }
.cat .count { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.cat .bar { grid-column: 3 / 5; height: 3px; }
.cat.off { opacity: .45; }

.tabs { display: flex; gap: 0; }
.tabs button { flex: 1; border-radius: 0; }
.tabs button:first-child { border-radius: 4px 0 0 4px; }
.tabs button:last-child { border-radius: 0 4px 4px 0; border-left: none; }
.tabs button[aria-pressed="true"] { background: var(--accent); color: #1b1b1b; border-color: var(--accent); }

.cat .list-dot { background: transparent; border: 2px solid var(--accent); }

/* Checklist view */
#checklist { flex: 1; height: 100%; overflow-y: auto; padding: 16px 24px 48px; }
#checklist .list { max-width: 760px; margin: 0 auto 28px; }
#checklist h2 { display: flex; justify-content: space-between; align-items: baseline; font-size: 18px; margin: 8px 0 12px; }
#checklist .count { color: var(--muted); font-size: 12px; font-weight: normal; font-variant-numeric: tabular-nums; }
#checklist .section { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; margin-bottom: 8px; }
#checklist summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  list-style-position: inside;
}
#checklist summary .bar { grid-column: 1 / -1; height: 3px; }
#checklist .section-name { font-weight: 600; }
#checklist ul { list-style: none; margin: 0; padding: 0 12px 10px; }
#checklist .item { padding: 6px 0; border-top: 1px solid var(--border); }
#checklist .item label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
#checklist .item input { margin-top: 3px; accent-color: var(--accent); }
#checklist .item.done .item-name { color: var(--muted); text-decoration: line-through; }
#checklist .notes { margin: 2px 0 0 26px; color: var(--muted); font-size: 13px; white-space: pre-wrap; }
#checklist .notes a { color: var(--accent); }
#checklist .hidden-item { color: var(--muted); font-style: italic; }
#checklist .hidden-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  color: var(--muted);
  border-style: dashed;
}

.steam h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 0 0 6px; }
.steam .steam-row { display: flex; gap: 6px; margin-bottom: 6px; }
.steam input {
  flex: 1; min-width: 0; font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 4px; padding: 5px 8px;
}
.steam .hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
button:disabled { opacity: .5; cursor: default; }
#checklist .badge {
  margin-left: auto; font-size: 11px; color: var(--muted); border: 1px solid var(--border);
  border-radius: 3px; padding: 0 5px; text-transform: capitalize;
}
#checklist .item.secret .item-name { color: var(--muted); font-style: italic; }

footer { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
#sources { font-size: 11px; color: var(--muted); }
#sources a { color: var(--muted); }

#sidebar-toggle { display: none; }

/* Leaflet popups */
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--text); }
.leaflet-popup-content { margin: 12px 14px; min-width: 220px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-container { font: inherit; }
.leaflet-control-attribution { background: #000a !important; color: var(--muted); }
.leaflet-control-attribution a { color: var(--muted); }

.popup h3 { margin: 0 0 2px; font-size: 15px; }
.popup .meta { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.popup p { margin: 6px 0; white-space: pre-wrap; }
.popup a { color: var(--accent); }
.popup .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.popup form { display: flex; flex-direction: column; gap: 6px; }
.popup input, .popup textarea {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 8px;
  width: 100%;
}
.popup .error { color: var(--danger); font-size: 12px; }

.map-hint {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: var(--accent);
  color: #1b1b1b;
  padding: 4px 12px;
  border-radius: 4px;
  pointer-events: none;
}

@media (max-width: 700px) {
  #sidebar {
    position: fixed;
    z-index: 1100;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform .2s;
    width: min(86vw, var(--sidebar-w));
  }
  body.sidebar-open #sidebar { transform: none; }
  #checklist { padding: 56px 16px 48px; }
  #sidebar-toggle {
    display: block;
    position: fixed;
    z-index: 1200;
    top: 10px;
    right: 10px;
  }
}
