/* ==========================================================================
   Base: reset, texture, typography, primitives
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.45;
  color: var(--ink);
  background-color: var(--bg);
  /* Environmental texture: faint map grid, tiny location nodes and coordinate ticks */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cg fill='none' stroke='%2315202D'%3E%3Cpath d='M0 .5H160M.5 0V160' stroke-opacity='.05'/%3E%3Cpath d='M80 76v8M76 80h8' stroke-opacity='.09'/%3E%3C/g%3E%3Ccircle cx='120.5' cy='40.5' r='1.3' fill='%2315202D' fill-opacity='.10'/%3E%3Ccircle cx='40.5' cy='128.5' r='1' fill='%231E9BFF' fill-opacity='.22'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32'%3E%3Cpath d='M0 .5H32M.5 0V32' fill='none' stroke='%2315202D' stroke-opacity='.022'/%3E%3C/svg%3E");
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
  overflow-x: hidden;
}
body::before {
  /* very faint topographic curves, anchored top-right */
  content: "";
  position: fixed;
  inset: 0 0 auto auto;
  width: min(900px, 90vw);
  height: 700px;
  background: url("../img/topo.svg") no-repeat top right / contain;
  opacity: .045;
  pointer-events: none;
  z-index: -1;
}
body.is-locked { overflow: hidden; }

img { max-width: 100%; display: block; }
svg { flex-shrink: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
table { border-collapse: collapse; }
[hidden] { display: none !important; }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 3px;
}

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 8px; top: -40px; z-index: 200;
  background: var(--ink); color: #fff; padding: 8px 12px; border-radius: var(--r-btn);
}
.skip-link:focus { top: 8px; }

/* ---------- Type helpers ---------- */
.mono { font-family: var(--mono); font-feature-settings: normal; letter-spacing: 0; }
.num { font-variant-numeric: tabular-nums; }
.label {
  font-size: var(--fs-xxs);
  font-weight: 650;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.eyebrow::before {
  content: ""; width: 14px; height: 2px; background: var(--blue);
}
.condensed { font-stretch: 80%; }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }

/* ---------- Layout ---------- */
.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }
.stack > * + * { margin-top: var(--stack, 12px); }
.row { display: flex; align-items: center; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1 1 auto; min-width: 0; }

main#main { min-height: 60vh; padding-bottom: calc(var(--mnav-h) + 40px + env(safe-area-inset-bottom)); }
@media (min-width: 900px) { main#main { padding-bottom: 64px; } }

.section { margin-top: 36px; }
@media (min-width: 900px) { .section { margin-top: 48px; } }
.section-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 14px;
}
.section-title {
  font-size: var(--fs-xl);
  font-weight: 750;
  letter-spacing: -.01em;
  line-height: 1.15;
}
.section-sub { color: var(--muted); font-size: var(--fs-sm); margin-top: 3px; }
.section-link {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  font-size: var(--fs-sm); font-weight: 600; color: var(--blue-ink);
}
.section-link:hover { text-decoration: underline; text-underline-offset: 3px; }

.page-head { padding: 22px 0 14px; }
.page-title { font-size: var(--fs-2xl); font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.page-sub { color: var(--muted); margin-top: 4px; }
@media (min-width: 900px) { .page-title { font-size: var(--fs-3xl); } .page-head { padding: 30px 0 18px; } }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--ink);
  --btn-bd: var(--line-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px;
  border-radius: var(--r-btn);
  border: 1px solid var(--btn-bd);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 650;
  font-size: var(--fs-md);
  line-height: 1;
  white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  user-select: none;
}
.btn:hover { border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn-primary { --btn-bg: var(--blue); --btn-fg: #fff; --btn-bd: var(--blue); box-shadow: 0 1px 0 rgba(10, 107, 191, .6) inset, 0 1px 2px rgba(10,107,191,.25); }
.btn-primary:hover { --btn-bg: var(--blue-hover); border-color: var(--blue-hover); }
.btn-dark { --btn-bg: var(--ink); --btn-fg: #fff; --btn-bd: var(--ink); }
.btn-dark:hover { --btn-bg: #243245; border-color: #243245; }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; }
.btn-ghost:hover { --btn-bg: var(--bg-2); border-color: transparent; }
.btn-lg { min-height: 48px; padding: 0 22px; font-size: var(--fs-lg); }
.btn-sm { min-height: 32px; padding: 0 11px; font-size: var(--fs-sm); border-radius: 6px; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }

.icon-btn {
  position: relative;
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: var(--r-btn);
  color: var(--ink-2);
  transition: background var(--t-fast), color var(--t-fast);
}
.icon-btn:hover { background: var(--bg-2); color: var(--ink); }
.count-dot {
  position: absolute; top: 3px; right: 1px;
  min-width: 17px; height: 17px; padding: 0 4px;
  display: grid; place-items: center;
  border-radius: 4px;
  background: var(--blue); color: #fff;
  font: 700 12px/1 var(--mono);
  box-shadow: 0 0 0 2px var(--surface);
}
.count-dot:empty, .count-dot[data-count="0"] { display: none; }

.link { color: var(--blue-ink); font-weight: 600; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; }
.field > label, .field-label { font-size: var(--fs-sm); font-weight: 650; color: var(--ink-2); }
.field-hint { font-size: var(--fs-xs); color: var(--muted); }
.field-error { font-size: var(--fs-xs); color: var(--red-ink); font-weight: 600; }
.input, .select, .textarea {
  width: 100%; min-height: 42px; padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: var(--r-btn);
  background: var(--surface);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.textarea { padding: 10px 12px; min-height: 110px; resize: vertical; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-strong); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-ring); outline: none; }
.input[aria-invalid="true"] { border-color: var(--red); }
.select {
  appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%236B7686' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
.select-sm { min-height: 34px; font-size: var(--fs-sm); padding-left: 10px; }

.check {
  display: flex; align-items: center; gap: 9px; cursor: pointer;
  font-size: var(--fs-sm); color: var(--ink-2);
  min-height: 30px;
}
.check input {
  appearance: none; margin: 0; flex: none;
  width: 16px; height: 16px; border-radius: 3px;
  border: 1.5px solid var(--line-strong); background: var(--surface);
  display: grid; place-items: center;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.check input::after {
  content: ""; width: 9px; height: 5px; margin-top: -2px;
  border: 2px solid #fff; border-top: 0; border-right: 0;
  transform: rotate(-45deg) scale(0); transition: transform var(--t-fast);
}
.check input:checked { background: var(--blue); border-color: var(--blue); }
.check input:checked::after { transform: rotate(-45deg) scale(1); }
.check input:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.check .check-count { margin-left: auto; font: 500 var(--fs-xs) var(--mono); color: var(--faint); }
.check.is-empty { opacity: .5; }

/* toggle switch */
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; min-height: 32px; font-size: var(--fs-sm); color: var(--ink-2); }
.toggle input {
  appearance: none; margin: 0; flex: none; width: 30px; height: 18px; border-radius: 4px;
  background: var(--line-2); position: relative; transition: background var(--t-fast);
}
.toggle input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 3px;
  background: #fff; box-shadow: var(--sh-1); transition: transform var(--t-fast) var(--ease);
}
.toggle input:checked { background: var(--green); }
.toggle input:checked::after { transform: translateX(12px); }
.toggle input:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---------- Skeletons ---------- */
.skel {
  position: relative; overflow: hidden;
  background: var(--slot);
  border-radius: 4px;
}
.skel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.65), transparent);
  transform: translateX(-100%);
  animation: skel 1.3s infinite;
}
@keyframes skel { to { transform: translateX(100%); } }
.skel-line { height: 10px; margin-top: 8px; }

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