:root {
  color-scheme: light;
  --ink: #17242d;
  --ink-soft: #52616b;
  --surface: #f7f9f8;
  --surface-raised: #ffffff;
  --surface-deep: #e8eeec;
  --accent: #176b70;
  --accent-deep: #104e53;
  --signal: #c26b2c;
  --signal-soft: #f4e2d4;
  --line: #cbd5d3;
  --line-strong: #9aabaa;
  --success: #2f6e4f;
  --warning: #9b5d25;
  --error: #a33c35;
  --shadow: 0 18px 50px rgb(20 40 47 / 10%);
  --radius: 10px;
  --header-font: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  --body-font: "Avenir Next", "DIN Alternate", "Bahnschrift", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--surface-deep);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: var(--body-font);
  background:
    radial-gradient(circle at 82% 4%, rgb(23 107 112 / 10%), transparent 30rem),
    linear-gradient(rgb(255 255 255 / 55%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / 55%) 1px, transparent 1px),
    var(--surface-deep);
  background-size: auto, 24px 24px, 24px 24px, auto;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 0.65rem 0.9rem;
  color: var(--ink);
  background: var(--surface-raised);
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
  background: #edf5f3;
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

:focus-visible {
  outline: 3px solid rgb(23 107 112 / 35%);
  outline-offset: 3px;
}

.site-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  padding: 1.55rem clamp(1rem, 3vw, 3rem) 1.35rem;
  color: #edf6f4;
  background:
    linear-gradient(105deg, rgb(255 255 255 / 3%), transparent 42%),
    #16232c;
  border-bottom: 4px solid var(--accent);
}

.identity-block {
  max-width: 62rem;
}

.eyebrow,
.section-kicker {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.site-header .eyebrow {
  color: #89c7c4;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2 {
  font-family: var(--header-font);
  font-weight: 600;
}

h1 {
  margin-bottom: 0.15rem;
  font-size: clamp(2.1rem, 4vw, 3.8rem);
  letter-spacing: -0.035em;
  line-height: 0.98;
}

h2 {
  margin-bottom: 0.35rem;
  font-size: clamp(1.35rem, 2vw, 1.85rem);
  line-height: 1.08;
}

.dek {
  margin-bottom: 0;
  color: #b8c8ca;
  font-size: 0.95rem;
}

.header-meta {
  display: grid;
  justify-items: end;
  gap: 0.55rem;
  width: min(34rem, 42vw);
}

.datum-badge {
  border: 1px solid rgb(137 199 196 / 45%);
  padding: 0.25rem 0.5rem;
  color: #b9dedd;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

#status-panel {
  width: 100%;
  border-left: 3px solid #89c7c4;
  padding: 0.55rem 0.7rem;
  color: #dce9e8;
  background: rgb(255 255 255 / 5%);
  font-size: 0.78rem;
  line-height: 1.4;
}

#status-panel[data-tone="warning"] {
  border-color: #d89b65;
}

#status-panel[data-tone="error"] {
  border-color: #e1786f;
}

#status-panel[data-tone="success"] {
  border-color: #7ec7a4;
}

#analysis-workspace {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  grid-template-rows: minmax(640px, calc(100vh - 11rem)) auto;
  grid-template-areas:
    "layers map"
    "details profile";
  gap: 1rem;
  width: min(1680px, 100%);
  margin: 0 auto;
  padding: 1rem;
}

.map-stage,
#layer-panel,
#point-details,
#profile-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgb(247 249 248 / 94%);
  box-shadow: var(--shadow);
}

.map-stage {
  grid-area: map;
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  min-width: 0;
  overflow: hidden;
  animation: panel-in 440ms ease both;
}

.map-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.15rem 0.6rem;
}

.map-heading-row h2 {
  margin-bottom: 0;
}

.map-toolbar {
  display: flex;
  gap: 0.45rem;
  padding: 0 1.15rem 0.75rem;
}

.map-toolbar button {
  min-height: 38px;
  padding: 0.45rem 0.75rem;
  font-size: 0.76rem;
  font-weight: 650;
}

#map {
  position: relative;
  min-height: 560px;
  margin: 0 0.7rem;
  overflow: hidden;
  border: 1px solid #9caaa8;
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgb(23 107 112 / 9%), transparent 45%),
    repeating-linear-gradient(0deg, transparent 0 31px, rgb(22 35 44 / 6%) 31px 32px),
    repeating-linear-gradient(90deg, transparent 0 31px, rgb(22 35 44 / 6%) 31px 32px),
    #dfe8e5;
}

.setup-card {
  position: absolute;
  inset: 50% auto auto 50%;
  display: grid;
  grid-template-columns: auto minmax(0, 28rem);
  gap: 1rem;
  width: min(34rem, calc(100% - 2rem));
  padding: 1.2rem;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line-strong);
  background: rgb(255 255 255 / 90%);
  box-shadow: 0 12px 34px rgb(20 40 47 / 14%);
}

.setup-index {
  color: var(--signal);
  font-family: var(--header-font);
  font-size: 2rem;
  line-height: 1;
}

.setup-card strong {
  display: block;
  margin-bottom: 0.25rem;
}

.setup-card p,
.map-caveat {
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
  line-height: 1.45;
}

.map-caveat {
  padding: 0.65rem 1.15rem 0.75rem;
}

#layer-panel {
  grid-area: layers;
  min-height: 0;
  overflow: auto;
  animation: panel-in 360ms ease both;
}

.panel-heading {
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--line);
}

.panel-heading p:last-child {
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
  line-height: 1.45;
}

#layer-controls {
  padding: 0.45rem 0.8rem 1rem;
}

#layer-controls h3 {
  margin: 1rem 0 0.4rem;
  color: var(--ink-soft);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.layer-control {
  display: grid;
  gap: 0.35rem;
  padding: 0.68rem 0;
  border-bottom: 1px solid #dde4e2;
}

.layer-control label {
  display: grid;
  grid-template-columns: 1.25rem minmax(0, 1fr);
  align-items: start;
  gap: 0.5rem;
  font-size: 0.8rem;
  line-height: 1.35;
}

.layer-control input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin-top: 0.05rem;
  accent-color: var(--accent);
}

.layer-control button {
  min-height: 34px;
  justify-self: start;
  padding: 0.35rem 0.55rem;
  font-size: 0.68rem;
}

.layer-meta,
.layer-unavailable {
  color: var(--ink-soft);
  font-size: 0.68rem;
  line-height: 1.4;
}

.layer-unavailable {
  color: var(--warning);
}

.opacity-control {
  display: grid;
  gap: 0.45rem;
  margin-top: 1rem;
  font-size: 0.75rem;
  font-weight: 650;
}

.opacity-control input {
  width: 100%;
  accent-color: var(--accent);
}

#point-details {
  grid-area: details;
  min-width: 0;
  overflow: hidden;
  animation: panel-in 520ms 80ms ease both;
}

#point-details-content {
  padding: 0.9rem 1rem 1rem;
}

#point-details-content h3 {
  margin-bottom: 0.7rem;
  font-family: var(--header-font);
  font-size: 1.05rem;
}

#point-details-content dl {
  display: grid;
  grid-template-columns: minmax(7rem, auto) 1fr;
  gap: 0.35rem 0.7rem;
  margin: 0;
  font-size: 0.72rem;
}

#point-details-content dt {
  color: var(--ink-soft);
}

#point-details-content dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.point-note {
  margin: 0.8rem 0 0;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.7rem;
  line-height: 1.45;
}

#profile-panel {
  grid-area: profile;
  min-width: 0;
  overflow: hidden;
  animation: panel-in 520ms 120ms ease both;
}

.profile-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
}

.profile-heading > p {
  max-width: 32rem;
  text-align: right;
}

#profile-chart {
  min-width: 0;
  overflow-x: auto;
  padding: 0.25rem 0.75rem 0.8rem;
}

#profile-chart svg {
  display: block;
  min-width: 560px;
  width: 100%;
  height: auto;
}

#profile-chart > p {
  margin: 0.25rem 0.75rem;
  color: var(--ink-soft);
  font-size: 0.7rem;
}

.profile-point {
  cursor: pointer;
  transition: r 120ms ease, fill 120ms ease, stroke-width 120ms ease;
}

.profile-point:hover,
.profile-point:focus {
  fill: var(--signal-soft);
}

.profile-point--selected {
  fill: var(--signal-soft);
  stroke-width: 3;
}

.drawer-trigger {
  display: none;
}

.drawer-heading-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.drawer-close {
  display: none;
}

dialog {
  width: min(46rem, calc(100% - 2rem));
  max-height: min(42rem, calc(100vh - 3rem));
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 1.25rem;
  color: var(--ink);
  background: var(--surface-raised);
  box-shadow: 0 24px 80px rgb(10 24 30 / 30%);
}

dialog::backdrop {
  background: rgb(10 24 30 / 58%);
  backdrop-filter: blur(3px);
}

dialog ul {
  display: grid;
  gap: 0.65rem;
  padding-left: 1.2rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
  line-height: 1.45;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  padding: 1rem clamp(1rem, 3vw, 3rem) 1.4rem;
  color: #5a676e;
  font-size: 0.68rem;
  line-height: 1.5;
}

footer p {
  max-width: 52rem;
  margin-bottom: 0;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1040px) {
  #analysis-workspace {
    grid-template-columns: 270px minmax(0, 1fr);
  }

  .profile-heading {
    display: block;
  }

  .profile-heading > p {
    max-width: none;
    text-align: left;
  }
}

@media (max-width: 760px) {
  .site-header {
    display: block;
    padding: 1.15rem 1rem;
  }

  .header-meta {
    justify-items: start;
    width: 100%;
    margin-top: 1rem;
  }

  #analysis-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas:
      "map"
      "details"
      "profile";
    padding: 0.65rem;
  }

  .map-stage {
    min-height: 0;
  }

  #map {
    min-height: max(480px, 64svh);
    margin: 0 0.45rem;
  }

  .map-toolbar {
    overflow-x: auto;
    padding-inline: 0.75rem;
  }

  .map-toolbar button {
    min-height: 44px;
    white-space: nowrap;
  }

  .drawer-trigger {
    display: inline-flex;
    align-items: center;
  }

  .drawer-close {
    display: inline-flex;
    align-items: center;
  }

  #layer-panel {
    position: fixed;
    z-index: 20;
    inset: 0 auto 0 0;
    width: min(88vw, 340px);
    animation: none;
    border-width: 0 1px 0 0;
    border-radius: 0;
    transform: translateX(-102%);
    opacity: 0;
    pointer-events: none;
    transition: transform 220ms ease, opacity 180ms ease;
  }

  #layer-panel[data-drawer-open="true"] {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }

  #point-details-content dl {
    grid-template-columns: 1fr;
  }

  #point-details-content dd {
    margin-bottom: 0.35rem;
  }

  footer {
    display: block;
    padding: 1rem;
  }

  footer p + p {
    margin-top: 0.5rem;
  }
}

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