/* ============================================================
   Computational Lighting Spectral Optimizer — Stylesheet
   Premium Scientific Instrument Interface
   ============================================================ */

/* === CUSTOM PROPERTIES === */
:root {
    --bg-primary: #050505;
    --bg-secondary: #11100d;
    --bg-tertiary: #17130d;
    --glass-bg: rgba(8, 9, 11, 0.72);
    --glass-border: rgba(255, 255, 255, 0.14);
    --glass-border-hover: rgba(228, 184, 91, 0.48);
    --text-primary: #f6f1e8;
    --text-secondary: rgba(235, 239, 245, 0.68);
    --text-muted: rgba(235, 239, 245, 0.44);
    --accent-blue: #e4b85b;
    --accent-cyan: #ffb347;
    --accent-purple: #ff6b25;
    --gold: #e4b85b;
    --ember: #ff6b25;
    --neon-glow: 0 0 28px rgba(228, 184, 91, 0.18);
    --card-radius: 8px;
    --panel-shadow: 0 18px 58px rgba(0, 0, 0, 0.34);
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);

    /* Channel colors */
    --ch-red: #ff3b3b;
    --ch-green: #2dff6e;
    --ch-blue: #3b7dff;
    --ch-warmwhite: #ffc966;
    --ch-cyan: #36d6e7;
    --ch-lime: #aaff33;
    --ch-amber: #ff9f33;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #050505;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Animated background grid */
.bg-grid {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-image:
        radial-gradient(ellipse at 50% 8%, rgba(228, 184, 91, 0.12), transparent 42%),
        radial-gradient(ellipse at 82% 18%, rgba(255, 107, 37, 0.12), transparent 34%),
        linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 48px 48px;
    background-size: auto, auto, 48px 48px, 48px 48px;
    pointer-events: none;
    z-index: 0;
    animation: gridPulse 8s ease-in-out infinite;
}

@keyframes gridPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* === SCROLLBAR === */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: rgba(228, 184, 91, 0.32);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(228, 184, 91, 0.52);
}

/* === GLASS CARD === */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--glass-border);
    border-radius: var(--card-radius);
    box-shadow: var(--panel-shadow);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

/* === HEADER / HERO === */
.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px clamp(20px, 4vw, 58px);
    background: linear-gradient(to bottom, rgba(0,0,0,0.84), rgba(0,0,0,0.34));
    border-bottom: 1px solid rgba(255,255,255,0.08);
    backdrop-filter: blur(18px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255,255,255,0.28);
    border-radius: var(--card-radius);
    color: #0b0905;
    background: linear-gradient(135deg, #fff0b8, #e6b34e 48%, #ff6b25);
    font-weight: 900;
    box-shadow: 0 0 34px rgba(228, 184, 91, 0.3);
}

.brand-name strong {
    display: block;
    font-size: 14px;
    line-height: 18px;
}

.brand-name span {
    display: block;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 16px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(245,248,255,0.76);
    font-size: 13px;
}

.nav-links a {
    padding: 8px 10px;
    border-radius: 999px;
    border: 1px solid transparent;
    color: inherit;
    text-decoration: none;
    transition: border-color 180ms ease, background 180ms ease, color 180ms ease;
}

.nav-links a:hover {
    color: #fff;
    border-color: rgba(228,184,91,0.45);
    background: rgba(228,184,91,0.08);
}

.page-hero {
    position: relative;
    z-index: 10;
    padding: 118px clamp(20px, 5vw, 76px) 24px;
    max-width: 1600px;
    margin: 0 auto;
}

.kicker {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #f3d28a;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
}

.kicker::before {
    content: "";
    width: 34px;
    height: 1px;
    background: var(--gold);
}

.page-hero h1 {
    margin: 18px 0 0;
    display: grid;
    gap: 8px;
}

.title-main {
    font-family: Georgia, "Times New Roman", "Songti SC", serif;
    font-size: clamp(46px, 7vw, 92px);
    line-height: 0.92;
    font-weight: 500;
    letter-spacing: 0;
    text-shadow: 0 0 30px rgba(228, 184, 91, 0.18);
}

.title-sub {
    color: rgba(245,248,255,0.76);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.24em;
    text-transform: uppercase;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.subtitle {
    margin-top: 2px;
    font-size: 0.78rem;
    color: var(--text-muted);
    letter-spacing: 0.08em;
}

.page-hero p {
    margin: 18px 0 0;
    max-width: 760px;
    color: rgba(244,248,255,0.76);
    font-size: clamp(15px, 1.4vw, 18px);
    line-height: 1.68;
}

/* === MAIN LAYOUT === */
main {
    position: relative;
    z-index: 10;
    display: grid;
    grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
    gap: 18px;
    padding: 18px 24px 14px;
    max-width: 1600px;
    margin: 0 auto;
}

/* === CONTROLS PANEL === */
.controls-panel {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: calc(100vh - 145px);
    overflow-y: auto;
    position: sticky;
    top: 20px;
}

.panel-header h2 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}
.panel-header h2 span {
    font-weight: 400;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-left: 6px;
}

/* === MODE TOGGLE === */
.mode-toggle-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 0;
    border-top: 1px solid rgba(255,255,255,0.05);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.data-note {
    display: grid;
    gap: 5px;
    padding: 10px 12px;
    border: 1px solid rgba(228,184,91,0.2);
    border-radius: var(--card-radius);
    background: rgba(228,184,91,0.055);
}

.data-note strong {
    color: var(--gold);
    font-size: 0.76rem;
}

.data-note span {
    color: var(--text-secondary);
    font-size: 0.72rem;
    line-height: 1.55;
}

.spd-import {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 10px;
    border: 1px solid rgba(228, 184, 91, 0.18);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.035);
}

.import-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(228, 184, 91, 0.35);
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(228,184,91,0.18), rgba(255,255,255,0.04));
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.import-btn:hover {
    border-color: rgba(228, 184, 91, 0.7);
    box-shadow: 0 0 24px rgba(228, 184, 91, 0.14);
    transform: translateY(-1px);
}

.import-btn small {
    color: var(--gold);
    font-size: 0.66rem;
    font-weight: 600;
    white-space: nowrap;
}

.import-status {
    color: var(--text-secondary);
    font-size: 0.72rem;
    line-height: 1.45;
}

.mode-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: color var(--transition-fast);
}
.mode-label.active {
    color: var(--gold);
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
    cursor: pointer;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.08);
    border-radius: 13px;
    border: 1px solid rgba(255,255,255,0.18);
    transition: var(--transition-fast);
}
.toggle-slider::before {
    content: '';
    position: absolute;
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background: var(--gold);
    border-radius: 50%;
    transition: var(--transition-smooth);
    box-shadow: 0 0 18px rgba(228, 184, 91, 0.36);
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(22px);
    background: var(--ember);
    box-shadow: 0 0 18px rgba(255, 107, 37, 0.36);
}

/* === CHANNEL SLIDERS === */
.channels-container {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.channel-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 11px;
    border-radius: 8px;
    background: rgba(255,255,255,0.045);
    border: 1px solid rgba(255,255,255,0.1);
    transition: background var(--transition-fast), border-color var(--transition-fast), opacity 0.5s, transform 0.5s;
}
.channel-row:hover {
    background: rgba(228, 184, 91, 0.055);
    border-color: rgba(228, 184, 91, 0.28);
}

.channel-row.hidden {
    opacity: 0;
    transform: translateY(-10px);
    max-height: 0;
    overflow: hidden;
    padding: 0 12px;
    margin: 0;
    border: none;
}

.channel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.channel-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 500;
}

.channel-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    box-shadow: 0 0 8px currentColor;
}

.channel-wavelength {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.channel-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    font-weight: 600;
    min-width: 38px;
    text-align: right;
}

/* Custom Range Slider */
.channel-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    transition: opacity var(--transition-fast);
}

.channel-slider::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 3px;
    background: rgba(255,255,255,0.08);
}

.channel-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    margin-top: -6px;
    border: 2px solid rgba(255,255,255,0.9);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.channel-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.channel-slider::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background: rgba(255,255,255,0.08);
    border: none;
}

.channel-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid rgba(255,255,255,0.9);
}

/* Channel-specific slider colors (set via JS custom properties) */
.channel-slider {
    background: linear-gradient(to right, var(--ch-color) 0%, var(--ch-color) var(--slider-fill, 0%), rgba(255,255,255,0.08) var(--slider-fill, 0%), rgba(255,255,255,0.08) 100%);
}

.channel-slider::-webkit-slider-thumb {
    background: var(--ch-color);
    box-shadow: 0 0 12px var(--ch-color), 0 0 4px rgba(0,0,0,0.5);
}

.channel-slider::-moz-range-thumb {
    background: var(--ch-color);
    box-shadow: 0 0 12px var(--ch-color), 0 0 4px rgba(0,0,0,0.5);
}

/* === PRESETS === */
.presets-section {
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 12px;
}
.presets-section h3 {
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-secondary);
}
.presets-section h3 span {
    font-weight: 400;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-left: 4px;
}

.preset-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.preset-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-height: 58px;
    padding: 9px 6px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 8px;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.preset-btn:hover {
    background: rgba(228, 184, 91, 0.08);
    border-color: rgba(228, 184, 91, 0.45);
    color: var(--text-primary);
    transform: translateY(-1px);
}
.preset-icon {
    min-width: 36px;
    min-height: 24px;
    display: inline-grid;
    place-items: center;
    border: 1px solid rgba(228,184,91,0.28);
    border-radius: 999px;
    color: var(--gold);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.68rem;
    font-weight: 700;
}

/* === VISUALIZATION AREA === */
.visualization-area {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* === SPD PANEL === */
.spd-panel {
    padding: 18px 20px 20px;
}

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

.spd-header h2 {
    font-size: 0.92rem;
    font-weight: 600;
}
.spd-header h2 span {
    font-weight: 400;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-left: 6px;
}

/* D65 Toggle Checkbox */
.d65-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.78rem;
    color: var(--text-secondary);
    user-select: none;
}
.d65-toggle input {
    display: none;
}
.toggle-indicator {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1.5px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.05);
    position: relative;
    transition: all var(--transition-fast);
}
.d65-toggle input:checked ~ .toggle-indicator {
    background: var(--gold);
    border-color: var(--gold);
}
.d65-toggle input:checked ~ .toggle-indicator::after {
    content: '✓';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    color: var(--bg-primary);
    font-weight: 700;
}
.toggle-text {
    transition: color var(--transition-fast);
}
.d65-toggle input:checked ~ .toggle-text {
    color: var(--gold);
}

.canvas-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 7.2;
    border-radius: 8px;
    overflow: hidden;
    box-shadow:
        0 0 30px rgba(228, 184, 91, 0.07),
        inset 0 0 30px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255,255,255,0.12);
}

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

/* === METRICS DASHBOARD === */
.metrics-dashboard {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
}

.metric-card {
    min-height: 118px;
    padding: 14px 14px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 7px;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-fast);
}
.metric-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--neon-glow);
}

.metric-icon {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid rgba(228,184,91,0.24);
    background: rgba(228,184,91,0.08);
    color: var(--gold);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    font-weight: 800;
    margin-bottom: 2px;
}

.metric-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
}

.metric-label {
    font-size: 0.66rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    line-height: 1.3;
}

.metric-value-row {
    display: flex;
    align-items: baseline;
    gap: 3px;
}

.metric-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(1.2rem, 1.7vw, 1.46rem);
    font-weight: 700;
    color: var(--text-primary);
    transition: color var(--transition-fast);
    line-height: 1;
}

.metric-unit {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
}

.metric-bar {
    width: 100%;
    height: 3px;
    border-radius: 2px;
    background: rgba(255,255,255,0.06);
    margin-top: 2px;
    position: relative;
    overflow: hidden;
}
.metric-bar::after {
    content: '';
    position: absolute;
    left: 0; top: 0;
    height: 100%;
    width: var(--bar-fill, 0%);
    border-radius: 2px;
    background: var(--bar-color, var(--accent-blue));
    transition: width 0.6s ease;
}

/* CS Status Badge */
.cs-status {
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: 8px;
    text-transform: uppercase;
    transition: all var(--transition-fast);
}
.cs-status.alerting {
    background: rgba(166, 233, 107, 0.13);
    color: #a6e96b;
    border: 1px solid rgba(166, 233, 107, 0.3);
}
.cs-status.moderate {
    background: rgba(228, 184, 91, 0.15);
    color: var(--gold);
    border: 1px solid rgba(228, 184, 91, 0.34);
}
.cs-status.sleep {
    background: rgba(255, 107, 37, 0.13);
    color: #ff9b63;
    border: 1px solid rgba(255, 107, 37, 0.32);
}

/* Pulse animation for metric updates */
@keyframes metricPulse {
    0% { box-shadow: 0 0 0 0 rgba(228, 184, 91, 0.3); }
    50% { box-shadow: 0 0 15px 3px rgba(228, 184, 91, 0.15); }
    100% { box-shadow: 0 0 0 0 rgba(228, 184, 91, 0); }
}

.metric-card.pulse {
    animation: metricPulse 0.6s ease-out;
}

/* === OPTIMIZER SECTION === */
.optimizer-section {
    position: relative;
    z-index: 10;
    margin: 0 24px 18px;
    padding: 18px 20px;
    max-width: 1552px;
    margin-left: auto;
    margin-right: auto;
    width: calc(100% - 48px);
}

.optimizer-header h2 {
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.optimizer-header h2 span {
    font-weight: 400;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.ai-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--gold), var(--ember));
    color: #120d08;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    letter-spacing: 0.1em;
}

.optimizer-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 3px;
}

.optimizer-controls {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
    margin-top: 14px;
}

.optimize-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.03);
    color: var(--text-primary);
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.optimize-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.optimize-btn.morning::before {
    background: linear-gradient(135deg, rgba(255, 170, 51, 0.1), rgba(255, 107, 53, 0.05));
}
.optimize-btn.evening::before {
    background: linear-gradient(135deg, rgba(107, 107, 255, 0.1), rgba(139, 92, 246, 0.05));
}
.optimize-btn.focus::before,
.optimize-btn.meeting::before,
.optimize-btn.sleep::before {
    background: linear-gradient(135deg, rgba(228,184,91,0.1), rgba(255,107,37,0.045));
}

.optimize-btn:hover::before {
    opacity: 1;
}

.optimize-btn:hover {
    border-color: rgba(255,255,255,0.2);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.optimize-btn:active {
    transform: translateY(0);
}

.optimize-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-icon {
    font-size: 1.55rem;
}

.btn-label {
    font-size: 0.88rem;
    font-weight: 600;
    text-align: left;
    line-height: 1.4;
}
.btn-label small {
    font-weight: 400;
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.btn-target {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gold);
    margin-left: auto;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(228, 184, 91, 0.1);
    border: 1px solid rgba(228, 184, 91, 0.24);
}

/* Optimizer Progress */
.optimizer-progress {
    margin-top: 14px;
    padding: 14px;
    background: rgba(0,0,0,0.2);
    border-radius: 12px;
    border: 1px solid rgba(228, 184, 91, 0.16);
}

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

.progress-label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--gold);
    animation: progressPulse 1.5s ease-in-out infinite;
}

@keyframes progressPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.progress-iter {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.progress-bar-track {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.06);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--gold), var(--ember));
    width: 0%;
    transition: width 0.1s linear;
    box-shadow: 0 0 10px rgba(228, 184, 91, 0.36);
}

.progress-metrics {
    display: flex;
    gap: 24px;
}

.progress-metric {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.progress-metric span:first-child {
    font-size: 0.68rem;
    color: var(--text-muted);
}
.progress-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* === FOOTER === */
footer {
    position: relative;
    z-index: 10;
    text-align: center;
    padding: 16px 24px 24px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

footer p {
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}

.footer-cn {
    margin-top: 4px;
    font-size: 0.65rem !important;
    opacity: 0.7;
}

/* === RESPONSIVE === */
@media (max-width: 1100px) {
    .page-hero {
        padding-top: 104px;
    }

    main {
        grid-template-columns: 1fr;
        padding: 16px;
    }

    .controls-panel {
        max-height: none;
        position: static;
    }

    .channels-container {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }

    .metrics-dashboard {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .optimizer-controls {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .optimizer-section {
        margin: 0 16px 16px;
        width: calc(100% - 32px);
    }
}

@media (max-width: 768px) {
    .nav {
        padding: 14px 16px;
        gap: 12px;
    }

    .brand-name span {
        display: none;
    }

    .nav-links {
        gap: 4px;
        font-size: 12px;
    }

    .nav-links a {
        padding: 7px 8px;
    }

    .page-hero {
        padding: 92px 16px 16px;
    }

    .title-main {
        font-size: clamp(40px, 14vw, 56px);
    }

    .title-sub {
        font-size: 11px;
        letter-spacing: 0.16em;
    }

    .metrics-dashboard {
        grid-template-columns: repeat(2, 1fr);
    }

    .optimizer-controls {
        grid-template-columns: 1fr;
    }

    .canvas-wrapper {
        aspect-ratio: 16 / 10;
    }
}

@media (max-width: 520px) {
    .brand-mark {
        width: 34px;
        height: 34px;
        font-size: 13px;
    }

    .brand-name strong {
        max-width: 145px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .nav-links a {
        padding: 6px;
    }

    main {
        padding: 14px 16px 10px;
    }

    .controls-panel,
    .spd-panel,
    .optimizer-section {
        box-shadow: 0 12px 36px rgba(0, 0, 0, 0.24);
    }

    .metrics-dashboard {
        gap: 10px;
    }

    .metric-card {
        min-height: 112px;
        padding: 12px 10px 10px;
    }

    .optimizer-section {
        width: calc(100% - 32px);
        margin-bottom: 14px;
    }
}

/* === UTILITY ANIMATIONS === */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

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

.slide-up {
    animation: slideUp 0.6s ease-out forwards;
}

/* Staggered entrance */
.controls-panel { animation: slideUp 0.5s ease-out 0.1s both; }
.spd-panel { animation: slideUp 0.5s ease-out 0.2s both; }
.metrics-dashboard .metric-card:nth-child(1) { animation: slideUp 0.4s ease-out 0.25s both; }
.metrics-dashboard .metric-card:nth-child(2) { animation: slideUp 0.4s ease-out 0.3s both; }
.metrics-dashboard .metric-card:nth-child(3) { animation: slideUp 0.4s ease-out 0.35s both; }
.metrics-dashboard .metric-card:nth-child(4) { animation: slideUp 0.4s ease-out 0.4s both; }
.metrics-dashboard .metric-card:nth-child(5) { animation: slideUp 0.4s ease-out 0.45s both; }
.optimizer-section { animation: slideUp 0.5s ease-out 0.5s both; }

/* === LIGHT WORKSPACE THEME OVERRIDE === */
:root {
    --bg-primary: #f7f2e9;
    --bg-secondary: #fffaf2;
    --bg-tertiary: #efe6d8;
    --glass-bg: rgba(255, 252, 246, 0.88);
    --glass-border: rgba(55, 48, 39, 0.14);
    --glass-border-hover: rgba(228, 184, 91, 0.62);
    --text-primary: #211d17;
    --text-secondary: rgba(34, 30, 24, 0.68);
    --text-muted: rgba(34, 30, 24, 0.48);
    --accent-blue: #c7952e;
    --accent-cyan: #dd9b33;
    --accent-purple: #e25f2d;
    --gold: #c9942d;
    --ember: #e3652a;
    --neon-glow: 0 18px 42px rgba(201, 148, 45, 0.16);
    --panel-shadow: 0 18px 50px rgba(64, 45, 22, 0.10);
}

body {
    background:
        radial-gradient(ellipse at 12% 8%, rgba(228, 184, 91, 0.18), transparent 36%),
        radial-gradient(ellipse at 92% 2%, rgba(255, 107, 37, 0.10), transparent 34%),
        #f7f2e9;
    color: var(--text-primary);
}

.bg-grid {
    background-image:
        radial-gradient(ellipse at 50% 8%, rgba(228, 184, 91, 0.12), transparent 42%),
        linear-gradient(rgba(34, 30, 24, 0.055) 1px, transparent 1px),
        linear-gradient(90deg, rgba(34, 30, 24, 0.045) 1px, transparent 1px);
    background-size: auto, 48px 48px, 48px 48px;
    opacity: 0.7;
}

.glass-card {
    background: var(--glass-bg);
    border-color: var(--glass-border);
    box-shadow: var(--panel-shadow);
}

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

.page-hero {
    padding-top: 48px;
    padding-bottom: 22px;
}

.kicker {
    color: var(--gold);
}

.title-main {
    color: #211d17;
    text-shadow: none;
}

.title-sub,
.page-hero p,
.panel-header h2 span,
.presets-section h3,
.spd-header h2 span,
.optimizer-header h2 span:not(.ai-badge),
.optimizer-desc,
.metric-label,
.btn-label small,
footer p {
    color: var(--text-secondary);
}

.title-sub {
    color: rgba(33, 29, 23, 0.58);
}

.controls-panel,
.spd-panel,
.optimizer-section,
.metric-card {
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.mode-toggle-container,
.presets-section {
    border-color: rgba(34, 30, 24, 0.10);
}

.data-note,
.spd-import,
.optimizer-progress {
    background: rgba(255, 255, 255, 0.56);
    border-color: rgba(201, 148, 45, 0.24);
}

.import-btn {
    background: linear-gradient(135deg, rgba(228,184,91,0.22), rgba(255,255,255,0.74));
    color: var(--text-primary);
}

.mode-label,
.channel-wavelength,
.channel-value,
.import-status,
.d65-toggle,
.metric-unit,
.btn-target,
.progress-label,
.progress-metric span:first-child {
    color: var(--text-secondary);
}

.mode-label.active,
.preset-icon,
.btn-target,
.progress-value {
    color: var(--gold);
}

.toggle-switch {
    background: rgba(34, 30, 24, 0.12);
    border-color: rgba(34, 30, 24, 0.16);
}

.channel-row,
.preset-btn,
.optimize-btn {
    background: rgba(255, 255, 255, 0.58);
    border-color: rgba(34, 30, 24, 0.10);
    color: var(--text-primary);
}

.channel-row:hover,
.preset-btn:hover,
.optimize-btn:hover {
    background: rgba(255, 249, 236, 0.84);
    border-color: rgba(201, 148, 45, 0.42);
    box-shadow: 0 10px 28px rgba(64, 45, 22, 0.10);
}

.channel-slider {
    background: rgba(34, 30, 24, 0.10);
}

.channel-slider::-webkit-slider-runnable-track {
    background: linear-gradient(to right, var(--ch-color) 0%, var(--ch-color) var(--slider-fill, 0%), rgba(34, 30, 24, 0.10) var(--slider-fill, 0%), rgba(34, 30, 24, 0.10) 100%);
}

.channel-slider::-moz-range-track {
    background: rgba(34, 30, 24, 0.10);
}

.canvas-wrapper {
    background: #fffaf0;
    border-color: rgba(34, 30, 24, 0.20);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.78),
        inset 0 0 28px rgba(111, 81, 34, 0.06);
}

.spd-panel {
    background: rgba(255, 252, 246, 0.96);
}

.spd-header h2 {
    color: #211d17;
}

.toggle-indicator {
    border-color: rgba(34, 30, 24, 0.24);
    background: rgba(34, 30, 24, 0.04);
}

.d65-toggle input:checked + .toggle-indicator {
    color: #211d17;
}

.metric-icon {
    background: rgba(201, 148, 45, 0.12);
    color: var(--gold);
}

.metric-value,
.progress-metric span:last-child {
    color: var(--text-primary);
}

.metric-bar {
    background: rgba(34, 30, 24, 0.10);
}

.optimize-btn.morning {
    background: linear-gradient(135deg, rgba(255, 191, 82, 0.22), rgba(255, 255, 255, 0.72));
}

.optimize-btn.evening {
    background: linear-gradient(135deg, rgba(103, 113, 156, 0.15), rgba(255, 255, 255, 0.72));
}

.optimize-btn.focus,
.optimize-btn.meeting,
.optimize-btn.sleep {
    background: linear-gradient(135deg, rgba(228,184,91,0.18), rgba(255,255,255,0.72));
}

.progress-bar-track {
    background: rgba(34, 30, 24, 0.10);
}

footer {
    border-color: rgba(34, 30, 24, 0.10);
}

::-webkit-scrollbar-track {
    background: #f7f2e9;
}
