:root {
    /* Darkened background colors by 30% */
    --page-bg: #0a0c10;
    --page-bg-soft: #0d0f16;
    --panel: rgba(16, 18, 28, 0.95);
    --panel-strong: #0f121a;
    --graph-bg: #0a0e15;
    --border: #2a3347;
    --border-strong: #3d4f72;
    --text: #e6e6ec;
    --muted: #7a8aad;
    --accent: #355073;
    --accent-soft: rgba(53, 80, 115, 0.3);
    --resource-fill: #131a26;
    --subsystem-fill: #1a2435;
    --read: #4d8fdc;
    --write: #6ca8e6;
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.45);

    /* Primary data series - high saturation, high contrast */
    --color-primary: #3a6fc7;
    --color-primary-light: #5d8fdc;
    --color-primary-dark: #1f4a87;
    
    /* Secondary data series */
    --color-secondary: #b04d56;
    --color-secondary-light: #d27880;
    --color-secondary-dark: #7a343b;
    
    /* Tertiary data series */
    --color-tertiary: #6f9657;
    --color-tertiary-light: #80b06f;
    --color-tertiary-dark: #4d6a3a;
    
    /* Quaternary data series */
    --color-quaternary: #b88a5b;
    --color-quaternary-light: #d4b888;
    --color-quaternary-dark: #7d5f3e;
    
    /* Quinary data series */
    --color-quinary: #9f52b4;
    --color-quinary-light: #bc7dd1;
    --color-quinary-dark: #6d387c;
    
    /* Senary data series */
    --color-senary: #3e8e96;
    --color-senary-light: #6caeb5;
    --color-senary-dark: #2a6268;
    
    /* Septenary data series */
    --color-septenary: #a0714d;
    --color-septenary-light: #c49076;
    --color-septenary-dark: #6f4e35;
    
    /* Octonary data series */
    --color-octonary: #3e4554;
    --color-octonary-light: #5c6370;
    --color-octonary-dark: #2a2e38;

    /* Graph element colors - mapped to data types - Darkened */
    --graph-bar-1: #3a6fc7;
    --graph-bar-2: #b04d56;
    --graph-bar-3: #6f9657;
    --graph-bar-4: #b88a5b;
    --graph-bar-5: #9f52b4;
    --graph-bar-6: #3e8e96;
    --graph-bar-7: #a0714d;
    --graph-bar-8: #3e4554;
    
    /* Line chart colors */
    --graph-line-1: #3a6fc7;
    --graph-line-2: #b04d56;
    --graph-line-3: #6f9657;
    --graph-line-4: #b88a5b;
    --graph-line-5: #9f52b4;
    --graph-line-6: #3e8e96;
    
    /* Data point colors */
    --graph-point-1: #5d8fdc;
    --graph-point-2: #d27880;
    --graph-point-3: #80b06f;
    --graph-point-4: #d4b888;
    --graph-point-5: #bc7dd1;
    --graph-point-6: #6caeb5;
    
    /* Pie chart segment colors */
    --pie-segment-1: #3a6fc7;
    --pie-segment-2: #b04d56;
    --pie-segment-3: #6f9657;
    --pie-segment-4: #b88a5b;
    --pie-segment-5: #9f52b4;
    --pie-segment-6: #3e8e96;
    --pie-segment-7: #a0714d;
    --pie-segment-8: #3e4554;
    
    /* Subdued/secondary element colors */
    --subdued-1: #3e4554;
    --subdued-2: #323842;
    --subdued-3: #262c36;
    
    /* Gradient definitions */
    --gradient-primary: linear-gradient(135deg, #3a6fc7 0%, #1f4a87 100%);
    --gradient-secondary: linear-gradient(135deg, #b04d56 0%, #7a343b 100%);
    --gradient-success: linear-gradient(135deg, #6f9657 0%, #4d6a3a 100%);
    --gradient-warning: linear-gradient(135deg, #b88a5b 0%, #7d5f3e 100%);
    --gradient-info: linear-gradient(135deg, #3e8e96 0%, #2a6268 100%);
    
    /* Node type colors - Darkened */
    --node-subsystem: #1a2435;
    --node-subsystem-light: #24344a;
    --node-subsystem-border: #3d4f72;
    --node-field: #131a26;
    --node-field-light: #1a2435;
    --node-field-border: #2a3347;
    
    /* Edge colors - Darkened */
    --edge-read: #4d8fdc;
    --edge-read-light: #6ca8e0;
    --edge-write: #6ca8e6;
    --edge-write-light: #8fc4f0;
    
    /* Legend colors - Darkened */
    --legend-color-1: #3a6fc7;
    --legend-color-2: #6f9657;
    --legend-color-3: #b88a5b;
    --legend-color-4: #9f52b4;
    --legend-color-5: #3e8e96;
    --legend-color-6: #b04d56;
    
    /* Accessibility - WCAG AA compliant contrast indicators */
    --high-contrast-text: #ffffff;
    --medium-contrast-text: #e0e6f0;
    --low-contrast-text: #9aa6c3;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--page-bg-soft);
    overflow: hidden;
}

body {
    display: flex;
    flex-direction: column;
}

body {
    min-height: 100vh;
}

.app {
    height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 12px;
    padding: 12px;
    overflow: hidden;
}

.topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px 20px;
    margin: 0 auto;
    width: min(100%, 1680px);
    max-width: 1680px;
    padding: 12px 16px;
    border: 1px solid rgba(76, 92, 126, 0.6);
    border-radius: 18px;
    background: rgba(17, 21, 31, 0.84);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.title-block {
    max-width: 760px;
}

.eyebrow,
.panel-kicker,
.control-label {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.title-block h1 {
    margin: 0;
    font-size: clamp(1.4rem, 2vw, 2.2rem);
    line-height: 1;
    letter-spacing: -0.03em;
}

.subhead {
    margin: 6px 0 0;
    max-width: 60ch;
    font-size: 1rem;
    line-height: 1.45;
    color: var(--muted);
}

.toolbar {
    display: grid;
    gap: 12px;
    justify-items: end;
    min-width: 310px;
}

.toolbar-group {
    display: grid;
    gap: 8px;
    justify-items: end;
}

.model-selector {
    min-width: 200px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(24, 31, 45, 0.92);
    color: var(--text);
    font: inherit;
    font-size: 1.14rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa6c3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

.model-selector:hover {
    transform: translateY(-1px);
    border-color: var(--border-strong);
    background: #20293b;
}

.model-selector:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}

.model-selector option {
    background: var(--panel-strong);
    color: var(--text);
    padding: 10px;
}

.counts {
    font-size: 1.08rem;
    font-weight: 700;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 2.5fr) minmax(320px, 0.7fr);
    grid-template-rows: 1fr;
    gap: 16px;
    max-width: 1920px;
    margin: 0 auto;
    width: min(100%, 1920px);
    min-height: 0;
    max-height: 100%;
}

.graph-shell,
.details-panel {
    border: 1px solid rgba(76, 92, 126, 0.5);
    border-radius: 22px;
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
    min-height: 0;
    overflow: hidden;
}

.graph-shell {
    display: flex;
    flex-direction: column;
    padding: 16px;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
    background: var(--graph-bg);
    position: relative;
}

.graph-shell #graph {
    flex: 1;
    min-height: 0;
}

/* Graph loader - subtle loading indicator in top right corner */
.graph-loader {
    position: absolute;
    top: 24px;
    right: 24px;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

.graph-loader.visible {
    opacity: 1;
    visibility: visible;
}

.loader-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.graph-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 14px;
    padding: 2px 2px 12px;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(24, 31, 45, 0.92);
    font-size: 1.08rem;
    transition: transform 140ms ease, border-color 140ms ease;
}

.legend-item:hover {
    transform: translateY(-1px);
    border-color: var(--border-strong);
}

.legend-item strong {
    font-size: 1.08rem;
}

/* Legend color indicators - distinct colors for different data series */
.legend-line {
    width: 26px;
    height: 3px;
    border-radius: 999px;
    background: var(--read);
}

.legend-line.read {
    background: var(--edge-read);
}

.legend-line.write {
    background: var(--edge-write);
}

/* Multi-color legend for data series */
.legend-line.series-1 {
    background: var(--legend-color-1);
}

.legend-line.series-2 {
    background: var(--legend-color-2);
}

.legend-line.series-3 {
    background: var(--legend-color-3);
}

.legend-line.series-4 {
    background: var(--legend-color-4);
}

.legend-line.series-5 {
    background: var(--legend-color-5);
}

.legend-line.series-6 {
    background: var(--legend-color-6);
}

/* Legend with gradient indicator */
.legend-line.gradient {
    background: var(--gradient-primary);
}

/* Legend with dot indicator */
.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.legend-dot.series-1 {
    background: var(--legend-color-1);
}

.legend-dot.series-2 {
    background: var(--legend-color-2);
}

.legend-dot.series-3 {
    background: var(--legend-color-3);
}

.legend-dot.series-4 {
    background: var(--legend-color-4);
}

.legend-dot.series-5 {
    background: var(--legend-color-5);
}

.legend-dot.series-6 {
    background: var(--legend-color-6);
}

/* Data series legend container */
.legend-series {
    display: inline-flex;
    gap: 4px;
    padding: 6px 10px;
}

.legend-series .legend-line {
    width: 18px;
    height: 3px;
    border-radius: 2px;
}

/* === Comprehensive Legend Styles === */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.legend-section {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(24, 31, 45, 0.7);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.legend-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text);
    margin-right: 4px;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.92rem;
    color: var(--muted);
}

.legend-item strong {
    font-size: 0.95rem;
    color: var(--text);
    margin-left: 2px;
}

/* Legend line (edge) indicators */
.legend-line {
    width: 24px;
    height: 3px;
    border-radius: 2px;
}

.legend-line.read {
    background: var(--edge-read);
}

.legend-line.write {
    background: var(--edge-write);
}

/* Legend box for node types */
.legend-box {
    width: 20px;
    height: 14px;
    border-radius: 3px;
    border-width: 2px;
    border-style: solid;
}

.legend-box.subsystem {
    background: var(--node-subsystem);
    border-color: var(--node-subsystem-border);
}

.legend-box.field {
    background: var(--node-field);
    border-color: var(--node-field-border);
}

/* Border thickness for importance levels */
.legend-border-thick {
    width: 24px;
    height: 8px;
    border-radius: 2px;
    background: var(--color-primary);
    border: 3px solid var(--color-primary-dark);
}

.legend-border-thin {
    width: 24px;
    height: 8px;
    border-radius: 2px;
    background: var(--subdued-1);
    border: 1px solid var(--subdued-3);
}

/* Color key grid for palette */
.legend-colors {
    flex-direction: column;
    align-items: flex-start;
}

.color-key-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 6px 0;
}

.color-key-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    color: var(--muted);
}

.color-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(255,255,255,0.2);
}

.legend-hint {
    font-size: 0.8rem;
    color: var(--muted);
    font-style: italic;
}

/* Compact legend styles */
.graph-meta.compact {
    padding: 4px 0;
    gap: 6px;
}

.graph-meta.compact .legend {
    gap: 8px;
}

.legend-section.compact {
    padding: 4px 8px;
    gap: 4px;
    font-size: 0.8rem;
}

.legend-section.compact .legend-title {
    font-size: 0.75rem;
    margin-right: 2px;
}

.legend-section.compact .legend-item {
    font-size: 0.75rem;
    gap: 4px;
}

.legend-section.compact .legend-line {
    width: 16px;
    height: 2px;
}

.legend-dot {
    width: 14px;
    height: 10px;
    border-radius: 2px;
    border: 2px solid;
}

.legend-dot.subsystem {
    background: var(--color-primary);
    border-color: var(--color-primary-dark);
}

.legend-dot.field {
    background: var(--color-secondary);
    border-color: var(--color-secondary-dark);
}

.color-key-mini {
    display: flex;
    gap: 2px;
}

.color-key-mini span {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    font-size: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.graph-help.compact {
    font-size: 0.8rem;
    padding: 4px 0;
}

/* === Visual Hierarchy Styles === */
/* Key/primary data points - highlighted with glow effect */
.key-node,
.key-element {
    position: relative;
}

.key-node::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 8px;
    background: transparent;
    box-shadow: 0 0 12px 2px var(--color-primary);
    opacity: 0.4;
    pointer-events: none;
}

/* Secondary/subdued elements */
.subdued-element {
    opacity: 0.65;
}

/* Node importance indicators */
.node-importance-high {
    border-color: var(--color-primary) !important;
    box-shadow: 0 0 8px var(--color-primary);
}

.node-importance-medium {
    border-color: var(--color-tertiary) !important;
}

.node-importance-low {
    border-color: var(--subdued-1) !important;
    opacity: 0.85;
}

/* === Graph Element Colors === */
/* Bar chart colors */
.graph-bar {
    transition: fill 200ms ease, stroke 200ms ease;
}

.graph-bar:hover {
    filter: brightness(1.15);
}

.graph-bar.series-1 { fill: var(--graph-bar-1); stroke: var(--graph-bar-1); }
.graph-bar.series-2 { fill: var(--graph-bar-2); stroke: var(--graph-bar-2); }
.graph-bar.series-3 { fill: var(--graph-bar-3); stroke: var(--graph-bar-3); }
.graph-bar.series-4 { fill: var(--graph-bar-4); stroke: var(--graph-bar-4); }
.graph-bar.series-5 { fill: var(--graph-bar-5); stroke: var(--graph-bar-5); }
.graph-bar.series-6 { fill: var(--graph-bar-6); stroke: var(--graph-bar-6); }
.graph-bar.series-7 { fill: var(--graph-bar-7); stroke: var(--graph-bar-7); }
.graph-bar.series-8 { fill: var(--graph-bar-8); stroke: var(--graph-bar-8); }

/* Line chart colors */
.graph-line {
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.graph-line.series-1 { stroke: var(--graph-line-1); }
.graph-line.series-2 { stroke: var(--graph-line-2); }
.graph-line.series-3 { stroke: var(--graph-line-3); }
.graph-line.series-4 { stroke: var(--graph-line-4); }
.graph-line.series-5 { stroke: var(--graph-line-5); }
.graph-line.series-6 { stroke: var(--graph-line-6); }

/* Data point colors */
.graph-point {
    stroke: var(--graph-bg);
    stroke-width: 2;
}

.graph-point.series-1 { fill: var(--graph-point-1); }
.graph-point.series-2 { fill: var(--graph-point-2); }
.graph-point.series-3 { fill: var(--graph-point-3); }
.graph-point.series-4 { fill: var(--graph-point-4); }
.graph-point.series-5 { fill: var(--graph-point-5); }
.graph-point.series-6 { fill: var(--graph-point-6); }

/* Pie segment colors */
.pie-segment {
    stroke: var(--graph-bg);
    stroke-width: 2;
    transition: transform 150ms ease, filter 150ms ease;
}

.pie-segment:hover {
    transform: scale(1.03);
    filter: brightness(1.1);
}

.pie-segment.series-1 { fill: var(--pie-segment-1); }
.pie-segment.series-2 { fill: var(--pie-segment-2); }
.pie-segment.series-3 { fill: var(--pie-segment-3); }
.pie-segment.series-4 { fill: var(--pie-segment-4); }
.pie-segment.series-5 { fill: var(--pie-segment-5); }
.pie-segment.series-6 { fill: var(--pie-segment-6); }
.pie-segment.series-7 { fill: var(--pie-segment-7); }
.pie-segment.series-8 { fill: var(--pie-segment-8); }



.graph-help {
    margin: 0;
    max-width: 56ch;
    color: var(--muted);
    font-size: 1.12rem;
    line-height: 1.4;
}

#graph {
    min-height: 0;
    height: 100%;
    background: var(--graph-bg);
    overflow: hidden;
    touch-action: none;
    overscroll-behavior: contain;
    -webkit-user-select: none;
    user-select: none;
    position: relative;
    outline: none;
}

#graph:focus,
#graph:focus-visible {
    outline: none;
    box-shadow: none;
}

.details-panel {
    display: grid;
    grid-template-rows: auto 1fr;
    padding: 18px 20px;
}

.panel-head {
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(76, 92, 126, 0.45);
}

.panel-head h2 {
    margin: 0;
    font-size: clamp(1.6rem, 2vw, 2.2rem);
    line-height: 1.05;
    letter-spacing: -0.03em;
}

.selection-subtitle {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 1.12rem;
    line-height: 1.4;
}

.detail-content {
    min-height: 0;
    padding-top: 14px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 6px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.detail-content::-webkit-scrollbar {
    width: 10px;
}

.detail-content::-webkit-scrollbar-track {
    background: rgba(24, 31, 45, 0.4);
    border-radius: 999px;
}

.detail-content::-webkit-scrollbar-thumb {
    background: rgba(88, 112, 163, 0.7);
    border-radius: 999px;
}

.summary-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.summary-card {
    flex: 1 1 140px;
    min-width: fit-content;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(24, 31, 45, 0.82);
}

.summary-card .label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.summary-card .value {
    display: block;
    font-size: 1.45rem;
    font-weight: 700;
    line-height: 1.1;
}

.meta-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: fit-content;
    max-width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(24, 31, 45, 0.84);
    color: var(--muted);
    font-size: 1.02rem;
}

.meta-pill strong {
    color: var(--text);
    overflow-wrap: anywhere;
}

.detail-section {
    margin-top: 12px;
}

.detail-section h3 {
    margin: 0 0 8px;
    font-size: 1.14rem;
}

.detail-section p {
    margin: 0;
    color: var(--muted);
    font-size: 1.08rem;
    line-height: 1.45;
}

.detail-list {
    display: grid;
    gap: 8px;
}

.detail-item {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(24, 31, 45, 0.8);
}

.detail-item .label {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.detail-item .value {
    display: block;
    font-size: 1.12rem;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.detail-item.code .value {
    font-family: Consolas, "Courier New", monospace;
    font-size: 1rem;
}

.relation-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
    gap: 8px;
}

.relation-card {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(22, 29, 43, 0.92);
    color: var(--text);
    text-align: left;
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 140ms ease, border-color 140ms ease, background-color 140ms ease;
}

.relation-card:hover {
    transform: translateY(-1px);
    border-color: var(--border-strong);
    background: #20293b;
}

.relation-card .relation-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.relation-card .relation-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 1.12rem;
    font-weight: 700;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.relation-card .relation-meta {
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.relation-card .relation-tag {
    flex: 0 0 auto;
    width: fit-content;
    max-width: 100%;
    padding: 5px 8px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.84rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.relation-card.write .relation-tag {
    background: rgba(130, 192, 255, 0.18);
    color: var(--write);
}

.relation-card.read .relation-tag {
    background: rgba(102, 168, 240, 0.18);
    color: var(--read);
}

.empty-state {
    padding: 14px;
    border: 1px dashed var(--border);
    border-radius: 14px;
    color: var(--muted);
    font-size: 1.08rem;
    line-height: 1.4;
    background: rgba(20, 24, 35, 0.7);
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.secondary-button {
    width: fit-content;
    max-width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(24, 31, 45, 0.9);
    color: var(--text);
    font: inherit;
    font-size: 1.02rem;
    cursor: pointer;
    touch-action: manipulation;
    transition: border-color 140ms ease, background-color 140ms ease;
}

.secondary-button:hover {
    border-color: var(--border-strong);
    background: #20293b;
}

@media (max-width: 1180px) {
    html,
    body {
        overflow: auto;
    }

    .app {
        height: auto;
    }

    .workspace {
        grid-template-columns: 1fr;
        max-width: 100%;
    }

    .graph-shell {
        min-height: 600px;
    }
}

@media (max-width: 900px) {
    .app {
        padding: 12px;
    }

    .topbar {
        padding: 18px;
    }

    .topbar,
    .graph-meta {
        align-items: stretch;
    }

    .toolbar,
    .toolbar-group {
        justify-items: start;
    }



    .graph-shell {
        min-height: 500px;
    }
}

@media (max-width: 640px) {
    html,
    body {
        overflow: auto;
    }

    .app {
        height: auto;
        gap: 12px;
        padding: 12px;
    }

    .topbar,
    .details-panel,
    .graph-shell {
        padding: 16px;
        border-radius: 18px;
    }

    .topbar {
        gap: 16px;
    }

    .title-block {
        max-width: none;
    }

    .eyebrow,
    .panel-kicker,
    .control-label {
        font-size: 0.85rem;
    }

    .title-block h1 {
        font-size: 1.9rem;
        line-height: 1.05;
    }

    .subhead {
        font-size: 1rem;
    }

    .toolbar,
    .toolbar-group {
        width: 100%;
        min-width: 0;
        justify-items: stretch;
    }



    .graph-shell {
        min-height: 450px;
    }



    .counts {
        font-size: 1rem;
    }



    .workspace {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .graph-shell {
        min-height: 72vh;
        grid-template-rows: auto minmax(420px, 72vh);
    }

    .graph-meta {
        gap: 10px;
    }

    .legend {
        display: grid;
        grid-template-columns: 1fr;
    }

    .legend-item {
        justify-content: space-between;
        font-size: 0.92rem;
    }

    .legend-item strong {
        font-size: 0.92rem;
    }

    .graph-help {
        font-size: 0.95rem;
        max-width: none;
    }

    #graph {
        min-height: 420px;
        border-radius: 18px;
    }

    .details-panel {
        min-height: 52vh;
        grid-template-rows: auto minmax(300px, 1fr);
    }

    .panel-head h2 {
        font-size: 1.2rem;
    }

    .selection-subtitle {
        font-size: 0.95rem;
    }

    .summary-grid,
    .meta-pills,
    .action-row {
        gap: 6px;
    }

    .summary-card {
        flex: 1 1 100%;
    }

    .summary-card .value {
        font-size: 1.15rem;
    }

    .detail-section h3 {
        font-size: 0.95rem;
    }

    .detail-section p,
    .detail-item .value,
    .relation-card .relation-meta {
        font-size: 0.9rem;
    }

    .relation-list {
        grid-template-columns: 1fr;
    }

    .relation-card .relation-title {
        font-size: 0.96rem;
    }
}
