* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #0f0f1a;
    color: #e0e0e0;
    overflow: hidden;
}

#app {
    display: flex;
    height: 100vh;
}

#sidebar {
    width: 340px;
    background: #1a1a2e;
    padding: 20px;
    overflow-y: auto;
    border-right: 1px solid #2d2d44;
}

#sidebar h1 {
    font-size: 1.5rem;
    margin-bottom: 4px;
    color: #fff;
}

.subtitle {
    color: #888;
    font-size: 0.85rem;
    margin-bottom: 20px;
}

.site-logo {
    display: inline-block;
    margin-bottom: 12px;
}

.site-logo img {
    height: 24px;
    width: auto;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed #4a4a6a;
    border-radius: 12px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 20px;
    position: relative;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.drop-zone-content {
    pointer-events: none;
}

.drop-zone svg {
    color: #10b981;
    margin-bottom: 12px;
}

.drop-zone p {
    margin-bottom: 4px;
}

.drop-zone .hint {
    font-size: 0.8rem;
    color: #666;
}

.drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* Info Panel */
.info-panel {
    background: #252540;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}

.info-panel h3 {
    font-size: 0.9rem;
    margin-bottom: 12px;
    color: #fff;
}

#info-content {
    font-size: 0.85rem;
    line-height: 1.6;
}

#info-content .info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

#info-content .info-label {
    color: #888;
}

/* Settings Panel */
.settings-panel {
    background: #252540;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}

.settings-panel h3 {
    font-size: 0.9rem;
    margin-bottom: 12px;
    color: #fff;
}

.settings-panel h3:not(:first-child) {
    margin-top: 16px;
}

/* Radio Group */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-option {
    display: flex;
    flex-direction: column;
    padding: 10px 12px;
    background: #1a1a2e;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.radio-option:hover {
    background: #2d2d50;
}

.radio-option:has(input:checked) {
    background: rgba(16, 185, 129, 0.15);
    border-color: #10b981;
}

.radio-option input[type="radio"] {
    display: none;
}

.radio-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.radio-label::before {
    content: '';
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #4a4a6a;
    transition: all 0.2s;
}

.radio-option:has(input:checked) .radio-label::before {
    border-color: #10b981;
    background: #10b981;
    box-shadow: inset 0 0 0 3px #252540;
}

.radio-desc {
    font-size: 0.75rem;
    color: #888;
    margin-left: 22px;
    margin-top: 2px;
}

/* Sub-options */
.sub-options {
    margin-top: 12px;
    padding: 12px;
    background: #1a1a2e;
    border-radius: 6px;
}

.sub-options .control-group {
    margin-bottom: 8px;
}

.sub-options .control-group:last-child {
    margin-bottom: 0;
}

.sub-options label {
    font-size: 0.8rem;
    color: #ccc;
}

.sub-options input[type="range"] {
    width: 100%;
    margin-top: 6px;
    accent-color: #10b981;
}

.sub-options input[type="number"] {
    width: 100%;
    margin-top: 6px;
    padding: 6px 10px;
    background: #252540;
    border: 1px solid #3d3d5c;
    border-radius: 4px;
    color: #fff;
    font-size: 0.85rem;
}

/* Controls */
#controls h3 {
    font-size: 0.9rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    margin-top: 16px;
}

#controls h3:first-child {
    margin-top: 0;
}

.control-group {
    margin-bottom: 12px;
}

.control-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    cursor: pointer;
}

.control-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #10b981;
}

.control-group input[type="text"],
.control-group select {
    width: 100%;
    padding: 8px 10px;
    background: #252540;
    border: 1px solid #3d3d5c;
    border-radius: 6px;
    color: #fff;
    font-size: 0.85rem;
    margin-top: 4px;
}

.control-group input[type="text"]:focus,
.control-group select:focus {
    outline: none;
    border-color: #10b981;
}

.control-group select option {
    background: #252540;
}

/* Color boxes */
.color-box {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    display: inline-block;
}

.color-box.green { background: #10b981; }
.color-box.cyan { background: #00ffff; }
.color-box.yellow { background: #ffff00; }
.color-box.purple { background: #ff00ff; }
.color-box.blue { background: #4a9eff; }

/* Buttons */
.btn {
    width: 100%;
    padding: 10px 16px;
    background: #3d3d5c;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 12px;
}

.btn:hover:not(:disabled) {
    background: #4d4d6c;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #10b981;
    color: #000;
}

.btn-primary:hover:not(:disabled) {
    background: #0d9668;
}

.btn-danger {
    background: #ef4444;
    color: #fff;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

/* Face Editor */
#face-editor .hint {
    font-size: 0.75rem;
    color: #888;
    margin: 8px 0;
    font-style: italic;
}

#face-editor input[type="range"] {
    width: 100%;
    margin-top: 6px;
    accent-color: #10b981;
}

#face-editor .control-group label {
    display: block;
    font-size: 0.8rem;
    color: #ccc;
}

#face-editor .control-group {
    margin-bottom: 8px;
}

#face-editor .btn {
    margin-top: 8px;
}

#face-editor #apply-surface-btn {
    margin-top: 12px;
}

#selection-info {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #3d3d5c;
}

.edit-mode-active {
    border-color: #f59e0b !important;
}

.edit-mode-active h3::after {
    content: ' (Edit Mode)';
    color: #f59e0b;
    font-size: 0.75rem;
}

/* Edit mode cursor */
body.edit-mode-cursor #canvas {
    cursor: crosshair;
}

/* Exclusion mode cursor */
body.exclusion-mode-cursor #canvas {
    cursor: crosshair;
}

/* Exclusion panel styles */
#exclusion-panel .hint {
    font-size: 0.75rem;
    color: #888;
    margin: 8px 0;
    font-style: italic;
}

#exclusion-panel .stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 0.85rem;
}

#exclusion-panel .stat-label {
    color: #888;
}

#exclusion-panel .stat-value {
    color: #ff4444;
    font-weight: 500;
}

#exclusion-panel .btn {
    margin-top: 8px;
}

#exclusion-panel .button-row {
    display: flex;
    gap: 8px;
}

#exclusion-panel .button-row .btn {
    flex: 1;
    margin-top: 0;
}

.btn-small {
    padding: 6px 10px;
    font-size: 0.75rem;
    margin-top: 8px;
    width: auto;
    display: inline-block;
    margin-right: 6px;
}

.exclusion-mode-active {
    border: 2px solid #ff4444 !important;
}

.exclusion-mode-active h3::after {
    content: ' (Active)';
    color: #ff4444;
    font-size: 0.75rem;
}

.color-box.red { background: #ff4444; }
.color-box.orange { background: #ff8800; }

#cropbox-controls {
    margin-top: 8px;
    padding: 8px;
    background: #1a1a2e;
    border-radius: 4px;
}

#cropbox-controls .hint {
    margin-top: 0;
    margin-bottom: 8px;
}

.cropbox-sliders {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}

.cropbox-sliders .slider-row {
    display: flex;
    flex-direction: column;
}

.cropbox-sliders .slider-row label {
    font-size: 0.7rem;
    color: #888;
    margin-bottom: 2px;
}

.cropbox-sliders .slider-row label span {
    color: #ff8800;
    font-weight: 500;
}

.cropbox-sliders input[type="range"] {
    width: 100%;
    accent-color: #ff8800;
    height: 4px;
}

/* Viewport */
#viewport {
    flex: 1;
    position: relative;
    background: #1a1a2e;
}

#canvas {
    width: 100%;
    height: 100%;
    display: block;
}

#loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 15, 26, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #2d2d44;
    border-top-color: #10b981;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#stats {
    position: absolute;
    bottom: 16px;
    left: 16px;
    display: flex;
    gap: 16px;
    font-size: 0.8rem;
    color: #888;
    background: rgba(26, 26, 46, 0.9);
    padding: 8px 12px;
    border-radius: 6px;
}

/* Collision stats panel */
#col-stats {
    font-size: 0.85rem;
    line-height: 1.6;
}

#col-stats .stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

#col-stats .stat-label {
    color: #888;
}

#col-stats .stat-value {
    color: #10b981;
    font-weight: 500;
}

/* Credits */
.credits {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #2d2d44;
    font-size: 0.75rem;
    color: #666;
    text-align: center;
}

.credits a {
    color: #888;
    text-decoration: none;
    transition: color 0.2s;
}

.credits a:hover {
    color: #10b981;
}

.credits a.author {
    color: #10b981;
    font-weight: 500;
}

.credits a.author:hover {
    text-decoration: underline;
}

/* Scrollbar */
#sidebar::-webkit-scrollbar {
    width: 8px;
}

#sidebar::-webkit-scrollbar-track {
    background: #1a1a2e;
}

#sidebar::-webkit-scrollbar-thumb {
    background: #3d3d5c;
    border-radius: 4px;
}

#sidebar::-webkit-scrollbar-thumb:hover {
    background: #4d4d6c;
}

/* Responsive - Tablet */
@media (max-width: 900px) {
    body {
        overflow: auto;
    }

    #app {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    #sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #2d2d44;
        padding: 16px;
    }

    #sidebar h1 {
        font-size: 1.25rem;
    }

    #viewport {
        min-height: 50vh;
        height: 50vh;
    }

    .credits {
        display: none;
    }
}

/* Responsive - Mobile */
@media (max-width: 640px) {
    #sidebar {
        padding: 12px;
    }

    #sidebar h1 {
        font-size: 1.1rem;
    }

    .subtitle {
        font-size: 0.8rem;
        margin-bottom: 12px;
    }

    .drop-zone {
        padding: 20px 16px;
        margin-bottom: 12px;
    }

    .drop-zone svg {
        width: 36px;
        height: 36px;
    }

    .radio-option {
        padding: 8px 10px;
    }

    .radio-label {
        font-size: 0.8rem;
    }

    .radio-desc {
        font-size: 0.7rem;
    }

    .info-panel {
        padding: 12px;
        margin-bottom: 12px;
    }

    .settings-panel {
        padding: 12px;
        margin-bottom: 12px;
    }

    .control-group label {
        font-size: 0.8rem;
    }

    .control-group input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }

    .btn {
        padding: 14px 16px;
        font-size: 0.85rem;
    }

    #viewport {
        min-height: 45vh;
        height: 45vh;
    }

    #stats {
        bottom: 12px;
        left: 12px;
        font-size: 0.7rem;
        padding: 6px 10px;
        gap: 12px;
    }
}

/* Very small phones */
@media (max-width: 380px) {
    #sidebar {
        padding: 10px;
    }

    .drop-zone {
        padding: 16px 12px;
    }

    .radio-option {
        padding: 6px 8px;
    }
}
