/* ============================================================
   Neuro Graph — Typography Redesign
   Token system: unified spacing, radius, color-opacity scale,
   and disciplined glow. Dark sci-fi aesthetic preserved.
   Type system: Space Grotesk (display/UI) + JetBrains Mono (metadata)
   ============================================================ */
:root {
    /* Base palette */
    --bg: #0a1128;
    --bg-deep: #050510;
    --bg-surface: #0f1a30;
    --bg-panel: rgba(10, 17, 40, 0.98);

    /* Accent — cyan used at varying opacity for hierarchy */
    --accent: #00ffff;
    --accent-bright: #5cffff;
    --accent-primary: rgba(0, 255, 255, 1);
    --accent-strong: rgba(0, 255, 255, 0.55);
    --accent-mid: rgba(0, 255, 255, 0.30);
    --accent-faint: rgba(0, 255, 255, 0.12);
    --accent-ghost: rgba(0, 255, 255, 0.06);

    --secondary: #0088ff;
    --secondary-mid: rgba(0, 136, 255, 0.35);

    /* Text */
    --text: rgba(220, 235, 245, 0.92);
    --text-accent: rgba(0, 255, 255, 0.85);
    --text-muted: rgba(140, 170, 190, 0.70);
    --text-faint: rgba(100, 130, 155, 0.55);

    /* Dividers */
    --divider: 1px solid rgba(0, 255, 255, 0.14);

    /* Spacing scale */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --panel-gap: var(--space-4);

    /* Radius scale */
    --radius-pill: 999px;
    --radius-card: 10px;
    --radius-control: 8px;
    --radius-modal: 14px;
    --radius-drawer: 20px;

    /* Glow */
    --glow-accent: 0 0 16px rgba(0, 255, 255, 0.20);
    --glow-active: 0 0 16px rgba(0, 255, 255, 0.35);
    --glow-panel: 0 0 24px rgba(0, 255, 255, 0.05);
    --glow-modal: 0 8px 40px rgba(0, 0, 0, 0.5), 0 0 30px rgba(0, 255, 255, 0.08);
    --glow-dot: 0 0 5px currentColor;

    /* Typography — two typeface system */
    --font-display: "Space Grotesk", system-ui, -apple-system, sans-serif;
    --font-mono: "JetBrains Mono", "SF Mono", "Fira Code", ui-monospace, monospace;
    --font: var(--font-mono);

    /* Type scale (1.25 ratio) */
    --fs-display: 28px;
    --fs-h1: 22px;
    --fs-h2: 17px;
    --fs-base: 14px;
    --fs-small: 13px;
    --fs-xs: 11px;
    --fs-xxs: 10px;

    /* Legacy aliases (for compatibility with neural-graph.js) */
    --fs-heading: var(--fs-h2);
    --fs-title: var(--fs-h1);
    --fs-label: var(--fs-small);

    /* Line heights */
    --lh-tight: 1.15;
    --lh-snug: 1.35;
    --lh-body: 1.55;
    --lh-relaxed: 1.7;
    --lh: var(--lh-body);

    /* Letter spacing */
    --ls-display: -0.02em;
    --ls-heading: -0.01em;
    --ls-body: 0;
    --ls-label: 0.02em;
    --ls-caps: 0.08em;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-display);
    font-size: var(--fs-base);
    line-height: var(--lh-body);
    letter-spacing: var(--ls-body);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

canvas {
    display: block;
    margin-right: 280px;
    margin-top: 56px;
    background: var(--bg-deep);
    touch-action: none;
    transition: margin-right 0.25s ease, margin-bottom 0.3s ease;
}
@media (max-width: 768px) {
    canvas { margin-right: 0; margin-bottom: 0; transition: margin-bottom 0.3s ease; }
    canvas.drawer-open { margin-bottom: 60vh; }
}

/* ---- Top filter bar ---- */
#filter-bar {
    position: fixed;
    top: 0; left: 0; right: 280px;
    height: 56px;
    background: rgba(10, 17, 40, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: var(--divider);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0 var(--space-5);
    z-index: 12;
    transition: right 0.25s ease;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}
#filter-bar::-webkit-scrollbar { display: none; }
#filter-bar .filter-btn { flex-shrink: 0; }
@media (max-width: 768px) { #filter-bar { right: 0; } }

.filter-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 7px 14px;
    border-radius: var(--radius-pill);
    cursor: pointer;
    font-size: var(--fs-small);
    font-family: var(--font-display);
    font-weight: 500;
    letter-spacing: var(--ls-label);
    white-space: nowrap;
    transition: background 0.18s, border-color 0.18s, color 0.18s;
}
.filter-btn:hover {
    color: var(--text);
    background: var(--accent-ghost);
}
.filter-btn:active { transform: translateY(0.5px); }
.filter-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #001215;
    font-weight: 600;
    box-shadow: var(--glow-accent);
}

/* ---- Drawer scrim ---- */
.drawer-scrim {
    display: none; position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 18; opacity: 0;
    transition: opacity 0.25s ease;
}
.drawer-scrim.is-open { display: block; opacity: 1; }
@media (min-width: 769px) { .drawer-scrim { display: none !important; } }

/* ---- Bottom drawer (mobile) ---- */
.bottom-drawer {
    display: none; position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--bg-surface);
    border-radius: var(--radius-drawer) var(--radius-drawer) 0 0;
    height: 50vh; max-height: 50vh;
    z-index: 25;
    flex-direction: column;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.45);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    overflow: hidden;
}
.bottom-drawer.open { display: flex; transform: translateY(0); }
@media (max-width: 768px) {
    .bottom-drawer {
        display: flex; flex-direction: column;
        transform: translateY(calc(100% - 80px));
        height: 60vh; max-height: 60vh;
    }
    .bottom-drawer.open { transform: translateY(0); height: 70vh; max-height: 70vh; }
}
.drawer-header {
    display: flex; align-items: center; justify-content: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4) 14px;
    flex-shrink: 0; position: relative;
    cursor: grab;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}
.drawer-header:active { cursor: grabbing; }
.drawer-handle {
    width: 44px; height: 4px;
    background: var(--accent-strong);
    border-radius: var(--radius-pill);
    flex-shrink: 0;
    box-shadow: 0 0 6px rgba(0, 255, 255, 0.2);
    pointer-events: none;
}

/* ---- Share modal ---- */
.share-modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 100;
    align-items: center; justify-content: center;
    padding: var(--space-5);
}
.share-modal-overlay.is-open { display: flex; }
.share-modal {
    background: var(--bg-surface);
    border: 1px solid var(--accent-mid);
    border-radius: var(--radius-modal);
    max-width: 420px; width: 100%;
    max-height: 85vh; overflow: hidden;
    display: flex; flex-direction: column;
    box-shadow: var(--glow-modal);
}
.share-modal h3 {
    padding: var(--space-4) var(--space-5) var(--space-2);
    color: var(--text);
    font-size: var(--fs-h1);
    font-weight: 700;
    letter-spacing: var(--ls-heading);
    margin: 0;
}
.share-modal .share-preview {
    padding: var(--space-3) var(--space-5);
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    line-height: var(--lh-relaxed);
    color: var(--text-muted);
    white-space: pre-wrap;
    word-break: break-all;
    overflow-y: auto;
    flex: 1; min-height: 0;
}
.share-modal .share-preview a { color: var(--accent-bright); text-decoration: underline; }
.share-modal .share-preview a:hover { color: #99ffff; }
.share-modal .share-actions {
    display: flex; gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-top: var(--divider);
}
.share-modal .share-actions button {
    flex: 1; padding: 10px var(--space-3);
    border-radius: var(--radius-control);
    font-family: var(--font-display);
    font-size: var(--fs-small); font-weight: 500;
    letter-spacing: var(--ls-label);
    cursor: pointer; border: 1px solid transparent;
    transition: background 0.18s, border-color 0.18s, color 0.18s;
}
.share-modal .share-actions .btn-copy {
    background: var(--accent-faint);
    color: var(--text-accent);
    border-color: var(--accent-mid);
}
.share-modal .share-actions .btn-copy:hover { background: var(--accent-strong); color: #001215; }
.share-modal .share-actions .btn-share {
    background: var(--accent);
    color: #001215; font-weight: 600;
    box-shadow: var(--glow-accent);
}
.share-modal .share-actions .btn-share:hover { box-shadow: var(--glow-active); }
.share-modal .share-actions .btn-close {
    background: transparent;
    color: var(--text-muted);
    border-color: rgba(140, 170, 190, 0.2);
}
.share-modal .share-actions .btn-close:hover { color: var(--text); border-color: rgba(140, 170, 190, 0.4); }

/* ---- Drawer content ---- */
.drawer-filters {
    display: flex; gap: var(--space-2);
    padding: 0 var(--space-4) var(--space-4);
    overflow-x: auto;
    border-bottom: var(--divider);
}
.drawer-content {
    flex: 1 1 0; min-height: 0;
    display: flex; flex-direction: column;
    overflow: hidden;
    padding: 0 var(--space-5) var(--space-6);
}
#drawerDetails {
    color: var(--text);
    font-size: var(--fs-xs);
    line-height: var(--lh-relaxed);
    padding-bottom: var(--space-6);
}
#drawerDetails .drawer-detail-heading {
    color: var(--text);
    font-size: var(--fs-h1);
    font-weight: 700;
    letter-spacing: var(--ls-heading);
    margin: 0 0 var(--space-2) 0;
}
#drawerDetails .drawer-detail-name {
    margin-bottom: var(--space-1);
    color: #ffff99; font-weight: 700;
}
#drawerDetails .drawer-detail-name img { width: 100%; height: auto; border-radius: var(--radius-control); margin-bottom: var(--space-2); }
#drawerDetails .drawer-detail-type {
    font-family: var(--font-mono);
    font-size: var(--fs-xxs);
    color: var(--text-accent);
    text-transform: uppercase;
    letter-spacing: var(--ls-caps);
    margin: var(--space-1) 0;
}
#drawerDetails .drawer-detail-desc {
    margin: var(--space-2) 0 var(--space-2) 0;
    color: var(--text-muted);
    font-style: italic; line-height: var(--lh-body);
}
#drawerDetails .drawer-detail-connections-heading {
    color: var(--text-accent); font-weight: 700;
    margin: 0 0 var(--space-1) 0;
    font-family: var(--font-mono);
    font-size: var(--fs-xxs);
    text-transform: uppercase;
    letter-spacing: var(--ls-caps);
}
#drawerDetails .drawer-detail-connections { font-size: var(--fs-xxs); color: var(--text-faint); }
#drawerDetails .drawer-detail-connections div { margin: var(--space-1) 0; }

.drawer-section { margin-bottom: var(--space-4); }
.drawer-section:last-child { margin-bottom: 0; }
.drawer-section.jump-to-node-section { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; margin-bottom: var(--space-4); }
.drawer-section.jump-to-node-section .drawer-section-title { flex-shrink: 0; }
.drawer-section-title {
    color: var(--text-accent);
    font-size: var(--fs-small);
    margin: 0 0 var(--space-2) 0;
    font-weight: 600;
    letter-spacing: var(--ls-label);
}
.drawer-node-list {
    display: flex; flex-direction: column;
    gap: var(--space-2);
    flex: 1 1 0; min-height: 200px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.drawer-node-list .filter-node {
    display: block; width: 100%; text-align: left;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-control);
    border: 1px solid var(--accent-mid);
    background: var(--accent-faint);
    color: inherit;
    font-size: var(--fs-small);
    cursor: pointer; font-family: inherit;
    transition: background 0.18s, border-color 0.18s;
}
.drawer-node-list .filter-node:hover {
    background: var(--accent-strong);
    border-color: var(--accent);
}
.drawer-node-list h4 { font-size: var(--fs-small); margin: var(--space-3) 0 var(--space-1) 0; }
.drawer-node-list h4:first-child { margin-top: 0; }
.drawer-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.drawer-action-btn {
    padding: 10px 14px;
    border-radius: var(--radius-control);
    font-size: var(--fs-small); font-weight: 500;
    letter-spacing: var(--ls-label);
    cursor: pointer; border: none; font-family: inherit;
}
.drawer-action-btn.primary { background: var(--accent-faint); color: var(--text-accent); }
.drawer-action-btn.primary:hover { background: var(--accent-strong); }
.drawer-legend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2) var(--space-4); }
.drawer-legend-grid .legend-item { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-xs); }
.drawer-legend-grid .legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* Drawer meta (hash + date) - visible on mobile inside drawer */
.drawer-meta {
    flex-shrink: 0;
    padding: var(--space-3) 0 var(--space-2);
    margin-top: auto;
    border-top: var(--divider);
    font-size: var(--fs-xs);
    font-family: var(--font-mono);
    color: var(--text-faint);
    word-break: break-all;
}
.drawer-meta-row { margin: var(--space-1) 0; }
.drawer-meta-label { color: var(--text-faint); }
.drawer-meta-hash { word-break: break-all; }

/* ---- Fixed hash overlay (desktop) ---- */
.fixed-hash-overlay {
    position: fixed;
    bottom: var(--space-3);
    left: var(--space-3);
    font-size: var(--fs-xs);
    color: var(--text-muted);
    z-index: 20;
}
.fixed-hash-overlay-inner {
    font-size: 9px;
    color: var(--text-faint);
    font-family: var(--font-mono);
    word-break: break-all;
    max-width: 240px;
}

/* On mobile hide fixed hash/date overlay (shown in drawer instead) */
@media (max-width: 768px) {
    #fixed-hash-overlay,
    #memory-version { display: none !important; }
}

/* Show drawer on mobile only */
@media (max-width: 768px) {
    #detailPanel { display: none !important; }
}
@media (min-width: 769px) {
    .bottom-drawer { display: none !important; }
}

/* ---- Info panel (right side) ---- */
#info {
    --panel-divider: var(--divider);
    position: fixed; right: 0; top: 0;
    width: 280px; height: 100vh;
    background: var(--bg-panel);
    padding: var(--space-5) var(--space-5);
    border-left: 1px solid var(--accent-strong);
    font-size: var(--fs-base);
    overflow: hidden;
    box-shadow: var(--glow-panel);
    z-index: 10;
    display: flex; flex-direction: column;
    min-height: 100vh;
    gap: 0;
    transition: transform 0.25s ease, width 0.25s ease;
}
@media (max-width: 768px) {
    #info {
        position: fixed; bottom: 0; right: 0; left: 0; top: auto;
        width: 100%; height: auto;
        min-height: 60vh; max-height: 70vh;
        border-left: none;
        border-top: 1px solid var(--accent-strong);
        border-radius: var(--radius-drawer) var(--radius-drawer) 0 0;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    #info.open { transform: translateY(0); }
    #panel-toggle { display: none !important; }
}
#info.collapsed { transform: translateX(100%); pointer-events: none; }

/* Panel toggle tab */
#panel-toggle {
    position: fixed; right: 280px; top: 50%;
    transform: translateY(-50%);
    z-index: 11;
    width: 28px; height: 48px;
    border: 1px solid var(--accent-strong);
    border-right: none;
    border-radius: var(--radius-control) 0 0 var(--radius-control);
    background: rgba(10, 17, 40, 0.95);
    color: var(--text-accent);
    font-size: 14px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--glow-panel);
    transition: right 0.25s ease, background 0.2s, border-color 0.2s;
}
#panel-toggle:hover { background: var(--accent-faint); border-color: var(--accent); }
#info.collapsed ~ #panel-toggle { right: 0; }

/* Panel layout */
#info .panel-top { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: var(--panel-gap); overflow: hidden; }
#info .panel-top .panel-top-content { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: var(--panel-gap); overflow: hidden; }
#info .panel-top .panel-top-content > .filter-section:first-of-type { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
#info .panel-top .panel-top-content > .filter-section:has(.filter-list) { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
#info .panel-top .panel-buttons { flex: 0 0 auto; }
#info .accordion-body-actions .panel-buttons { padding-top: var(--space-2); border-top: none; }
#info .panel-legend { flex: 0 0 auto; padding-top: var(--panel-gap); border-top: var(--panel-divider); }

/* Panel header */
.panel-header { margin-bottom: var(--space-1); }
.panel-header h3 {
    margin: 0 0 var(--space-1) 0;
    color: var(--text);
    font-family: var(--font-display);
    font-size: var(--fs-display);
    font-weight: 700;
    letter-spacing: var(--ls-display);
    line-height: var(--lh-tight);
}
.panel-header .tagline {
    color: var(--secondary);
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    letter-spacing: var(--ls-label);
    text-transform: uppercase;
    margin: 0;
}
.panel-status {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    margin: 0; min-height: 1.4em;
    color: var(--text-muted);
}
.panel-status .stat {
    color: #ffff88;
    font-weight: 700;
}
.panel-meta {
    display: flex; align-items: center;
    gap: var(--space-2); flex-wrap: wrap;
    font-family: var(--font-mono);
    font-size: var(--fs-xxs);
    color: var(--secondary);
    letter-spacing: var(--ls-label);
    margin: 0;
}
.panel-meta .stat { color: var(--text-accent); font-weight: 700; }

/* Global h3 */
h3 {
    margin: 0 0 var(--space-2) 0;
    color: var(--text);
    font-family: var(--font-display);
    font-size: var(--fs-h2);
    font-weight: 600;
    letter-spacing: var(--ls-heading);
    line-height: var(--lh-snug);
}
p { margin: 0; line-height: var(--lh-body); }

/* Primary buttons (Actions section) */
button.primary {
    background: var(--accent);
    color: #001215;
    padding: 10px var(--space-4);
    border: 0;
    cursor: pointer;
    border-radius: var(--radius-control);
    font-weight: 600;
    font-size: var(--fs-small);
    font-family: var(--font-display);
    letter-spacing: var(--ls-label);
    transition: background 0.18s, box-shadow 0.18s, transform 0.18s;
    width: 100%;
    box-shadow: var(--glow-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}
button.primary:hover {
    box-shadow: var(--glow-active);
    transform: translateY(-1px);
}
button.primary:active { transform: translateY(0); }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
button.primary svg {
    width: 14px; height: 14px;
    flex-shrink: 0;
}

/* Stat (global) */
.stat {
    color: var(--text-accent);
    font-weight: 700;
}
.desc { color: var(--secondary); font-size: var(--fs-xxs); font-family: var(--font-mono); }

/* Collapsible sections */
.collapsible-trigger {
    background: none;
    border: none;
    color: var(--text);
    font-size: var(--fs-small);
    font-weight: 600;
    letter-spacing: var(--ls-label);
    cursor: pointer;
    width: 100%;
    text-align: left;
    padding: var(--space-2) 0;
    display: flex; align-items: center; justify-content: space-between;
    font-family: var(--font-display);
    margin: 0;
    transition: color 0.18s;
}
.collapsible-trigger:hover { color: var(--accent-bright); }
.collapsible-body {
    max-height: 0; overflow: hidden;
    transition: max-height 0.2s ease;
}
.collapsible-body.open { max-height: 120px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.collapsible-body.open.legend-open { max-height: 140px; }
.collapsible-body.timeline-body.open { max-height: min(320px, 50vh); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.accordion-body-detail.open { max-height: min(400px, 50vh); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.accordion-body-actions.open { max-height: 180px; overflow: visible; }

/* Every collapsible section gets a consistent top divider + gap */
.filter-section { padding-top: var(--panel-gap); border-top: var(--divider); }

/* Filter toggle (Jump to node) */
.filter-toggle {
    background: none; border: none;
    color: var(--text);
    font-size: var(--fs-small);
    font-weight: 600;
    letter-spacing: var(--ls-label);
    cursor: pointer; width: 100%; text-align: left;
    padding: var(--space-2) 0;
    display: flex; align-items: center; justify-content: space-between;
    font-family: var(--font-display); margin: 0;
    flex-shrink: 0;
    transition: color 0.18s;
}
.filter-toggle:hover { color: var(--accent-bright); }
.filter-list {
    max-height: 0; overflow: hidden;
    transition: max-height 0.25s ease;
    flex: 0 0 auto;
}
.filter-list.open {
    flex: 1 1 0; min-height: 0;
    margin-top: var(--space-2);
    max-height: none;
    overflow-x: hidden; overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}
.filter-category {
    margin-top: var(--space-3);
    font-family: var(--font-mono);
    font-size: var(--fs-xxs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: var(--ls-caps);
    padding-left: 8px;
    border-left: 2px solid var(--cat-color, var(--secondary));
    padding-bottom: 2px;
    margin-bottom: var(--space-1);
}
.filter-category:first-child { margin-top: var(--space-1); }
.filter-node {
    display: block; width: 100%; text-align: left;
    padding: 5px var(--space-2) 5px 10px;
    margin: 1px 0;
    border: none;
    border-left: 2px solid var(--cat-color, var(--accent-mid));
    border-radius: 0 var(--radius-control) var(--radius-control) 0;
    font-size: var(--fs-small);
    font-family: var(--font-display);
    cursor: pointer;
    background: var(--accent-ghost);
    color: inherit;
    transition: background 0.18s, border-color 0.18s;
}
.filter-node:hover { background: var(--accent-faint); border-left-color: var(--cat-color, var(--accent)); }

/* Legend */
.legend-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-1) var(--space-3);
    font-size: var(--fs-xs);
    font-family: var(--font-mono);
    letter-spacing: var(--ls-label);
}
.legend-item { display: flex; align-items: center; gap: var(--space-2); }
.legend-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: var(--glow-dot);
}

/* ---- Detail panel (desktop) ---- */
#detailPanel {
    flex: 1 1 auto;
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    padding-top: var(--panel-gap);
    border-top: var(--panel-divider);
    -webkit-overflow-scrolling: touch;
}
#detailPanel.is-empty { display: none; }
#detailPanel .detail-inner { font-size: var(--fs-xs); line-height: var(--lh-relaxed); }

/* Panel buttons wrapper */
.panel-buttons {
    padding-top: var(--panel-gap);
    border-top: var(--divider);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}