:root {
  --bg: #ffffff;
  --panel: #f6f7f9;
  --text: #1d2330;
  --muted: #5f6b7a;
  --border: #d9dde3;
  --accent: #2e5eaa;
  --banner-bg: #fff4d6;
  --banner-text: #6b4e00;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --panel: #1c2027;
    --text: #e7eaee;
    --muted: #9aa5b1;
    --border: #2f3540;
    --accent: #7aa7f0;
    --banner-bg: #3a3112;
    --banner-text: #f3dc95;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; margin: 0; }
select, input, button { font: inherit; color: inherit; }
select {
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px;
}

.banner {
  background: var(--banner-bg); color: var(--banner-text);
  padding: 6px 16px; font-size: 13px;
}

.layout { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: 340px; flex: none; overflow-y: auto;
  background: var(--panel); border-right: 1px solid var(--border);
  padding: 14px 16px;
}
.map { flex: 1; min-height: 0; }

.search { position: relative; margin-bottom: 14px; }
.search input {
  width: 100%; padding: 9px 11px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg);
}
.results { list-style: none; margin: 4px 0 0; padding: 0; }
.results li {
  padding: 7px 9px; border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
}
.results li:hover, .results li.active { background: var(--bg); }
.results small { color: var(--muted); display: block; }
.lookup {
  margin-top: 6px; width: 100%; text-align: left; cursor: pointer;
  background: none; border: 1px dashed var(--border); border-radius: 6px; padding: 7px 9px;
  color: var(--accent);
}

.selection {
  border: 1px solid var(--border); border-left-width: 6px; border-radius: 8px;
  background: var(--bg); padding: 10px 12px; margin-bottom: 14px;
}
.selection .chapter-tag { font-weight: 700; font-size: 16px; }
.selection .meta { color: var(--muted); font-size: 13px; }

h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 6px; }
.legend { list-style: none; margin: 0; padding: 0; }
.legend li { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.legend label { flex: 1; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.legend .count { color: var(--muted); font-size: 13px; }
.swatch { width: 14px; height: 14px; border-radius: 3px; flex: none; }
.note { color: var(--muted); font-size: 12px; margin-top: 10px; }

.pin {
  min-width: 24px; height: 24px; padding: 0 3px; border-radius: 12px;
  color: #fff; font-weight: 700; font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.pin.selected { transform: scale(1.35); box-shadow: 0 0 0 3px rgba(0,0,0,.35); }
.chapter-label {
  background: transparent; border: none; box-shadow: none;
  font-weight: 800; font-size: 13px; text-shadow: 0 0 3px #fff, 0 0 3px #fff;
}
.chapter-label::before { display: none; }

@media (max-width: 720px) {
  .layout { flex-direction: column; }
  .sidebar { width: auto; max-height: 42vh; border-right: none; border-bottom: 1px solid var(--border); }
  .topbar h1 { font-size: 16px; }
}
