:root {
    --bg-base: #F3F4F6;
    --surface: #FFFFFF;
    --border: #E5E7EB;
    --text-main: #111827;
    --text-muted: #6B7280;
    --primary: #0F766E;
    --primary-hover: #0D9488;
    --secondary: #F3F4F6;
    --danger: #B91C1C;
    --radius: 12px;
    --leaf-dark: #2E7D32;
    --leaf-mid: #4CAF50;
    --leaf-light: #81C784;
    --ai-bg: #0F172A;
    --ai-header: #0B1121;
    --ai-line: #1E293B;
    --shadow: 0 4px 6px -1px rgba(17, 24, 39, 0.06), 0 1px 3px rgba(17, 24, 39, 0.04);
    --track: #E5E7EB;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 20px;
}

.dashboard {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr) 400px;
    width: 100%;
    max-width: 1600px;
    height: calc(100vh - 40px);
    max-height: 920px;
    gap: 16px;
}

.panel {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.sidebar-left {
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
}

.scene-container {
    position: relative;
    background: linear-gradient(180deg, #EAF3F8 0%, #F7FBFF 38%, #F3F6F1 72%, #E9E1D6 100%);
}

.sidebar-right {
    background: var(--ai-bg);
    color: #F8FAFC;
    display: flex;
    flex-direction: column;
}

header h1 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

header p {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.controls-wrapper {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

label { font-size: 13px; font-weight: 500; }

.value-badge {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    box-shadow: 0 1px 2px rgba(17, 24, 39, 0.05);
}

.divider {
    border: 0;
    border-top: 1px solid var(--border);
}

.time-control {
    margin-top: auto;
    background: #F8FAFC;
    padding: 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
}

.time-inputs { display: flex; gap: 8px; }

.time-inputs input,
.time-inputs select {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    background: #fff;
    color: var(--text-main);
    box-shadow: 0 1px 2px rgba(17, 24, 39, 0.05);
}

.time-inputs input:focus,
.time-inputs select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.btn-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.btn-primary,
.btn-secondary {
    border: none;
    padding: 11px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary.is-running { background: var(--danger); }
.btn-secondary {
    background: var(--secondary);
    color: var(--text-main);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: #E5E7EB; }

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: var(--track);
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--primary);
    box-shadow: 0 1px 3px rgba(17, 24, 39, 0.18);
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--primary);
    box-shadow: 0 1px 3px rgba(17, 24, 39, 0.18);
    cursor: pointer;
}

.slider-growth {
    background: linear-gradient(to right, var(--leaf-mid) var(--fill, 50%), var(--track) var(--fill, 50%));
}

.slider-stress {
    background: linear-gradient(to right, #A16207 var(--fill, 0%), var(--track) var(--fill, 0%));
}

#aba.slider-stress {
    background: linear-gradient(to right, #92400E var(--fill, 0%), var(--track) var(--fill, 0%));
}

#aba::-webkit-slider-thumb { border-color: #92400E; }
#aba::-moz-range-thumb { border-color: #92400E; }
#ethylene::-webkit-slider-thumb { border-color: #A16207; }
#ethylene::-moz-range-thumb { border-color: #A16207; }

.sky-haze {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 16%, rgba(255, 255, 255, 0.65) 0%, transparent 52%);
    pointer-events: none;
    z-index: 1;
}

#plantVector {
    position: relative;
    z-index: 5;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.scene-caption {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 8;
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748B;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px 10px;
}

.ai-panel header {
    padding: 22px 24px;
    border-bottom: 1px solid var(--ai-line);
    background: var(--ai-header);
}

.ai-panel header p { color: #94A3B8; }

.ai-header-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-status-dot {
    width: 8px;
    height: 8px;
    background: #4ADE80;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(74, 222, 128, 0.12);
    animation: pulse 2.4s infinite;
}

.ai-status-dot.is-alert {
    background: #E11D48;
    box-shadow: 0 0 0 4px rgba(225, 29, 72, 0.16);
}

.ai-content {
    padding: 20px 24px 24px;
    flex: 1;
    overflow-y: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.65;
    color: #CBD5E1;
}

.ai-placeholder { color: #64748B; font-style: italic; }

.ai-block {
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px dashed #334155;
}

.ai-block:last-child { border-bottom: 0; margin-bottom: 0; }

.ai-block strong {
    color: #A8C5B4;
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
}

.ai-alert { color: #FCA5A5; }

.ai-metric {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: #94A3B8;
    font-size: 11px;
    margin-top: 6px;
}

.ai-metric span { color: #E2E8F0; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

@media (max-width: 1180px) {
    body { padding: 12px; }
    .dashboard {
        grid-template-columns: 1fr;
        height: auto;
        max-height: none;
    }
    .scene-container { min-height: 520px; }
    .time-control { margin-top: 8px; }
}
