:root {
  --ink: #000;
  --paper: #f4f1ea;
  --accent: #ff3d00;
  --hi: #ffe600;
  --bar: #ff3d00;
  --retail: #ffb300;
  --food: #2979ff;
  --other: #fffdf6;
  --gap: #1a1a1a;
  --unresearched: #9e9e9e;
  --film: #8e24aa;
  --border: 4px solid var(--ink);
  --thin: 3px solid var(--ink);
  --shadow: 6px 6px 0 var(--ink);
  --font: "Courier New", ui-monospace, SFMono-Regular, Menlo, monospace;
  --panel-w: 440px;
  --timebar-h: 132px;
  --topbar-h: 74px;
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  overflow: hidden;
}

h1, h2, h3 { margin: 0; text-transform: uppercase; letter-spacing: -0.02em; }
h1 { font-size: 1.7rem; font-weight: 900; }
h2 { font-size: 1.25rem; font-weight: 900; }
h3 { font-size: 0.95rem; font-weight: 900; margin: 1rem 0 0.4rem; }
a { color: var(--ink); font-weight: 700; }
a:hover { background: var(--hi); }
.muted { color: #555; font-size: 0.82rem; }

.btn {
  font-family: var(--font);
  font-weight: 900;
  text-transform: uppercase;
  background: var(--hi);
  color: var(--ink);
  border: var(--thin);
  box-shadow: 3px 3px 0 var(--ink);
  padding: 0.3rem 0.65rem;
  cursor: pointer;
}
.btn:hover { background: var(--accent); color: #fff; }
.btn:active, .btn.on { transform: translate(3px, 3px); box-shadow: none; }
.btn.on { background: var(--ink); color: var(--hi); }
.btn.small { font-size: 0.75rem; }

/* ---------- top bar */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1rem;
  border-bottom: var(--border);
  background: var(--hi);
}
.brand { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.logo { width: 46px; height: 46px; }
.sub { margin: 0.1rem 0 0; font-size: 0.8rem; font-weight: 700; }
.stats { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: flex-end; }
.stat {
  border: var(--thin);
  background: #fff;
  padding: 0.2rem 0.5rem;
  box-shadow: 3px 3px 0 var(--ink);
  text-align: center;
}
.stat b { display: block; font-size: 1.05rem; }
.stat span { font-size: 0.65rem; text-transform: uppercase; }

/* ---------- layout */
.layout {
  display: grid;
  grid-template-columns: 1fr var(--panel-w);
  height: calc(100vh - var(--topbar-h) - var(--timebar-h));
}
.stage { position: relative; border-right: var(--border); min-width: 0; }
.scene { position: absolute; inset: 0; }
.scene canvas { display: block; }

.hud {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
  pointer-events: none;
}
.hud-group {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: #fff;
  border: var(--thin);
  box-shadow: 3px 3px 0 var(--ink);
  padding: 0.3rem 0.45rem;
  font-weight: 900;
  font-size: 0.75rem;
}
.hud-label { font-weight: 900; }
.check { display: flex; align-items: center; gap: 0.35rem; font-weight: 900; font-size: 0.75rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }

.tooltip {
  position: absolute;
  pointer-events: none;
  background: #fff;
  border: var(--thin);
  box-shadow: 4px 4px 0 var(--ink);
  padding: 0.35rem 0.5rem;
  font-size: 0.78rem;
  max-width: 280px;
  z-index: 5;
}
.tooltip b { display: block; }

.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  font-weight: 900;
  background: var(--paper);
}
.loading.error { color: var(--accent); }

/* ---------- side panel */
.panel { display: flex; flex-direction: column; min-height: 0; background: var(--paper); }
.tabs { display: flex; border-bottom: var(--border); }
.tab {
  flex: 1;
  font-family: var(--font);
  font-weight: 900;
  font-size: 0.72rem;
  padding: 0.6rem 0.2rem;
  border: none;
  border-right: var(--thin);
  background: #fff;
  cursor: pointer;
}
.tab:last-child { border-right: none; }
.tab.active { background: var(--ink); color: var(--hi); }
.tab-body { overflow-y: auto; padding: 0.9rem; flex: 1; min-height: 0; }

.card {
  background: #fff;
  border: var(--thin);
  box-shadow: var(--shadow);
  padding: 0.75rem;
  margin-bottom: 1rem;
}
.addr-list { margin: 0.2rem 0 0.4rem; font-size: 1.05rem; font-weight: 900; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 0.15rem 0.6rem; font-size: 0.8rem; }
.facts dt { font-weight: 900; }
.facts dd { margin: 0; }

.chip {
  display: inline-block;
  border: 2px solid var(--ink);
  padding: 0 0.3rem;
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
  vertical-align: middle;
}
.chip.bar { background: var(--bar); color: #fff; }
.chip.beer_liquor_retail { background: var(--retail); }
.chip.restaurant { background: var(--food); color: #fff; }
.chip.other { background: var(--other); }
.chip.gap { background: var(--gap); color: var(--hi); }
.chip.unresearched { background: var(--unresearched); }
.chip.residential { background: #e6e0d2; }
.chip.license { background: var(--hi); }
.chip.ocr { background: #fff; border-style: dashed; }
.chip.film, .chip.press { background: var(--film); color: #fff; }
.chip.permit { background: #fff; }
.chip.approx { background: #fff; border-style: dotted; }

.film-item {
  border: 2px solid var(--ink);
  border-left: 6px solid var(--film);
  background: #fff;
  padding: 0.35rem 0.5rem;
  margin: 0.45rem 0;
  font-size: 0.8rem;
}
.film-item .prod { font-weight: 900; }
.film-item .film-scene { display: block; }
.event-row { border-bottom: 2px solid var(--ink); padding: 0.3rem 0; font-size: 0.78rem; }
.event-row .when { font-weight: 900; cursor: pointer; text-decoration: underline; margin-right: 0.3rem; }
.event-row .text { display: block; color: #333; }
.panel-details { margin: 0.6rem 0; }
.panel-details > summary {
  cursor: pointer;
  font-weight: 900;
  text-transform: uppercase;
  font-size: 0.85rem;
  border: var(--thin);
  background: #fff;
  box-shadow: 3px 3px 0 var(--ink);
  padding: 0.3rem 0.5rem;
}
.film-badge {
  display: inline-block;
  background: var(--film);
  color: #fff;
  border: 2px solid var(--ink);
  font-size: 0.62rem;
  font-weight: 900;
  padding: 0 0.25rem;
  margin-left: 0.3rem;
  vertical-align: middle;
}
.mini .tick { position: absolute; top: 30px; width: 2px; height: 12px; background: var(--film); }
.mini .tick.permit { background: var(--ink); top: 32px; height: 8px; }

.mini {
  position: relative;
  height: 46px;
  border: var(--thin);
  background: repeating-linear-gradient(45deg, #fff, #fff 4px, #eee 4px, #eee 8px);
  margin: 0.4rem 0 0.2rem;
}
.mini .seg { position: absolute; height: 14px; border: 1px solid var(--ink); cursor: pointer; }
.mini .seg.gapseg { background: var(--gap); top: 30px; height: 10px; border: none; opacity: 0.85; }
.mini .now { position: absolute; top: -4px; bottom: -4px; width: 3px; background: var(--hi); border: 1px solid var(--ink); }
.mini-axis { display: flex; justify-content: space-between; font-size: 0.65rem; font-weight: 700; }

.span {
  border-left: 6px solid var(--ink);
  padding: 0.35rem 0.5rem;
  margin: 0.45rem 0;
  background: #fff;
  border-top: 2px solid var(--ink);
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
}
.span.current { outline: 3px solid var(--hi); outline-offset: 1px; }
.span .when { font-weight: 900; cursor: pointer; text-decoration: underline; }
.span .name { font-weight: 900; }
.span .basis { font-size: 0.72rem; color: #444; }
.span details { font-size: 0.75rem; margin-top: 0.25rem; }
.span summary { cursor: pointer; font-weight: 700; }
.span .cite { margin: 0.2rem 0; }
.span .snippet { font-style: italic; color: #333; background: #f6f3ea; padding: 0.15rem 0.3rem; display: block; }
.span.bar { border-left-color: var(--bar); }
.span.beer_liquor_retail { border-left-color: var(--retail); }
.span.restaurant { border-left-color: var(--food); }
.span.other { border-left-color: #bbb; }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  border-bottom: 2px solid var(--ink);
  padding: 0.4rem 0.2rem;
  cursor: pointer;
}
.list li:hover { background: var(--hi); }
.list .right { text-align: right; font-size: 0.75rem; white-space: nowrap; }
.search {
  width: 100%;
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 0.45rem;
  border: var(--thin);
  box-shadow: 3px 3px 0 var(--ink);
  margin-bottom: 0.7rem;
}
.gap-item { border: var(--thin); background: #fff; padding: 0.5rem; margin-bottom: 0.6rem; box-shadow: 3px 3px 0 var(--ink); }
.gap-item b { display: block; }
.downloads { display: flex; gap: 0.4rem; flex-wrap: wrap; margin: 0.5rem 0 1rem; }
.downloads a { text-decoration: none; }

/* ---------- time bar */
.timebar {
  height: var(--timebar-h);
  border-top: var(--border);
  background: #fff;
  display: grid;
  grid-template-columns: 170px auto 1fr 300px;
  align-items: center;
  gap: 1rem;
  padding: 0 1rem;
}
.year { font-size: 3.2rem; font-weight: 900; line-height: 1; }
.year-note { font-size: 0.7rem; font-weight: 700; min-height: 2.2em; }
.controls { display: flex; flex-direction: column; gap: 0.4rem; align-items: flex-start; }
.controls .btn { width: 100%; }
.controls { display: grid; grid-template-columns: repeat(3, auto); gap: 0.4rem; }
.controls .check { grid-column: 1 / -1; }
.slider-wrap { position: relative; min-width: 0; }
.density { width: 100%; height: 38px; display: block; border: var(--thin); border-bottom: none; background: var(--paper); }
#slider {
  width: 100%;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  height: 22px;
  background: var(--ink);
  border: var(--thin);
}
#slider::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 30px; background: var(--hi); border: 3px solid var(--ink); cursor: grab; }
#slider::-moz-range-thumb { width: 18px; height: 30px; background: var(--hi); border: 3px solid var(--ink); border-radius: 0; cursor: grab; }
.ticks { position: relative; height: 16px; font-size: 0.65rem; font-weight: 900; }
.ticks span { position: absolute; transform: translateX(-50%); }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 0.2rem 0.5rem; font-size: 0.7rem; font-weight: 700; }
.legend div { display: flex; align-items: center; gap: 0.3rem; }
.swatch { width: 14px; height: 14px; border: 2px solid var(--ink); flex: none; }

@media (max-width: 1000px) {
  html, body { overflow: auto; height: auto; }
  body { display: flex; flex-direction: column; }
  :root { --timebar-h: auto; --topbar-h: auto; }
  .layout { display: contents; }
  .topbar { order: 0; flex-direction: column; align-items: flex-start; padding: 0.6rem; }
  .stats .stat { padding: 0.1rem 0.35rem; }
  .stage { order: 1; height: 58vh; flex: none; border-right: none; border-bottom: var(--border); }
  .timebar {
    order: 2;
    grid-template-columns: auto 1fr;
    height: auto;
    padding: 0.6rem;
    gap: 0.5rem 0.8rem;
    border-top: none;
    border-bottom: var(--border);
  }
  .slider-wrap, .legend { grid-column: 1 / -1; }
  .panel { order: 3; }
  .tab-body { max-height: none; }
  .year { font-size: 2.2rem; }
  .hud { gap: 0.35rem; }
  .hud-group { padding: 0.2rem 0.35rem; }
}
