
  :root {
    --panel-bg: #ffffff;
    --border: #d8d2c4;
    --text: #2b2a26;
    --muted: #7a766c;
    --accent: #2e6b34;
    --easy: #2e8b57;
    --moderate: #2a6fb0;
    --hard: #c0392b;
  }
  * { box-sizing: border-box; }
  /* iOS Dynamic Type: the -apple-system-body font shorthand resolves the root
     font-size to the user's current Dynamic Type body size inside WKWebView, so
     `rem` (which everything below is written in) scales with it. The shorthand
     also resets font-family/weight/style/line-height on <html>, so <body> keeps
     declaring the family stack — descendants inherit from there, unchanged. */
  html { font: -apple-system-body; }
  body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    /* body text size tracks the root (which tracks iOS Dynamic Type). Fixed chrome
       is capped via min() lower down so nav/buttons don't balloon. */
    font-size: 1rem;
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  /* Tabs */
  header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 16px;
    background: #1f3a24;
    color: #f4f1e8;
    min-height: 52px;
    flex-shrink: 0;
    /* Wrap so the region <select> can never be pushed off-screen at
       accessibility-XXXL. At default text sizes everything fits on one row and
       nothing wraps; once the capped title/nav grow wide enough to exceed the
       viewport, #region-select (and/or the nav) drop onto a second/third row
       instead of being clipped. min-height (not height) lets the bar grow tall
       enough to show every wrapped row. */
    flex-wrap: wrap;
  }
  /* Cap fixed chrome so large Dynamic Type sizes don't blow up the title bar:
     text scales with rem but stops at this ceiling. On wide screens header h1
     is 17px → min(1.0625rem, 22px). */
  header h1 { font-size: min(1.0625rem, 22px); margin: 0 12px 0 0; font-weight: 600; }
  nav { display: flex; gap: 4px; min-height: 100%; }
  nav button {
    background: none;
    border: none;
    color: #c9d4c5;
    /* nav buttons live in fixed chrome: capped at 20px (no bigger than today's
       comfortable default, even at accessibility-XXXL). */
    font-size: min(0.875rem, 20px);
    padding: 0 14px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    min-height: 100%;
  }
  nav button.active {
    color: #fff;
    border-bottom-color: #8fc98f;
    font-weight: 600;
  }
  nav button:hover { color: #fff; }
  #region-select {
    margin-left: auto;
    background: #2b4a31;
    color: #f4f1e8;
    border: 1px solid #3f6b45;
    border-radius: 6px;
    padding: 5px 8px;
    /* fixed chrome in the header — capped at 18px so the select can't push the bar huge. */
    font-size: min(0.8125rem, 18px);
    cursor: pointer;
  }

  .tab { flex: 1; display: none; min-height: 0; }
  .tab.active { display: flex; }

  /* Map tab layout. .map-card wraps #map, so the card is the flex child that
     has to grow; #map only fills it. The tab itself must be positioned: it is
     what anchors the floating map chrome (#trail-search, #route-toolbar), which
     otherwise resolves against the viewport and lands on top of the header,
     swallowing clicks on the Map and Planner nav buttons. */
  #tab-map.active { position: relative; }
  .map-card { display: flex; flex: 1; min-width: 0; }
  #map { flex: 1; }
  aside {
    width: 300px;
    flex-shrink: 0;
    background: var(--panel-bg);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
  }
  aside section { padding: 14px 16px; border-bottom: 1px solid var(--border); }
  aside h2 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
    margin: 0 0 10px;
  }

  .layer-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 5px 0;
    cursor: pointer;
    font-size: 0.875rem;
    user-select: none;
  }
  .layer-row input { accent-color: var(--accent); }
  .swatch {
    width: 18px; height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.25);
    flex-shrink: 0;
  }
  .swatch.hatched {
    background: repeating-linear-gradient(45deg, #b9b1a2 0 2px, transparent 2px 5px);
  }

  #land-status, #cad-status, #trail-status, #poi-status, #camp-status, #offroad-status { font-size: 0.625rem; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--muted); }
  #land-status.loading, #cad-status.loading, #trail-status.loading, #poi-status.loading, #camp-status.loading, #offroad-status.loading { color: #b8860b; }
  #land-status.error, #cad-status.error, #trail-status.error, #poi-status.error, #camp-status.error, #offroad-status.error { color: var(--hard); }
  /* Serving previously-fetched (last-good) data because the live source is unreachable. */
  #land-status.stale, #cad-status.stale, #trail-status.stale, #poi-status.stale, #camp-status.stale, #offroad-status.stale, #slope-status.stale, #radar-status.stale { color: #b8860b; }
  /* Budget-blocked on a satellite link — informational, not an error: texts and
     alerts still work, bulk/tile data is paused and served from cache. */
  #land-status.satellite, #cad-status.satellite, #trail-status.satellite, #poi-status.satellite, #camp-status.satellite, #offroad-status.satellite, #slope-status.satellite, #radar-status.satellite { color: var(--moderate); }
  .leg-line { display: inline-block; width: 20px; height: 0; vertical-align: middle; flex-shrink: 0; }
  .name-popup .leaflet-popup-content { margin: 8px 12px; font-size: 0.8125rem; line-height: 1.35; }
  .name-popup .leaflet-popup-content small { color: var(--muted); }

  /* Cap Leaflet map chrome — vendor/leaflet/leaflet.css declares
     `.leaflet-container { font-size: 0.75rem }`, which tracked 12px while the
     root was pinned at 16px but now inherits the Dynamic Type root and swells
     to ~40px at accessibility-XXXL, covering the map. The attribution, layer
     labels, and popup content all inherit from this container, so a ceiling on
     it alone restores them. Map chrome overlaying a map, not scrollable text,
     so it is capped like the other chrome — `min(<rem>, 12px)` holds it at the
     original size even at accessibility-XXXL, and 12px never falls below the
     11–12px attribution floor OSM/ODbL needs. The em-based descendants
     (1.08333em → 13px) follow from the capped 12px container, unchanged. Do
     not edit the vendored CSS — styles.css loads after it. */
  .leaflet-container { font-size: min(0.75rem, 12px); }
  /* `.leaflet-popup-content` is shadowed for name popups above; the generic
     rule (trail/land popups) inherits the capped 12px container, and its own
     1.08333em resolves against that cap → 13px, as before. No separate
     ceiling needed. */

  /* Trails tab — 50-state directory */
  #tab-trails { display: none; overflow-y: auto; flex-direction: column; padding: 22px 26px; }
  #tab-trails.active { display: flex; }
  .trails-intro { max-width: 760px; margin-bottom: 18px; }
  .trails-intro h2 { margin: 0 0 6px; font-size: 1.25rem; }
  .trails-intro p { margin: 0; color: var(--muted); font-size: 0.875rem; line-height: 1.5; }
  #state-search {
    margin: 4px 0 18px; padding: 9px 12px; font-size: 0.875rem; width: 100%; max-width: 380px;
    border: 1px solid var(--border); border-radius: 8px;
  }
  .state-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; max-width: 1100px; }
  .state-card {
    text-align: left; background: var(--panel-bg); border: 1px solid var(--border); border-radius: 10px;
    padding: 11px 13px; cursor: pointer; transition: border-color .12s, box-shadow .12s;
  }
  .state-card:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
  .state-card .sc-name { font-weight: 600; font-size: 0.875rem; display: flex; justify-content: space-between; align-items: baseline; }
  .state-card .sc-abbr { color: var(--muted); font-size: 0.6875rem; font-weight: 500; }
  .state-card .sc-area { color: #4d4a42; font-size: 0.75rem; margin-top: 3px; }

  .legend-row { display: flex; align-items: center; gap: 8px; font-size: 0.8125rem; padding: 3px 0; }
  .dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.3); }

  /* Trail detail panel */
  #detail { display: none; }
  #detail.open { display: block; }
  #detail h3 { margin: 0 0 2px; font-size: 1rem; }
  #detail .diff-badge {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 700;
    color: #fff;
    border-radius: 10px;
    padding: 2px 9px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 10px;
  }
  .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin-bottom: 12px; }
  .stat .label { font-size: 0.6875rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
  .stat .value { font-size: 0.9375rem; font-weight: 600; }
  #detail p.desc { font-size: 0.8125rem; color: #4d4a42; line-height: 1.45; margin: 0 0 14px; }
  /* Access (road + parking) block */
  .access-block { border: 1px solid var(--line, #e2ded3); border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; background: #faf9f5; }
  .access-row { display: flex; gap: 10px; align-items: flex-start; }
  .access-row + .access-row { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line, #e9e5db); }
  .access-ico { font-size: 1.5rem; line-height: 1; flex: 0 0 auto; width: 26px; text-align: center; }
  .access-lab { font-size: 0.6875rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
  .access-val { font-size: 0.8125rem; color: #3a382f; line-height: 1.4; margin-top: 1px; }
  .access-link { display: inline-block; margin-top: 5px; font-size: 0.75rem; font-weight: 600; color: var(--accent); text-decoration: none; cursor: pointer; }
  .access-link:hover { text-decoration: underline; }
  /* Emergency block */
  .emergency-block { border: 1px solid #e7c3bd; border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; background: #fcf3f1; }
  .emergency-h { font-size: 0.75rem; font-weight: 700; color: #a23b2c; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
  .emergency-h span { font-weight: 500; text-transform: none; color: var(--muted); letter-spacing: 0; }
  a.emergency-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; text-decoration: none; color: inherit; padding: 6px 0; border-top: 1px solid #f0d8d3; }
  a.emergency-item:first-of-type { border-top: none; }
  .emergency-item .ei-lab { font-size: 0.75rem; color: #4d4a42; line-height: 1.3; }
  .emergency-item .ei-tel { font-size: 0.875rem; font-weight: 700; color: var(--accent); white-space: nowrap; }
  a.emergency-item.primary { background: #fbe4df; margin: 0 -6px; padding: 8px 6px; border-radius: 6px; border-top: none; }
  a.emergency-item.primary .ei-tel { color: #c0392b; font-size: 1rem; }
  .emergency-note { font-size: 0.6875rem; color: var(--muted); line-height: 1.4; margin-top: 8px; }
  .directions-btn {
    display: block;
    text-align: center;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 10px;
    border-radius: 8px;
  }
  .directions-btn:hover { background: #245428; }
  #detail-close {
    float: right;
    border: none;
    background: none;
    font-size: 1.125rem;
    color: var(--muted);
    cursor: pointer;
    line-height: 1;
  }
  .placeholder {
    margin: auto;
    color: var(--muted);
    font-size: 0.9375rem;
  }

  /* Add-to-plan button in detail panel */
  .plan-btn {
    display: block; width: 100%; margin-top: 8px;
    text-align: center; background: #fff; color: var(--accent);
    border: 1px solid var(--accent); border-radius: 8px;
    font-size: 0.875rem; font-weight: 600; padding: 9px; cursor: pointer;
  }
  .plan-btn:hover { background: #f0f6f0; }
  .plan-btn.added { background: var(--accent); color: #fff; border-color: var(--accent); }

  /* Planner tab */
  #tab-planner { display: none; overflow-y: auto; flex-direction: column; padding: 22px 26px; }
  #tab-planner.active { display: flex; }
  .planner-wrap { max-width: 820px; width: 100%; }
  .planner-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 4px; }
  .planner-head h2 { margin: 0; font-size: 1.25rem; }
  #plan-clear {
    background: none; border: none; color: var(--hard); font-size: 0.8125rem; cursor: pointer; padding: 4px;
  }
  #plan-clear:hover { text-decoration: underline; }
  .planner-sub { color: var(--muted); font-size: 0.875rem; margin: 0 0 18px; }

  .plan-totals {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
    background: #f6f4ee; border: 1px solid var(--border); border-radius: 12px;
    padding: 14px 16px; margin-bottom: 18px;
  }
  .plan-totals .pt { text-align: center; }
  .plan-totals .pt-val { font-size: 1.375rem; font-weight: 700; color: var(--accent); }
  .plan-totals .pt-lab { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-top: 2px; }

  .plan-list { display: flex; flex-direction: column; gap: 10px; }
  .plan-item {
    display: flex; align-items: center; gap: 12px;
    border: 1px solid var(--border); border-radius: 10px; padding: 11px 14px; background: #fff;
  }
  .plan-item .pi-bar { width: 5px; align-self: stretch; border-radius: 3px; flex-shrink: 0; }
  .plan-item .pi-main { flex: 1; min-width: 0; }
  .plan-item .pi-name { font-weight: 600; font-size: 0.9375rem; }
  .plan-item .pi-meta { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
  .plan-item .pi-remove {
    border: none; background: none; color: var(--muted); font-size: 1.125rem; cursor: pointer; line-height: 1; padding: 4px;
  }
  .plan-item .pi-remove:hover { color: var(--hard); }
  .plan-empty { color: var(--muted); font-size: 0.9375rem; padding: 30px 0; text-align: center; }
  #wp-export, #wp-import { background: none; border: none; color: var(--accent); font-size: 0.8125rem; font-weight: 600; cursor: pointer; padding: 4px; }
  #wp-export:hover, #wp-import:hover { text-decoration: underline; }
  #wp-export:disabled { color: var(--muted); cursor: default; text-decoration: none; }
  .plan-item .pi-edit { border: none; background: none; color: var(--muted); font-size: 0.9375rem; cursor: pointer; line-height: 1; padding: 4px; }
  .plan-item .pi-edit:hover { color: var(--accent); }
  .plan-item .pi-name.clickable { cursor: pointer; }

  /* Trip kit: hike type, gear, hazards, rig */
  .trip-kit { margin-top: 26px; border-top: 1px solid var(--border); padding-top: 20px; }
  .kit-types { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
  .kit-type {
    border: 1px solid var(--border); background: #fff; border-radius: 20px;
    padding: 7px 15px; font-size: 0.8125rem; font-weight: 600; color: var(--text); cursor: pointer;
  }
  .kit-type:hover { border-color: var(--accent); }
  .kit-type.active { background: var(--accent); color: #fff; border-color: var(--accent); }
  .kit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
  .kit-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; background: #fff; }
  .kit-card h3 { margin: 0 0 10px; font-size: 0.875rem; display: flex; align-items: baseline; gap: 6px; }
  .kit-tag { font-size: 0.6875rem; font-weight: 600; color: var(--muted); background: #f0eee7; border-radius: 10px; padding: 2px 8px; }
  .gear-row { display: flex; align-items: flex-start; gap: 8px; font-size: 0.8125rem; padding: 3px 0; cursor: pointer; }
  .gear-row input { accent-color: var(--accent); margin-top: 2px; }
  .haz-group { margin-bottom: 9px; }
  .haz-group .haz-h { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 3px; }
  .haz-list { display: flex; flex-wrap: wrap; gap: 5px; }
  .haz-chip { font-size: 0.75rem; background: #fbeee9; color: #9a3b22; border: 1px solid #f0d3c8; border-radius: 8px; padding: 2px 8px; }
  .haz-chip.plant { background: #eef6ea; color: #3f6b2e; border-color: #d5e8cb; }
  .haz-chip.cond { background: #eef2f8; color: #355a86; border-color: #d2def0; }
  .rig-line { font-size: 0.8125rem; margin: 4px 0; }
  .rig-line .rl-lab { color: var(--muted); }
  .rig-list { margin: 6px 0 0; padding-left: 18px; font-size: 0.8125rem; line-height: 1.5; }
  .kit-note { font-size: 0.6875rem; color: var(--muted); margin-top: 12px; line-height: 1.4; }

  /* Permits & passes */
  .permit-card { margin-top: 14px; }
  .permit-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
  .permit-row:last-child { border-bottom: none; }
  .permit-main { flex: 1; min-width: 0; }
  .permit-title { font-weight: 600; font-size: 0.875rem; }
  .permit-desc { font-size: 0.75rem; color: var(--muted); margin-top: 2px; line-height: 1.4; }
  .permit-link {
    flex-shrink: 0; background: var(--accent); color: #fff; text-decoration: none;
    font-size: 0.8125rem; font-weight: 600; padding: 7px 13px; border-radius: 8px; white-space: nowrap;
  }
  .permit-link:hover { background: #245428; }

  .trail-marker {
    width: 18px; height: 18px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.45);
  }

  /* Trailhead / terminus endpoint badges */
  .trail-end { background: none; border: none; }
  .te {
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8125rem; line-height: 1;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  }
  .te-head { border: 2px solid var(--easy); }    /* trailhead — green ring */
  .te-end  { border: 2px solid var(--hard); }    /* terminus  — red ring */
  .te-park { border: 2px solid #1f6feb; font-weight: 700; color: #1f6feb; font-size: 0.875rem; } /* parking — blue ring */
  .te-wp   { border: 2px solid #b8860b; }          /* user waypoint — gold ring */

  /* ---- Mobile / native (Capacitor) polish ---- */
  /* Respect notches & status bars on both platforms */
  header { padding-top: env(safe-area-inset-top); min-height: calc(52px + env(safe-area-inset-top)); }

  @media (max-width: 760px), (pointer: coarse) {
    /* overflow:hidden is deliberately NOT carried into the wrapped layout: with
       flex-wrap on header, a clipping overflow would hide the wrapped
       #region-select row — exactly the off-screen regression round C fixes. The
       horizontal bound the old overflow:hidden provided is re-established by
       #region-select { max-width: 38vw } below (and by flex-wrap itself, which
       moves any overflow onto a new row instead of letting it spill). min-height
       (not height) lets the bar grow tall enough to fit every wrapped row. */
    header { gap: 6px; padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
    header h1 { font-size: min(0.9375rem, 22px); margin-right: 2px; white-space: nowrap; flex-shrink: 0; }
    nav { gap: 0; }
    nav button { padding: 0 12px; font-size: min(0.8125rem, 20px); min-height: 44px; }   /* 44px = min touch target */
    #region-select { padding: 7px 8px; font-size: min(0.75rem, 18px); max-width: 38vw; }

    /* Map tab becomes vertical: full-bleed map + draggable bottom panel */
    #tab-map.active { flex-direction: column; position: relative; }
    #map { flex: 1; min-height: 40vh; }
    aside {
      width: 100%;
      max-height: 45vh;
      border-left: none;
      border-top: 1px solid var(--border);
      box-shadow: 0 -4px 18px rgba(0,0,0,0.12);
      -webkit-overflow-scrolling: touch;
      padding-bottom: env(safe-area-inset-bottom);
    }
    /* Drag handle affordance on the panel */
    aside::before {
      content: ""; display: block; width: 38px; height: 4px; border-radius: 2px;
      background: var(--border); margin: 8px auto 2px;
    }
    .layer-row { padding: 9px 0; font-size: 0.9375rem; }       /* easier to tap */
    .layer-row input { width: 20px; height: 20px; }

    /* Trails & Planner tabs: comfortable phone padding + safe areas */
    #tab-trails, #tab-planner {
      padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
    }
    .state-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

    /* Detail card: float as an opaque bottom sheet over everything */
    #detail.open {
      position: fixed; left: 0; right: 0; bottom: 0; z-index: 1200;
      background: var(--panel-bg);          /* opaque — was showing the layer list through it */
      border-top: 1px solid var(--border);
      border-radius: 16px 16px 0 0;
      box-shadow: 0 -6px 24px rgba(0,0,0,0.3);
      padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
      max-height: 72vh; overflow-y: auto;
    }
  }

  /* ===== Membership / paywall ===== */
  .plan-badge { display:inline-flex; align-items:center; gap:5px; font-size: 0.6875rem; font-weight:700;
    padding:3px 9px; border-radius:999px; letter-spacing:.02em; vertical-align:middle; }
  .plan-badge.free  { background:#e7eae3; color:#4a5247; }
  .plan-badge.trial { background:#fde9c8; color:#8a5a12; }
  .plan-badge.paid  { background:#1f3a24; color:#bfe6c6; }
  .lock-pill { font-size: 0.6875rem; font-weight:700; color:#8a5a12; background:#fde9c8;
    border-radius:999px; padding:1px 7px; margin-left:6px; }
  .membership-card { border:1px solid var(--line,#dfe3da); border-radius:12px; padding:16px 18px;
    margin:0 0 20px; background:#fafbf8; }
  .membership-card h2 { margin:0 0 6px; font-size: 1.125rem; display:flex; align-items:center; gap:10px; }
  .membership-card .mc-sub { color:var(--muted); font-size: 0.8125rem; margin:0 0 12px; line-height:1.5; }
  .membership-card .mc-actions { display:flex; flex-wrap:wrap; gap:10px; }
  .btn-paid { padding:10px 16px; border:none; border-radius:9px; font-size: 0.875rem; font-weight:700;
    cursor:pointer; background:#2e6b34; color:#fff; }
  .btn-paid.secondary { background:#fff; color:#2e6b34; border:1.5px solid #2e6b34; }
  .btn-paid:disabled { opacity:.5; cursor:default; }
  .feature-list { list-style:none; margin:10px 0 0; padding:0; }
  .feature-list li { display:flex; gap:9px; align-items:flex-start; font-size: 0.84375rem;
    padding:5px 0; color:#2b3329; line-height:1.45; }
  .feature-list li .fi { flex:0 0 auto; width:18px; text-align:center; }

  /* Paywall modal */
  #paywall { position:fixed; inset:0; z-index:5000; display:none; align-items:center;
    justify-content:center; background:rgba(20,28,20,.55); padding:18px;
    padding-bottom:calc(18px + env(safe-area-inset-bottom)); }
  #paywall.open { display:flex; }
  .pw-card { background:#fff; border-radius:16px; max-width:430px; width:100%;
    max-height:88vh; overflow-y:auto; box-shadow:0 18px 50px rgba(0,0,0,.35);
    padding:24px 24px 20px; }
  .pw-card h2 { margin:0 0 4px; font-size: 1.3125rem; color:#1f3a24; }
  .pw-card .pw-feat { color:var(--muted); font-size: 0.84375rem; margin:0 0 4px; }
  .pw-card .pw-hi { font-weight:700; color:#2e6b34; }
  .pw-price { font-size: 0.8125rem; color:var(--muted); margin:14px 0 4px; }
  .pw-error { font-size: 0.8125rem; color:#b3261e; background:rgba(179,38,30,0.08);
    border:1px solid rgba(179,38,30,0.25); border-radius:8px; padding:8px 10px;
    margin:8px 0 0; line-height:1.4; }
  .pw-error[hidden] { display:none; }
  .pw-actions { display:flex; flex-direction:column; gap:10px; margin-top:16px; }
  .pw-actions .btn-paid { width:100%; }
  .pw-dismiss { background:none; border:none; color:var(--muted); font-size: 0.8125rem;
    cursor:pointer; margin-top:6px; width:100%; padding:6px; }
  .pw-note { font-size: 0.71875rem; color:var(--muted); text-align:center; margin:10px 0 0; line-height:1.4; }
  .pw-legal { font-size: 0.71875rem; text-align:center; margin:8px 0 0; }
  .pw-legal a { color:var(--accent); text-decoration:underline; }

  /* ===== Multi-day planner ===== */
  .day-card { border:1px solid var(--line,#dfe3da); border-radius:12px; margin:0 0 14px; background:#fff; overflow:hidden; }
  .day-card.active { border-color:#2e6b34; box-shadow:0 0 0 1px #2e6b34 inset; }
  .day-head { display:flex; align-items:center; gap:10px; padding:11px 14px; background:#f3f6f1; cursor:pointer; }
  .day-card.active .day-head { background:#e6f0e6; }
  .day-head .day-title { font-weight:700; font-size: 0.9375rem; flex:1; border:none; background:transparent; color:#22301f; padding:2px 4px; border-radius:6px; }
  .day-head .day-title:focus { background:#fff; outline:1.5px solid #2e6b34; }
  .day-head .day-active-tag { font-size: 0.625rem; font-weight:700; color:#2e6b34; background:#cfe6cf; border-radius:999px; padding:2px 7px; }
  .day-head .day-del { border:none; background:none; color:var(--muted); font-size: 1rem; cursor:pointer; line-height:1; padding:4px; }
  .day-head .day-del:hover { color:#c0392b; }
  .day-totals { display:flex; gap:14px; padding:6px 14px 0; font-size: 0.71875rem; color:var(--muted); }
  .day-totals b { color:#2b3329; }
  .day-body { padding:8px 14px 12px; }
  .day-empty { font-size: 0.78125rem; color:var(--muted); padding:8px 2px; }
  .trip-meta-row { display:flex; align-items:center; flex-wrap:wrap; gap:10px; margin:0 0 14px; }
  .trip-meta-row label { font-size: 0.8125rem; color:var(--muted); font-weight:600; }
  .trip-meta-row input[type=date] { padding:8px 10px; border:1px solid var(--line,#dfe3da); border-radius:8px; font-size: 0.875rem; background:#fff; }
  .trip-meta-row #plan-share { margin-left:auto; padding:9px 14px; }
  .pi-route .pi-bar { background:#1f6feb !important; }
  .pi-move { border:none; background:#eef1ec; color:#3a463a; font-size: 0.6875rem; border-radius:6px; padding:3px 6px; cursor:pointer; }

  /* ===== Route drawing toolbar (on the map) ===== */
  #route-toolbar { position:absolute; left:50%; transform:translateX(-50%);
    top:12px; z-index:1200; display:none;
    background:#1f3a24; color:#fff; border-radius:12px; padding:10px 12px;
    box-shadow:0 6px 22px rgba(0,0,0,.35); max-width:calc(100vw - 24px); }
  #route-toolbar.open { display:block; }
  #route-toolbar .rt-row { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
  /* Route toolbar is floating map chrome (position:absolute over #map), the
     same category as the Leaflet attribution and the header bar — not readable
     text in a scrollable pane. Cap each text size with min() so Dynamic Type
     stops it from covering the map; .rt-row already wraps, so nothing clips. */
  #route-toolbar .rt-stat { font-size: min(0.75rem, 12px); opacity:.9; margin-right:4px; }
  #route-toolbar button { border:none; border-radius:8px; padding:7px 11px; font-size: min(0.8125rem, 13px); font-weight:600; cursor:pointer; }
  #route-toolbar .rt-finish { background:#2e6b34; color:#fff; }
  #route-toolbar .rt-undo, #route-toolbar .rt-cancel { background:#3a5640; color:#dfeede; }
  #route-toolbar .rt-snap { display:flex; align-items:center; gap:5px; font-size: min(0.75rem, 12px); cursor:pointer; }
  #route-toolbar .rt-hint { font-size: min(0.6875rem, 11px); opacity:.8; margin-top:6px; }

  /* ===== Trail name search (on the map) ===== */
  #trail-search { position:absolute; z-index:1100; left:12px;
    top:12px; width:min(330px, calc(100vw - 90px)); }
  #trail-search .ts-box { display:flex; align-items:center; background:#fff; border-radius:10px;
    box-shadow:0 2px 10px rgba(0,0,0,.22); border:1px solid #cfcabd; overflow:hidden; }
  /* The search box is floating map chrome (position:absolute over #map), not a
     scrollable pane — cap its text with min() so Dynamic Type doesn't enlarge
     it to the full 53px root (which truncates the "Search trails by name…"
     placeholder to "Search trails"). The caps below are chosen to keep that
     placeholder intact at the 312px box width at root=53px / 402px viewport.
     The results dropdown (#ts-results) is deliberately NOT capped here — it is
     a scrollable list of trail names (content), like the aside/planner, and
     keeps scaling fully. */
  #trail-search .ts-box span.ts-ico { padding:0 4px 0 10px; font-size: min(0.875rem, 14px); color:#5a6157; }
  #trail-search input { flex:1; border:none; outline:none; padding:11px 8px; font-size: min(0.875rem, 14px); background:transparent; }
  #trail-search .ts-clear { border:none; background:none; font-size: min(1rem, 16px); color:#8a8a82; cursor:pointer; padding:0 10px; display:none; }
  #ts-results { margin-top:6px; background:#fff; border-radius:10px; box-shadow:0 6px 22px rgba(0,0,0,.25);
    max-height:min(56vh, 420px); overflow-y:auto; display:none; }
  #ts-results.open { display:block; }
  .ts-group { font-size: 0.625rem; font-weight:700; letter-spacing:.04em; text-transform:uppercase;
    color:#7a8174; padding:8px 12px 4px; }
  .ts-item { display:flex; gap:8px; align-items:flex-start; padding:9px 12px; cursor:pointer; border-top:1px solid #f0efe9; }
  .ts-item:hover { background:#f4f7f2; }
  .ts-item .ts-bar { flex:0 0 auto; width:4px; align-self:stretch; border-radius:2px; background:#1f6feb; }
  .ts-item .ts-name { font-size: 0.84375rem; font-weight:600; color:#22301f; }
  .ts-item .ts-meta { font-size: 0.71875rem; color:var(--muted); margin-top:1px; }
  .ts-empty, .ts-status { padding:11px 12px; font-size: 0.78125rem; color:var(--muted); }

  /* ===== My Trips ===== */
  .trip-overview { margin-bottom:12px; }
  #active-trip-button {
    display:flex; flex-direction:column; align-items:flex-start; width:100%;
    min-height:44px; padding:8px 12px; border:1px solid var(--border);
    border-radius:10px; background:var(--panel-bg); cursor:pointer;
    font-family:inherit; text-align:left;
  }
  #active-trip-button .atb-label {
    font-size: 0.6875rem; color:var(--muted); font-weight:600;
    letter-spacing:.03em; text-transform:uppercase; margin-bottom:2px;
  }
  #active-trip-button .atb-name {
    font-size: 0.9375rem; font-weight:600; color:var(--text);
    overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
    max-width:100%;
  }
  #active-trip-button:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }

  .my-trips-sheet {
    display:flex; flex-direction:column; position:fixed; left:0; right:0; bottom:0;
    max-height:70vh; overflow-y:auto; z-index:2000;
    background:var(--panel-bg); border-radius:16px 16px 0 0;
    box-shadow:0 -4px 24px rgba(0,0,0,.25);
    border-top:1px solid var(--border);
  }
  .my-trips-sheet[hidden] { display:none; }
  .mts-head {
    display:flex; align-items:center; justify-content:space-between;
    padding:12px 16px; border-bottom:1px solid var(--border);
    position:sticky; top:0; background:var(--panel-bg); z-index:1;
  }
  .mts-head h2 { font-size: 1.0625rem; margin:0; font-weight:600; color:var(--text); }
  #my-trips-close {
    min-width:44px; min-height:44px; border:none; background:none;
    font-size: 1.125rem; color:var(--muted); cursor:pointer; border-radius:8px;
    display:flex; align-items:center; justify-content:center;
  }
  #my-trips-close:hover { background:#f0eee8; color:var(--text); }
  #my-trips-close:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }

  .my-trips-list { display:flex; flex-direction:column; gap:8px; padding:8px 12px 16px; }

  .trip-card {
    display:block; width:100%; text-align:left; padding:10px 14px;
    border:1px solid var(--border); border-radius:10px; background:var(--panel-bg);
    cursor:pointer; font-family:inherit; color:var(--text);
  }
  .trip-card:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
  .trip-card .tc-name {
    display:block; font-size: 0.9375rem; font-weight:700; color:var(--text);
    overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  }
  .trip-card .tc-dates,
  .trip-card .tc-source,
  .trip-card .tc-updated { display:block; font-size: 0.75rem; color:var(--muted); margin-top:2px; }
  .trip-card.active {
    border-left:4px solid var(--accent); background:#eaf2ea;
    padding-left:11px;
  }
  .trip-card.active .tc-name::before { content:'✓ '; }
  .trip-card.active .tc-name { color:var(--accent); }

  .mts-empty {
    padding:32px 16px; text-align:center; font-size: 0.8125rem;
    color:var(--muted); line-height:1.5;
  }

  .mts-import {
    display:flex; align-items:center; gap:12px; margin:0 12px 16px; padding:14px;
    border:1px solid #b7d5bd; border-radius:12px; background:#edf6ee;
  }
  .mts-import-copy { display:flex; flex:1; min-width:0; flex-direction:column; gap:3px; }
  .mts-import-copy strong { color:#153f32; font-size: 0.9375rem; line-height:1.2; }
  .mts-import-sources { color:#2b6d54; font-size: 0.75rem; font-weight:700; }
  .mts-import-copy small { color:#587269; font-size: 0.6875rem; line-height:1.35; }
  .mts-import [data-import-trigger] {
    min-width:104px; min-height:44px; padding:9px 14px; border:0; border-radius:10px;
    background:#075044; color:#fff; font-family:inherit; font-size: 0.8125rem;
    font-weight:700; cursor:pointer;
  }
  .mts-import [data-import-trigger]:focus-visible {
    outline:2px solid #177a5d; outline-offset:2px;
  }

  /* ===== Safe Import review sheet (Task 9 part B-3) ============================
   *
   * The review sheet is rendered by src/trips/import-ui.ts as a fixed
   * bottom-sheet modal (role=dialog, aria-modal=true). The entry point that
   * opens it is gated by AI_TRIP_IMPORT_ENABLED (enabled in the production
   * build); the review/confirm surface itself ships in the bundle regardless.
   *
   * Focus trap, Escape, and prefers-reduced-motion are exercised at the
   * module level by import-ui.test.ts; this stylesheet makes those behaviours
   * real on a real browser:
   *   - the sheet uses a single transition on `transform` for the slide-up;
   *   - `prefers-reduced-motion: reduce` disables that transition (and any
   *     base motion on the sheet) so users with motion sensitivity see a
   *     no-op entrance.
   *
   * Every class emitted by import-ui.ts (buildReviewSheet / renderErrorSheet
   * / showStaleWarning / showTripUpdatedBanner / mountImportEntry) is enumerated
   * here; the markup↔stylesheet contract is covered by import-ui.test.ts.
   */
  .import-review {
    position:fixed; left:0; right:0; bottom:0; z-index:4000;
    max-height:88vh; overflow-y:auto;
    background:var(--panel-bg);
    border-top:1px solid var(--border);
    border-radius:16px 16px 0 0;
    box-shadow:0 -6px 24px rgba(0,0,0,.3);
    padding:16px 16px calc(16px + env(safe-area-inset-bottom));
    transform:translateY(0);
    transition:transform 160ms ease-out;
  }
  .import-review[role="alertdialog"] .irt-error-msg {
    color:var(--hard); font-size: 0.875rem; line-height:1.5;
    margin:8px 0 0;
  }
  .irt-close, .irt-cancel, .irt-confirm {
    font-family:inherit;
    border-radius:9px;
    padding:10px 16px;
    font-size: 0.875rem; font-weight:600;
    cursor:pointer;
    min-height:44px;
  }
  .irt-close {
    border:1px solid var(--border); background:var(--panel-bg);
    color:var(--text);
  }
  .irt-trip-name { font-size: 1rem; font-weight:600; color:var(--text); margin:4px 0; }
  .irt-source, .irt-dates, .irt-version {
    font-size: 0.8125rem; color:var(--muted); margin:2px 0; line-height:1.4;
  }
  .irt-counts { font-size: 0.8125rem; margin:8px 0; color:var(--text); line-height:1.45; }
  .irt-removals { list-style:none; margin:8px 0; padding:0; }
  .irt-removals li { font-size: 0.8125rem; color:var(--hard); padding:1px 0; }
  .irt-removals li:first-child { font-weight:600; color:var(--text); margin-bottom:4px; }
  .irt-warnings { font-size: 0.8125rem; color:var(--hard); background:#fde9c8;
    border-radius:8px; padding:8px 10px; margin:8px 0; }
  .irt-current-safe { font-size: 0.8125rem; color:var(--muted); margin:8px 0; line-height:1.45; }
  .irt-undo {
    font-size: 0.8125rem; color:var(--text); line-height:1.5;
    background:#f4f7ef; border:1px solid var(--border);
    border-radius:8px; padding:10px 12px; margin:10px 0;
  }
  .irt-sections { margin:10px 0 0; }
  .irt-sections [data-section] {
    border:1px solid var(--border); border-radius:10px;
    padding:8px 10px; margin:8px 0;
    background:var(--panel-bg);
  }
  .irt-sections [data-section] h3 { font-size: 0.875rem; margin:0 0 6px; color:var(--text); }
  .irt-sections [data-section] ul { list-style:none; margin:0; padding:0; }
  .irt-sections [data-section] li { font-size: 0.8125rem; padding:2px 0; color:var(--text); }
  /* Collapsed (data-expanded="false") sections hide their content; the focus
     trap and accessibility contract expect the sheet itself to not exhaust
     the viewport, so collapsed sections collapse visually rather than being
     removed from the accessibility tree. */
  .irt-sections [data-section][data-expanded="false"] ul { display:none; }
  .irt-sections [data-section][data-expanded="true"] ul { display:block; }
  .irt-buttons {
    display:flex; gap:10px; margin-top:14px;
    position:sticky; bottom:0; background:var(--panel-bg);
    padding-top:6px;
  }
  .irt-confirm {
    flex:1 1 auto;
    background:#2e6b34; color:#fff; border:none;
  }
  .irt-confirm:disabled { opacity:.5; cursor:default; }
  .irt-confirm.gated {
    background:#8a5a12; /* the Trail Pro unlock CTA */
  }
  .irt-cancel {
    flex:1 1 auto;
    background:var(--panel-bg); color:var(--text);
    border:1px solid var(--border);
  }
  .irt-cancel:disabled { opacity:.5; cursor:default; }
  /* Stale-base second-confirmation alert banner. */
  .irt-stale {
    background:#fde9c8; color:#8a5a12;
    border-radius:8px; padding:8px 10px;
    font-size: 0.8125rem; margin:8px 0 0;
  }
  /* Post-commit "Trip updated — Undo" banner. Status role for screen readers. */
  .irt-updated {
    position:fixed; left:50%; bottom:calc(16px + env(safe-area-inset-bottom));
    transform:translateX(-50%);
    background:#1f3a24; color:#f4f1e8;
    border-radius:10px; padding:10px 14px;
    box-shadow:0 4px 16px rgba(0,0,0,.3);
    z-index:4100; max-width:92vw;
    display:flex; align-items:center; gap:10px;
  }
  .irt-updated-text { font-size: 0.875rem; font-weight:600; }
  .irt-updated a {
    color:#bfe6c6; text-decoration:underline;
    font-size: 0.875rem; font-weight:600; cursor:pointer;
  }

  /* Reduced motion: opt out of the slide-up transition (and any other motion
     on the sheet) so users with motion sensitivity see a no-op entrance.
     The .no-motion class is applied by import-ui.ts when
     window.matchMedia('(prefers-reduced-motion: reduce)').matches is true.
     A blanket @media block also covers the case where the matchMedia check
     ran before a user's reduced-motion preference surfaced. */
  .import-review.no-motion { transition:none; }
  .irt-updated.no-motion { transition:none; }
  @media (prefers-reduced-motion: reduce) {
    .import-review { transition:none; }
    .irt-updated { transition:none; }
  }

  /* ===== Selected direction: green gradient option 3 ===== */
  :root {
    --forest-950: #063f35;
    --forest-900: #075044;
    --forest-800: #0a6552;
    --forest-700: #177a5d;
    --mint-300: #a5dfb2;
    --mint-100: #dff4df;
    --ready-text: #f7fbf8;
    --ready-panel: rgba(240, 248, 239, .94);
  }
  .ready-hero, .active-trail-card, .readiness-panel, .map-options-btn,
  .mobile-sheet-head, .mobile-map-actions { display: none; }
  header h1 { display: flex; align-items: center; gap: 10px; }
  .brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 50%; background: var(--mint-100); color: var(--forest-900);
  }
  .brand-mark img, nav button img { width: 20px; height: 20px; }
  nav button img { display: none; }
  .nav-count:empty { display: none; }
  .nav-count:not(:empty) {
    display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px;
    padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--mint-300); color: var(--forest-950);
    font-size: 0.625rem; font-weight: 800;
  }

  .planner-disclosure { margin: 18px 0; border: 1px solid var(--line); border-radius: 12px; background: #f8faf6; }
  .planner-disclosure > summary { padding: 12px 16px; min-height: 44px; box-sizing: border-box; cursor: pointer; font-weight: 650; }
  .planner-disclosure .membership-card { margin: 0; border: 0; border-top: 1px solid var(--line); border-radius: 0 0 12px 12px; }
  .planner-add-trail { width: 100%; margin: 0 0 18px; }
  .planner-wrap button, .planner-wrap input[type="date"], .planner-wrap summary { min-height: 44px; }
  #plan-backup, #plan-restore, #wp-import, #wp-export { padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--accent); font: inherit; font-size: .875rem; cursor: pointer; }
  .plan-totals[hidden], #plan-backup[hidden], #plan-share[hidden], #plan-clear[hidden] { display: none !important; }
  .trail-detail-actions { display: grid; gap: 8px; margin: 14px 0; }
  .trail-detail-actions .directions-btn, .trail-detail-actions .plan-btn { margin: 0; min-height: 44px; border-radius: 10px; box-sizing: border-box; }
  #d-ar { width: 100%; border: 1px solid var(--accent); color: var(--accent); background: #fff; font: inherit; cursor: pointer; padding: 10px 12px; }
  .access-ico img { width: 22px; height: 22px; }
  .planner-wrap button:focus-visible, .planner-disclosure > summary:focus-visible, #d-ar:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

  @media (max-width: 760px), (pointer: coarse) {
    html, body { min-height: 100%; background: var(--forest-950); }
    body {
      height: 100dvh; color: var(--ready-text); isolation: isolate;
      background-image: url('assets/blackrow-ready-forest-bg.png');
      background-position: center; background-size: cover; background-attachment: fixed;
    }
    body::before {
      content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
      background: rgba(4, 58, 48, .2);
    }
    header {
      position: relative; z-index: 1400; height: calc(84px + env(safe-area-inset-top));
      padding: env(safe-area-inset-top) 24px 0; background: rgba(4, 58, 48, .72); border: 0;
      gap: 10px; overflow: visible; flex-wrap: nowrap;
    }
    header h1 { min-width: 0; margin: 0; font-size: 1.0625rem; font-weight: 700; letter-spacing: -.01em; }
    .brand-mark { width: 34px; height: 34px; flex: 0 0 auto; }
    .brand-mark img { width: 21px; height: 21px; }
    #region-select {
      margin-left: auto; width: 164px; max-width: 42vw; height: 44px; padding: 0 11px;
      border: 1px solid rgba(165, 223, 178, .42); border-radius: 14px;
      background: rgba(5, 70, 58, .7); color: var(--ready-text); font-size: 0.75rem;
    }

    nav {
      position: fixed; z-index: 1500; left: 27px; right: 27px; bottom: max(8px, env(safe-area-inset-bottom));
      height: 66px; min-height: 66px; padding: 4px; border: 1px solid rgba(209, 239, 216, .58); border-radius: 18px;
      background: rgba(15, 82, 66, .88); box-shadow: 0 12px 36px rgba(2, 32, 27, .36);
    }
    nav button {
      position: relative; flex: 1; min-width: 0; height: 56px; min-height: 56px; padding: 5px 8px;
      display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
      color: #c0d9c8; border: 0; border-radius: 14px; font-size: 0.6875rem;
    }
    nav button img { display: block; width: 23px; height: 23px; opacity: .82; filter: invert(91%) sepia(11%) saturate(359%) hue-rotate(82deg); }
    nav button.active { color: #062f28; background: rgba(174, 222, 183, .92); border: 0; }
    nav button.active img { opacity: 1; filter: invert(14%) sepia(20%) saturate(2025%) hue-rotate(117deg); }
    .nav-count:not(:empty) { position: absolute; top: 3px; left: calc(50% + 7px); margin: 0; }

    .tab { min-height: 0; }
    #tab-map.active {
      display: block; position: relative; padding: 0 27px calc(82px + env(safe-area-inset-bottom));
      overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
    }
    .ready-hero { display: block; padding: 0 0 17px; }
    .ready-eyebrow { display: none; }
    .ready-hero h2 {
      margin: 0; color: var(--ready-text); font-size: clamp(1.75rem, 7.5vw, 2rem); font-weight: 600;
      line-height: 1.02; letter-spacing: -.05em;
    }

    .active-trail-card {
      display: flex; align-items: center; gap: 14px; margin-bottom: 12px; padding: 12px 14px;
      min-height: 76px; border: 1px solid rgba(190, 232, 198, .58); border-radius: 17px;
      background: rgba(18, 92, 72, .64); box-shadow: 0 12px 28px rgba(2, 43, 34, .18); cursor: pointer;
    }
    .trail-ring {
      display: flex; align-items: center; justify-content: center; width: 48px; height: 48px; flex: 0 0 auto;
      border-radius: 50%; background: #b8e8b8; color: var(--forest-900); box-shadow: 0 8px 18px rgba(0, 37, 29, .28);
    }
    .trail-ring img { display: block; width: 27px; height: 27px; }
    .active-trail-copy { min-width: 0; }
    .active-trail-label { display: none; }
    .active-trail-copy h3 { margin: 0 0 7px; color: #fff; font-size: 1.125rem; line-height: 1.15; letter-spacing: -.02em; }
    .active-trail-stats { display: flex; flex-wrap: nowrap; gap: 4px 0; color: #d9eedc; font-size: 0.6875rem; }
    .active-trail-stats span { display: inline-flex; align-items: center; white-space: nowrap; }
    .active-trail-stats span + span::before { content: ""; width: 1px; height: 13px; margin: 0 7px; background: rgba(210, 237, 216, .43); }
    .active-trail-stats img { width: 15px; height: 15px; margin-right: 4px; filter: invert(85%) sepia(17%) saturate(839%) hue-rotate(77deg); }
    .active-trail-stats strong { font-weight: 650; }

    .map-card {
      display: block; position: relative; height: clamp(280px, 36vh, 420px); min-height: 280px; overflow: hidden;
      border: 1px solid rgba(222, 243, 224, .72); border-radius: 18px; background: #dbe5cf;
      box-shadow: 0 16px 32px rgba(1, 37, 29, .25);
    }
    #map { width: 100%; height: 100%; min-height: 0; filter: saturate(.72) sepia(.08) contrast(.96); }

    /* The 249px map is sized for a phone. A tablet runs the same stack on a
     * screen half again as tall, so the leftover became a band of background
     * below the cards -- let the map take that slack instead, and widen the
     * gutters so the column is not a phone layout stretched across glass. */
    @media (min-width: 768px) {
      .map-card { height: clamp(249px, 44vh, 640px); }
      #tab-map.active { padding-right: 48px; padding-left: 48px; }
    }
    .map-card .leaflet-control-zoom { display: flex; flex-direction: column; gap: 7px; border: 0; box-shadow: none; }
    .map-card .leaflet-control-zoom a {
      display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; line-height: 34px;
      border: 0; border-radius: 50% !important; color: var(--forest-900); background: rgba(248, 252, 246, .95); font-size: 1.25rem;
    }
    .map-card .leaflet-control-zoom a:first-child { border-radius: 50% 50% 0 0; }
    .map-card .leaflet-control-zoom a:last-child { border-radius: 0 0 50% 50%; }
    .map-card .leaflet-top.leaflet-left { left: auto; right: 8px; }
    #locate-btn { right: 12px !important; bottom: 12px !important; width: 36px !important; height: 36px !important; border: 0 !important; background: rgba(248, 252, 246, .96) !important; }
    #dl-area-btn, #sos-btn, #wp-btn, #track-btn, #tools-btn, #sat-btn { display: none !important; }
    .map-options-btn {
      display: flex; position: absolute; z-index: 1000; left: 12px; bottom: 12px; align-items: center; gap: 7px;
      min-height: 36px; padding: 0 11px; border: 0; border-radius: 18px; background: rgba(248, 252, 246, .92);
      color: var(--forest-900); box-shadow: 0 5px 16px rgba(12, 49, 36, .2); font: 700 0.6875rem inherit;
    }
    .map-options-btn img { width: 18px; height: 18px; }

    .readiness-panel {
      display: block; margin-top: 7px; padding: 8px 14px; color: #f7fbf8;
      border: 1px solid rgba(209, 239, 216, .62); border-radius: 18px;
      background: rgba(30, 104, 78, .74); box-shadow: 0 18px 38px rgba(1, 37, 29, .24);
    }
    .readiness-row {
      display: flex; align-items: center; width: 100%; min-height: 46px; gap: 11px; padding: 4px 0;
      border: 0; border-bottom: 1px solid rgba(209, 239, 216, .25); background: transparent; color: inherit; text-align: left;
      font-family: inherit; cursor: pointer;
    }
    .readiness-icon {
      display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; flex: 0 0 auto;
      border-radius: 50%; background: rgba(0, 70, 53, .88); color: #fff;
    }
    .readiness-icon img { width: 20px; height: 20px; filter: invert(98%); }
    .readiness-copy { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 2px; }
    .readiness-copy strong { font-size: 0.875rem; line-height: 1.18; letter-spacing: -.01em; }
    .readiness-copy small { color: #d0ead5; font-size: 0.6875rem; line-height: 1.25; }
    .readiness-state {
      display: flex; align-items: center; justify-content: center; width: 31px; height: 31px; flex: 0 0 auto;
      border-radius: 10px; background: rgba(70, 139, 98, .32); border: 1px solid rgba(174, 222, 183, .42);
    }
    .readiness-state.pending { background: rgba(34, 105, 78, .38); }
    .readiness-state img { width: 17px; height: 17px; filter: invert(88%) sepia(21%) saturate(573%) hue-rotate(72deg); }
    .start-hike-btn {
      display: flex; position: relative; align-items: center; justify-content: center; width: 100%; min-height: 52px; margin-top: 10px;
      padding: 0 54px; border: 1px solid rgba(150, 210, 160, .68); border-radius: 26px; background: rgba(0, 61, 48, .94); color: #fff;
      font-family: inherit; font-size: 1.1875rem; font-weight: 750; letter-spacing: -.02em;
      box-shadow: 0 8px 18px rgba(3, 57, 46, .26); cursor: pointer;
    }
    .start-hike-arrow {
      display: flex; position: absolute; right: 4px; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 18px;
      background: rgba(67, 139, 91, .9);
    }
    .start-hike-arrow img { width: 27px; height: 27px; filter: invert(92%) sepia(10%) saturate(800%) hue-rotate(72deg); }
    .change-trail-btn {
      display: none; min-height: 44px; margin: 4px auto -5px; border: 0; background: transparent;
      color: var(--forest-800); font: 700 0.8125rem inherit; text-decoration: underline; text-underline-offset: 4px; cursor: pointer;
    }

    #trail-search {
      display: none; position: fixed; z-index: 1700; left: 14px; right: 14px; top: calc(78px + env(safe-area-inset-top));
      width: auto; padding: 10px; border: 1px solid rgba(222, 243, 224, .75); border-radius: 15px;
      background: rgba(5, 61, 51, .96); box-shadow: 0 16px 38px rgba(1, 31, 25, .38);
    }
    .trail-picker-open #trail-search { display: block; }
    #trail-search .ts-box { border: 0; border-radius: 11px; box-shadow: none; }
    #trail-search .ts-box span.ts-ico { display: none; }
    #trail-search .ts-clear { display: block !important; min-width: 44px; min-height: 44px; }
    #ts-results { max-height: 52vh; }

    #map-options {
      display: block; position: fixed; z-index: 1650; left: 0; right: 0; bottom: 0; width: 100%; max-height: 78dvh;
      padding: 0 0 calc(84px + env(safe-area-inset-bottom)); color: #173c32; border: 0; border-radius: 24px 24px 0 0;
      background: #f3f7f0; box-shadow: 0 -18px 48px rgba(1, 31, 25, .4); overflow-y: auto;
      transform: translateY(110%); visibility: hidden; transition: transform .24s ease, visibility .24s;
    }
    .layers-open #map-options { transform: translateY(0); visibility: visible; }
    .trail-detail-open #map-options { background: #f5f8f2; }
    .trail-detail-open #map-options > :not(#detail) { display: none !important; }
    #map-options::before { display: none; }
    .mobile-sheet-head {
      display: flex; position: sticky; z-index: 2; top: 0; align-items: center; justify-content: space-between;
      padding: 16px 18px; border-bottom: 1px solid #d5dfd3; background: #f3f7f0;
    }
    .mobile-sheet-head > div { display: flex; flex-direction: column; }
    .mobile-sheet-head span { font-size: 1.0625rem; font-weight: 780; }
    .mobile-sheet-head small { color: #5e766e; font-size: 0.6875rem; margin-top: 2px; }
    .mobile-sheet-head button { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0; border-radius: 14px; background: #dde9dd; }
    .mobile-sheet-head img { width: 20px; height: 20px; }
    .mobile-map-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 13px 12px 4px; }
    .mobile-map-actions button {
      display: flex; min-height: 68px; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
      padding: 7px 3px; border: 1px solid #ccdbcc; border-radius: 13px; background: #fff; color: #174d3f; font: 700 0.625rem inherit;
    }
    .mobile-map-actions img { width: 23px; height: 23px; }
    #map-options > section { padding: 14px 18px; }

    #detail.open {
      position: relative; inset: auto; z-index: 1800; max-height: none; overflow-y: visible;
      color: var(--text); background: #f5f8f2; border-radius: 22px 22px 0 0;
    }
    #tab-planner.active, #tab-reservations.active {
      display: flex; color: var(--text); background: rgba(248, 250, 246, .98); padding-bottom: calc(92px + env(safe-area-inset-bottom));
    }

    @media (prefers-reduced-motion: reduce) {
      #map-options { transition: none; }
    }
  }

  @media (max-width: 360px) {
    header { height: calc(132px + env(safe-area-inset-top)); padding: calc(12px + env(safe-area-inset-top)) 16px 12px; flex-wrap: wrap; gap: 8px; }
    header h1 { width: 100%; }
    #region-select { width: 100%; max-width: 100%; margin-left: 0; }
    .trail-ring { display: none; }
    .active-trail-stats { flex-wrap: wrap; row-gap: 6px; }
  }
