:root {
  --ink: #12262f;
  --ink-soft: #3d555e;
  --sea-deep: #07161d;
  --sea: #0d2c36;
  --sea-mid: #164352;
  --foam: #dceee8;
  --paper: #f6f1e6;
  --paper-2: #efe7d6;
  --sand: #c4a36c;
  --coral: #c45c4a;
  --line: rgba(18, 38, 47, 0.12);
  --line-strong: rgba(18, 38, 47, 0.22);
  --shadow: 0 18px 50px rgba(7, 22, 29, 0.28);
  --radius: 18px;
  --display: "Fraunces", "Palatino Linotype", Palatino, Georgia, serif;
  --serif: "Source Serif 4", Georgia, "Iowan Old Style", serif;
  --sans: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #1a5566 0%, transparent 50%),
    radial-gradient(900px 420px at 110% 0%, #3a2a18 0%, transparent 46%),
    var(--sea-deep);
}

button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid #e39b52;
  outline-offset: 3px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

a { color: #0d5c6d; }
a:hover { color: var(--coral); }

img { max-width: 100%; display: block; }

.skip {
  position: absolute;
  left: -999px;
  top: 8px;
  background: var(--paper);
  padding: 8px 12px;
  z-index: 20;
}
.skip:focus { left: 8px; }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 14px 22px;
  background: rgba(7, 22, 29, 0.78);
  border-bottom: 1px solid rgba(220, 238, 232, 0.08);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 8;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--foam);
}

.compass {
  width: 42px;
  height: 42px;
  flex: none;
}

.brand-title {
  font-family: var(--display);
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  line-height: 1;
}
.brand-sub {
  display: block;
  margin-top: 4px;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(220, 238, 232, 0.62);
}

.search-wrap {
  position: relative;
  max-width: 560px;
  width: 100%;
  justify-self: center;
}

.search-wrap input {
  width: 100%;
  border: 1px solid rgba(220, 238, 232, 0.16);
  background: rgba(255, 255, 255, 0.05);
  color: var(--foam);
  border-radius: 999px;
  padding: 11px 16px 11px 42px;
  outline: none;
}
.search-wrap input::placeholder { color: rgba(220, 238, 232, 0.45); }
.search-wrap input:focus {
  border-color: var(--sand);
  background: rgba(255, 255, 255, 0.08);
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--sand);
  pointer-events: none;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.btn {
  border: 0;
  cursor: pointer;
  border-radius: 999px;
  padding: 9px 14px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--foam);
  background: transparent;
  border: 1px solid rgba(220, 238, 232, 0.16);
}
.btn:hover { background: rgba(255, 255, 255, 0.08); }
.btn-accent {
  background: var(--sand);
  color: #1b1408;
  border-color: transparent;
  font-weight: 650;
}
.btn-accent:hover { filter: brightness(1.05); color: #1b1408; }

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 0;
}

.nav-pane {
  background: rgba(13, 44, 54, 0.72);
  color: var(--foam);
  border-right: 1px solid rgba(220, 238, 232, 0.08);
  padding: 18px 12px 28px;
  overflow: auto;
}

.nav-pane h2 {
  margin: 0 10px 12px;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--sand);
  font-weight: 650;
}

.tree-list, .tree-list ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tree-list ul { padding-left: 14px; }

.tree-list a {
  display: flex;
  gap: 8px;
  align-items: center;
  color: inherit;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 0.95rem;
}
.tree-list a:hover, .tree-list a.active {
  background: rgba(255, 255, 255, 0.08);
}
.tree-list a.active { color: var(--sand); }

.flag {
  width: 22px;
  height: 15px;
  object-fit: cover;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18);
  flex: none;
}
.flag-lg {
  width: 54px;
  height: 36px;
  border-radius: 4px;
}

.type-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
  background: var(--sand);
}
.type-dot.country { background: #7eb7c9; }
.type-dot.subdivision { background: #d7c39a; }
.type-dot.island { background: var(--coral); }

.stage {
  padding: 28px 32px 64px;
  overflow: auto;
}

.panel {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: calc(100vh - 140px);
  padding: 34px 40px 48px;
  position: relative;
  overflow: hidden;
}
.panel::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 8px;
  background: linear-gradient(90deg, var(--sea-mid), var(--sand), var(--coral));
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 0.88rem;
  color: var(--ink-soft);
  margin: 8px 0 18px;
}
.crumbs a { color: inherit; text-decoration: none; border-bottom: 1px solid transparent; }
.crumbs a:hover { border-bottom-color: currentColor; color: var(--ink); }
.crumbs .sep { opacity: 0.45; }

.hero {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr;
  gap: 28px;
  align-items: end;
  margin-bottom: 28px;
}

.kicker {
  font-size: 0.75rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--coral);
  margin: 0 0 8px;
}

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 550;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
h1 { font-size: clamp(2.2rem, 4vw, 3.6rem); margin: 0 0 10px; }
.deck {
  font-family: var(--serif);
  font-size: 1.18rem;
  color: var(--ink-soft);
  max-width: 40rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat {
  background: var(--sea);
  color: var(--foam);
  border-radius: 16px;
  padding: 16px 18px;
}
.stat b {
  display: block;
  font-family: var(--display);
  font-size: 1.8rem;
  line-height: 1;
}
.stat span {
  display: block;
  margin-top: 6px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.75;
}

.continent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin: 10px 0 34px;
}

.place-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 16px 14px;
  min-height: 128px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.place-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 24px rgba(18, 38, 47, 0.12);
}
.place-card.featured {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: var(--sea-mid);
  color: var(--foam);
  min-height: 180px;
}
.place-card.featured::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(180deg, rgba(7, 22, 29, 0.08), rgba(7, 22, 29, 0.7));
}
.featured-art { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; object-fit: cover; }
.place-card.featured .meta, .place-card.featured h3, .place-card.featured p { position: relative; z-index: 1; }
.place-card .meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.place-card .meta > span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.place-card .meta > span:last-child { white-space: nowrap; }
.place-card.featured .meta { color: var(--sand); }
.place-card h3 {
  margin: 14px 0 6px;
  font-size: 1.35rem;
}
.place-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
}
.place-card.featured p { color: rgba(220, 238, 232, 0.84); }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 28px 0 12px;
}
.section-head h2 { margin: 0; font-size: 1.5rem; }

.letter-index {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 18px;
}
.letter-index a {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  text-decoration: none;
  background: var(--paper-2);
  color: var(--ink);
  border: 1px solid var(--line);
}
.letter-index a:focus-visible { outline-offset: 2px; }
.letter-index a:hover, .letter-index a.active {
  background: var(--sea);
  color: var(--foam);
  border-color: transparent;
}

.island-list {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}
.island-row {
  display: grid;
  grid-template-columns: 28px 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
}
.island-row:hover { background: rgba(13, 44, 54, 0.04); }
.island-row strong { font-weight: 650; }
.island-row .quiet { color: var(--ink-soft); font-size: 0.9rem; }

.article {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 32px;
  align-items: start;
}

.prose {
  font-family: var(--serif);
  font-size: 1.08rem;
  line-height: 1.65;
}
.prose .lead {
  font-size: 1.22rem;
  color: var(--ink);
}
.prose h2, .prose h3 { margin: 1.6em 0 0.4em; }
.prose p, .prose ul, .prose ol, .prose table { margin: 0 0 1em; }
.prose blockquote {
  margin: 1.2em 0;
  padding: 4px 0 4px 18px;
  border-left: 3px solid var(--sand);
  color: var(--ink-soft);
}
.prose cite { display: block; margin-top: 8px; font-size: 0.92rem; }
.prose .article-image, .preview-frame .article-image {
  width: var(--image-scale, 100%);
  max-width: 100%;
  margin: 1em auto;
}
.article-image img {
  width: 100%;
  max-height: 500px;
  object-fit: contain;
}

.table-wrap { margin: 1.2em 0; }
table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.95rem;
}
th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th { background: var(--paper-2); font-weight: 650; }
figcaption {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-top: 6px;
}

.infobox {
  background: var(--paper-2);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  overflow: hidden;
  position: sticky;
  top: 84px;
}
.infobox header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 14px 10px;
  text-align: left;
  background: var(--sea);
  color: var(--foam);
}
.infobox header .flag-lg { width: 48px; height: 32px; flex: none; }
.infobox header h2 {
  margin: 0;
  font-size: 1.2rem;
  overflow-wrap: anywhere;
}
.infobox .cover {
  width: var(--image-scale, 100%);
  max-width: 100%;
  max-height: 180px;
  height: auto;
  margin: 0 auto;
  object-fit: contain;
}
.map-frame { position: relative; }
.map-frame.map-sized {
  width: var(--map-scale, 100%);
  max-width: 100%;
  margin: 0 auto 1em;
}
.map-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}
.map-open[hidden] { display: none; }
.custom-map {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 500px;
  margin: 0 auto;
}
.map-dialog {
  position: fixed;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: fit-content;
  max-width: 94vw;
  max-height: 94vh;
  padding: 48px 16px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.map-dialog::backdrop { background: rgba(7, 22, 29, 0.78); }
.map-dialog-image {
  width: auto;
  max-width: min(90vw, 1200px);
  max-height: calc(94vh - 72px);
  object-fit: contain;
}
.map-dialog-close {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--paper-2);
  color: var(--ink);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.osm-map {
  position: relative;
  height: auto;
  max-height: 224px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}
.osm-map[hidden] { display: none; }
.osm-map .infobox-map {
  position: absolute;
  z-index: 0;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
.map-control-mask {
  position: absolute;
  z-index: 1;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 68px;
  border-radius: 3px;
  background: #aad3df;
  pointer-events: none;
}
.infobox dl {
  margin: 0;
  padding: 8px 0 12px;
}
.infobox dl > div {
  display: grid;
  grid-template-columns: 42% 1fr;
  gap: 8px;
  padding: 6px 12px;
  font-size: 0.88rem;
}
.infobox dt { color: var(--ink-soft); }
.infobox dd { margin: 0; }
.infobox-map {
  border: 0;
  width: 100%;
  height: 180px;
  display: block;
  background: #c5d5d8;
}
.infobox-map.fixed-map { pointer-events: none; }
.map-unavailable { padding: 10px 12px; margin: 0; font-size: 0.85rem; color: var(--ink-soft); }
.map-unavailable[hidden], .map-frame [hidden] { display: none; }
.gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  justify-items: center;
  gap: 10px;
  margin: 1em 0;
  width: var(--image-scale, 100%);
  max-width: 100%;
  margin-inline: auto;
}
.gallery > figure { width: 100%; margin: 0; }
.gallery > figure:only-child,
.gallery > figure:nth-child(odd):last-child {
  grid-column: 1 / -1;
  width: min(100%, 520px);
}
.gallery img { width: 100%; max-height: 300px; object-fit: contain; }
.gallery figcaption { text-align: center; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.place-tags { margin: 18px 0; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  font-size: 0.88rem;
}

.search-results { display: grid; gap: 8px; }
.search-hit {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  background: var(--paper-2);
}
.search-hit:hover { outline: 1px solid var(--sand); }
.search-hit small { color: var(--ink-soft); }

.empty {
  padding: 28px 8px;
  color: var(--ink-soft);
}

.wave {
  height: 28px;
  margin: 8px 0 22px;
  color: var(--sea-mid);
  opacity: 0.35;
}

.title-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.place-heading { margin: 0 0 14px; }
.place-heading .kicker { margin: 0 0 8px; }
.place-name-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  font-size: clamp(2.2rem, 4vw, 3.6rem);
}
.place-name-row .flag-lg {
  width: auto;
  height: 1em;
  max-width: 2.25em;
  object-fit: contain;
  flex: none;
}
.place-name-row h1 {
  min-width: 0;
  margin: 0 0 10px;
  overflow-wrap: anywhere;
}
.place-cover {
  width: var(--image-scale, 100%);
  max-width: 100%;
  aspect-ratio: 5 / 1;
  max-height: 132px;
  margin: 14px 0 20px;
  overflow: hidden;
  border-radius: 12px;
  background: var(--paper-2);
}
.place-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.place-details {
  margin: 18px 0 24px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-2);
}
.place-details h2 { margin: 0 0 8px; font-size: 1.25rem; }
.place-details dl { margin: 0; }
.place-details dl > div {
  display: grid;
  grid-template-columns: minmax(110px, 30%) minmax(0, 1fr);
  gap: 12px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
}
.place-details dt { color: var(--ink-soft); }
.place-details dd { margin: 0; overflow-wrap: anywhere; }
.island-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto auto;
  align-items: center;
  margin: 0 0 18px;
}
.island-title.has-flag { grid-template-columns: 68px minmax(0, 1fr); column-gap: 16px; }
.island-title .flag-lg {
  grid-column: 1;
  grid-row: 2;
  width: 68px;
  height: 45px;
  object-fit: contain;
  flex: none;
}
.island-title .kicker { grid-column: 1; grid-row: 1; margin: 0 0 4px; }
.island-title h1 { grid-column: 1; grid-row: 2; margin: 0; overflow-wrap: anywhere; }
.island-title .deck { grid-column: 1; grid-row: 3; margin: 4px 0 0; }
.island-title.has-flag .kicker,
.island-title.has-flag h1,
.island-title.has-flag .deck { grid-column: 2; }

.local-filter {
  width: 100%;
  max-width: 320px;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .nav-pane { display: none; }
  .hero, .article { grid-template-columns: 1fr; }
  .infobox { position: static; }
  .topbar { grid-template-columns: 1fr; }
  .search-wrap { max-width: none; }
  .panel { padding: 28px 18px 36px; }
  .stats { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .topbar { padding: 12px 14px; gap: 12px; }
  .top-actions { justify-content: flex-start; }
  .stage { padding: 18px 12px 36px; }
  .panel { padding: 24px 14px 30px; }
  .section-head { align-items: stretch; flex-direction: column; }
  .local-filter { max-width: none; }
  .island-row { grid-template-columns: 28px minmax(0, 1fr); gap: 8px; }
  .island-row > .quiet { grid-column: 2; }
  .island-title.has-flag { grid-template-columns: 52px minmax(0, 1fr); column-gap: 10px; }
  .island-title .flag-lg { width: 52px; height: 35px; }
  .map-dialog { max-width: 96vw; padding: 46px 10px 10px; }
  .map-dialog-image { max-width: 92vw; max-height: calc(94vh - 64px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}

@media print {
  .topbar, .nav-pane, .top-actions { display: none !important; }
  .layout, .stage, .panel { display: block; background: #fff; box-shadow: none; }
  body { background: #fff; }
}
