:root {
  --panel: #f7f4ef;
  --ink: #1c1917;
  --muted: #57534e;
  --line: #d6d3d1;
  --accent: #1d4ed8;
  --live: #e85d04;
  --planned: #7b2cbf;
  --tree: #2d6a4f;
  --shadow: 0 8px 24px rgba(28, 25, 23, 0.12);
  font-family: ui-sans-serif, system-ui, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  background: #e7e5e4;
  color: var(--ink);
  overflow-x: hidden;
}
body {
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  min-height: 100%;
  width: 100%;
  max-width: 100%;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1rem;
  background: #1c1917;
  color: #fafaf9;
  z-index: 2;
  min-width: 0;
  max-width: 100%;
}
.brand h1 { margin: 0; font-size: 1.15rem; font-weight: 650; letter-spacing: 0.01em; }
.tagline { margin: 0.15rem 0 0; font-size: 0.8rem; color: #d6d3d1; }
.btn {
  appearance: none;
  border: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.55rem 0.9rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.top-actions { display: flex; gap: 0.45rem; flex-wrap: wrap; justify-content: flex-end; }
#btn-layers { display: none; }
.btn:hover { filter: brightness(1.08); }
.btn-ghost {
  background: transparent;
  color: #fafaf9;
  border: 1px solid #a8a29e;
}
.btn-ghost.active, .btn-ghost:hover { background: #292524; }

.catbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.45rem 0.75rem;
  background: #292524;
  z-index: 3;
  overflow-x: hidden;
  min-width: 0;
  max-width: 100%;
}
.cat {
  appearance: none;
  border: 0;
  background: #1c1917;
  color: #fafaf9;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  cursor: pointer;
  flex: 1;
  min-width: 0;
  font-family: inherit;
}
.cat:hover { filter: brightness(1.12); }
.cat.active { background: #1d4ed8; }
.cat[data-cat="today"] { box-shadow: inset 0 -2px #fbbf24; }
.cat[data-cat="harbour"] { box-shadow: inset 3px 0 0 #1e3a5f; }

.newsbar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: #292524;
  color: #fafaf9;
  font-size: 0.82rem;
  padding: 0.4rem 0.75rem;
  z-index: 3;
  min-height: 2.7rem;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}
.ticker-label {
  flex-shrink: 0;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.68rem;
  color: #fbbf24;
}
.newsbar-scroll {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  overflow-y: hidden;
  flex: 1;
  min-width: 0;
  scrollbar-width: thin;
  padding-bottom: 0.1rem;
}
.news-card {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  margin: 0;
  text-align: left;
  font: inherit;
  font-size: 0.78rem;
  color: inherit;
  cursor: pointer;
  flex: 0 0 auto;
  background: #44403c;
  border-radius: 8px;
  padding: 0.35rem 0.65rem;
  max-width: 17rem;
  white-space: normal;
  line-height: 1.3;
}
.news-card:hover {
  background: #57534e;
}
.news-card:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}
.news-card strong {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #fbbf24;
  margin-bottom: 0.12rem;
}
.ticker-when { color: #d6d3d1; font-size: 0.72rem; }

.stage {
  position: relative;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.panel {
  position: absolute;
  top: 0.75rem;
  bottom: 0.75rem;
  max-height: none;
  overflow: auto;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.panel-left { left: 0.75rem; width: min(22rem, calc(50vw - 1.2rem)); }
.panel-right { right: 0.75rem; width: min(24rem, calc(50vw - 1.2rem)); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.85rem 0.95rem;
  box-shadow: var(--shadow);
}
.card h2 {
  margin: 0 0 0.55rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  margin: 0.22rem 0;
  cursor: pointer;
}
.toggle input { width: 1.05rem; height: 1.05rem; accent-color: var(--tree); }
.hint, .placeholder { color: var(--muted); font-size: 0.82rem; line-height: 1.4; margin: 0.55rem 0 0; }
.legend ul { list-style: none; margin: 0; padding: 0; font-size: 0.85rem; }
.legend li { display: flex; align-items: center; gap: 0.5rem; margin: 0.28rem 0; }
.swatch { width: 0.9rem; height: 0.9rem; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.swatch.dash { background-image: repeating-linear-gradient(90deg, currentColor 0 6px, transparent 6px 10px); }
.swatch.outline { background: rgba(29, 78, 216, 0.15); border: 2px solid #1d4ed8; }

.search-wrap { display: block; }
.search-wrap input {
  width: 100%;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  margin: 0.35rem 0 0.2rem;
  background: #fff;
  color: var(--ink);
}

#object-list { margin-top: 0.4rem; }
.obj-group { margin: 0.85rem 0 0; }
.obj-group h3 {
  margin: 0 0 0.35rem;
  font-size: 0.92rem;
  font-weight: 650;
}
.obj-group ul { list-style: none; margin: 0; padding: 0; }
.obj-row {
  display: block;
  width: 100%;
  text-align: left;
  appearance: none;
  border: 0;
  border-radius: 8px;
  background: #fff;
  padding: 0.5rem 0.6rem;
  margin: 0.28rem 0;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(28,25,23,0.06);
  font-family: inherit;
  color: inherit;
}
.obj-row:hover, .obj-row.active { outline: 2px solid var(--accent); }
.obj-row .name { display: block; font-weight: 650; font-size: 0.92rem; }
.obj-row .meta { display: block; font-size: 0.78rem; color: var(--muted); margin-top: 0.12rem; line-height: 1.35; }
.obj-empty { font-size: 0.82rem; color: var(--muted); margin: 0.3rem 0 0; }

.cat:focus-visible,
.btn:focus-visible,
.obj-row:focus-visible,
.news-card:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

#details dl { margin: 0; }
#details dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-top: 0.65rem; }
#details dd { margin: 0.1rem 0 0; font-size: 0.95rem; line-height: 1.35; }
#details h3 { margin: 0 0 0.2rem; font-size: 1.05rem; }
#details .badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 650;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  color: #fff;
  margin-bottom: 0.35rem;
}
.badge.live { background: var(--live); }
.badge.planned { background: var(--planned); }
.badge.tree { background: var(--tree); }
.badge.play { background: #0f766e; }
.badge.heat { background: #dc2f02; }
.badge.district { background: #44403c; }
.badge.housing { background: #6d28d9; }
.badge.listing { background: #db2777; }
.badge.school { background: #0369a1; }
.badge.market { background: #b45309; }
.badge.harbour { background: #1e3a5f; }
.badge.jobs { background: #0369a1; }
.badge.unemployed { background: #9a3412; }
.badge.sites { background: #d97706; }
.badge.universities { background: #7c3aed; }

.filters { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0 0 0.7rem; }
.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
}
.chip.active { background: #1c1917; color: #fafaf9; border-color: #1c1917; }

.footer {
  background: #1c1917;
  color: #d6d3d1;
  font-size: 0.72rem;
  line-height: 1.45;
  padding: 0.55rem 1rem;
  z-index: 2;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  overflow-wrap: anywhere;
}
.footer p { margin: 0.15rem 0; }
.footer code { color: #fafaf9; }

.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(28, 25, 23, 0.45);
  color: #fff;
  font-weight: 650;
  z-index: 5;
  pointer-events: none;
}
.loading.hidden { display: none; }

.maplibregl-ctrl-attrib { font-size: 10px; }
.maplibregl-ctrl-top-right { top: 0.6rem; right: 25.2rem; }
.maplibregl-ctrl-bottom-right { right: 25.2rem; }

.toggle[hidden], .legend li[hidden] { display: none; }

@media (min-width: 961px) {
  #details-card[hidden] {
    display: block;
  }
}

@media (max-width: 960px) {
  #btn-layers { display: inline-block; }
  .panel-left {
    display: none;
    left: 0.4rem;
    right: 0.4rem;
    width: auto;
    top: 0.4rem;
    bottom: auto;
    max-height: 58vh;
    z-index: 6;
  }
  .panel-left.is-open { display: flex; }
  .panel-right {
    top: auto;
    left: 0.4rem;
    right: 0.4rem;
    width: auto;
    bottom: 0.4rem;
    max-height: 22vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  #list-intro { display: none; }
  #list-title {
    font-size: 0.72rem;
    margin: 0 0 0.25rem;
    flex-shrink: 0;
  }
  .search-wrap { flex-shrink: 0; }
  .search-wrap input {
    padding: 0.28rem 0.5rem;
    margin: 0 0 0.25rem;
  }
  #list-card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0.45rem 0.55rem;
  }
  #object-list {
    flex: 1;
    min-height: 0;
    overflow: auto;
    margin-top: 0;
    -webkit-overflow-scrolling: touch;
  }
  #list-filters,
  .filters {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    flex-shrink: 0;
    gap: 0.22rem;
    margin: 0 0 0.2rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  #list-filters .chip,
  .filters .chip {
    flex: 0 0 auto;
    padding: 0.1rem 0.4rem;
    font-size: 0.68rem;
    white-space: nowrap;
  }
  #object-list .obj-group:first-of-type {
    margin-top: 0;
  }
  #details-card.is-empty,
  #details-card[hidden] {
    display: none;
  }
  #details-card:not([hidden]):not(.is-empty) {
    overflow: auto;
    min-height: 0;
    flex: 1 1 0;
  }
  .tagline { display: none; }
  .maplibregl-ctrl-top-right,
  .maplibregl-ctrl-bottom-right { right: 8px; top: 0.6rem; }
  .catbar {
    padding: 0.3rem 0.45rem;
    gap: 0.3rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .cat {
    flex: 0 0 auto;
    min-width: auto;
    white-space: nowrap;
    font-size: 0.82rem;
    padding: 0.45rem 0.4rem;
  }
}
