/* App shell, matched to the Key Tech Services Portal shell skeleton.
   Desktop (>= 1024px): full-width header / rail (flush left, hover-expands) · workspace card (title bar + tools + map)
   · aux panel (flush right; overlay below 1280px) / full-width status bar, 12px gaps on the background canvas.
   Phone & portrait tablet (< 1024px): full-screen map, requested full-page tools, bottom icon dock. */
body { display: flex; flex-direction: column; gap: var(--s3); overflow: hidden; height: 100dvh; }

.appbar {
  position: relative; z-index: 1100; height: var(--header-h); flex: none; display: flex; align-items: center; gap: var(--s3);
  padding: 0 12px 0 0; padding-top: env(safe-area-inset-top); background: var(--surface);
  border-bottom: 1px solid var(--line); box-shadow: 0 2px 4px -2px var(--hdr-shadow);
}
.brand { display: flex; align-items: center; height: 100%; text-decoration: none; color: inherit; min-width: 0; }
.logo-slot { width: var(--rail-w); height: 100%; display: grid; place-items: center; flex: none; }
.brand-mark { width: 36px; height: 36px; border-radius: 8px; background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; display: grid; place-items: center; }
.brand-mark .icon { width: 18px; height: 18px; stroke-width: 2.2; }
.brand-name { font-size: 14px; font-weight: 600; }
.brand-sub { font-size: 11px; color: var(--text-2); }
.appbar-actions { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.hdr-btn {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; border: 0; background: transparent;
  color: var(--text-2); flex: none;
}
.hdr-btn .icon { width: 16px; height: 16px; }
.hdr-btn:hover { background: var(--surface-2); color: var(--text); }
.hdr-btn[aria-pressed="true"] { color: var(--primary); background: var(--surface-2); }
#acctLink {
  margin-left: 6px !important; height: 30px; padding: 0 12px; border-radius: 999px; display: inline-flex; align-items: center;
  background: var(--surface-2); color: var(--primary); text-decoration: none; font-size: 12px; font-weight: 600;
}
#acctLink:hover { color: var(--text); }
#acctLink.acct-avatar { width: 32px; height: 32px; padding: 0; justify-content: center; overflow: hidden; background: var(--primary); color: var(--bg); font-size: 12px; letter-spacing: .02em; }
#acctLink.acct-avatar:hover { color: var(--bg); box-shadow: 0 0 0 2px var(--accent); }
#acctLink.acct-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.shell { flex: 1; min-height: 0; display: flex; gap: var(--s3); padding-right: var(--s3); overflow: hidden; }
body[data-aux="open"] .shell { padding-right: 0; }

/* Left rail: flush left, rounded right, 56px; widens to 224px on hover and pushes the workspace */
.rail-slot { position: relative; z-index: 1040; width: var(--rail-w); flex: none; transition: width .2s ease-out; }
.rail-slot:has(.sections:hover) { width: var(--rail-open); }
.sections {
  position: absolute; inset: 0 auto 0 0; width: 100%; display: flex; flex-direction: column; gap: 4px; padding: 8px;
  overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-left: 0; border-radius: 0 12px 12px 0;
}
.sections a {
  height: 40px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 11px; border-radius: 10px; overflow: hidden;
  color: var(--text-2); text-decoration: none; font-size: 14px; transition: background-color .15s, color .15s;
}
.sections a:hover { background: var(--surface-2); color: var(--text); }
.sections a[aria-current="page"] { background: var(--surface-2); color: var(--primary); }
.sections .icon { width: 18px; height: 18px; flex: none; stroke-width: 1.75; }
.sections a span { white-space: nowrap; opacity: 0; transition: opacity .2s; }
.sections:hover a span, .sections:has(:focus-visible) a span { opacity: 1; }
@media (min-width: 1024px) { .sections .dock-only { display: none; } }
@media (max-width: 1023px) { .sections .rail-only { display: none !important; } }
.sections a.rail-home { background: var(--surface-2); color: var(--primary); }

/* Workspace card: sticky title bar + body (tools panel + map) */
.workspace {
  flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-1);
}
.ws-bar {
  min-height: 56px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.ws-titles { flex: 1; min-width: 0; }
.ws-titles h1 { font-size: 15px; font-weight: 600; line-height: 1.25; letter-spacing: -0.02em; }
.ws-titles p { margin-top: 2px; font-size: 12px; color: var(--text-2); }
.ws-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
/* Loran-C off for this chart (js/app/loran.js): the map's TD converter goes away */
body.no-loran .mc-btn, body.no-loran .mc-conv { display: none !important; }   /* GPS placement and its pin remain available. */

.view { flex: 1; min-height: 0; overflow-y: auto; padding: 20px var(--s5); display: flex; flex-direction: column; gap: var(--s4); }
.view:focus { outline: none; }
.view-head { display: flex; align-items: flex-end; gap: var(--s3); }
.view-head p { margin-top: 2px; }
.sp:not(.sp-detail) > .sp-head { flex-wrap: wrap; }
.sp:not(.sp-detail) > .sp-head > h2 { flex-basis: 100%; }

.mapwrap { position: relative; min-width: 0; min-height: 0; z-index: 0; }
#map { position: absolute; inset: 0; background: var(--surface-3); }

/* Aux panel: hidden by default; docks flush right (rounded left) at >= 1280px, overlay below */
.aux {
  width: var(--aux-w); flex: none; min-height: 0; display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--line); border-right: 0; border-radius: 12px 0 0 12px; overflow: hidden;
}
body[data-aux="closed"] .aux { display: none; }
.aux-scrim { display: none; }
.aux-tabs { height: 48px; flex: none; display: flex; align-items: center; gap: 4px; padding: 0 6px 0 12px; border-bottom: 1px solid var(--line); }
.aux-tab { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 8px; border-radius: 8px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); text-decoration: none; white-space: nowrap; }
.aux-tab .icon { width: 15px; height: 15px; flex: none; }
.aux-tab:hover { color: var(--text); background: var(--surface-2); }
.aux-tab[aria-current="page"] { background: var(--surface-2); color: var(--primary); }
.aux-tabs .hdr-btn { margin-left: 2px; }
.aux-head { height: 44px; display: flex; align-items: center; gap: 8px; padding: 0 6px 0 16px; border-bottom: 1px solid var(--line); }
.aux-head h2 { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; flex: 1; }
.aux-body { flex: 1; overflow-y: auto; padding: var(--s4); display: flex; flex-direction: column; gap: var(--s4); }
.aux-empty { margin: auto; text-align: center; color: var(--text-2); font-size: 13px; max-width: 220px; }
.aux-empty .icon { width: 28px; height: 28px; margin: 0 auto 8px; opacity: .6; }
.aux-title { font-size: 17px; font-weight: 600; }
.aux-kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; }
.aux-kv dt { color: var(--text-2); }
.aux-kv dd { margin: 0; text-align: right; }
.aux-section { border-top: 1px solid var(--line); padding-top: var(--s3); }
.aux-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); font-weight: 600; margin-bottom: 6px; }


/* Status bar: full width, 32px */
.statusbar {
  height: var(--status-h); flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 var(--s4); border-top: 1px solid var(--line); background: var(--surface); font-size: 11px; color: var(--text-2);
}
.statusbar a { color: inherit; }
.statusbar a:hover { color: var(--text); }
.statusbar nav { display: flex; gap: 12px; align-items: center; }
.status-dot { display: inline-flex; align-items: center; gap: 6px; }
.status-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.status-dot.off::before { background: var(--warn); }

@media (max-width: 1023px) {
  :root { --header-h: 52px; --nav-h: 0px; --dock-h: env(safe-area-inset-bottom, 0px); }
  .appbar { background: var(--surface); border-bottom: 1px solid var(--line); }
  .shell { display: block; position: relative; padding: 0; }
  body { gap: 0; }
  .appbar { padding-left: 4px; box-shadow: none; }
  .logo-slot { width: 48px; }
  .workspace, .ws-body, .rail-slot { display: contents; }
  .ws-bar { display: none; }
  body[data-aux="open"] .shell { padding-right: 0; }
  .statusbar { display: none; }
  /* No phone dock: reserve only the device safe area for map overlays. */
  /* The map ends above the collapsed slide-up sheet, so the collapsed sheet never covers the chart. */
  /* Collapsed sheet: one height for search + Add and selected-item summaries. */
  :root { --sheet-min: 100px; }
  .mapwrap { position: absolute; inset: 0 0 calc(var(--sheet-min) + var(--dock-h)); transition: bottom .24s ease; }
  /* Keep the cursor and Leaflet's centre in the exposed map above the half sheet.
     A full sheet covers this same map; it must not crush the map controls into its top sliver. */
  body[data-sheet="half"] .mapwrap, body[data-sheet="full"] .mapwrap { bottom: 50dvh; }
  #aux, body[data-aux] #aux { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; width: auto; display: flex; flex-direction: column;
    height: calc(var(--sheet-min) + var(--dock-h)); padding-bottom: var(--dock-h); border: 1px solid var(--line); border-bottom: 0;
    border-radius: 16px 16px 0 0; box-shadow: 0 -4px 18px rgba(0,0,0,.18); transition: height .24s ease; overflow: hidden; }
  body #aux[data-sheet="half"] { height: 50dvh; }
  body #aux[data-sheet="full"] { height: calc(100dvh - env(safe-area-inset-top, 0px) - 24px); }
  #aux[data-sheet="min"] .view { display: none; }
  body #aux[data-sheet="min"] { box-shadow: none; border-radius: 0; }
  body[data-section] #aux { display: none !important; }
  .sheet-handle { flex: none; height: 24px; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    padding: 0; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 13px; font-weight: 600; touch-action: none; cursor: grab;
    user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
  .sheet-grip { width: 44px; height: 5px; border-radius: 3px; background: var(--line-strong, var(--line)); }
  .sheet-handle:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
  #aux .view { flex: 1; min-height: 0; overflow-y: auto; padding-top: var(--s4); }
  /* Expanded chart lists: separate the dock, heading/actions, filters and first list. */
  #aux .sp:not(.sp-detail) { gap: var(--s4); }
  #aux .sp:not(.sp-detail) > .sp-head { gap: var(--s2); }
  #aux .sp:not(.sp-detail) > .sp-head { flex-wrap: wrap; }
  #aux .sp:not(.sp-detail) > .sp-head > h2 { flex-basis: 100%; }
  #aux .sp:not(.sp-detail) > .sp-head > :not(.grow) { flex-shrink: 0; }
  #aux .sp:not(.sp-detail) > .sp-head .btn { min-height: var(--touch); }
  #aux .sp:not(.sp-detail) > .sp-head .btn-icon { width: var(--touch); }
  #aux .sp-tools { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto; gap: var(--s3); }
  #aux .sp-tools .input { height: var(--touch); min-height: var(--touch); font-size: 16px; }
  #aux .sp-tools select.input { line-height: normal; }
  #aux .view .view-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: var(--s3); }
  #aux .view .view-head > .grow { min-width: 0; }
  #aux .view .view-head > .btn { flex-shrink: 0; }
  #aux .view .btn-row .btn { min-height: var(--touch); }
  #aux .sp-detail { gap: var(--s4); }
  #aux .sp-detail > .sp-head { display: flex; flex-wrap: wrap; gap: var(--s2); }
  #aux .sp-detail > .sp-head .btn { min-height: var(--touch); flex-shrink: 0; }
  #aux .sp-detail > .sp-head .btn-icon { width: var(--touch); }
  #aux .sp-detail > .sp-head > .sp-back { flex-basis: 100%; justify-content: flex-start; }
  #aux .sp-detail > .sp-head > .grow { display: none; }
  #aux .sp-phone-detail > .sp-head { display: flex; flex-wrap: nowrap; align-items: center; gap: var(--s2); height: 64px; flex: none; padding-block: var(--s1); }
  #aux .sp-summary { min-width: 0; }
  #aux .sp-summary-actions .menu-pop { right: 0; left: auto; top: calc(100% + 6px); bottom: auto; min-width: 200px; max-height: calc(50dvh - 100px); overflow-y: auto; overscroll-behavior: contain; }
  #aux .sp-summary-actions .menu-pop .btn { display: flex; align-items: center; justify-content: flex-start; gap: var(--s2); width: 100%; height: auto; padding: var(--s2); }
  #aux .sp-summary-actions .menu-pop .sp-share-overflow { display: none; }
  #aux .sp-misc { margin-top: 0; }
  #aux .view:has(.sp-phone-detail) { padding: 0 var(--s3) var(--s4) 14px; }
  @media (max-width: 359px) {
    #aux .sp-summary-actions > .sp-share { display: none; }
    #aux .sp-summary-actions .menu-pop .sp-share-overflow { display: flex; }
    #aux .sp:not(.sp-detail) > .sp-head { display: grid; grid-template-columns: auto auto minmax(0, 1fr); }
    #aux .sp:not(.sp-detail) > .sp-head > .btn,
    #aux .sp:not(.sp-detail) > .sp-head > .menu { grid-row: 2; }
    #aux .view .view-head { grid-template-columns: minmax(0, 1fr); }
    #aux .view .view-head > .btn { justify-self: start; }
  }
  @media (prefers-reduced-motion: reduce) { #aux, .mapwrap { transition: none; } }

  .sections {
    display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100; height: var(--dock-h);
    flex-direction: row; padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px)); background: var(--surface); border-top: 1px solid var(--line);
  }
  .sections { inset: auto 0 0 0; width: auto; border: 0; border-top: 1px solid var(--line); border-radius: 0; overflow: visible; gap: 4px; }
  .sections a { flex: 1; height: auto; min-height: 0; padding: 4px 2px; flex-direction: column; justify-content: center; gap: 2px; font-size: 10.5px; font-weight: 600; }
  .sections a span { opacity: 1; }
  .sections .icon { width: 20px; height: 20px; }
  .sections a, .sections a:hover, .sections a[aria-current="page"] { box-shadow: none !important; background: transparent !important; outline: 0; }
  .sections a { color: var(--text-2); -webkit-tap-highlight-color: transparent; }
  .sections a[aria-current="page"] { color: var(--primary) !important; }
  .sections a:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
  .sections .rail-extra { display: none; }

  /* Dock row: full-width search; Add stays on the map above this row. */
  #aux { overflow: visible !important; }
  #aux .aux-dock { display: flex; flex: none; align-items: center; gap: 10px; height: 64px; padding: 4px 12px 6px 14px; }
  #aux .aux-dock .spot-search { position: relative; inset: auto; flex: 1; min-width: 0; max-width: none; z-index: 5; }
  #aux .aux-dock .chart-pick { position: relative; top: auto; left: auto; transform: none; flex: none; z-index: 1; }
  #aux .aux-dock .cp-menu { top: auto; bottom: calc(100% + 10px); left: -4px; transform: none; min-width: 220px; max-width: min(340px, calc(100vw - 24px)); }
  #aux .aux-dock .cp-menu button { align-items: flex-start; text-align: left; }
  #aux .aux-dock .ss-list { position: fixed; left: 10px; right: 10px; bottom: calc(var(--sheet-min) + var(--dock-h) + 6px); max-height: 50dvh; overflow-y: auto;
    background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-1); z-index: 1200; }
  #aux .aux-dock .spot-search.is-full .ss-results { position: fixed; left: 0; right: 0; top: env(safe-area-inset-top, 0px); bottom: calc(var(--sheet-min) + var(--dock-h));
    width: auto; height: auto; padding-top: 12px; z-index: 1200; border-bottom: 1px solid var(--line); }
  #aux[data-sheet="min"].has-selection .aux-dock,
  #aux:has(.sp-detail) .aux-dock { display: none; }
  /* Spots / Routes: compact segmented toggle at the left of the dock row, before the search. */
  #aux .aux-tabs { display: flex; flex: none; height: 50px; margin: 0; padding: 4px; gap: 2px; align-items: stretch;
    border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); }
  #aux .aux-dock .aux-tab { padding: 0 10px; }
  #aux { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  #aux[data-sheet="min"].has-selection .aux-tabs { display: none; }
  /* Chart switcher back on the map, top-left; profile top-right. */
  /* Chart dropdown top-centre; app switcher (2x2 grid) top-left; profile top-right. */
  .mapwrap > .chart-pick.cp-map { position: absolute; top: var(--s3); left: 50%; transform: translateX(-50%); z-index: 810; }
  .mapwrap > .chart-pick.cp-map .cp-menu { top: calc(100% + 8px); bottom: auto; left: 50%; transform: translateX(-50%); }
  .mapwrap > .chart-pick.cp-map .cp-btn { width: auto; height: var(--touch); max-width: calc(100vw - 2 * var(--touch) - 48px); padding: 0 14px 0 12px; gap: 6px;
    background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--text); }
  .mapwrap > .chart-pick.cp-map .cp-label { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mapwrap > .chart-pick.cp-map .cp-caret { display: block; color: var(--text-2); font-size: 11px; }
  .app-switch { position: absolute; top: var(--s3); left: var(--s3); z-index: 815; }
  .app-switch .as-btn { width: var(--touch); height: var(--touch); border-radius: 50%; }
  .app-switch .as-menu { display: none; position: absolute; top: calc(100% + 8px); left: 0; min-width: 180px; padding: 6px; flex-direction: column; gap: 2px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-1); }
  .app-switch.open .as-menu { display: flex; }
  .app-switch .as-menu a { display: flex; align-items: center; gap: 12px; min-height: var(--touch); padding: 0 12px; border-radius: 10px; color: var(--text); text-decoration: none; font-size: 15px; }
  .app-switch .as-menu a[aria-current] { color: var(--primary); background: var(--surface-2); }
  .app-switch .as-menu .icon { width: 20px; height: 20px; }
  .mapwrap > .map-acct.acct-map { position: absolute; top: var(--s3); right: var(--s3); z-index: 820; display: grid; }
  #aux .aux-tab { height: auto; padding: 0 16px; border-radius: 999px; text-transform: none; letter-spacing: 0; font-size: 13px; }
  #aux .aux-tab[aria-current="page"] { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-1); }
  #aux .aux-tab[data-tab="lists"], .aux-scrim { display: none !important; }
  .brand-sub { display: none; }
  .hdr-aux { display: none !important; }
}
/* Phones: no top bar — theme, account and sign-in live in Settings (bottom bar) */
@media (max-width: 1023px) {
  :root { --header-h: 0px; }
  .appbar { display: none !important; }
  .mapwrap { top: env(safe-area-inset-top); }
}

@media (min-width: 1024px) { .statusbar { display: grid; grid-template-columns: 1fr auto 1fr; } }
.statusbar .sb-status { display: flex; gap: 12px; align-items: center; justify-self: end; }

/* Desktop: each section has a left rail; Charts holds its chart list. Tools remain flush right. */
@media (min-width: 1024px) {
  .shell { padding-left: 0; }
  body[data-section] #railCharts { display: none; }
  .sections { overflow-y: auto; scrollbar-width: thin; }
  body[data-aux="open"] .shell { padding-right: 0; }
  body[data-aux="closed"] .shell { padding-right: var(--s3); }
}
.brand-logo{width:32px;height:32px;display:block;object-fit:contain}
/* Dark-theme logo variant follows the app's own theme toggle */
:root[data-theme="dark"] .brand-logo{content:url("../logo-dark.png")}
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]) .brand-logo{content:url("../logo-dark.png")}}
@media (min-width: 1024px) { .phone-only { display: none !important; } }

/* Touch taps on the desktop rail must not leave it expanded (sticky :hover); see auxpanel.js */
@media (min-width: 1024px) {
  body.rail-touch .rail-slot { width: var(--rail-w) !important; }
  body.rail-touch .sections a span, body.rail-touch .sections .rc-name, body.rail-touch .sections .rc-add { opacity: 0 !important; }
}

/* ---------- Sections: Charts (map + panel) / Weather / Vessels. main.js sets body[data-section] for the full-page
   ones and renders them into #sectionPage; the rail (desktop) and bottom dock (phone) switch between them. ---------- */
.section-page[hidden] { display: none; }
.section-page { flex: 1; min-width: 0; min-height: 0; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-1); }
.section-body { max-width: 1040px; margin: 0 auto; padding: 24px var(--s5) 48px; }
body[data-section] .workspace, body[data-section] .aux, body[data-section] .aux-scrim { display: none !important; }
body[data-section] .shell { padding-right: var(--s3); }
@media (max-width: 1023px) {
  .section-page { position: fixed; left: 0; right: 0; top: calc(var(--header-h) + env(safe-area-inset-top)); bottom: var(--dock-h); z-index: 900;
    border: 0; border-radius: 0; box-shadow: none; }
  .section-body { padding: 16px 16px 32px; }
  /* Weather / Vessels: the map is hidden, but its app switcher (top left) and profile (top right) stay on top, so
     another app or Settings is always one tap away; the page starts below them. */
  body[data-section] .workspace { display: contents !important; }
  body[data-section] .mapwrap { z-index: 950; pointer-events: none; }
  body[data-section] .mapwrap > :not(#appSwitch):not(#mapAcct) { display: none !important; }
  body[data-section] #appSwitch, body[data-section] #mapAcct { pointer-events: auto; }
  body[data-section] .section-body { padding-top: calc(var(--touch) + 24px); }
}

/* Desktop: Charts / Weather / Vessels centred in the top bar; the current one is highlighted with a bar under it.
   (Phones have no top bar and switch sections from the bottom dock.) */
.topnav { position: absolute; left: 50%; top: 0; bottom: 0; transform: translateX(-50%); display: flex; align-items: stretch; gap: 4px; padding-top: env(safe-area-inset-top); }
.topnav a { position: relative; display: flex; align-items: center; gap: 8px; padding: 0 16px; color: var(--text-2); text-decoration: none; font-size: 13.5px; font-weight: 600; transition: color .15s; }
.topnav a .icon { width: 18px; height: 18px; stroke-width: 1.75; }
.topnav a::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: transparent; transition: background-color .15s; }
.topnav a:hover { color: var(--text); }
.topnav a:hover::after { background: var(--line-strong); }
.topnav a[aria-current="page"] { color: var(--primary); }
.topnav a[aria-current="page"]::after { background: var(--primary); }
.topnav a:focus-visible { outline: 2px solid var(--focus); outline-offset: -4px; border-radius: 8px; }
@media (max-width: 1023px) { .topnav { display: none; } }

/* Desktop rail on full-page sections: the section's own items (#railSection, filled by view.rail via main.js) */
.rail-section { display: flex; flex-direction: column; gap: 4px; }
.rail-section:empty { display: none; }
.sections .rs-badge { width: 22px; height: 22px; flex: none; display: grid; place-items: center; margin: 0 -2px; border-radius: 7px;
  border: 1px solid var(--line-strong); font-size: 11px; font-weight: 600; color: var(--text-2); }
.sections a[aria-current="page"] .rs-badge { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.sections .rs-add { margin-top: 4px; border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; }

/* Requested chart tools are normal full-page content, never a draggable panel. */
.chart-tools-head { display: flex; justify-content: flex-end; padding: 10px 16px 0; }
@media (max-width: 1023px) {
  .chart-tools-head + .section-body { padding-top: 8px; }
}


.mode-slot { height: 100%; display: flex; align-items: center; padding-left: 12px; flex: none; }
.sb-brand { font-weight: 600; color: var(--text); }
.sp-site { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.sp-site dt { color: var(--text-2); font-size: 13px; }
.sp-site dd { margin: 0; }
.sp-tools .sp-kind.input { flex: 0 0 auto; width: auto; min-width: 0; }
.kind-tabs { margin: 0; }

/* Shared mobile right-side reveal; its width never changes the map's geometry. */
.chart-settings-drawer, .chart-drawer-back { display: none; }
@media (max-width: 1023px) {
  :root { --chart-drawer-w: min(480px, calc(100vw - 56px)); --chart-drawer-motion: 320ms cubic-bezier(.22, .75, .25, 1); }
  .chart-settings-drawer { display: flex; flex-direction: column; position: fixed; top: 0; right: 0; bottom: 0;
    width: var(--chart-drawer-w); z-index: 900; background: var(--surface); overflow: hidden;
    padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: translateX(24%); visibility: hidden; transition: transform var(--chart-drawer-motion), visibility 0s 320ms; }
  .chart-drawer-head { display: flex; justify-content: flex-end; flex: none; padding: var(--s3) var(--s4) 0; }
  .chart-drawer-head .btn { width: var(--touch); height: var(--touch); }
  .chart-settings-drawer .view { padding: var(--s3) var(--s4) var(--s5); overscroll-behavior: contain; }
  .chart-settings-drawer .view-head { align-items: start; }
  .chart-settings-drawer .layers-pop { position: relative; inset: auto !important; width: 100%; max-height: none; min-height: 0; flex: 1;
    border: 0; border-radius: 0; box-shadow: none; padding: var(--s3) var(--s4) var(--s5); overflow-y: auto; overscroll-behavior: contain; animation: none; }
  .chart-settings-drawer .layers-pop > .mc-head { top: calc(-1 * var(--s3)); margin: calc(-1 * var(--s3)) calc(-1 * var(--s4)) var(--s3); padding: var(--s3) var(--s4); }
  .chart-settings-drawer .layers-pop > .mc-head [data-close] { display: none; }
  body[data-chart-drawer="open"] .chart-settings-drawer { transform: translateX(0); visibility: visible; transition-delay: 0s; }
  body[data-chart-drawer] .mapwrap, body[data-chart-drawer] #aux { transition: transform var(--chart-drawer-motion); box-shadow: var(--shadow-reveal); }
  body[data-chart-drawer] .mapwrap { z-index: 950; }
  body[data-chart-drawer="open"] .mapwrap, body[data-chart-drawer="open"] #aux { transform: translateX(calc(-1 * var(--chart-drawer-w))); }
  body[data-chart-drawer="open"] .chart-drawer-back { display: block; position: fixed; inset: 0 auto 0 0;
    width: calc(100vw - var(--chart-drawer-w)); z-index: 1100; border: 0; background: transparent; cursor: pointer; }
  @media (prefers-reduced-motion: reduce) {
    .chart-settings-drawer, body[data-chart-drawer] .mapwrap, body[data-chart-drawer] #aux { transition: none; }
  }
}
