:root {
  --bg: #0b0f1a;
  --bg-2: #10162a;
  --panel: #131a2e;
  --panel-2: #1a2340;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #eef2ff;
  --text-strong: #ffffff;
  --muted: #94a3c4;
  --accent: #6ee7b7;
  --accent-2: #7dd3fc;
  --accent-3: #c4b5fd;
  --danger: #fca5a5;
  --success: #86efac;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-display: "Iowan Old Style", "Palatino", Georgia, ui-serif, serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f7fb;
    --bg-2: #ffffff;
    --panel: #ffffff;
    --panel-2: #f5f7fb;
    --border: rgba(15, 23, 42, 0.08);
    --border-strong: rgba(15, 23, 42, 0.14);
    --text: #1e293b;
    --text-strong: #0f172a;
    --muted: #64748b;
    --accent: #059669;
    --accent-2: #0284c7;
    --accent-3: #7c3aed;
    --danger: #dc2626;
    --success: #059669;
    --shadow: 0 8px 32px rgba(15, 23, 42, 0.08);
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(1200px 500px at 15% -10%, rgba(110, 231, 183, 0.06), transparent 50%),
    radial-gradient(1000px 400px at 90% -10%, rgba(125, 211, 252, 0.05), transparent 55%),
    var(--bg);
  background-attachment: fixed;
}

.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 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  gap: 20px;
  align-items: center;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-strong);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}
.brand .logo { color: var(--accent); }
.brand .tld { color: var(--accent); font-weight: 500; }

.search {
  flex: 1;
  display: flex;
  gap: 8px;
  position: relative;
}

.search-input-wrap {
  flex: 1;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.search input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text-strong);
  font-size: 15px;
  font-family: inherit;
  border-radius: 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 25%, transparent);
}

.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { display: none; }

.search button {
  padding: 12px 20px;
  border: none;
  background: var(--accent);
  color: #05261c;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  transition: transform 0.1s ease, opacity 0.15s;
  white-space: nowrap;
}
@media (prefers-color-scheme: light) {
  .search button { color: white; }
}
.search button:hover { transform: translateY(-1px); }
.search button:active { transform: translateY(0); }
.search button:disabled { opacity: 0.5; cursor: wait; }

/* ---------- suggestions ---------- */

.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  margin: 0;
  list-style: none;
  z-index: 60;
  max-height: 320px;
  overflow-y: auto;
}

.suggestions li {
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.suggestions li:hover,
.suggestions li[aria-selected="true"] {
  background: var(--panel-2);
  color: var(--text-strong);
}

.suggestions li .pin {
  color: var(--muted);
  flex-shrink: 0;
}

/* ---------- main ---------- */

main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* ---------- welcome ---------- */

.welcome {
  padding: 60px 24px 40px;
  text-align: center;
}
.welcome-inner {
  max-width: 720px;
  margin: 0 auto;
}
.welcome h1 {
  font-family: var(--font-display);
  font-size: clamp(32px, 5vw, 52px);
  margin: 0 0 12px;
  letter-spacing: -0.02em;
  font-weight: 700;
  color: var(--text-strong);
}
.welcome p {
  font-size: 17px;
  color: var(--muted);
  margin: 0 0 28px;
}
.chips {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.chip {
  padding: 8px 14px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s;
}
.chip:hover { background: var(--panel-2); transform: translateY(-1px); }

/* ---------- hero ---------- */

.hero {
  padding: 32px 4px 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.eyebrow {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0 0 8px;
}

.hero-address {
  font-family: var(--font-display);
  font-size: clamp(28px, 4.5vw, 44px);
  font-weight: 700;
  color: var(--text-strong);
  margin: 0 0 6px;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.hero-sub {
  color: var(--muted);
  font-size: 16px;
  margin: 0 0 16px;
}

.hero-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}
.badge.accent { color: var(--accent); border-color: color-mix(in oklab, var(--accent) 35%, transparent); }
.badge.accent-2 { color: var(--accent-2); border-color: color-mix(in oklab, var(--accent-2) 35%, transparent); }
.badge.accent-3 { color: var(--accent-3); border-color: color-mix(in oklab, var(--accent-3) 35%, transparent); }
.badge .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}

.hero-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-link {
  padding: 8px 14px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
}
.btn-link:hover { background: var(--panel-2); }

/* ---------- media row (photo + map) ---------- */

.media-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 900px) {
  .media-row { grid-template-columns: 1fr; }
}

/* ---------- cards ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.card h2 {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 12px;
}

.pill {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  padding: 3px 8px;
  background: var(--panel-2);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.media-card {
  padding: 16px;
  overflow: hidden;
}
.media-card .card-head { padding: 4px 6px 0; }
.media-body {
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  background: var(--panel-2);
  border: 1px solid var(--border);
  position: relative;
}
.media-body img,
.media-body iframe,
#map {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.media-body img { object-fit: cover; }
#map { background: var(--panel-2); }

.media-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  font-size: 14px;
  padding: 24px;
  text-align: center;
  flex-direction: column;
  gap: 8px;
}
.media-empty code {
  font-family: var(--mono);
  font-size: 12px;
  padding: 2px 6px;
  background: var(--panel);
  border-radius: 4px;
  border: 1px solid var(--border);
}

.dir-picker {
  display: inline-flex;
  gap: 2px;
  background: var(--panel-2);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.dir-picker button {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.dir-picker button:hover { color: var(--text); }
.dir-picker button[aria-pressed="true"] {
  background: var(--panel);
  color: var(--text-strong);
  box-shadow: var(--shadow-sm);
}

/* ---------- stat row ---------- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 0 0 8px;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 700;
  color: var(--text-strong);
  line-height: 1;
  letter-spacing: -0.02em;
}
.stat-unit {
  font-size: 15px;
  color: var(--muted);
  font-weight: 500;
  margin-left: 4px;
  font-family: var(--font);
}
.stat-sub {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0 0;
}

/* ---------- detail grid ---------- */

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kv {
  display: grid;
  grid-template-columns: 40% 60%;
  gap: 8px 12px;
  font-size: 14px;
  margin: 0;
}
.kv dt {
  color: var(--muted);
  font-size: 13px;
}
.kv dd {
  margin: 0;
  color: var(--text-strong);
}
.kv .code {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  padding: 1px 5px;
  background: var(--panel-2);
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: 1px;
}

.empty {
  color: var(--muted);
  font-style: italic;
  font-size: 14px;
  padding: 8px 0;
}

.big-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-strong);
  margin: 0 0 4px;
  line-height: 1.2;
}
.big-sub {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 12px;
}

/* ---------- raw ---------- */

.raw {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 20px;
  margin-top: 8px;
}
.raw summary {
  cursor: pointer;
  padding: 12px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  list-style: none;
  user-select: none;
}
.raw summary::-webkit-details-marker { display: none; }
.raw summary::before {
  content: "▸";
  margin-right: 8px;
  display: inline-block;
  transition: transform 0.15s;
}
.raw[open] summary::before { transform: rotate(90deg); }
.raw pre {
  margin: 0 0 12px;
  padding: 16px;
  background: var(--bg);
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 11px;
  overflow-x: auto;
  max-height: 500px;
  overflow-y: auto;
  border: 1px solid var(--border);
  color: var(--muted);
}

/* ---------- status ---------- */

.status {
  margin: 24px auto;
  max-width: 720px;
  padding: 14px 20px;
  border-radius: 12px;
  font-size: 14px;
  text-align: center;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
}
.status.error {
  background: color-mix(in oklab, var(--danger) 8%, var(--panel));
  border-color: color-mix(in oklab, var(--danger) 35%, transparent);
  color: var(--danger);
}
.status.loading::before {
  content: "";
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
  vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- footer ---------- */

footer {
  padding: 32px 24px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  border-top: 1px solid var(--border);
}
footer a { color: var(--muted); text-decoration: underline; text-decoration-color: var(--border-strong); }
footer a:hover { color: var(--text); }

/* Leaflet dark tweaks */
@media (prefers-color-scheme: dark) {
  .leaflet-container {
    background: var(--panel-2);
  }
  .leaflet-tile {
    filter: brightness(0.7) invert(1) contrast(0.92) hue-rotate(200deg) saturate(0.5) brightness(0.8);
  }
  .leaflet-control-attribution {
    background: rgba(0,0,0,0.6) !important;
    color: var(--muted) !important;
  }
  .leaflet-control-attribution a { color: var(--accent-2) !important; }
}

/* ---------- responsive ---------- */

@media (max-width: 700px) {
  .topbar-inner { padding: 10px 16px; }
  .brand span { display: none; }
  .search input { font-size: 14px; padding-left: 40px; }
  main { padding: 20px 16px 60px; }
  .hero { padding: 20px 4px; }
  .stat-value { font-size: 28px; }
}
