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

body {
    background: #111;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #fff;
    overflow: hidden;
}

#app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

#canvasContainer {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    min-width: 0;
}

#canvas {
    max-width: 100%;
    max-height: 100%;
    image-rendering: pixelated;
}

/* Sidebar */
#sidebar {
    width: 280px;
    background: #1a1a1a;
    border-left: 1px solid #333;
    overflow-y: auto;
    flex-shrink: 0;
}

.toolbar {
    padding: 12px;
    background: #222;
    border-bottom: 1px solid #333;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.toolbar button {
    padding: 6px 12px;
    background: #444;
    border: 1px solid #555;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.toolbar button:hover {
    background: #555;
}

#fps {
    font-size: 11px;
    color: #888;
    margin-left: auto;
    font-family: monospace;
    min-width: 120px;
    text-align: right;
}

/* Settings sections */
.settings-section {
    padding: 10px 12px;
    border-bottom: 1px solid #333;
}

.settings-section h3 {
    font-size: 10px;
    color: #666;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.settings-section label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    margin-bottom: 2px;
}

.settings-section label span:first-child {
    color: #aaa;
}

.settings-section label .val {
    color: #6af;
    font-family: monospace;
    font-size: 11px;
    min-width: 40px;
    text-align: right;
}

.settings-section input[type="range"] {
    width: 100%;
    margin-bottom: 8px;
}

.settings-section select {
    padding: 4px 8px;
    background: #333;
    border: 1px solid #444;
    color: #fff;
    border-radius: 3px;
    font-size: 12px;
    width: 100%;
    margin-top: 2px;
}

.preset-desc {
    display: block;
    font-size: 10px;
    color: #666;
    margin: 6px 0 10px 0;
}

/* Toggles */
.toggles {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.toggles.compact {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

label.toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    background: #252525;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    margin: 0;
}

label.toggle:hover {
    background: #2a2a2a;
}

label.toggle input[type="checkbox"] {
    width: 14px;
    height: 14px;
    margin: 0;
    cursor: pointer;
    accent-color: #6af;
    flex-shrink: 0;
}

label.toggle span {
    font-size: 11px;
    color: #ddd;
}

label.toggle small {
    font-size: 10px;
    color: #666;
}

label.toggle:has(input:not(:checked)) {
    opacity: 0.5;
}

label.toggle:has(input:not(:checked)) span {
    text-decoration: line-through;
    color: #888;
}

label.toggle.inline {
    background: transparent;
    padding: 0;
}

label.toggle.inline:hover {
    background: transparent;
}

/* Species legend */
.species-legend .legend {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    color: #aaa;
}

.swatch {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    border: 1px solid #444;
}

/* Scrollbar */
#sidebar::-webkit-scrollbar {
    width: 6px;
}

#sidebar::-webkit-scrollbar-track {
    background: #1a1a1a;
}

#sidebar::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 3px;
}

#sidebar::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Responsive: stack on narrow screens */
@media (max-width: 700px) {
    #app {
        flex-direction: column;
    }

    #sidebar {
        width: 100%;
        max-height: 40vh;
        border-left: none;
        border-top: 1px solid #333;
    }

    #canvasContainer {
        flex: 1;
    }
}
