/* Import modern fonts from Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,300..800&family=Nunito:wght@300..800&display=swap');

/* Global variables for color scheme & styling tokens */
:root {
    --bg-paper: #FDFCF8;          /* Rice Paper Off-White */
    --bg-panel: #FEFEFA;          /* Extremely light beige */
    --color-text-main: #2C2C24;   /* Deep Loam / Charcoal */
    --color-text-muted: #78786C;  /* Dried Grass */
    --color-text-dim: #9FA195;    /* Muted Grey-green */
    
    /* Core Organic Palette */
    --color-primary: #5D7052;        /* Moss Green */
    --color-primary-fg: #F3F4F1;     /* Pale Mist */
    --color-secondary: #C18C5D;      /* Terracotta / Clay */
    --color-secondary-fg: #FFFFFF;
    --color-accent: #E6DCCD;         /* Sand / Beige */
    --color-accent-fg: #4A4A40;      /* Bark */
    --color-muted: #F0EBE5;          /* Stone */
    --color-muted-fg: #78786C;
    --color-border: #DED8CF;         /* Raw Timber */
    --color-destructive: #A85448;    /* Burnt Sienna */
    
    /* Elements mapping colors */
    --color-floor: rgba(93, 112, 82, 0.04);
    --color-wall: #4A4A40;
    --color-window: rgba(193, 140, 93, 0.2);
    --color-ac: rgba(169, 194, 192, 0.3);
    --color-fan: rgba(93, 112, 82, 0.2);
    
    /* Fonts */
    --font-header: 'Fraunces', serif;
    --font-body: 'Nunito', sans-serif;
    
    /* Shadows */
    --shadow-soft: 0 4px 20px -2px rgba(93, 112, 82, 0.15);
    --shadow-float: 0 10px 40px -10px rgba(193, 140, 93, 0.2);
}

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

body {
    background-color: var(--bg-paper);
    color: var(--color-text-main);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
}

/* Global grain/noise overlay */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.035;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

/* Decorative ambient blobs */
.blob-bg {
    position: absolute;
    pointer-events: none;
    z-index: -1;
    filter: blur(100px);
}
.blob-1 {
    top: 5%;
    left: -10%;
    width: 500px;
    height: 500px;
    background-color: var(--color-primary);
    opacity: 0.07;
    border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
}
.blob-2 {
    bottom: -5%;
    right: -10%;
    width: 600px;
    height: 600px;
    background-color: var(--color-secondary);
    opacity: 0.06;
    border-radius: 40% 60% 70% 30% / 50% 60% 30% 70%;
}

/* Header container */
header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--color-border);
    background: rgba(253, 252, 248, 0.8);
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    box-shadow: var(--shadow-soft);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 1.3rem;
    width: 2.6rem;
    height: 2.6rem;
    background: var(--color-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary-fg);
    box-shadow: var(--shadow-soft);
    animation: rotate-breeze 15s linear infinite;
    display: inline-flex;
}

@keyframes rotate-breeze {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

h1 {
    font-family: var(--font-header);
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--color-text-main);
}

.header-subtitle {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-top: 0.2rem;
}

/* Main Layout Grid */
main {
    flex: 1;
    display: grid;
    grid-template-columns: 340px 1fr 340px;
    gap: 1.5rem;
    padding: 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

@media (max-width: 1100px) {
    main {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }
}

/* Glassmorphism Panel styles */
.glass-panel {
    background: var(--bg-panel);
    border: 1px solid rgba(222, 216, 207, 0.5);
    padding: 1.5rem;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    height: 100%;
}

#config-panel {
    border-radius: 2rem 1.5rem 2.2rem 1.8rem / 2rem 2rem 2.5rem 1.5rem;
}

.simulation-panel {
    border-radius: 1.8rem 2.2rem 1.5rem 2rem / 2rem 1.5rem 2rem 2.5rem;
}

#analytics-panel {
    border-radius: 2.2rem 1.8rem 2rem 1.5rem / 2rem 2.5rem 2rem 1.5rem;
}

/* Stepper (Steps list) */
.steps-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.step-card {
    border-radius: 1.5rem 1rem 1.5rem 1rem / 1rem 1.5rem 1rem 1.5rem;
    border: 1px solid rgba(222, 216, 207, 0.6);
    background: rgba(240, 235, 229, 0.35);
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    gap: 0.75rem;
}

.step-card:hover {
    background: rgba(230, 220, 205, 0.45);
    border-color: var(--color-border);
}

.step-card.active {
    background: rgba(93, 112, 82, 0.08);
    border-color: var(--color-primary);
    box-shadow: var(--shadow-soft);
}

.step-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-accent);
    color: var(--color-accent-fg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.active .step-num {
    background: var(--color-primary);
    color: var(--color-primary-fg);
}

.step-content h3 {
    font-family: var(--font-header);
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.step-content p {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    line-height: 1.3;
}

/* Control tools */
.tool-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.tool-btn {
    flex: 1;
    min-width: 100px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid var(--color-border);
    color: var(--color-text-main);
    padding: 0.6rem 0.8rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: all 0.2s ease;
    font-weight: 500;
}

.tool-btn:hover {
    background: rgba(230, 220, 205, 0.3);
    border-color: var(--color-text-muted);
}

.tool-btn.active {
    background: rgba(93, 112, 82, 0.12);
    border-color: var(--color-primary);
    color: var(--color-primary);
    box-shadow: var(--shadow-soft);
    font-weight: 700;
}

/* Specific button styles */
.action-btn {
    width: 100%;
    background: var(--color-primary);
    color: var(--color-primary-fg);
    font-family: var(--font-body);
    font-weight: 700;
    padding: 0.75rem;
    border-radius: 9999px;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-soft);
}

.action-btn:hover {
    transform: scale(1.03);
    box-shadow: 0 6px 24px -4px rgba(93, 112, 82, 0.25);
}

.action-btn:active {
    transform: scale(0.97);
}

.secondary-btn {
    background: transparent;
    border: 2px solid var(--color-secondary);
    color: var(--color-secondary);
    font-family: var(--font-body);
    font-weight: 600;
}

.secondary-btn:hover {
    background: rgba(193, 140, 93, 0.08);
}

/* Sliders */
.slider-container {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    color: var(--color-text-muted);
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 8px;
    background: var(--color-border);
    border-radius: 9999px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    transition: transform 0.15s ease;
    box-shadow: 0 2px 8px rgba(93, 112, 82, 0.3);
}

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

.pitch-selector { display: flex; gap: 0.4rem; margin-top: 0.4rem; }
.pitch-btn {
    flex: 1; background: rgba(255,255,255,0.6);
    border: 1px solid var(--color-border); color: var(--color-text-muted);
    padding: 0.45rem; border-radius: 9999px; font-size: 0.75rem; cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}
.pitch-btn.active { background: rgba(93, 112, 82, 0.12); border-color: var(--color-primary); color: var(--color-primary); font-weight: 700; }

.quick-selector {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.35rem;
    margin-top: 0.35rem;
}

.quick-btn {
    min-width: 0;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    padding: 0.38rem 0.35rem;
    border-radius: 9999px;
    font-size: 0.72rem;
    line-height: 1.1;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    white-space: nowrap;
}

.quick-btn.active {
    background: rgba(93, 112, 82, 0.12);
    border-color: var(--color-primary);
    color: var(--color-primary);
    font-weight: 700;
}

/* Interactive Room Canvas Center Panel */
.simulation-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 500px;
}

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

.mode-selector {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 0.25rem;
    border: 1px solid var(--border-glass);
}

.mode-tab {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    transition: all 0.2s;
}

.mode-tab.active {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-weight: 600;
}

.mode-tab:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.sim-viewport {
    flex: 1;
    position: relative;
    background: #F5F2EB;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 4px 12px rgba(93, 112, 82, 0.08);
}

/* Grid Wrapper and Container Sizing */
.grid-wrapper {
    position: relative;
    width: 95%;
    max-width: 550px;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
}

.grid-wrapper.simulation-running {
    cursor: grab;
}

.grid-wrapper.simulation-running.is-orbiting {
    cursor: grabbing;
}

.grid-wrapper.simulation-running .grid-container {
    pointer-events: none;
}

.grid-wrapper.view-3d .grid-container {
    visibility: hidden;
}

.grid-container {
    position: relative;
    display: grid;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.01) 1px, transparent 1px);
    background-size: 16px 16px;
}

.grid-cell {
    border: 1px solid rgba(93, 112, 82, 0.04);
    transition: background 0.15s ease;
    cursor: crosshair;
    position: relative;
    border-radius: 2px;
}

.grid-cell.is-hidden-outside {
    background: var(--color-wall) !important;
    border-color: rgba(222, 216, 207, 0.08) !important;
    box-shadow: inset 0 0 6px rgba(0,0,0,0.25) !important;
}

/* Cells states */
.cell-floor {
    background-color: var(--color-floor);
    border-color: rgba(93, 112, 82, 0.08);
}

.cell-wall {
    background-color: var(--color-wall);
    border-color: rgba(222, 216, 207, 0.3);
    box-shadow: inset 0 0 6px rgba(0,0,0,0.25);
}

.cell-furniture {
    background-color: #F0EBE5;
    border: 1px solid var(--color-border);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem;
}
.furniture-icon { pointer-events: none; opacity: 0.85; }

.cell-window {
    background-color: var(--color-window);
    border: 2px solid var(--color-secondary);
    box-shadow: 0 0 8px rgba(193, 140, 93, 0.25);
}

.cell-ac {
    background-color: var(--color-ac);
    border: 2px solid var(--color-primary);
    box-shadow: 0 0 10px rgba(93, 112, 82, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--color-primary);
}

.cell-fan {
    background-color: var(--color-fan);
    border: 2px solid var(--color-primary);
    box-shadow: 0 0 10px rgba(93, 112, 82, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--color-primary);
}

/* Direction indicators inside cells */
.dir-arrow {
    position: absolute;
    font-weight: 900;
    pointer-events: none;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.cell-ac .dir-arrow {
    color: var(--accent-cyan);
    text-shadow: 0 0 5px rgba(0,242,254,0.8);
}

.cell-fan .dir-arrow {
    color: var(--accent-green);
    text-shadow: 0 0 5px rgba(0,245,160,0.8);
}

/* Overlay CFD Canvas */
.simulation-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Let clicks pass through to the grids underneath */
    mix-blend-mode: normal;
}

/* Simulation Controls Panel */
.sim-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    background: rgba(240, 235, 229, 0.5);
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    border: 1px solid var(--color-border);
}

.control-icon-btn {
    background: transparent;
    border: none;
    color: var(--color-text-main);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.control-icon-btn:hover {
    color: var(--color-primary);
    background: rgba(93, 112, 82, 0.1);
}

.control-icon-btn:active {
    transform: scale(0.9);
}

/* Visual Layers Panel toggles */
.layer-toggles {
    display: flex;
    gap: 0.4rem;
    font-size: 0.75rem;
}

.layer-toggle-btn {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    padding: 0.35rem 0.7rem;
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.layer-toggle-btn:hover {
    background: rgba(230, 220, 205, 0.3);
}

.layer-toggle-btn.active {
    background: rgba(93, 112, 82, 0.12);
    border-color: var(--color-primary);
    color: var(--color-primary);
    font-weight: 700;
}

.fan-count-select {
    width: 100%;
    margin-top: 0.45rem;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.8);
    color: var(--color-text-main);
    outline: none;
    font-family: var(--font-body);
}

/* Circular Analytics progress ring */
.score-circle-container {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    width: 140px;
    height: 140px;
    margin: 0 auto;
}

.score-svg {
    transform: rotate(-90deg);
}

.score-track {
    fill: none;
    stroke: rgba(255, 255, 255, 0.03);
    stroke-width: 8;
}

.score-fill {
    fill: none;
    stroke: url(#score-gradient);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 377;
    stroke-dashoffset: 377; /* Decreases as score increases (circumference = 2 * PI * 60) */
    transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.score-text-box {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.score-value {
    font-family: var(--font-header);
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1;
}

.score-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-text-muted);
    margin-top: 0.2rem;
}

/* Stats list table */
.stats-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.8rem;
    background: rgba(240, 235, 229, 0.35);
    border: 1px solid rgba(222, 216, 207, 0.5);
    border-radius: 12px;
    font-size: 0.8rem;
}

.stat-title {
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-val {
    font-weight: 700;
    font-family: var(--font-header);
}

/* Charts canvas */
.chart-container {
    width: 100%;
    height: 100px;
    border: 1px solid rgba(222, 216, 207, 0.5);
    border-radius: 12px;
    background: rgba(240, 235, 229, 0.25);
    overflow: hidden;
    position: relative;
}

.chart-canvas {
    width: 100%;
    height: 100%;
}

/* Auto optimizer recommendations list */
.rec-title {
    font-family: var(--font-header);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-text-main);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.rec-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.rec-card {
    background: rgba(93, 112, 82, 0.03);
    border: 1px solid rgba(93, 112, 82, 0.1);
    border-radius: 12px;
    padding: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.rec-card:hover {
    background: rgba(93, 112, 82, 0.08);
    border-color: rgba(93, 112, 82, 0.35);
    transform: translateX(3px);
}

.rec-rank {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-primary);
    color: var(--color-primary-fg);
    font-size: 0.75rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rec-details {
    flex: 1;
    margin-left: 0.75rem;
}

.rec-pos {
    font-size: 0.8rem;
    font-weight: 600;
}

.rec-sub {
    font-size: 0.65rem;
    color: var(--color-text-muted);
}

.rec-score-pill {
    background: rgba(93, 112, 82, 0.1);
    color: var(--color-primary);
    font-weight: 700;
    font-family: var(--font-header);
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    border: 1px solid rgba(93, 112, 82, 0.2);
}

/* Pulsing ghost highlight spots for recommended fans on the grid */
.pulse-highlight {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 2px dashed var(--color-primary);
    border-radius: 4px;
    box-shadow: 0 0 12px rgba(93, 112, 82, 0.25);
    animation: cell-pulse 1.5s infinite ease-in-out;
    pointer-events: none;
    z-index: 5;
    background: rgba(93, 112, 82, 0.08);
}

.pulse-highlight-num {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-primary);
    color: var(--color-primary-fg);
    font-size: 0.65rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

@keyframes cell-pulse {
    0% { opacity: 0.3; transform: scale(0.95); }
    50% { opacity: 0.9; transform: scale(1.03); }
    100% { opacity: 0.3; transform: scale(0.95); }
}

/* Educational Info Tooltip / Tip Card */
.tip-card {
    background: rgba(93, 112, 82, 0.04);
    border-left: 4px solid var(--color-primary);
    padding: 0.85rem;
    border-radius: 0 16px 16px 0;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    line-height: 1.4;
}

.tip-title {
    font-weight: 700;
    color: var(--color-text-main);
    margin-bottom: 0.2rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* Modal overlay (e.g. optimizer loading progress) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(44, 44, 36, 0.6);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--color-border);
    border-radius: 2rem;
    padding: 2rem;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: var(--shadow-float);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(93, 112, 82, 0.1);
    border-top: 4px solid var(--color-primary);
    border-radius: 50%;
    margin: 0 auto;
    animation: rotate-breeze 1s linear infinite;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--color-muted);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--color-accent), var(--color-primary));
    transition: width 0.1s ease;
}

/* Helper spacing utilities */
.flex-row {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
}

.divider {
    height: 1px;
    background: var(--color-border);
    width: 100%;
}

/* Floating Color Legend Bar */
.sim-legend {
    position: absolute;
    right: 15px;
    top: 15px;
    background: rgba(254, 254, 250, 0.95);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 8px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 15;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.65rem;
    color: var(--color-text-muted);
    width: 65px;
    align-items: center;
    box-shadow: var(--shadow-soft);
}

.legend-title {
    font-weight: 700;
    color: var(--color-text-main);
    font-size: 0.7rem;
    font-family: var(--font-header);
}

.legend-bar-container {
    display: flex;
    height: 120px;
    gap: 6px;
    width: 100%;
    align-items: center;
    justify-content: center;
}

.legend-gradient {
    width: 8px;
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(to bottom, #d91616 0%, #8dd916 50%, #16c3d9 100%);
    transition: background 0.3s ease;
}

.legend-labels {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    font-family: var(--font-header);
    font-weight: 600;
    font-size: 0.6rem;
    line-height: 1;
}

/* Floating 3D Double Layer Legend */
.double-layer-legend {
    position: absolute;
    left: 15px;
    bottom: 15px;
    background: rgba(254, 254, 250, 0.95);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 10px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 15;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.65rem;
    color: var(--color-text-muted);
    width: 120px;
    box-shadow: var(--shadow-soft);
}

.double-layer-legend .legend-title {
    font-weight: 700;
    color: var(--color-text-main);
    font-size: 0.7rem;
    font-family: var(--font-header);
    margin-bottom: 2px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--color-text-main);
    text-align: left;
}

.legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
}
