:root {
  --bg: #06080d;
  --glass: rgba(12, 15, 23, 0.84);
  --glass-solid: #0d1018;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #eef0f5;
  --muted: #949cad;
  --dim: #6b7384;
  --gold: #f2c66d;
  --gold-soft: rgba(242, 198, 109, 0.14);
  --radius: 18px;
  --panel-w: 380px;
  --detail-w: 400px;
  --gap: 12px;
  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(120% 90% at 60% 40%, #0e1526 0%, #070a12 55%, #04050a 100%);
  color: var(--text);
  font: 14px/1.45 var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

#stars, #map { position: fixed; inset: 0; width: 100%; height: 100%; }
#map { background: transparent; }
.maplibregl-canvas { outline: none; }

/* ---------- loader ---------- */
#loader {
  position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; gap: 14px;
  background: var(--bg); color: var(--muted); transition: opacity .5s ease, visibility .5s;
}
#loader.done { opacity: 0; visibility: hidden; }
.loader-mark {
  width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--gold);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- left panel ---------- */
#panel {
  position: fixed; z-index: 10; top: var(--gap); left: var(--gap); bottom: var(--gap); width: var(--panel-w);
  display: flex; flex-direction: column; gap: 12px; padding: 16px 16px 0;
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(22px) saturate(1.3); -webkit-backdrop-filter: blur(22px) saturate(1.3);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
#sheetHandle { display: none; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px; height: 40px; padding: 7px; flex: none; color: var(--gold);
  background: var(--gold-soft); border: 1px solid rgba(242, 198, 109, 0.28); border-radius: 12px;
}
.brand h1 { margin: 0; font: 600 19px/1.15 var(--serif); letter-spacing: 0.01em; }
.brand h1 em { font-style: italic; color: var(--gold); font-weight: 500; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }

.search {
  display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 12px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 12px;
  transition: border-color .15s, background .15s;
}
.search:focus-within { border-color: rgba(242, 198, 109, 0.6); background: rgba(255, 255, 255, 0.09); }
.search svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; font-size: 14.5px; }
.search input::placeholder { color: var(--dim); }
.search kbd {
  font: 11px var(--sans); color: var(--dim); border: 1px solid var(--line-strong); border-radius: 5px; padding: 1px 6px;
}
.search:focus-within kbd { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px 0 8px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); border-radius: 999px;
  font-size: 12.5px; color: var(--text); transition: background .15s, border-color .15s, opacity .15s;
}
.chip i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.chip small { color: var(--dim); font-size: 11px; }
.chip:hover { background: rgba(255, 255, 255, 0.1); }
.chips.filtered .chip:not(.on) { opacity: 0.45; }
.chip.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); }

.more-btn {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 7px; padding: 0; margin-top: -2px;
  background: none; border: 0; color: var(--muted); font-size: 12.5px;
}
.more-btn:hover, .more-btn[aria-expanded="true"] { color: var(--gold); }
.more-btn svg { width: 15px; height: 15px; }
.badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--gold); color: #1a1405;
  font-size: 11px; font-weight: 700; display: inline-grid; place-items: center;
}

.more { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, 0.03); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: grid; gap: 4px; min-width: 0; }
.field > span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--dim); }
select {
  width: 100%; height: 34px; padding: 0 28px 0 10px; appearance: none; -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.06) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5L6 8l3.5-3.5' fill='none' stroke='%23949cad' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 9px center / 12px;
  border: 1px solid var(--line); border-radius: 9px; outline: 0; text-overflow: ellipsis;
}
select:focus-visible { border-color: rgba(242, 198, 109, 0.6); }
select option { background: #151924; color: var(--text); }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 10px; }
.seg button { height: 27px; padding: 0 11px; background: none; border: 0; border-radius: 7px; color: var(--muted); font-size: 12.5px; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--gold); color: #1a1405; font-weight: 600; }

.toggles { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle i { width: 30px; height: 18px; border-radius: 9px; background: rgba(255, 255, 255, 0.14); position: relative; transition: background .15s; }
.toggle i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle input:checked + i { background: var(--gold); }
.toggle input:checked + i::after { transform: translateX(12px); }
.toggle input:focus-visible + i { outline: 2px solid var(--gold); outline-offset: 2px; }

.result-bar { display: flex; align-items: center; gap: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.result-bar #count { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-bar #count b { color: var(--text); font-weight: 600; }
.result-bar select { width: auto; height: 28px; font-size: 12.5px; background-color: transparent; border-color: transparent; color: var(--muted); padding-left: 6px; }
#reset { background: none; border: 0; padding: 0; color: var(--gold); font-size: 12.5px; white-space: nowrap; }
#reset:hover { text-decoration: underline; }

#list { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -16px; padding: 0; outline: 0; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; border-radius: 0 0 var(--radius) var(--radius); }
#listInner { position: relative; }
.row {
  position: absolute; left: 8px; right: 8px; height: 66px; display: flex; align-items: center; gap: 12px; padding: 0 10px;
  background: none; border: 0; border-radius: 12px; text-align: left; width: calc(100% - 16px);
}
.row:hover, .row:focus-visible { background: rgba(255, 255, 255, 0.07); outline: 0; }
.row.active { background: var(--gold-soft); box-shadow: inset 0 0 0 1px rgba(242, 198, 109, 0.35); }
.thumb {
  position: relative; flex: none; width: 48px; height: 48px; border-radius: 10px; overflow: hidden;
  background: color-mix(in srgb, var(--c) 22%, #10131c); display: grid; place-items: center;
}
.thumb::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: 0 0 10px var(--c); }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .25s; }
.thumb img.ok { opacity: 1; }
.row-text { flex: 1; min-width: 0; display: block; }
.row-sub { display: block; }
.row-name { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; }
.row-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.star { flex: none; width: 13px; height: 13px; color: var(--gold); }
.empty { padding: 40px 24px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text); font: 600 16px var(--serif); margin-bottom: 4px; }

/* ---------- map tools ---------- */
#tools { position: fixed; z-index: 9; top: var(--gap); left: calc(var(--panel-w) + var(--gap) * 2); display: flex; gap: 8px; }
#tools .seg, #home { background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
#home { width: 35px; height: 35px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); padding: 0; }
#home:hover { color: var(--gold); }
#home svg { width: 18px; height: 18px; }

.maplibregl-ctrl-bottom-left { left: calc(var(--panel-w) + var(--gap) * 2); bottom: 4px; }
.maplibregl-ctrl-bottom-left .maplibregl-ctrl { margin: 0 0 8px 0; }
.maplibregl-ctrl-group { background: var(--glass); border: 1px solid var(--line); border-radius: 10px; box-shadow: none !important; backdrop-filter: blur(16px); overflow: hidden; }
.maplibregl-ctrl-group button { width: 33px; height: 33px; }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--line); }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1) opacity(.75); }
.maplibregl-ctrl.maplibregl-ctrl-attrib { background: rgba(8, 10, 16, 0.72) !important; color: #aab2c2; font-size: 10.5px; border-radius: 9px !important; }
.maplibregl-ctrl-attrib a, .maplibregl-ctrl-attrib-inner { color: #aab2c2 !important; }
.maplibregl-ctrl-attrib-button { filter: invert(1) opacity(.7); }

.maplibregl-popup.tip { pointer-events: none; z-index: 5; }
.tip .maplibregl-popup-content {
  background: rgba(10, 12, 19, 0.94); color: var(--text); border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 7px 11px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); font: 13px var(--sans); max-width: 260px;
}
.tip .maplibregl-popup-content b { display: block; font-weight: 600; }
.tip .maplibregl-popup-content span { color: var(--muted); font-size: 12px; }
.tip .maplibregl-popup-tip { display: none; }

.pin { width: 18px; height: 18px; border-radius: 50%; background: var(--c, var(--gold)); border: 2.5px solid #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.35), 0 0 18px var(--c, var(--gold)); position: relative; }
.pin::before, .pin::after {
  content: ""; position: absolute; inset: -3px; border-radius: 50%; border: 2px solid #fff; opacity: 0;
  animation: pulse 2.2s ease-out infinite;
}
.pin::after { animation-delay: 1.1s; }
@keyframes pulse { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(3.6); opacity: 0; } }

/* ---------- detail panel ---------- */
#detail {
  position: fixed; z-index: 11; top: var(--gap); right: var(--gap); bottom: var(--gap); width: var(--detail-w);
  background: var(--glass-solid); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55); scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent;
  transform: translateX(calc(100% + 24px)); opacity: 0; visibility: hidden;
  transition: transform .35s cubic-bezier(.2, .8, .2, 1), opacity .25s, visibility .35s;
}
#detail.open { transform: none; opacity: 1; visibility: visible; }

.hero { position: relative; height: 240px; background: linear-gradient(135deg, color-mix(in srgb, var(--c) 34%, #0d1018), #0d1018 70%); overflow: hidden; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(13,16,24,0) 45%, rgba(13,16,24,.75) 82%, #0d1018 100%); pointer-events: none; }
.hero img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transform: scale(1.04); transition: opacity .45s, transform .9s ease; display: block; }
.hero img.ok { opacity: 1; transform: none; }
.hero-empty { position: absolute; inset: 0; display: grid; place-items: center; color: color-mix(in srgb, var(--c) 70%, #fff); opacity: .5; }
.hero-empty svg { width: 76px; height: 76px; }
.hero .shimmer { position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.07) 50%, transparent 70%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.close {
  position: absolute; z-index: 2; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line-strong);
  background: rgba(8, 10, 16, .65); backdrop-filter: blur(8px); display: grid; place-items: center; padding: 0;
}
.close:hover { background: rgba(8, 10, 16, .9); color: var(--gold); }
.close svg { width: 16px; height: 16px; }
.credit { position: absolute; z-index: 2; left: 12px; top: 12px; font-size: 10.5px; color: rgba(255,255,255,.8); background: rgba(8,10,16,.55); padding: 3px 8px; border-radius: 999px; text-decoration: none; backdrop-filter: blur(6px); }
.credit:hover { color: #fff; }

.d-body { padding: 0 22px 24px; margin-top: -34px; position: relative; z-index: 1; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tag { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; background: rgba(255,255,255,.08); border: 1px solid var(--line); color: var(--text); }
.tag i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.tag.gold { background: var(--gold-soft); border-color: rgba(242,198,109,.35); color: var(--gold); }
.d-body h2 { margin: 0; font: 600 26px/1.15 var(--serif); letter-spacing: 0.005em; text-wrap: balance; }
.local { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.where { margin: 10px 0 0; display: flex; gap: 7px; align-items: flex-start; color: var(--muted); font-size: 13.5px; }
.where svg { width: 15px; height: 15px; flex: none; margin-top: 2px; color: var(--gold); }
.summary { margin: 16px 0 0; font-size: 15px; line-height: 1.6; color: #dfe3ec; }
.source { margin: 6px 0 0; font-size: 11.5px; color: var(--dim); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 18px 0 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 12px;
  border-radius: 11px; border: 1px solid var(--line-strong); background: rgba(255,255,255,.05); color: var(--text);
  text-decoration: none; font-size: 13px; font-weight: 500; transition: background .15s, border-color .15s;
}
.btn:hover { background: rgba(255,255,255,.11); }
.btn svg { width: 15px; height: 15px; flex: none; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #1a1405; font-weight: 600; }
.btn.primary:hover { background: #f7d58d; }

.facts { margin: 22px 0 0; display: grid; grid-template-columns: 108px 1fr; gap: 0; border-top: 1px solid var(--line); }
.facts dt, .facts dd { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.facts dt { color: var(--dim); }
.facts dd { color: var(--text); overflow-wrap: anywhere; }
.tcid { margin: 14px 0 0; font-size: 11px; color: var(--dim); letter-spacing: .04em; }

/* ---------- small screens ---------- */
@media (max-width: 820px) {
  :root { --gap: 8px; }
  #panel {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 56vh; padding: 6px 14px 0;
    border-radius: 20px 20px 0 0; border-width: 1px 0 0; transition: height .3s cubic-bezier(.2,.8,.2,1);
  }
  #panel.collapsed { height: 132px; }
  #panel.collapsed .chips, #panel.collapsed .more-btn, #panel.collapsed .more, #panel.collapsed .brand { display: none; }
  #sheetHandle { display: grid; place-items: center; height: 18px; background: none; border: 0; padding: 0; margin: 0 0 -4px; }
  #sheetHandle span { width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); }
  .brand-mark { width: 34px; height: 34px; }
  #list { margin: 0 -14px; border-radius: 0; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -14px; padding: 0 14px; scrollbar-width: none; }
  .chip { flex: none; }
  #tools { left: var(--gap); }
  .maplibregl-ctrl-bottom-left { display: none; }
  #detail { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 82vh; border-radius: 20px 20px 0 0; transform: translateY(105%); }
  .hero { height: 200px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
