:root {
  --bg: #f6f4ef;
  --panel: #ffffff;
  --ink: #1d1c1a;
  --muted: #6b675f;
  --line: #ddd8cd;
  --accent: #b5401f;
  --kind-production: #b5401f;
  --kind-reissue: #d98a3a;
  --kind-boutique: #2f6f8f;
  --kind-kit: #5b8a3c;
  --kind-diy: #7a5c99;
  --kind-prototype: #8a8578;
  --block: #444038;
  --radius: 8px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513;
    --panel: #201f1c;
    --ink: #ece8df;
    --muted: #a39e93;
    --line: #36332e;
    --accent: #e0714d;
    --block: #c9c3b6;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.topbar h1 { font-size: 18px; margin: 0; letter-spacing: 0.02em; }

.search { flex: 1; max-width: 420px; }

.search input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}

.views { display: flex; gap: 4px; margin-left: auto; }

.views button {
  font: inherit;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.views button.active { background: var(--ink); color: var(--panel); border-color: var(--ink); }

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 220px 1fr 360px;
}

.filters, .detail {
  overflow-y: auto;
  padding: 14px 16px;
  background: var(--panel);
}

.filters { border-right: 1px solid var(--line); }
.detail { border-left: 1px solid var(--line); }

.filters h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 8px; }

fieldset { border: 0; padding: 0; margin: 0 0 16px; }
legend { font-weight: 600; margin-bottom: 4px; }
fieldset label { display: flex; align-items: center; gap: 6px; padding: 2px 0; cursor: pointer; }

.swatch { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }
.swatch.block { border-radius: 2px; background: var(--block); }

.legend-row { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 2px 0; }
.legend-line { width: 28px; height: 0; border-top: 2px solid var(--muted); flex: none; }
.legend-line.dashed { border-top-style: dashed; }
.legend-line.dotted { border-top-style: dotted; }

.hint { font-size: 13px; color: var(--muted); }

.graph-wrap { position: relative; min-width: 0; }
#graph { position: absolute; inset: 0; }

#timeline-axis {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 28px;
  pointer-events: none;
  font-size: 12px;
  color: var(--muted);
}
#timeline-axis span { position: absolute; transform: translateX(-50%); bottom: 6px; }
#timeline-note {
  position: absolute; top: 10px; left: 14px; margin: 0;
  font-size: 13px; color: var(--muted); pointer-events: none;
}

.detail h2 { margin: 0 0 2px; font-size: 20px; line-height: 1.25; }
.detail .sub { color: var(--muted); margin: 0 0 10px; }
.detail h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 18px 0 6px; }
.detail ul { list-style: none; padding: 0; margin: 0; }
.detail li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.detail li:last-child { border-bottom: 0; }
.detail a { color: var(--accent); }
.detail .note { display: block; color: var(--muted); font-size: 13px; }

.pill {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  margin-left: 4px;
  vertical-align: 1px;
  white-space: nowrap;
}
.pill.kind { color: #fff; border: 0; }
.pill.review { border-color: var(--accent); color: var(--accent); }

.goto {
  background: none; border: 0; padding: 0;
  font: inherit; font-weight: 600; color: var(--ink);
  text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px;
  cursor: pointer; text-align: left;
}
.goto:hover { text-decoration-color: var(--accent); }

.cite { font-size: 12px; color: var(--muted); }
.cite a { color: var(--muted); }

.empty p { color: var(--muted); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 55vh auto auto; }
  .graph-wrap { min-height: 55vh; }
  .filters { order: 3; border-right: 0; border-top: 1px solid var(--line); }
  .detail { order: 2; border-left: 0; border-top: 1px solid var(--line); }
  .topbar { flex-wrap: wrap; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
}
