/* Civic Light theme: Defamation Review Tracker */

:root {
  /* Surfaces */
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-alt: #f3f1ec;
  --border: #e3dfd5;
  --row-hover: #f6f2e8;

  /* Text */
  --fg: #1a1916;
  --muted: #6b6558;

  /* Accent */
  --accent: #1f4f73;
  --accent-soft: #e6edf3;

  /* Notice (parchment yellow) */
  --notice-fg: #5a4a1a;
  --notice-bg: #fbf3d7;
  --notice-border: #e8d27a;

  /* Chip (category) */
  --chip-bg: #eee9dd;
  --chip-fg: #3d3a30;

  /* Histogram sparkline */
  --hist-good: #557e3a;
  --hist-mid:  #b39134;
  --hist-bad:  #a14a2a;

  /* Bucket pill palette */
  --b-none-bg:      #a8a395; --b-none-fg:      #1a1916;
  --b-1-bg:         #1f4f73; --b-1-fg:         #ffffff;
  --b-5-bg:         #2b6f8f; --b-5-fg:         #ffffff;
  --b-10-bg:        #b39134; --b-10-fg:        #1a1916;
  --b-20-bg:        #b8781c; --b-20-fg:        #ffffff;
  --b-50-bg:        #a8761a; --b-50-fg:        #ffffff;
  --b-100-bg:       #8a4a14; --b-100-fg:       #ffffff;
  --b-150-bg:       #5a3308; --b-150-fg:       #ffffff;
  --b-200-bg:       #7d2f1b; --b-200-fg:       #ffffff;
  --b-250-bg:       #9a271c; --b-250-fg:       #ffffff;
  --b-over-250-bg:  #5a140f; --b-over-250-fg:  #ffffff;

  --radius: 4px;

  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-head: Georgia, "Times New Roman", Times, serif;
  --font-mono: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --map-side-pane-width: 320px;
}

[data-theme="dark"] {
  /* Surfaces */
  --bg:          #141210;
  --surface:     #1c1a17;
  --surface-alt: #232018;
  --border:      #302d26;
  --row-hover:   #232018;

  /* Text */
  --fg:    #e4dfd4;
  --muted: #87806e;

  /* Accent */
  --accent:      #5a9ec8;
  --accent-soft: #1a2a38;

  /* Notice */
  --notice-fg:     #c8a84a;
  --notice-bg:     #221e0e;
  --notice-border: #5a4a1a;

  /* Chip */
  --chip-bg: #2b2820;
  --chip-fg: #b8b0a0;

  /* Histogram sparkline */
  --hist-good: #6aaa4a;
  --hist-mid:  #d4b040;
  --hist-bad:  #c86040;

  /* Bucket pill palette */
  --b-none-bg:      #6b6558; --b-none-fg:      #f4efe5;
  --b-1-bg:         #5a9ec8; --b-1-fg:         #0f171d;
  --b-5-bg:         #50b0c0; --b-5-fg:         #0f171d;
  --b-10-bg:        #c8a848; --b-10-fg:        #15110a;
  --b-20-bg:        #d09030; --b-20-fg:        #15110a;
  --b-50-bg:        #c07828; --b-50-fg:        #15110a;
  --b-100-bg:       #c05030; --b-100-fg:       #ffffff;
  --b-150-bg:       #d06040; --b-150-fg:       #ffffff;
  --b-200-bg:       #d84038; --b-200-fg:       #ffffff;
  --b-250-bg:       #e03830; --b-250-fg:       #ffffff;
  --b-over-250-bg:  #ff6a5a; --b-over-250-fg:  #15110a;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--fg);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-underline-offset: 3px; }

/* ---------- Legal/static pages ---------- */
.legal-page {
  display: block;
  min-height: 100%;
}
.legal-main {
  width: min(920px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 56px;
}
.legal-main h1,
.legal-main h2,
.legal-main h3 {
  color: var(--fg);
  line-height: 1.2;
}
.legal-main h1 {
  margin: 0 0 8px;
  font-family: var(--font-head);
  font-size: 32px;
  font-weight: 600;
}
.legal-main h2 {
  margin: 32px 0 10px;
  font-size: 20px;
}
.legal-main h3 {
  margin: 22px 0 8px;
  font-size: 16px;
}
.legal-main p,
.legal-main li {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.62;
}
.legal-main ul {
  padding-left: 22px;
}
.legal-main table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0 24px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.legal-main th,
.legal-main td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.legal-main th {
  width: 28%;
  color: var(--fg);
  font-weight: 600;
  background: var(--surface-alt);
}
.legal-note {
  border: 1px solid var(--notice-border);
  background: var(--notice-bg);
  color: var(--notice-fg);
  padding: 14px 16px;
  border-radius: var(--radius);
}
.legal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.legal-nav a {
  color: var(--muted);
  text-decoration: none;
}
.legal-nav a:hover {
  color: var(--fg);
}

/* ---------- Header ---------- */
.site-header {
  padding: 20px 28px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 14px;
}
.header-title { flex: 1; min-width: 0; }
.site-header h1 {
  margin: 0;
  font-family: var(--font-head);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.1;
  color: var(--fg);
}
.tagline {
  margin: 10px 0 0;
  max-width: 760px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
}
.tagline a { text-decoration: underline; }

/* Header controls (lang + theme toggle) */
.header-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
  flex-shrink: 0;
}
.controls-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.theme-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0;
}
.theme-btn:hover { color: var(--fg); }
.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 12px;
  background: var(--surface);
}
.lang-btn {
  padding: 5px 12px;
  background: transparent;
  color: var(--muted);
  border: none;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.04em;
  font-family: inherit;
}
.lang-btn.active { background: var(--fg); color: var(--bg); }

/* Footer last-updated chip */
.footer-updated #meta-updated { color: var(--fg); }

/* Footer nav strip */
.footer-nav {
  display: flex;
  gap: 22px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.footer-nav a { color: var(--muted); text-decoration: none; }
.footer-nav a:hover { color: var(--fg); }

/* ---------- Notice banner ---------- */
.notice {
  position: relative;
  background: var(--notice-bg);
  color: var(--notice-fg);
  border-top: 1px solid var(--notice-border);
  border-bottom: 1px solid var(--notice-border);
  padding: 14px 56px 14px 28px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.notice[hidden] {
  display: none !important;
}
.notice-badge {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 1px;
}
.notice-badge-glyph {
  font-family: "Apple Chancery", "Segoe Script", "Brush Script MT", cursive;
  font-weight: 400;
  font-size: 17px;
  font-style: italic;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1;
  padding: 0;
  transform: translateX(-1.5px);
}
.notice-body { font-size: 13px; line-height: 1.5; max-width: 980px; }
.notice-body strong {
  font-weight: 700;
  margin-right: 6px;
}
.notice-close {
  position: absolute;
  top: 10px;
  right: 18px;
  width: 26px;
  height: 26px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--notice-fg);
  cursor: pointer;
  font-family: inherit;
  font-size: 20px;
  line-height: 1;
  opacity: 0.72;
}
.notice-close:hover,
.notice-close:focus-visible {
  border-color: var(--notice-border);
  opacity: 1;
  outline: none;
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  flex-wrap: wrap;
}
.tab {
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
}
.tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
#filter {
  flex: 1;
  max-width: 360px;
  min-width: 200px;
  padding: 7px 12px;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  outline: none;
}
#filter:focus { border-color: var(--accent); }
/* ---------- Category multi-select dropdown ---------- */
.cat-dropdown {
  position: relative;
  display: flex;
  align-items: center;
  gap: 3px;
}
.cat-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px 7px 12px;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  max-width: 200px;
  overflow: hidden;
}
.cat-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cat-trigger[aria-expanded="true"],
.cat-trigger.active { border-color: var(--accent); }
.cat-trigger.active { background: var(--accent-soft); }
#cat-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.cat-caret {
  font-size: 10px;
  flex-shrink: 0;
  color: var(--muted);
  transition: transform .15s;
}
.cat-trigger[aria-expanded="true"] .cat-caret { transform: rotate(180deg); }
.cat-clear {
  padding: 5px 7px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.cat-clear:hover { color: var(--fg); border-color: var(--accent); }
.cat-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  width: 240px;
  max-height: 300px;
}
.cat-panel:not([hidden]) {
  display: flex;
  flex-direction: column;
}
.cat-search {
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
  font-family: inherit;
  font-size: 13px;
  background: transparent;
  color: var(--fg);
  outline: none;
  flex-shrink: 0;
  border-radius: var(--radius) var(--radius) 0 0;
}
.cat-options {
  overflow-y: auto;
  flex: 1;
}
.cat-option {
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--fg);
}
.cat-option:not([hidden]) { display: flex; }
.cat-option:hover { background: var(--bg); }
.cat-option input[type="checkbox"] {
  accent-color: var(--accent);
  flex-shrink: 0;
  margin: 0;
}
.toolbar-meta {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-family: var(--font-mono);
}

/* ---------- City selector ---------- */
.city-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px 0 10px;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
}
.city-select-wrap:focus-within { border-color: var(--accent); }
.city-select-icon { font-size: 12px; line-height: 1; opacity: 0.75; }
.city-select-caret {
  font-size: 10px;
  color: var(--muted);
  pointer-events: none;
}
.city-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background: transparent;
  color: var(--fg);
  border: none;
  padding: 7px 0;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}
.city-select option:disabled { color: var(--muted); font-style: italic; }
.city-toast {
  position: absolute;
  top: calc(100% + 6px);
  left: 24px;
  z-index: 300;
  background: var(--fg);
  color: var(--bg);
  padding: 7px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
}
.city-toast[hidden] { display: none; }

/* ---------- Main / views ---------- */
main { flex: 1; min-height: 0; position: relative; }
.view { display: none; height: 100%; }
.view.active { display: block; }

/* ---------- Table ---------- */
.table-wrap { height: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--surface); }
th {
  padding: 12px 14px;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
th.sorted { color: var(--fg); }
th.sorted::after { content: ' \2191'; color: var(--muted); }
th.sorted.desc::after { content: ' \2193'; color: var(--muted); }

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-size: 13px;
}
tr:hover td { background: var(--row-hover); }

td .place-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--fg);
}
td .place-name a { color: var(--fg); text-decoration: none; }
td .place-name a:hover { color: var(--accent); text-decoration: underline; }
td .place-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

/* Category chip */
.chip {
  display: inline-block;
  padding: 2px 8px;
  background: var(--chip-bg);
  color: var(--chip-fg);
  font-size: 11px;
  border-radius: var(--radius);
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* Stars / rating cell */
.rating {
  font-family: var(--font-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.rating .star { color: var(--muted); margin-left: 4px; }
.dim { color: var(--muted); }

/* Mono number cell */
.mono-num {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Sparkline (mini distribution) ---------- */
.spark {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 22px;
  width: 70px;
}
.spark .bar {
  width: 10px;
  opacity: 0.85;
  min-height: 2px;
}
.spark .bar.good { background: var(--hist-good); }
.spark .bar.mid  { background: var(--hist-mid); }
.spark .bar.bad  { background: var(--hist-bad); }

/* ---------- Bucket pill ---------- */
.pill {
  display: inline-block;
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: var(--radius);
  min-width: 56px;
  text-align: center;
}
.pill.bucket-none { background: var(--b-none-bg); color: var(--b-none-fg); }
.pill.bucket-1    { background: var(--b-1-bg);    color: var(--b-1-fg); }
.pill.bucket-5    { background: var(--b-5-bg);    color: var(--b-5-fg); }
.pill.bucket-10   { background: var(--b-10-bg);   color: var(--b-10-fg); }
.pill.bucket-20   { background: var(--b-20-bg);   color: var(--b-20-fg); }
.pill.bucket-50   { background: var(--b-50-bg);   color: var(--b-50-fg); }
.pill.bucket-100  { background: var(--b-100-bg);  color: var(--b-100-fg); }
.pill.bucket-150  { background: var(--b-150-bg);  color: var(--b-150-fg); }
.pill.bucket-200  { background: var(--b-200-bg);  color: var(--b-200-fg); }
.pill.bucket-250  { background: var(--b-250-bg);  color: var(--b-250-fg); }
.pill.bucket-over-250 { background: var(--b-over-250-bg); color: var(--b-over-250-fg); }

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--muted);
}
.page-size {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.page-size select {
  padding: 4px 22px 4px 8px;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 8px center, right 4px center;
  background-size: 4px 4px;
  background-repeat: no-repeat;
}
.page-info {
  margin-left: auto;
  letter-spacing: 0.04em;
}
.page-info b { color: var(--fg); font-weight: 600; }
.page-nav { display: inline-flex; gap: 4px; }
.page-btn {
  padding: 3px 10px;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  line-height: 1;
}
.page-btn:hover:not(:disabled) { background: var(--row-hover); }
.page-btn:disabled { color: var(--muted); cursor: not-allowed; opacity: 0.6; }

/* Make the table-wrap fit between pagination and view bottom */
#view-table { display: none; flex-direction: column; }
#view-table.active { display: flex; }
#view-table .table-wrap { flex: 1; min-height: 0; }

/* ---------- Map view: sidebar + map ---------- */
#view-map { flex-direction: row; }
#view-map.active { display: flex; }

/* Left sidebar */
.map-sidebar {
  width: var(--map-side-pane-width);
  min-width: var(--map-side-pane-width);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}
.sidebar-header {
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-count {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Sidebar list */
.sidebar-list {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sidebar-list.virtualized {
  position: relative;
}
.sidebar-list-virtual-inner {
  position: relative;
  min-height: 100%;
}
.map-sidebar.stats-open .sidebar-list {
  flex: 1 1 50%;
  min-height: 0;
  border-bottom: 1px solid var(--border);
}
.sidebar-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.sidebar-list.virtualized .sidebar-item {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  box-sizing: border-box;
}
.sidebar-item:hover { background: var(--row-hover); }
.sidebar-item.active { background: var(--accent-soft); }
.sidebar-item-body { flex: 1; min-width: 0; }
.sidebar-item-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-item-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-item .pill { flex-shrink: 0; font-size: 11px; padding: 3px 8px; min-width: 0; }

.sidebar-stats[hidden] {
  display: none !important;
}
.sidebar-stats {
  flex: 1 1 50%;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
}
.sidebar-stats-title {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Sidebar detail panel */
.sidebar-detail[hidden] {
  display: none !important;
}
.sidebar-detail {
  width: var(--map-side-pane-width);
  min-width: var(--map-side-pane-width);
  max-width: var(--map-side-pane-width);
  flex: 0 0 var(--map-side-pane-width);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--surface);
}
.detail-back {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  text-align: left;
  width: 100%;
}
.detail-back:hover { color: var(--fg); background: var(--row-hover); }
.detail-hero {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.detail-category {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.detail-name {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.15;
  color: var(--fg);
  margin: 0 0 6px;
}
.detail-address {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 14px;
}
.detail-maps-link {
  font-size: 13px;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.detail-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.detail-section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.detail-rating {
  font-size: 20px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}
.detail-rating .star { color: var(--muted); font-size: 16px; margin: 0 6px; }
.detail-review-count { font-size: 13px; color: var(--muted); }
.detail-hist {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 44px;
}
.detail-hist .bar {
  flex: 1;
  min-height: 3px;
  border-radius: 2px 2px 0 0;
  opacity: 0.85;
}
.detail-hist .bar.good { background: var(--hist-good); }
.detail-hist .bar.mid  { background: var(--hist-mid); }
.detail-hist .bar.bad  { background: var(--hist-bad); }
.detail-hist-labels {
  display: flex;
  gap: 4px;
  margin-top: 5px;
}
.detail-hist-labels span {
  flex: 1;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--muted);
}
.detail-footer {
  padding: 16px 20px;
  margin-top: auto;
}
.detail-report-link {
  font-size: 12px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-style: dotted;
}

/* Right map area */
.map-area {
  flex: 1;
  min-width: 0;
  position: relative;
}
#map { width: 100%; height: 100%; }
.legend {
  position: absolute;
  bottom: 14px;
  left: 14px;
  background: rgba(255,255,255,0.96);
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  max-width: calc(100% - 28px);
}
.legend .legend-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 4px;
}
.legend .pill { min-width: 0; padding: 2px 7px; font-size: 11px; }

/* Polygon label badge (centroid of Bezirk / Ortsteil) */
.poly-label {
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 8px;
  font-family: var(--font-body);
  font-size: 11px;
  line-height: 1.2;
  color: var(--fg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  pointer-events: none;
  text-align: center;
  white-space: nowrap;
  transform: translate(-50%, -50%);
}
.poly-label .poly-name {
  font-weight: 600;
  display: block;
  letter-spacing: 0.01em;
}
.poly-label .poly-stat {
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 10px;
}
[data-theme="dark"] .poly-label {
  background: rgba(28,26,23,0.94);
  color: var(--fg);
}

/* Supercluster bubble marker (fallback when no GeoJSON) */
.cluster-bubble {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.15), 0 2px 6px rgba(0,0,0,0.18);
  cursor: pointer;
}
[data-theme="dark"] .cluster-bubble {
  border-color: #2a2820;
}

/* Sidebar polygon row (low-zoom listing) */
.sidebar-poly {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.sidebar-poly:hover { background: var(--row-hover); }
.sidebar-poly-name {
  font-family: var(--font-head);
  font-weight: 500;
  font-size: 15px;
}
.sidebar-poly-sub {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  margin-top: 2px;
}
.sidebar-poly-bar {
  flex: 0 0 60px;
  height: 6px;
  background: var(--surface-alt);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.sidebar-poly-bar::after {
  content: "";
  position: absolute; top: 0; left: 0; bottom: 0;
  background: var(--accent);
  width: var(--bar, 0%);
}

/* Zoom hint banner over map */
.zoom-hint {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.96);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  pointer-events: none;
  z-index: 1;
}
[data-theme="dark"] .zoom-hint {
  background: rgba(28,26,23,0.94);
}

/* ---------- Footer ---------- */
footer {
  padding: 10px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
}
footer > .footer-nav { margin-right: auto; }
footer > .ver { margin-left: auto; }
footer a { color: var(--muted); text-decoration: none; }
footer a:hover { color: var(--fg); }
.footer-nav a { text-decoration: none; }

/* ---------- Map marker tooltip ---------- */
.marker-tooltip {
  position: absolute;
  z-index: 10;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 10px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.14);
  max-width: 200px;
  line-height: 1.3;
}
.marker-tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  transform: translateX(-50%) rotate(45deg);
  width: 8px;
  height: 8px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.marker-tooltip-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--fg);
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.marker-tooltip-rating {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.marker-tooltip-rating .star { margin-left: 2px; }
.marker-tooltip .pill { font-size: 11px; padding: 2px 7px; min-width: 0; }

/* ---------- Dark mode overrides ---------- */
[data-theme="dark"] .legend {
  background: rgba(28, 26, 23, 0.96);
}
[data-theme="dark"] .maplibregl-popup-content {
  background: var(--surface);
  color: var(--fg);
}
[data-theme="dark"] .maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--surface); }
[data-theme="dark"] .maplibregl-popup-anchor-top    .maplibregl-popup-tip { border-bottom-color: var(--surface); }
[data-theme="dark"] .maplibregl-popup-anchor-left   .maplibregl-popup-tip { border-right-color: var(--surface); }
[data-theme="dark"] .maplibregl-popup-anchor-right  .maplibregl-popup-tip { border-left-color: var(--surface); }
[data-theme="dark"] .maplibregl-popup-close-button  { color: var(--muted); }

@media (max-width: 720px) {
  html,
  body {
    height: auto;
    min-height: 100%;
  }

  .site-header { padding: 20px 24px 14px; }
  .header-row { gap: 14px; }
  .site-header h1 { font-size: 27px; }
  .notice { padding: 14px 24px; }

  .toolbar {
    padding: 12px 24px;
    align-items: stretch;
  }
  #filter {
    order: 2;
    flex-basis: 100%;
    max-width: none;
    min-width: 0;
  }
  .cat-dropdown {
    order: 3;
    max-width: 100%;
  }
  .cat-trigger { max-width: 180px; }
  .toolbar-meta {
    order: 4;
    width: 100%;
    margin-left: 0;
  }

  main {
    flex: 0 0 auto;
    min-height: 800px;
  }

  .table-wrap {
    overflow-x: hidden;
  }

  table {
    table-layout: fixed;
  }

  #places-table th,
  #places-table td {
    padding: 10px 6px;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  #places-table th {
    font-size: 9px;
    line-height: 1.25;
    letter-spacing: 0;
    vertical-align: bottom;
  }

  #places-table th:nth-child(1),
  #places-table td:nth-child(1) { width: 29%; }
  #places-table th:nth-child(2),
  #places-table td:nth-child(2) { width: 20%; }
  #places-table th:nth-child(3),
  #places-table td:nth-child(3) { width: 15%; }
  #places-table th:nth-child(4),
  #places-table td:nth-child(4) { width: 18%; }
  #places-table th:nth-child(5),
  #places-table td:nth-child(5) { display: none; }
  #places-table th:nth-child(6),
  #places-table td:nth-child(6) { width: 18%; }

  #places-table th.sorted::after,
  #places-table th.sorted.desc::after {
    display: block;
    content: "\2191";
    line-height: 1;
  }
  #places-table th.sorted.desc::after { content: "\2193"; }

  td .place-name {
    font-size: 13px;
    line-height: 1.3;
  }

  td .place-sub {
    font-size: 10.5px;
    line-height: 1.35;
  }

  .chip {
    white-space: normal;
    padding: 2px 6px;
    line-height: 1.25;
  }

  .rating,
  .mono-num {
    font-size: 11px;
  }

  .rating .star {
    margin-left: 2px;
  }

  .pill {
    min-width: 0;
    padding: 4px 6px;
    font-size: 11px;
  }

  #view-map.active {
    flex-direction: column;
    min-height: 800px;
  }
  .map-sidebar {
    width: 100%;
    min-width: 0;
    max-height: 220px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .map-sidebar.stats-open {
    max-height: 360px;
  }
  .map-area {
    flex: 1 0 560px;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 560px;
  }
  #map {
    flex: 1 0 420px;
    height: auto;
    min-height: 420px;
  }
  .legend {
    position: static;
    max-width: none;
    gap: 5px;
    align-items: flex-start;
    border-left: none;
    border-right: none;
    border-bottom: none;
    border-radius: 0;
    box-shadow: none;
  }
  .legend .legend-title {
    flex-basis: 100%;
    margin-right: 0;
  }
  .legend .pill {
    min-width: 42px;
    white-space: nowrap;
  }
}

@media (max-width: 959px) and (min-width: 721px) {
  #view-map.detail-open .map-sidebar {
    display: none;
  }

  #view-map.detail-open .sidebar-detail {
    order: -1;
    border-left: none;
    border-right: 1px solid var(--border);
  }
}

@media (max-width: 720px) {
  .map-sidebar {
    order: 1;
  }
  .map-sidebar.stats-open .sidebar-list {
    flex-basis: 50%;
  }

  .sidebar-detail {
    order: 2;
    width: 100%;
    min-width: 0;
    max-width: none;
    flex: 0 0 auto;
    max-height: none;
    border-left: none;
    border-bottom: 1px solid var(--border);
  }

  .map-area {
    order: 3;
  }
}
