:root {
  --bg: #f7f9fb;
  --surface: #ffffff;
  --surface-strong: #edf2f7;
  --text: #17202a;
  --muted: #637083;
  --line: #dce3eb;
  --accent: #087f8c;
  --accent-strong: #065f69;
  --warm: #b7791f;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(23, 32, 42, .08);
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  margin: 0;
}

a {
  color: var(--accent);
}

.icon {
  display: inline-block;
  fill: none;
  height: 1.05em;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  vertical-align: -.15em;
  width: 1.05em;
}

.topbar {
  align-items: center;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: .65rem;
  justify-content: space-between;
  min-height: 52px;
  padding: .4rem clamp(.75rem, 3vw, 2rem);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  color: var(--text);
  font-size: 1rem;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}

.nav {
  align-items: center;
  display: flex;
  flex-wrap: nowrap;
  gap: .15rem;
  justify-content: flex-end;
  overflow-x: auto;
}

.nav a {
  border-radius: 6px;
  color: var(--muted);
  font-size: .95rem;
  padding: .32rem .5rem;
  text-decoration: none;
  white-space: nowrap;
}

.nav a.active,
.nav a:hover {
  background: var(--surface-strong);
  color: var(--text);
}

.page {
  margin: 0 auto;
  max-width: 1280px;
  padding: clamp(1rem, 4vw, 3rem);
}

.site-footer {
  color: var(--muted);
  font-size: .9rem;
  margin: 0 auto;
  max-width: 1120px;
  padding: 0 clamp(1rem, 4vw, 3rem) 2rem;
  text-align: center;
}

.hero {
  align-items: end;
  display: block;
  gap: 1rem;
  margin: .75rem 0 1.35rem;
}

.eyebrow {
  color: var(--warm);
  font-size: .82rem;
  font-weight: 760;
  margin: 0 0 .25rem;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(2rem, 7vw, 4.75rem);
  line-height: 1;
  margin: 0;
}

h2 {
  font-size: 1.25rem;
  margin: 0 0 1rem;
}

.login-title {
  font-size: 2rem;
  margin-bottom: 1rem;
}

.muted {
  color: var(--muted);
}

.button {
  align-items: center;
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 720;
  min-height: 44px;
  padding: .65rem .9rem;
  text-decoration: none;
}

.button:hover {
  background: var(--accent-strong);
  color: #fff;
}

.button.secondary {
  background: var(--surface-strong);
  color: var(--text);
}

.grid {
  display: grid;
  gap: .75rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel,
.stat,
.login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel,
.login-panel {
  padding: 1.25rem;
}

.stat {
  padding: .85rem 1rem;
}

.stat .value {
  display: block;
  font-size: 1.75rem;
  font-weight: 780;
  line-height: 1.1;
}

.map-list {
  display: grid;
  gap: .75rem;
  margin: 0;
  padding: 0;
}

.map-list > li {
  list-style: none;
}

.map-row {
  align-items: center;
  border-top: 1px solid var(--line);
  color: inherit;
  display: grid;
  gap: 1rem;
  grid-template-columns: 400px minmax(0, 1fr) auto;
  padding: 1rem 0 0;
  text-decoration: none;
}

.map-row:hover .map-title {
  color: var(--accent);
}

.thumb {
  background: var(--surface-strong);
  border-radius: 6px;
  aspect-ratio: 4 / 1;
  display: block;
  overflow: hidden;
  width: 400px;
}

.thumb img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.map-title {
  color: var(--text);
  display: block;
  font-weight: 720;
  text-decoration: none;
}

.meta {
  color: var(--muted);
  font-size: .92rem;
}

.map-views {
  align-items: center;
  display: inline-flex;
  gap: .25rem;
  justify-content: flex-end;
  white-space: nowrap;
}

.map-views .icon {
  display: none;
}

.login-shell {
  display: grid;
  min-height: calc(100vh - 52px);
  place-items: center;
}

.login-panel {
  max-width: 420px;
  width: 100%;
}

.field {
  display: grid;
  gap: .35rem;
  margin: 0 0 1rem;
}

.field label {
  font-weight: 700;
}

.field input {
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  min-height: 44px;
  padding: .65rem .75rem;
  width: 100%;
}

.alert {
  background: #fff5f5;
  border: 1px solid #fed7d7;
  border-radius: 8px;
  color: var(--danger);
  margin: 0 0 1rem;
  padding: .75rem .9rem;
}

.actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
}

.section-spaced {
  margin-top: 1rem;
}

.field select {
  appearance: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  min-height: 44px;
  padding: .65rem .75rem;
  width: 100%;
}

.field.compact {
  margin: 0;
}

.archive-tools {
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
  margin-top: 1.5rem;
  padding: 1rem 0;
}

.filter-toggle {
  display: none;
  justify-content: center;
  width: max-content;
}

.mobile-filter-reset {
  display: none;
}

.filter-state {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.filter-state:focus-visible + .filter-toggle {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.filters {
  align-items: end;
  display: grid;
  gap: .75rem;
  grid-template-columns: 150px 220px minmax(220px, 1fr) auto;
}

.filter-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.section-heading {
  align-items: baseline;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: .75rem;
}

.tag-line {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .4rem;
}

.tag-line span {
  background: var(--surface-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: .78rem;
  padding: .15rem .45rem;
}

.pagination {
  align-items: center;
  display: flex;
  gap: .75rem;
  justify-content: center;
  margin-top: 1.25rem;
}

.page-count,
.empty-state {
  color: var(--muted);
}

.map-detail-hero {
  display: block;
  gap: 1rem;
  margin: 1rem 0;
}

.map-detail-hero h1 {
  font-size: clamp(2rem, 6vw, 4rem);
}

.detail-top-row {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.detail-top-row .back-link {
  margin-bottom: 0;
}

.detail-date-mobile {
  color: var(--warm);
  display: none;
  font-size: .82rem;
  font-weight: 760;
}

.map-title-row {
  align-items: center;
  display: grid;
  gap: .75rem;
  grid-template-columns: minmax(0, 1fr) auto;
}

.back-link {
  align-items: center;
  display: inline-flex;
  gap: .2rem;
  font-weight: 720;
  margin-bottom: 1rem;
  text-decoration: none;
}

.detail-nav,
.viewer-toolbar,
.zoom-controls,
.segmented {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.detail-nav {
  justify-content: flex-end;
}

.detail-nav .button {
  gap: .25rem;
}

.map-viewer {
  background: #111820;
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.fullscreen-toolbar {
  display: none;
}

.viewer-toolbar {
  background: #fff;
  border: 1px solid var(--line);
  border-bottom: 0;
  justify-content: space-between;
  padding: .6rem;
}

.segmented,
.zoom-controls {
  background: var(--surface-strong);
  border-radius: 6px;
  padding: .25rem;
}

.segmented button,
.zoom-controls button {
  background: transparent;
  border: 0;
  border-radius: 5px;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 720;
  min-height: 40px;
  min-width: 44px;
  padding: .45rem .65rem;
}

.segmented button.active,
.segmented button:hover,
.zoom-controls button:hover {
  background: #fff;
}

.map-stage {
  cursor: grab;
  height: min(72vh, 820px);
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.map-stage:active {
  cursor: grabbing;
}

.map-stage img {
  display: block;
  max-width: none;
  transform-origin: 0 0;
  user-select: none;
  width: 100%;
}

.detail-grid {
  display: grid;
  gap: .75rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.detail-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .8rem;
}

.detail-item span {
  color: var(--muted);
  display: block;
  font-size: .82rem;
}

.detail-item strong {
  display: block;
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.map-comment {
  white-space: normal;
}

@media (max-width: 760px) {
  .hero,
  .map-detail-hero {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .topbar {
    gap: .4rem;
  }

  .brand {
    font-size: .95rem;
  }

  .nav {
    justify-content: flex-end;
  }

  .grid {
    gap: .45rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stat {
    border-radius: 6px;
    padding: .55rem;
  }

  .stat .value {
    font-size: 1.15rem;
  }

  .stat .muted {
    display: block;
    font-size: .72rem;
    line-height: 1.2;
  }

  .archive-tools {
    border: 0;
    margin-top: .9rem;
    padding: 0;
  }

  .filter-toggle {
    display: inline-flex;
    width: 100%;
  }

  .filter-state:checked + .filter-toggle {
    display: none;
  }

  .filter-state:not(:checked) + .filter-toggle + .filters {
    display: none;
  }

  .filters {
    border-bottom: 1px solid var(--line);
    border-top: 1px solid var(--line);
    grid-template-columns: 1fr;
    margin-top: .75rem;
    padding: .75rem 0;
  }

  .filter-actions .button {
    justify-content: center;
    width: 100%;
  }

  .mobile-filter-reset {
    display: inline-flex;
  }

  .section-heading {
    align-items: start;
    flex-direction: column;
    gap: .1rem;
  }

  .map-row {
    align-items: start;
    grid-template-columns: 1fr auto;
  }

  .thumb {
    grid-column: 1 / -1;
    width: 100%;
  }

  .map-views {
    align-self: start;
    justify-self: end;
  }

  .map-views .icon {
    display: inline-block;
  }

  .map-views .views-label {
    display: none;
  }

  .pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .pagination .button {
    justify-content: center;
  }

  .viewer-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .zoom-controls {
    display: none;
  }

  .segmented button,
  .zoom-controls button {
    justify-content: center;
  }

  .map-title-row {
    align-items: start;
  }

  .detail-date-desktop {
    display: none;
  }

  .detail-date-mobile {
    display: inline-block;
  }

  .map-detail-hero h1 {
    font-size: 1.7rem;
  }

  .detail-nav {
    flex-wrap: nowrap;
  }

  .detail-nav .button {
    justify-content: center;
    min-height: 40px;
    min-width: 40px;
    padding: .45rem;
  }

  .detail-nav .nav-text {
    display: none;
  }

  .segmented {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .map-stage {
    height: 68vh;
  }

  .map-viewer.is-fullscreen {
    border-radius: 0;
    inset: 0;
    position: fixed;
    z-index: 100;
  }

  .map-viewer.is-fullscreen .viewer-toolbar {
    display: none;
  }

  .map-viewer.is-fullscreen .fullscreen-toolbar {
    display: flex;
  }

  .fullscreen-toolbar {
    align-items: center;
    display: none;
    inset: .75rem .75rem auto .75rem;
    justify-content: space-between;
    pointer-events: none;
    position: fixed;
    z-index: 101;
  }

  .fullscreen-toolbar button {
    align-items: center;
    background: rgba(255, 255, 255, .94);
    border: 0;
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 720;
    justify-content: center;
    min-height: 44px;
    min-width: 44px;
    padding: .55rem .75rem;
    pointer-events: auto;
  }

  .map-viewer.is-fullscreen .map-stage {
    height: 100vh;
  }

  body.map-viewer-open {
    overflow: hidden;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}
