/* ===== CSS Variables & Design Tokens ===== */
:root {
    /* Core palette */
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2236;
    --bg-card: #151d2e;
    --bg-card-hover: #1c2740;
    --bg-input: #0d1321;

    /* Accent palette */
    --accent-primary: #3b82f6;
    --accent-secondary: #6366f1;
    --accent-tertiary: #8b5cf6;
    --accent-glow: rgba(59, 130, 246, 0.25);
    --accent-gradient: linear-gradient(135deg, #3b82f6, #8b5cf6);
    --accent-gradient-warm: linear-gradient(135deg, #f59e0b, #ef4444);

    /* Status colors */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    /* Text */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-accent: #93c5fd;

    /* Borders */
    --border-subtle: rgba(148, 163, 184, 0.08);
    --border-light: rgba(148, 163, 184, 0.15);
    --border-accent: rgba(59, 130, 246, 0.3);

    /* Layout */
    --panel-width: 340px;
    --header-height: 56px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s cubic-bezier(0.16, 1, 0.3, 1);

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px var(--accent-glow);
}

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

html,
body {
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ===== Loading Overlay ===== */
#loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

#loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader-content {
    text-align: center;
}

.loader-content h2 {
    font-size: 1.8rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-top: 24px;
}

.loader-content p {
    color: var(--text-secondary);
    margin-top: 8px;
    font-size: 0.9rem;
}

.loader-ring {
    width: 60px;
    height: 60px;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 1s linear infinite;
}

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

/* ===== Password Overlay ===== */
#password-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

#password-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.password-content {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 32px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    max-width: 380px;
    width: 90%;
    position: relative;
    z-index: 10001;
}

.password-content h2 {
    font-size: 1.6rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 12px;
}

.password-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 24px;
    line-height: 1.5;
}

.password-content input {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    background: var(--bg-input);
    color: var(--text-primary);
    margin-bottom: 16px;
    font-family: inherit;
    font-size: 1rem;
    text-align: center;
    letter-spacing: 0.1em;
    transition: all var(--transition-fast);
}

.password-content input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.password-content button {
    width: 100%;
    padding: 12px 14px;
    background: var(--accent-gradient);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    transition: all var(--transition-fast);
}

.password-content button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

.password-content button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* ===== Header ===== */
#app-header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 36px;
    height: 36px;
    color: var(--accent-primary);
    filter: drop-shadow(0 0 6px var(--accent-glow));
}

.logo-icon svg {
    width: 100%;
    height: 100%;
}

#app-header h1 {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-subtitle {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.header-right {
    display: flex;
    gap: 8px;
}

.header-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.header-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-accent);
}

.header-btn svg {
    width: 15px;
    height: 15px;
}

/* Header Tabs */
.header-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    height: 100%;
    align-items: flex-end;
}

.header-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0 16px 14px 16px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
}

.header-tab:hover {
    color: var(--text-primary);
}

.header-tab.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

/* ===== Main Layout ===== */
#app-main {
    display: flex;
    height: calc(100vh - var(--header-height));
}

/* ===== Side Panels ===== */
#control-panel,
#results-panel,
#goals-panel {
    width: var(--panel-width);
    min-width: var(--panel-width);
    max-width: var(--panel-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
}

#results-panel,
#goals-panel {
    border-right: none;
    border-left: 1px solid var(--border-subtle);
}

.panel-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ===== Control Sections ===== */
.control-section,
.result-section {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
    transition: border-color var(--transition-normal);
}

.control-section:hover,
.result-section:hover {
    border-color: var(--border-light);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 14px;
}

.section-title svg {
    width: 16px;
    height: 16px;
    color: var(--accent-primary);
    flex-shrink: 0;
}

/* ===== Geometry Selector ===== */
.geometry-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.geo-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 8px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.geo-btn:hover {
    border-color: var(--border-accent);
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.geo-btn.active {
    border-color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.1);
    color: var(--text-primary);
    box-shadow: var(--shadow-glow);
}

.geo-icon {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    position: relative;
}

.geo-icon-cylinder {
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.4), rgba(59, 130, 246, 0.1));
    border-radius: 4px;
    width: 22px;
    height: 36px;
    margin: 0 auto;
    border: 2px solid rgba(59, 130, 246, 0.6);
}

.geo-icon-sphere {
    background: radial-gradient(circle at 35% 35%, rgba(99, 102, 241, 0.5), rgba(99, 102, 241, 0.1));
    border-radius: 50%;
    border: 2px solid rgba(99, 102, 241, 0.6);
}

.geo-icon-open {
    background: linear-gradient(0deg, rgba(139, 92, 246, 0.5) 0%, rgba(139, 92, 246, 0.1) 60%, transparent 60%);
    border-bottom: 3px solid rgba(139, 92, 246, 0.7);
    border-radius: 2px;
}

.geo-icon-symmetric {
    background: linear-gradient(0deg,
            rgba(245, 158, 11, 0.6) 0%, rgba(245, 158, 11, 0.6) 15%,
            rgba(245, 158, 11, 0.1) 15%, rgba(245, 158, 11, 0.1) 85%,
            rgba(245, 158, 11, 0.6) 85%, rgba(245, 158, 11, 0.6) 100%);
    border-radius: 2px;
    border: 1px solid rgba(245, 158, 11, 0.5);
}

.geo-icon-hemisphere {
    background: radial-gradient(circle at 50% 100%, rgba(20, 184, 166, 0.5) 0%, rgba(20, 184, 166, 0.1) 70%, transparent 70%);
    border-bottom: 3px solid rgba(20, 184, 166, 0.7);
    border-radius: 50% 50% 2px 2px;
}

/* ===== Select Wrapper ===== */
.select-wrapper {
    position: relative;
}

.select-wrapper select {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    transition: border-color var(--transition-fast);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.select-wrapper select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

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

/* ===== Sliders ===== */
.slider-group {
    margin-bottom: 14px;
}

.slider-group:last-child {
    margin-bottom: 0;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.slider-header label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.value-input {
    width: 72px;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    background: var(--bg-input);
    color: var(--text-accent);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    font-weight: 500;
    text-align: right;
    transition: border-color var(--transition-fast);
}

.value-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-input);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.slider-container {
    position: relative;
    width: 100%;
}

.slider-optimum-mark {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 3px;
    height: 16px;
    background: #10b981;
    border-radius: 2px;
    pointer-events: none;
    z-index: 5;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.9);
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-gradient);
    cursor: pointer;
    border: 2px solid var(--bg-secondary);
    box-shadow: 0 0 8px var(--accent-glow);
    transition: transform var(--transition-fast);
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-gradient);
    cursor: pointer;
    border: 2px solid var(--bg-secondary);
    box-shadow: 0 0 8px var(--accent-glow);
}

.slider-range {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 0.68rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

/* ===== M/C Ratio Display ===== */
.mc-ratio-display {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-top: 4px;
}

.ratio-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.ratio-value {
    float: right;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.ratio-bar-bg {
    width: 100%;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    margin-top: 10px;
    overflow: hidden;
}

.ratio-bar-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 2px;
    transition: width var(--transition-normal), background var(--transition-normal);
}

.ratio-range-text {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* ===== Toggles ===== */
.toggle-group {
    margin-bottom: 10px;
}

.toggle-group:last-of-type {
    margin-bottom: 14px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.toggle-label input[type="checkbox"] {
    display: none;
}

.toggle-switch {
    width: 36px;
    height: 20px;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    position: relative;
    transition: all var(--transition-normal);
    flex-shrink: 0;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--text-muted);
    top: 2px;
    left: 2px;
    transition: all var(--transition-normal);
}

.toggle-label input:checked+.toggle-switch {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.toggle-label input:checked+.toggle-switch::after {
    transform: translateX(16px);
    background: white;
}

/* ===== Viewport ===== */
#viewport-container {
    flex: 1;
    position: relative;
    background: var(--bg-primary);
    overflow: hidden;
}

#three-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* ===== Equation Overlay ===== */
#equation-overlay {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    pointer-events: none;
}

.equation-card {
    background: rgba(17, 24, 39, 0.85);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 12px 24px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.equation-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.02em;
}

.equation-text sup {
    font-size: 0.7em;
}

.equation-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ===== Velocity HUD ===== */
#velocity-hud {
    position: absolute;
    bottom: 20px;
    left: 20px;
    display: flex;
    gap: 12px;
    z-index: 10;
    pointer-events: none;
}

.hud-item {
    background: rgba(17, 24, 39, 0.8);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    min-width: 110px;
}

.hud-item.hud-primary {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-glow);
}

.hud-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.hud-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.hud-primary .hud-value {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 1.6rem;
}

.hud-unit {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ===== Camera Hint ===== */
#camera-hint {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 16px;
    z-index: 10;
    pointer-events: none;
}

#camera-hint span {
    font-size: 0.7rem;
    color: var(--text-muted);
    opacity: 0.6;
}

/* ===== Results Panel ===== */
.result-hero {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(139, 92, 246, 0.08));
    border-color: var(--border-accent);
}

.result-velocity-card {
    text-align: center;
    padding: 16px 0 8px;
}

.result-big-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.result-big-value {
    margin-top: 4px;
}

.result-big-value span:first-child {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2.4rem;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1;
}

.result-big-unit {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-left: 4px;
}

.result-secondary {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    margin-top: 6px;
}

/* ===== Result Grid ===== */
.result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.result-item {
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 10px;
    display: flex;
    flex-direction: column;
    transition: background var(--transition-fast);
}

.result-item:hover {
    background: var(--bg-tertiary);
}

.result-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.result-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 2px;
}

.result-unit {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ===== Validity Card ===== */
.validity-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
    transition: all var(--transition-normal);
}

.validity-card.invalid {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.2);
}

.validity-card.warning {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.2);
}

.validity-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
    flex-shrink: 0;
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.validity-card.invalid .validity-icon {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.validity-card.warning .validity-icon {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.validity-text {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* ===== Comparison Chart ===== */
.comparison-chart {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.comparison-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.comparison-bar-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    width: 65px;
    text-align: right;
    flex-shrink: 0;
    font-weight: 500;
}

.comparison-bar-track {
    flex: 1;
    height: 22px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.comparison-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

.comparison-bar-fill.bar-cylinder {
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
}

.comparison-bar-fill.bar-sphere {
    background: linear-gradient(90deg, #6366f1, #818cf8);
}

.comparison-bar-fill.bar-open {
    background: linear-gradient(90deg, #8b5cf6, #a78bfa);
}

.comparison-bar-fill.bar-symmetric {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.comparison-bar-value {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.68rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.comparison-bar-row.active .comparison-bar-label {
    color: var(--text-primary);
    font-weight: 700;
}

/* ===== Formula Reference ===== */
.formula-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.formula-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    transition: all var(--transition-fast);
}

.formula-item.active {
    border-color: var(--border-accent);
    background: rgba(59, 130, 246, 0.06);
}

.formula-name {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.formula-item.active .formula-name {
    color: var(--text-primary);
}

.formula-eq {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.formula-item.active .formula-eq {
    color: var(--text-accent);
}

/* ===== Animations ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.result-big-value span:first-child {
    animation: fadeInUp 0.4s ease;
}

/* ===== Responsive ===== */
@media (max-width: 1400px) {
    :root {
        --panel-width: 300px;
    }
}

@media (max-width: 1100px) {
    :root {
        --panel-width: 280px;
    }

    #velocity-hud {
        flex-direction: column;
    }
}

/* ===== Comparison Tray Overlay ===== */
.comparison-tray {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 16px;
    z-index: 50;
    pointer-events: none;
    max-width: calc(100% - 300px);
    justify-content: flex-end;
    align-items: flex-start;
}

.compare-box {
    pointer-events: auto;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-top: 3px solid var(--accent-primary);
    border-radius: var(--radius-md);
    padding: 16px;
    min-width: 170px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 6px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.compare-box-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 8px;
    margin-bottom: 4px;
}

.compare-box-title {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
}

.compare-box-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    transition: color var(--transition-fast);
}

.compare-box-delete:hover {
    color: var(--danger);
}

.compare-box-stat {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
}

.compare-box-label {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.compare-box-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.compare-box-val-sm {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.compare-box-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px dashed var(--border-light);
}

.compare-box-detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.6rem;
    color: var(--text-muted);
}

.compare-box-detail-row span:last-child {
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}