/**
 * Subpages & forms — isolated from map app styles.
 * Safe to load on index.html for header nav only; map layout unchanged.
 *
 * CONTROL RULES — Layer A (monochrome action) + Layer B (sector pastels in main.css)
 * A1. button-primary — gradient #418F8F→#2A684F. Add startup, Submit only.
 * A2. button-secondary (btn--surface) — white, ink text, hairline. Filters, Cancel.
 * A3. nav text links — Updates, Advertise (muted, accent hover).
 * A4. button-icon — 32×32, hairline, rounded 10px. Mobile menu.
 * A5. nav-pill-group — soft tray; active segment = white + bold ink (not green).
 * B. Pastel badges / avatars / bento filters — sector hues only.
 *
 * SIZE AUDIT (btn--sm | btn--md | btn--lg optional; default .btn = 32px):
 * default / sm / md 32px — all current buttons
 * lg 40px — opt-in only (btn--lg)
 * mobile touch — form-actions (non-sm) only → min 44px; spotlight/success CTAs stay sm (32px)
 *
 * PAGE SHELLS (hybrid):
 * page-doc.page-flat — flat column, no card (Add, Updates, About, Terms)
 * page-doc.page-plain — centered spotlight, no card (404, Ads)
 *
 * Flat/plain pages scroll on html (body grows with content).
 */

/* ── Header chrome — instant on repeat visits (session) ── */
html.chrome-ready .logo.logo-font-ready .logo-badge,
html.chrome-ready .logo.logo-font-ready .logo-text {
  display: block;
  animation: none !important;
  opacity: 1;
}
html.chrome-ready .logo.logo-font-ready .logo-badge-skeleton,
html.chrome-ready .logo.logo-font-ready .logo-skeleton {
  display: none !important;
}
html.chrome-ready body.logo-badge-ready .logo.logo--ready .logo-badge,
html.chrome-ready body.logo-badge-ready .logo.logo-font-ready .logo-badge {
  display: block;
  animation: none !important;
  opacity: 1;
}
html.chrome-ready body.logo-badge-ready .logo.logo--ready .logo-badge-skeleton,
html.chrome-ready body.logo-badge-ready .logo.logo-font-ready .logo-badge-skeleton {
  display: none !important;
}
html.chrome-ready body.logo-badge-ready .header-nav {
  opacity: 1;
  pointer-events: auto;
}
html.chrome-ready body.fonts-ready .logo-badge-skeleton,
html.chrome-ready body.fonts-ready .header-tagline-skeleton {
  display: none !important;
}
html.chrome-ready body.logo-badge-ready .logo:not(.logo--ready) .logo-badge-skeleton {
  display: block !important;
}
html.chrome-ready body.fonts-ready .header-tagline {
  display: inline;
  animation: none !important;
}
html.chrome-ready body.fonts-ready .panel-footer__copy {
  display: block;
  animation: none !important;
}
html.chrome-ready body.fonts-ready .panel-footer__skeleton {
  display: none !important;
}
@media (max-width: 768px) {
  html.chrome-ready body.fonts-ready .header-tagline {
    display: none;
  }
}

/* ── Subpage logo layout — shared with map via .site-header:has(.header-nav) below ── */

/* ── Header nav (map + subpages) ── */
.site-header:has(.header-nav) {
  position: sticky;
  top: 0;
  z-index: 1001;
  flex-shrink: 0;
}

.site-header:has(.header-nav) .logo {
  flex: 0 1 auto;
  min-width: 0;
  overflow: visible;
  min-height: var(--logo-line-height);
}

.site-header:has(.header-nav) .logo-text {
  white-space: nowrap;
  overflow: visible;
  padding-right: 0.08em;
  padding-bottom: 0.14em;
  margin-bottom: -0.14em;
}

.header-right:has(.header-nav) {
  font-size: 13.2px;
  min-height: 18px;
  gap: 10px;
}
.header-cta {
  flex-shrink: 0;
  white-space: nowrap;
}
.header-right .header-cta.btn {
  height: var(--btn-height-sm);
  min-height: var(--btn-height-sm);
  padding: 0 14px;
  font-size: var(--btn-font-sm);
}
.header-nav .header-cta {
  color: #fff;
  padding: 0 14px;
  min-height: var(--ctrl-h-sm);
  height: var(--ctrl-h-sm);
  margin-left: 2px;
  border: none;
  background: var(--primary-grad);
  font-weight: var(--ctrl-weight-active);
  border-radius: var(--ctrl-radius-md);
}
.header-nav .header-cta:not(:disabled):hover,
.header-nav .header-cta:not(:disabled):focus-visible {
  color: #fff;
  background: var(--primary-grad-pressed);
}
.header-nav .header-cta:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.header-right .header-cta.btn.btn--primary {
  background: var(--primary-grad);
}
.header-right .header-cta.btn.btn--primary:hover,
.header-right .header-cta.btn.btn--primary:focus-visible {
  background: var(--primary-grad-pressed);
}
.header-nav .header-cta .header-cta__icon {
  opacity: 1;
}
.header-cta__icon {
  display: inline-flex;
  flex-shrink: 0;
}
.header-cta__icon svg {
  width: 14px;
  height: 14px;
}
.header-cta__label--short {
  display: none;
}
.header-nav {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-right: 4px;
}
.header-nav .header-nav__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  border: none;
  border-radius: 0;
  background: none;
  box-sizing: border-box;
  font-family: var(--font-ui);
  font-size: inherit;
  font-weight: 600;
  font-synthesis: none;
  font-variation-settings: 'wght' 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  color: var(--muted);
  transition: color 0.15s ease;
}
.header-nav .header-nav__link:hover,
.header-nav .header-nav__link:focus-visible {
  color: var(--accent);
}
.header-nav .header-nav__link[aria-current="page"] {
  color: var(--text);
  cursor: default;
  pointer-events: none;
}
.header-nav .header-nav__link[aria-current="page"]:hover,
.header-nav .header-nav__link[aria-current="page"]:focus-visible {
  color: var(--text);
}
.header-nav .header-nav__link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
.header-nav .nav-label {
  font: inherit;
  font-weight: inherit;
}
.header-nav__icon {
  display: inline-flex;
  flex-shrink: 0;
  color: currentColor;
}
.header-nav__icon svg {
  width: 14px;
  height: 14px;
  display: block;
}
.header-nav [data-phosphor-size="sm"],
.header-cta [data-phosphor-size="sm"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
[data-phosphor-size="md"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
[data-phosphor]:empty {
  opacity: 0;
}
[data-phosphor]:not(:empty) {
  opacity: 1;
}
.header-nav .header-cta {
  margin-left: 2px;
}
.header-menu-btn {
  display: none;
}
.header-menu-btn.btn {
  display: none;
  position: relative;
  flex-shrink: 0;
  width: var(--ctrl-h-sm);
  min-width: var(--ctrl-h-sm);
  max-width: var(--ctrl-h-sm);
  height: var(--ctrl-h-sm);
  min-height: var(--ctrl-h-sm);
  padding: 0;
  gap: 0;
  overflow: hidden;
  border-radius: var(--ctrl-radius-md);
  color: var(--text);
  box-sizing: border-box;
}
.header-menu-btn__icon {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.header-menu-btn__icon .phosphor-icon,
.header-menu-btn__icon svg {
  width: 16px;
  height: 16px;
  display: block;
}
.header-menu-btn__icon--close {
  display: none;
}
.header-menu-btn[aria-expanded="true"] .header-menu-btn__icon--open {
  display: none;
}
.header-menu-btn[aria-expanded="true"] .header-menu-btn__icon--close {
  display: inline-flex;
}
.header-menu-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.header-nav-panel {
  display: contents;
}
.header-nav-backdrop {
  display: none;
}
@media (max-width: 720px) {
  .site-header:has(.header-nav) .header-tagline {
    display: none;
  }
  body.fonts-ready .site-header:has(.header-nav) .header-tagline {
    display: none;
  }
  .header-nav__icon {
    opacity: 1;
  }
}

/* ── Document / task page shell — matches list view column ── */
body.page-task,
body.page-doc {
  min-height: 0;
  display: flex !important;
  flex-direction: column;
}

/* Legacy framed doc (unused — flat/plain override) */
body.page-doc:not(.page-flat):not(.page-plain) {
  overflow: hidden !important;
  height: 100% !important;
  background: var(--list-gutter-bg);
}

/* ── Shared subpage surface: white bg, html scroll, stable scrollbar ── */
html:has(body.page-doc.page-flat),
html:has(body.page-doc.page-plain) {
  overflow-x: hidden;
  overflow-y: scroll;
  height: auto;
  min-height: 100%;
}

body.page-doc.page-flat,
body.page-doc.page-plain {
  overflow: visible !important;
  height: auto !important;
  min-height: 100dvh;
  background: var(--surface);
}

body.page-doc.page-flat .page-shell,
body.page-plain .page-shell {
  flex: 1 0 auto;
  min-height: 0;
  overflow: visible;
  background: var(--surface);
  padding:
    0
    max(var(--content-column-gutter), env(safe-area-inset-right))
    calc(40px + env(safe-area-inset-bottom, 0px))
    max(var(--content-column-gutter), env(safe-area-inset-left));
}

body.page-doc.page-flat .page-frame {
  flex: none;
  min-height: auto;
}

.page-shell {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  width: 100%;
  background: var(--list-gutter-bg);
  padding:
    var(--content-column-inset)
    var(--content-column-gutter)
    calc(var(--content-column-inset) + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
}

.page-frame {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: min(var(--list-content-max), 100%);
  max-width: var(--list-content-max);
  margin: 0 auto;
}

.page-card {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--shell-card-bg);
  border: var(--shell-card-border);
  border-radius: 14px;
  box-shadow: var(--shell-card-shadow);
  overflow: hidden;
}

.page-card__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  padding: 24px;
  padding-bottom: 32px;
  box-sizing: border-box;
}

.page-card__body::-webkit-scrollbar {
  width: 4px;
}
.page-card__body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.page-inner {
  width: 100%;
  margin: 0 auto;
}

.page-back {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  border-radius: 6px;
}
.page-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin-bottom: 20px;
  box-sizing: border-box;
}
.page-topbar .page-back {
  margin-bottom: 0;
  min-width: 0;
  flex: 1 1 auto;
}
.page-topbar .page-eyebrow {
  margin-bottom: 0;
  flex: 0 0 auto;
  min-width: 6.35rem;
  padding: 0 12px;
  text-align: center;
  box-sizing: border-box;
}
.page-back:hover {
  color: var(--accent);
}
.page-back:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.page-eyebrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  height: var(--tag-height);
  min-height: var(--tag-height);
  margin-bottom: 12px;
  padding: 0 10px 0 8px;
  border-radius: var(--pill-radius);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, #fff);
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
  box-sizing: border-box;
}

.page-title {
  font-family: var(--font-logo);
  font-size: clamp(1.75rem, 4.5vw, 2.25rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 10px;
  min-height: 2.35rem;
}
body:not(.fonts-ready) .page-title {
  visibility: hidden;
}
body.fonts-ready .page-title {
  visibility: visible;
  animation: header-text-in 0.15s ease;
}

.page-lead {
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
  margin-bottom: 28px;
}

/* Empty / spotlight subpages (e.g. ads stub) */
.page-card__body--spotlight {
  display: flex;
  flex-direction: column;
}
.page-spotlight {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 0;
  padding: 20px 0 32px;
  text-align: center;
}
.page-hero-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  margin-bottom: 18px;
  border-radius: 22px;
  background: color-mix(in srgb, var(--accent-light) 50%, transparent);
  color: var(--accent);
}
.page-hero-icon svg {
  width: 42px;
  height: 42px;
}
.page-spotlight .page-lead {
  max-width: 100%;
  margin-bottom: 28px;
}
.page-lead--lines .page-lead__line {
  display: block;
}
.page-spotlight .page-lead--lines .page-lead__line {
  text-wrap: balance;
}
.page-spotlight .btn {
  width: fit-content;
  height: var(--ctrl-h-sm);
  min-height: var(--ctrl-h-sm);
  padding: 0 14px;
  font-size: var(--ctrl-font-sm);
}

/* Plain white spotlight pages (404, ads stub) — no card shell */
body.page-plain,
body.page-plain.page-doc {
  background: var(--surface);
}

body.page-plain .page-shell--plain .page-frame {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: min(var(--list-content-max), 100%);
  max-width: var(--list-content-max);
  margin: 0 auto;
  min-height: 0;
  padding-top: 28px;
}

body.page-plain .page-topbar {
  width: 100%;
  margin-bottom: 20px;
}

.page-spotlight--center {
  flex: 0 0 auto;
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  max-width: 28rem;
  margin: 0 auto;
  padding: 0 0 32px;
  text-align: center;
}

/* ── Flat doc shell — long editorial subpages (Updates, Terms). No card frame. ── */
body.page-doc.page-flat {
  background: var(--surface);
}

body.page-doc.page-flat .page-shell {
  background: var(--surface);
}

body.page-doc.page-flat .page-card {
  flex: none;
  min-height: auto;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}

body.page-doc.page-flat .page-card__body {
  flex: none;
  min-height: auto;
  overflow: visible;
  padding: 28px 0 0;
}

.page-section-label {
  padding: 0 0 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.page-prose {
  max-width: 38rem;
  margin-top: 1.5rem;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
}
.page-prose p {
  margin: 0 0 1rem;
}
.page-prose h2.page-section-label {
  margin: 1.75rem 0 0.5rem;
  padding: 0;
}
.page-prose a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.page-prose ul {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}
.page-prose li {
  margin: 0 0 0.35rem;
}
.page-prose li:last-child {
  margin-bottom: 0;
}

.page-meta {
  margin-top: 2rem;
  font-size: 12px;
  color: var(--muted);
}
.page-meta a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.page-sign {
  margin: 1.25rem 0 1.75rem;
  min-height: 3rem;
}
.page-sign__img {
  display: none;
  width: auto;
  max-width: 200px;
  height: auto;
}
.page-sign__img.is-loaded {
  display: block;
}
.page-sign__text {
  margin: 0;
  font-family: "Instrument Serif", Georgia, serif;
  font-style: italic;
  font-size: 2.75rem;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--text);
}
.page-sign__text.is-hidden {
  display: none;
}
.page-sign-off {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
}
.page-sign-off__line {
  display: block;
}
.page-sign-off__line + .page-sign-off__line {
  margin-top: 0.15rem;
}
.page-sign-off__role {
  white-space: nowrap;
}
.page-sign-off__sep {
  margin: 0 0.35rem;
  color: var(--muted);
}
.page-sign-off a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
@media (max-width: 720px) {
  .page-sign-off__role {
    white-space: normal;
    display: block;
  }
  .page-sign-off__sep--meta {
    display: none;
  }
  .page-sign-off__date {
    display: block;
    margin-top: 0.15rem;
  }
}

.page-divider {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 28px 0;
}

/* ── Updates / changelog ── */
.update-changelog {
  position: relative;
}
.update-month-radio {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.update-changelog .update-month[data-month] {
  display: none;
}
.update-changelog:has(#month-radio-2026-06:checked) [data-month="2026-06"],
.update-changelog:has(#month-radio-2026-05:checked) [data-month="2026-05"] {
  display: block;
}
.update-changelog:has(#month-radio-2026-06:checked) label[for="month-radio-2026-06"],
.update-changelog:has(#month-radio-2026-05:checked) label[for="month-radio-2026-05"] {
  background: var(--segment-active-bg);
  color: var(--segment-active-color);
}
.update-month-nav {
  margin-bottom: 22px;
}
.update-month-nav__track {
  cursor: grab;
  touch-action: pan-x;
}
.update-month-nav__track.list-sort {
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.update-month-nav__track::-webkit-scrollbar {
  display: none;
}
.update-month-nav__track--dragging {
  cursor: grabbing;
  scroll-snap-type: none;
}
.update-month-nav__track .list-sort__btn {
  flex: 0 0 auto;
  scroll-snap-align: start;
  padding: 0 12px;
}
.update-month-pill:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.update-month-count {
  margin: 10px 2px 0;
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.35;
  color: var(--muted);
}
.update-month__title {
  font-family: var(--font-logo);
  font-size: 1.35rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 16px;
}
.update-month__title--sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.update-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 36px;
}
.update-item {
  display: flex;
  flex-direction: column;
}
.update-shot {
  order: 3;
  margin: 0 0 14px;
  aspect-ratio: 944 / 562;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface2);
}
.update-shot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}
.update-item__tags {
  order: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: var(--tag-height);
  margin-bottom: 8px;
}
.update-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: var(--tag-height);
  min-height: var(--tag-height);
  padding: 0 8px;
  border-radius: var(--pill-radius);
  font-family: var(--font-ui);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
  border: 1px solid transparent;
}
.update-tag::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.update-tag--ui {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, #fff);
  border-color: color-mix(in srgb, var(--accent) 22%, transparent);
}
.update-tag--map {
  color: #0d9488;
  background: color-mix(in srgb, #0d9488 10%, #fff);
  border-color: color-mix(in srgb, #0d9488 22%, transparent);
}
.update-tag--data {
  color: #2563eb;
  background: color-mix(in srgb, #2563eb 10%, #fff);
  border-color: color-mix(in srgb, #2563eb 22%, transparent);
}
.update-tag--mobile {
  color: #7c3aed;
  background: color-mix(in srgb, #7c3aed 10%, #fff);
  border-color: color-mix(in srgb, #7c3aed 22%, transparent);
}
.update-tag--new {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, #fff);
  border-color: color-mix(in srgb, var(--accent) 24%, transparent);
}
.update-item__title {
  order: 2;
  font-family: var(--font-logo);
  font-size: clamp(1.2rem, 3.2vw, 1.4rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text);
  margin: 0 0 12px;
}
.update-item__text {
  order: 4;
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--muted);
  margin: 0;
}
.update-item__text a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.update-item__text a:hover {
  color: #145a32;
}

/* ── Form controls (mirrors map search input) ── */
.form-field {
  margin-bottom: 16px;
}
.form-field:last-child {
  margin-bottom: 0;
}

.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}
.form-label .req {
  color: var(--accent2);
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-family: var(--font-ui);
  outline: none;
  transition: border-color 0.15s, outline-color 0.15s;
  accent-color: var(--accent);
}
.form-textarea {
  min-height: 88px;
  resize: vertical;
  line-height: 1.45;
}
.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--accent);
}
.form-input:focus-visible,
.form-textarea:focus-visible,
.form-select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.form-input::placeholder,
.form-textarea::placeholder {
  color: color-mix(in srgb, var(--muted) 70%, transparent);
}
.form-field.is-invalid .form-input,
.form-field.is-invalid .form-textarea,
.form-input.is-invalid,
.form-textarea.is-invalid {
  border-color: var(--accent2);
}
.form-field.is-invalid .form-sector-grid {
  outline: 2px solid color-mix(in srgb, var(--accent2) 45%, transparent);
  outline-offset: 3px;
  border-radius: 12px;
}
.form-field.is-invalid .form-map-wrap {
  border-color: var(--accent2);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent2) 20%, transparent);
}
.form-field.is-invalid .form-map-wrap:focus {
  outline: 2px solid var(--accent2);
  outline-offset: 2px;
}
.form-hint {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.4;
}
.form-error {
  margin-top: 6px;
  font-size: 12px;
  color: var(--accent2);
  display: none;
}
.form-field.is-invalid .form-error {
  display: block;
}

.form-combobox {
  position: relative;
}
.form-suggest {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.1);
  max-height: 220px;
  overflow-y: auto;
}
.form-suggest[hidden] {
  display: none !important;
}
.form-suggest__item {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  line-height: 1.35;
  color: var(--text);
  cursor: pointer;
}
.form-suggest__item:hover,
.form-suggest__item.is-active {
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}
.form-suggest__item mark {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: inherit;
  font-weight: 600;
  padding: 0 1px;
  border-radius: 2px;
}
.form-suggest__empty {
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--muted);
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 480px) {
  .form-row-2 {
    grid-template-columns: 1fr;
  }
}

/* ── Sector picker (bento — reuses map filter pill styles) ── */
.form-sector-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 58px;
  align-content: start;
  gap: 8px;
}
.form-sector-grid .pill--bento {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  font-size: 11px;
}

/* ── Map pin picker ── */
.form-map-wrap {
  border: 1.5px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}
.form-map {
  height: 220px;
  width: 100%;
  background: var(--surface2);
}
.form-map .leaflet-bottom.leaflet-left {
  bottom: 0 !important;
  left: 0 !important;
  top: auto !important;
  right: auto !important;
  margin: 0 0 10px 10px;
  z-index: 400;
}
.form-map .leaflet-bottom.leaflet-left .leaflet-control {
  margin: 0;
}

.form-map-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}
.form-map-meta strong {
  color: var(--text);
  font-weight: 500;
}

.add-form-marker.leaflet-marker-icon {
  background: transparent !important;
  border: none !important;
}
.add-form-marker__dot {
  cursor: grab;
}
.leaflet-dragging .add-form-marker__dot {
  cursor: grabbing;
  transform: scale(1.08);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

/* ── Buttons (implements control rules above) ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--ctrl-h-sm);
  min-height: var(--ctrl-h-sm);
  padding: 0 14px;
  border: none;
  border-radius: var(--ctrl-radius-md);
  font-family: var(--font-ui);
  font-size: var(--ctrl-font-sm);
  font-weight: 600;
  font-synthesis: none;
  font-variation-settings: 'wght' 600;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn--sm {
  height: var(--ctrl-h-sm);
  min-height: var(--ctrl-h-sm);
  padding: 0 14px;
  font-size: var(--ctrl-font-sm);
}
.btn--md {
  height: var(--ctrl-h-sm);
  min-height: var(--ctrl-h-sm);
  padding: 0 12px;
  font-size: var(--ctrl-font-md);
}
.btn--lg {
  height: var(--ctrl-h-lg);
  min-height: var(--ctrl-h-lg);
  padding: 0 14px;
  font-size: var(--ctrl-font-lg);
}
.btn--surface {
  background: var(--surface);
  color: var(--text);
  border: var(--ctrl-border);
}
.btn--surface:focus {
  outline: none;
}
/* Stroke buttons — shared accent hover (ghost + surface) */
.btn--ghost:hover,
.btn--ghost:focus-visible,
.btn--surface:not(.active):not(.btn--active):not(.filter-sheet-btn--active):hover,
.btn--surface:not(.active):not(.btn--active):not(.filter-sheet-btn--active):focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}
.btn--surface.active:not(.filter-sheet-btn),
.btn--surface.btn--active:not(.filter-sheet-btn) {
  border-color: var(--text);
  background: var(--surface);
  color: var(--text);
}
.btn--icon {
  width: var(--ctrl-h-sm);
  min-width: var(--ctrl-h-sm);
  padding: 0;
  font-weight: var(--ctrl-weight);
}
.btn--primary {
  background: var(--primary-grad);
  color: #fff;
  border: 1.5px solid transparent;
  font-weight: var(--ctrl-weight-active);
}
.btn--primary:hover {
  background: var(--primary-grad-pressed);
  color: #fff;
}
.btn--primary:active {
  background: var(--primary-grad-pressed);
}
.btn--secondary {
  background: var(--text);
  color: #fff;
  border: none;
  box-shadow: none;
}
.btn--secondary:hover {
  background: #000;
}
.btn--ghost {
  background: transparent;
  color: var(--muted);
  border: var(--btn-border);
  box-shadow: none;
}
.btn--block {
  width: 100%;
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn svg,
.btn .phosphor-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Filter btn — sector pastel when active (overrides btn--surface.btn--active) */
.btn.btn--surface.filter-sheet-btn.filter-sheet-btn--active {
  border-color: color-mix(in srgb, var(--pill-accent, var(--accent)) 24%, transparent);
  background: color-mix(in srgb, var(--pill-accent, var(--accent)) 12%, #fff);
  color: var(--pill-accent, var(--accent));
}
.btn.btn--surface.filter-sheet-btn.filter-sheet-btn--active:hover,
.btn.btn--surface.filter-sheet-btn.filter-sheet-btn--active:focus-visible {
  border-color: color-mix(in srgb, var(--pill-accent, var(--accent)) 40%, transparent);
  background: color-mix(in srgb, var(--pill-accent, var(--accent)) 18%, #fff);
  color: var(--pill-accent, var(--accent));
}
.btn.btn--surface.filter-sheet-btn.filter-sheet-btn--active svg,
.btn.btn--surface.filter-sheet-btn.filter-sheet-btn--active .phosphor-icon {
  color: currentColor;
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 28px;
}
.form-actions .btn--primary {
  order: -1;
}

@media (min-width: 769px) {
  .form-actions {
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
  }
  .form-actions .btn--primary,
  .form-actions .btn--surface {
    order: 0;
  }
  .form-actions .btn--block {
    width: auto;
  }
  .form-actions .btn--primary,
  .form-actions .btn--surface {
    flex: 0 0 auto;
  }
}

/* ── Success state ── */
.form-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 0 8px;
}
.form-success[hidden] {
  display: none !important;
}
.form-success__icon {
  margin-bottom: 18px;
}
.form-success__title {
  margin-bottom: 10px;
}
.form-success__text {
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
  margin-bottom: 0;
  max-width: 36em;
}
.form-success__actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(100%, 280px);
  margin-top: 24px;
}
.form-success__back {
  width: auto;
  align-self: center;
}
.form-success__share-label,
.form-success__share {
  width: 100%;
}
.form-success__share-label {
  margin: 16px 0 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}
.form-success__share {
  display: flex;
  gap: 8px;
  width: 100%;
}
.form-success__share-btn {
  flex: 1 1 0;
  min-width: 0;
}
.form-success .btn {
  height: var(--ctrl-h-sm);
  min-height: var(--ctrl-h-sm);
  padding: 0 14px;
  font-size: var(--ctrl-font-sm);
}

/* Dev preview switcher — localhost or ?preview= on /add/ */
.form-preview-bar {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 1200;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: var(--ctrl-border);
  border-radius: var(--ctrl-radius-md);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}
.form-preview-bar__label {
  padding: 0 8px 0 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.form-preview-bar__btn {
  height: var(--ctrl-h-sm);
  min-height: var(--ctrl-h-sm);
  padding: 0 10px;
  border: none;
  border-radius: calc(var(--ctrl-radius-md) - 2px);
  background: transparent;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.form-preview-bar__btn:hover,
.form-preview-bar__btn:focus-visible {
  color: var(--text);
  background: var(--surface2);
}
.form-preview-bar__btn.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}
.form-preview-bar__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ── Responsive nav labels ── */
.nav-label--compact {
  display: none;
}
@media (max-width: 420px) {
  .nav-label--full {
    display: none;
  }
  .nav-label--compact {
    display: inline;
  }
  .header-nav-panel .nav-label--full {
    display: inline;
  }
  .header-nav-panel .nav-label--compact {
    display: none;
  }
}

@media (max-width: 720px) {
  .header-menu-btn,
  .header-menu-btn.btn {
    display: inline-flex;
  }
  .site-header:has(.header-nav) .logo {
    max-width: calc(100% - var(--ctrl-h-sm) - 12px);
  }
  .header-right:has(.header-nav) {
    gap: 8px;
  }
  .site-header.is-menu-open {
    z-index: 1002;
  }
  .header-nav-panel {
    display: none;
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    z-index: 1;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
    padding:
      6px
      max(12px, env(safe-area-inset-right))
      10px
      max(12px, env(safe-area-inset-left));
    box-sizing: border-box;
  }
  .site-header.is-menu-open .header-nav-panel {
    display: block;
  }
  .header-nav-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    top: var(--header-h);
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    background: rgba(22, 22, 22, 0.18);
    pointer-events: auto;
  }
  .header-nav-panel .header-nav {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    width: 100%;
  }
  .header-nav-panel .header-nav .header-nav__link {
    width: 100%;
    min-height: 48px;
    padding: 14px 12px;
    font-size: 15px;
    border-radius: var(--ctrl-radius-md);
  }
  .header-nav-panel .header-nav .header-nav__link:hover,
  .header-nav-panel .header-nav .header-nav__link:focus-visible,
  .header-nav-panel .header-nav .header-nav__link[aria-current="page"] {
    background: var(--segment-tray-bg);
    color: var(--text);
  }
  .header-nav-panel .header-nav .header-cta {
    margin-top: 4px;
    width: 100%;
    justify-content: center;
  }
  .header-nav-panel .header-nav .header-cta .header-cta__label--full {
    display: inline;
  }
  .header-nav-panel .header-nav .header-cta .header-cta__label--short {
    display: none;
  }
  .header-nav-panel .nav-label--full {
    display: inline;
  }
  .header-nav-panel .nav-label--compact {
    display: none;
  }
}

/* ========== MOBILE (subpages + header nav) ========== */
@media (max-width: 768px) {
  .site-header:has(.header-nav) {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    height: var(--header-h);
    min-height: var(--header-h);
  }

  .site-header:has(.header-nav) .logo {
    overflow: hidden;
    min-width: 0;
  }

  .site-header:has(.header-nav) .logo-text {
    overflow: hidden;
    text-overflow: ellipsis;
    padding-bottom: 0.2em;
    margin-bottom: -0.2em;
  }

  .header-nav {
    gap: 9px;
    flex-shrink: 0;
  }

  body.page-doc.page-flat,
  body.page-doc.page-plain {
    -webkit-overflow-scrolling: touch;
  }

  .page-shell {
    padding:
      var(--content-column-inset)
      max(10px, env(safe-area-inset-right))
      calc(var(--content-column-inset) + env(safe-area-inset-bottom, 0px))
      max(10px, env(safe-area-inset-left));
  }

  .page-frame {
    width: 100%;
  }

  .page-card__body {
    padding: 20px 16px 28px;
    scrollbar-gutter: stable;
  }

  .page-topbar {
    margin-bottom: 16px;
  }
  .page-back {
    margin-bottom: 16px;
    min-height: 44px;
    align-items: center;
  }
  .page-topbar .page-back {
    margin-bottom: 0;
  }

  .page-title {
    font-size: 1.65rem;
  }

  .page-lead {
    font-size: 13px;
    margin-bottom: 22px;
  }

  .page-divider {
    margin: 22px 0;
  }

  /* iOS Safari zooms focused inputs below 16px */
  .form-input,
  .form-textarea,
  .form-select {
    font-size: 16px;
    min-height: 44px;
  }
  .form-textarea {
    min-height: 96px;
  }

  .form-sector-grid {
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 54px;
    gap: 6px;
  }
  .form-sector-grid .pill--bento {
    height: 54px;
    min-height: 54px;
    max-height: 54px;
    padding: 8px 4px;
    font-size: 10px;
    line-height: 1.2;
  }
  .form-sector-grid .pill--bento .pill__icon svg {
    width: 16px;
    height: 16px;
  }

  .form-map {
    height: min(52vw, 260px);
    min-height: 220px;
  }

  .form-map-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    font-size: 11px;
    line-height: 1.35;
  }

  .form-actions .btn:not(.btn--sm) {
    min-height: 44px;
    height: auto;
    padding: 12px 18px;
  }

  .form-actions {
    margin-top: 24px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* Unified subpage shells — override legacy framed mobile rules above */
  body.page-doc.page-flat .page-shell,
  body.page-plain .page-shell {
    flex: 1 0 auto;
    overflow: visible;
    background: var(--surface);
    padding:
      0
      max(10px, env(safe-area-inset-right))
      calc(32px + env(safe-area-inset-bottom, 0px))
      max(10px, env(safe-area-inset-left));
  }

  body.page-doc.page-flat .page-frame {
    flex: none;
    min-height: auto;
    width: 100%;
  }

  body.page-doc.page-flat .page-card {
    background: transparent;
    border: none;
    box-shadow: none;
    overflow: visible;
  }

  body.page-doc.page-flat .page-card__body {
    flex: none;
    min-height: auto;
    overflow: visible;
    padding: 20px 0 0;
  }

  body.page-plain .page-shell--plain .page-frame {
    flex: none;
    width: min(var(--list-content-max), 100%);
    max-width: var(--list-content-max);
    margin: 0 auto;
    padding-top: 20px;
    align-items: stretch;
  }
}
