/* === CoreScope — style.css === */

/* Phosphor icon sprite helper (#1648 M1).
 * Icons live in public/icons/phosphor-sprite.svg as <symbol id="ph-NAME">.
 * Reference with: <svg class="ph-icon"><use href="/icons/phosphor-sprite.svg#ph-NAME"/></svg>
 * Inherits color via currentColor; sized to 1em so it scales with surrounding text. */
.ph-icon {
  width: 1em;
  height: 1em;
  /* #1648 M1 follow-up: icons are 1em-sized so they scale with the
   * surrounding text — but several nav surfaces use a smaller font-size
   * (top-nav text is ~12.8px), which dropped the rendered icon below the
   * intended 16px floor. Pin .ph-icon's own font-size to 16px so the
   * icon scales independently of the parent's text size. */
  font-size: 16px;
  vertical-align: -0.125em;
  fill: currentColor;
  flex-shrink: 0;
}

/* Status-token color classes (#1648 M3).
 * Replace 🟢🟡🔴⚪/✅⚠️❌ emoji dots with Phosphor sprites that inherit EMOJI-OK-COMMENT
 * their color via currentColor. Each class threads the existing
 * --status-* color token so dark/light theming continues to work.
 *
 * Pattern:
 *   <span class="status-ok"><svg class="ph-icon"><use href="…#ph-circle-fill"/></svg></span>
 */
.status-ok    { color: var(--status-green); }
.status-warn  { color: var(--status-yellow); }
.status-err   { color: var(--status-red); }
.status-muted { color: var(--text-muted, #94a3b8); }
.status-ok .ph-icon,
.status-warn .ph-icon,
.status-err .ph-icon,
.status-muted .ph-icon { fill: currentColor; }

/* Aldrich webfont — used by the navbar logo SVG (issue #1137 follow-up).
 * Self-hosted woff2 (latin subset from Google Fonts, ~16KB). Only weight
 * available is 400; the SVG's font-weight="700" synthesizes bold. */
@font-face {
  font-family: 'Aldrich';
  src: url('/fonts/aldrich-regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ============================================================
 * Z-INDEX SCALE (single source of truth — issues #1128, #1131, #1128 followup)
 * ------------------------------------------------------------
 * Use these tokens for ANY new stacking context. Raw z-index
 * literals are legacy and being migrated. When touching a rule
 * with a literal z-index, replace it with the appropriate token
 * below.
 *
 *   --z-base            0     document base, table cells
 *   --z-dropdown        100   in-flow dropdowns anchored to a
 *                             toolbar control (multi-select,
 *                             saved-filter, column-toggle,
 *                             autocomplete, region dropdown,
 *                             node-filter dropdown)
 *   --z-popover         300   popovers anchored to a dropdown
 *                             or table cell (path-overflow +N,
 *                             hop-conflict, autocomplete row
 *                             detail). Sits ABOVE dropdowns
 *                             but BELOW modals.
 *   --z-modal-backdrop  9000  full-viewport modal scrim
 *   --z-modal           9100  modal panels themselves
 *   --z-tooltip         9200  tooltips, ctx menus, hover popovers
 *                             that must float above modals
 *
 * Lint: scripts/check-css-vars.js asserts every var(--name)
 * reference resolves; CI will fail on undefined custom properties
 * (see #1128 Bug 4 root cause — `--surface` shipped undefined
 * and 8 dropdowns rendered transparent).
 *
 * Migration policy: legacy literal z-index values that work are
 * left in place to avoid behavioural risk; new code MUST use
 * the tokens. The 10 highest-traffic dropdowns/popovers in the
 * packets toolbar were renumbered in the #1128 followup.
 * ============================================================ */

/* ============================================================
 * FLUID SCAFFOLDING (issue #1054)
 * ------------------------------------------------------------
 * Global design tokens for spacing, typography, and container
 * layout. All values use clamp()/min() so the layout scales
 * smoothly between ~768px and ~2560px viewports without media
 * queries. Targets at the historic 1440px design width match
 * the previous hardcoded px values to within ~1px so existing
 * pages render identically there.
 *
 * Component-specific spacing/typography (nav, tables, charts,
 * map, packets, analytics, …) lives in its own marked region
 * further below — DO NOT add component CSS in this region.
 * ============================================================ */

/* ============================================================
 * TIER-1 PALETTE — raw colour stops. Theme-independent.
 * Issue #1671 / #1668 M2. Single source of truth for every hex
 * value that ships in this file. Outside this block, no rule
 * may use a raw `#hex` or `rgb(...)` literal — use a token.
 * Source: Tailwind CSS v3 default palette (MIT licensed,
 * battle-tested for WCAG-graded luminance steps).
 *   gray  ×9   blue  ×9   green ×5
 *   amber ×5   red   ×5   purple ×5
 * Total palette tokens: 38.
 * ============================================================ */
:root {
  /* Grays — 9 stops, low → high luminance */
  --palette-gray-50:  #f9fafb;
  --palette-gray-100: #f3f4f6;
  --palette-gray-200: #e5e7eb;
  --palette-gray-300: #d1d5db;
  --palette-gray-400: #9ca3af;
  --palette-gray-500: #6b7280;
  --palette-gray-600: #4b5563;
  --palette-gray-700: #374151;
  --palette-gray-800: #1f2937;
  --palette-gray-900: #111827;

  /* Blues — accent / info family */
  --palette-blue-100: #dbeafe;
  --palette-blue-200: #bfdbfe;
  --palette-blue-300: #93c5fd;
  --palette-blue-400: #60a5fa;
  --palette-blue-500: #3b82f6;
  --palette-blue-600: #2563eb;
  --palette-blue-700: #1d4ed8;
  --palette-blue-800: #1e40af;
  --palette-blue-900: #1e3a8a;

  /* Greens / ambers / reds / purples — status families */
  --palette-green-300: #86efac;
  --palette-green-400: #4ade80;
  --palette-green-500: #22c55e;
  --palette-green-600: #16a34a;
  --palette-green-700: #15803d;

  --palette-amber-300: #fcd34d;
  --palette-amber-400: #fbbf24;
  --palette-amber-500: #f59e0b;
  --palette-amber-600: #d97706;
  --palette-amber-700: #b45309;

  --palette-red-300: #fca5a5;
  --palette-red-400: #f87171;
  --palette-red-500: #ef4444;
  --palette-red-600: #dc2626;
  --palette-red-700: #b91c1c;

  --palette-purple-300: #c4b5fd;
  --palette-purple-400: #a78bfa;
  --palette-purple-500: #8b5cf6;
  --palette-purple-600: #7c3aed;
  --palette-purple-700: #6d28d9;
}

:root {
  /* #680 DHM terrain overlay: multiply darkens the base map by the
     hillshade's shadows. Dark themes (both blocks below) invert the
     hillshade and screen it, the same treatment the inverted dark base
     tiles get, so relief shows as light ridges and labels stay readable. */
  --terrain-overlay-blend: multiply;
  --terrain-overlay-filter: none;
  /* #752 — compact map credit for the inset maps (node detail, node-reach,
     packet-path, area-nodes, rx-coverage, Analytics subpath). The smallest
     inset is 200px tall (160px at <=640px), and the Esri World Imagery
     credit is long enough to wrap, so the credit is capped at two lines and
     scrolls; nothing is cut away, and it never takes more than about a
     seventh of the smallest inset. */
  --mc-credit-compact-font-size: 10px;
  --mc-credit-compact-line-height: 1.3;
  --mc-credit-compact-max-width: 70%;
  --mc-credit-compact-padding-v: 1px;
  --mc-credit-compact-padding-h: 5px;
  /* #756 — box-sizing is border-box, so the vertical padding eats into the
     content height the font-size/line-height product budgets for. Without
     it, every two-line credit (Esri World Imagery) is 2px taller than the
     cap and scrolls even though it only ever has two lines. */
  --mc-credit-compact-max-height: calc(2 * var(--mc-credit-compact-font-size) * var(--mc-credit-compact-line-height) + 2 * var(--mc-credit-compact-padding-v));
  --mc-credit-compact-padding: var(--mc-credit-compact-padding-v) var(--mc-credit-compact-padding-h);
  /* How far a bottom-right inset overlay (the node-detail QR) must sit
     above the map's bottom edge to clear the credit: the cap plus the 8px
     the overlay used to have plus 4px of air. Static, because the cap is a
     constant — no JS measuring as on Live. */
  --mc-credit-compact-clearance: calc(var(--mc-credit-compact-max-height) + 12px);
  /* #681 M4 — Path profile chart. Six tokens so the customizer can reach
     them later (M6). Dark values live in BOTH dark blocks below. */
  --terrain-fill: #9a8a73;                       /* DTM, the bare ground */
  --terrain-clutter: rgba(84, 124, 92, 0.55);    /* DTM → DSM: trees, buildings */
  --los-line: #1d4ed8;                           /* line of sight */
  --fresnel-100: #6d28d9;                        /* first Fresnel zone */
  --fresnel-60: #a78bfa;                         /* the 60 % criterion */
  --profile-blocked: #b91c1c;                    /* terrain in the way */
  /* #730 M3 — the surface band by class: inside a building footprint, and
     trees/other. Each is >= 3:1 against the panel and against the other
     (test-issue-730-buildings-ui.js measures it). Dark values live in
     BOTH dark blocks below. */
  --terrain-building: #5e1f0c;
  --terrain-vegetation: #5a9466;
  /* #781 — the profile's hover cursor: the chart's dashed line and the
     map's dot. Dark values live in BOTH dark blocks below. */
  --tp-cursor: #334155;
  --tp-cursor-dot: #dc2626;
  /* #724 M3 — Mastedatabasen antenna sites on the map (canvas markers read
     these). Dark values live in BOTH dark blocks below. */
  --mast-site: #0e7490;                          /* every antenna site */
  --mast-interference: #c2410c;                  /* 700/800/900 MHz ring */
  /* Node-quality link strength colours (bottleneck tiers). Dark-theme
     overrides live in the [data-theme="dark"] block below (brighter hues). */
  --link-strong: #1a7f37;
  --link-medium: #bf8700;
  --link-weak: #cf222e;
  --link-oneway: #8c959f;  /* one-way (no two-way link) — distinct from weak red */
  /* --- Fluid spacing scale ---------------------------------
   * Targets at 1440px viewport: 4 / 8 / 16 / 24 / 32 / 48 px.
   * Min/max clamps keep small viewports usable and prevent
   * runaway growth on ultra-wide displays.
   */
  --space-xs:  clamp(3px,  0.15vw + 2px,  6px);
  --space-sm:  clamp(6px,  0.30vw + 4px, 12px);
  --space-md:  clamp(10px, 0.50vw + 8px, 20px);
  --space-lg:  clamp(16px, 0.75vw + 12px, 32px);
  --space-xl:  clamp(24px, 1.00vw + 16px, 48px);
  --space-2xl: clamp(32px, 2.00vw + 20px, 64px);

  /* --- Fluid type scale ------------------------------------
   * Targets at 1440px viewport: 13 / 16 / 18 / 24 / 32 px.
   * Floors ensure readability at 768px; caps prevent giant
   * text at 2560px+.
   */
  --fs-sm:  clamp(12px, 0.15vw + 11px, 14px);
  --fs-md:  clamp(14px, 0.20vw + 13px, 17px);
  --fs-lg:  clamp(15px, 0.30vw + 14px, 20px);
  --fs-xl:  clamp(18px, 0.50vw + 16px, 28px);
  --fs-2xl: clamp(22px, 0.75vw + 20px, 36px);

  /* --- Typography weight tokens — #1668 M3 ----------------
   * Chip / badge / meta rule (M3): font-size >= 14px OR
   * (font-size >= 12px AND font-weight >= 500). Use --fw-medium
   * on anything that stays at 12-13px to keep it readable. */
  --fw-normal:   400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;

  /* --- Fluid radii ----------------------------------------- */
  --radius-sm: clamp(3px, 0.1vw + 2px, 6px);
  --radius-md: clamp(6px, 0.2vw + 5px, 12px);
  --radius-lg: clamp(10px, 0.3vw + 8px, 18px);

  /* --- Container layout ------------------------------------
   * --gutter scales the side padding; --content-max caps the
   * usable content width but always leaves a gutter on each
   * side at small viewports.
   */
  --gutter: clamp(12px, 2vw, 32px);
  --content-max: min(100% - (2 * var(--gutter)), 1600px);

  --nav-bg: #0f0f23;
  --nav-bg2: #1a1a2e;
  --nav-text: #ffffff;
  --nav-text-muted: #cbd5e1;
  --nav-active-bg: rgba(74, 158, 255, 0.15);
  --accent: #4a9eff;
  /* #1668 M2 — accessible accent for chips/badges/active buttons that put
     white text on a blue surface. The legacy --accent (#4a9eff) yields
     #fff/#4a9eff = 2.75:1 (BLOCKER per M1 audit). --accent-strong drops
     two stops to palette-blue-600 = #2563eb (#fff on it = 4.83:1, AA pass)
     and is the surface for: .skip-link, .btn.active, .hop-link.hop-named,
     .nav-link.active background, .fGroup.active. */
  --accent-strong: var(--palette-blue-600);
  --text-on-accent: var(--palette-gray-50);
  /* #1668 M5 — accessible link/text color. The legacy --accent (#4a9eff)
     used for text-on-light backgrounds was 2.52:1 on white (BLOCKER per
     M5 axe gate, 219 hits across .analytics-link / .sort-active / .ch-*).
     Dark theme override below bumps to palette-blue-400 (#60a5fa) so
     links stay readable on surface-0 (#0f0f23 ≈ 8.4:1, AA pass).
     Use --link-color for any "text rendered ON the page surface that
     should look like a link / interactive accent" — NOT for backgrounds.
     Backgrounds carrying white text continue to use --accent-strong. */
  /* #1668 M5 — accessible semantic status colors. The legacy fallbacks
     baked into JS (var(--success, #22c55e)) used the bright palette-500
     hues which fail AA against white surfaces (#22c55e/white = 2.27:1,
     #ef4444/white = 3.76:1). New theme-aware tokens use palette-700 on
     light surfaces (5.0-6.5:1 vs white) and palette-400/500 on dark
     (6+:1 vs surface-0/1). All callers should now read --success /
     --warning / --danger WITHOUT a hex fallback (kept as legacy support
     only). */
  --success: var(--palette-green-700, #15803d);
  --warning: #b45309;
  --danger: var(--palette-red-600, #dc2626);
  /* #353 — 1-byte path hash recommendation (renderPathHashSize in app.js).
     Round 3 (operator decision): a 1-byte hash is a recommendation, not an
     error, so it follows the amber --warning palette (not --danger) in both
     themes. WCAG AA (>= 4.5:1) on every surface it renders on: channel badge
     and node badge 5.02:1 light / 10.51:1 dark, packet-detail row 4.60:1 light
     / 13.09:1 dark. Themeable via the customizer (pathHashWarn). */
  --path-hash-warn: var(--warning);
  --link-color: var(--palette-blue-600);
  --accent-bg: rgba(59, 130, 246, 0.12);
  --accent-border: rgba(59, 130, 246, 0.25);
  --geo-filter-color: #3b82f6;
  --status-green: #22c55e;
  /* #1719 — `--status-green` (#22c55e) is the BACKGROUND swatch hue
     (used as `background:` on badges + dots over white card surfaces).
     As TEXT on a white .analytics-stat-card it is only 2.28:1 (BLOCKER).
     `--status-green-text` is the text-only variant for surfaces that
     render numbers/labels in the green palette over light cards — pinned
     to palette-green-700 (#15803d) → 5.06:1 on #fff (AA pass). Dark
     theme overrides keep the bright #22c55e since it reads ≥6:1 on the
     card-bg #232340. */
  --status-green-text: var(--palette-green-700, #15803d);
  --status-yellow: #eab308;
  --status-red: #ef4444;
  --status-orange: #f97316;
  --status-purple: #a855f7;
  --status-amber: #f59e0b;
  --status-amber-light: #fef3c7;
  --status-amber-text: #92400e;
  /* #1719 — `--skew-badge-no-clock-bg` carries the muted "no clock data"
     badge background (was --text-muted which renders #d1d5db in dark
     theme → #fff text = 1.47:1, BLOCKER × 137 on clock-health). Pinned
     to palette-gray-600 (#4b5563) so #fff text reads 7.56:1 on both
     themes (light: 7.56:1, dark: 7.56:1). */
  --skew-badge-no-clock-bg: var(--palette-gray-600, #4b5563);
  /* #1648 M6 (M4 CDP carry-forward): named token for the neutral/info
     accent used as the unrolled-route hop fallback color (was #3b82f6
     baked in route-render.js). Themes via dark-mode block below. */
  --status-info: #3b82f6;
  --path-inspector-speculative: #d97706;
  /* #1715 — neighbor-graph role swatches (`#ngRoleChecks` labels) read
   * these tokens via the role-suffixed `.role-swatch--ROLE` class (analytics.js).
   * Light-theme values are palette-700 shades that clear WCAG AA ≥4.5:1
   * against the white analytics surface (#ffffff). Dark-theme overrides
   * live in the [data-theme="dark"] block further down and use palette-400
   * shades that clear AA against the dark card-bg (#1a1a2e). Keeping the
   * swatch palette as CSS custom properties is what kept #1715 from
   * regressing — never reintroduce inline `style="color:#..."` on these
   * spans. */
  --role-repeater:  #dc2626;  /* 4.83:1 on #fff */
  --role-companion: #2563eb;  /* 5.17:1 on #fff */
  --role-room:      #15803d;  /* 5.02:1 on #fff */
  --role-sensor:    #b45309;  /* 5.02:1 on #fff */
  --role-observer:  #7c3aed;  /* 5.70:1 on #fff */
  --accent-hover: #6db3ff;
  --text: #1a1a2e;
  /* #1668 M2 — bumped from #5b6370 (~5.7:1 on white) to palette-gray-700
     #374151 (~10.3:1 on white, ~9.9:1 on surface-0 #f4f5f7). Light theme
     muted text was a MAJOR/borderline case; this clears the buffer. */
  --text-muted: var(--palette-gray-700);
  --text-subtle: var(--palette-gray-600);
  --border: #e2e5ea;
  --row-stripe: #f9fafb;
  --row-hover: #eef2ff;
  --detail-bg: #ffffff;
  --badge-radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
  --input-bg: #fff;
  --selected-bg: #dbeafe;

  /* --- Logo theme tokens (PR #1137 + brand-default follow-up) -----------
   * The CoreScope SVG logos are inlined into the DOM (navbar +
   * home hero), so they inherit page CSS custom properties. The
   * legacy --logo-* names are kept so existing themes / brand
   * customizations that override them still work.
   *   --logo-text   → wordmark "CORE" / "SCOPE" / labels
   *   --logo-accent → primary node + left-side arcs   (default sage)
   *   --logo-accent-hi → secondary node + right-side arcs (default teal)
   *   --logo-muted  → tagline + sine wave
   * Sage (#cfd9c9 — fog) and teal (#2c8c8c — water) are the OUT-OF-BOX
   * brand identity. They are NOT cascaded from --accent any more, so
   * changing the app accent color via dev tools alone will NOT recolor
   * the logo. The customizer (public/customize-v2.js) mirrors --accent
   * and --accent-hover into --logo-accent / --logo-accent-hi when an
   * operator picks a theme, preserving full theme-driven recoloring.
   * No --logo-bg here on purpose — the inlined SVGs MUST be transparent
   * so they sit on whatever bg the page paints. --logo-text defaults to
   * --text (the page foreground) so the hero wordmark is readable on
   * any theme; the navbar scopes it to --nav-text below so it stays
   * white on the dark navbar. */
  --logo-text: var(--text);
  --logo-accent: #cfd9c9;
  --logo-accent-hi: #2c8c8c;
  --logo-muted: var(--text-muted);

  --surface-0: #f4f5f7;
  --surface-1: #ffffff;
  --surface-2: #ffffff;
  --surface-3: #ffffff;
  /* #1128 (Bug 4): `--surface` was referenced in 8+ rules (.fux-saved-menu,
   * .fux-popover, .path-popover, .fux-ac-dropdown, .fux-ctx-menu, ...) but
   * never defined → backgrounds resolved transparent → row content bled
   * through dropdowns. Alias it to the opaque card surface. */
  --surface: var(--surface-1);
  --content-bg: var(--surface-0);
  --card-bg: var(--surface-1);
  --hover-bg: rgba(0,0,0, 0.04);
  /* #1128 followup: caught by scripts/check-css-vars.js — these were
   * referenced without a fallback in .rf-detail-meta, .rf-detail-close
   * and .tools-card and would resolve transparent / inherit. Alias them
   * to existing tokens. */
  --text-primary: var(--text);
  --bg-hover: var(--hover-bg);
  --primary: var(--accent);
  /* #1128 followup M3: extended check-css-vars.js to scan JS/HTML inline
   * styles (analytics.js, nodes.js) caught these undefined refs.
   * Aliased to existing tokens — same pattern as --text-primary above. */
  --bg-secondary: var(--surface-2);
  --text-secondary: var(--text-muted);
  --bg: var(--surface);
  /* PR #893: --shadow used by .theme-toggle thumb shadow; define in :root for
   * light theme. Dark theme override is set in both dark-mode blocks below. */
  --shadow: rgba(0,0,0,0.3);
  --trace-ghost-color: #94a3b8;

  /* #620: minimum viewport margin of the region/area dropdown menus. Read by
   * region-filter.js placeMenu() as well as the menu max-width below. */
  --region-menu-gutter: 8px;

  /* #1128: documented z-index scale. Use these custom props for any new
   * stacking context decision. Existing legacy z-index values that work are
   * left in place to avoid behavioural risk; new code must use these tokens.
   *   --z-base       0   document base, table cells
   *   --z-dropdown   100 in-flow dropdowns (multi-select, saved, columns)
   *   --z-popover    300 popovers anchored to dropdowns / cells
   *   --z-modal-backdrop 9000 / --z-modal 9100 / --z-tooltip 9200
   */
  --z-base: 0;
  --z-dropdown: 100;
  --z-popover: 300;
  --z-modal-backdrop: 9000;
  --z-modal: 9100;
  --z-tooltip: 9200;
}

/* ⚠️ DARK THEME VARIABLES — KEEP BOTH BLOCKS IN SYNC EMOJI-OK-COMMENT
   The media query handles OS-level dark mode (auto); [data-theme="dark"] handles manual toggle.
   When changing dark theme variables, update BOTH blocks below. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --terrain-overlay-blend: screen;
    --terrain-overlay-filter: invert(1);
    /* #681 M4 — Path profile chart on dark surfaces. */
    --terrain-fill: #5d5444;
    --terrain-clutter: rgba(122, 170, 132, 0.45);
    --los-line: #60a5fa;
    --fresnel-100: #c4b5fd;
    --fresnel-60: #8b5cf6;
    --profile-blocked: #f87171;
    /* #730 M3 — the surface band by class. */
    --terrain-building: #e6cdb0;
    --terrain-vegetation: #337f4c;
    /* #781 — the profile's hover cursor. */
    --tp-cursor: #e2e8f0;
    --tp-cursor-dot: #f87171;
    /* #724 M3 — antenna sites on dark tiles. */
    --mast-site: #22d3ee;
    --mast-interference: #fb923c;
    --status-green: #22c55e;
    /* #1719 — on dark card-bg (#232340) #22c55e gives 6.65:1, AA pass.
       Keep the bright hue for text rather than darkening it. */
    --status-green-text: #22c55e;
    /* #1719 — keep --skew-badge-no-clock-bg dark enough for #fff text. */
    --skew-badge-no-clock-bg: var(--palette-gray-600, #4b5563);
    --status-yellow: #eab308;
    --status-red: #ef4444;
    --status-orange: #f97316;
    --status-purple: #a855f7;
    --status-amber: #f59e0b;
    --status-amber-light: #422006;
    --status-amber-text: #fcd34d;
    --path-inspector-speculative: #f59e0b;
    /* #1715 — dark-theme role swatch overrides. Light values (palette-700)
     * fail 4.5:1 on the dark analytics card-bg #1a1a2e (e.g. #dc2626 →
     * 3.53:1). Palette-400/500 shades clear AA on dark. Mirror these in
     * the [data-theme="dark"] block below. */
    --role-repeater:  #ef4444;  /* 4.53:1 on #1a1a2e */
    --role-companion: #3b82f6;  /* 4.64:1 on #1a1a2e */
    --role-room:      #16a34a;  /* 5.18:1 on #1a1a2e */
    --role-sensor:    #d97706;  /* 5.35:1 on #1a1a2e */
    --role-observer:  #a78bfa;  /* 6.27:1 on #1a1a2e */
    --status-info: #60a5fa;
    /* #1668 M5 — bump link text up two stops on dark surfaces (4a9eff
       was OK but borderline on card-bg; #60a5fa = palette-blue-400 ≈
       7.8:1 on surface-0, 5.4:1 on card-bg, AA pass either way). */
    --link-color: var(--palette-blue-400);
    /* #1668 M5 — bright -400/-500 hues for AA against dark surfaces */
    --success: var(--palette-green-400, #4ade80);
    --warning: #fcd34d;
    --danger:  var(--palette-red-400, #f87171);
    --surface-0: #0f0f23;
    --surface-1: #1a1a2e;
    --surface-2: #232340;
    --surface-3: #2d2d50;
    --surface: var(--surface-1);
    --content-bg: var(--surface-0);
    --card-bg: var(--surface-2);
    --text: #e2e8f0;
    /* #1668 M2 — text-muted bumped from #a8b8cc to palette-gray-300
       (#d1d5db); ~8.7:1 on surface-0, ~7.6:1 on card-bg (was ~7.5:1).
       Clears `span.text-muted` BLOCKERs flagged on translucent surfaces
       (where the legacy value dropped below 4.5 once alpha-stacked). */
    --text-muted: var(--palette-gray-300);
    --text-subtle: var(--palette-gray-400);
    --border: #334155;
    --row-stripe: #1e1e34;
    --row-hover: #2d2d50;
    --detail-bg: #232340;
    --input-bg: #1e1e34;
    --selected-bg: #1e3a5f;
    --hover-bg: rgba(255,255,255, 0.06);
    --shadow: rgba(0,0,0,0.5);
    --trace-ghost-color: #94a3b8;
    --section-bg: #1e1e34;
  }
}
/* ⚠️ DARK THEME VARIABLES — KEEP IN SYNC with @media block above (EMOJI-OK-COMMENT) */
[data-theme="dark"] {
  color-scheme: dark;
  --terrain-overlay-blend: screen;
  --terrain-overlay-filter: invert(1);
  /* #681 M4 — Path profile chart on dark surfaces (mirror of the @media block). */
  --terrain-fill: #5d5444;
  --terrain-clutter: rgba(122, 170, 132, 0.45);
  --los-line: #60a5fa;
  --fresnel-100: #c4b5fd;
  --fresnel-60: #8b5cf6;
  --profile-blocked: #f87171;
  /* #730 M3 — the surface band by class (mirror of the @media block). */
  --terrain-building: #e6cdb0;
  --terrain-vegetation: #337f4c;
  /* #781 — the profile's hover cursor (mirror of the @media block). */
  --tp-cursor: #e2e8f0;
  --tp-cursor-dot: #f87171;
  /* #724 M3 — antenna sites on dark tiles (mirror of the @media block). */
  --mast-site: #22d3ee;
  --mast-interference: #fb923c;
  /* Brighter link-strength hues for contrast on dark map tiles + surfaces. */
  --link-strong: #3fb950;
  --link-medium: #d29922;
  --link-weak: #f85149;
  --link-oneway: #768390;
  --status-green: #22c55e;
  /* #1719 — see :root[prefers-color-scheme:dark] block; mirror here. */
  --status-green-text: #22c55e;
  --skew-badge-no-clock-bg: var(--palette-gray-600, #4b5563);
  --status-yellow: #eab308;
  --status-red: #ef4444;
  --status-orange: #f97316;
  --status-purple: #a855f7;
  --status-amber: #f59e0b;
  --status-amber-light: #422006;
  --status-amber-text: #fcd34d;
  --status-info: #60a5fa;
  /* #1715 — dark-theme role swatch overrides (mirrors the media-query
   * block above). Palette-400/500 shades clear WCAG AA on #1a1a2e. */
  --role-repeater:  #ef4444;  /* 4.53:1 on #1a1a2e */
  --role-companion: #3b82f6;  /* 4.64:1 on #1a1a2e */
  --role-room:      #16a34a;  /* 5.18:1 on #1a1a2e */
  --role-sensor:    #d97706;  /* 5.35:1 on #1a1a2e */
  --role-observer:  #a78bfa;  /* 6.27:1 on #1a1a2e */
  /* #1668 M5 — see :root[data-theme="dark"] media block above for rationale */
  --link-color: var(--palette-blue-400);
  --success: var(--palette-green-400, #4ade80);
  --warning: #fcd34d;
  --danger:  var(--palette-red-400, #f87171);
  --surface-0: #0f0f23;
  --surface-1: #1a1a2e;
  --surface-2: #232340;
  --surface-3: #2d2d50;
  --surface: var(--surface-1);
  --content-bg: var(--surface-0);
  --card-bg: var(--surface-2);
  --text: #e2e8f0;
  /* #1668 M2 — see :root[data-theme="dark"] media block for rationale */
  --text-muted: var(--palette-gray-300);
  --text-subtle: var(--palette-gray-400);
  --border: #334155;
  --row-stripe: #1e1e34;
  --row-hover: #2d2d50;
  --detail-bg: #232340;
  --input-bg: #1e1e34;
  --selected-bg: #1e3a5f;
  --hover-bg: rgba(255,255,255, 0.06);
  --shadow: rgba(0,0,0,0.5);
  --trace-ghost-color: #94a3b8;
  --section-bg: #1e1e34;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; font-family: var(--font); font-size: var(--fs-md); background: var(--content-bg); color: var(--text); }

/* ============================================================
 * COMPONENT STYLES — page-specific rules below.
 * (Nav, tables, charts, map, packets, analytics, etc.)
 * Tasks 1050-3..6 / 1052-* edit sections inside this region.
 * ============================================================ */

/* === Skip Link === */
/* #1668 M2 — was background:var(--accent) (#4a9eff) with white text =
   2.75:1 BLOCKER. Bumped to --accent-strong / --text-on-accent for
   4.83:1 AA pass (both themes). */
.skip-link { position: absolute; top: -100%; left: 16px; padding: 8px 16px; background: var(--accent-strong); color: var(--text-on-accent); border-radius: 6px; z-index: 999; font-weight: 600; text-decoration: none; }
.skip-link:focus { top: 8px; }

/* === Focus Indicators === */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
.data-table tbody tr:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* === Touch Targets === */
/* House preference: 48x48 CSS px minimum for the controls below (#2052),
   above WCAG 2.5.5's 44x44 minimum. Targets use min-height/min-width
   plus inline-flex centering so existing visual styling (font-size, padding,
   icon size) is preserved on desktop while the *hit area* grows for touch.
   Issue #1060.

   Issue #1400: the global `min-height: 48px` on `.nav-link` was the root
   cause of ~20 recurring nav-vanishing bugs (#1391, #1396, and ~18 earlier
   symptoms). 48px links + padding inflated `.nav-links` to 56px tall inside
   a 52px `.top-nav` with `overflow:hidden`; Firefox flex-centered the
   over-tall item to a negative y, clipping the entire link strip ABOVE the
   viewport. Touch-target sizing is preserved for mobile via the
   `@media (max-width: 767px)` override added near the hamburger block. */
.nav-link { display: inline-flex; align-items: center; }

/* Generic button surfaces — filter bar, modal buttons, inline .btn usages.
   inline-flex keeps text/icons centered without changing visible padding much. */
.btn,
.filter-bar .btn,
.filter-group .btn {
  min-height: 48px;
  min-width: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn-icon {
  min-height: 48px;
  min-width: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  touch-action: manipulation;
}

.nav-btn {
  min-height: 48px;
  min-width: 48px;
  touch-action: manipulation;
}

.ch-icon-btn,
.ch-row-menu-item {
  min-height: 48px;
  min-width: 48px;
  touch-action: manipulation;
}

.ch-gear-btn {
  min-height: 48px;
  min-width: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  touch-action: manipulation;
}

.panel-close-btn {
  min-height: 48px;
  min-width: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  touch-action: manipulation;
}

.mc-jump-btn {
  min-height: 48px;
  min-width: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  touch-action: manipulation;
}

button.ch-item {
  min-height: 48px;
  touch-action: manipulation;
}

/* Additional button-like controls discovered during PR #1067 review (Issue
   #1060 follow-up). Same 48x48 house minimums + touch-action. */
.btn-link,
.col-toggle-btn,
.filter-toggle-btn,
.ch-add-channel-btn,
.ch-back-btn,
.ch-modal-btn-secondary,
.ch-scroll-btn,
.chooser-btn,
.clock-filter-btn,
.copy-link-btn,
.alab-btn {
  min-height: 48px;
  min-width: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn-link:active,
.col-toggle-btn:active,
.filter-toggle-btn:active,
.ch-add-channel-btn:active,
.ch-back-btn:active,
.ch-modal-btn-secondary:active,
.ch-scroll-btn:active,
.chooser-btn:active,
.clock-filter-btn:active,
.copy-link-btn:active,
.alab-btn:active {
  background: var(--row-hover);
  transform: scale(0.97);
  opacity: 0.9;
}

/* Form controls: native <select> and text-like <input> need 48px tap targets
   too. Scoped to interactive input types — checkbox/radio/range keep their
   own visible size and rely on a wrapping label/parent for hit area. */
select,
input[type="text"],
input[type="search"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"],
input[type="week"] {
  min-height: 48px;
  box-sizing: border-box;
  touch-action: manipulation;
}

/* Theme the UA-native checkbox + radio so they pick up the page accent
 * instead of rendering as bare white squares against the dark theme.
 * Pairs with `color-scheme: dark` on the dark-theme rule so the box
 * surround also re-skins. (Tufte #1646 — bare native widgets are
 * chartjunk-by-omission: they advertise the chrome, not the data.) */
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent);
}

/* Visible :active states — touch devices have no hover, so :active is the
   primary feedback channel. Use opacity + slight scale + background shift so
   the press is felt even when the user's finger covers the control. */
.btn:active,
.filter-bar .btn:active,
.filter-group .btn:active {
  background: var(--row-hover);
  transform: scale(0.97);
  opacity: 0.9;
}
.btn-icon:active {
  background: var(--row-hover);
  transform: scale(0.97);
}
.nav-btn:active {
  background: var(--nav-bg2);
  transform: scale(0.97);
  opacity: 0.9;
}
.ch-icon-btn:active {
  opacity: 1;
  transform: scale(0.92);
}
.ch-gear-btn:active,
.panel-close-btn:active,
.mc-jump-btn:active {
  background: var(--row-hover);
  transform: scale(0.95);
}

/* Hover→tap conversion. Hover-only feedback (e.g., tooltip reveal) is gated
   behind @media (hover: hover) so touch devices don't get stuck in a hover
   state after a tap. The same content is exposed on tap via :focus-within
   below. */
@media (hover: hover) {
  .sort-help:hover .sort-help-tip { display: block; }
}

/* Tap-to-reveal tooltip: .sort-help becomes keyboard/tap focusable (set
   tabindex="0" in markup). On focus or focus-within, the tip is shown so a
   tap on touch devices reveals it without requiring hover. */
.sort-help { outline: none; }
.sort-help:focus,
.sort-help:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
.sort-help:focus .sort-help-tip,
.sort-help:focus-within .sort-help-tip { display: block; }

/* === Nav (Issue #1055 — Priority+ at all widths) ===
   The top-nav uses Priority+ at ALL widths: only links marked
   data-priority="high" render inline; everything else collapses into
   the "More ▾" menu. This eliminates the historic 1080–1279px overflow
   window AND the 1280–1599px overlap window where the full link strip
   ran underneath .nav-right. Spacing and type use the #1054 fluid
   clamp() tokens so the bar scales smoothly across viewport widths.
   The hamburger and stacked mobile layout still take over at <768px. */
.top-nav {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(135deg, var(--nav-bg) 0%, var(--nav-bg2) 100%); color: var(--nav-text);
  padding: 0 var(--gutter); height: 52px;
  position: sticky; top: 0; z-index: 1100;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  flex-wrap: nowrap; overflow: hidden; min-width: 0;
  /* #1413: enforce a minimum horizontal gap between flex children of
     .top-nav (.nav-left and .nav-right). Without this the only thing
     pushing nav-right away from nav-left was justify-content: space-
     between, which collapses to zero whenever nav-left's intrinsic
     content fills the row — including the historic vw~1101..1599 band
     where .nav-stats reappears (display:flex) and shoves nav-right
     leftward to overlap the .nav-more-btn. */
  column-gap: 16px;
}
/* #1403: removed overflow:hidden — was clipping flex children offscreen (vertical) AND clipping the More dropdown contents. The original purpose was to prevent horizontal overflow during Priority+ measurement (#1066) — that purpose is served by .top-nav itself which still has overflow:hidden. */
.nav-left { display: flex; align-items: center; gap: var(--space-lg); min-width: 0; flex-shrink: 1; }
.nav-brand { display: flex; align-items: center; gap: var(--space-sm); text-decoration: none; color: var(--nav-text); font-weight: 700; font-size: var(--fs-md); }
.brand-icon { font-size: 20px; }
/* #1450 — split .brand-logo by element type:
   - Inline default wordmark (<svg>) keeps the 125x36 pin tuned to its
     viewBox (#1141 widened it to fit CORE/SCOPE; intrinsic content
     ratio ~3.08:1, so width:125px @ height:36px is the natural box).
   - Operator custom logo via branding.logoUrl is an <img>, whose
     natural aspect ratio MUST be preserved — pinning width:125px on
     a 1:1 or portrait image squishes it into a pill. Use width:auto
     with a max-width cap so wide logos don't blow the nav layout. */
svg.brand-logo {
  display: block;
  height: 36px;
  width: 125px;
  max-height: 36px;
  /* The logo is inlined into the DOM (PR #1137) so it inherits page
     CSS variables; theme via --logo-text / --logo-accent / etc. defined
     in :root above. The .top-nav scope below overrides --logo-text to
     --nav-text so the wordmark stays readable on the dark navbar even
     when the page theme is Light. */
}
img.brand-logo {
  display: block;
  height: 36px;
  width: auto;          /* preserve natural aspect of operator image */
  max-width: 200px;     /* cap wide logos so they can't push nav-right off */
  max-height: 36px;
  object-fit: contain;  /* defensive — never crop or stretch the image */
}
.top-nav {
  /* Navbar lives on --nav-bg (typically dark), so the brand wordmark
     must use --nav-text rather than the page --text default. */
  --logo-text: var(--nav-text);
}
/* Mark-only navbar logo: hidden by default, swapped in for the full
   wordmark logo at narrow viewports where SCOPE would otherwise clip
   (#1137 mobile width pin was 99px → SCOPE→SCOF at ≤390px). */
.brand-mark-only {
  display: none;
  height: 32px;
  width: auto;
}
/* #1173: legacy navbar `.live-dot` indicator removed — WS state is now
   encoded in the brand-logo itself (.logo-disconnected + packet-driven
   .logo-pulse-active). The navbar element is gone from index.html, so we
   don't ship a `display: none` shell here — `live.js` reuses `.live-dot`
   for legend bullets (styled by live.css) and a global no-op rule would
   wipe those out. If a stale extension/customizer ever injects a navbar
   `.live-dot`, it's a harmless 0×0 unstyled span. */
/* #1173: brand-logo packet-pulse animation.
   - Class toggles only — pure CSS animation. JS adds/removes:
     .logo-pulse-active (chained ping, source then destination)
     .logo-pulse-blip   (reduced-motion fallback, destination only)
     .logo-disconnected (sustained desaturate while WS down)
   - All color comes from --logo-accent / --logo-accent-hi tokens.
     Animation only tweaks filter: brightness() + transform: scale(). */
.brand-logo circle.logo-node-a,
.brand-logo circle.logo-node-b,
.brand-mark-only circle.logo-node-a,
.brand-mark-only circle.logo-node-b {
  transform-box: fill-box;
  transform-origin: center;
  transition: filter .12s ease-out;
  will-change: filter, transform;
}
@keyframes logo-pulse-step {
  0%   { filter: brightness(1);   transform: scale(1); }
  40%  { filter: brightness(1.6); transform: scale(1.18); }
  100% { filter: brightness(1);   transform: scale(1); }
}
.brand-logo circle.logo-pulse-active,
.brand-mark-only circle.logo-pulse-active {
  animation: logo-pulse-step 80ms ease-out;
}
@keyframes logo-pulse-blip-step {
  0%   { opacity: 1; }
  50%  { opacity: 0.55; }
  100% { opacity: 1; }
}
.brand-logo circle.logo-pulse-blip,
.brand-mark-only circle.logo-pulse-blip {
  animation: logo-pulse-blip-step 140ms linear;
}
.brand-logo.logo-disconnected,
.brand-mark-only.logo-disconnected {
  filter: grayscale(0.6) opacity(0.7);
  transition: filter .25s ease-out;
}
@media (prefers-reduced-motion: reduce) {
  .brand-logo circle.logo-pulse-active,
  .brand-mark-only circle.logo-pulse-active {
    /* Defensive: in case anything mistakenly toggles the chained class
       under reduced-motion, neutralize the scale animation. */
    animation: none;
  }
}

.nav-links { display: flex; align-items: center; gap: var(--space-xs); flex: 1 1 auto; min-width: 0; }
.nav-link {
  color: var(--nav-text-muted); text-decoration: none;
  padding: 14px clamp(8px, 0.6vw + 4px, 14px); font-size: var(--fs-sm);
  font-weight: var(--fw-medium); /* #1668 M3 — 12-14px fluid + 500 floor */
  border-bottom: 2px solid transparent; transition: all .15s;
  background: none; border-top: none; border-left: none; border-right: none;
  cursor: pointer; font-family: var(--font);
  white-space: nowrap; /* #1046: never wrap labels — wrapping makes the nav bar grow taller */
}
.nav-link:hover { color: var(--nav-text); }
.nav-link.active { 
  color: var(--nav-text); 
  border-bottom-color: transparent;
  background: var(--nav-active-bg); 
  border-radius: 6px; 
  margin: 4px 0;
  padding: 10px clamp(8px, 0.6vw + 4px, 14px);
}

.nav-dropdown { position: relative; }
.dropdown-menu {
  display: none; position: absolute; top: 100%; left: 0;
  background: var(--nav-bg2); border: 1px solid var(--border); border-radius: 6px;
  min-width: 140px; padding: 4px 0; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.nav-dropdown:hover .dropdown-menu { display: block; }
.dropdown-item {
  display: block; padding: 8px 16px; color: var(--text-muted); text-decoration: none; font-size: 13px;
}
.dropdown-item:hover { background: var(--accent-strong); color: var(--text-on-accent); }

.nav-right { display: flex; align-items: center; gap: var(--space-sm); flex-shrink: 0; }
.nav-btn {
  background: none; border: 1px solid var(--border); color: var(--nav-text-muted); padding: 6px 12px;
  border-radius: 6px; cursor: pointer; font-size: 14px; transition: all .15s;
  display: inline-flex; align-items: center; justify-content: center;
}
.nav-btn:hover { background: var(--nav-bg2); color: var(--nav-text); }

/* === Theme Toggle Switch === */
.theme-toggle {
  display: inline-flex; align-items: center; cursor: pointer;
  padding: 0; margin: 0; border: none; background: none;
  min-width: 48px; min-height: 48px; justify-content: center;
}
.theme-toggle input[type="checkbox"] {
  position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none;
}
.theme-toggle-track {
  position: relative; width: 46px; height: 24px;
  background: var(--border); border-radius: 12px;
  transition: background 0.2s ease; display: flex; align-items: center;
  border: 1px solid var(--border);
}
.theme-toggle input:checked ~ .theme-toggle-track {
  background: var(--accent);
}
/* PR #893 follow-up: keyboard focus indicator. The native checkbox is visually
 * hidden, so we draw the ring on the track sibling when the checkbox is
 * :focus-visible. Matches the global focus-ring style above. */
.theme-toggle input:focus-visible ~ .theme-toggle-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.theme-toggle-thumb {
  position: absolute; left: 3px; width: 18px; height: 18px;
  background: var(--nav-text); border-radius: 50%;
  box-shadow: 0 1px 3px var(--shadow);
  transition: transform 0.2s ease;
  z-index: 1;
}
.theme-toggle input:checked ~ .theme-toggle-track .theme-toggle-thumb {
  transform: translateX(22px);
}
.theme-toggle-icon {
  position: absolute; font-size: 10px; line-height: 1;
  top: 50%; transform: translateY(-50%);
  pointer-events: none; user-select: none;
  transition: opacity 0.2s ease;
}
.theme-toggle-sun { right: 4px; opacity: 1; }
.theme-toggle-moon { left: 4px; opacity: 0; }
.theme-toggle input:checked ~ .theme-toggle-track .theme-toggle-sun { opacity: 0; }
.theme-toggle input:checked ~ .theme-toggle-track .theme-toggle-moon { opacity: 1; }
/* PR #893 follow-up: respect prefers-reduced-motion — disable the slide/fade
 * animation so the thumb snaps to position. */
@media (prefers-reduced-motion: reduce) {
  .theme-toggle-track,
  .theme-toggle-thumb,
  .theme-toggle-icon { transition: none; }
}
/* PR #893 follow-up: Windows High Contrast / forced-colors mode — the track
 * background and thumb shadow get flattened to system colors, so explicitly
 * keep a system-colored border on track and thumb to stay visible. */
@media (forced-colors: active) {
  .theme-toggle-track { border: 1px solid CanvasText; background: Canvas; }
  .theme-toggle-thumb { background: CanvasText; box-shadow: none; }
  .theme-toggle input:focus-visible ~ .theme-toggle-track {
    outline: 2px solid Highlight;
  }
}
/* === Nav Stats === */
.nav-stats {
  display: flex; gap: 12px; align-items: center; font-size: 12px; color: var(--nav-text-muted);
  font-family: var(--mono); margin-right: 4px; white-space: nowrap;
}
.nav-stats .stat-val { color: var(--nav-text); font-weight: 600; transition: color 0.3s ease; }
.nav-stats .stat-val.updated { color: var(--link-color); }

/* === Layout === */
/* Default: body-scroll mode — content pushes beyond viewport, iOS status-bar
   tap-to-scroll works because <body> is the scroll container.  Pages that need
   a fixed-height container (maps, virtual-scroll, split-panels) add
   .app-fixed via the router so their children can use height:100%. */
#app { min-height: calc(100vh - 52px); min-height: calc(100dvh - 52px); }
/* #1174 mesh-op review: subtract --bottom-nav-reserve so /map and the
 * other fixed-height pages (packets, nodes, channels, audio-lab) do not
 * have their last 56px covered by the bottom-nav at ≤768. The token is
 * 0px at desktop so wide-viewport behavior is unchanged. */
#app.app-fixed { height: calc(100vh - 52px - var(--bottom-nav-reserve, 0px)); height: calc(100dvh - 52px - var(--bottom-nav-reserve, 0px)); min-height: 0; overflow: hidden; }

.split-layout {
  display: flex; height: 100%; overflow: hidden;
}
.panel-left {
  flex: 1; min-width: 0; overflow: auto; padding: 8px 12px;
}
.panel-right {
  width: 420px; min-width: 280px; max-width: 70vw; border-left: 1px solid var(--border);
  background: var(--detail-bg); overflow-y: auto; padding: 16px;
  position: relative;
}
.panel-resize-handle {
  position: absolute; top: 0; left: -3px; width: 6px; height: 100%;
  cursor: col-resize; z-index: 10; background: transparent;
}
.panel-resize-handle:hover, .panel-resize-handle.dragging {
  background: var(--accent); opacity: 0.3;
}
.panel-right.empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 14px;
}
.split-layout.detail-collapsed .panel-right { display: none; }
.panel-close-btn {
  position: absolute; top: 8px; right: 12px; z-index: 11;
  background: none; border: none; font-size: 20px; line-height: 1;
  color: var(--text-muted); cursor: pointer; padding: 4px 6px;
  border-radius: 4px; transition: color 0.15s, background 0.15s;
}
.panel-close-btn:hover { color: var(--text); background: var(--surface-1); }
.panel-right.empty .panel-close-btn { display: none; }

/* === Page Header === */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.page-header h2 { font-size: 18px; font-weight: 700; }
.page-header .count { color: var(--text-muted); font-weight: 400; font-size: 14px; margin-left: 8px; }

/* === Filter Bar === */
/* === Filter toolbar (#1122)
 * Toolbar layout is composed of fenced .filter-group clusters:
 *   1. Quick filters       — text inputs (hash, node, observer, region, type, channel)
 *   2. Toggles             — Group by Hash, ★ My Nodes EMOJI-OK-COMMENT
 *   3. Time window         — last-N selector
 *   4. Sort & view options — observer sort, columns toggle, hex paths
 * Adjacent .filter-group + .filter-group siblings get a left divider + padding
 * so the visual seam between groups stays readable even when wrapped. */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; align-items: center;
  row-gap: 12px;
}
.filter-bar input, .filter-bar select {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; background: var(--input-bg); color: var(--text); font-family: var(--font);
  height: 34px; min-height: 34px; box-sizing: border-box; line-height: 1;
}
.filter-bar input { width: 120px; }
.filter-bar select { min-width: 90px; }
.filter-bar .btn {
  padding: 6px 14px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--input-bg); cursor: pointer; font-size: 13px; transition: all .15s;
  font-family: var(--font); color: var(--text); height: 34px; min-height: 34px; box-sizing: border-box; line-height: 1;
}
.filter-group { display: flex; gap: 6px; align-items: center; }
/* #1124 (MAJOR-3): each grouped cluster wraps as a single unit at narrow
 * widths instead of letting individual controls reflow across categories. */
.filter-bar .filter-group { flex-wrap: nowrap; }
.filter-group .btn { padding: 4px 10px; font-size: 12px; font-weight: var(--fw-medium); border-radius: 12px; border: 1px solid var(--border); background: var(--input-bg); color: var(--text); cursor: pointer; transition: background 0.15s, color 0.15s; height: 34px; min-height: 34px; box-sizing: border-box; line-height: 1; } /* #1668 M3 — added 500 weight on chip */
.filter-group .btn.active { background: var(--accent-strong); color: var(--text-on-accent); border-color: var(--accent-strong); }
.filter-group .btn:hover:not(.active) { background: var(--surface-2); }
.filter-group + .filter-group { border-left: 1px solid var(--border); padding-left: 12px; margin-left: 6px; }
.sort-help { cursor: help; font-size: 14px; color: var(--text-muted, #888); position: relative; display: inline-block; }
.sort-help-tip {
  display: none; position: absolute; top: 130%; left: 50%; transform: translateX(-50%);
  background: var(--card-bg, #222); color: var(--text, #eee); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px 12px; font-size: 12px; line-height: 1.5;
  white-space: pre-line; width: 260px; z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,.3); pointer-events: none;
}
.sort-help:hover .sort-help-tip { display: block; }
.node-packet-count-help {
  border: 0; padding: 0; background: none; color: inherit; font: inherit;
  text-align: left; text-transform: inherit; letter-spacing: inherit;
}
.node-packet-count-help .sort-help-tip {
  top: auto; bottom: 100%; left: 0; transform: none; pointer-events: auto;
  font-weight: normal; text-transform: none; letter-spacing: normal;
}
.node-packet-count-help.help-dismissed .sort-help-tip { display: none; }
/* Avoid touch target expansion redirecting nearby table-cell taps into the help button. */
.node-packet-count-help.help-touch .sort-help-tip { pointer-events: none; }
.filter-bar .btn:hover { background: var(--row-hover); }
/* #96 — "Hide CONTROL packets" checkbox in the packets filter bar. */
.filter-bar .filter-checkbox { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text); white-space: nowrap; cursor: pointer; }
.filter-bar .filter-checkbox input[type="checkbox"] { /* not the text-input box above */
  width: 16px; height: 16px; min-width: 0; min-height: 0; padding: 0; margin: 0; cursor: pointer; accent-color: var(--accent);
}
@media (pointer: coarse) { .filter-bar .filter-checkbox { min-height: 44px; } } /* the label is the touch target */
.filter-bar .btn.active { background: var(--accent-strong); color: var(--text-on-accent); border-color: var(--accent-strong); }
.filter-bar .col-toggle-btn { height: 34px; min-height: 34px; }

.btn-icon {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); padding: 6px 10px; cursor: pointer; font-size: 14px; transition: all .15s;
}
.btn-icon:hover { background: var(--row-hover); }

/* === Tables === */
/* #1056: Primary tables (packets, nodes, observers) are fluid:
 *  - width:100% — columns share the available width via the browser layout
 *  - no fixed px widths on individual columns; only min-widths to protect
 *    legibility, set in `clamp(...)` so they relax on small viewports
 *  - priority-based column hiding done in JS via .col-hidden + a "+N hidden"
 *    pill rendered inside thead (clickable to reveal)
 */
.data-table {
  width: 100%; border-collapse: collapse; font-size: 13px; font-weight: var(--fw-medium);
  table-layout: auto;
} /* #1668 M3 — was 12px/400, now 13px paired with 500 weight */
.data-table th {
  text-align: left; padding: 4px 6px; font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .3px; color: var(--text-muted);
  border-bottom: 2px solid var(--border); background: var(--card-bg);
  position: sticky; top: 0; z-index: 1;
}
.data-table th.sortable { cursor: pointer; }
.data-table th.sortable:hover { color: var(--link-color); }
.data-table td {
  padding: 3px 6px; border-bottom: 1px solid var(--border);
  vertical-align: middle; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  max-width: 0; /* forces td to respect table width instead of expanding to content */
}
.data-table td.col-details { white-space: normal; word-break: break-word; max-width: 480px; }
/* #1122/#1124: the packets "Details" cell is a one-line summary (the full
 * message is in the detail pane / SlideOver). Letting it wrap made rows taller
 * whenever table-layout:auto narrowed the column (e.g. 1030-1280px desktop
 * widths), breaking the bounded row height and the virtual scroller's
 * constant-row-height assumption (#1770). Clamp the INNER .col-details-clip to
 * one line; the td keeps white-space:normal so the column's intrinsic widths
 * (and thus the table layout) are unchanged -- see the #1805 note in the
 * mobile block, whose inline-block/nowrap clip still overrides this. */
.data-table td.col-details > .col-details-clip {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  line-clamp: 1;
  overflow: hidden;
}
/* The one-line clip box is only a line box tall, so anything drawn outside
 * it is clipped (padding would expose the top of the hidden 2nd line).
 * Draw link focus rings inside the link box instead of around it... */
.data-table td.col-details > .col-details-clip a:focus-visible { outline-offset: -2px; }
/* ...and give the line box room for .chan-tag pills (17px, baseline-aligned)
 * where that is height-neutral: above 768px the Path chips already make rows
 * ~30px tall. (<=640px keeps the #1805 inline-block clip below.) */
@media (min-width: 769px) {
  .data-table td.col-details > .col-details-clip { line-height: 18px; }
}
/* Direct Neighbors' Configured Scope cell (observer-detail.js) can hold a
 * long comma-joined scope list (e.g. a #eu/#dk/#dk-sjl/... catch-all
 * observer) -- the generic max-width:0 ellipsis rule above truncated it
 * down to nothing readable. Wrap instead, same override pattern as
 * col-details. */
.data-table td.col-scope-list { white-space: normal; word-break: break-word; max-width: 320px; }
/* #1415: pin the expand-chevron column narrow at every viewport.
 * Chevron glyph is ~16px wide; legacy column auto-sized to 50-180px and shoved every
 * downstream data column right. 32px is enough for the ▶/▼ + 8px padding. */
.data-table th.col-expand,
.data-table td.col-expand {
  width: 32px; min-width: 32px; max-width: 32px;
  padding: 3px 4px; text-align: center;
}

/* #1415 / #1458 / #1461 — mobile packets UX overhaul.
 * NOTE: hiding the first dt/dd pair below assumes Payload Type is the
 * first <dt> in .detail-meta (per packets.js renderDetail). Keep that
 * invariant — test-issue-1415-packets-layout.js asserts it. */
@media (max-width: 600px) {
  /* #1: kill empty chevron rail */
  #pktTable th.col-expand,
  #pktTable td.col-expand { display: none !important; }

  /* #1b: slim THEAD ~24px sticky */
  #pktTable thead th {
    padding: 3px 6px !important;
    font-size: 9px !important;
    line-height: 1.2 !important;
    letter-spacing: 0.04em !important;
    text-transform: uppercase;
    height: 24px !important;
  }
  #pktTable thead { position: sticky; top: 0; z-index: 5; background: var(--surface-1, #1a1a1a); }

  /* #2: hide page-header row + filter-expr.
   * pause + Filters pill are mirrored into .nav-left by mobile-page-actions.js.
   * NOTE: do NOT display:none the entire .filter-bar — the original
   * .filter-toggle-btn lives inside it and must remain clickable for the
   * #534 E2E test (and for any user whose navbar mirror failed to inject). */
  #pktLeft .page-header { display: none !important; }
  #pktLeft .pkt-filter-expr { display: none !important; }
  /* #1461 followup: the navbar mirror is always present on mobile.
   * Hide the in-page Filters button \u2014 the test #534 now clicks the
   * navbar mirror (.filter-toggle-btn-mirror) instead. */
  .filter-bar > .filter-toggle-btn {
    display: none !important;
  }
  /* Bar itself has no chrome unless expanded */
  .filter-bar {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    min-height: 0 !important;
  }
  .filter-bar.filters-expanded {
    padding: 6px 8px !important;
    margin-bottom: 4px !important;
    background: var(--surface-2, rgba(0,0,0,0.05)) !important;
    border: 1px solid var(--border, #333) !important;
    border-radius: 6px !important;
  }

  /* Navbar-mirror buttons injected by mobile-page-actions.js. Visual tokens
   * (border, colors) live here so the customizer can theme them and so we
   * don't ship them as inline cssText strings. */
  .mpa-btn-icon {
    padding: 4px 6px;
    font-size: 14px;
    background: transparent;
    border: 1px solid var(--border, #444);
    border-radius: 6px;
    color: var(--nav-text, #fff);
    cursor: pointer;
  }
  .mpa-btn-pill {
    padding: 4px 10px;
    font-size: 12px;
    background: transparent;
    border: 1px solid var(--border, #444);
    border-radius: 999px;
    color: var(--nav-text, #fff);
    cursor: pointer;
    font-weight: 500;
  }
  .mpa-toast {
    position: fixed;
    left: 50%;
    bottom: 90px;
    transform: translateX(-50%);
    background: var(--surface-2, #222);
    color: var(--text, #fff);
    padding: 10px 16px;
    border: 1px solid var(--border, #444);
    border-radius: 8px;
    font-size: 13px;
    max-width: 80vw;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: opacity .3s;
  }

  .filter-bar.filters-expanded {
    padding: 6px 8px !important;
    margin-bottom: 4px !important;
    background: var(--surface-2, rgba(0,0,0,0.05)) !important;
    border: 1px solid var(--border, #333) !important;
    border-radius: 6px !important;
    height: auto;
  }

  /* #3: detail panel cleanup */
  /* Strip redundant src→dst line (identity in sticky header) */
  .mobile-detail-sheet .detail-srcdst { display: none !important; }
  /* Hide boxed "decoded message" card on mobile — content already in
   * the sticky header's semantic summary */
  .mobile-detail-sheet .detail-message { display: none !important; }
  /* Hide PAYLOAD TYPE row (first dt+dd pair — already in header badge) */
  .mobile-detail-sheet dl.detail-meta > dt:first-child,
  .mobile-detail-sheet dl.detail-meta > dt:first-child + dd { display: none !important; }
  /* 2-col grid for label/value rows */
  .mobile-detail-sheet dl.detail-meta {
    display: grid;
    grid-template-columns: minmax(90px, 30%) 1fr;
    gap: 4px 10px;
    margin: 8px 0 !important;
  }
  .mobile-detail-sheet dl.detail-meta dt {
    margin: 0 !important;
    padding: 0 !important;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    align-self: center;
  }
  .mobile-detail-sheet dl.detail-meta dd {
    margin: 0 !important;
    padding: 0 !important;
    font-size: 13px;
  }

  /* #4: sheet structure — kill handle, sticky header inside sheet, clear
   * bottom-nav (58px tall) so last row doesn't get cut off, taller max */
  /* Restructure: outer sheet has fixed height + overflow:hidden; the
   * .mobile-sheet-content is the ONLY scroll region. ✕ close stays sticky EMOJI-OK-COMMENT
   * pinned at top of the sheet. Title also stays sticky within the
   * scroll region. */
  .mobile-detail-sheet {
    max-height: calc(100vh - 110px) !important;  /* leave room for bottom nav */
    padding: 0 !important;
    overflow: hidden !important;
    display: none;
    flex-direction: column;
  }
  .mobile-detail-sheet.open { display: flex !important; }
  .mobile-sheet-handle { display: none !important; }  /* conflicts with browser pull-to-refresh */
  .mobile-sheet-close {
    position: absolute !important;
    top: 6px !important;
    right: 10px !important;
    background: var(--surface-2, rgba(0,0,0,0.6)) !important;
    border-radius: 999px !important;
    width: 32px !important;
    height: 32px !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 16px !important;
    z-index: 20 !important;
    border: 1px solid var(--border, #444) !important;
  }
  .mobile-sheet-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 12px 60px !important;
    /* visible scrollbar so operator sees there's more */
    scrollbar-width: thin;
  }
  .mobile-sheet-content::-webkit-scrollbar { width: 6px; }
  .mobile-sheet-content::-webkit-scrollbar-thumb { background: var(--border, #555); border-radius: 3px; }
  /* Sticky in-sheet header for packet identity */
  .mobile-detail-sheet .detail-title {
    position: sticky;
    top: 0;
    background: var(--detail-bg);
    z-index: 5;
    padding: 6px 36px 8px 0;
    margin: 0 0 8px 0;
    border-bottom: 1px solid var(--border);
  }
}
.data-table td:has(.spark-bar), .data-table td.col-spark { max-width: none; overflow: visible; min-width: 80px; }
.data-table .col-time { min-width: clamp(72px, 8vw, 108px); white-space: nowrap; }

/* #1056: priority-based column hiding + reveal pill
 * .col-hidden is toggled by JS (TableResponsive.apply) on both th and td.
 * The pill is appended into the last visible th in the header row. */
.data-table th.col-hidden,
.data-table td.col-hidden { display: none !important; }
.col-hidden-pill {
  display: inline-block; margin-left: 6px;
  padding: 1px 7px; border-radius: 999px;
  /* #1668 M5 — was bg:--accent-bg (rgba blue tint) + color:--accent
     = ~2.4:1 on light theme. Swap the tint for solid --accent-strong
     (palette-blue-600 #2563eb) and use --text-on-accent (gray-50) so
     the pill matches the M2 .skip-link / .filter-bar .btn.active
     pattern: 4.83:1 AA both themes, no per-theme branching. */
  background: var(--accent-strong);
  color: var(--text-on-accent);
  font-size: 12px; font-weight: var(--fw-bold); letter-spacing: .3px; /* #1668 M3 — was 10px */
  cursor: pointer; user-select: none; vertical-align: middle;
  border: 1px solid var(--accent, #60a5fa);
  text-transform: none;
}
.col-hidden-pill:hover { filter: brightness(1.15); }
.col-hidden-pill:focus-visible { outline: 2px solid var(--accent, #60a5fa); outline-offset: 2px; }
/* MAJOR-4: re-hide affordance — visually distinct from the +N reveal pill. */
.col-rehide-pill { background: transparent; color: var(--text-dim, #94a3b8); border-color: var(--border, #334155); margin-left: 4px; }
/* MAJOR-2: when user-resizable columns push total width past container,
 * fall back to horizontal scroll on the wrap rather than overflowing the page. */
.table-fluid-wrap { width: 100%; overflow-x: auto; }
.obs-nb-scope-scroll-hint { display: none; }
/* Decision buttons are never ellipsized: the narrow-viewport .data-table td
 * rule (max-width + text-overflow) would paint an overflowing button as "…". */
.data-table td.obs-nb-scope-actions { max-width: none; overflow: visible; white-space: nowrap; }

/* Observer Neighbors scope review: give both decision buttons a real table
 * column on phones, then let the existing fluid wrapper scroll it. Without
 * a min-width, .data-table's max-width:0 cells ellipsize the buttons while
 * the wrapper has almost nothing to scroll. */
@media (max-width: 600px) {
  .obs-nb-scope-scroll-hint { display: block; font-size: 0.8em; margin: 0 0 6px; }
  .obs-nb-scope-table.has-actions { min-width: 560px; }
}

/* === #1056 AC#4: Slide-over row-detail overlay (narrow viewports) ========
 * Singleton .slide-over-backdrop + .slide-over-panel injected into <body>
 * by SlideOver helper in packets.js. Used by Packets/Nodes/Observers row
 * clicks at viewport <=1023 instead of routing to a separate page.
 * Reuses the existing slideInRight keyframe defined later in this file.
 */

/* #1168 Munger #3: ref-counted scroll-lock. Multiple modal surfaces
 * (SlideOver, ChannelColorPicker, future modals) acquire/release a
 * shared count via window.__scrollLock; the class is added on first
 * acquire and removed on last release. Replaces the previous
 * body.style.overflow capture-and-restore string approach which
 * corrupted overflow under last-writer-wins races. */
body.scroll-locked { overflow: hidden; }
/* #180: the SlideOver is a modal dialog (role=dialog, aria-modal, focus
 * trap), so it stacks on the modal tokens, above the sticky .top-nav (1100).
 * At 1000/1001 the panel's header and close button sat under the nav at
 * 641–1023 px, and a click on × landed on the nav. */
.slide-over-backdrop {
  position: fixed; inset: 0; z-index: var(--z-modal-backdrop);
  background: rgba(0, 0, 0, 0.5);
  cursor: pointer;
}
.slide-over-backdrop[hidden] { display: none; }
.slide-over-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(480px, 90vw);
  z-index: var(--z-modal);
  background: var(--detail-bg, var(--card-bg, #1f2937));
  color: var(--text, inherit);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.35);
  overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column;
  animation: slideInRight 200ms ease-out;
}
.slide-over-panel[hidden] { display: none; }
.slide-over-header {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 10px 12px;
  background: var(--card-bg, var(--detail-bg));
  border-bottom: 1px solid var(--border);
}
.slide-over-title {
  margin: 0; font-size: 14px; font-weight: 600;
  color: var(--text, inherit);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.slide-over-close {
  background: none; border: none; cursor: pointer;
  font-size: 18px; line-height: 1;
  color: var(--text-muted, #94a3b8);
  padding: 4px 8px; border-radius: 4px;
  /* WCAG 2.5.5 / Apple HIG — 48px tap target on touch devices. */
  min-width: 48px; min-height: 48px;
  display: inline-flex; align-items: center; justify-content: center;
}
.slide-over-close:hover { color: var(--text, inherit); background: var(--row-hover); }
.slide-over-close:focus-visible { outline: 2px solid var(--accent, #60a5fa); outline-offset: 2px; }
.slide-over-content { flex: 1; min-height: 0; padding: 12px; }
@media (prefers-reduced-motion: reduce) {
  .slide-over-panel { animation: none; }
}

.timestamp-future-icon { margin-left: 4px; cursor: help; }
.data-table tbody tr:nth-child(even) { background: var(--row-stripe); }
.data-table tbody tr:hover { background: var(--row-hover); cursor: pointer; }
.data-table tbody tr.selected { background: var(--selected-bg); }

/* === Badges === */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: var(--badge-radius);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px;
}

.badge-region {
  display: inline-block; padding: 2px 6px; border-radius: 4px;
  font-size: 10px; font-weight: 700; font-family: var(--mono);
  background: var(--nav-bg); color: var(--nav-text); letter-spacing: .5px;
}
/* #76 Heard By: direct receptions (with the node's signal) and relay
   observers (without), shared by node page, side panel and Live panel. */
.heard-by-subtitle {
  margin: 10px 0 4px; font-size: 12px; font-weight: 600; color: var(--text-muted);
}
.heard-by-subtitle .heard-by-help { font-size: inherit; font-weight: inherit; color: inherit; }
.heard-by-help {
  border: 0; padding: 0; background: none; font: inherit; text-align: left;
}
.heard-by-help .sort-help-tip { left: 0; transform: none; font-weight: normal; text-transform: none; letter-spacing: normal; }
.heard-by-empty { font-size: 12px; margin: 2px 0 6px; }
.heard-by .observer-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 4px 0; border-bottom: 1px solid var(--border); font-size: 12px;
}
.heard-by .heard-by-name { font-weight: 600; }
.heard-by .heard-by-stats { color: var(--text-muted); white-space: nowrap; }
.heard-by-link { color: var(--link-color); text-decoration: none; }
.live-heard-by .heard-by-title { font-size: 12px; margin: 12px 0 6px; color: var(--text-muted); }
.live-heard-by .observer-row { font-size: 11px; padding: 2px 0; }

/* Issue #1290: listener vs repeater badge on observers list + detail.
 * Driven by ObserverResp.can_relay (false = firmware reported repeat:off).
 * Server-side disambiguator excludes listener observers from path-hop
 * candidates; this badge surfaces the same hint to operators. Colors use
 * existing theme vars so the badge tracks the active palette. */
.badge-listener,
.badge-repeater {
  display: inline-block; padding: 1px 5px; border-radius: 4px;
  font-size: 10px; font-weight: 700; font-family: var(--mono);
  letter-spacing: .5px; margin-left: 4px; vertical-align: middle;
}
.badge-listener {
  background: var(--transport-badge-bg, #f59e0b20);
  color: var(--transport-badge-fg, #d97706);
}
.badge-repeater {
  background: var(--nav-bg); color: var(--nav-text);
}
/* Observer IATA pill rendered inline next to observer name on packets (#1188).
 * Visually similar to .badge-region but distinct so the row badge and the
 * inline-with-observer badge can be styled independently in future themes. */
.badge-iata {
  display: inline-block; padding: 1px 5px; border-radius: 4px;
  font-size: 10px; font-weight: 700; font-family: var(--mono);
  background: var(--nav-bg); color: var(--nav-text); letter-spacing: .5px;
  margin-left: 4px; vertical-align: middle;
}
/* TODO: expose --transport-badge-bg/fg in customizer THEME_CSS_MAP (tracked in future milestone) */
.badge-transport {
  display: inline-block; padding: 1px 5px; border-radius: 4px;
  font-size: 9px; font-weight: 700; font-family: var(--mono);
  background: var(--transport-badge-bg, #f59e0b20); color: var(--transport-badge-fg, #d97706);
  letter-spacing: .5px; vertical-align: middle;
  /* Scope names are case-sensitive (#458): opt out of .badge uppercase. */
  text-transform: none;
  /* Region names can run long (e.g. "#dk-trekantsomraadet") — cap and
     ellipsis instead of blowing out the Type column; full name is
     always in the title attribute. */
  max-width: 90px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
}
/* Transport-scoped but the region couldn't be resolved (no configured
   region matched, or an HMAC collision made the match ambiguous) —
   muted instead of the confident amber so it reads as "unresolved". */
.badge-transport-unknown {
  background: var(--text-muted-bg, #6b728020); color: var(--text-muted, #6b7280);
}
/* Dedicated Scope column pill (#71 Packets column). Reuses the
   badge-transport-unknown muted look for the "no match" state so it reads
   consistently with the inline T? pill on the Type column. */
.badge-scope {
  display: inline-block; padding: 1px 6px; border-radius: 4px;
  font-size: 10px; font-weight: 700; font-family: var(--mono);
  background: var(--transport-badge-bg, #f59e0b20); color: var(--transport-badge-fg, #d97706);
  letter-spacing: .3px; text-transform: none;
}
.badge-scope-unknown {
  background: var(--text-muted-bg, #6b728020); color: var(--text-muted, #6b7280);
}
.badge-obs {
  display: inline-block; padding: 1px 6px; border-radius: 10px;
  font-size: 10px; font-weight: 600;
  background: #ede9fe; color: #6d28d9;
}
.multibyte-badge {
  color: var(--text);
  background: var(--accent-bg);
  font-size: 10px;
}
.pubkey-prefix-badge {
  background:var(--nav-bg);
  color:var(--nav-text);
  font-family:var(--mono)
}
/* === Monospace === */
.mono { font-family: var(--mono); font-size: 13px; font-weight: var(--fw-medium); } /* #1668 M3 — was 12px/inherit */

/* #1668 M3 — explicit floor for "Xs/Xm/Xd ago" timestamps used on every row
 * of /packets, /nodes, /live. Was inheriting 12px/400 (thin-small). */
.timestamp-text {
  font-size: 13px;
  font-weight: var(--fw-medium);
}

/* === Detail Panel === */
.detail-title {
  font-size: 15px; font-weight: 700; margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 2px solid var(--border);
  /* #1458 P0-A: semantic-first header — type badge + summary + hops share a row. */
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.detail-title .detail-summary { color: var(--text-muted); font-weight: 400; }
.detail-srcdst {
  font-size: 14px; margin: -4px 0 12px; color: var(--text);
}
.detail-srcdst .arrow { color: var(--text-muted); margin: 0 4px; }
.detail-hash {
  font-family: var(--mono); font-size: 12px; color: var(--text-muted);
  margin-bottom: 12px; word-break: break-all;
}
.detail-meta {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px;
  margin-bottom: 16px; font-size: 13px;
}
.detail-meta dt { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .3px; }
.detail-meta dd { font-weight: 500; margin-bottom: 4px; }
/* #1281: 📍map link inside detail-meta — UA-default blue is unreadable on EMOJI-OK-COMMENT
 * dark backgrounds. Force theme-aware color via --accent. */
.loc-map-link { color: var(--link-color); font-size: 0.85em; text-decoration: none; }
.loc-map-link:hover { text-decoration: underline; }
.observation-current { background: var(--accent-bg, rgba(0,122,255,0.1)); font-weight: 600; }
.detail-obs-row:hover { background: var(--hover-bg, rgba(255,255,255,0.05)); }
.detail-obs-table th { font-size: 0.8em; text-transform: uppercase; color: var(--text-muted); }

/* === Hex Dump === */
.hex-dump {
  font-family: var(--mono); font-size: 11px; line-height: 1.8;
  padding: 12px; border-radius: 8px; background: #1e1e2e; color: #cdd6f4;
  overflow-x: auto; margin-bottom: 16px; word-break: break-all;
}
.hex-byte { padding: 1px 2px; border-radius: 2px; }
.hex-header { background: #f38ba8; color: #1e1e2e; }
.hex-pathlen { background: #fab387; color: #1e1e2e; }
.hex-transport { background: #89b4fa; color: #1e1e2e; }
.hex-path { background: #a6e3a1; color: #1e1e2e; }
.hex-payload { background: #f9e2af; color: #1e1e2e; }
.hex-pubkey { background: #f9e2af; color: #1e1e2e; }
.hex-timestamp { background: #fab387; color: #1e1e2e; }
.hex-signature { background: #f38ba8; color: #1e1e2e; }
.hex-flags { background: #94e2d5; color: #1e1e2e; }
.hex-lat, .hex-lon, .hex-location { background: #89b4fa; color: #1e1e2e; }
.hex-name { background: #cba6f7; color: #1e1e2e; }

.hex-legend {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; font-size: 11px;
}
.hex-legend span {
  display: inline-flex; align-items: center; gap: 4px;
}
.hex-legend .swatch {
  display: inline-block; width: 12px; height: 12px; border-radius: 2px;
}

/* === Field Breakdown Table === */
.field-table {
  width: 100%; border-collapse: collapse; font-size: 11px; margin-bottom: 12px;
}
.field-table th {
  text-align: left; padding: 6px 8px; background: var(--nav-bg); color: var(--nav-text);
  font-size: 11px; text-transform: uppercase; letter-spacing: .3px;
}
.field-table td {
  padding: 5px 8px; border-bottom: 1px solid var(--border);
}
.field-table .section-row td {
  background: var(--section-bg, #eef2ff); font-weight: 700; font-size: 11px;
  text-transform: uppercase; letter-spacing: .5px; color: var(--text);
}
.field-table .section-header td  { background: rgba(243,139,168,0.18); }
.field-table .section-transport td { background: rgba(137,180,250,0.18); }
.field-table .section-path td    { background: rgba(166,227,161,0.18); }
.field-table .section-payload td { background: rgba(249,226,175,0.18); }

/* === Path display === */
.path-hops {
  display: inline-flex; align-items: center; gap: 2px; font-family: var(--mono); font-size: 11px;
  /* #1122: never wrap; clip so a long hop chain cannot spill into the next row */
  flex-wrap: nowrap;
  max-width: 100%;
  max-height: 22px;
  overflow: hidden;
  vertical-align: middle;
}
.path-hops .hop { color: var(--link-color); line-height: 18px; }
/* #1668 M2 / operator-flagged chip: was `color:#fff; background:var(--accent)`
   = 2.75:1 on dark theme (BLOCKER). Now uses --accent-strong (#2563eb)
   with --text-on-accent (gray-50) for 4.83:1 — WCAG AA body pass in
   both themes. */
.path-hops .hop-named { color: var(--text-on-accent); background: var(--accent-strong); padding: 1px 6px; border-radius: 3px; font-family: var(--font); font-size: 12px; font-weight: 600; cursor: default; flex: 0 0 auto; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 18px; }
.path-hops .arrow { color: var(--text-muted); flex: 0 0 auto; line-height: 18px; }
/* #217 "Full Names" (packets.js): hop chips keep their whole name. The path
 * stays on one line; hops past the edge go behind the +N pill. Wrapping would
 * make rows taller than the fixed VSCROLL_ROW_HEIGHT the virtual scroller
 * positions rows with. */
#pktTable.pkt-full-names .path-hops .hop-named { max-width: none; }
/* #1122/#1128: bound the row height contributed by the path column.
 * `max-height` on a <td> is widely ignored by browsers (table layout
 * overrides it), so use `height` — table cells respect `height` as
 * min-height, locking the row to a single line of chip content
 * regardless of hop count. */
/* #1668 M3 r1 (tufte #4): preserve PATH column width after the table body
 * font bump (12 -> 13) widened sibling columns and squeezed PATH chips
 * from 7-9 visible chars down to 3-4. Reserve enough room for two
 * abbreviated 7-char chips + arrow. .path-hops already uses 11px font, so
 * no chip-level font change is needed here. */
.data-table td.col-path, .data-table th.col-path { min-width: 140px; }
.data-table td.col-path { height: 28px; line-height: 22px; overflow: hidden; }

/* === Modal === */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: clamp(8px, 2vw, 24px); /* #1059: viewport-edge breathing room */
}
.modal {
  /* #1059: fluid via min(); cap height at 90vh; internal scroll.
     MINOR-6: dropped redundant `width: ...` — `max-width: min(90vw, 500px)`
     alone is sufficient to constrain the box (modals are auto-width within
     a flex centering container). */
  background: var(--card-bg); border-radius: 12px; padding: 24px;
  max-width: min(90vw, 500px);
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0,0,0,.2);
  /* Sticky-positioned descendants need a positioned ancestor. */
  position: relative;
}
.modal h3 { margin-bottom: 12px; }
.modal textarea {
  width: 100%; height: 120px; font-family: var(--mono); font-size: 13px;
  padding: 10px; border: 1px solid var(--border); border-radius: 6px;
  resize: vertical; margin-bottom: 12px;
}
.modal .btn-primary {
  background: var(--accent-strong); color: var(--text-on-accent); border: none; padding: 8px 20px;
  border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 600;
}
.modal .btn-primary:hover { background: var(--palette-blue-700, #1d4ed8); }
.modal .btn-close {
  background: none; border: 1px solid var(--border); padding: 8px 16px;
  border-radius: 6px; cursor: pointer; margin-left: 8px; font-size: 14px;
}

/* === #1059: Sticky close buttons (modal can scroll, close stays reachable).
   AC3 is a global contract — applies to ALL .modal users (BYOP, channels,
   any future modal). Two patterns covered:
     1. Sticky header pattern (.byop-modal): header pinned at top: 0 inside
        the scrollable .modal; close is a child, no extra positioning needed.
     2. Floating close pattern (.modal-close at top of .modal body):
        position: sticky on the close button itself.
   .ch-modal already uses position: absolute on a position: relative parent,
   which keeps the close visually pinned across content scroll — that pattern
   continues to satisfy AC3. */
.byop-modal .byop-header {
  position: sticky; top: 0; z-index: 2;
  background: var(--card-bg);
  /* #1487: was `margin: -24px -24px 12px; padding: 12px 24px;` — assumed
     .modal desktop padding of 24px. On mobile .modal switches to 16px
     padding, so the negative margin overshot, content-flow pushed the
     next sibling UP under the (sticky-pinned) header, and the
     description paragraph was visually occluded by ~12px. Drop the
     full-bleed negative-margin gymnastics — header now uses normal
     padding (modal padding handles the inset) and bounded sizing. */
  margin: 0 0 12px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  /* Hard cap so emoji ascent / btn-icon 48px floor can't blow the header
     past the safe range (was 73px pre-fix). */
  max-height: 48px;
  box-sizing: border-box;
}
.byop-modal .byop-header h3 {
  /* #1487: explicit font + line-height so emoji-bearing title doesn't
     blow up the header on platforms where the default emoji font has
     huge ascent metrics (observed contributor to 73px header). */
  margin: 0; font-size: 1rem; line-height: 1.3;
}
/* MINOR-7: dropped position: sticky on .byop-x — it sits inside the
   already-sticky .byop-header, so the sticky on the child was a no-op.
   We only need visual styling here.
   #1487: override .btn-icon 48px floor — inside the header we need a
   compact button so the header stays bounded. The :before tap-target
   pad below preserves accessibility (effective hit area ~ 44x44). */
.byop-modal .byop-x {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 6px; padding: 2px 8px; cursor: pointer; font-size: 14px;
  line-height: 1; color: var(--text);
  min-height: 0; min-width: 0; height: 32px;
  position: relative;
}
/* #1487: invisible tap-pad to keep ≥44px effective hit area while the
   visual button stays compact inside the bounded header. */
.byop-modal .byop-x::before {
  content: ''; position: absolute; inset: -8px; border-radius: 8px;
}
.byop-modal .byop-x:hover { background: var(--row-hover, rgba(0,0,0,0.05)); }

/* MINOR-8: generic sticky-close for any .modal that uses a sibling .modal-close
   inside the scrollable box (no enclosing sticky header). Excludes
   .ch-modal-close which already uses position: absolute on a position:
   relative .ch-modal — that pattern already keeps the close pinned across
   internal scroll, so we don't override it. */
.modal > .modal-close:not(.ch-modal-close) {
  position: sticky; top: 0; z-index: 3; float: right;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 16px;
  line-height: 1; color: var(--text);
}
.modal > .modal-close:not(.ch-modal-close):hover { background: var(--row-hover, rgba(0,0,0,0.05)); }

/* #1648 M6 (M5 CDP carry-forward): mobile touch-target. The 4px/10px
   padding above produces an ~24px hit area, below the 48×48 house minimum
   (#2052, #235). Bump on ≤640px so dismiss is reliably tappable on phones.
   Applies to both the generic .modal-close and the channel-modal close. */
@media (max-width: 640px) {
  .modal > .modal-close:not(.ch-modal-close),
  .ch-modal-close {
    min-width: 48px; min-height: 48px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 12px;
  }
}

/* #249: the add-channel dialog's primary buttons were 32 px tall next to
   their 48 px inputs. Touch only, like the #630 coarse-pointer block;
   desktop keeps them at 32 px. */
@media (pointer: coarse) {
  #chGenerateBtn, #chPskAddBtn, #chHashtagBtn { min-height: 48px; }
}


/* === Map Controls Panel === */
.map-controls {
  /* #1059: fluid width via clamp() so controls scale with viewport but never
     exceed available room or go below a usable minimum. */
  position: absolute; top: 12px; right: 12px; z-index: 1000;
  background: var(--card-bg); border-radius: 10px; padding: 14px 16px;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  width: clamp(160px, 18vw, 240px);
  max-width: calc(100vw - 24px);
  font-size: 13px;
  /* #839: and above the map credit (bottom right), which ran under it;
     map.js publishes the credit's height. */
  max-height: calc(100% - 24px - var(--map-credit-height, 0px)); overflow-y: auto;
  /* #1236: keep the scrollbar gutter reserved so the scroll affordance is
     visible even when content briefly fits — users get a consistent visual
     cue that the panel is scrollable. */
  scrollbar-gutter: stable;
}
/* #1236: sticky panel title so the scroll affordance is always visible at the
   top of the scroll container when content overflows on small viewports. */
.map-controls h3 {
  font-size: 15px;
  margin: -14px -16px 10px -16px;
  padding: 10px 16px;
  position: sticky;
  top: -14px;
  background: var(--card-bg);
  z-index: 2;
  border-bottom: 1px solid var(--border);
  border-radius: 10px 10px 0 0;
}
.mc-section { margin-bottom: 10px; }
.mc-label { font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; color: var(--text-muted); margin-bottom: 4px; }
.mc-section label { display: block; padding: 2px 0; cursor: pointer; }
.mc-section select { width: 100%; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.mc-jumps { display: flex; flex-wrap: wrap; gap: 4px; }
.mc-jump-btn {
  padding: 3px 10px; border: 1px solid var(--border); border-radius: 4px;
  background: var(--input-bg); cursor: pointer; font-size: 12px; font-weight: 600;
}
.mc-jump-btn:hover { background: var(--row-hover); }
fieldset.mc-section { border: none; padding: 0; margin: 0 0 10px 0; min-width: 0; }
fieldset.mc-section legend.mc-label { padding: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* === Misc === */
.text-muted { color: var(--text-muted); }
/* Explanatory note beside a tool's own content (e.g. the operator-disabled
   notice in Areas -> Position-Fix Coverage Gaps): same size as the muted
   notes it sits next to, so it does not read as body copy. */
.estimated-positions-note { font-size: 0.85em; margin: 0 0 8px; }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mb-8 { margin-bottom: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }

/* === Channels Page === */
/* #1057: Fluid layout. .ch-layout is a container query root so the channels
   page can stack sidebar above main when the *available* layout width is
   narrow (independent of the global viewport — handles cases where the
   nav/side-pane consumes width). Sidebar uses clamp() for fluid sizing
   between a usable min (~220px) and a comfortable max (~320px) on wide
   screens; .ch-main keeps flex:1 so it absorbs remaining width including
   ultrawide. */
.ch-layout {
  display: flex; height: 100%; overflow: hidden;
  container-type: inline-size;
  container-name: chlayout;
}
.ch-sidebar {
  width: clamp(220px, 22vw, 320px);
  min-width: 220px;
  background: var(--card-bg);
  border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden;
}
.ch-sidebar-header {
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}
.ch-sidebar-title {
  display: flex; align-items: center; gap: 6px;
  font-size: 15px; font-weight: 700;
  flex: 1 1 auto; min-width: 0;
  /* Name dominates; no longer push other controls onto a new row */
  margin: 0;
}
.ch-header-region { margin: 0; padding: 0; flex: 0 0 auto; }
.ch-encrypted-toggle {
  display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-muted);
  cursor: pointer; user-select: none; margin-bottom: 4px;
}
.ch-encrypted-toggle input { margin: 0; cursor: pointer; }
.ch-toggle-label { white-space: nowrap; }
.ch-item.ch-encrypted { opacity: 0.55; }
.ch-item.ch-encrypted .ch-item-name { font-style: italic; }
.ch-icon { font-size: 20px; }
.ch-sidebar-controls { display: flex; align-items: center; gap: 6px; }
.ch-region-select {
  flex: 1; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px; background: var(--input-bg); color: var(--text); font-family: var(--font);
}
.ch-gear-btn {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 8px; cursor: pointer; font-size: 14px;
}
.ch-gear-btn:hover { background: var(--row-hover); }
.ch-channel-list { flex: 1; overflow-y: auto; }
button.ch-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  cursor: pointer; transition: background .12s; border: none; border-bottom: 1px solid var(--border);
  background: transparent; width: 100%; text-align: left; color: var(--text);
  font-family: inherit; font-size: inherit; line-height: inherit;
  -webkit-tap-highlight-color: rgba(0,0,0,.08);
  touch-action: manipulation;
}
button.ch-item:hover { background: var(--row-hover); }
button.ch-item:active { background: var(--selected-bg); }
button.ch-item.selected { background: var(--selected-bg); }
.ch-badge {
  width: 40px; height: 40px; min-width: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 13px; letter-spacing: .3px;
}
.ch-item-body { flex: 1; min-width: 0; }
.ch-item-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 2px; }
.ch-item-name { font-weight: 600; font-size: 14px; }
.ch-item-time { font-size: 12px; font-weight: var(--fw-medium); color: var(--text-muted); white-space: nowrap; } /* #1668 M3 — was 11px/400 */
.ch-unread-badge {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  margin-left: 4px;
  background: var(--accent, #3b82f6);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  border-radius: 9px;
  text-align: center;
  line-height: 1.4;
}
/* Shared icon button base for sidebar row controls (remove ✕, share ⤴). EMOJI-OK-COMMENT
   Inherits the shared 48x48 house minimum above. */
.ch-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 4px; margin-left: 2px;
  box-sizing: border-box;
  opacity: 0.55; transition: opacity 0.15s, color 0.15s;
  line-height: 1; user-select: none;
}
/* #354: one overflow trigger per saved channel. It keeps the 48x48 house
   target (#2052) but the negative margins take it out of the row's height, so
   a saved row is as tall as a Network row. */
.ch-row-menu-btn { margin: -4px -8px -4px 0; flex-shrink: 0; opacity: 0.8; }
.ch-row-menu-btn .ph-icon { width: 18px; height: 18px; }
button.ch-item:hover .ch-icon-btn { opacity: 1; }
.ch-icon-btn:hover, .ch-icon-btn:focus-visible { opacity: 1 !important; }
.ch-icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
.ch-row-menu {
  position: fixed; z-index: var(--z-popover, 300); min-width: 160px; max-width: calc(100vw - 8px);
  padding: 4px; background: var(--card-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 16px var(--shadow);
}
.ch-row-menu[hidden] { display: none; }
.ch-row-menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 12px;
  background: none; border: none; border-radius: 6px; color: inherit; font: inherit; text-align: left;
  cursor: pointer; touch-action: manipulation;
}
.ch-row-menu-item:hover, .ch-row-menu-item:focus-visible { background: var(--row-hover); outline: none; }
.ch-row-menu-item:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.ch-row-menu-danger { color: var(--danger); }
.ch-user-badge { font-size: 12px; font-weight: var(--fw-medium); margin-left: 2px; opacity: 0.85; flex-shrink: 0; } /* #1668 M3 r1 — chip floor, mirror row chips (adv #2) */
.ch-item-preview { font-size: 13px; font-weight: var(--fw-medium); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* #1668 M3 — was 12px/400 */

.ch-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; }

/* Sidebar resize handle (#89) */
.ch-sidebar-resize {
  position: absolute; top: 0; right: -3px; width: 6px; height: 100%;
  cursor: col-resize; z-index: 10; background: transparent;
}
.ch-sidebar-resize:hover { background: var(--accent); opacity: 0.3; }
.ch-sidebar { position: relative; }
.ch-main-header {
  padding: 14px 20px; font-size: 16px; font-weight: 700;
  border-bottom: 1px solid var(--border); background: var(--card-bg);
  display: flex; align-items: center; gap: 8px;
}
.ch-back-btn {
  display: none; background: none; border: none; font-size: 22px; cursor: pointer;
  color: var(--text); padding: 8px 12px; border-radius: 4px;
  align-items: center; justify-content: center;
  min-width: 48px; min-height: 48px;
  -webkit-tap-highlight-color: rgba(0,0,0,.08);
  touch-action: manipulation;
}
.ch-back-btn:hover { background: var(--row-hover); }
.ch-header-text { flex: 1; }
.ch-messages {
  flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 16px;
  background: var(--content-bg);
}
.ch-empty, .ch-loading { color: var(--text-muted); text-align: center; padding: 40px; font-size: 14px; margin: auto; }
.ch-msg { display: flex; gap: 12px; }
.ch-avatar {
  width: 36px; height: 36px; min-width: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 15px; margin-top: 2px;
}
.ch-msg-content { flex: 1; min-width: 0; }
.ch-msg-sender { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.ch-msg-bubble {
  background: var(--surface-1); color: var(--text); padding: 10px 14px; border-radius: 4px 12px 12px 12px;
  font-size: 14px; line-height: 1.5; word-break: break-word; display: inline-block; max-width: 100%;
  border: 1px solid var(--border);
}
.ch-mention { color: var(--link-color); font-weight: 600; }
/* Ping-bot reply (public/channels.js botReplyHtml) -- dashed border marks
 * it as a synthesized, CoreScope-only reply, never actually transmitted
 * onto the mesh, distinct from a real observed message. */
.ch-bot-message { margin-top: -8px; }
.ch-bot-message .ch-msg-bubble { border-style: dashed; font-style: italic; }
.ch-encrypted-text { font-size: 11px; color: var(--text-muted); }
.ch-msg-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.ch-path-hash-badge {
  display: inline-flex;
  max-width: 100%;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: var(--badge-radius);
  background: var(--surface-2);
  color: var(--text-muted);
  line-height: 1.4;
  overflow-wrap: anywhere;
  vertical-align: baseline;
}
/* #353 — 1-byte path hash warning, shared by the channel "Sent with" badge,
 * the packet-detail Hash Size row and the node badge (renderPathHashSize in
 * public/app.js). The icon + sr-only text carry it without colour. */
.path-hash-warn { color: var(--path-hash-warn); font-weight: 600; }
.path-hash-warn .ph-icon { margin-right: 3px; vertical-align: -0.125em; }
/* #480 — "no scope" marker (renderNoScope in app.js): reuses the amber
 * --path-hash-warn recommendation colour; stays compact on most messages. */
.no-scope { white-space: nowrap; }
.ch-path-hash-badge--warn { border-color: var(--path-hash-warn); align-items: center; }
.node-path-hash-badge { background: var(--surface-2); border: 1px solid var(--path-hash-warn); font-size: 10px; }
.ch-analyze-link { color: var(--link-color); text-decoration: none; margin-left: 8px; }
.ch-analyze-link:hover { text-decoration: underline; }
.ch-scroll-btn {
  position: absolute; bottom: 16px; right: 24px; background: var(--accent); color: #fff;
  border: none; border-radius: 20px; padding: 8px 16px; font-size: 12px; font-weight: 600;
  cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.2); z-index: 10;
}
.ch-scroll-btn:hover { background: var(--accent-hover); }
.ch-scroll-btn.hidden { display: none; }

/* Clickable sender names */
.ch-sender-link { cursor: pointer; text-decoration: none; }
.ch-sender-link:hover { text-decoration: underline; }
.ch-avatar { cursor: pointer; }

/* Node tooltip (hover) */
.ch-node-tooltip {
  position: fixed; z-index: 1000; background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px; box-shadow: 0 4px 16px rgba(0,0,0,.15);
  min-width: 180px; max-width: 260px;
}
.ch-tooltip-name { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.ch-tooltip-role { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.ch-tooltip-meta { font-size: 11px; color: var(--text-muted); }
.ch-tooltip-key { font-size: 10px; color: var(--text-muted); margin-top: 4px; }

/* Node detail panel (slide from right) */
.ch-node-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: 320px; max-width: 80%;
  background: var(--card-bg); border-left: 1px solid var(--border);
  box-shadow: -4px 0 16px rgba(0,0,0,.1); z-index: 20;
  transform: translateX(100%); transition: transform .2s ease;
  overflow-y: auto; display: flex; flex-direction: column;
}
.ch-node-panel.open { transform: translateX(0); }
.ch-node-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0;
  background: var(--card-bg); z-index: 1;
}
.ch-node-close {
  background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted);
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
}
.ch-node-close:hover { background: var(--row-hover); color: var(--text); }
.ch-node-panel-body { padding: 16px; flex: 1; }
.ch-node-field { font-size: 13px; margin-bottom: 8px; }
.ch-node-label { display: block; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .3px; margin-bottom: 2px; }
.ch-node-adverts { margin-top: 12px; }
.ch-node-advert { font-size: 12px; color: var(--text-muted); padding: 4px 0; border-bottom: 1px solid var(--border); }
.ch-node-link { display: inline-block; margin-top: 12px; color: var(--link-color); text-decoration: none; font-size: 13px; }
.ch-node-link:hover { text-decoration: underline; }

/* === Nodes Page === */
.nodes-page { display: flex; flex-direction: column; height: 100%; }
.nodes-page .split-layout { flex: 1; min-height: 0; }
.nodes-topbar {
  padding: 12px 16px; display: flex; align-items: center; gap: 16px;
  border-bottom: 1px solid var(--border); background: var(--card-bg); flex-shrink: 0;
}
.nodes-search {
  flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; background: var(--input-bg); color: var(--text); font-family: var(--font);
}
.nodes-counts { display: flex; gap: 8px; flex-shrink: 0; }
.nodes-export-btn { flex-shrink: 0; white-space: nowrap; }
.node-count-pill {
  display: inline-block; padding: 3px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap;
}
.nodes-tabs-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; flex-wrap: wrap; gap: 8px;
}
.nodes-tabs { display: flex; gap: 2px; }
.node-tab {
  padding: 7px 16px; border: none; background: none; cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--text-muted); border-bottom: 2px solid transparent;
  font-family: var(--font); transition: all .15s;
}
.node-tab:hover { color: var(--text); }
.node-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.nodes-filters { display: flex; gap: 8px; align-items: center; }
.nodes-filters select {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; background: var(--input-bg); color: var(--text); font-family: var(--font);
  height: 34px; min-height: 34px; box-sizing: border-box; line-height: 1;
}

/* Node Detail */
.node-detail { padding: 4px 0; }
.node-detail-name { font-size: 20px; font-weight: 700; margin: 12px 0 4px; }
.node-detail-role { margin-bottom: 12px; }
.node-detail-section {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px; margin-bottom: 8px;
}
/* Bug 7 fix: neighbor table text inherits accent color — force readable text */
.node-detail-section .data-table td,
.node-full-card .data-table td {
  color: var(--text);
}
.node-detail-section .data-table td a,
.node-full-card .data-table td a {
  color: var(--accent);
}
/* #1146: "Paths Through This Node" entries render as <div> blocks, not
   tables, so the rule above doesn't reach them. Without this, the path-hop
   <a> elements inherit the UA-default rgb(0,0,238) blue, which on the dark
   card surface (--card-bg: #232340 in dark mode) computes to ~2.5-3.5:1 — well below
   the 4.5:1 WCAG AA body-text minimum. Use --accent so the link tracks the
   active theme (and customizer overrides) like the data-table links do. */
.node-detail-section #pathsContent a,
.node-full-card #fullPathsContent a {
  color: var(--accent);
}
.node-detail-section #pathsContent a:hover,
.node-full-card #fullPathsContent a:hover {
  color: var(--accent-hover);
}
.node-detail-section h4 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted); margin-bottom: 8px; padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.node-detail-key {
  font-size: 11px; word-break: break-all; color: var(--text-muted);
  background: var(--row-stripe); padding: 6px 8px; border-radius: 4px; margin-bottom: 8px;
}
.node-map-container { margin-bottom: 8px; }
.qr-placeholder { text-align: center; padding: 12px; }
.qr-box {
  width: 120px; height: 120px; margin: 0 auto; border: 2px dashed var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 13px; border-radius: 8px;
}
.btn-primary {
  background: var(--accent); color: #fff; border: none; padding: 8px 20px;
  border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent-hover); }

/* Advert Timeline */
.advert-entry {
  display: flex; align-items: flex-start; gap: 10px; padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.advert-entry:last-child { border-bottom: none; }
.advert-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 4px;
}
/* #829: explicit color so text stays readable when inherited color matches card-bg */
.advert-info { font-size: 12px; line-height: 1.5; color: var(--text); }
.advert-info a { color: var(--link-color); }

/* === Traces Page === */
.traces-page { padding: 16px; max-width: var(--trace-max-width, 95vw); margin: 0 auto; }
.trace-search {
  display: flex; gap: 8px; margin-bottom: 20px;
}
.trace-search input {
  flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; font-family: var(--mono); background: var(--input-bg); color: var(--text);
}
.trace-empty { text-align: center; padding: 40px; color: var(--text-muted); font-size: 14px; }
.trace-summary {
  display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.trace-stat {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 20px; text-align: center; flex: 1; min-width: 120px;
}
.trace-stat-value { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.trace-stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); }
.trace-section {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 16px; margin-bottom: 16px;
}
.trace-section h3 { font-size: 14px; font-weight: 700; margin-bottom: 12px; }

/* Path Visualization */
.trace-path-viz {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 12px; background: var(--nav-bg); border-radius: 6px; margin-bottom: 8px;
}
.trace-path-hop {
  display: inline-block; padding: 4px 10px; background: var(--accent); color: #fff;
  border-radius: 4px; font-family: var(--mono); font-size: 12px; font-weight: 600;
}
.trace-path-arrow { color: var(--text-muted); font-size: 16px; }
.trace-path-label { color: var(--text-muted); font-size: 12px; font-style: italic; }
.trace-path-info { font-size: 12px; color: var(--text-muted); }

/* Timeline */
.tl-header {
  display: grid; grid-template-columns: 160px 1fr 70px 70px 70px;
  gap: 8px; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .3px; color: var(--text-muted); padding-bottom: 6px;
  border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.tl-row {
  display: grid; grid-template-columns: 160px 1fr 70px 70px 70px;
  gap: 8px; align-items: center; padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.tl-observer { font-size: 12px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-bar-container {
  position: relative; height: 16px; background: var(--border); border-radius: 8px;
}
.tl-marker {
  position: absolute; top: 2px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); transform: translateX(-50%);
  box-shadow: 0 0 6px rgba(74, 158, 255, .5);
}
.tl-delta { font-size: 11px; color: var(--text-muted); text-align: right; }
.tl-snr { font-size: 12px; font-weight: 600; text-align: right; }
.tl-snr.good { color: var(--status-green); }
.tl-snr.ok { color: var(--status-yellow); }
.tl-snr.bad { color: var(--status-red); }
.tl-rssi { font-size: 12px; color: var(--text-muted); text-align: right; }

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* === Observers Page === */
.observers-page { padding: 20px; margin: 0 auto; }
.obs-summary { display: flex; gap: 20px; margin-bottom: 16px; flex-wrap: wrap; }
.obs-stat { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-muted); }
/* #1562 — "Last updated: X ago" pill on the observers-page header.
   Clickable (forces a fresh fetch / bypasses client cache). Goes to
   --warning when the cached payload is >60s old so operators see staleness. */
.obs-updated { cursor: pointer; font-size: 13px; color: var(--text-muted); border: 1px dashed transparent; padding: 2px 6px; border-radius: 4px; }
.obs-updated:hover, .obs-updated:focus { border-color: var(--border); outline: none; }
.obs-updated-stale { color: var(--status-yellow); border-color: var(--status-yellow); }
.health-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.health-dot.health-green { background: var(--status-green); box-shadow: 0 0 6px #22c55e80; }
.health-dot.health-yellow { background: var(--status-yellow); box-shadow: 0 0 6px #eab30880; }
.health-dot.health-red { background: var(--status-red); box-shadow: 0 0 6px #ef444480; }
.obs-table td:first-child { white-space: nowrap; }
.obs-table td:nth-child(6) { max-width: none; overflow: visible; }
.col-observer { min-width: 70px; max-width: none; }
.col-scope { min-width: 60px; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spark-bar { position: relative; min-width: 60px; max-width: 100px; flex: 1; height: 18px; background: var(--border); border-radius: 4px; overflow: hidden; display: inline-block; vertical-align: middle; }
@media (max-width: 640px) { .spark-bar { max-width: 60px; } }
.spark-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-hover, #60a5fa)); border-radius: 4px; transition: width 0.3s; }
.spark-label { position: absolute; right: 4px; top: 0; line-height: 18px; font-size: 11px; color: var(--text); font-weight: 500; }

/* === Dark mode input overrides === */
[data-theme="dark"] .filter-bar input,
[data-theme="dark"] .filter-bar select,
[data-theme="dark"] .nodes-search,
[data-theme="dark"] .ch-region-select,
[data-theme="dark"] .nodes-filters select,
[data-theme="dark"] .trace-search input,
[data-theme="dark"] .mc-jump-btn,
[data-theme="dark"] .filter-bar .btn { background: var(--input-bg); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .filter-bar .btn.active { background: var(--accent-strong); color: var(--text-on-accent); border-color: var(--accent-strong); }
[data-theme="dark"] .ch-item.selected,
[data-theme="dark"] .data-table tbody tr.selected { background: var(--selected-bg); }
[data-theme="dark"] .tl-bar-container { background: #334155; }
[data-theme="dark"] .spark-bar { background: #334155; }
[data-theme="dark"] .spark-label { color: #e2e8f0; }
[data-theme="dark"] .hex-dump { border: 1px solid var(--border); }
[data-theme="dark"] .mc-jump-btn { background: var(--surface-2); color: var(--text); }

/* === Search Overlay === */
.search-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 300;
  display: flex; align-items: flex-start; justify-content: center; padding-top: 80px;
}
.search-overlay.hidden { display: none; }
.search-box {
  background: var(--card-bg); border-radius: 12px; width: 560px; max-width: 90vw;
  box-shadow: 0 16px 48px rgba(0,0,0,.3); overflow: hidden;
}
.search-box input {
  width: 100%; padding: 16px 20px; border: none; font-size: 16px;
  background: var(--card-bg); color: var(--text); font-family: var(--font);
  outline: none; border-bottom: 1px solid var(--border);
}
.search-results { max-height: 400px; overflow-y: auto; }
.search-result-item {
  padding: 10px 20px; cursor: pointer; font-size: 13px;
  border-bottom: 1px solid var(--border); transition: background .1s;
}
.search-result-item:hover { background: var(--row-hover); }
.search-result-type { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--link-color); margin-right: 8px; }
.search-no-results { padding: 20px; text-align: center; color: var(--text-muted); font-size: 14px; }

/* === Loading States & Transitions (M16) === */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--row-hover) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
}
.skeleton-line { height: 14px; margin-bottom: 10px; }
.skeleton-line.short { width: 60%; }
.skeleton-line.shorter { width: 40%; }
.skeleton-table-row { display: flex; gap: 12px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.skeleton-table-cell { height: 16px; flex: 1; }
.skeleton-table-cell.narrow { max-width: 80px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.page-enter { animation: fadeIn 150ms ease-out; }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty-state-text { font-size: 15px; font-weight: 500; margin-bottom: 4px; }
.empty-state-hint { font-size: 13px; }

/* === M17 Visual Juice === */
@keyframes row-flash {
  0% { background: rgba(74, 158, 255, 0.25); }
  100% { background: transparent; }
}
.data-table tbody tr.new-row { animation: row-flash 800ms ease-out; }

.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--link-color); }
.data-table th.sort-active { color: var(--link-color); }
.data-table th .sort-arrow { font-size: 10px; margin-left: 4px; opacity: 0.7; }
.data-table tbody tr { border-left: 3px solid transparent; transition: border-color 0.15s, background 0.15s; }
.data-table tbody tr:hover { border-left-color: var(--accent); }

.badge { transition: transform 0.15s ease; }
.badge:hover { transform: scale(1.05); }

@keyframes slideInRight { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.panel-right:not(.empty) { animation: slideInRight 200ms ease-out; }

/* === Hamburger (hidden on desktop) === */
.hamburger { display: none; }
/* "More" button (hidden on desktop) */
.nav-more-wrap { display: none; position: relative; }
.nav-more-btn { display: inline-flex; }
/* #1406: position:fixed (not absolute) so the dropdown escapes .nav-more-wrap's
   layout box. When absolute, the dropdown's content extents inflated
   .nav-more-wrap.scrollHeight → bubbled into .nav-left flex line-height calc
   → centered a 279px content line in 52px container → entire nav strip clipped
   above viewport. position:fixed removes the dropdown from flow entirely; JS in
   app.js positions top/right dynamically relative to the More button. */
.nav-more-menu {
  display: none; position: fixed; right: 0; top: 0;
  background: var(--nav-bg); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15); flex-direction: column;
  min-width: 160px; padding: 4px 0; z-index: 1200;
}
.nav-more-menu.open { display: flex; }
.nav-more-menu .nav-link {
  padding: 10px 16px; border-bottom: none; border-radius: 0; margin: 0;
  white-space: nowrap;
}
.nav-more-menu .nav-link:hover { background: var(--nav-bg2); color: var(--nav-text); }
.nav-more-menu .nav-link.active { background: var(--nav-active-bg); }
/* Ensure nav stays above Leaflet map */
.nav-links.open { z-index: 1100; }
#map-wrap .leaflet-container { z-index: 1; }

/* === Responsive — Tablet (≤900px) === */
@media (max-width: 900px) {
  .panel-right { width: 320px; min-width: 320px; }
  .nav-stats { display: none; }
  /* #1450 — same svg/img split at tablet width */
  svg.brand-logo { height: 32px; width: 112px; }
  img.brand-logo { height: 32px; width: auto; max-width: 180px; }
  .nav-link { padding: 14px 8px; font-size: 13px; }
  .map-controls { width: 180px; font-size: 12px; }
}

/* === Responsive — Mobile (≤400px) ===
   At narrow viewports the inline wordmark SVG (intrinsic 111px content)
   clips when squeezed into the 99px tablet pin (#1137 → SCOPE→SCOF).
   Swap to the dedicated .brand-mark-only inline SVG (arcs+dots only). */
@media (max-width: 400px) {
  /* #1450 — must match the svg/img specificity used at top-level
     (svg.brand-logo / img.brand-logo, 0,1,1) or the new rules win
     and the wordmark fails to hide on narrow mobile widths. */
  svg.brand-logo, img.brand-logo { display: none; }
  .brand-mark-only { display: block; }
}

/* #1057: Container query — stack the channels layout when the channels
   page itself is narrow (e.g. on tablets, or when a side panel consumes
   width). Below ~700px of *container* inline size, sidebar drops to full
   width and stacks above the message area instead of squeezing it. */
@container chlayout (max-width: 700px) {
  .ch-layout { flex-direction: column; }
  .ch-sidebar {
    width: 100%; min-width: 0;
    max-height: 40%;
    overflow-y: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .ch-sidebar-resize { display: none; }
  .ch-main { width: 100%; }
}

/* === Nav Priority+ — JS-driven measurement (Issue #1102) ===
   Above the mobile hamburger breakpoint we render ALL nav links inline
   by default. A small JS pass in app.js (applyNavPriority) measures the
   actual fit and adds .is-overflow to whichever links don't fit, then
   moves them into the "More ▾" overflow menu. Pure CSS can't do this
   correctly because we want every link visible at 2560px+ but only the
   high-priority ones at 800px — and the breakpoint where each link
   drops depends on its label width, the gutters, the active-link
   padding, and the nav-stats badge. JS measurement is the only correct
   answer. data-priority="high" links are pinned to the left via
   order:-1 and are kept inline as long as possible (low-priority links
   overflow first). Spacing/type still use #1054 fluid clamp() tokens. */
@media (min-width: 768px) {
  .nav-links { display: flex !important; flex-direction: row; gap: var(--space-xs); }
  .nav-more-wrap { display: flex; align-items: center; }
  .hamburger { display: none; }
  .nav-link { padding: 14px clamp(8px, 0.6vw + 4px, 14px); font-size: var(--fs-sm); }
  .nav-links a[data-priority="high"] { order: -1; }
  .nav-link.active { background: var(--nav-active-bg); border-radius: 6px; margin: 4px 0; padding: 10px clamp(8px, 0.6vw + 4px, 14px); }
  /* JS-managed: links assigned .is-overflow get hidden inline; the
     "More ▾" wrap is hidden when nothing overflows. */
  .nav-links .nav-link.is-overflow { display: none; }
  .nav-more-wrap.is-hidden { display: none !important; }
}

/* === Nav narrow-desktop tightening (Issue #1055 — 1024px overlap fix) ===
   Between 768px and ~1100px, even with Priority+ collapsed to 5 high
   links + "More ▾" + 4 nav-right buttons + nav-stats, the row doesn't
   fit and the rightmost visible link overlaps nav-right by ~20px.
   Hide nav-stats and tighten nav-link padding/gap in this band;
   nav-stats reappears at ≥1101px where there is room for it.
   NOTE: this block MUST follow the (min-width: 768px) Priority+ block
   above so its tighter padding/gap rules win the cascade by source
   order at 1024px (same specificity). */
@media (min-width: 768px) and (max-width: 1100px) {
  .nav-stats { display: none; }
  .nav-links { gap: 0; }
  .nav-link { padding: 14px 6px; }
  .nav-link.active { padding: 10px 6px; }
  .nav-right { gap: 4px; }
}

/* === Responsive — Hamburger nav (<768px) === */
@media (max-width: 767px) {
  .hamburger { display: inline-flex; }
  .nav-more-wrap { display: none !important; }
  .nav-links {
    /* Issue #1109: was position:absolute. The containing block becomes
       .top-nav (the nearest positioned ancestor: position:sticky), which
       has `overflow:hidden; height:52px` since #1066 to guard against
       horizontal overflow during the Priority+ measurement pass. That
       guard clipped this dropdown invisibly below the navbar. Switching
       to position:fixed escapes any overflow:hidden ancestor (containing
       block becomes the viewport) without relaxing the #1066 desktop
       overflow guard. */
    display: none; position: fixed; top: 52px; left: 0; right: 0;
    background: var(--nav-bg); flex-direction: column; padding: 8px 0;
    box-shadow: 0 8px 24px rgba(0,0,0,.4); z-index: 1100;
    max-height: calc(100dvh - 52px); overflow-y: auto;
  }
  .nav-links a:not([data-priority="high"]) { display: flex; }
  .nav-links.open { display: flex; }
  .nav-link { padding: 12px 20px; border-bottom: none; }
  /* Issue #1400: restore 48px touch-target on mobile only. Global rule
     removed because it overflowed the 52px desktop top-nav. */
  .nav-link { min-height: 48px; }
  .nav-link.active { background: var(--nav-active-bg); border-radius: 0; margin: 0; padding: 12px 20px; }
  .nav-left { gap: 12px; }
  body.nav-open { overflow: hidden; }
}

/* === Responsive — Mobile (≤640px) === */
@media (max-width: 640px) {
  .nav-right { gap: 4px; }

  /* Layouts: stack instead of side-by-side */
  .split-layout { flex-direction: column; overflow-y: auto; }
  .panel-left { padding: 6px; flex: 1; min-height: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .panel-right { display: none; }

  /* Channels: stack sidebar above message area on narrow viewports.
     #1057 follow-up: container query alone was being overridden here by
     the previous Discord-overlay rule (flex-direction:row + absolute
     positioning), so the layout failed to stack at 480px. Use a plain
     stacking layout that the E2E test recognizes (sidebar.bottom <=
     main.top). */
  .ch-layout { flex-direction: column; position: relative; }
  .ch-sidebar {
    width: 100%; min-width: 0; max-height: 40%; height: auto;
    overflow-y: auto;
    border-right: none; border-bottom: 1px solid var(--border);
    background: var(--card-bg);
  }
  .ch-sidebar-resize { display: none; }
  .ch-main {
    width: 100%; flex: 1; min-height: 0;
    background: var(--content-bg);
  }
  .ch-back-btn { display: flex; }
  .ch-main-header { display: flex; align-items: center; gap: 8px; }

  /* #1224 Channels mobile UX: compact header, dominant channel name,
     icon-only row actions, smaller empty state. */
  .ch-sidebar-header {
    padding: 6px 10px; gap: 6px;
  }
  /* #235: with 48px touch targets the region pills cannot share a row with
     the title and + Add at phone width. Keep title and + Add on the first
     row and give the pills the second. The old max-height: 56px cap only
     hid the overflow: the list was drawn over the lower half of the pills. */
  .ch-sidebar-header .ch-header-region { order: 1; }
  .ch-sidebar-title { font-size: 14px; }
  .ch-sidebar-title .ch-icon { font-size: 16px; }
  .ch-add-channel-btn { padding: 4px 8px; font-size: 12px; }
  .ch-analytics-link { padding: 3px 7px; font-size: 13px; }
  /* Region filter shows just its compact pills/dropdown trigger in the header. */
  .ch-header-region .region-filter-bar { padding: 0; gap: 4px; }
  .ch-header-region .region-pill { padding: 2px 6px; font-size: 11px; }
  /* #416 — the channels header is the tightest host of the region control. */
  .ch-header-region .region-quick-pick { padding: 2px 6px; font-size: 11px; }
  .ch-header-region .region-quick-picks { gap: 4px; }
  .ch-header-region .region-dropdown-trigger { padding: 3px 6px; font-size: 11px; }
  /* #620: the shared menu placement (region-filter.js placeMenu) keeps the
     open menu inside the viewport wherever the trigger sits, so Channels
     needs no menu override of its own (it used to pin right: 0 here). */

  /* Channel list row: name must dominate. Below 768px channels.js renders
     the flat .ch-row list (#1367), which has no inline share/remove
     actions, so there is no size override for .ch-icon-btn here: wherever
     those actions render they keep the shared 48x48 house minimum. */
  #chList .ch-item { padding: 10px 12px; gap: 10px; }
  #chList .ch-item-name { flex: 1 1 auto; min-width: 0; }
  #chList .ch-item-top { gap: 6px; }
  /* #1648 M5: share-btn now renders an inline <svg.ph-icon> from channels.js,
   * so the legacy `font-size: 0` + `::before { content: '<emoji>' }` shim is
   * obsolete. The SVG inherits color via currentColor. */
  /* Mobile-narrow timestamp — #1668 M3 chip floor (12px+500 carries from base) */
  #chList .ch-item-time { font-size: 12px; }

  /* Empty state must not dominate. */
  .ch-empty { padding: 12px; font-size: 13px; max-height: 30vh; }

  /* Tables: smaller text for mobile — #1668 M3 chip floor (12px+500) */
  .data-table { font-size: 12px; min-width: 0; }
  .data-table td { padding: 5px 4px; max-width: 100px; }
  .data-table th { padding: 5px 4px; font-size: 10px; }
  .data-table .col-time { min-width: 64px; }
  .panel-left { overflow-x: auto; }

  /* #1770: packets-view virtual-scroller assumes constant row height
     (VSCROLL_ROW_HEIGHT). The base rule at ~L1097 sets
     `.data-table td.col-details { white-space: normal; word-break: break-word }`
     which let the "Details" cell wrap on narrow viewports (since #1122 the
     inner clip is also line-clamped at wider widths, see ~L1106), producing
     variable row heights → visible jitter when scrolling past ~900px on
     iOS. Quick-fix (S path): clamp the cell to a single line on mobile.
     The proper L-path fix (per-row measurement) tracks separately.

     v2 (#1805 follow-up): the clamp lives on an INNER `.col-details-clip`
     wrapper, not the `<td>` itself. Reason: with `white-space: nowrap` on
     the td and `table-layout: auto`, the cell's min-content becomes the
     full single-line text width, blowing past the `max-width: 100px`
     mobile hint. Rows then grow wider than the 360px viewport — which
     breaks `test-gestures-1062-e2e.js` (a)/(h) because the swipe coords
     fall outside the viewport and `elementFromPoint` no longer hits the
     row. Inline-block + fixed `max-width` on the clip caps the column's
     preferred width so the row stays viewport-bounded and gestures work. */
  .data-table td.col-details > .col-details-clip {
    display: inline-block;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
  }

  /* Filters: collapse on mobile */
  .filter-bar { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .filter-toggle-btn { display: inline-flex !important; }
  .filter-bar > *:not(.filter-toggle-btn):not(.col-toggle-wrap) { display: none; }
  /* Must match :not() specificity of the hide rule above, otherwise .filters-expanded loses
     the specificity battle and filter children stay hidden (see issue #534). */
  .filter-bar.filters-expanded > *:not(.filter-toggle-btn):not(.col-toggle-wrap) { display: inline-flex; }
  .filter-bar.filters-expanded > .col-toggle-wrap { display: inline-block; }
  .filter-bar.filters-expanded input { width: 100%; }
  .filter-bar.filters-expanded select { width: 100%; }
  .filter-group { flex-wrap: wrap; }
  .filter-group + .filter-group { border-left: none; padding-left: 0; margin-left: 0; }
  .filter-bar .btn { min-height: 36px; }
  .node-filter-wrap { width: 100%; }

  /* Nodes */
  .nodes-topbar { flex-direction: column; gap: 8px; padding: 10px; }
  .nodes-tabs-bar { flex-direction: column; }
  .nodes-counts { flex-wrap: wrap; }
  .node-count-pill { font-size: 11px; padding: 2px 8px; }

  /* Traces */
  .trace-summary { flex-direction: column; }
  .tl-header, .tl-row { grid-template-columns: 100px 1fr 50px 50px 50px; gap: 4px; font-size: 11px; }

  /* Search overlay: full width */
  .search-box { width: 95vw; }
  .search-overlay { padding-top: 60px; }

  /* Map controls — #1329: drop fixed 200px cap, use accordion sections
     instead so visible content fits without internal scrolling. Panel can
     grow to fill available height; max-height bound by viewport so it
     never escapes the screen. */
  .map-controls { width: calc(100vw - 24px); right: 12px; top: 8px; max-height: calc(100vh - 80px); font-size: 12px; padding: 10px 12px; }
  /* On mobile, hide collapsed section bodies (everything inside the
     fieldset except the legend). The legend remains tappable to expand. */
  .map-controls fieldset.mc-section.mc-collapsed > *:not(legend) { display: none; }
  .map-controls fieldset.mc-section > legend.mc-label {
    cursor: pointer;
    user-select: none;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
  }
  /* ▸ / ▾ indicator via ::after so we don't touch markup */
  .map-controls fieldset.mc-section > legend.mc-label::after {
    content: '▾';
    font-size: 10px;
    color: var(--text-muted);
    margin-left: 8px;
    transition: transform 0.15s;
  }
  .map-controls fieldset.mc-section.mc-collapsed > legend.mc-label::after {
    content: '▸';
  }
  #leaflet-map { z-index: 0; }
  #map-wrap { z-index: 0; }

  /* Detail: smaller text */
  .detail-meta { grid-template-columns: 1fr; }
  .hex-dump { font-size: 10px; }

  /* Modal */
  .modal { width: 95vw; padding: 16px; }

  /* Page header */
  .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
}

/* === Grouped Packet Rows === */
.group-header { cursor: pointer; font-weight: 600; }
.group-header:hover { background: var(--row-hover); }
.group-child { font-size: 12px; }
.group-child td { padding-left: 20px; }
.group-child.hidden { display: none; }

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Favorite stars — Phosphor sprite, 48×48 hit target (the house minimum, #2052) */
.fav-star {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 0; line-height: 1;
  transition: color .15s, transform .15s;
  min-width: 48px; min-height: 48px;
  display: inline-flex; align-items: center; justify-content: center;
}
.fav-star .ph-icon { width: 22px; height: 22px; }
.fav-star:hover { transform: scale(1.1); }
.fav-star.on { color: var(--status-yellow); }

/* BYOP Decode Modal */
.byop-modal { max-width: 560px; }
.byop-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.byop-header h3 { margin: 0; }
.byop-x { font-size: 1.2rem; color: var(--text-muted); background: none; border: none; cursor: pointer; }
.byop-input {
  width: 100%; min-height: 60px; max-height: 120px; resize: vertical;
  font-family: var(--mono); font-size: .8rem; padding: 10px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface-1);
  color: var(--text);
}
.byop-input:focus { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 1px; }
.byop-err { color: var(--status-red); font-size: .85rem; }
.byop-decoded { margin-top: 8px; }
.byop-section { margin-bottom: 14px; }
.byop-section-title {
  font-size: .75rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--accent); font-weight: 600; margin-bottom: 6px;
  padding-bottom: 4px; border-bottom: 1px solid var(--border);
}
.byop-kv { display: flex; flex-direction: column; gap: 4px; }
.byop-row { display: flex; gap: 12px; font-size: .85rem; }
.byop-key { color: var(--text-muted); min-width: 110px; flex-shrink: 0; }
.byop-val { color: var(--text); word-break: break-all; }
.byop-path { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-family: var(--mono); font-size: .8rem; }
.byop-hex { font-size: .75rem; word-break: break-all; color: var(--text-muted); background: var(--surface-1); padding: 8px; border-radius: 4px; max-height: 80px; overflow: auto; }
.byop-pre { font-size: .75rem; margin: 0; white-space: pre-wrap; }

/* Favorites nav dropdown */
.nav-fav-wrap { position: relative; }
.nav-fav-dropdown {
  display: none; position: absolute; top: 100%; right: 0; z-index: 1000;
  min-width: 260px; max-height: 360px; overflow-y: auto;
  background: var(--surface-1, var(--detail-bg)); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.15); margin-top: 6px;
}
.nav-fav-dropdown.open { display: block; }
.fav-dd-empty { padding: 20px; text-align: center; color: var(--text-muted); font-size: .85rem; }
.fav-dd-loading { padding: 16px; text-align: center; color: var(--text-muted); font-size: .85rem; }
.fav-dd-item {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  text-decoration: none; color: var(--text); transition: background .1s;
  border-bottom: 1px solid var(--border);
}
.fav-dd-item:last-child { border-bottom: none; }
.fav-dd-item:hover { background: var(--surface-1); }
.fav-dd-status { font-size: .7rem; flex-shrink: 0; }
.fav-dd-name { flex: 1; font-size: .85rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fav-dd-meta { font-size: .75rem; color: var(--text-muted); flex-shrink: 0; }
.fav-dd-star { font-size: .9rem; }

/* Leaflet popup accessibility — ensure readable in both themes */
.leaflet-popup-content-wrapper {
  background: var(--card-bg) !important; color: var(--text) !important;
  border-radius: 8px !important; box-shadow: 0 4px 12px rgba(0,0,0,.2) !important;
}
.leaflet-popup-tip { background: var(--card-bg) !important; }
.leaflet-popup-content { color: var(--text) !important; font-size: 13px !important; }

/* packet-path-map.js: tooltips got long once they started carrying role,
   approx/confidence, and distance/timing info together -- Leaflet's
   default tooltip is white-space:nowrap, which stretched a long one
   into an unreadable single line spanning the whole map. Wrap it onto
   multiple lines instead. Width is in ch (character-relative) rather
   than px so the box scales with font-size -- a fixed px width left
   room for barely one word per line at larger text sizes. The
   tooltip's containing pane has no intrinsic width, so a plain
   width:auto block collapses to min-content (one word per line,
   ignoring max-width entirely) -- width:max-content makes it size to
   its content up to max-width instead. */
.leaflet-tooltip.packet-path-tooltip {
  white-space: normal;
  width: max-content;
  max-width: 28ch;
}

/* For Leaflet layer control */
.leaflet-control-layers,
.leaflet-control-layers-expanded {
  background-color: var(--card-bg) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
.leaflet-control-layers-separator {
  border-top-color: var(--border) !important;
}
[data-theme="dark"] .leaflet-control-layers-toggle {
  filter: invert(1);
}

/* #839 — every map credit follows the theme (Leaflet's own is a white bar,
   which stayed light over a dark map). One more class than leaflet.css's
   rule, which loads after this file; the compact inset credit below and the
   Matrix theme still override it. */
.leaflet-container .leaflet-control.leaflet-control-attribution {
  background: color-mix(in srgb, var(--surface-1) 85%, transparent);
  color: var(--text-muted);
}
.leaflet-container .leaflet-control.leaflet-control-attribution a {
  color: var(--link-color);
}

/* #752 — the inset maps credit the viewer's active base map through the
   registry's own attribution control (MC_ensureAttribution, compact: true).
   The credit must stay legible on a 200px inset without swallowing it, so
   it is capped at two lines (--mc-credit-compact-max-height) and scrolls
   instead of being truncated: an attribution that is cut off is no
   attribution. Colours come from the theme tokens, like the layer control
   above. */
.leaflet-control-attribution.mc-credit-compact {
  font-size: var(--mc-credit-compact-font-size);
  line-height: var(--mc-credit-compact-line-height);
  max-width: var(--mc-credit-compact-max-width);
  max-height: var(--mc-credit-compact-max-height);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  padding: var(--mc-credit-compact-padding);
  background: color-mix(in srgb, var(--surface-1) 88%, transparent) !important;
  color: var(--text-muted) !important;
}
.leaflet-control-attribution.mc-credit-compact a {
  color: var(--accent) !important;
}

/* #680 — DHM terrain hillshade pane (between base tiles and markers). */
.mc-terrain-pane {
  mix-blend-mode: var(--terrain-overlay-blend);
  filter: var(--terrain-overlay-filter);
}

/* #724 M3 — antenna sites: the status line under the overlay toggles and
   the site popup. */
.mc-masts-status {
  font-size: 11px;
  color: var(--text-muted);
  margin: 0 0 4px 20px;
  max-width: 220px;
}
.mc-masts-popup .mc-masts-popup-title { font-weight: 600; margin-bottom: 2px; }
.mc-masts-popup .mc-masts-popup-addr,
.mc-masts-popup .mc-masts-popup-stations { font-size: 12px; }
.mc-masts-popup .mc-masts-popup-table { border-collapse: collapse; margin: 6px 0; font-size: 12px; }
.mc-masts-popup .mc-masts-popup-table th,
.mc-masts-popup .mc-masts-popup-table td { padding: 1px 6px 1px 0; text-align: left; }
.mc-masts-popup .mc-masts-popup-table tr.mc-masts-int td { color: var(--mast-interference); font-weight: 600; }
.mc-masts-popup .mc-masts-popup-hint { font-size: 12px; margin: 6px 0; padding-left: 6px; border-left: 3px solid var(--mast-interference); }
.mc-masts-popup .mc-masts-popup-note { font-size: 11px; color: var(--text-muted); margin: 6px 0 0; }

/* #723 M2 heritage popup */
/* Click-for-info on the protected ancient monuments overlay
   (heritage-info.js). Colours follow the theme through the variables. */
.mc-heritage-popup .leaflet-popup-content { margin: 10px 14px; min-width: 180px; }
.mc-heritage-info { color: var(--text); line-height: 1.35; }
.mc-heritage-title { font-weight: 600; font-size: 14px; margin: 0 24px 6px 0; overflow-wrap: anywhere; }
.mc-heritage-fields {
  display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0;
}
.mc-heritage-fields dt { color: var(--text-muted); }
.mc-heritage-fields dd { margin: 0; overflow-wrap: anywhere; }
.mc-heritage-msg { margin-right: 18px; }
.mc-heritage-note { margin-top: 6px; color: var(--text-muted); font-style: italic; }
.mc-heritage-credit { margin-top: 8px; font-size: 11px; color: var(--text-muted); }
/* Leaflet styles the button as .leaflet-container a.leaflet-popup-close-button,
   so these need the same specificity plus the popup class to win. */
.leaflet-container .mc-heritage-popup a.leaflet-popup-close-button { color: var(--text-muted); }
@media (pointer: coarse) {
  .leaflet-container .mc-heritage-popup a.leaflet-popup-close-button {
    width: 44px; height: 44px; line-height: 44px; font-size: 24px;
  }
  .mc-heritage-title, .mc-heritage-msg { margin-right: 40px; }
}
/* end #723 M2 heritage popup */

/* ---- Leaflet overrides for theme ---- */
.leaflet-control-zoom a {
  background: color-mix(in srgb, var(--surface-1) 92%, transparent) !important;
  backdrop-filter: blur(12px);
  color: var(--text) !important;
  border-color: var(--border) !important;
  width: 48px !important;
  height: 48px !important;
  line-height: 48px !important;
  font-size: 20px !important;
}
.leaflet-control-zoom a:hover {
  background: rgba(59, 130, 246, 0.2) !important;
}

/* Column resize handles */
.col-resize-handle {
  position: absolute; top: 0; right: -4px; width: 9px; height: 100%;
  cursor: col-resize; z-index: 5; background: transparent; border-radius: 1px;
}
.col-resize-handle::after {
  content: ''; position: absolute; top: 4px; left: 3px; width: 3px; height: calc(100% - 8px);
  background: var(--border); border-radius: 1px;
}
.col-resize-handle:hover::after, .col-resize-handle.active::after {
  background: var(--accent); opacity: 0.6;
}

/* Encrypted channels de-emphasized */
button.ch-item.ch-item-encrypted { opacity: 0.5; }
button.ch-item.ch-item-encrypted:hover { opacity: 0.7; }
button.ch-item.ch-item-encrypted.selected { opacity: 0.8; }
button.ch-item.ch-item-encrypted .ch-badge { filter: grayscale(0.6); }

/* Channel key input (#725 M2) */
.ch-key-input {
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px 0 0 6px;
  background: var(--card-bg);
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
}
.ch-key-input:focus {
  outline: 2px solid var(--accent, #3b82f6);
  outline-offset: -1px;
  border-color: var(--link-color, #3b82f6);
}
.ch-key-input::placeholder { color: var(--text-muted); }
.ch-key-input-wrap { margin-bottom: 4px; }
.ch-wrong-key { color: var(--danger, #ef4444); font-weight: 500; }

/* Add channel form (#759) */
.ch-add-form { margin: 0; }
.ch-add-label { display: block; font-weight: 600; font-size: 13px; color: var(--text); margin-bottom: 4px; }
.ch-key-input, .ch-add-btn { height: 32px; box-sizing: border-box; }
.ch-add-row { display: flex; align-items: stretch; }
.ch-add-btn {
  width: 32px; height: 32px; flex-shrink: 0;
  border: 1px solid var(--accent, #3b82f6); border-left: none;
  border-radius: 0 6px 6px 0;
  background: var(--accent, #3b82f6); color: #fff;
  font-size: 18px; font-weight: 700; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.ch-add-btn:hover { opacity: 0.85; }
.ch-add-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; line-height: 1.3; }
.ch-add-status { font-size: 12px; margin-top: 4px; padding: 4px 6px; border-radius: 4px; }
.ch-analytics-link {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 4px 8px;
  font-size: 14px;
  text-decoration: none;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  flex: 0 0 auto;
}
.ch-analytics-link:hover { color: var(--link-color); }
.ch-add-status--loading { color: var(--text-muted); }
.ch-add-status--success { color: var(--success, #22c55e); }
.ch-add-status--warn { color: var(--warning, #eab308); }
.ch-add-status--error { color: var(--danger, #ef4444); }

/* Touch-friendly tappable elements */
.ch-tappable {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0,0,0,.08);
  user-select: none; -webkit-user-select: none;
}
.ch-msg-sender.ch-tappable {
  display: inline-block;
  padding: 4px 6px 4px 0;
  margin: -4px 0 0 -0px;
  min-height: 32px;
  line-height: 24px;
  border-radius: 4px;
}
.ch-msg-sender.ch-tappable:active { opacity: 0.6; }
@media (max-width: 640px) {
  .ch-msg-sender.ch-tappable {
    padding: 6px 10px 6px 0;
    min-height: 36px;
    font-size: 14px;
  }
  .ch-avatar.ch-tappable { min-width: 48px; min-height: 48px; width: 48px; height: 48px; }
  /* #1253: trim .badge-iata h-padding + margin-left on narrow viewports so
   * the observer cell + IATA pill fits within a 375px viewport. Without this
   * the badge right edge overflows by ~1.25px at 375px (same class of fix
   * as #1250/#1251 VCR LCD-clip). Badge stays fully visible — only padding
   * and side margin shrink; font-size, colors (via vars) unchanged. */
  .badge-iata { padding: 1px 3px; margin-left: 2px; }
}

/* Full-screen node detail */
.node-fullscreen { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.node-full-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: var(--card-bg); min-height: 48px;
}
.node-back-btn { display: flex !important; }
.node-full-title { font-weight: 700; font-size: 17px; flex: 1; }
.node-full-body { flex: 1; overflow-y: auto; padding: 16px; }
.node-full-card {
  background: var(--card-bg); border-radius: 8px; padding: 16px;
  margin-bottom: 12px; border: 1px solid var(--border);
}
.node-full-card h4 { margin: 0 0 10px; font-size: 14px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
/* #254: the Affinity Debug heading is a disclosure button. It keeps the h4
 * look and spans the heading, so the whole row toggles as before. */
.node-full-card h4 .affinity-debug-toggle {
  display: flex; align-items: center; gap: 6px; width: 100%;
  margin: 0; padding: 0; border: 0; background: none; cursor: pointer;
  font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit; text-align: start;
}
@media (pointer: coarse) { .node-full-card h4 .affinity-debug-toggle { min-height: 48px; } }
.node-activity-list { display: flex; flex-direction: column; gap: 6px; }
.node-activity-item {
  display: flex; gap: 8px; font-size: 13px; padding: 6px 0;
  border-bottom: 1px solid var(--border); align-items: baseline;
}
.node-activity-item:last-child { border-bottom: none; }
.node-activity-time { color: var(--text-muted); white-space: nowrap; min-width: 70px; font-size: 12px; }

/* #2073 Recent Adverts (node-adverts.js): per-route counts, tabs, route badge.
   Colors reuse the status tokens; badge text stays --text for contrast. */
.node-adverts-counts { display: flex; flex-wrap: wrap; gap: 2px 16px; margin: 0 0 8px; font-size: 12px; color: var(--text-muted); }
.node-adverts-count-row strong { margin-right: 4px; color: var(--text); }
.node-adverts-note { margin: 0 0 8px; font-size: 12px; }
.node-adverts-intervals { display: flex; flex-direction: column; gap: 2px; margin: 0 0 8px; font-size: 12px; color: var(--text-muted); cursor: help; }
.node-adverts-interval-row strong { margin-right: 4px; color: var(--text); }
.node-adverts-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 8px; }
.node-adverts-tabs .tab-btn { padding: 4px 10px; }
.node-adverts-empty { font-size: 13px; }
.advert-timeline .node-adverts-empty { padding: 8px; }
.advert-route-badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 0 6px;
  border: 1px solid var(--border); border-radius: 4px;
  font-size: 11px; font-weight: var(--fw-semibold); color: var(--text); white-space: nowrap;
}
.advert-route-badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); }
.advert-route-badge[data-route-class="flood"]::before { background: var(--status-info); }
.advert-route-badge[data-route-class="zero_hop"]::before { background: var(--status-green); }
.advert-route-badge[data-route-class="mixed"]::before { background: var(--status-purple); }
/* Per-advert hash size when a node's adverts disagree (was inline colors). */
.advert-hs-badge { font-size: 9px; font-family: var(--mono); color: var(--text-on-accent); background: var(--palette-green-600); }
.advert-hs-badge.hs-1 { background: var(--status-orange); }
.advert-hs-badge.hs-2 { background: var(--palette-green-300); color: var(--palette-gray-900); }

/* Analytics page */
.analytics-page { padding: 16px 24px; max-width: 1600px; margin: 0 auto; }
.analytics-header { margin-bottom: 20px; }
.analytics-header h2 { margin: 0 0 4px; }
.analytics-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.analytics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 16px; margin-bottom: 16px; }
.analytics-grid .analytics-card { margin-bottom: 0; }
.analytics-full { grid-column: 1 / -1; }
.analytics-card h3 { margin: 0 0 8px; font-size: 15px; }
.analytics-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.analytics-table th { text-align: left; padding: 8px; border-bottom: 2px solid var(--border); font-size: 12px; text-transform: uppercase; color: var(--text-muted); }
.analytics-table th.sortable { cursor: pointer; user-select: none; }
.analytics-table th.sortable:hover { color: var(--link-color); }
.analytics-table th.sort-active { color: var(--link-color); }
.analytics-table th .sort-arrow { font-size: 10px; margin-left: 4px; opacity: 0.7; }
.analytics-table td { padding: 8px; border-bottom: 1px solid var(--border); }
.analytics-table .ch-section-row { background: var(--card-bg); }
.analytics-table .ch-section-row td.ch-section-header {
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 10px 8px 6px;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
}
.analytics-table .ch-section-row:hover { background: var(--card-bg); cursor: default; }
.hash-bars { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.hash-bar-row { display: flex; align-items: center; gap: 12px; }
.hash-bar-label { min-width: 160px; font-size: 13px; }
.hash-bar-track { flex: 1; height: 24px; background: var(--border); border-radius: 4px; overflow: hidden; }
.hash-bar-fill { height: 100%; border-radius: 4px; transition: width .3s; }
.hash-cell.hash-active:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.hash-cell.hash-selected { outline: 2px solid var(--accent); outline-offset: -2px; box-shadow: 0 0 6px var(--accent); }
.hash-cell-empty  { background: var(--card-bg); color: var(--text-muted); font-size: 12px; font-weight: 500; }
/* #1668-M4 r1: hash-cell semantic bgs carve out darker shades than the
   --status-green / --status-yellow tokens so #fff text passes WCAG AA.
   The status tokens themselves stay light (operator semantic "good"/"warn"
   against page bg). Cell bgs need their own contrast budget vs #fff fg.
   taken:    #22c55e (2.28:1) -> #15803d (green-700, 5.02:1)
   possible: #eab308 (1.92:1) -> #854d0e (yellow-800, 6.85:1)
   See test-issue-1668-m4-per-route.js hash-cell contrast block. */
.hash-cell-taken    { background: #15803d; color: #fff; font-size: 12px; font-weight: 700; }
.hash-cell-possible { background: #854d0e; color: #fff; font-size: 12px; font-weight: 700; }
.hash-cell-collision { color: #fff; font-size: 12px; font-weight: 700; }
/* #1668-M4 — per-route carve-outs.
   Hash-grid cells use a SEMANTIC bg palette (green=taken, yellow=possible,
   red-orange=collision). M2/M3 didn't fix these because the BG is the
   encoding. We don't flatten it — instead we bump the TEXT weight to 600+
   so 12px white-on-color clears AA (was 11px/400, M1 ~302 violations). */
.hash-cell { font-size: 12px; font-weight: 600; }
/* #1473 — First-byte 0x00 / 0xFF pubkeys are avoided by the MeshCore
   firmware keygen convention (NOT a protocol-level rejection):
   https://github.com/meshcore-dev/MeshCore/blob/8ede7641/examples/simple_repeater/main.cpp#L83
   Visually grey + strike, kill pointer events so the matrix click handler
   skips them. Applied by public/prefix-reserved.js → markReservedCells(). */
.hash-cell.prefix-reserved,
.prefix-reserved {
  background: repeating-linear-gradient(
    45deg,
    var(--card-bg),
    var(--card-bg) 4px,
    var(--border) 4px,
    var(--border) 8px
  ) !important;
  color: var(--text-muted) !important;
  text-decoration: line-through;
  opacity: 0.6;
  cursor: not-allowed !important;
  pointer-events: none;
}
.hash-matrix-tooltip {
  position: fixed; z-index: var(--z-tooltip); background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.25); padding: 8px 12px;
  font-size: 12px; min-width: 160px; max-width: 260px; pointer-events: none;
}
.hash-matrix-tooltip-hex { font-family: var(--mono); font-size: 13px; font-weight: 700; margin-bottom: 4px; color: var(--link-color); }
.hash-matrix-tooltip-status { color: var(--text-muted); font-size: 11px; }
.hash-matrix-tooltip-nodes { margin-top: 6px; display: flex; flex-direction: column; gap: 2px; }
.hash-byte-selector { display: flex; gap: 4px; }
.hash-byte-btn { padding: 4px 12px; border-radius: 20px; border: 1px solid var(--border); background: var(--card-bg); color: var(--text-muted); font-size: 12px; font-weight: 600; cursor: pointer; transition: background .15s, color .15s; }
.hash-byte-btn:hover { background: var(--border); color: var(--text); }
.hash-byte-btn.active { background: var(--accent-strong); color: var(--text-on-accent); border-color: var(--accent-strong); }
.hash-bar-value { min-width: 120px; text-align: right; font-size: 13px; font-weight: 600; }
/* #1668 M5 — was translucent-fg-on-tinted-bg (e.g. #ef4444 on #ef444420
   stacked over surface ≈ 2-4:1, BLOCKER). Solid -700 hue with white text
   preserves semantic encoding (red/green/blue) AND clears AA both themes:
   #fff/#b91c1c=6.47, #fff/#15803d=5.02, #fff/#1d4ed8=6.70. */
.badge-hash-1 { background: var(--palette-red-700, #b91c1c); color: var(--palette-gray-50, #f9fafb); }
.badge-hash-2 { background: var(--palette-green-700, #15803d); color: var(--palette-gray-50, #f9fafb); }
.badge-success { background: var(--palette-green-700, #15803d); color: var(--palette-gray-50, #f9fafb); }
.badge-danger { background: var(--palette-red-700, #b91c1c); color: var(--palette-gray-50, #f9fafb); }
.badge-hash-3 { background: var(--palette-blue-700, #1d4ed8); color: var(--palette-gray-50, #f9fafb); }
.timeline-legend { display: flex; gap: 16px; justify-content: center; margin-top: 8px; font-size: 12px; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.timeline-chart svg { display: block; }
@media (max-width: 640px) {
  .hash-bar-label { min-width: 80px; }
  .hash-bar-value { min-width: 80px; font-size: 12px; }
  .hash-bar-label span { display: none; }
}
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: var(--hover-bg, rgba(0,0,0,.04)); }
.analytics-link { color: var(--link-color); text-decoration: none; font-weight: 600; }
.analytics-link:hover { text-decoration: underline; }

/* Analytics v2 */
.analytics-tabs { display: flex; gap: 4px; margin-top: 12px; flex-wrap: wrap; }
.tab-btn { padding: 6px 14px; border: 1px solid var(--border); border-radius: 6px; background: var(--card-bg); color: var(--text); cursor: pointer; font-size: 13px; font-weight: var(--fw-medium); transition: all .15s; } /* #1668 M3 — 13px + 500 floor */
.tab-btn:hover { background: var(--hover-bg, rgba(0,0,0,.04)); }
/* #1668 M2 — active tab was #fff on --accent (2.75:1 BLOCKER). */
.tab-btn.active { background: var(--accent-strong); color: var(--text-on-accent); border-color: var(--accent-strong); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 240px)); gap: 12px; margin-bottom: 16px; }
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; padding: 14px; text-align: center; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--text); }
.stat-label { font-size: 12px; font-weight: var(--fw-medium); color: var(--text-muted); margin-top: 2px; } /* #1668 M3 — added 500 weight */
.stat-detail { font-size: 12px; font-weight: var(--fw-medium); color: var(--text-muted); margin-top: 2px; } /* #1668 M3 r1 — was 11px/400, below chip floor (adv #3) */
.stat-spark { margin-top: 6px; display: flex; justify-content: center; }
/* #1058 — Analytics rows: fluid + auto-stacking via CSS Grid `auto-fit`.
   Cards stack automatically when the row can't fit two columns at the
   400px-floor minimum (avoids cramped charts), and otherwise lay out
   side-by-side. Replaces the prior `flex` + `@media (max-width:640px)`
   approach so behavior is driven by available width — not viewport —
   matching #1050's fluid-everywhere mandate. `min(100%, 400px)` keeps
   the track from overflowing at very narrow widths. */
.analytics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.rf-stats { display: flex; gap: 16px; flex-wrap: wrap; padding-top: 8px; font-size: 13px; }
.payload-bars { display: flex; flex-direction: column; gap: 6px; }
.payload-bar-row { display: flex; align-items: center; gap: 8px; }
.payload-bar-label { min-width: 100px; font-size: 12px; font-weight: var(--fw-medium); display: flex; align-items: center; gap: 4px; } /* #1668 M3 — added 500 weight */
.payload-bar-value { min-width: 100px; text-align: right; font-size: 12px; font-weight: var(--fw-medium); } /* #1668 M3 r1 — match .payload-bar-label weight (adv #1) */
.repeater-list { display: flex; flex-direction: column; gap: 4px; }
.repeater-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.repeater-name { min-width: 140px; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.repeater-bar { flex: 1; }
.repeater-count { min-width: 60px; text-align: right; font-size: 12px; font-weight: 600; }
.reach-rings { display: flex; flex-direction: column; gap: 6px; }
.reach-ring { display: flex; align-items: baseline; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.reach-hop { min-width: 70px; font-weight: 700; font-size: 13px; }
.reach-nodes { flex: 1; font-size: 12px; line-height: 1.6; }
.reach-count { min-width: 70px; text-align: right; font-size: 12px; color: var(--text-muted); }
@media (max-width: 640px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .repeater-name { min-width: 80px; }
  .reach-ring { flex-wrap: wrap; }
  .analytics-page { padding: 12px; }
  .analytics-grid { grid-template-columns: 1fr; }
}
.observer-selector { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }
.node-qr { text-align: center; margin-top: 8px; }
.node-qr svg { max-width: 100px; height: auto; border-radius: 4px; }
[data-theme="dark"] .node-qr svg rect[fill="#ffffff"] { fill: var(--card-bg); }
[data-theme="dark"] .node-qr svg rect[fill="#000000"] { fill: var(--text); }
.node-map-qr-wrap { position: relative; }
/* #752 — bottom: clears the inset's map credit (the control is in the same
   corner and paints above this overlay, z-index 800 against 400). */
.node-map-qr-overlay { position: absolute; bottom: var(--mc-credit-compact-clearance); right: 8px; z-index: 400; background: rgba(255,255,255,0.5); border-radius: 4px; padding: 4px; line-height: 0; margin: 0; text-align: center; }
.node-map-qr-overlay svg { max-width: 56px !important; height: auto; display: block; margin: 0; }
[data-theme="dark"] .node-map-qr-overlay { background: rgba(255,255,255,0.4); }

/* Replay on Live Map button in packet detail */
.detail-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.replay-live-btn {
  padding: 5px 12px;
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.3);
  color: #c084fc;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.replay-live-btn:hover { background: rgba(168, 85, 247, 0.3); }

/* Node filter dropdown */
.node-filter-wrap { display: inline-block; }
.node-filter-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface-1, #1e293b);
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  border-radius: 6px;
  max-height: 200px;
  overflow-y: auto;
  z-index: var(--z-dropdown);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.node-filter-dropdown.hidden { display: none; }
.node-filter-option {
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.1s;
}
.node-filter-option:hover { background: var(--surface-2, rgba(255,255,255,0.08)); }
/* .node-filter-option.node-filter-active — #1719 round-1 polish: bg/color
   consolidated into the .btn-active-accent rule. */

/* Hide low-value columns on mobile */
@media (max-width: 640px) {
  .col-region, .col-rpt, .col-size, .col-hashsize, .col-pubkey, .col-scope { display: none; }
}

/* Clickable hop links */
.hop-link {
  color: var(--link-color, #3b82f6);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s;
}
.hop-link:hover { color: var(--accent-hover, #60a5fa); text-decoration: underline; }

/* Detail map link */
.detail-map-link {
  padding: 5px 12px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.25);
  color: #fbbf24;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
}
.detail-map-link:hover { background: rgba(245, 158, 11, 0.25); }

/* Anchors lack the native vertical content centering of adjacent buttons. */
.detail-actions > a.detail-map-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.copy-link-btn {
  padding: 5px 12px;
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  color: var(--text);
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.copy-link-btn:hover { background: var(--accent-border, rgba(59, 130, 246, 0.25)); }

/* Route tooltip on map */
.route-tooltip {
  background: rgba(0,0,0,0.8) !important;
  color: #fbbf24 !important;
  border: 1px solid rgba(245,158,11,0.3) !important;
  font-weight: 600;
  font-size: 0.75rem;
}

/* Ambiguous hop indicator */
.hop-ambiguous { border-bottom: 1px dashed var(--status-yellow, #f59e0b); }
/* #598 — unlisted hop: no known node with its prefix fits that point in the path */
.hop-unlisted { font-family: var(--mono); color: var(--text-muted); }
.hop-nogps { font-size: 0.85em; color: var(--text-muted); }
.hop-warn { font-size: 0.7em; margin-left: 2px; vertical-align: super; color: var(--status-yellow, #f59e0b); }
.hop-conflict-btn { background: var(--status-yellow, #f59e0b); color: #000; border: none; border-radius: 4px; font-size: 11px;
  font-weight: 700; padding: 1px 5px; cursor: pointer; vertical-align: middle; margin-left: 3px; line-height: 1.2; }
.hop-conflict-btn:hover { background: var(--status-yellow, #d97706); filter: brightness(0.85); }

/* #165 (port of upstream 2099) — a badge is a sibling of its pill, so
   "A [8] -> B [6]" gave no clue which name the 8 belonged to. The group ties the pair together and keeps the
   separator outside it. Only hops that carry a badge are wrapped. */
.hop-group { display: inline-flex; align-items: center; white-space: nowrap; }
.hop-group .hop-conflict-btn,
.hop-group .hop-unreliable-btn { margin-left: 2px; }

/* One indicator for a whole path, used by the packets list. The detail pane
   keeps a badge per hop, because that is where the candidates get read. It
   leads the path so a clipped (overflowing) path cell cannot hide it. */
.hop-path-warn { display: inline-flex; align-items: center; gap: 2px; margin-right: 4px; flex: 0 0 auto;
  background: var(--status-yellow); color: var(--palette-gray-900); border-radius: 4px;
  font-size: 11px; font-weight: 700; padding: 1px 5px; line-height: 1.2;
  vertical-align: middle; white-space: nowrap; }
.hop-conflict-popover { position: absolute; z-index: var(--z-popover); background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.25); width: 260px; max-height: 300px; overflow-y: auto; }
.hop-conflict-header { padding: 10px 12px; font-size: 12px; font-weight: 700; border-bottom: 1px solid var(--border);
  color: var(--text-muted); }
.hop-conflict-list { padding: 4px 0; }
.hop-conflict-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; text-decoration: none;
  color: var(--text); font-size: 13px; border-bottom: 1px solid var(--border); }
.hop-conflict-item:last-child { border-bottom: none; }
.hop-conflict-item:hover { background: var(--hover-bg); }
.hop-conflict-name { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hop-conflict-dist { font-size: 11px; color: var(--text-muted); font-family: var(--mono); white-space: nowrap; }
.hop-conflict-pk { font-size: 10px; color: var(--text-muted); font-family: var(--mono); }
/* #1668 M5 — was opacity:0.85; dropped fg #f9fafb on accent-strong
   #2563eb to 4.45:1 (BLOCKER). The adjacent .hop-unreliable-btn (status
   yellow warning glyph) is the redundant non-color signal that this hop
   is dubious — opacity haze was over-encoding it. Remove the haze; the
   warning icon stays as the visual marker. */
.hop-unreliable { font-style: italic; }
.hop-unreliable-btn { background: none; border: none; color: var(--status-yellow, #f59e0b); font-size: 13px;
  cursor: help; vertical-align: middle; margin-left: 2px; padding: 0 2px; line-height: 1; }
.hop-global-fallback { border-bottom: 1px dashed var(--status-red); }
.hop-current {
  display: inline-block;
  padding: 0 4px;
  /* box-shadow, not outline: outline is this app's focus affordance (see
     "Focus Indicators" above), so an outlined-but-unfocused hop reads as
     focused, and a genuinely focused one would differ only in ring width and
     a near-identical blue. A shadow ring draws the same box while leaving
     :focus-visible unambiguous, and — like outline — it does not disturb the
     shared renderer's dashed ambiguity border. */
  box-shadow: 0 0 0 1px var(--link-color);
  border-radius: 4px;
  font-weight: 700 !important;
  color: var(--link-color) !important;
}

/* Self-loop subpath rows */
.subpath-selfloop { opacity: 0.6; }
.subpath-selfloop td:first-child::after { content: ''; }

/* Hop prefix in subpath routes */
.hop-prefix { color: var(--text-muted); font-size: 0.8em; }

/* Subpath split layout */
.subpath-layout { display: flex; gap: 0; flex: 1; min-height: 0; overflow: auto; position: relative; }
.subpath-list { flex: 1; overflow-y: auto; padding: 16px; min-width: 0; }
.subpath-detail { width: 420px; min-width: 360px; max-width: 50vw; border-left: 1px solid var(--border, #e5e7eb); overflow-y: auto; padding: 16px; transition: width 0.2s; }
.subpath-detail.collapsed { width: 0; min-width: 0; padding: 0; overflow: hidden; border: none; }
.subpath-detail-inner h4 { margin: 0 0 4px; word-break: break-word; }
.subpath-meta { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; color: var(--text-muted); font-size: 0.9em; }
.subpath-section { margin: 16px 0; }
.subpath-section h5 { margin: 0 0 6px; font-size: 0.9em; }
/* #1705 — was background:var(--accent) (#4a9eff) + color:#fff = 2.75:1, and
   the muted hop-prefix line at rgba(255,255,255,0.6) composited over that
   accent to 1.87:1 (hard BLOCKER). Pin the row to --accent-strong
   (#2563eb, palette-blue-600) with --text-on-accent (#f9fafb): primary
   text 4.95:1, hop-prefix at --text-on-accent (full alpha) on the same
   bg = 4.95:1 — clears WCAG AA (≥4.5:1). The hop-prefix used to be
   visually "muted" via 60% alpha white; we drop the alpha-muting because
   no other token in either theme composites to ≥4.5:1 on this background.
   Trade-off accepted: the prefix and primary line are now equal-weight
   visually — the previous secondary styling was itself the source of the
   1.87:1 BLOCKER, so visual hierarchy here is recovered via type/weight,
   not color.
   #1719 polish r1: !important on color also, to consolidate with
   .btn-active-accent override pattern. */
.subpath-selected { background: var(--accent-strong) !important; color: var(--text-on-accent) !important; }
.subpath-selected .hop-prefix { color: var(--text-on-accent); }
tr[data-hops]:hover { background: rgba(59,130,246,0.1); }

/* Hour distribution chart */
.hour-chart { display: flex; align-items: flex-end; gap: 2px; height: 60px; }
.hour-bar { flex: 1; background: var(--accent, #3b82f6); border-radius: 2px 2px 0 0; min-width: 4px; }
.hour-labels { display: flex; justify-content: space-between; font-size: 0.7em; color: var(--text-muted); }

/* Parent paths */
.parent-path { padding: 3px 0; border-bottom: 1px solid var(--border, #e5e7eb); }

@media (max-width: 768px) {
  .subpath-layout { flex-direction: column; height: auto; }
  .subpath-detail { width: 100%; border-left: none; border-top: 1px solid var(--border, #e5e7eb); }
}

@media (max-width: 480px) {
  .subpath-detail { min-width: 100%; width: 100%; max-width: 100%; }
  .subpath-layout { flex-direction: column; }

  /* #1415 mobile chrome compaction — keep packets pre-table chrome to ≤2 rows.
   * Hide BYOP (operator request) to reclaim ~70px from the page-header row,
   * shrink the page-header h2, and zero its bottom margin. The filter bar
   * already collapses behind a "Filters ▾" toggle (see existing block above). */
  .page-header [data-action="pkt-byop"] { display: none; }
  .page-header { margin-bottom: 6px; }
  .page-header h2 { font-size: 15px; }
  .data-table td, .data-table th { padding: 6px 4px; }

  /* #1458 P0-C — collapse the always-on filter expression input on small mobile.
   * Reveals when the sibling .filter-bar has .filters-expanded (set by the
   * existing "Filters ▾" toggle, so one tap reveals BOTH chrome rows). */
  .pkt-filter-expr { display: none; }
  #pktLeft:has(.filter-bar.filters-expanded) .pkt-filter-expr { display: block; }

  /* #1458 P0-A — semantic-first detail title: keep it dense, single-row when
   * possible, badges + summary share a line. */
  .detail-title { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 15px; }
  .detail-srcdst { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
}

/* #1458 P0-B — raw-bytes disclosure styling (applies everywhere). */
.detail-technical { margin-top: 12px; }
.detail-technical > summary {
  cursor: pointer; padding: 6px 0; font-weight: 600; color: var(--text-muted);
  user-select: none;
}
.detail-technical[open] > summary { color: var(--text); }

/* Legend swatches */
.legend-swatch { display: inline-block; width: 12px; height: 12px; border: 1px solid var(--border); vertical-align: middle; }

/* Subpath jump nav */
.subpath-jump-nav { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; font-size: 0.9em; flex-wrap: wrap; }
.subpath-jump-nav span { color: var(--text-muted); }
.subpath-jump-nav a { padding: 4px 12px; border-radius: 4px; text-decoration: none; font-size: 0.85em; }
.subpath-jump-nav a:hover { opacity: 0.8; }

/* Route patterns table breathing room */
.subpath-list .analytics-table td:nth-child(2) { white-space: normal; word-break: break-word; max-width: 50vw; }
.subpath-list .analytics-table { table-layout: auto; }
.subpath-list h4 { margin-top: 24px; }

/* #70 — BYOP textarea larger on mobile */
@media (max-width: 640px) {
  .byop-input { min-height: 120px; }
}

/* #71 — Column visibility toggle */
.col-toggle-wrap { position: relative; display: inline-block; }
.col-toggle-btn { font-size: 13px; padding: 6px 10px; cursor: pointer; background: var(--input-bg); border: 1px solid var(--border); border-radius: 6px; color: var(--text); height: 34px; box-sizing: border-box; line-height: 1; }
.col-toggle-menu { display: none; position: absolute; top: 100%; left: 0; z-index: var(--z-dropdown); background: var(--card-bg); border: 1px solid var(--border); border-radius: 6px; padding: 6px 0; min-width: 150px; box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.col-toggle-menu.open { display: block; }
.col-toggle-menu label { display: flex; align-items: center; gap: 6px; padding: 4px 12px; font-size: .82rem; cursor: pointer; color: var(--text); }
.col-toggle-menu label input[type="checkbox"] { width: 14px; height: 14px; margin: 0; flex-shrink: 0; }
.col-toggle-menu label:hover { background: var(--row-hover); }

/* Column hide classes */
.hide-col-region .col-region,
.hide-col-time .col-time,
.hide-col-hash .col-hash,
.hide-col-size .col-size,
.hide-col-type .col-type,
.hide-col-scope .col-scope,
.hide-col-observer .col-observer,
.hide-col-path .col-path,
.hide-col-rpt .col-rpt,
.hide-col-hashsize .col-hashsize,
.hide-col-details .col-details { display: none; }

/* === Home page fixes === */

/* #25 — Widen home page content cap from 720px to 1200px */
.home-stats,
.home-health,
.home-journey,
.home-checklist,
.home-footer,
.home-favorites { max-width: 1200px; }

/* #40, #235 — suggest-claim touch target at the 48px house minimum */
.suggest-claim { min-height: 48px; min-width: 48px; padding: 10px 14px; display: inline-flex; align-items: center; justify-content: center; }

/* #41 — Lower My Nodes grid minimum to prevent overflow on 375-640px */
.my-nodes-grid { max-width: 1200px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

/* #42 — Stats cards: use grid with max-width per card on wide screens */
.home-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 200px)); justify-content: center; }

/* #44 — Namespaced home sparkline classes (avoid collision with observers .spark-bar) */
.home-spark-label { font-size: .65rem; color: var(--text-muted); margin-bottom: 4px; }
.home-spark-bars { display: flex; align-items: flex-end; gap: 2px; height: 28px; }
.home-spark-bar { flex: 1; background: var(--accent); border-radius: 1px; min-width: 0; }

/* === Bug fixes: #17 #20 #21 #69 === */

/* #17 — Hash matrix mobile overflow */
.hash-matrix-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
@media (max-width: 640px) {
  .hash-matrix-table td { width: 24px !important; height: 24px !important; font-size: 0.7em !important; }
  .hash-matrix-table td .hash-cell { padding: 0; }
}

/* #20 — Observers table horizontal scroll on mobile
 * #1056 — fluid columns + +N hidden pill removes the need for a forced
 * min-width; keep the wrapper for backward-compat selectors but let the
 * inner table flex with the viewport. */
.obs-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.obs-table-scroll .obs-table { min-width: 0; }

/* #245 M2 — Analytics → Advert Intervals (advert-interval-analytics.js) */
.ai-note { margin: 0 0 12px; font-size: 13px; }
.ai-dist { display: flex; flex-direction: column; gap: 6px; }
.ai-dist-row { display: grid; grid-template-columns: minmax(80px, max-content) 1fr minmax(32px, max-content); align-items: center; gap: 8px; font-size: 13px; }
.ai-dist-bar { display: block; height: 10px; border-radius: 5px; overflow: hidden; background: var(--border); }
.ai-dist-fill { display: block; height: 100%; background: var(--accent); }
.ai-dist-count { text-align: right; font-weight: var(--fw-medium); }
.ai-class-counts { margin-top: 10px; font-size: 12px; }
.ai-rearm-row { font-size: 13px; margin: 4px 0; }
/* end #245 M2 */

/* #206 — Analytics/Compare tables scroll wrappers on mobile */
.analytics-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.analytics-table-scroll .analytics-table,
.analytics-table-scroll .analytics-peer-table,
.analytics-table-scroll .compare-table { min-width: 480px; }
/* Busiest Repeaters: six columns that fit a phone, names wrap anywhere. */
.analytics-table-scroll .busiest-repeaters-table { min-width: 0; }
/* #716 — "24h"/"1h" became "Relayed 24h"/"Relayed 1h" so the columns say
 * what they count without relying on the group header above them; tighter
 * horizontal padding on a phone keeps the six columns fitting as before. */
@media (max-width: 480px) {
  .busiest-repeaters-table th, .busiest-repeaters-table td { padding: 8px 4px; }
}
@media (max-width: 640px) {
  .spark-bar { min-width: 60px; width: auto; }
}

/* #21 — Chat message bubble max-width */
.ch-msg-bubble { max-width: 720px; }

/* #69 — Touch-friendly resize handle */
@media (pointer: coarse) {
  .panel-resize-handle { width: 12px !important; }
}
/* #21 — max-width applied via .ch-msg-bubble rule above */

/* === Bug fixes: #16 collapsible controls, #53 detail map height === */
.map-controls-toggle {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1001;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid var(--border, #333);
  background: var(--card-bg, #1e1e1e);
  color: var(--text, #fff);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.map-controls.collapsed {
  display: none;
}
.node-detail-map {
  height: 280px;
  min-height: 200px;
}
.node-top-row { display: flex; gap: 16px; margin-bottom: 12px; }
.node-top-row .node-map-wrap { flex: 3; min-height: 200px; border-radius: 8px; overflow: hidden; }
.node-top-row .node-map-wrap .node-detail-map { height: 100%; }
.node-top-row .node-qr-wrap { flex: 1; align-self: flex-start; min-width: 120px; max-width: 160px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.node-top-row .node-qr-wrap .node-qr { margin-top: 0; }
.node-qr-wrap--full { max-width: 240px; margin: 0 auto; }
.node-stats-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; overflow: visible; margin-bottom: 12px; }
.node-stats-table td { padding: 6px 12px; border-bottom: 1px solid var(--border); }
.node-stats-table tr:last-child td { border-bottom: none; }
/* #382: no overflow clipping (the packet-count help tooltip extends past the
   table), so stripes and hovers are painted on the cells, which carry the
   rounded corners themselves (border width 1px inside an 8px radius). */
.node-stats-table tr:nth-child(even) td { background: var(--row-stripe); }
.node-stats-table tr:first-child td:first-child { border-top-left-radius: 7px; }
.node-stats-table tr:first-child td:last-child { border-top-right-radius: 7px; }
.node-stats-table tr:last-child td:first-child { border-bottom-left-radius: 7px; }
.node-stats-table tr:last-child td:last-child { border-bottom-right-radius: 7px; }
.node-stats-table td:first-child { font-weight: 600; color: var(--text-muted); width: 40%; white-space: nowrap; }
.node-stats-table td:last-child { font-weight: 500; }
@media (max-width: 768px) {
  .node-top-row { flex-direction: column; }
  .node-top-row .node-qr-wrap { min-height: auto; }
}
@media (max-width: 640px) {
  .node-detail-map {
    height: 200px;
    min-height: 160px;
  }
  /* #1243 — On mobile, mirror the desktop split-pane behavior used by the
     compact node detail (.node-map-qr-wrap): overlay the QR on the map
     instead of stacking a 250px-tall QR panel below it. Desktop (≥768px)
     keeps the side-by-side flex layout untouched. */
  .node-top-row { position: relative; }
  .node-top-row .node-map-wrap { flex: 1 1 100%; }
  .node-top-row .node-qr-wrap {
    position: absolute;
    /* #752 — above the map credit, as .node-map-qr-overlay is. */
    bottom: var(--mc-credit-compact-clearance);
    right: 8px;
    z-index: 400;
    flex: 0 0 auto;
    min-width: 0;
    max-width: 96px;
    padding: 4px;
    background: var(--card-bg-translucent, rgba(255, 255, 255, 0.85));
    border: 1px solid var(--border);
    border-radius: 4px;
    line-height: 0;
    margin: 0;
  }
  .node-top-row .node-qr-wrap .node-qr svg { max-width: 72px; height: auto; }
  /* Hide the redundant pubkey caption inside the overlay QR — it's already
     shown in the card above and would push the overlay too large. */
  .node-top-row .node-qr-wrap .mono { display: none; }
  [data-theme="dark"] .node-top-row .node-qr-wrap {
    background: var(--card-bg-translucent-dark, rgba(255, 255, 255, 0.4));
  }
}

.detail-back-btn {
  background: none;
  border: 1px solid var(--border, #333);
  color: var(--text, #fff);
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
}

.meshcore-marker { background: none !important; border: none !important; }
.marker-stale { opacity: 0.7; filter: grayscale(90%) brightness(0.8); }
.last-seen-active { color: var(--status-green); }
.last-seen-stale { color: var(--text-muted); }

/* === Node Analytics === */
.analytics-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.analytics-stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; text-align: center; }
.analytics-stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 2px; }
.analytics-stat-value { font-size: 20px; font-weight: 700; }
.analytics-stat-desc { font-size: 10px; color: var(--text-muted); margin-top: 2px; font-style: italic; }
.analytics-charts {
  /* #1058 — fluid + auto-stacking layout. The grid sizes from its own
     available width (NOT the viewport), so a narrow side-pane on a wide
     screen still stacks. `auto-fit` collapses empty tracks; `minmax()`
     guarantees a minimum readable column width before wrapping. The
     `container-type: inline-size` opts in to container queries so
     descendants (or future tweaks) can size against this element's
     own width rather than the viewport. Uses #1054 spacing tokens. */
  container-type: inline-size;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}
.analytics-chart-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 6px; padding: var(--space-sm); min-width: 0; }
.analytics-chart-card.full { grid-column: 1 / -1; }
/* Constrain chart media inside the card (svg/canvas at any depth). The
   `.analytics-chart-card svg, .analytics-chart-card canvas` descendant
   selector is robust to wrapper elements (legends, tooltips, axis
   groups) being added between the card and the chart media. */
.analytics-chart-card svg,
.analytics-chart-card canvas { max-width: 100%; height: auto; display: block; }
/* #562 — the battery badge icon keeps the shared icon size; the chart-media
   rule above (height:auto, display:block) must not stretch it. Scoped to the
   badge so chart SVG responsiveness is unchanged. */
.analytics-chart-card .battery-status-badge .ph-icon { display: inline-block; width: 16px; height: 16px; max-width: none; }
.analytics-chart-card h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 4px; }
.analytics-chart-desc { font-size: 10px; color: var(--text-muted); margin-bottom: 8px; font-style: italic; }
.analytics-heatmap { display: grid; grid-template-columns: 40px repeat(24, 1fr); gap: 2px; }
.analytics-heatmap-cell { aspect-ratio: 1; border-radius: 2px; cursor: default; }
.analytics-heatmap-label { font-size: 10px; color: var(--text-muted); display: flex; align-items: center; }
.analytics-time-range { display: flex; gap: 8px; margin-bottom: 16px; }
.analytics-time-range button { padding: 4px 12px; border-radius: 4px; border: 1px solid var(--border); background: var(--card-bg); color: var(--text); cursor: pointer; font-size: 12px; }
/* .analytics-time-range button.active — #1719 round-1 polish: bg/color
   consolidated into the .btn-active-accent rule. */
.analytics-peer-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.analytics-peer-table th { text-align: left; padding: 6px 8px; border-bottom: 2px solid var(--border); color: var(--text-muted); font-size: 11px; text-transform: uppercase; }
.analytics-peer-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.analytics-peer-table tr:hover td { background: var(--card-bg); }
@media (max-width: 768px) { .analytics-stats { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .analytics-stats { grid-template-columns: 1fr; } }

/* Claimed (My Mesh) node rows */
.claimed-row { background: color-mix(in srgb, var(--accent) 8%, transparent) !important; border-left: 3px solid var(--accent); }
.claimed-row:hover { background: color-mix(in srgb, var(--accent) 14%, transparent) !important; }
.claimed-badge { color: var(--accent); font-size: 13px; margin-right: 2px; }

/* Filter toggle button — hidden on desktop */
.filter-toggle-btn { display: none; }

/* Mobile detail bottom sheet */
.mobile-detail-sheet {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  max-height: 70vh; background: var(--detail-bg);
  border-top-left-radius: 16px; border-top-right-radius: 16px;
  box-shadow: 0 -4px 24px rgba(0,0,0,.3);
  z-index: 200; overflow-y: auto; padding: 8px 16px 24px;
  transform: translateY(100%); transition: transform .25s ease;
}
.mobile-detail-sheet.open { display: block; transform: translateY(0); }
.mobile-sheet-handle {
  width: 40px; height: 4px; background: var(--border);
  border-radius: 2px; margin: 4px auto 8px; cursor: pointer;
}
.mobile-sheet-close {
  position: absolute; top: 8px; right: 12px;
  background: none; border: none; font-size: 20px;
  color: var(--text-muted); cursor: pointer; z-index: 1;
}
.mobile-sheet-close:hover { color: var(--text); }
.mobile-sheet-content { padding-top: 4px; }

/* Perf dashboard */
.perf-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; padding: 12px 20px; min-width: 120px; text-align: center; }
.perf-num { font-size: 24px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.perf-num--small { font-size: 0.85em; }
.perf-num--small a { color: var(--text-muted); text-decoration: none; }
.perf-num--small a:hover { color: var(--text); }
.perf-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }
.perf-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.perf-table th { text-align: left; padding: 6px 10px; border-bottom: 2px solid var(--border); color: var(--text-muted); font-size: 11px; text-transform: uppercase; }
.perf-table td { padding: 5px 10px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.perf-table code { font-size: 12px; color: var(--text); }
.perf-table .perf-slow { background: rgba(239, 68, 68, 0.08); }
.perf-table .perf-slow td { color: var(--status-red); }
.perf-table .perf-warn { background: rgba(251, 191, 36, 0.06); }
.perf-table .perf-warn td { color: var(--status-yellow); }

/* #204 — Perf page responsive */
@media (max-width: 640px) {
  #perfWrapper { padding: 12px !important; }
  .perf-card { min-width: 0; flex: 1 1 calc(50% - 8px); }
  .perf-table { font-size: 11px; }
  .perf-table th, .perf-table td { padding: 4px 6px; }
}

/* ─── Region / Area filter bars ─── */
.region-filter-bar { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0; }
.area-dropdown-menu { min-width: 160px; }
.area-dropdown-item.area-item-active { color: var(--accent); font-weight: 600; }
.region-filter-container { margin: 0; padding: 0; display: inline-flex; align-items: center; }
.region-pill {
  display: inline-flex; align-items: center; justify-content: center; padding: 4px 12px; border-radius: 16px;
  font-size: 12px; font-weight: 500; cursor: pointer; border: 1.5px solid var(--border);
  background: transparent; color: var(--text-muted); transition: all 0.15s; white-space: nowrap;
  flex-shrink: 0;
}
.region-pill:hover { border-color: var(--accent); color: var(--accent); }
/* #1668 M5 — was bg:var(--accent)(#4a9eff) + #fff = 2.75:1 BLOCKER on both themes.
   Bumped to --accent-strong (#2563eb) + --text-on-accent for 4.83:1 AA pass.
   Same M2 token pair used for .skip-link / .hop-named / .filter-bar .btn.active. */
button.region-pill-active {
  background: var(--accent-strong); color: var(--text-on-accent); border-color: var(--accent-strong);
}
button.region-pill-active:hover { opacity: 0.85; color: var(--text-on-accent); }
.region-filter-label {
  font-size: 12px; font-weight: 600; color: var(--text-muted); align-self: center;
  margin-right: 2px; user-select: none; white-space: nowrap; flex-shrink: 0;
}

/* #416 — named region quick picks. One wrapped row of buttons next to the
   region control, separated by a hairline so it reads as a shortcut over the
   same codes rather than more region pills. Rendered only when the operator
   configured `regionGroups`, which is also what lets the container wrap:
   without groups the layout is byte-for-byte what it was. */
.region-filter-container.has-region-quick-picks { flex-wrap: wrap; row-gap: 4px; }
.region-quick-picks {
  display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-left: 8px; padding-left: 8px; border-left: 1px solid var(--border);
}
.region-quick-pick {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 4px 12px; border-radius: 16px; font-size: 12px; font-weight: 500;
  font-family: var(--font); cursor: pointer; border: 1.5px dashed var(--border);
  background: transparent; color: var(--text-muted); transition: all 0.15s;
  white-space: nowrap; flex-shrink: 0; max-width: 14em;
  overflow: hidden; text-overflow: ellipsis;
}
.region-quick-pick:hover { border-color: var(--accent); color: var(--accent); }
.region-quick-pick:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Same --accent-strong / --text-on-accent pair as .region-pill-active, kept
   for the 4.83:1 AA contrast #1668 M5 settled on; the dashed border is what
   tells a group apart from a single region at a glance. */
.region-quick-pick-active {
  background: var(--accent-strong); color: var(--text-on-accent);
  border-style: solid; border-color: var(--accent-strong);
}
.region-quick-pick-active:hover { opacity: 0.85; color: var(--text-on-accent); }
/* On a phone or small tablet the row wraps away from the control, so the
   hairline would divide nothing useful: the quick picks become their own
   full-width row. #620: in dropdown mode that row goes above the control (the
   wrap gets order: 1), so the menu, which drops below its trigger, never
   covers the picks, and the container is capped to its host so a long row
   cannot widen the page. Desktop layout is untouched. */
@media (max-width: 768px) {
  .region-filter-container.has-region-quick-picks { max-width: 100%; min-width: 0; }
  .region-filter-container.has-region-quick-picks .region-dropdown-wrap { order: 1; }
  .region-quick-picks {
    margin-left: 0; padding-left: 0; border-left: 0;
    flex-basis: 100%; width: 100%; min-width: 0;
  }
  .region-quick-pick { max-width: 100%; }
}

.analytics-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
/* The one time-window / metric <select> style: Analytics filters and the
   Perf page's WebSocket-history Period control. */
.time-window-select {
  height: 34px; min-height: 34px; padding: 0 10px; border-radius: 6px; box-sizing: border-box;
  font-size: 13px; font-weight: 500; cursor: pointer; border: 1px solid var(--border);
  background: var(--input-bg); color: var(--text); font-family: var(--font); transition: border-color 0.15s;
}
.time-window-select:hover { border-color: var(--accent); }
.perf-range-control { display: inline-flex; align-items: center; gap: 8px; }
.region-dropdown-wrap { position: relative; display: inline-flex; align-items: center; }
.region-dropdown-trigger {
  display: inline-flex; align-items: center; padding: 6px 10px; border-radius: 6px;
  font-size: 13px; font-weight: 500; cursor: pointer; border: 1px solid var(--border);
  background: var(--input-bg); color: var(--text); transition: all 0.15s;
  height: 34px; box-sizing: border-box; white-space: nowrap; line-height: 1;
}
.region-dropdown-trigger:hover { border-color: var(--accent); color: var(--accent); }
.region-dropdown-menu {
  position: absolute; top: 100%; left: 0; z-index: var(--z-dropdown);
  min-width: min(220px, calc(100vw - 2 * var(--region-menu-gutter)));
  max-width: calc(100vw - 2 * var(--region-menu-gutter));
  width: max-content; max-height: 260px; overflow-y: auto;
  background: var(--card-bg, #fff); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12); padding: 4px 0;
}
.region-dropdown-item {
  display: flex; align-items: center; gap: 6px; padding: 6px 12px;
  font-size: 13px; cursor: pointer; color: var(--text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; width: 100%; max-width: min(320px, calc(100vw - 2 * var(--region-menu-gutter) - 2px));
  background: transparent; border: 0px;
}
.region-dropdown-item input[type="checkbox"] {
  width: 14px; height: 14px; margin: 0; flex-shrink: 0;
}
.region-dropdown-item:hover { background: var(--row-hover, #f5f5f5); }

/* Generic multi-select dropdown (Observer, Type filters) */
.multi-select-wrap { position: relative; display: inline-flex; align-items: center; }
.multi-select-trigger {
  display: inline-flex; align-items: center; padding: 6px 10px; border-radius: 6px;
  font-size: 13px; font-weight: 500; cursor: pointer; border: 1px solid var(--border);
  background: var(--input-bg); color: var(--text); transition: all 0.15s;
  height: 34px; box-sizing: border-box; white-space: nowrap; line-height: 1;
  /* #1128 (Bug 3): cap trigger width so a long selection like
   * "TRACE,MULTIPART,GRP_TXT" doesn't balloon the row and overlap toolbar
   * buttons. The full label remains accessible via the title tooltip.
   * #1131 MAJOR-4: use clamp() so the cap scales with viewport width
   * instead of being a hard 180px on every screen size. */
  max-width: clamp(120px, 18vw, 280px); overflow: hidden; text-overflow: ellipsis;
}
.multi-select-trigger:hover { border-color: var(--accent); color: var(--accent); }
.multi-select-menu {
  position: absolute; top: 100%; left: 0; z-index: var(--z-dropdown);
  min-width: 220px; max-height: 260px; overflow-y: auto;
  background: var(--card-bg, #fff); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12); padding: 4px 0; display: none;
}
.multi-select-menu.open { display: block; }
.multi-select-item {
  display: flex; align-items: center; gap: 6px; padding: 6px 12px;
  font-size: 13px; cursor: pointer; color: var(--text); white-space: nowrap;
}
.multi-select-item input[type="checkbox"] {
  width: 14px; height: 14px; margin: 0; flex-shrink: 0;
}
.multi-select-item:hover { background: var(--row-hover, #f5f5f5); }

.chan-tag { background: var(--accent-strong, #2563eb); color: var(--text-on-accent, #f9fafb); padding: 2px 8px; border-radius: 4px; font-size: 0.9em; font-weight: 600; }

/* Matrix mode hex animation */
.matrix-char { background: none !important; border: none !important; }
.matrix-char span { display: block; text-align: center; white-space: nowrap; line-height: 1; }

/* === Matrix Theme === */
.matrix-theme .leaflet-tile-pane,
.matrix-theme .mc-ortho-pane {
  filter: brightness(1.1) contrast(1.2) sepia(0.6) hue-rotate(70deg) saturate(2);
}
.matrix-theme.leaflet-container::before {
  content: ''; position: absolute; inset: 0; z-index: 401;
  background: rgba(0, 60, 10, 0.35); mix-blend-mode: multiply; pointer-events: none;
}
.matrix-theme.leaflet-container::after {
  content: ''; position: absolute; inset: 0; z-index: 402;
  background: rgba(0, 255, 65, 0.06); mix-blend-mode: screen; pointer-events: none;
}
.matrix-theme { background: #000 !important; }
.matrix-theme .leaflet-control-zoom a { background: #0a0a0a !important; color: #00ff41 !important; border-color: #00ff4130 !important; }
.matrix-theme .leaflet-control-attribution { background: rgba(0,0,0,0.8) !important; color: #00ff4180 !important; }
.matrix-theme .leaflet-control-attribution a { color: #00ff4160 !important; }

/* Scanline overlay */
.matrix-scanlines {
  position: absolute; inset: 0; z-index: 9999; pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,255,65,0.02) 2px, rgba(0,255,65,0.02) 4px);
}

/* Feed panel in matrix mode */
.matrix-theme .live-feed {
  background: rgba(0, 10, 0, 0.92) !important;
  border-color: #00ff4130 !important;
  font-family: 'Courier New', monospace !important;
}
.matrix-theme .live-feed .live-feed-item { color: #00ff41 !important; border-color: #00ff4115 !important; }
.matrix-theme .live-feed .live-feed-item:hover { background: rgba(0,255,65,0.08) !important; }
.matrix-theme .live-feed .feed-hide-btn { color: #00ff41 !important; }

/* Controls in matrix mode (#1205 R1) — keep matrix text/accent color
   only. Background + border are owned by the parent #liveHeader (MESH
   LIVE panel) now that .live-controls is in-flow and transparent;
   re-painting an opaque box here would orphan a nested chrome rect
   inside the header for matrix-theme users. */
.matrix-theme .live-controls {
  background: transparent !important;
  border: 0 !important;
  color: #00ff41 !important;
}
.matrix-theme .live-controls label,
.matrix-theme .live-controls span,
.matrix-theme .live-controls .lcd-display { color: #00ff41 !important; }
.matrix-theme .live-controls button { color: #00ff41 !important; border-color: #00ff4130 !important; }
.matrix-theme .live-controls input[type="range"] { accent-color: #00ff41; }

/* Node detail panel in matrix mode */
.matrix-theme .live-node-detail {
  background: rgba(0, 10, 0, 0.95) !important;
  border-color: #00ff4130 !important;
  color: #00ff41 !important;
}
.matrix-theme .live-node-detail a { color: #00ff41 !important; }
.matrix-theme .live-node-detail .feed-hide-btn { color: #00ff41 !important; }

/* Node labels on map */
.matrix-theme .node-label { color: #00ff41 !important; text-shadow: 0 0 4px #00ff41 !important; }
.matrix-theme .leaflet-marker-icon:not(.matrix-char) { filter: hue-rotate(90deg) saturate(1) brightness(0.35) opacity(0.5); }

/* Audio controls */
.audio-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 8px;
  font-size: 12px;
}
.audio-controls.hidden { display: none; }
.audio-slider-label {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted, #6b7280);
  font-size: 11px;
  white-space: nowrap;
}
.audio-slider {
  width: 80px;
  height: 4px;
  cursor: pointer;
  accent-color: #8b5cf6;
}
.audio-slider-label span {
  min-width: 24px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.matrix-theme .audio-controls label,
.matrix-theme .audio-controls span { color: #00ff41 !important; }
.matrix-theme .audio-slider { accent-color: #00ff41; }

/* Audio voice selector */
.audio-voice-select {
  background: var(--input-bg, #1f2937);
  color: var(--text, #e5e7eb);
  border: 1px solid var(--border, #374151);
  border-radius: 4px;
  padding: 2px 4px;
  font-size: 11px;
  cursor: pointer;
}
.matrix-theme .audio-voice-select {
  background: #001a00 !important;
  color: #00ff41 !important;
  border-color: #00ff4130 !important;
}

/* Audio unlock overlay */
.audio-unlock-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.audio-unlock-prompt {
  background: #1f2937;
  color: #e5e7eb;
  padding: 24px 40px;
  border-radius: 12px;
  font-size: 20px;
  font-weight: 600;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  user-select: none;
}
.matrix-theme .audio-unlock-prompt {
  background: #001a00;
  color: #00ff41;
  box-shadow: 0 0 30px rgba(0,255,65,0.2);
}


/* Packet Filter Language */
.packet-filter-input { transition: border-color 0.2s; }
.packet-filter-input:focus { border-color: var(--accent); outline: none; }
.packet-filter-input.filter-error { border-color: var(--status-red); }
.packet-filter-input.filter-active { border-color: var(--status-green); }

/* ============================================================
 * Generic themed button vocabulary (#1644).
 * ------------------------------------------------------------
 * PR #1642 introduced markup like <button class="btn-secondary"> in
 * observers.js / observer-detail.js but never shipped a top-level
 * `.btn-secondary` rule — only `.ch-modal-btn-secondary`. The buttons
 * fell back to the browser default (white/gray) and looked broken
 * against the themed UI.
 *
 * The fix is a small, three-tier vocabulary built out of existing
 * surface/border/text tokens — NO new top-level color tokens, no
 * gradient/shadow chartjunk. Companion to `.btn-primary` (#3329 above):
 *
 *   .btn-primary    — high-emphasis, accent-filled
 *   .btn-secondary  — low-emphasis, themed neutral on surface
 *   .btn-ghost      — minimal, transparent until hover
 *
 * Sized 32-px tall by default; the global 48-px touch-target rule
 * lifts the hit area on touch devices without breaking desktop
 * proportions. Sibling `.btn-icon` (already defined above) keeps
 * its existing semantics.
 * ============================================================ */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, color 120ms;
}
.btn-secondary:hover:not([disabled]):not(:disabled) {
  background: var(--row-hover);
  border-color: var(--accent);
  color: var(--text);
}
.btn-secondary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn-secondary[disabled],
.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.btn-ghost:hover:not([disabled]):not(:disabled) {
  background: var(--hover-bg);
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost[disabled],
.btn-ghost:disabled { opacity: 0.5; cursor: not-allowed; }

/* === Observer Comparison (#/compare) — Tufte redesign (#1644) ===
 * Design rationale: the old layout was three card-boxes side-by-side
 * (heavy borders, decorative rgba tints, three nearly-identical
 * 28px counts) forcing the eye to do mental subtraction. The
 * redesign borrows the route-view v2 vocabulary (surface tokens,
 * small-multiples, ctx pills, sparing accent) so the comparison
 * page belongs in the same product. A single proportional
 * diff-strip (Tufte's "show the data") makes the asymmetry
 * legible at a glance; the textual cards are demoted to subtext.
 */
.compare-page { padding: var(--space-md); max-width: 1200px; margin: 0 auto;
  /* #1646 mobile: reserve space below the floating bottom-nav at ≤768px.
   * --bottom-nav-reserve is 0px on desktop, 56px + safe-area on mobile,
   * so this rule is a no-op for desktop and adds the exact clearance
   * needed on phones — the Shared-Types pill row + tabs were getting
   * eaten by the nav. (Tufte: don't reserve space we don't need.) */
  padding-bottom: calc(var(--space-md) + var(--bottom-nav-reserve, 0px));
}
.compare-page .page-header {
  display: flex; align-items: center; justify-content: flex-start;
  gap: var(--space-sm); margin-bottom: var(--space-sm);
}
.compare-page .page-header h2 { font-size: var(--fs-lg); margin: 0; }

.compare-breadcrumbs {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin: 0 0 var(--space-md);
}
.compare-breadcrumbs a { color: var(--link-color); text-decoration: none; }
.compare-breadcrumbs a:hover { text-decoration: underline; }

.compare-controls {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-md);
}
/* Once both observers are picked, the headline strip below is the
 * answer. Demote the picker: tighter padding, smaller labels.
 * Operators can still swap A/B without leaving the page. The "A"/"B"
 * referent stays visible (issue #1646 Tufte: erase labels, not
 * referents). */
.compare-controls.is-collapsed {
  padding: 4px var(--space-md);
}
.compare-controls.is-collapsed .compare-select-group label { display: none; }
.compare-controls.is-collapsed .compare-select { font-size: var(--fs-sm); padding: 4px 8px; }
.compare-controls.is-collapsed .compare-select-id { display: inline-block; }
.compare-selector {
  display: flex; align-items: flex-end; gap: var(--space-sm); flex-wrap: wrap;
}
.compare-select-group { display: flex; flex-direction: column; gap: 2px; min-width: 180px; }
.compare-select-group label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--text-muted);
}
/* The "A" / "B" badge is hidden when the labels are visible (expanded
 * state) and revealed when collapsed, so the dropdown row never loses
 * its A/B referent. */
.compare-select-id {
  display: none;
  font-size: 10px; font-weight: 700; color: var(--text-muted);
  letter-spacing: 0.6px; padding: 2px 0;
}
.compare-select {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--input-bg); color: var(--text); font-size: var(--fs-sm);
  cursor: pointer;
}
.compare-select:focus { border-color: var(--accent); outline: none; }
.compare-vs {
  /* #1668 M5 — was font-size:10px+color:var(--text-muted)+opacity:0.7
     → composite color #8c929b on white = 3.13:1 (BLOCKER). Removed the
     opacity haze AND bumped from text-muted to text (full theme color)
     so the 'vs' lives in the same readable band as adjacent labels. */
  font-size: 10px; font-weight: 700; color: var(--text);
  text-transform: uppercase; letter-spacing: 1.2px;
  padding: 0 4px;
  align-self: center;
}
/* The Compare CTA was removed in #1646 — comparison auto-runs when
 * both observers are chosen. The legacy .compare-btn touch-target
 * declaration was deleted with it; surrounding form controls already
 * carry their own 48px-min-height rule. */

.compare-results { margin-top: var(--space-md); }

/* ── Headline strip — the only large number on the page ───────────
 * Three counts above a single proportional bar (small multiples on
 * a shared axis: one strip, not three boxes). Eye sees the whole
 * comparison in one fixation. */
.compare-strip {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md) var(--space-md);
  margin-bottom: var(--space-md);
}
.compare-strip-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--space-md);
  align-items: baseline;
  margin-bottom: 8px;
}
.compare-strip-side { display: flex; flex-direction: column; gap: 2px; cursor: pointer; }
.compare-strip-side-b { text-align: right; }
.compare-strip-name {
  font-size: var(--fs-sm); font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* The side cells lead with the percentage, matching the middle cell
 * (one unit across the row, no design variation — issue #1646). */
.compare-strip-side-pct {
  font-family: var(--mono);
  font-size: var(--fs-xl); font-weight: 700;
  color: var(--text); font-variant-numeric: tabular-nums;
  line-height: 1;
}
.compare-strip-side-pct-unit {
  font-size: 0.6em; margin-left: 1px;
}
.compare-strip-sub { font-size: 11px; color: var(--text-muted); }
.compare-strip-mid {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border-left: 1px dashed var(--border);
  border-right: 1px dashed var(--border);
  padding: 0 var(--space-md);
  cursor: pointer;
}
.compare-strip-mid-count {
  font-family: var(--mono);
  font-size: var(--fs-sm); font-weight: 600;
  color: var(--text); font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* The 79% gets the largest type — it IS the answer to "how much
 * overlap?". The raw count and the label demote underneath. (Tufte:
 * the most important number gets the most ink. Issue #1646.) */
.compare-strip-mid-pct {
  font-family: var(--mono);
  font-size: var(--fs-xl); font-weight: 700;
  color: var(--accent); font-variant-numeric: tabular-nums;
  line-height: 1;
}
.compare-strip-mid-pct-unit {
  font-size: 0.6em; margin-left: 1px;
}
.compare-strip-mid-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-muted);
}

/* The diff bar — one row, three colored segments, shared axis. */
.compare-bar-container { margin-top: 4px; }
.compare-bar {
  display: flex; height: 10px; border-radius: 5px; overflow: hidden;
  background: var(--surface-2);
}
.compare-bar-seg {
  transition: width 240ms ease;
  /* #1646: Tufte/honesty — a 1–2% segment must still be visible or
   * the chart is lying about presence. This is a *presence floor only*,
   * not a perception-equivalent floor: 2px is the smallest pip the
   * eye can reliably register on a 10px-tall bar without falsely
   * equating a 1% and a 5% slice (which a 6px floor would do).
   * Above ~2% the proportional encoding remains accurate. */
  min-width: 2px;
}
.compare-bar-a    { background: var(--accent); }
.compare-bar-both { background: var(--status-green); }
.compare-bar-b    { background: var(--status-amber); }
/* Tick marks on the diff bar showing where the proportions land */
.compare-bar-legend {
  display: flex; gap: var(--space-md); margin-top: 6px;
  font-size: 11px; color: var(--text-muted);
  flex-wrap: wrap;
}
.compare-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.compare-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.compare-dot-a    { background: var(--accent); }
.compare-dot-both { background: var(--status-green); }
.compare-dot-b    { background: var(--status-amber); }

/* ── Asymmetric reach sentences ───────────────────────────────────
 * Two compact lines telling the directional story without three
 * cards or two big numbers. Mono-numeric for at-a-glance compare. */
.compare-asym {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}
.compare-asym-line {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  line-height: 1.45;
}
.compare-asym-line b { color: var(--text); font-family: var(--mono); font-variant-numeric: tabular-nums; }
.compare-asym-line .compare-asym-pct {
  font-family: var(--mono); font-size: var(--fs-lg); font-weight: 700;
  color: var(--text); font-variant-numeric: tabular-nums;
  display: block; margin-bottom: 2px;
}

/* ── Type breakdown — packet-context ctx pills (route-view vocab) ─ */
.compare-type-summary {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-md);
  font-size: var(--fs-sm); color: var(--text);
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
}
.compare-type-summary-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-muted); font-weight: 700;
  margin-right: 4px;
}
.compare-type-badge {
  display: inline-flex; align-items: baseline; gap: 4px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: var(--badge-radius);
  background: var(--surface-2);
  font-size: 11px;
  color: var(--text);
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}
.compare-type-badge b { color: var(--accent); font-weight: 700; }

/* ── Tabs (Summary / Both / Only A / Only B) ──────────────────── */
.compare-tabs {
  display: flex; gap: 0; margin-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.compare-tabs .tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 6px 14px;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: color 120ms, border-color 120ms;
  margin-bottom: -1px;
}
.compare-tabs .tab-btn:hover { color: var(--text); }
.compare-tabs .tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.compare-summary-text { padding: 4px 0 var(--space-sm); font-size: var(--fs-sm); line-height: 1.6; color: var(--text-muted); }
.compare-summary-text p { margin: 0 0 8px; }
.compare-summary-text p b,
.compare-summary-text p strong { color: var(--text); font-family: var(--mono); font-variant-numeric: tabular-nums; }
.compare-warning {
  color: var(--status-amber-text); background: var(--status-amber-light);
  border: 1px solid var(--status-amber); padding: 6px 10px; border-radius: var(--radius-sm);
  font-weight: 600;
}
.compare-good {
  color: var(--status-green);
  border: 1px solid var(--status-green); padding: 6px 10px; border-radius: var(--radius-sm);
  font-weight: 600;
}

.compare-table { font-size: var(--fs-sm); }

/* ── #122 reference-to-many mode ─────────────────────────────────── */
.compare-mode-toggle {
  display: flex; gap: var(--space-xs); margin-bottom: var(--space-sm); flex-wrap: wrap;
}
.compare-ref-headline {
  margin-bottom: var(--space-sm);
}
.compare-ref-headline-name {
  font-size: var(--fs-lg); font-weight: var(--fw-semibold); color: var(--text);
}
.compare-ref-headline-sub {
  font-size: var(--fs-sm); color: var(--text-muted); font-variant-numeric: tabular-nums;
}
.compare-ref-note {
  font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.5;
  margin: 0 0 var(--space-sm);
}
.compare-ref-table { font-size: var(--fs-sm); }
.compare-ref-table .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.compare-ref-sort-btn {
  background: transparent; border: none; color: var(--text-muted);
  font-size: var(--fs-sm); font-weight: var(--fw-semibold); cursor: pointer;
  padding: 2px 0; white-space: nowrap;
}
.compare-ref-sort-btn:hover { color: var(--text); }
.compare-ref-sort-btn.active { color: var(--accent); }

@media (max-width: 640px) {
  .compare-selector { flex-direction: column; align-items: stretch; }
  .compare-select-group { min-width: 0; }
  .compare-select { min-width: auto; width: 100%; }
  .compare-vs { display: none; }
  .compare-strip-row { grid-template-columns: 1fr; gap: var(--space-sm); }
  .compare-strip-side-b { text-align: left; }
  .compare-strip-mid { border-left: none; border-right: none;
    border-top: 1px dashed var(--border); border-bottom: 1px dashed var(--border);
    padding: var(--space-sm) 0; flex-direction: row; gap: 6px; align-items: baseline; }
  .compare-asym { grid-template-columns: 1fr; }
  /* #1646 mobile reflow: the asym sentence wraps mid-phrase at narrow
   * widths ("3,262 of GY889 Repeater's 3,347 packets" splitting after
   * "Repeater's"). text-wrap:pretty rebalances trailing words to
   * avoid orphan-style breaks; overflow-wrap:anywhere lets very long
   * node names yield instead of pushing the column. The percentage
   * already lives on its own line (display:block), so the body is
   * free to breathe. */
  .compare-asym-line {
    text-wrap: pretty;
    overflow-wrap: anywhere;
    word-break: normal;
  }
  /* #1646 mobile tabs: "Only N6IJ Repeater (675)" overruns the row at
   * 375px; without min-width:0 a flex item can't shrink past its
   * intrinsic content width. Allow each tab to shrink and ellipsis
   * its label so all four fit. The count parenthetical stays
   * visible because it's at the tail of the string. */
  .compare-tabs .tab-btn {
    min-width: 0;
    flex: 0 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 50%;
    padding: 6px 10px;
  }
}

/* ── Observers page — compare-selection column + button hints ─── */
.col-compare-select {
  width: 36px; text-align: center;
  /* Tufte: this column is administrative chrome, NOT data.
     Shrink it; use the muted text so it doesn't compete. */
  color: var(--text-muted);
}
/* The checkbox itself: theme-aware accent + minimum tap target
 * provided by the surrounding cell, not the input. */
.col-compare-select input[type="checkbox"] {
  width: 16px; height: 16px; min-height: 16px;
  accent-color: var(--accent); cursor: pointer;
  /* When at least one row is selected, we add .has-compare-selection
   * to the table so the column highlight makes it obvious WHICH rows
   * are in the selection. */
}
.obs-table.has-compare-selection .col-compare-select { color: var(--text); }
.obs-table tbody tr:has(input[data-compare-select]:checked) {
  background: var(--selected-bg);
}
/* Compact "Compare selected (0)" button: when nothing selected, fade
 * to background so it doesn't compete with the primary "Compare
 * observers" CTA. The disabled rule above already gives 0.5 opacity. */
.observers-page .page-header {
  display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap;
  margin-bottom: var(--space-sm);
}
.observers-page .page-header h2 { font-size: var(--fs-lg); margin: 0 var(--space-sm) 0 0; }
.observers-page .page-header .obs-refresh-spacer { margin-left: auto; }

/* Observer-detail header: the Compare-with picker + Compare button
 * should sit together visually. Reuses the same .btn-secondary. */
.observer-detail-page .compare-with-group {
  display: inline-flex; align-items: stretch; gap: 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-1); overflow: hidden;
}
.observer-detail-page .compare-with-group select.time-range-select {
  border: none; background: transparent; color: var(--text);
  font-size: var(--fs-sm); padding: 6px 10px;
  border-right: 1px solid var(--border);
  min-height: 0;
}
.observer-detail-page .compare-with-group select.time-range-select:focus { outline: none; }
.observer-detail-page .compare-with-group button[data-action="compare-with-go"] {
  border: none; border-radius: 0; background: var(--surface-2);
}
.observer-detail-page .compare-with-group button[data-action="compare-with-go"]:hover:not(:disabled) {
  background: var(--row-hover); color: var(--text);
}

/* Neighbor graph canvas focus indicator for keyboard navigation */
#ngCanvas:focus {
  outline: 2px solid var(--link-color, #60a5fa);
  outline-offset: 2px;
}
#ngCanvas:focus:not(:focus-visible) {
  outline: none;
}

/* ===================== RF Health Dashboard ===================== */
.rf-health-container { padding: 0; }
.rf-time-selector {
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
  margin-bottom: 8px; padding: 8px 0;
}
.rf-range-btn {
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 4px;
  background: var(--bg-secondary, var(--card-bg, #1e1e1e)); color: var(--text-primary, #e0e0e0);
  cursor: pointer; font-size: 12px; transition: background 0.15s;
}
.rf-range-btn:hover { background: var(--bg-hover, #333); }
/* #1719 — consolidated active-button accent: was background:var(--accent)
   (#4a9eff) + color:#fff = 2.75:1 (BLOCKER × N selectors). All four
   recurring sites (.rf-range-btn.active, .clock-filter-btn.active,
   .subpath-jump-nav a, inline ptCheckBtn / ptGenBtn) now route through
   the shared `.btn-active-accent` style or this same token pair so a
   future regression is fixable in one place. --accent-strong
   (#2563eb) + --text-on-accent (#f9fafb) = 8.59:1 (AA pass). */
.btn-active-accent,
.rf-range-btn.active,
.clock-filter-btn.active,
.subpath-jump-nav a,
/* #1719 round-1 polish: three additional active-state surfaces
   consolidated here. Their inline `background:var(--accent); color:#fff`
   rules (2.75:1) are removed below — they now inherit this token pair. */
.node-filter-option.node-filter-active,
.subpath-selected,
.analytics-time-range button.active {
  background: var(--accent-strong);
  color: var(--text-on-accent);
  border-color: var(--accent-strong);
}
.rf-custom-inputs { display: inline-flex; gap: 4px; align-items: center; margin-left: 8px; }
.rf-datetime {
  padding: 3px 6px; border: 1px solid var(--border); border-radius: 4px;
  background: var(--bg-secondary, var(--card-bg)); color: var(--text-primary); font-size: 12px;
}

.rf-health-split {
  display: flex; height: calc(100vh - 180px); min-height: 300px; overflow: hidden;
}
.rf-health-grid {
  flex: 1; min-width: 0; overflow-y: auto; padding: 0 8px 8px 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px; align-content: start;
}
.rf-cell {
  border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px;
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
  background: var(--bg-secondary, var(--card-bg, #1e1e1e));
}
.rf-cell:hover { border-color: var(--accent); }
.rf-cell:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.rf-cell-selected { border-color: var(--accent); background: var(--bg-hover, rgba(96,165,250,0.08)); }

.rf-cell-header { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; margin-bottom: 4px; }
.rf-cell-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.rf-cell-nf { font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rf-cell-batt { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.rf-nf-warning { color: var(--status-yellow, #f59e0b); }
.rf-nf-critical { color: var(--status-red, #ef4444); }

.rf-cell-sparkline { height: 24px; margin: 2px 0; overflow: hidden; }
.rf-cell-stats { display: flex; gap: 8px; font-size: 10px; color: var(--text-muted); }
/* #479 — a fourth stat ("TX 1h") wraps between items, never inside one */
.rf-cell-stats { flex-wrap: wrap; row-gap: 0; }
.rf-cell-stats > span { white-space: nowrap; }
/* #479 — rolling 1 h TX airtime at or over the duty-cycle threshold */
.airtime-over { color: var(--danger); font-weight: 600; }

/* Side panel for observer detail */
.rf-health-detail {
  width: 420px; min-width: 280px; max-width: 50vw;
  border-left: 1px solid var(--border); background: var(--bg-secondary, var(--card-bg));
  overflow-y: auto; padding: 16px; position: relative;
  animation: slideInRight 200ms ease-out;
}
.rf-health-detail.rf-panel-empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 14px; animation: none;
}
.rf-detail-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.rf-detail-header h3 { margin: 0; font-size: 16px; }
.rf-detail-close {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 18px; padding: 2px 6px; border-radius: 4px;
}
.rf-detail-close:hover { background: var(--bg-hover); }
.rf-detail-charts { display: flex; flex-direction: column; gap: 4px; }
.rf-detail-chart { margin: 0; overflow-x: auto; }
.rf-detail-summary { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .rf-health-split { flex-direction: column; height: auto; }
  .rf-health-grid { grid-template-columns: 1fr; max-height: 50vh; }
  .rf-health-detail {
    width: 100% !important; max-width: 100%; min-width: 0;
    border-left: none; border-top: 1px solid var(--border);
  }
  .rf-time-selector { gap: 3px; }
  .rf-custom-inputs { margin-left: 0; margin-top: 4px; flex-wrap: wrap; }
}

/* Channel Color Picker Popover (M2, #271) */
/* === Channel Color Picker (#674) === */
.cc-picker-popover {
  position: fixed;
  z-index: var(--z-tooltip);
  background: var(--bg-secondary, #1e1e1e);
  border: 1px solid var(--border-color, #333);
  border-radius: 8px;
  padding: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.cc-picker-swatches {
  display: flex;
  gap: 6px;
}
.cc-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.15s;
}
.cc-swatch:hover { border-color: rgba(255,255,255,0.6); }
.cc-swatch:focus-visible { border-color: #fff; outline: 2px solid var(--accent, #3b82f6); outline-offset: 1px; }
.cc-swatch-active { border-color: #fff; }
.cc-picker-clear {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 4px 0;
  font-size: 11px;
  color: var(--text-muted, #888);
  background: none;
  border: none;
  cursor: pointer;
  text-align: center;
}
.cc-picker-clear:hover { color: var(--text-primary, #e0e0e0); }

/* Color dot affordance (#674) */
.ch-color-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.3);
  cursor: pointer;
  vertical-align: middle;
  margin-left: 6px;
  flex-shrink: 0;
}
.ch-color-clear {
  display: inline-block;
  font-size: 10px;
  line-height: 1;
  color: var(--text-muted, #888);
  cursor: pointer;
  margin-left: 3px;
  vertical-align: middle;
}
.ch-color-clear:hover { color: var(--text-primary, #e0e0e0); }
.ch-color-dot:not([style*="background"]) {
  background: transparent;
  border-style: dashed;
  border-color: var(--text-muted, #888);
}

/* Mobile bottom-sheet + larger touch targets (#674) */
@media (pointer: coarse) {
  .ch-color-dot {
    width: 20px;
    height: 20px;
    margin-left: 8px;
  }
  .cc-swatch {
    width: 36px;
    height: 36px;
  }
  .cc-picker-swatches {
    justify-content: center;
    gap: 10px;
  }
  .cc-picker-popover {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 12px 12px 0 0;
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    box-sizing: border-box;
  }
}

/* === #630 — Mobile Accessibility Fixes === */

/* #630-1: Touch targets — 48px house minimum on touch devices (#2052, #235) */
@media (pointer: coarse) {
  .filter-bar .btn,
  .filter-group .btn,
  .tab-btn,
  .filter-bar input,
  .filter-bar select,
  .region-pill,
  .region-quick-pick,
  .region-dropdown-trigger,
  .multi-select-trigger,
  .node-count-pill,
  .analytics-time-range button,
  .detail-back-btn,
  .filter-toggle-btn,
  .time-window-select {
    min-height: 48px;
    min-width: 48px;
  }
  .filter-bar input,
  .filter-bar select,
  .time-window-select {
    height: 48px;
  }
  .region-dropdown-trigger,
  .multi-select-trigger {
    height: 48px;
  }
  /* #314: two controls the #239 sweep did not cover. Measured at 375x812
     with a touch user agent, the swipe tip's "Got it" was 26 px tall and
     the packets reveal pill 18 px. Both are compact by design on desktop
     (a hint chip and a column-header badge), so the bump is touch-only,
     like the rest of this block. Both need the flex centring too: their
     labels are smaller than the box they now sit in. */
  .gesture-hint-dismiss,
  .col-hidden-pill {
    min-height: 48px;
    min-width: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* #630-3: Status text labels — visually hidden text for screen readers */
.sr-status-label { font-size: 11px; margin-left: 4px; }

/* #630-4: Detail panel as full-width overlay on mobile */
@media (max-width: 640px) {
  .split-layout .panel-right:not(.empty) {
    display: block;
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    min-width: 0;
    z-index: 150;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* #839 — a node opens as its own page here, so the empty side pane's
     "Select a node" placeholder only took height from the list. */
  .nodes-page .split-layout .panel-right.empty { display: none; }
}

/* #839 — Nodes in phone landscape (640x360, 568x320): the stacked top bar
   and region chips fill #app above the bottom nav and left the list's own
   scroll box ~12px, so no row could be reached. On a short phone the page
   scrolls as one: the top bar scrolls away and the list follows it. */
@media (max-width: 640px) and (max-height: 500px) {
  .nodes-page { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .nodes-page .split-layout { flex: none; height: auto; overflow: visible; }
  .nodes-page .panel-left { flex: none; }
}

/* #630-5: Analytics tabs — horizontal scroll on small screens */
@media (max-width: 640px) {
  .analytics-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding-bottom: 4px;
  }
  .analytics-tabs .tab-btn {
    flex-shrink: 0;
    white-space: nowrap;
  }
}

/* #630-6: Tables — horizontal scroll wrapper (legacy; #1056 uses fluid cols) */
.table-scroll-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
@media (max-width: 640px) {
  /* #1056: do NOT enforce min-width on primary fluid tables — column hiding
   * via JS keeps content readable without horizontal scroll. */
  .data-table { min-width: 0; }
}

/* Table sorting indicators */
th[data-sort-key] { cursor: pointer; user-select: none; }
th[data-sort-key]:hover { background: var(--hover-bg, rgba(255,255,255,0.05)); }
th.sort-active { color: var(--accent, #60a5fa); }
.sort-arrow { font-size: 0.75em; opacity: 0.8; }

/* #690 — Clock Skew badges & fleet table */
.skew-badge { display: inline-block; font-size: 12px; padding: 1px 6px; border-radius: 3px; margin-left: 4px; font-weight: var(--fw-semibold); white-space: nowrap; } /* #1668 M3 — was 10px */
.skew-badge--ok { background: var(--status-green); color: #fff; }
.skew-badge--warning { background: var(--status-yellow); color: #000; }
.skew-badge--critical { background: var(--status-orange); color: #fff; }
.skew-badge--absurd { background: var(--status-purple); color: #fff; }
.skew-badge--no_clock { background: var(--skew-badge-no-clock-bg); color: #fff; }
.skew-badge--bimodal_clock { background: var(--status-amber-light); color: var(--status-amber-text); border: 1px solid var(--status-amber); }

.skew-detail-section { padding: 10px 16px; margin-bottom: 8px; }
.skew-sparkline-wrap { margin-top: 6px; }
.skew-sparkline-wrap svg { display: block; }


.clock-fleet-row--warning { background: color-mix(in srgb, var(--status-yellow) 10%, transparent); }
.clock-fleet-row--critical { background: color-mix(in srgb, var(--status-orange) 10%, transparent); }
.clock-fleet-row--absurd { background: color-mix(in srgb, var(--status-purple) 10%, transparent); }
.clock-fleet-row--no_clock { background: color-mix(in srgb, var(--text-muted) 10%, transparent); }

.clock-filter-btn { font-size: 12px; padding: 3px 8px; border: 1px solid var(--border); border-radius: 4px; background: var(--card-bg, #fff); color: var(--text); cursor: pointer; margin-right: 4px; }

/* === Path Inspector (issue #944) === */
.path-inspector-page { padding: 16px; max-width: 900px; margin: 0 auto; }
.path-inspector-input-row { display: flex; gap: 8px; margin-bottom: 12px; }
.path-inspector-input-row .input { flex: 1; }
.path-inspector-error { color: var(--status-red, #ef4444); font-size: 13px; margin-bottom: 8px; }
.path-inspector-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.path-inspector-table th,
.path-inspector-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.path-inspector-table th { background: var(--card-bg); font-weight: 600; }
.speculative-warning { color: var(--path-inspector-speculative, #d97706); font-weight: 600; }
.speculative-badge { cursor: help; }
.speculative-row { background: color-mix(in srgb, var(--path-inspector-speculative, #d97706) 8%, transparent); }
.evidence-row { font-size: 12px; color: var(--text-muted); }
.evidence-row.collapsed { display: none; }
.evidence-detail { padding: 4px 10px; }
.hop-evidence { margin: 2px 0; }
.path-inspector-stats { margin-top: 12px; font-size: 12px; color: var(--text-muted); }
.no-results { color: var(--text-muted); font-style: italic; }

/* Map side pane for path inspector */
.map-side-pane { flex: 0 0 32px; overflow: hidden; transition: flex-basis 0.2s; border-left: 1px solid var(--border); background: var(--card-bg); }
.map-side-pane.expanded { flex: 0 0 320px; overflow-y: auto; padding: 12px; }
.map-side-pane .pane-toggle { cursor: pointer; padding: 8px; font-size: 14px; text-align: center; }
.map-side-pane .pane-content { display: none; }
.map-side-pane.expanded .pane-content { display: block; }
/* #123: the Map Controls panel and its toggle belong to the Leaflet area, so
   keep them clear of the Path Inspector pane (collapsed 32px, expanded
   320px); otherwise they cover the pane and its toggle. Below 641px the pane
   is hidden and the mobile rules place the controls. */
@media (min-width: 641px) {
  #mapSidePane ~ .map-controls { right: calc(32px + 12px); transition: right 0.2s; }
  #mapSidePane ~ .map-controls-toggle { right: calc(32px + 10px); transition: right 0.2s; }
  #mapSidePane.expanded ~ .map-controls { right: calc(320px + 12px); }
  #mapSidePane.expanded ~ .map-controls-toggle { right: calc(320px + 10px); }
}
/* #1236: on mobile the path-inspector side pane was eating 32px of horizontal
   width (flex:0 0 32px) inside #map-wrap, leaving an unused gutter on the
   right of the leaflet canvas. Path Inspector is a desktop-only convenience;
   hide the pane on narrow viewports so the map fills 100% of the viewport. */
@media (max-width: 640px) {
  .map-side-pane { display: none; }
}

/* Tools landing page */
.tools-landing { padding: 24px; max-width: 600px; }
/* auto-fill collapses to 1 column on narrow viewports with no media query
   needed -- each card gets at least 260px, as many columns as fit above that. */
/* No align-items override -- grid's default "stretch" makes every card in
   a row match the tallest one, so cards with a longer description don't
   look bigger than their neighbors. */
.tools-menu { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 12px; }
.tools-section { margin-top: 24px; }
.tools-section:first-of-type { margin-top: 16px; }
.tools-section-title { margin: 0; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.tools-card { display: block; padding: 16px; border-radius: 8px; border: 1px solid var(--border); background: var(--card-bg); color: var(--text); text-decoration: none; transition: border-color 0.2s; }
.tools-card:hover { border-color: var(--primary); }
.tools-card h3 { margin: 0 0 4px 0; font-size: 16px; }
.tools-card p { margin: 0; font-size: 13px; color: var(--text-muted); }

/* ── Ping Scores page (cmd/server/ping_scores.go, GET /api/ping-scores) ── */
.ping-scores-page { padding: 16px; max-width: 1100px; margin: 0 auto; }
.ping-scores-page h3 { margin: 20px 0 4px 0; font-size: 16px; }
.ping-scores-page h3:first-of-type { margin-top: 12px; }
.ps-records-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.ps-record-card { position: relative; }
.ps-record-card.ps-empty { opacity: 0.6; }
.ps-week-grid .ps-record-card { border-left: 3px solid var(--accent); padding-left: 13px; }
.ps-record-meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.ps-record-desc { font-size: 11px; color: var(--text-muted); margin-top: 6px; line-height: 1.4; }
.ps-leaderboards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-top: 8px; }
.ps-leaderboard { background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; }
.ps-leaderboard h3 { margin: 0 0 8px 0; font-size: 15px; }
.ps-leaderboard-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ps-leaderboard-table th { text-align: left; color: var(--text-muted); font-weight: 600; padding: 4px 8px 4px 0; border-bottom: 1px solid var(--border); }
.ps-leaderboard-table td { padding: 4px 8px 4px 0; border-bottom: 1px solid var(--border); }
.ps-leaderboard-table tr:last-child td { border-bottom: none; }

/* ── Map marker clustering (issue #1036, a11y refit issue #1356) ──
 *
 * #1356 WCAG 2.2 AA refit — Tufte structural framing + audit minimal patch.
 * Design source: github.com/Kpa-clawbot/CoreScope/issues/1356 (Tufte + audit comments).
 *
 * Carriers (NON-color) of meaning, per WCAG 1.4.1:
 *   - V1 cluster bubbles: size (40/48/56px) + numeral + border-style ramp EMOJI-OK-COMMENT
 *     (1.5px solid / 2.5px solid / 2px double). Fill is a single neutral.
 *   - V2 role pills: capital-letter prefix (R/C/M/S/O). Wong (2011) palette
 *     hue is secondary. Dark text (#1a1a1a) on ALL five pills (audit override
 *     so only ONE text-color rule is needed and every pill passes 4.5:1).
 *   - V3 multi-byte hash labels: unicode glyph prefix (✓/?/✗) + neutral fill EMOJI-OK-COMMENT
 *     + 3px colored left-border using the audit's high-luminance accent set
 *     (NOT Tol "vibrant" — those failed 3:1 vs the neutral fill).
 *
 * Constants are --mc-* namespaced. The reserved --info / --warning / --accent
 * system vars are NOT touched (per issue scope + AGENTS.md).
 */
:root {
  /* V1 — cluster bubble */
  --mc-cluster-fill:   rgba(33, 41, 54, 0.88);
  --mc-cluster-text:   #ffffff;
  --mc-cluster-border: #666666; /* audit: white border = 1.05:1 vs Carto-light; #666 = 4.83:1 */

  /* V2 — role pills (Wong 2011 colorblind-safe palette) */
  --mc-role-repeater:  #D55E00; /* vermillion        */
  --mc-role-companion: #56B4E9; /* sky blue          */
  --mc-role-room:      #009E73; /* bluish-green      */
  --mc-role-sensor:    #F0E442; /* yellow            */
  --mc-role-observer:  #CC79A7; /* reddish-purple    */

  /* #1488 — marker stroke (outline around the role shape on map + live).
   * Reporter (EldoonNemar) found the new white stroke overwhelming with
   * hundreds of nodes. Defaults preserve visibility on both dark + light
   * tiles; operators dial these via the customizer (Colors → Marker
   * Stroke) or via config.json (markerStroke.*). All SVG marker builders
   * read these vars so changes propagate live without a reload. */
  --mc-marker-stroke-color:   #fff;
  --mc-marker-stroke-width:   2;
  --mc-marker-stroke-opacity: 1;

  /* #1407 — per-role text colors paired with each --mc-role-X bg so
   * .mc-pill (and any badge using the var) hits WCAG 1.4.3 AA against
   * the active preset. Wong defaults all clear 4.5:1 with dark text;
   * preset overrides live in body[data-cb-preset="..."] blocks below. */
  --mc-role-repeater-text:  #1a1a1a;
  --mc-role-companion-text: #1a1a1a;
  --mc-role-room-text:      #1a1a1a;
  --mc-role-sensor-text:    #1a1a1a;
  --mc-role-observer-text:  #1a1a1a;

  /* V3 — multi-byte hash labels (neutral fill + high-luminance accent stripes) */
  --mc-mb-fill:        rgba(33, 41, 54, 0.92);
  --mc-mb-text:        #ffffff;
  --mc-mb-confirmed:   #56F0A0; /* audit override of Tol vibrant for fill contrast */
  --mc-mb-suspected:   #FFD966;
  --mc-mb-unknown:     #FF8888;
}

/* ─────────────────────────────────────────────────────────────────────────
 * #1361 — Colorblind preset overrides.
 *
 * Each block overrides --mc-role-* and --mc-mb-* CSS vars when the body
 * carries the matching data-cb-preset attribute. cb-presets.js also writes
 * these vars inline on documentElement (defense-in-depth so the preset
 * takes effect even on pages that ship custom theme overrides), and keeps
 * window.ROLE_COLORS in sync for JS consumers (legend, cluster builder).
 *
 * Palette sources cited in PR body. Authoritative CSS rules here mirror
 * the JS PRESETS table in public/cb-presets.js — both are the source of
 * truth so a regression that drops one is still caught by the other
 * (mirrors the #1356 "pill color: defense-in-depth via CSS + inline" pattern).
 * ─────────────────────────────────────────────────────────────────────── */
/* #1446 — the body data-cb-preset rule for the default (Wong) palette is
 * intentionally OMITTED. Wong is the :root baseline; selecting "default"
 * from the customizer is identical to "no preset". Writing the Wong
 * palette here would mask the server config's nodeColors (see #1446
 * cascade). Wong values remain available via :root above.
 */
body[data-cb-preset="deut"] {
  /* IBM 5-class deut variant — anchors shifted out of red/green collision. */
  --mc-role-repeater:  #FE6100;
  --mc-role-companion: #648FFF;
  --mc-role-room:      #785EF0;
  --mc-role-sensor:    #FFB000;
  --mc-role-observer:  #DC267F;
  /* #1407 — room/observer fail with dark text (3.86/3.83); flip to white. */
  --mc-role-repeater-text:  #1a1a1a;
  --mc-role-companion-text: #1a1a1a;
  --mc-role-room-text:      #ffffff;
  --mc-role-sensor-text:    #1a1a1a;
  --mc-role-observer-text:  #ffffff;
  --mc-mb-confirmed:   #648FFF;
  --mc-mb-suspected:   #FFB000;
  --mc-mb-unknown:     #DC267F;
}
body[data-cb-preset="prot"] {
  /* Protan: swap repeater anchor for higher-luminance amber. */
  --mc-role-repeater:  #FFB000;
  --mc-role-companion: #648FFF;
  --mc-role-room:      #785EF0;
  --mc-role-sensor:    #FE6100;
  --mc-role-observer:  #DC267F;
  /* #1407 — same room/observer flip as deut. */
  --mc-role-repeater-text:  #1a1a1a;
  --mc-role-companion-text: #1a1a1a;
  --mc-role-room-text:      #ffffff;
  --mc-role-sensor-text:    #1a1a1a;
  --mc-role-observer-text:  #ffffff;
  --mc-mb-confirmed:   #648FFF;
  --mc-mb-suspected:   #FFB000;
  --mc-mb-unknown:     #DC267F;
}
body[data-cb-preset="trit"] {
  /* Paul Tol muted (B/Y-safe). */
  --mc-role-repeater:  #CC6677;
  --mc-role-companion: #117733;
  --mc-role-room:      #882255;
  --mc-role-sensor:    #DDCC77;
  --mc-role-observer:  #AA4499;
  /* #1407 — companion / room / observer fail AA with dark text; flip to white. */
  --mc-role-repeater-text:  #1a1a1a;  /* 5.73:1 */
  --mc-role-companion-text: #ffffff;  /* 5.66:1 */
  --mc-role-room-text:      #ffffff;  /* 8.71:1 */
  --mc-role-sensor-text:    #1a1a1a;  /* 12.98:1 */
  --mc-role-observer-text:  #ffffff;  /* 5.25:1 */
  --mc-mb-confirmed:   #117733;
  --mc-mb-suspected:   #DDCC77;
  --mc-mb-unknown:     #CC6677;
}
body[data-cb-preset="achromat"] {
  /* Pure luminance ramp at 20/35/50/70/90% — relies on #1356/#1357 carriers. */
  --mc-role-repeater:  #333333;
  --mc-role-companion: #595959;
  --mc-role-room:      #808080;
  --mc-role-sensor:    #b3b3b3;
  --mc-role-observer:  #e6e6e6;
  /* #1407 — original bug: dark text on all 5 grays failed AA on 3 of 5.
   * Pair each gray with the text color that wins ≥4.5:1; L=50% mid-gray
   * needs pure black (#1a1a1a yields 4.41, #fff yields 3.95 — neither
   * passes; black yields 5.32). */
  --mc-role-repeater-text:  #ffffff;  /* 12.63:1 */
  --mc-role-companion-text: #ffffff;  /* 7.00:1 */
  --mc-role-room-text:      #000000;  /* 5.32:1 */
  --mc-role-sensor-text:    #1a1a1a;  /* 8.30:1 */
  --mc-role-observer-text:  #1a1a1a;  /* 13.94:1 */
  --mc-mb-confirmed:   #b3b3b3;
  --mc-mb-suspected:   #808080;
  --mc-mb-unknown:     #595959;
}

.mc-cluster-wrap { background: transparent !important; border: 0 !important; }
.mc-cluster {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: var(--font, system-ui, sans-serif);
  background: var(--mc-cluster-fill);
  color: var(--mc-cluster-text); text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  border: 2px solid var(--mc-cluster-border);
  /* Dark halo + soft shadow — audit fix so the border edge is visible vs Carto-light */
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.35);
  cursor: pointer;
  transition: transform 120ms ease;
}
.mc-cluster:hover { transform: scale(1.06); }
/* Border-style ramp is the redundant non-color carrier of the count bucket. */
.mc-cluster.mc-sm { width: 40px; height: 40px; border-width: 1.5px; border-style: solid; }
.mc-cluster.mc-md { width: 48px; height: 48px; border-width: 2.5px; border-style: solid; }
.mc-cluster.mc-lg { width: 56px; height: 56px; border-width: 2px;   border-style: double; }
.mc-cluster .mc-count { font-size: 0.875rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.mc-cluster.mc-lg .mc-count { font-size: 1rem; }
.mc-cluster .mc-pills {
  display: flex; gap: 2px; margin-top: 3px;
}
.mc-cluster .mc-pill {
  display: inline-block; min-width: 12px; padding: 1px 3px;
  border-radius: 3px;
  /* #1364: removed the prior `max-width` cap — it clamped the BOX
     (including the 1px 3px padding) to ~2.5ch of text, ellipsizing `R60`
     to `R…`. JS in map.js already caps counts at "999+" (max 5 chars:
     `R999+`), which is the load-bearing safety. `overflow:hidden` +
     `text-overflow:ellipsis` stay as belt-only graceful-degrade if the
     JS cap is ever bypassed. */
  overflow: hidden; text-overflow: ellipsis;
  /* #1407 — pill text color now reads --mc-pill-text (set per-pill via the
     role-* selectors below), with a #1a1a1a fallback for any caller that
     forgets to set the role class. This replaces the hardcoded `#1a1a1a`
     that broke WCAG 1.4.3 AA on the achromat preset for 3 of 5 grays.
     The Wong (#1357) audit conclusion still holds for the default preset
     because --mc-role-X-text defaults to #1a1a1a in :root.
     Sized in rem (0.625rem = 10px @ default 16px root) so user
     font-size preferences scale the pill (SC 1.4.4 Resize Text 200%). */
  font: 700 0.625rem/1.1 ui-monospace, "SF Mono", Consolas, monospace;
  letter-spacing: 0;
  color: var(--mc-pill-text, #1a1a1a); text-align: center; text-shadow: none;
  border: 1px solid rgba(0,0,0,0.25);
  /* #1360: overflow:hidden + text-overflow:ellipsis above bound the pill
     when counts approach the 4-char cap ("999+"). Acceptable tradeoff vs.
     SC 1.4.12 letter-spacing clipping: text content is the role letter +
     <=4 digits, far short of needing aggressive letter-spacing overrides. */
}
/* #1407 — per-role pill text color, sourced from --mc-role-*-text vars set
 * by cb-presets.js applyPreset() (and the body[data-cb-preset=...] CSS
 * blocks above). The role-<r> class is emitted by makeClusterIcon in
 * public/map.js, so each pill picks the correct foreground for its bg. */
.mc-cluster .mc-pill.role-repeater  { color: var(--mc-role-repeater-text,  #1a1a1a); }
.mc-cluster .mc-pill.role-companion { color: var(--mc-role-companion-text, #1a1a1a); }
.mc-cluster .mc-pill.role-room      { color: var(--mc-role-room-text,      #1a1a1a); }
.mc-cluster .mc-pill.role-sensor    { color: var(--mc-role-sensor-text,    #1a1a1a); }
.mc-cluster .mc-pill.role-observer  { color: var(--mc-role-observer-text,  #1a1a1a); }

/* V3 — multi-byte hash labels: neutral fill + colored 3px left border */
.mc-mb-label {
  background: var(--mc-mb-fill);
  color: var(--mc-mb-text);
  /* Sized in rem (0.75rem = 12px @ default root) so user font-size
     preferences scale the label per SC 1.4.4 Resize Text 200%. */
  font: 600 0.75rem/1.2 ui-monospace, "SF Mono", Consolas, monospace;
  letter-spacing: 0.02em;
  padding: 2px 5px 2px 4px;
  border-left: 3px solid transparent;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.35);
  white-space: nowrap;
  text-align: center;
  line-height: 1.2;
}
.mc-mb-label.status-confirmed { border-left-color: var(--mc-mb-confirmed); }
.mc-mb-label.status-suspected { border-left-color: var(--mc-mb-suspected); }
.mc-mb-label.status-unknown   { border-left-color: var(--mc-mb-unknown);   }
/* #807: hash size unknown (no advert known) — the label shows the 1-byte
   prefix plus an ellipsis; a dashed outline in the label's own text colour
   keeps it from reading as a confirmed 1-byte repeater. */
.mc-mb-label.hs-unknown {
  font-style: italic;
  outline: 1px dashed currentColor;
  outline-offset: -1px;
}

/* Forced-colors / Windows High Contrast — degrade gracefully (audit item 7). */
@media (forced-colors: active) {
  .mc-cluster, .mc-pill, .mc-mb-label {
    forced-color-adjust: auto;
    background: Canvas;
    color: CanvasText;
    border-color: CanvasText;
  }
}

/* === #1034 PR1: Channel Add modal + sectioned sidebar === */
.ch-add-channel-btn {
  background: var(--accent-strong, #2563eb); color: var(--text-on-accent, #f9fafb); border: none;
  padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.ch-add-channel-btn:hover { background: var(--palette-blue-700, #1d4ed8); }

.ch-modal-overlay { z-index: 1100; }
.ch-modal-overlay.hidden { display: none; }
.ch-modal { width: 560px; max-width: 92vw; padding: 24px 24px 16px; position: relative; }
.ch-modal h3 { margin: 0 0 16px; font-size: 18px; }
.ch-modal-close {
  position: absolute; top: 10px; right: 10px;
  background: transparent; border: none; cursor: pointer;
  font-size: 18px; color: var(--text-muted); padding: 4px 8px; border-radius: 6px;
}
.ch-modal-close:hover { background: var(--row-hover, rgba(0,0,0,0.05)); color: var(--text); }
.ch-modal-section { padding: 12px 0; border-top: 1px solid var(--border); }
.ch-modal-section:first-of-type { border-top: none; padding-top: 0; }
.ch-modal-section-title { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
.ch-modal-section-hint { margin: 0 0 10px; font-size: 12px; color: var(--text-muted); }
.ch-modal-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.ch-modal-input {
  flex: 1; min-width: 0; padding: 7px 10px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--input-bg, var(--card-bg)); color: var(--text);
}
.ch-modal-input--mono { font-family: var(--mono, monospace); }
.ch-modal-btn-secondary {
  background: var(--card-bg); color: var(--text);
  border: 1px solid var(--border); padding: 7px 12px;
  border-radius: 6px; cursor: pointer; font-size: 13px;
}
.ch-modal-btn-secondary[disabled] { opacity: .5; cursor: not-allowed; }
.ch-hashtag-row .ch-hashtag-prefix {
  font-family: var(--mono, monospace); font-size: 14px; color: var(--text-muted); padding: 0 2px;
}
.ch-modal-warn { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.ch-modal-warn code { background: var(--row-hover, rgba(0,0,0,0.05)); padding: 1px 4px; border-radius: 3px; font-size: 11px; }
.ch-modal-error { color: var(--status-red, #dc2626); font-size: 12px; margin-top: 4px; }
.ch-modal-footer {
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-muted); line-height: 1.4;
}
.ch-modal-callout {
  margin: 10px 0 14px; padding: 10px 12px; border-radius: 6px;
  background: var(--warn-bg, #fef3c7); color: var(--warn-text, #92400e);
  border: 1px solid var(--warn-border, #fcd34d);
  font-size: 13px; line-height: 1.4;
}
.ch-section-locality {
  font-size: 12px; font-weight: 500; text-transform: none;
  letter-spacing: 0; color: var(--text-muted); opacity: 0.85;
  margin-left: 4px;
}
.ch-qr-output { font-size: 11px; font-family: var(--mono, monospace); color: var(--text-muted); word-break: break-all; min-height: 14px; padding: 4px 0; }

/* #1087 polish: dedicated Share modal styling. Mirrors .ch-modal* tokens. */
.ch-share-modal { max-width: 480px; }
.ch-share-modal-title { margin: 0 0 12px; font-size: 16px; font-weight: 600; }
.ch-share-modal-body { display: flex; flex-direction: column; gap: 12px; }
.ch-share-qr {
  display: flex; align-items: center; justify-content: center;
  min-height: 120px; padding: 8px;
  background: var(--bg-secondary, rgba(0,0,0,0.02));
  border: 1px solid var(--border); border-radius: 6px;
}
.ch-share-field-group { display: flex; flex-direction: column; gap: 4px; }
.ch-share-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.ch-share-row { display: flex; gap: 6px; align-items: center; }
.ch-share-row .ch-modal-input { flex: 1; min-width: 0; }
.ch-share-error {
  color: var(--status-red, #dc2626); font-size: 13px; line-height: 1.4;
  padding: 8px 12px; text-align: center;
}

.ch-section { margin-bottom: 8px; }
.ch-section-header {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-muted);
  background: transparent; border: none; width: 100%; text-align: left; cursor: default;
}
.ch-section-toggle { cursor: pointer; }
.ch-section-toggle:hover { color: var(--text); }
.ch-section-empty { padding: 8px 12px; font-size: 12px; color: var(--text-muted); font-style: italic; }
.ch-section-caret { display: inline-block; width: 10px; }

/* ── Filter UX (issue #966) ────────────────────────────────────────────── */
.fux-bar { display: flex; gap: 6px; margin-top: 4px; align-items: center; flex-wrap: wrap; position: relative; }
.fux-help-btn,
.fux-saved-trigger { background: var(--input-bg); color: var(--text); border: 1px solid var(--border); border-radius: 4px; padding: 2px 8px; font-size: 12px; cursor: pointer; }
.fux-help-btn:hover,
.fux-saved-trigger:hover { background: var(--bg-hover, var(--surface)); }

.fux-popover { position: fixed; top: 60px; right: 24px; width: min(720px, 92vw); max-height: 80vh; overflow: auto; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,0.35); z-index: var(--z-modal); padding: 0; }
/* #1122: when help is opened inside .modal-overlay (real modal/backdrop),
   reset the absolute positioning so the flex-centered overlay places it.
   Also neutralise .modal default padding so the sticky header sits flush. */
.modal-overlay > .fux-popover { position: relative; top: auto; right: auto; left: auto; bottom: auto; padding: 0; max-width: min(720px, 92vw); width: min(720px, 92vw); }
.modal.fux-popover { padding: 0; }
.fux-help-overlay { z-index: var(--z-modal); }
/* #1124: keep the help modal inside the viewport. The backdrop alone is
 * enough visual separation; rows underneath stay rendered. */
.modal-overlay > .fux-popover { max-height: 80vh; overflow-y: auto; }

/* #1124 (MAJOR-1): overflow pill rendered when path chips exceed the
 * row's height cap. Visual style mirrors the #1056 TableResponsive pill. */
.path-overflow-pill {
  display: inline-flex; align-items: center;
  flex: 0 0 auto;
  margin-left: 4px;
  padding: 1px 6px;
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  /* The pill is the last flex item, after the chips that overflow, so on its
   * own it sat past the clipped edge of .path-hops and never showed (#217).
   * Stick it to the right edge, over the last chip. */
  position: sticky; right: 0; z-index: 1;
}
/* Opaque on hover: the pill sits over the last chip, and --bg-hover is a
 * translucent tint that let the chip show through. */
.path-overflow-pill:hover, .path-overflow-pill:focus-visible { color: var(--text); background: var(--row-hover); border-color: var(--accent); }
.path-popover {
  position: absolute; z-index: var(--z-popover);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  padding: 8px 10px; max-width: min(480px, calc(100vw - 32px)); max-height: min(420px, 60vh); overflow: auto;
  font-family: var(--mono); font-size: 12px;
}
.path-popover .path-popover-title { font-family: var(--font); font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.path-popover .hop, .path-popover .hop-named { white-space: nowrap; }
/* Full path, one hop per line (packets.js _pathPopoverHtml). Each hop sits in
 * its own .path-hops so chips keep their table styling, minus the 120px cap:
 * the popover exists to show the names the table had to cut. */
.path-popover-list { list-style: none; margin: 0; padding: 0; }
.path-popover-list li { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.path-popover-idx { min-width: 2ch; text-align: right; color: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.path-popover .path-hops, .path-popover .path-hops .hop-named { max-width: none; }
.fux-popover-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.fux-popover-close { background: transparent; border: none; color: var(--text-muted); font-size: 16px; cursor: pointer; padding: 0 4px; }
.fux-popover-close:hover { color: var(--text); }
.fux-popover-body { padding: 12px 16px; font-size: 13px; }
.fux-popover-body h3,
.fux-popover-body h4 { margin: 12px 0 6px; }
.fux-table { width: 100%; border-collapse: collapse; font-size: 12px; margin: 4px 0 12px; }
.fux-table th,
.fux-table td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.fux-table th { color: var(--text-muted); font-weight: 600; }
.fux-mono { font-family: var(--mono); font-size: 12px; }
.fux-examples { margin: 4px 0; padding-left: 20px; }
.fux-examples li { margin: 2px 0; }

.fux-ac-dropdown { position: absolute; left: 0; right: 0; top: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; max-height: 280px; overflow-y: auto; z-index: var(--z-dropdown); box-shadow: 0 4px 12px rgba(0,0,0,0.25); margin-top: 2px; }
.fux-ac-item { padding: 4px 10px; display: flex; justify-content: space-between; gap: 12px; cursor: pointer; font-size: 12px; }
.fux-ac-item:hover,
.fux-ac-item.active { background: var(--bg-hover, rgba(120,160,255,0.12)); }
.fux-ac-val { font-family: var(--mono); color: var(--text); }
.fux-ac-desc { color: var(--text-muted); font-size: 11px; max-width: 60%; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.fux-ctx-menu { position: absolute; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; box-shadow: 0 4px 14px rgba(0,0,0,0.35); z-index: var(--z-tooltip); min-width: 200px; padding: 4px 0; }
.fux-ctx-item { display: block; width: 100%; text-align: left; background: transparent; border: none; color: var(--text); padding: 5px 12px; font-size: 12px; cursor: pointer; font-family: var(--mono); }
.fux-ctx-item:hover { background: var(--bg-hover, rgba(120,160,255,0.12)); }

/* #72: the Saved trigger sits at the right end of the filter row — anchor right and bound the width so long expressions ellipsize instead of widening #pktLeft. */
.fux-saved-menu { position: absolute; top: 100%; right: 0; width: max-content; min-width: 320px; max-width: min(480px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; z-index: var(--z-dropdown); box-shadow: 0 4px 14px rgba(0,0,0,0.3); margin-top: 4px; padding: 4px 0; }
.fux-saved-menu.hidden { display: none; }
.fux-saved-header { padding: 6px 10px; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--border); }
.fux-saved-item { display: flex; align-items: center; gap: 8px; padding: 5px 10px; cursor: pointer; font-size: 12px; }
.fux-saved-item:hover { background: var(--bg-hover, rgba(120,160,255,0.12)); }
.fux-saved-name { font-weight: 600; min-width: 120px; }
.fux-saved-expr { color: var(--text-muted); font-size: 11px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fux-saved-del { background: transparent; border: none; color: var(--text-muted); font-size: 12px; cursor: pointer; padding: 0 4px; }
.fux-saved-del:hover { color: var(--status-red, #ef4444); }
.fux-saved-footer { border-top: 1px solid var(--border); padding: 4px 0; }
.fux-saved-save { display: block; width: 100%; text-align: left; background: transparent; border: none; color: var(--text); padding: 6px 10px; font-size: 12px; cursor: pointer; }
.fux-saved-save:hover { background: var(--bg-hover, rgba(120,160,255,0.12)); }

td[data-filter-field] { cursor: context-menu; }

/* === Issue #1064 — Edge-swipe nav drawer ============================
 * Slide-over from the LEFT edge. Z-index sits ABOVE bottom-nav (1200)
 * but BELOW modal (var(--z-modal) = 9100). Fenced for parallel-PR
 * coordination with #1062 (gesture handlers / swipe-affordance section).
 * --------------------------------------------------------------------- */

/* `pan-y` lets vertical scroll work everywhere; the drawer claims
 * horizontal swipes inside our viewport. iOS browser back-swipe (system
 * left-edge gesture) still works — it's at the OS layer, above the page.
 *
 * Mesh-Op review (PR #1184): scope this to wide viewports only. At
 * ≤768px the drawer is `display:none` (Option A), so this rule does
 * nothing useful and would block horizontal panning gestures the future
 * gesture system (#1185) might want to claim. */
@media (min-width: 769px) {
  body { touch-action: pan-y; }
}

.nav-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1250; /* above bottom-nav (1200), below modal-backdrop (9000) */
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}
.nav-drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.nav-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(320px, 86vw);
  max-width: 360px;
  background: var(--surface);
  color: var(--text);
  border-right: 1px solid var(--border);
  box-shadow: 4px 0 18px rgba(0, 0, 0, 0.35);
  z-index: 1260; /* above its backdrop, still below modal */
  transform: translateX(-100%);
  transition: transform 220ms cubic-bezier(0.2, 0.7, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  outline: none;
}
.nav-drawer.is-open { transform: translateX(0); }

.nav-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  /* nav-drawer.css paints the title and close button with --nav-text(-muted),
     so the header sits on the nav colours in every theme (#150). */
  background: var(--nav-bg2);
}
.nav-drawer-title {
  font-weight: 700;
  font-size: var(--fs-md);
  color: var(--text);
  letter-spacing: 0.02em;
}
.nav-drawer-close {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  touch-action: manipulation;
}
.nav-drawer-close:hover,
.nav-drawer-close:focus-visible {
  background: var(--bg-hover, rgba(120, 160, 255, 0.12));
  outline: none;
}

.nav-drawer-list {
  display: flex;
  flex-direction: column;
  padding: 6px 0;
  overflow-y: auto;
  flex: 1;
}
.nav-drawer-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  color: var(--text);
  text-decoration: none;
  font-size: var(--fs-md);
  min-height: 48px;
  touch-action: manipulation;
}
.nav-drawer-item:hover,
.nav-drawer-item:focus-visible {
  background: var(--bg-hover, rgba(120, 160, 255, 0.12));
  outline: none;
}
.nav-drawer-icon {
  font-size: 18px;
  line-height: 1;
  width: 24px;
  text-align: center;
  flex: none;
}
.nav-drawer-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Option A: drawer is wide-only (>768px). At ≤768px the bottom-nav has
 * the More tab (PR #1174) — drawer is hidden + script bails on open(). */
@media (max-width: 768px) {
  .nav-drawer,
  .nav-drawer-backdrop { display: none !important; }
}

/* Reduced motion: instant snap, no transition. */
@media (prefers-reduced-motion: reduce) {
  .nav-drawer { transition: none; }
  .nav-drawer-backdrop { transition: none; }
}
/* === end #1064 ====================================================== */

/* === #1062 Touch Gestures ============================================
 * Visual affordances for touch-gestures.js. CSS variables only — no
 * hardcoded colors. body owns vertical scroll natively (touch-action: pan-y);
 * the bottom-nav opts out so we manage horizontal swipes on it.
 * ==================================================================== */
body { touch-action: pan-y; }
[data-bottom-nav] { touch-action: none; }

.row-swiping { transition: transform 180ms ease-out; }
.row-action-overlay {
  position: fixed;
  z-index: 1500;
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--card-bg, #1a1a1a);
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  opacity: 0;
  transform: translateX(40px);
  transition: opacity 180ms ease-out, transform 180ms ease-out;
  pointer-events: auto;
}
.row-action-overlay.row-action-overlay-open {
  opacity: 1;
  transform: translateX(0);
}
.row-action-overlay[hidden] { display: none; }
.row-action-btn {
  flex: 1 1 auto;
  background: transparent;
  border: none;
  color: var(--text, #e7e7e7);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  min-height: 48px;
  border-right: 1px solid var(--border, #333);
}
.row-action-btn:last-child { border-right: none; }
.row-action-btn:hover { background: var(--bg-hover, rgba(120, 160, 255, 0.12)); }
.row-action-btn:active { background: var(--accent-bg, rgba(0, 122, 255, 0.18)); }

@media (prefers-reduced-motion: reduce) {
  .row-swiping,
  .row-action-overlay { transition: none !important; }
}
/* === end #1062 ====================================================== */

/* === Issue #1065 — Gesture discoverability hints =================== */
/* width:fit-content makes the pill shrink to its content; without it
 * the wrap defaults to block (100% of body width). Combined with
 * .gesture-hint-bottom { left:50%; transform:translateX(-50%) } that
 * pushed the wrap off-screen-left on narrow viewports (#1065 follow-up).
 * Stacked just under the modal scrim (#818): a hint stays above the
 * page, the bottom nav and the drawers, but never covers a dialog on the
 * --z-modal scale (the Skraafoto viewer at 375x560 on a first visit).
 * The transient status UI at 9000 to 9999 (the warm-up banner, toasts,
 * the analytics warm-up pill) now lies above a hint, as it should.
 * Comments live ABOVE the rule body, not interleaved, because a stray
 * em-dash or sequence inside the body has historically caused some CSS
 * parsers to drop the entire rule from the CSSOM. */
.gesture-hint {
  position: fixed;
  z-index: calc(var(--z-modal-backdrop) - 1);
  width: -moz-fit-content;
  width: fit-content;
  max-width: 360px;
  pointer-events: none !important;
  opacity: 1;
  animation-name: gesture-hint-slide-in;
  animation-duration: 240ms;
  animation-timing-function: ease-out;
  animation-fill-mode: both;
  transition: opacity 320ms ease-out;
}
.gesture-hint-bottom {
  left: 50%;
  bottom: 80px;
  transform: translateX(-50%);
}
.gesture-hint-top {
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
}
.gesture-hint-top-left {
  left: 16px;
  top: 80px;
}
.gesture-hint-inner {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-2, #1a1a1a);
  color: var(--text, #e7e7e7);
  border: 1px solid var(--border, #333);
  border-radius: 999px;
  padding: 8px 8px 8px 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  font-size: 13px;
  line-height: 1.3;
}
.gesture-hint-text {
  white-space: normal;
}
.gesture-hint-dismiss {
  pointer-events: auto;
  background: var(--accent, #4a9eff);
  color: var(--accent-fg, #fff);
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  flex: 0 0 auto;
}
.gesture-hint-dismiss:hover { filter: brightness(1.1); }
.gesture-hint-fading { opacity: 0; }

@keyframes gesture-hint-slide-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.gesture-hint-top-left { animation-name: gesture-hint-fade-in; }
@keyframes gesture-hint-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .gesture-hint {
    animation-name: none !important;
    animation-duration: 0s !important;
  }
}
/* === end #1065 ====================================================== */

/* === #1367 Channels chat-app redesign (mobile) ====================== */
/* Mobile (<768px): flat chat-app row list. Full-width 80px rows with
   a hash-colored avatar, bold name, ellipsized last-message preview,
   and right-aligned relative timestamp. No inline action chips. */
.ch-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 80px; height: 80px; padding: 8px 12px;
  background: transparent; border: 0; border-bottom: 1px solid var(--border);
  text-align: left; cursor: pointer; color: var(--text);
  -webkit-tap-highlight-color: rgba(0,0,0,.08);
  touch-action: manipulation;
}
.ch-row:hover { background: var(--row-hover); }
.ch-row.selected { background: var(--selected-bg); }
.ch-row-avatar {
  width: 64px; height: 64px; flex: 0 0 64px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px; letter-spacing: 0.5px;
}
.ch-row-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ch-row-line1 {
  display: flex; align-items: baseline; gap: 8px;
  min-width: 0;
}
.ch-row-name {
  flex: 1 1 auto; min-width: 0;
  font-weight: 700; font-size: 15px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ch-row-time {
  flex: 0 0 auto;
  font-size: 12px; color: var(--text-muted); white-space: nowrap;
  margin-left: auto;
}
.ch-row-preview {
  font-size: 13px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Detail view chrome (mobile): back chevron + title. */
.ch-back {
  display: none; background: none; border: 0; cursor: pointer;
  color: var(--text); font-size: 24px; line-height: 1;
  min-width: 48px; min-height: 48px; padding: 0 8px;
  border-radius: 6px;
  align-items: center; justify-content: center;
  -webkit-tap-highlight-color: rgba(0,0,0,.08);
  touch-action: manipulation;
}
.ch-back:hover, .ch-back:focus { background: var(--row-hover); outline: none; }

/* Per-message structure additions (mobile + desktop): a colored
   reply-target prefix at the start of the bubble body. */
.ch-reply-target { font-weight: 700; }

/* Mobile-only layout swap: sidebar IS the full screen until a channel
   is opened, then the main pane slides over it. */
@media (max-width: 767px) {
  .ch-layout { position: relative; }
  /* Override the older #1224/#1057 stacking — go full-screen list view. */
  .ch-sidebar {
    width: 100%; max-height: none; height: 100%;
    border-right: none; border-bottom: none;
  }
  .ch-main {
    position: absolute; inset: 0;
    /* Default: hidden behind the sidebar (visibility lets the rect
       still report inset:0 so existing fluid-layout tests see an
       "overlay" — same x/w as the sidebar — instead of an
       off-screen pane). */
    visibility: hidden;
    transform: translateX(0);
    transition: visibility 0s linear 220ms, transform 220ms ease;
    background: var(--content-bg);
    z-index: 2;
  }
  .ch-layout.ch-detail-open .ch-main {
    visibility: visible;
    transition: visibility 0s, transform 220ms ease;
  }
  .ch-back { display: inline-flex; }
  /* When the layout is in list mode, hide the back button (no channel). */
  .ch-layout:not(.ch-detail-open) .ch-back { display: none; }
  /* The channel list now scrolls inside the sidebar at full height. */
  .ch-channel-list { padding-bottom: 24px; }
}
/* === end #1367 ====================================================== */
/* ─── #1374 packet-route map view ───────────────────────────────────
   Role-aware shape markers + sequence-number badges + directional
   arrows + collapsible legend. WCAG SC 1.3.1 / 1.4.3 / 1.4.11 AA.
   - Marker badge background uses --mc-route-badge-bg / -fg with measured
     contrast ≥ 7:1 against #1a1a1a text on Carto Positron AND Dark
     Matter (we burn-in #f8fafc fill + #0f172a text — both tiles).
   - Edges use a per-hop HSL gradient as REDUNDANT carrier; the sequence
     number badge is the primary order signal so colorblind users and
     forced-colors users still read the route.
   - `prefers-reduced-motion: reduce` disables marker focus pulse.
   - `forced-colors: active` strips role colors → uses CanvasText/Canvas.
   ----------------------------------------------------------------- */
:root {
  --mc-route-badge-bg: #f8fafc;
  --mc-route-badge-fg: #0f172a;
  --mc-route-badge-border: #1a1a1a;
  --mc-route-label-bg: #f8fafc;
  --mc-route-label-fg: #0f172a;
  --mc-route-label-border: #475569;
  --mc-route-legend-bg: rgba(248, 250, 252, 0.96);
  --mc-route-legend-fg: #0f172a;
  --mc-route-legend-border: #475569;
}
[data-theme="dark"] {
  --mc-route-legend-bg: rgba(15, 23, 42, 0.94);
  --mc-route-legend-fg: #f1f5f9;
  --mc-route-legend-border: #94a3b8;
}

.mc-route-marker-icon { background: transparent !important; border: none !important; }
.mc-route-marker {
  position: relative;
  display: inline-block;
  line-height: 0;
}
.mc-route-marker:focus {
  outline: 3px solid #06b6d4;
  outline-offset: 2px;
  border-radius: 50%;
}
.mc-route-marker.ch-unresolved {
  opacity: 0.65;
  filter: grayscale(0.8);
}
.mc-route-seq-badge {
  position: absolute;
  bottom: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  background: var(--mc-route-badge-bg);
  color: var(--mc-route-badge-fg);
  border: 1.5px solid var(--mc-route-badge-border);
  border-radius: 8px;
  font: 700 10px/14px system-ui, sans-serif;
  text-align: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
.mc-route-label-icon { background: transparent !important; border: none !important; }
.mc-route-label {
  display: inline-block;
  padding: 1px 6px;
  background: var(--mc-route-label-bg);
  color: var(--mc-route-label-fg);
  border: 1px solid var(--mc-route-label-border);
  border-radius: 3px;
  font: 600 11px/14px system-ui, sans-serif;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.mc-route-edge {
  fill: none;
}
.mc-route-legend {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 700;
  max-width: 240px;
  background: var(--mc-route-legend-bg);
  color: var(--mc-route-legend-fg);
  border: 1px solid var(--mc-route-legend-border);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  font: 12px/1.4 system-ui, sans-serif;
}
.mc-route-legend-toggle {
  display: block;
  width: 100%;
  padding: 6px 10px;
  background: transparent;
  color: inherit;
  border: 0;
  border-bottom: 1px solid var(--mc-route-legend-border);
  font: 700 12px/1.2 system-ui, sans-serif;
  text-align: left;
  cursor: pointer;
}
.mc-route-legend-toggle:focus { outline: 2px solid #06b6d4; outline-offset: 1px; }
.mc-route-legend-toggle[aria-expanded="false"] + .mc-route-legend-body { display: none; }
.mc-route-legend-body { padding: 8px 10px; }
.mc-route-legend-list { list-style: none; padding: 0; margin: 4px 0; }
.mc-route-legend-entry {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
}
.mc-route-legend-swatch svg { display: block; }
.mc-route-legend-glyph {
  display: inline-block;
  width: 14px;
  text-align: center;
  font-weight: 700;
  color: var(--mc-route-legend-fg);
}
.mc-route-legend-gradient {
  display: inline-block;
  width: 32px;
  height: 8px;
  border-radius: 2px;
  background: linear-gradient(90deg, hsl(152,70%,50%), hsl(18,70%,58%));
  border: 1px solid var(--mc-route-legend-border);
}
.mc-route-legend-section {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mc-route-legend-fg);
  opacity: 0.75;
}
.mc-route-resolved-badge {
  display: inline-block;
  padding: 2px 6px;
  margin-bottom: 4px;
  background: #fef3c7;
  color: #78350f;
  border: 1px solid #92400e;
  border-radius: 3px;
  font: 700 11px/14px system-ui, sans-serif;
}
.mc-route-context-label {
  position: absolute;
  top: 12px;
  left: 60px;
  z-index: 700;
  padding: 4px 8px;
  background: var(--mc-route-legend-bg);
  color: var(--mc-route-legend-fg);
  border: 1px solid var(--mc-route-legend-border);
  border-radius: 4px;
  font: 600 11px/1.3 system-ui, sans-serif;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}
.mc-route-popup .mc-route-popup-title {
  font: 700 13px/1.3 system-ui, sans-serif;
  margin-bottom: 4px;
  color: var(--text, #0f172a);
}
.mc-route-popup .mc-route-popup-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font: 11px/1.4 system-ui, sans-serif;
  color: var(--text-muted, #475569);
}
.mc-route-popup .mc-route-popup-row b,
.mc-route-popup .mc-route-popup-row code {
  color: var(--text, #0f172a);
}
.mc-route-popup-link {
  color: var(--accent, #0ea5e9);
  font-size: 11px;
  text-decoration: underline;
}

@media (prefers-reduced-motion: reduce) {
  .mc-route-marker,
  .mc-route-edge { transition: none !important; animation: none !important; }
}
@media (forced-colors: active) {
  .mc-route-marker svg circle,
  .mc-route-marker svg rect,
  .mc-route-marker svg polygon { stroke: CanvasText !important; }
  .mc-route-seq-badge,
  .mc-route-label,
  .mc-route-legend,
  .mc-route-context-label {
    background: Canvas !important;
    color: CanvasText !important;
    border-color: CanvasText !important;
  }
  .mc-route-edge { stroke: CanvasText !important; }
}

/* ===========================================================================
   Issue #1369 — embed mode (?embed=1 on /#/map and /#/channels)
   Hide all chrome for full-bleed cross-domain iframe embeds. body.embed is
   toggled in app.js navigate() based on shouldEmbedRoute().
   =========================================================================== */
body.embed .top-nav,
body.embed [data-bottom-nav],
body.embed .nav-drawer,
body.embed .nav-drawer-backdrop { display: none !important; }
body.embed { padding: 0 !important; margin: 0 !important; }
/* App container occupies full viewport in embed mode — top-nav (52px) and
   bottom-nav reserve are gone, so reclaim the full dvh. */
body.embed #app.app-fixed {
  height: 100vh !important;
  height: 100dvh !important;
}

/* #1504 — Path symbols legend disclosure (subtle inline key, shared by Packets + Nodes). */
.path-symbols-legend-wrapper {
  margin: 4px 0 6px;
  text-align: right;
}
.path-symbols-legend {
  position: relative; /* anchor for absolutely-positioned .path-legend-list */
  display: inline-block;
  margin-left: 6px;
  font-weight: normal;
  font-size: 11px;
  vertical-align: middle;
}
.path-symbols-legend > summary {
  display: inline-block;
  cursor: pointer;
  color: var(--text-muted, #888);
  list-style: none;
  border-bottom: 1px dotted currentColor;
  user-select: none;
}
.path-symbols-legend > summary::-webkit-details-marker { display: none; }
.path-symbols-legend > summary::marker { content: ''; }
.path-symbols-legend > summary::before { content: 'ⓘ '; opacity: 0.7; }
.path-symbols-legend[open] > summary { color: var(--text, inherit); }
.path-symbols-legend .path-legend-list {
  position: absolute;
  right: 0;
  width: max-content;
  max-width: min(360px, calc(100vw - 32px));
  text-align: left;
  z-index: 50;
  margin: 4px 0 0;
  padding: 8px 12px;
  list-style: none;
  background: var(--bg-card, var(--bg, #fff));
  border: 1px solid var(--border, #ddd);
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text, inherit);
}
.path-symbols-legend .path-legend-list li { padding: 2px 0; }
.path-symbols-legend .path-legend-glyph {
  display: inline-block;
  min-width: 1.6em;
  font-weight: 600;
}

/* ============================================================
 * warmup-banner.js (#1660) — global server warm-up status pill.
 * a11y: role="status" live region in JS; CSS makes it visible.
 * All colors via CSS variables — customizer-safe.
 * ============================================================ */
.warmup-banner {
  position: sticky;
  top: 0;
  z-index: 9000;
  background: var(--warn-bg, #fef3c7);
  color: var(--warn-text, #92400e);
  border-bottom: 1px solid var(--warning, #eab308);
  font-size: 0.9rem;
  line-height: 1.4;
  transition: opacity 0.4s ease, max-height 0.4s ease;
  opacity: 1;
  max-height: 240px;
  overflow: hidden;
}
.warmup-banner--hidden {
  opacity: 0;
  max-height: 0;
  border-bottom-width: 0;
  pointer-events: none;
}
.warmup-banner__inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.4rem 1rem;
}
.warmup-banner__list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.warmup-banner__item {
  margin: 0;
  padding: 0.1rem 0;
}

/* ============================================================
 * #1715 — Neighbor-graph role swatches (`#ngRoleChecks` labels).
 *
 * Replaces inline `style="color:#..."` spans (which bypassed the
 * theme tokens entirely and produced different contrast results
 * on light vs dark) with class-based DOM. The `--role-*` tokens
 * are defined per-theme in :root + [data-theme="dark"] above and
 * clear WCAG AA ≥4.5:1 against #ffffff (light) and #1a1a2e (dark).
 * Never reintroduce inline color hex on these swatches.
 * ============================================================ */
.role-swatch        { color: var(--text, inherit); }
.role-swatch--repeater  { color: var(--role-repeater); }
.role-swatch--companion { color: var(--role-companion); }
.role-swatch--room      { color: var(--role-room); }
.role-swatch--sensor    { color: var(--role-sensor); }
.role-swatch--observer  { color: var(--role-observer); }

/* ─── Privacy page (#/privacy, opt-in — see public/privacy.js) ─────────── */
.privacy-page { max-width: 760px; margin: 0 auto; padding: var(--space-lg, 24px) var(--space-md, 16px); line-height: 1.6; }
.privacy-page h2 { display: flex; align-items: center; gap: 8px; }
.privacy-page .privacy-h { margin: var(--space-lg, 24px) 0 var(--space-sm, 8px); padding-bottom: 4px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 6px; }
.privacy-page ul { padding-left: 1.3em; }
.privacy-page li { margin: 6px 0; }
.privacy-page a { color: var(--link-color); }

/* Scope audit keeps search/pagination stable and at most 50 rows mounted. */
.scope-audit-controls { display:flex; flex-wrap:wrap; align-items:center; gap:8px; margin:12px 0; }
.scope-audit-controls input { max-width:100%; padding:6px 8px; background:var(--bg-secondary); color:var(--text); border:1px solid var(--border); border-radius:4px; }
.scope-audit-table-wrap { overflow-x:auto; }
.scope-audit-chip { display:inline-block; margin:2px 4px 2px 0; padding:2px 5px; border:1px solid var(--border); border-radius:4px; }
.scope-audit-caution { color:var(--warning); }
#scopes-panel-audit .scope-audit-table { width:100%; min-width:900px; table-layout:fixed; }
#scopes-panel-audit .scope-audit-table th:nth-child(1) { width:20%; }
#scopes-panel-audit .scope-audit-table th:nth-child(2) { width:15%; }
#scopes-panel-audit .scope-audit-table th:nth-child(3) { width:25%; }
#scopes-panel-audit .scope-audit-table th:nth-child(4) { width:15%; }
#scopes-panel-audit .scope-audit-table th:nth-child(5) { width:25%; }
#scopes-panel-audit .scope-audit-table th,
#scopes-panel-audit .scope-audit-table td { white-space:normal; overflow:visible; text-overflow:clip; overflow-wrap:anywhere; vertical-align:top; }
/* #414 scope transport */
#scope-audit-intro p { margin:0 0 6px; }
.scope-audit-controls [hidden] { display:none; }
.scope-audit-selected { border-color:var(--accent); color:var(--accent); }
@media (max-width: 640px) {
  #scopes-panel-audit .scope-transport-table { min-width:0; table-layout:auto; }
  #scopes-panel-audit .scope-transport-table thead { display:none; }
  #scopes-panel-audit .scope-transport-table,
  #scopes-panel-audit .scope-transport-table tbody,
  #scopes-panel-audit .scope-transport-table tr,
  #scopes-panel-audit .scope-transport-table td { display:block; width:auto; }
  #scopes-panel-audit .scope-transport-table tr { border-bottom:1px solid var(--border); padding:6px 0; }
  #scopes-panel-audit .scope-transport-table td { border:0; padding:2px 4px; max-width:none; }
  #scopes-panel-audit .scope-transport-table td::before { content:attr(data-label); display:block; font-size:0.8em; color:var(--text-muted); }
  .scope-audit-transport .scope-audit-controls input { width:100%; }
}
/* end #414 */

/* Regions map: an observed-relay footprint, deliberately distinct from RF coverage. */
.regions-page { display: flex; flex-direction: column; height: 100%; min-height: 420px; padding: 16px; gap: 8px; }
.regions-page h1, .regions-page p { margin: 0; }
.regions-note { color: var(--text-muted); max-width: 85ch; }
.regions-controls { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.regions-controls label { display: flex; gap: 6px; align-items: center; min-width: 0; }
.regions-controls select, .regions-controls button { background: var(--surface); color: var(--text-primary); border: 1px solid var(--border); padding: 6px 8px; border-radius: 6px; }
.regions-controls select { max-width: 100%; }
.regions-controls button { cursor: pointer; }
.regions-status { color: var(--text-muted); min-height: 2.4em; }
.regions-snapshot, .regions-coverage, .regions-details { color: var(--text-muted); font-size: 0.85em; overflow-wrap: anywhere; }
.regions-details summary { cursor: pointer; }
.regions-details p { margin-top: 6px; }
.regions-coverage[data-coverage-state="partial"], .regions-coverage[data-coverage-state="unknown"], .regions-coverage[data-coverage-state="loading"] { border-left: 3px solid var(--warning); padding-left: 8px; }
.regions-snapshot:empty, .regions-coverage:empty { display: none; }
.regions-leaflet { flex: 1; min-height: 280px; border: 1px solid var(--border); border-radius: 8px; }
@media (max-width: 600px) {
  .regions-page { padding: 10px; overflow-y: auto; }
  .regions-controls { align-items: stretch; }
  .regions-controls label { flex: 1 1 140px; }
  .regions-controls select { min-width: 0; flex: 1; }
}

/* #614 — "new version available" notice (version-notice.js) */
.version-notice {
  position: fixed;
  left: 50%;
  bottom: calc(16px + var(--bottom-nav-reserve, 0px));
  transform: translateX(-50%);
  z-index: var(--z-popover, 300);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 12px;
  box-sizing: border-box;
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px var(--shadow);
  font-size: 14px;
}
.version-notice-btn {
  min-height: 32px;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.version-notice-reload {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--text-on-accent);
}
.version-notice-btn:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

/* #634 (upstream 2344): an unrendered chart canvas keeps its 300px intrinsic
   width, which overflowed the single-column grid on 320px screens. */
.obs-charts canvas { max-width: 100%; }

/* === #681 M4: Path profile tool (Map page) ===============================
 * The toggle sits under the map-controls gear; the panel is a bottom sheet
 * inside #map-wrap, so it never covers the bottom-nav (#app.app-fixed has
 * already subtracted --bottom-nav-reserve).
 *
 * Every interactive control is at least 48px in both axes — #235/#2078 and
 * #666/#667 are the history here — and the panel body is its own scroll box
 * with a max-height rather than simply tall, which is what #672 showed a
 * short landscape viewport needs for the last control to stay reachable.
 */
.map-profile-toggle {
  position: absolute;
  top: 54px;
  right: 10px;
  z-index: 1001;
  width: 48px;
  height: 48px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px var(--shadow);
}
.map-profile-toggle:hover { background: var(--row-hover); }
.map-profile-toggle:focus-visible { outline: 2px solid var(--accent, var(--link-color)); outline-offset: 2px; }
.map-profile-toggle.active { background: var(--selected-bg); border-color: var(--los-line); }
/* A mouse does not need a 48px target; keep the gear and the ruler the same
   size on pointer-precise devices. */
@media (pointer: fine) {
  .map-profile-toggle { top: 54px; width: 36px; height: 36px; }
}
#mapSidePane ~ .map-profile-toggle { right: calc(32px + 10px); transition: right 0.2s; }
#mapSidePane.expanded ~ .map-profile-toggle { right: calc(320px + 10px); }
@media (max-width: 640px) {
  #mapSidePane ~ .map-profile-toggle,
  #mapSidePane.expanded ~ .map-profile-toggle { right: 10px; }
}

.map-profile-hint {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1002;
  max-width: min(90%, 420px);
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: var(--fs-sm);
  box-shadow: 0 2px 6px var(--shadow);
  text-align: center;
}
.map-profile-hint[hidden] { display: none; }
/* #839 §7: a profile link that could not be read. */
.map-profile-hint.is-error { border-color: var(--danger); border-left-width: 4px; }
.leaflet-container.tp-picking { cursor: crosshair; }

.tp-path-line { stroke: var(--los-line); stroke-opacity: 0.95; }
.tp-path-ghost { stroke: var(--los-line); stroke-opacity: 0.55; }
/* #781: the chart cursor's point on the path. A ring in the panel's own
   surface colour keeps the dot readable on any tile. */
.tp-cursor-dot { fill: var(--tp-cursor-dot); stroke: var(--card-bg); }

/* #721: the draggable A/B ends. The icon box is the 48px touch target and
   stays transparent; the visible disc inside it is the same white-on-
   --accent-strong tag as the panel's A/B (4.83:1, see .tp-end-tag). */
.tp-end-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: grab;
  touch-action: none;
}
.tp-end-marker:focus-visible { outline: 2px solid var(--accent, var(--link-color)); outline-offset: -6px; border-radius: 50%; }
.tp-end-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--card-bg);
  background: var(--accent-strong);
  color: var(--text-on-accent);
  font-size: 13px;
  font-weight: var(--fw-semibold, 600);
  box-shadow: 0 2px 6px var(--shadow);
  pointer-events: none;
}
.leaflet-dragging .tp-end-marker,
.leaflet-container.tp-dragging { cursor: grabbing; }
.tp-end-marker.leaflet-drag-target .tp-end-dot { transform: scale(1.15); }

.tp-panel {
  /* The cap is a variable so the Map page can keep a linked path clear of
     the panel before the chart has grown it to the cap (#746). */
  --tp-panel-max-h: 420px;
  /* #839 §2: the map the open profile always leaves above it, so the path,
     its ends and the chart cursor's dot can be seen beside the chart. It is
     the fit's free strip (FIT_MIN_FREE_PX) plus its two margins; map.js
     reads both variables back for the fit (TerrainProfile.panelCap). */
  --tp-map-keep: 184px;
  --tp-panel-min-h: 120px;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1200;
  display: none;
  flex-direction: column;
  min-height: 0;
  /* Never taller than the map area minus a strip of map, and never taller
     than the chart plus its controls need; the body scrolls. */
  max-height: min(var(--tp-panel-max-h), max(var(--tp-panel-min-h), calc(100% - var(--tp-map-keep))));
  background: var(--card-bg);
  color: var(--text);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 24px var(--shadow);
}
.tp-panel.is-open { display: flex; }
/* The compact bar and the folded head are short; only the grown panel
   keeps the strip of map (#790 keeps them whole on any screen). */
.tp-panel.tp-compact,
.tp-panel.tp-folded { max-height: min(var(--tp-panel-max-h), calc(100% - 12px)); }
.tp-head {
  flex: 0 0 auto;
  display: flex;
  /* #796 F5: one line. The chips wrap inside .tp-chips, never the row, so
     Copy and Close always sit beside the title. */
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
}
.tp-title { flex: 0 0 auto; margin: 0; font-size: var(--fs-sm); font-weight: var(--fw-semibold, 600); white-space: nowrap; }
.tp-chips {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}
.tp-close {
  flex: 0 0 auto;
  margin-left: auto;
  min-width: 48px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  border-radius: 4px;
}
.tp-close:hover { color: var(--text); background: var(--row-hover); }
.tp-close:focus-visible { outline: 2px solid var(--accent, var(--link-color)); outline-offset: 2px; }

/* The scroll box. overscroll-behavior keeps a flick inside the panel from
   panning the map underneath it. */
.tp-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom, 0px));
}
.tp-chart { width: 100%; }
.tp-chart .tp-svg { width: 100%; height: 180px; display: block; }

/* The chart's text is HTML, not SVG <text>. The 820x300 viewBox is
   stretched to the panel width with preserveAspectRatio="none", which
   squashed every in-SVG label to about 3px tall on a 360px phone. These
   spans are positioned in percentages of the same box — exact, because
   the mapping is linear per axis — and render at a real font size. */
.tp-plot { position: relative; width: 100%; }
/* #781: the hover cursor. A horizontal drag along the chart moves it, a
   vertical one still scrolls the panel. */
.tp-plot[tabindex] { touch-action: pan-y; cursor: crosshair; border-radius: 4px; }
.tp-plot[tabindex]:focus-visible { outline: 2px solid var(--los-line); outline-offset: 2px; }
.tp-plot > .tp-cursor-readout {
  position: absolute;
  top: 4px;
  z-index: 1;
  padding: 3px 6px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--text);
  white-space: nowrap;
  pointer-events: none;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
}
.tp-plot > .tp-cursor-readout > div:first-child { font-weight: var(--fw-semibold, 600); }
.tp-plot > span {
  position: absolute;
  font-size: 11px;
  line-height: 1;
  color: var(--text-muted);
  white-space: nowrap;
  pointer-events: none;
  /* A halo in the panel's own surface colour: these labels float over the
     chart, and a tall profile can push the terrain fill under any of them. */
  text-shadow: 0 0 3px var(--card-bg), 0 0 3px var(--card-bg), 0 0 2px var(--card-bg);
}
/* Right-aligned into the plot's left gutter, centred on its gridline. */
.tp-ax-y { transform: translate(-100%, -50%); padding-right: 4px; }
.tp-ax-x0 { transform: translateY(-50%); }
.tp-ax-x1 { transform: translate(-100%, -50%); }
.tp-ax-gap { transform: translate(-50%, -100%); }
.tp-plot > .tp-pin-lab {
  position: absolute;
  font-size: 12px;
  line-height: 1;
  font-weight: var(--fw-semibold, 600);
  color: var(--text);
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 0 3px var(--card-bg), 0 0 3px var(--card-bg), 0 0 2px var(--card-bg);
}
.tp-pin-a { transform: translateY(-100%); }
.tp-pin-b { transform: translate(-100%, -100%); }
.tp-plot-msg {
  position: absolute;
  inset: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 12px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.tp-status { margin: 0; padding: 18px 8px; text-align: center; color: var(--text-muted); font-size: var(--fs-sm); }
.tp-detail { margin: 6px 0; font-size: var(--fs-sm); color: var(--text-muted); }
.tp-meta { margin: 6px 0 0; font-size: var(--fs-sm); color: var(--text-muted); }
/* The chart's footer: directly under the plot it credits, so the licence
   line is on screen with the chart rather than at the foot of a scroll box
   the viewer may never reach. */
.tp-credit-line { margin: 4px 0 0; font-size: 11px; line-height: 1.3; color: var(--text-muted); }
/* #738 M2 — the Copernicus credit of a mixed profile, under the DHM one;
   the full Art. 6(b) line folds out of "Full credit". */
.tp-credit-fill[hidden], .tp-mixed-note[hidden] { display: none; }
.tp-credit-full { margin: 0; font-size: 11px; line-height: 1.3; color: var(--text-muted); }
.tp-credit-more { cursor: pointer; color: var(--link-color, var(--accent)); width: max-content; }
.tp-credit-more:focus-visible { outline: 2px solid var(--accent, var(--link-color)); outline-offset: 2px; }
/* A touch target of its own on a phone, like the credit links (#711). */
@media (pointer: coarse) { .tp-credit-more { padding: 15px 0; } }
/* The note a mixed verdict carries: a caveat on the verdict, in the warn
   tone the other caveats use. */
.tp-mixed-note {
  margin: 2px 0 0;
  padding-left: 6px;
  border-left: 3px solid var(--warning);
  font-size: var(--fs-sm);
  line-height: 1.35;
  color: var(--text-muted);
}

.tp-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: var(--fw-medium, 500);
  border: 1px solid var(--border);
  background: var(--surface-2, var(--input-bg));
  color: var(--text);
}
.tp-chip-ok { border-color: var(--success); color: var(--success); }
.tp-chip-warn { border-color: var(--warning); color: var(--warning); }
.tp-chip-bad { border-color: var(--danger); color: var(--danger); }
.tp-chip-unknown { border-color: var(--border); color: var(--text-muted); }
/* Plan §3.2 — the caveat that rides alongside the verdict until the viewer
   has set both antenna heights. */
.tp-chip-assumed { border-color: var(--warning); color: var(--warning); font-style: italic; }
.tp-chip[hidden] { display: none; }
/* #729 — the surface (buildings/trees) verdict. It takes the warn tone from
   .tp-chip-warn, which is the same --warning pair the assumed caveat already
   holds to 4.5:1 in both themes; only the wrapping differs, because
   "Buildings/trees: Blocked" is the longest chip in the row. */
.tp-chip-surface { white-space: normal; }
/* #730 M3 — "Through trees" and its kin: trees mostly attenuate, so the
   chip is a milder caveat than a building's. The warn border keeps it a
   caveat; the text is the plain text colour, and the border dashed, so it
   reads quieter without colour alone. Never the ok or bad pair: it is
   not a second verdict (#729). */
.tp-chip-mild { border-color: var(--warning); border-style: dashed; color: var(--text); }
/* #724 M4 — the interference hint: a cellular transmitter in the 700/800/900
   MHz bands near an end. The antenna-site layer's interference colour, so
   the chip and the map ring read as one thing; the strong tier (within
   100 m) is filled. Its line under the detail text says what it means. */
.tp-chip-mast { border-color: var(--mast-interference); color: var(--mast-interference); white-space: normal; }
.tp-chip-mast-strong { background: var(--mast-interference); color: var(--surface-1, var(--card-bg)); }
.tp-mast-note {
  margin: 2px 0 0;
  padding-left: 6px;
  border-left: 3px solid var(--mast-interference);
  font-size: var(--fs-sm);
  line-height: 1.35;
  color: var(--text-muted);
}
.tp-mast-note[hidden] { display: none; }
/* #723 M3 — a protected ancient monument at an end. The chip takes the
   warn tone from .tp-chip-warn and sits under the detail line, above the
   note that carries the wording, the type and the distance; it is kept out
   of the title row so it can never wrap Copy/Close and push the chart
   down in a short landscape panel. */
.tp-chip-heritage { margin-top: 4px; white-space: nowrap; }
.tp-heritage-note {
  margin: 2px 0 0;
  padding-left: 6px;
  border-left: 3px solid var(--warning);
  font-size: var(--fs-sm);
  line-height: 1.35;
  color: var(--text-muted);
}
.tp-heritage-note[hidden] { display: none; }
.tp-heritage-warning { color: var(--text); font-weight: var(--fw-semibold, 600); }
.tp-heritage-credit { font-size: 11px; }
/* The line that explains what a surface verdict means for a radio link.
   Shown only with the chip it explains, so it is hidden by default. */
.tp-surface-note {
  margin: 2px 0 0;
  font-size: var(--fs-sm);
  line-height: 1.35;
  color: var(--text-muted);
}
.tp-surface-note[hidden] { display: none; }
/* #730 M3 — the band's legend under the chart, and the muted note of a
   partial classification. */
.tp-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  margin: 2px 0 0;
  font-size: 11px;
  line-height: 1.3;
  color: var(--text-muted);
}
.tp-legend-item { display: inline-flex; align-items: center; gap: 4px; }
.tp-swatch { display: inline-block; width: 12px; height: 8px; border-radius: 2px; }
.tp-swatch-b { background: var(--terrain-building); }
.tp-swatch-v { background: var(--terrain-vegetation); }
.tp-swatch-none { background: var(--terrain-clutter); }
.tp-class-note {
  margin: 2px 0 0;
  font-size: var(--fs-sm);
  line-height: 1.35;
  color: var(--text-muted);
  font-style: italic;
}
.tp-class-note[hidden] { display: none; }

/* #681 M5 — copy link sits left of close; the pair shares the auto margin. */
.tp-copy { margin-left: auto; }
.tp-copy + .tp-close { margin-left: 0; }
.tp-copy:disabled { opacity: 0.45; cursor: default; }
/* On a phone the title row cannot hold two chips and two 48 px buttons, and
   the close button used to wrap onto a line of its own. Keep the buttons
   beside the title and let the chip row take the second line instead. */
@media (max-width: 520px) {
  .tp-head { flex-wrap: wrap; }
  .tp-chips { order: 2; flex-basis: 100%; }
}
/* #790: while an end is still to be picked (A, B, or a pending Move A/B) the
   panel is a compact bar: title, the next step, Cancel and Close. The body
   and the copy button are [hidden] by terrain-profile.js and the chips
   leave the bar here, so a phone keeps the map above it free to tap. */
.tp-cancel { flex: 0 0 auto; margin-left: auto; }
/* .tp-close makes the copy button inline-flex, which beats [hidden]. */
.tp-copy[hidden] { display: none; }
.tp-panel.tp-compact .tp-chips { display: none; }
/* #790 F4: the title of a finished profile is the ▾/▴ fold toggle. It
   looks like the title, is 48 px tall, and costs the title row only the
   glyph. Folded, the body goes and the head keeps the title, the chips
   and the verdict as the status line. */
.tp-fold {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 48px;
  min-height: 48px;
  margin: 0;
  padding: 0 4px;
  background: none;
  border: none;
  border-radius: 4px;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.tp-fold[hidden] { display: none; }
.tp-fold-glyph { font-size: 14px; }
.tp-fold:hover { background: var(--row-hover); }
.tp-fold:focus-visible { outline: 2px solid var(--accent, var(--link-color)); outline-offset: 2px; }
.tp-pick-status {
  margin: 0;
  padding: 6px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  font-size: var(--fs-sm);
  color: var(--text);
}
.tp-copy-status { margin: 0; padding: 2px 8px; font-size: var(--fs-sm); color: var(--text-muted); }
.tp-copy-status:empty { display: none; }
/* Each credit link keeps the credit line's size, but gets a 48 px hit box
   from padding cancelled by negative margins, so the line height is not
   disturbed. position + z-index lift that padding band above the chart and
   the detail line it overlaps; without them it is a 48 px box but only a
   ~36-40 px target (#711). min-width alone gives a short mark its 48 px of
   width, so the band grows vertically only: #733 puts a second link (the
   dataset) on this line, and horizontal padding cancelled by a negative
   margin would make each link's box overlap its neighbour's by 4 px — the
   later one wins the hit test, and the earlier one is no longer 48 px of
   its own target. */
.tp-credit-link {
  position: relative;
  z-index: 1;
  display: inline-block;
  min-width: 48px;
  padding: 18px 0;
  margin: -18px 0;
  color: inherit;
  text-decoration: underline;
  text-align: center;
}
.tp-credit-link:focus-visible { outline: 2px solid var(--accent, var(--link-color)); outline-offset: -14px; }

/* Where the antenna height comes from: default / operator / yours / link. */
.tp-src-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tp-hbadge {
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 10px;
  font-size: 11px;
  line-height: 18px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--surface-2, var(--input-bg));
}
.tp-hbadge[hidden] { display: none; }
.tp-hbadge-default { border-style: dashed; border-color: var(--warning); color: var(--text); }
.tp-hbadge-operator { border-color: var(--accent, var(--link-color)); color: var(--text); }
.tp-hbadge-estimate { border-style: dashed; border-color: var(--accent, var(--link-color)); color: var(--text); }
.tp-hbadge-yours { border-color: var(--success); color: var(--text); }
.tp-hbadge-link { border-color: var(--border); color: var(--text); }

/* #681 M5 — "Terrain profile to…" on node detail: a 48 px target in both
   the side pane and the full page action row. */
.node-terrain-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 48px;
  min-width: 48px;
  padding: 4px 12px;
  margin-left: 4px;
  font-size: 12px;
  text-decoration: none;
  vertical-align: middle;
}
/* The side pane gives it a row of its own under the 20 px Details /
   Analytics / Reach buttons, rather than letting it wrap there and double
   the height of that row (#711). */
.node-detail-actions { margin: -4px 0 12px; }
.node-detail-actions:empty { display: none; }
.node-full-actions .node-terrain-action,
.node-detail-actions .node-terrain-action { margin-left: 0; }
.node-terrain-icon { display: inline-flex; }

/* #737 M2 — "Oblique photo": the node-detail button sits beside "Terrain
   profile to…" with the same 48 px target; in the Path profile a row of
   its own under the chart (A, B, the clicked chart point). */
.sf-icon { display: inline-flex; }
.tp-sf-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0 0; }
.tp-sf-row[hidden] { display: none; }
.tp-sf-label { font-size: var(--fs-sm); color: var(--text-muted); margin-right: 2px; }
.tp-sf-btn { min-width: 48px; }
/* #839 §12: why Chart point is off, visible on a touch screen too. */
.tp-sf-hint { font-size: var(--fs-sm); color: var(--text-muted); }
.tp-sf-hint[hidden] { display: none; }
/* Both open a dialog over themselves: the browser's tap highlight would
   be painted over the photo until the next touch. */
.tp-sf-btn, .sf-node-action { -webkit-tap-highlight-color: transparent; }

/* The viewer: a modal on the modal tokens, one step above a SlideOver
   panel (#180) so a deep link opened on a tablet stacks over it too, and
   so its scrim covers the bottom nav (1200) and the profile panel. On a phone the dialog stops at
   the bottom nav's reserve, so the nav never covers any of it; the dialog
   scrolls inside itself with the head (and Close) pinned. */
.sf-overlay {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-modal) + 1);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 12px calc(12px + var(--bottom-nav-reserve, 0px));
  background: var(--shadow);
}
@media (max-height: 480px), (max-width: 480px) {
  .sf-overlay { padding: 4px 4px calc(4px + var(--bottom-nav-reserve, 0px)); }
}
.sf-dialog {
  display: flex;
  flex-direction: column;
  width: min(100%, 760px);
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 10px);
  box-shadow: 0 16px 48px var(--shadow);
}
.sf-dialog:focus { outline: none; }
.sf-head {
  position: sticky;
  top: 0;
  z-index: 1;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 0 0 14px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}
.sf-titles { flex: 1 1 auto; min-width: 0; }
.sf-title { margin: 0; font-size: var(--fs-md); font-weight: var(--fw-semibold, 600); }
.sf-where { margin: 0; font-size: var(--fs-sm); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sf-close {
  flex: 0 0 auto;
  min-width: 48px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
}
.sf-close:hover { color: var(--text); background: var(--row-hover); }
.sf-controls { flex: 0 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 8px 14px; }
.sf-dirs { display: inline-flex; gap: 4px; }
.sf-dir {
  min-width: 44px;
  min-height: 44px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold, 600);
  cursor: pointer;
}
.sf-dir.active { background: var(--selected-bg); border-color: var(--accent); }
.sf-dir:disabled { opacity: 0.45; cursor: default; }
.sf-year-wrap { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text-muted); }
.sf-year-wrap[hidden] { display: none; }
.sf-year {
  min-width: 88px;
  min-height: 44px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);
  font-size: var(--fs-sm);
}
.sf-zoom {
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold, 600);
  cursor: pointer;
}
.sf-zoom[aria-pressed="true"] { background: var(--selected-bg); border-color: var(--accent); }
.sf-zoom:disabled { opacity: 0.45; cursor: default; }
.sf-close:focus-visible, .sf-dir:focus-visible, .sf-year:focus-visible, .sf-zoom:focus-visible, .sf-full:focus-visible, .sf-credit a:focus-visible {
  outline: 2px solid var(--accent, var(--link-color));
  outline-offset: 2px;
}
/* A column: the frame (empty while there is no photo) stacks above the
   status, which stays centred instead of beside it (#839). */
.sf-stage {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  margin: 0 14px;
  border-radius: 6px;
  background: var(--section-bg);
  overflow: hidden;
}
.sf-img { display: block; width: 100%; height: auto; max-height: min(62vh, 680px); object-fit: contain; }
/* A short (landscape) screen: the whole photo fits under the head and the
   controls, so it is seen without scrolling; the rest scrolls below it. */
@media (max-height: 480px) {
  .sf-img { max-height: calc(100vh - var(--bottom-nav-reserve, 0px) - 128px); }
  .sf-controls { padding: 4px 14px; }
}
.sf-img[hidden], .sf-status[hidden], .sf-full[hidden] { display: none; }
/* #737 M3c: the marks layer covers the image element exactly and, with
   xMidYMid meet, letterboxes as its object-fit: contain does, so the
   crosshair and the line stay on the photo through any resize. */
.sf-frame { position: relative; width: 100%; }
.sf-marks { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: hidden; }
.sf-marks[hidden] { display: none; }
.sf-marks line, .sf-marks polyline { fill: none; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.sf-cross-halo, .sf-los-halo { stroke: var(--card-bg); stroke-width: 5; opacity: 0.85; }
.sf-cross-line { stroke: var(--danger); stroke-width: 2.5; }
.sf-cross-approx .sf-cross-line { stroke-dasharray: 3 3; }
.sf-los { stroke: var(--accent); stroke-width: 2.5; stroke-dasharray: 8 5; }
/* #839: the drop from the crosshair (the ground) up to the line (antenna height). */
.sf-drop-halo { stroke: var(--card-bg); stroke-width: 4; opacity: 0.85; }
.sf-drop { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 1 4; }
.sf-status { margin: 0; padding: 24px 16px; text-align: center; font-size: var(--fs-sm); color: var(--text-muted); }
.sf-dialog[data-state="error"] .sf-status { color: var(--danger); }
.sf-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 12px; margin: 4px 14px 0; font-size: var(--fs-sm); }
.sf-full { display: inline-flex; align-items: center; min-height: 44px; color: var(--link-color, var(--accent)); font-weight: var(--fw-semibold, 600); }
.sf-los-note, .sf-note, .sf-credit { margin: 2px 14px 0; font-size: 12px; line-height: 1.35; color: var(--text-muted); }
.sf-credit { margin-bottom: 12px; }
.sf-credit a { color: inherit; text-decoration: underline; }
/* A touch target of their own on a phone, like the profile's credit links (#711). */
@media (pointer: coarse) { .sf-credit a { display: inline-block; min-width: 44px; padding: 12px 0; text-align: center; } }

.tp-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: flex-start;
  margin-top: 8px;
}
.tp-field { display: flex; flex-direction: column; gap: 4px; min-width: 160px; }
.tp-field-label { font-size: 11px; color: var(--text-muted); }
.tp-end-head { display: flex; align-items: baseline; gap: 6px; }
/* The A/B tag is white text on a solid blue disc, so it follows the
   #1668 M2 rule for exactly that: --accent-strong (#2563eb in both themes)
   carries --text-on-accent at 4.83:1. --los-line is a *line* colour and
   lightens to #60a5fa on dark, where white on it is ~2.4:1 — a WCAG AA
   failure that axe only reports as "incomplete" because the disc is
   small and rounded. The chart's own A/B pins keep --los-line: they are
   the line, not text on it. */
.tp-end-tag {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent-strong); color: var(--text-on-accent, #fff);
  font-size: 11px; font-weight: var(--fw-semibold, 600);
}
.tp-end-name { font-size: var(--fs-sm); font-weight: var(--fw-medium, 500); word-break: break-word; }
.tp-assumed { font-size: 11px; color: var(--text-muted); }
.tp-assumed.is-assumed { font-style: italic; }

.tp-stepper { display: flex; align-items: stretch; gap: 4px; }
.tp-step {
  min-width: 48px;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.tp-step:hover { background: var(--row-hover); }
.tp-step:focus-visible,
.tp-height:focus-visible,
.tp-seg-btn:focus-visible,
.tp-cancel:focus-visible { outline: 2px solid var(--accent, var(--link-color)); outline-offset: 2px; }
.tp-height {
  width: 72px;
  min-height: 48px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);
  font-size: var(--fs-sm);
  text-align: center;
}
.tp-seg { display: flex; gap: 4px; flex-wrap: wrap; }
.tp-seg-btn,
.tp-cancel {
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);
  font-size: var(--fs-sm);
  cursor: pointer;
}
.tp-seg-btn.active { background: var(--selected-bg); border-color: var(--los-line); }
.tp-cancel:hover { background: var(--row-hover); }
.tp-seg-btn:disabled { opacity: 0.45; cursor: default; }
/* #721: Move A / Move B sit under their end's name; Swap between the ends. */
.tp-move { align-self: flex-start; min-width: 48px; }
.tp-swap-field { min-width: 0; align-self: center; }
.tp-swap { min-width: 48px; }

/* Short screens (#666/#672): the chart gives up height first, and the body
   still scrolls. */
@media (max-height: 560px) {
  .tp-chart .tp-svg { height: 108px; }
  .tp-head { padding: 2px 8px; }
}
@media (max-width: 600px) {
  .tp-field { min-width: 100%; }
  .tp-controls { gap: 8px; }
}
@media (max-width: 600px) and (max-height: 560px) {
  .tp-field { min-width: 46%; }
}
/* #839 §2: a short landscape screen has no height to spare for a strip of
   map above the grown panel, so the panel docks at the right, full height,
   and the path is fitted into the map beside it (--tp-dock, read by
   map.js). The compact bar and the folded head stay at the bottom (#790). */
/* Narrower still (568x320): no room to dock and no height for a strip
   without losing the chart (#723), so the grown panel takes nearly the
   whole map as before; folding it gives the map back. */
@media (max-height: 560px) and (orientation: landscape) and (max-width: 599px) {
  .tp-panel { --tp-map-keep: 12px; }
}
@media (max-height: 560px) and (orientation: landscape) and (min-width: 600px) {
  .tp-panel:not(.tp-compact):not(.tp-folded) {
    --tp-dock: right;
    top: 0;
    left: auto;
    width: min(60%, 460px);
    max-height: none;
    border-top: none;
    border-left: 1px solid var(--border);
    box-shadow: -8px 0 24px var(--shadow);
  }
}
