:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f0ede6;
  --text: #1f2326;
  --muted: #646a6f;
  --line: #dedad1;
  --accent: #2f6f73;
  --accent-soft: #dcebea;
  --warn: #9a5b13;
  --warn-soft: #f6e8d4;
  --good: #2f6b3a;
  --good-soft: #dfeedd;
  --bad: #9b2d2d;
  --star: #c98a12;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 2px 8px rgba(0, 0, 0, .04);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15181a;
    --surface: #1d2124;
    --surface-2: #262b2e;
    --text: #e6e4df;
    --muted: #9aa0a4;
    --line: #333a3e;
    --accent: #6fb5b8;
    --accent-soft: #23393b;
    --warn: #e2a85a;
    --warn-soft: #3a2d1c;
    --good: #84c08f;
    --good-soft: #213224;
    --bad: #e08484;
    --star: #e8b33f;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  max-width: 1320px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs a {
  padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--muted);
  white-space: nowrap;
}
.tabs a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.count:empty { display: none; }
.count {
  display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--star); color: #fff; font-size: 12px; text-align: center;
}
.citizen { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.citizen button {
  border: 0; background: transparent; padding: 5px 12px; cursor: pointer; color: var(--muted);
}
.citizen button.on { background: var(--accent); color: #fff; }

/* Layout */
main { max-width: 1320px; margin: 0 auto; padding: 16px; }
.layout { display: grid; grid-template-columns: 290px 1fr; gap: 20px; align-items: start; }
.filters {
  position: sticky; top: 70px; max-height: calc(100vh - 86px); overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px;
}
.filters-head { display: flex; gap: 6px; margin-bottom: 8px; }
.filters-head input {
  flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg);
}
.ghost {
  border: 1px solid var(--line); background: transparent; border-radius: 8px;
  padding: 6px 10px; cursor: pointer; color: var(--muted);
}
.ghost:hover { color: var(--text); }
.facet { border-top: 1px solid var(--line); padding: 8px 0; }
.facet > summary {
  cursor: pointer; font-weight: 600; font-size: 13px; text-transform: uppercase;
  letter-spacing: .03em; color: var(--muted); list-style: none; display: flex; justify-content: space-between;
}
.facet > summary::-webkit-details-marker { display: none; }
.facet > summary::after { content: "▾"; }
.facet:not([open]) > summary::after { content: "▸"; }
.facet .opts { margin-top: 6px; display: grid; gap: 2px; }
.facet label.opt {
  display: flex; align-items: center; gap: 8px; padding: 2px 4px; border-radius: 6px; cursor: pointer;
  font-size: 14px;
}
.facet label.opt:hover { background: var(--surface-2); }
.facet label.opt .n { margin-left: auto; color: var(--muted); font-size: 12px; }
.facet label.opt.zero { opacity: .45; }
.facet .range { display: grid; gap: 6px; margin-top: 6px; font-size: 14px; }
.facet .range input[type=range] { width: 100%; accent-color: var(--accent); }
.facet select { width: 100%; padding: 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); }

.results-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
#result-count { color: var(--muted); }
.sort { margin-left: auto; color: var(--muted); font-size: 14px; display: flex; gap: 6px; align-items: center; }
.sort select { padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
.filters-toggle { display: none; }
.active-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.active-chips button {
  border: 1px solid var(--accent); background: var(--accent-soft); color: var(--accent);
  border-radius: 14px; padding: 2px 10px; cursor: pointer; font-size: 13px;
}

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
.card {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 14px 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px;
  cursor: pointer; text-decoration: none; color: inherit;
}
.card:hover { border-color: var(--accent); }
.card h3 { margin: 0; font-size: 16px; line-height: 1.3; padding-right: 30px; }
.card .loc { color: var(--muted); font-size: 13px; }
.card .summary {
  font-size: 13.5px; color: var(--text); margin: 0;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card .facts { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12.5px; }
.card .bottom { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 12px;
  background: var(--surface-2); color: var(--text); font-size: 12.5px; white-space: nowrap;
}
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.good { background: var(--good-soft); color: var(--good); }
.tag.kind { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.booth { font-variant-numeric: tabular-nums; }
.star {
  position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border: 0; background: transparent;
  font-size: 20px; line-height: 1; cursor: pointer; color: var(--line); padding: 0;
}
.star.on { color: var(--star); }
.conf-low { color: var(--warn); }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* Detail */
.detail { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.detail-main, .detail-side > div {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
}
.detail-side { display: grid; gap: 12px; position: sticky; top: 70px; }
.back { display: inline-block; margin-bottom: 10px; text-decoration: none; }
.detail h1 { margin: 0 0 4px; font-size: 24px; line-height: 1.25; display: flex; gap: 10px; align-items: start; }
.detail h1 .star { position: static; flex: none; }
.detail .sub { color: var(--muted); margin-bottom: 12px; }
.detail h2 { font-size: 15px; margin: 22px 0 8px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.detail p { margin: 0 0 8px; }
.detail ul { margin: 0; padding-left: 20px; }
.detail li { margin: 3px 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pros li::marker { content: "+  "; color: var(--good); font-weight: 700; }
.cons li::marker { content: "!  "; color: var(--warn); font-weight: 700; }
table.prog { width: 100%; border-collapse: collapse; font-size: 14px; }
table.prog th, table.prog td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.prog th { color: var(--muted); font-weight: 600; font-size: 12.5px; }
table.prog td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.sources { font-size: 13px; word-break: break-all; }
.big-fee { font-size: 22px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Fair */
.floor { margin-bottom: 26px; }
.floor h2 { margin: 0 0 10px; font-size: 20px; }
.rooms { align-items: start; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.room { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.room h3 { margin: 0 0 6px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.room ul { list-style: none; margin: 0; padding: 0; }
.room li { display: flex; gap: 8px; padding: 3px 0; align-items: baseline; }
.room li .no { min-width: 26px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.room li a { text-decoration: none; color: var(--text); }
.room li a:hover { color: var(--accent); }
.room li .meta { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }

/* Compare */
.compare-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table.cmp { border-collapse: collapse; min-width: 100%; font-size: 14px; }
table.cmp th, table.cmp td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
table.cmp th[scope=row] { color: var(--muted); font-weight: 600; white-space: nowrap; position: sticky; left: 0; background: var(--surface); }
table.cmp td { min-width: 220px; }
table.cmp thead th { font-size: 15px; }

.foot { max-width: 1320px; margin: 0 auto; padding: 16px; color: var(--muted); font-size: 13px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .filters { position: static; max-height: none; display: none; }
  .filters.open { display: block; }
  .filters-toggle { display: inline-block; }
  .detail { grid-template-columns: 1fr; }
  .detail-side { position: static; }
  .two { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
  .tabs { order: 3; flex-basis: 100%; overflow-x: auto; }
}
