:root {
    --bg-app: #f1f5f9;
    --bg-panel: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --border: #e2e8f0;
    --danger: #ef4444;
    --success: #10b981;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --radius: 12px;
}

body {
    margin: 0;
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    overflow: hidden;
}

.lab-container {
    display: flex;
    height: 100vh;
}

/* Sidebar Controls */
.controls {
    width: 320px;
    background: var(--bg-panel);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    border-right: 1px solid var(--border);
    z-index: 10;
    box-shadow: var(--shadow);
    overflow-y: auto;
    max-height: 100vh;
    box-sizing: border-box;
}

.controls h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-main);
}

.controls p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

select,
input[type="range"] {
    width: 100%;
    padding: 10px;
    background: var(--bg-app);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 8px;
    outline: none;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

select:focus {
    border-color: var(--accent);
}

/* Buttons */
.actions {
    display: flex;
    gap: 12px;
}

button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
}

button:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-danger {
    background: var(--danger);
    color: white;
    opacity: 0.5;
    pointer-events: none;
}

.btn-danger.active {
    opacity: 1;
    pointer-events: all;
}

/* Device Info & Links */
.device-info {
    background: var(--bg-app);
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.device-info ul {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.device-info li {
    margin-bottom: 4px;
}

.device-info span {
    font-weight: 600;
    color: var(--text-main);
}

.navigation-link a {
    display: block;
    margin-top: 10px;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}

.navigation-link a:hover {
    text-decoration: underline;
}

/* Stage Area */
.stage-area {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    background: #ffffff;
}

/* Stats Overlay */
.stats-panel {
    position: absolute;
    top: 24px;
    left: 24px;
    display: flex;
    gap: 16px;
    z-index: 20;
}

.stat-box {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    padding: 12px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    text-align: center;
    min-width: 100px;
}

.stat-box .label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
}

.stat-box .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    font-family: monospace;
}

/* Chart */
.chart-container {
    height: 220px;
    background: var(--bg-app);
    width: 100%;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    box-sizing: border-box;
}

/* Render Stage */
.render-stage {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #ffffff;
}

/* Particles & Scenarios */
.particle {
    position: absolute;
    width: 20px;
    height: 20px;
    background: var(--accent);
    border-radius: 6px;
    will-change: transform;
}

.scenario-opacity {
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    from {
        opacity: 0.1;
    }

    to {
        opacity: 1;
    }
}

.scenario-shadows {
    background: #fff;
    border: 1px solid var(--border);
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3);
    animation: rotate 2s linear infinite;
}

.scenario-filters {
    background: linear-gradient(135deg, #ef4444, #2563eb);
    filter: blur(4px);
}

.scenario-layout {
    transition: none;
}

.scenario-transform {
    transform: translate3d(0, 0, 0);
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* History Section */
.history-section {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    margin-top: 16px;
    min-height: 100px;
    margin-bottom: 16px;
}

.history-section h3 {
    font-size: 1rem;
    margin: 0 0 12px 0;
    color: var(--text-main);
}

.history-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    background: var(--bg-app);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.run-info {
    display: flex;
    flex-direction: column;
}

.run-scenario {
    font-weight: 600;
    color: var(--text-main);
}

.run-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.run-stats {
    text-align: right;
}

.run-fps {
    display: block;
    font-weight: bold;
    color: var(--accent);
}

.device-info span {
    font-weight: 600;
    color: var(--text-main);
}

.navigation-link a {
    display: block;
    margin-top: 10px;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}

.navigation-link a:hover {
    text-decoration: underline;
}

/* Stage Area */
.stage-area {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    background: #ffffff;
}

/* Stats Overlay */
.stats-panel {
    position: absolute;
    top: 24px;
    left: 24px;
    display: flex;
    gap: 16px;
    z-index: 20;
}

.stat-box {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    padding: 12px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    text-align: center;
    min-width: 100px;
}

.stat-box .label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
}

.stat-box .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    font-family: monospace;
}

/* Chart */
.chart-container {
    height: 220px;
    background: var(--bg-app);
    width: 100%;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    box-sizing: border-box;
}

/* Render Stage */
.render-stage {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #ffffff;
}

/* Particles & Scenarios */
.particle {
    position: absolute;
    width: 20px;
    height: 20px;
    background: var(--accent);
    border-radius: 6px;
    will-change: transform;
}

.scenario-opacity {
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    from {
        opacity: 0.1;
    }

    to {
        opacity: 1;
    }
}

.scenario-shadows {
    background: #fff;
    border: 1px solid var(--border);
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3);
    animation: rotate 2s linear infinite;
}

.scenario-filters {
    background: linear-gradient(135deg, #ef4444, #2563eb);
    filter: blur(4px);
}

.scenario-layout {
    transition: none;
}

.scenario-transform {
    transform: translate3d(0, 0, 0);
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* History Section */
.history-section {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    margin-top: 16px;
    min-height: 100px;
    margin-bottom: 16px;
}

.history-section h3 {
    font-size: 1rem;
    margin: 0 0 12px 0;
    color: var(--text-main);
}

.history-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    background: var(--bg-app);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.run-info {
    display: flex;
    flex-direction: column;
}

.run-scenario {
    font-weight: 600;
    color: var(--text-main);
}

.run-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.run-stats {
    text-align: right;
}

.run-fps {
    display: block;
    font-weight: bold;
    color: var(--accent);
}

.run-score {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 10px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(4px);
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--bg-panel);
    padding: 24px;
    border-radius: var(--radius);
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: scale(1);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal.hidden .modal-content {
    transform: scale(0.9);
}

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

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-main);
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    line-height: 1;
}

.close-btn:hover {
    color: var(--text-main);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-app);
    border-radius: 8px;
    border: 1px solid var(--border);
}

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

.result-value {
    font-weight: 700;
    color: var(--text-main);
    font-family: monospace;
    font-size: 1.1rem;
}

.modal-footer {
    text-align: right;
}

.modal-footer button {
    width: auto;
    padding: 10px 24px;
}