:root {
  --bg: #f6f5f1;
  --panel: #ffffff;
  --fg: #1d1f22;
  --muted: #62666c;
  --line: #e2e0da;
  --has: #2b7a8b;
  --none: #9aa0a6;
  --sel: #1d1f22;
  --serif: "Source Serif 4", Georgia, serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141517;
    --panel: #1d1f22;
    --fg: #eceae4;
    --muted: #a3a6ab;
    --line: #34373b;
    --has: #5fb4c4;
    --none: #7d838a;
    --sel: #f4f2ec;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--sans); font-size: 15px; line-height: 1.45; font-variant-numeric: tabular-nums; }
a { color: inherit; }
.page { max-width: 1400px; margin: 0 auto; padding: 24px 16px 32px; display: grid; gap: 16px; }

.head h1 { font-family: var(--serif); font-weight: 400; font-size: 2.1rem; margin: 0; }
.head p { margin: 4px 0 0; color: var(--muted); max-width: 70ch; }

.wrap { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }

.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.tools input { font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--fg); flex: 1 1 14rem; min-width: 0; max-width: 24rem; }
.btn, .chip { font: inherit; font-size: .85rem; cursor: pointer; padding: 4px 12px; border: 1px solid var(--line); background: var(--panel); color: var(--fg); }
.btn { border-radius: var(--radius); }
.chip { border-radius: 999px; padding: 1px 10px; }
.btn:hover:not(:disabled), .chip:hover { border-color: var(--fg); }
.btn:disabled { color: var(--muted); cursor: default; }
.btn:focus-visible, .chip:focus-visible, .tools input:focus-visible { outline: 2px solid var(--fg); outline-offset: 1px; }
.hint { font-size: .85rem; color: var(--muted); }

.timeline { margin-bottom: 10px; }
.tl-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tl-out { font-size: .85rem; font-weight: 500; }
.tl-track { position: relative; height: 44px; }
.tl-track::after { content: ""; position: absolute; left: 0; right: 0; bottom: 2px; height: 1px; background: var(--line); }
.tl-bars { position: absolute; inset: 0 0 6px 0; width: 100%; height: calc(100% - 6px); }
.tl-bars rect.on { fill: var(--has); fill-opacity: .85; }
.tl-bars rect.off { fill: var(--none); fill-opacity: .35; }
.tl-range { position: absolute; left: 0; right: 0; bottom: -6px; width: 100%; margin: 0; height: 18px; background: none; pointer-events: none; -webkit-appearance: none; appearance: none; }
.tl-range::-webkit-slider-runnable-track { background: transparent; height: 18px; }
.tl-range::-moz-range-track { background: transparent; height: 18px; }
.tl-range::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; width: 16px; height: 16px; margin-top: 1px; border-radius: 50%; background: var(--panel); border: 2px solid var(--fg); cursor: ew-resize; }
.tl-range::-moz-range-thumb { pointer-events: auto; width: 13px; height: 13px; border-radius: 50%; background: var(--panel); border: 2px solid var(--fg); cursor: ew-resize; }
.tl-range:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--fg); outline-offset: 2px; }
.tl-axis { position: relative; height: 16px; margin-top: 4px; font-size: .78rem; color: var(--muted); }
.tl-axis span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.tl-axis span:first-child { transform: none; }
.tl-axis span:last-child { transform: translateX(-100%); }
@media (max-width: 520px) { .tl-axis span:nth-child(2) { display: none; } }

.map { height: min(72vh, 760px); min-height: 320px; border-radius: var(--radius); background: var(--bg); }
.maplibregl-map { font-family: var(--sans); }
.maplibregl-popup.area-tip { pointer-events: none; }
.area-tip .maplibregl-popup-content { background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.12); padding: 4px 8px; font-size: .82rem; }
.area-tip .maplibregl-popup-tip { display: none; }
.area-tip b { display: block; font-weight: 500; }
.area-tip span { color: var(--muted); }
.maplibregl-ctrl-attrib { font-size: 11px; }

.list h2 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 1.5rem; }
.sub { margin: 4px 0 12px; font-size: .85rem; color: var(--muted); }
/* Books in columns under the map, read left to right (most-rated first) */
.list ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); column-gap: 24px; align-items: start; }
.list li { display: grid; gap: 2px; padding-block: 10px; border-top: 1px solid var(--line); }
.list li a.title { font-family: var(--serif); font-size: 1.05rem; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.list li a.title:hover { text-decoration-color: var(--fg); }
.meta { font-size: .82rem; color: var(--muted); }
.meta b { color: var(--fg); font-weight: 500; }
.list li.group { grid-column: 1 / -1; border-top: 0; padding-block: 16px 2px; font-weight: 500; }
.list li.empty { grid-column: 1 / -1; color: var(--muted); font-size: .85rem; }
.link { font: inherit; background: none; border: 0; padding: 0; cursor: pointer; color: var(--fg); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.link:hover { text-decoration-color: var(--fg); }
.link:focus-visible { outline: 2px solid var(--fg); }
.list-tools { margin: -4px 0 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: inline-flex; gap: 4px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0; }
.kind { font-size: .72rem; line-height: 1.5; padding: 0 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }
.kind.nf { border-color: var(--fg); color: var(--fg); }
.chip[aria-pressed="true"] { border-color: var(--fg); background: var(--bg); font-weight: 500; }
.sop { font-size: .72rem; line-height: 1.5; padding: 0 8px; border: 1px solid var(--has); border-radius: 999px; color: var(--has); }
.crumbs { font-size: .82rem; color: var(--muted); margin-bottom: 4px; }

.foot { font-size: .8rem; color: var(--muted); max-width: 90ch; }

.eras { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin-bottom: 10px; }
.era-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip .n { color: var(--muted); font-weight: 400; margin-left: 4px; }

/* Filters fold away on phones; on wider screens they are always open */
.filters > summary { display: none; list-style: none; }
.filters > summary::-webkit-details-marker { display: none; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.list li.more { grid-column: 1 / -1; border-top: 0; justify-items: start; }

@media (max-width: 640px) {
  .page { padding: 16px 12px 24px; gap: 12px; }
  .head h1 { font-size: 1.6rem; }
  .head p { font-size: .85rem; }
  .card { padding: 12px; }
  .filters > summary { display: inline-block; margin-bottom: 10px; }
  #btn-clear:disabled { display: none; }
  .filters > summary::after { content: " ▾"; }
  .filters[open] > summary::after { content: " ▴"; }
  .map { height: 55vh; min-height: 300px; }
  .list-tools { gap: 6px; }
  /* Compact book items */
  .list li { padding-block: 8px; gap: 1px; }
  .list li a.title { font-size: 1rem; }
  .meta { font-size: .78rem; }
  .meta.born { display: none; }
  .tags { margin: 1px 0; }
}
.list li[hidden] { display: none; }

/* Read / Watch switch under the title */
.mode { margin-top: 8px; }
.mode .chip { font-size: .95rem; padding: 3px 16px; }
.list li a.title .en { color: var(--muted); }
.meta.streams { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.svc { font-size: .72rem; line-height: 1.5; padding: 0 7px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--fg); }

/* Chips never break over two lines; groups wrap as a whole */
.chip, .hint { white-space: nowrap; }
.seg { flex-wrap: wrap; align-items: center; }
