:root {
  color-scheme: dark;
  --bg: #101316;
  --panel: #181d21;
  --panel-2: #20272c;
  --text: #eef2f4;
  --muted: #a9b3ba;
  --line: #344048;
  --accent: #d8e8f2;
  --shadow: 0 18px 45px rgba(0,0,0,.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { line-height: 1.5; }
a { color: inherit; }
button, input { font: inherit; }
button, .button {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: .65rem;
  padding: .55rem .8rem;
  cursor: pointer;
}
button:hover, .button:hover { border-color: var(--accent); }

.site-header, .viewer-header {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  align-items: center;
  padding: 2rem clamp(1rem,4vw,4rem);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #171c20, #111518);
}
.site-header.compact { padding-block: 1.3rem; }
.site-header h1, .viewer-header h1 { margin: 0; line-height: 1.12; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .72rem; color: var(--muted); margin: 0 0 .35rem; }
.subtitle { color: var(--muted); max-width: 60rem; margin: .5rem 0 0; }
.top-nav, .viewer-actions { display: flex; gap: .65rem; align-items: center; }
.top-nav a { text-decoration: none; padding: .55rem .7rem; border-radius: .5rem; }
.top-nav a:hover, .top-nav a[aria-current="page"] { background: var(--panel-2); }

main:not(.viewer-layout):not(.map-main) { padding: 1.5rem clamp(1rem,4vw,4rem) 3rem; }
.toolbar { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.3rem; }
.search { display: grid; gap: .35rem; min-width: min(30rem,100%); color: var(--muted); }
.search input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: .7rem;
  padding: .75rem .9rem;
}
.muted { color: var(--muted); }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(min(100%,22rem),1fr));
  gap: 1.25rem;
}
.card {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.card-media { position: relative; aspect-ratio: 16/9; background: #080a0c; overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease; }
.card:hover .card-media img { transform: scale(1.015); }
.card-link { text-decoration: none; }
.card-body { padding: 1rem; display: grid; gap: .65rem; }
.card-body h2 { margin: 0; font-size: 1.18rem; }
.card-body p { margin: 0; }
.badges { display: flex; flex-wrap: wrap; gap: .4rem; }
.badge { font-size: .78rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: .2rem .5rem; }
.card-globe { position: absolute; left: .65rem; bottom: .65rem; width: 80px; height: 80px; border-radius: 50%; background: rgba(10,13,15,.76); backdrop-filter: blur(6px); }
.empty-state { border: 1px dashed var(--line); border-radius: 1rem; padding: 2rem; text-align: center; }
footer { padding: 1.5rem clamp(1rem,4vw,4rem); color: var(--muted); border-top: 1px solid var(--line); }

.viewer-page { overflow: hidden; }
.viewer-header { height: 88px; padding-block: .8rem; }
.viewer-heading { min-width: 0; flex: 1; }
.viewer-heading h1 { font-size: clamp(1rem,2vw,1.45rem); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-heading p { margin: .2rem 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back-link { text-decoration: none; }
.viewer-layout { height: calc(100vh - 88px); display: grid; grid-template-columns: minmax(0,1fr) 22rem; }
.osd { min-width: 0; height: 100%; background: #050708; }
.info-panel { overflow: auto; border-left: 1px solid var(--line); background: var(--panel); padding: 1rem; }
.coverage-card { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.coverage-card svg { width: 110px; height: 110px; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: .45rem .8rem; }
.details dt { color: var(--muted); }
.details dd { margin: 0; overflow-wrap: anywhere; }

.map-dialog {
  width: min(68rem,calc(100vw - 2rem));
  height: min(46rem,calc(100vh - 2rem));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--panel);
  color: var(--text);
}
.map-dialog::backdrop { background: rgba(0,0,0,.72); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
.dialog-head h2, .dialog-head p { margin: 0; }
.map { min-height: 25rem; background: #d8d8d8; color: #111; }
.map-dialog .map { height: calc(100% - 8.5rem); }
.map-main { padding: 1rem; }
.overview-map { height: calc(100vh - 13rem); min-height: 32rem; border-radius: .8rem; overflow: hidden; }
.map-disclaimer { margin: .65rem 1rem 1rem; color: var(--muted); }
.leaflet-popup-content a { color: #111; }
.globe-outline { fill: #11171b; stroke: #d6e0e6; stroke-width: 1.5; }
.globe-grid { fill: none; stroke: #66757f; stroke-width: .65; opacity: .72; }
.globe-coverage { fill: #e0edf4; fill-opacity: .62; stroke: #fff; stroke-width: 1.2; }

@media (max-width: 850px) {
  .viewer-page { overflow: auto; }
  .viewer-header { height: auto; flex-wrap: wrap; }
  .viewer-layout { height: auto; min-height: calc(100vh - 130px); grid-template-columns: 1fr; }
  .osd { height: 65vh; }
  .info-panel { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 620px) {
  .site-header { align-items: flex-start; flex-direction: column; gap: 1rem; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .viewer-actions { width: 100%; }
}
