/* ============================================================
   WBCP Interactive Uncertainty Visualization - Theme & Layout
   ============================================================ */

/* --- CSS Variables / Theme --- */
:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --bg-card: #1e2a4a;
    --accent: #e94560;
    --accent-hover: #ff6b81;
    --accent-dim: #c73e54;
    --text-primary: #eaeaea;
    --text-secondary: #a0a8c0;
    --text-muted: #6b7394;
    --border-color: #2a3a5e;
    --border-light: #344570;
    --success: #2ecc71;
    --warning: #f39c12;
    --error: #e74c3c;
    --input-bg: #0d1b36;
    --input-border: #2a3a5e;
    --input-focus: #e94560;
    --shadow: rgba(0, 0, 0, 0.35);
    --radius: 6px;
    --radius-lg: 10px;
    --sidebar-width: 320px;
    --header-height: 52px;
    --transition: 0.25s ease;
    --font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'Consolas', 'Fira Code', 'Courier New', monospace;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: var(--font-family);
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-primary);
    line-height: 1.5;
}

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

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --- Header --- */
.header {
    height: var(--header-height);
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
    gap: 16px;
    flex-shrink: 0;
    z-index: 100;
}

.header h1 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.header-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
    white-space: nowrap;
}

/* --- App Container --- */
.app-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

/* --- Panel (Accordion) --- */
.panel {
    border-bottom: 1px solid var(--border-color);
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-secondary);
    transition: background var(--transition);
}

.panel-header:hover {
    background: var(--bg-tertiary);
}

.panel-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.panel-toggle {
    margin-left: auto;
    font-size: 10px;
    color: var(--text-muted);
    transition: transform var(--transition);
}

.panel-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.35s ease;
    padding: 0 16px;
}

.panel-body.open {
    max-height: 2000px;
    padding: 12px 16px 16px;
    overflow-y: auto;
}

/* --- Labels --- */
.panel-body label,
.sidebar label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 10px;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* --- Form Controls --- */
select,
input[type="number"],
input[type="text"] {
    width: 100%;
    padding: 7px 10px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 12px;
    font-family: var(--font-family);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

select:focus,
input[type="number"]:focus,
input[type="text"]:focus {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 2px rgba(233, 69, 96, 0.2);
}

select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.input-num {
    width: 90px;
}

/* --- Range Slider --- */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: var(--border-color);
    outline: none;
    margin: 6px 0 4px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg-secondary);
    transition: transform var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg-secondary);
}

/* --- Radio & Checkbox Groups --- */
.radio-group,
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
}

.radio-group label,
.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 400;
    color: var(--text-primary);
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0;
    margin: 0;
    padding: 3px 0;
}

.radio-group input[type="radio"],
.checkbox-group input[type="checkbox"] {
    accent-color: var(--accent);
    width: 14px;
    height: 14px;
    cursor: pointer;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all var(--transition);
    width: 100%;
    margin-top: 12px;
    letter-spacing: 0.3px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-dim));
    color: #fff;
    box-shadow: 0 2px 8px rgba(233, 69, 96, 0.3);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--accent-hover), var(--accent));
    box-shadow: 0 4px 14px rgba(233, 69, 96, 0.4);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-run {
    background: linear-gradient(135deg, var(--success), #27ae60);
    color: #fff;
    font-size: 14px;
    padding: 12px 18px;
    box-shadow: 0 2px 8px rgba(46, 204, 113, 0.3);
}

.btn-run:hover:not(:disabled) {
    background: linear-gradient(135deg, #3ddb85, var(--success));
    box-shadow: 0 4px 14px rgba(46, 204, 113, 0.4);
    transform: translateY(-1px);
}

.btn-run:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

/* --- Info Card --- */
.info-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-top: 10px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.info-card strong {
    color: var(--text-primary);
}

.info-card .metric-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
}

.info-card .metric-row .metric-value {
    font-family: var(--font-mono);
    color: var(--accent);
    font-weight: 600;
}

/* --- Status Message --- */
.status-msg {
    margin-top: 8px;
    padding: 6px 10px;
    border-radius: var(--radius);
    font-size: 11px;
    line-height: 1.4;
}

.status-msg.success {
    background: rgba(46, 204, 113, 0.12);
    color: var(--success);
    border: 1px solid rgba(46, 204, 113, 0.25);
}

.status-msg.error {
    background: rgba(231, 76, 60, 0.12);
    color: var(--error);
    border: 1px solid rgba(231, 76, 60, 0.25);
}

.status-msg.info {
    background: rgba(52, 152, 219, 0.12);
    color: #5dade2;
    border: 1px solid rgba(52, 152, 219, 0.25);
}

/* --- Progress Bar --- */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
    margin: 10px 0 6px;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--success));
    border-radius: 3px;
    transition: width 0.4s ease;
}

#run-status-text {
    font-size: 11px;
    color: var(--text-muted);
}

/* --- Upload Area --- */
.upload-area {
    margin-top: 6px;
}

.upload-area input[type="file"] {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.upload-area input[type="file"]::file-selector-button {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 4px 10px;
    font-size: 11px;
    cursor: pointer;
    margin-right: 8px;
    transition: background var(--transition);
}

.upload-area input[type="file"]::file-selector-button:hover {
    background: var(--accent);
}

/* --- Model Param Groups --- */
.model-param-group {
    padding: 6px 0;
    border-top: 1px solid var(--border-color);
    margin-top: 6px;
}

/* --- Method Groups --- */
.method-group {
    margin-bottom: 10px;
}

.method-group-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    padding-bottom: 3px;
    border-bottom: 1px solid var(--border-color);
}

#method-params h4 {
    font-size: 12px;
    color: var(--text-primary);
    margin-bottom: 6px;
}

#method-params hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 10px 0;
}

/* --- Parameter Number Input (alongside slider) --- */
.param-number-input {
    width: 72px !important;
    min-width: 72px;
    flex-shrink: 0;
    padding: 4px 6px !important;
    font-size: 11px !important;
    font-family: var(--font-mono) !important;
    text-align: right;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    color: var(--text-primary);
}

.param-number-input:focus {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 2px rgba(233, 69, 96, 0.2);
}

/* Hide spin buttons for cleaner look */
.param-number-input::-webkit-inner-spin-button,
.param-number-input::-webkit-outer-spin-button {
    opacity: 1;
    height: 18px;
}

/* --- Bandwidth Unit Selector --- */
.bw-unit-select {
    width: auto !important;
    min-width: 50px;
    padding: 2px 6px !important;
    font-size: 10px !important;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
}

.bw-unit-select:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

/* --- Hidden Utility --- */
.hidden {
    display: none !important;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    position: relative;
}

/* --- Map --- */
.map-container {
    flex: 6;
    position: relative;
    min-height: 200px;
    overflow: hidden;
}

.map {
    width: 100%;
    height: 100%;
}

.map-controls {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
}

.map-control-select {
    width: 180px;
    padding: 6px 10px;
    background: rgba(22, 33, 62, 0.92);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 12px;
    backdrop-filter: blur(6px);
}

/* --- Map Legend --- */
.map-legend {
    background: rgba(22, 33, 62, 0.92);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 8px 12px;
    min-width: 160px;
    backdrop-filter: blur(6px);
}

.legend-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.legend-bar {
    width: 100%;
    height: 10px;
    border-radius: 5px;
    background: linear-gradient(90deg, #326B77, #CABED0, #A74D30);
}

.legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 3px;
    font-family: var(--font-mono);
}

/* --- Halo Legend --- */
.legend-separator {
    border-top: 1px solid var(--border-light);
    margin: 6px 0;
}

.legend-halo-sizes {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-top: 4px;
    padding: 4px 0;
}

.halo-size-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.halo-circle {
    border-radius: 50%;
    background: radial-gradient(circle, rgba(233, 140, 60, 0.85) 30%, rgba(233, 140, 60, 0.35) 70%, rgba(233, 140, 60, 0.1) 100%);
    border: 1px solid rgba(233, 140, 60, 0.6);
}

.halo-small {
    width: 12px;
    height: 12px;
}

.halo-medium {
    width: 20px;
    height: 20px;
}

.halo-large {
    width: 30px;
    height: 30px;
}

.legend-halo-sizes span {
    font-size: 9px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* --- Tooltip --- */
.map-tooltip {
    position: absolute;
    pointer-events: none;
    background: rgba(13, 27, 54, 0.94);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: 11px;
    line-height: 1.6;
    color: var(--text-primary);
    box-shadow: 0 4px 16px var(--shadow);
    z-index: 50;
    backdrop-filter: blur(8px);
    max-width: 240px;
}

.map-tooltip strong {
    color: var(--accent);
}

/* --- Chart Container --- */
.chart-container {
    flex: 4;
    display: flex;
    flex-direction: column;
    border-top: 2px solid var(--border-color);
    background: var(--bg-primary);
    min-height: 150px;
    overflow: hidden;
}

/* --- Chart Tabs --- */
.chart-tabs {
    display: flex;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.chart-tab {
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.chart-tab:hover {
    color: var(--text-primary);
    background: rgba(233, 69, 96, 0.06);
}

.chart-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: rgba(233, 69, 96, 0.08);
}

/* --- Chart Area --- */
.chart-area {
    flex: 1;
    padding: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.chart-area svg {
    width: 100%;
    height: 100%;
}

.chart-placeholder {
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
    padding: 40px;
    font-style: italic;
}

/* --- D3 Chart Styles --- */
.chart-area .axis path,
.chart-area .axis line {
    stroke: var(--border-light);
}

.chart-area .axis text {
    fill: var(--text-muted);
    font-size: 10px;
}

.chart-area .axis-label {
    fill: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
}

.chart-area .chart-title {
    fill: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
}

/* --- Gauge Styles --- */
.gauge-value {
    fill: var(--text-primary);
    font-size: 36px;
    font-weight: 700;
    font-family: var(--font-mono);
}

.gauge-label {
    fill: var(--text-secondary);
    font-size: 13px;
}

.gauge-sublabel {
    fill: var(--text-muted);
    font-size: 11px;
}

/* --- Info Banner --- */
.info-banner {
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.info-banner-teaser {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 24px;
    cursor: pointer;
    user-select: none;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    transition: color var(--transition);
}

.info-banner-teaser:hover {
    color: var(--text-primary);
}

.info-banner-icon {
    font-size: 16px;
    color: var(--accent);
}

.info-banner-arrow {
    margin-left: auto;
    font-size: 9px;
    color: var(--text-muted);
    transition: transform var(--transition);
}

.info-banner.open .info-banner-arrow {
    transform: rotate(180deg);
}

.info-banner-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.35s ease;
    padding: 0 24px;
}

.info-banner.open .info-banner-content {
    max-height: 400px;
    padding: 0 24px 12px;
}

.info-banner-content p {
    font-size: 12px;
    line-height: 1.65;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.info-banner-content p:last-child {
    margin-bottom: 0;
}

.info-banner-content strong {
    color: var(--text-primary);
}

.info-banner-content em {
    color: var(--accent);
    font-style: italic;
}

/* --- Panel Hints --- */
.panel-hint {
    font-size: 11px;
    font-style: italic;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0 0 8px 0;
    padding: 0;
}

/* --- Learn More Button --- */
.btn-learn-more {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(233, 69, 96, 0.1);
    color: var(--accent);
    border: 1px solid rgba(233, 69, 96, 0.25);
    border-radius: var(--radius);
    padding: 5px 12px;
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    margin-bottom: 10px;
    transition: all var(--transition);
}

.btn-learn-more:hover {
    background: rgba(233, 69, 96, 0.2);
    border-color: var(--accent);
}

/* --- Method Info Icon --- */
.method-info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(233, 69, 96, 0.15);
    color: var(--accent);
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    margin-left: 4px;
    border: none;
    padding: 0;
    font-family: var(--font-family);
    transition: all var(--transition);
    flex-shrink: 0;
}

.method-info-icon:hover {
    background: var(--accent);
    color: #fff;
}

/* --- Method Drawer Overlay --- */
.method-drawer {
    position: absolute;
    inset: 0;
    z-index: 50;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    animation: drawerSlideIn 0.3s ease;
}

.method-drawer.hidden {
    display: none !important;
}

@keyframes drawerSlideIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.drawer-header h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.drawer-close {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--border-light);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.drawer-close:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* --- Drawer Intro --- */
.drawer-intro {
    font-size: 12px;
    line-height: 1.65;
    color: var(--text-secondary);
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.drawer-intro strong {
    color: var(--text-primary);
}

/* --- Method Group in Drawer --- */
.drawer-group {
    margin-bottom: 24px;
}

.drawer-group-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.drawer-group-desc {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 12px;
    font-style: italic;
}

/* --- Method Card --- */
.method-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
    transition: border-color var(--transition);
}

.method-card:hover {
    border-color: var(--border-light);
}

.method-card-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.method-card-title .method-badge {
    font-size: 9px;
    font-weight: 600;
    color: var(--accent);
    background: rgba(233, 69, 96, 0.12);
    padding: 1px 6px;
    border-radius: 3px;
    text-transform: uppercase;
}

.method-card-desc {
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

/* --- Formula Block --- */
.method-formula {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 10px 14px;
    margin: 10px 0;
    overflow-x: auto;
    text-align: center;
}

.method-formula .katex {
    font-size: 14px;
}

.method-formula-explain {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-top: 6px;
}

/* --- Key Idea --- */
.method-key-idea {
    background: rgba(233, 69, 96, 0.06);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 8px 12px;
    margin-top: 10px;
    font-size: 11px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.method-key-idea strong {
    color: var(--accent);
}

/* --- Demo Container --- */
.demo-container {
    margin-top: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.demo-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

.demo-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.demo-controls label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
    text-transform: none;
    letter-spacing: 0;
    white-space: nowrap;
}

.demo-controls input[type="range"] {
    width: 120px;
    margin: 0;
}

.demo-controls .demo-val {
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--accent);
    min-width: 36px;
}

.demo-viz {
    padding: 8px;
    background: var(--bg-primary);
    min-height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.demo-viz svg {
    width: 100%;
    height: 100%;
}

/* --- Workflow Diagram --- */
.workflow-section {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.workflow-viz {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-top: 10px;
    max-width: 540px;
    overflow: auto;
}

.workflow-zoom-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    user-select: none;
}

.wf-zoom-btn {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid var(--border-light);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    padding: 0;
    font-family: var(--font-family);
}

.wf-zoom-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.wf-zoom-reset {
    width: auto;
    padding: 0 8px;
    font-size: 10px;
    margin-left: 4px;
}

.wf-zoom-level {
    font-size: 10px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    min-width: 34px;
    text-align: center;
}

.workflow-viz-inner {
    padding: 10px;
    overflow: auto;
    transition: transform 0.15s ease;
}

.workflow-viz-inner svg {
    width: 100%;
    height: auto;
    display: block;
}

/* --- Chart Description --- */
.chart-description {
    position: absolute;
    top: 4px;
    left: 12px;
    right: 12px;
    font-size: 10px;
    color: var(--text-muted);
    font-style: italic;
    line-height: 1.4;
    z-index: 1;
    pointer-events: none;
}

/* --- N_eff subscript in tab --- */
.chart-tab sub {
    font-size: 0.8em;
    vertical-align: baseline;
    position: relative;
    top: 0.2em;
}

/* --- Responsive --- */
@media (max-width: 1100px) {
    :root {
        --sidebar-width: 280px;
    }
    .header h1 {
        font-size: 14px;
    }
    .chart-tab {
        padding: 6px 10px;
        font-size: 11px;
    }
}

@media (max-width: 860px) {
    .app-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        min-width: unset;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    .map-container {
        flex: 1;
    }
    .chart-container {
        flex: 1;
    }
}
