* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body,
html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #121212;
    color: #e0e0e0;
}

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

/* ==========================================================================
   Sidebar Structure (Header Pinned, Scrollable Body, Export Footer Pinned)
   ========================================================================== */
#sidebar {
    width: 360px;
    height: 100vh;
    background: #191919;
    border-right: 1px solid #303030;
    display: flex;
    flex-direction: column;
    z-index: 10;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.5);
    overflow: hidden; /* Header and Footer stay locked */
}

/* Pinned Header */
.sidebar-header {
    padding: 16px 18px 12px 18px;
    border-bottom: 2px solid #2ecc71;
    background: #1f1f1f;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
}

.sidebar-header h2 {
    font-size: 1.15rem;
    color: #fff;
    margin: 0;
    font-weight: 700;
}

/* History (Undo / Redo) Buttons */
.history-controls {
    display: flex;
    gap: 5px;
}

.btn-history {
    background: #2b2b2b;
    color: #e0e0e0;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 4px 9px;
    font-size: 0.74rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 3px;
    transition: all 0.2s;
    user-select: none;
}

.btn-history:hover:not(:disabled) {
    background: #383838;
    border-color: #2ecc71;
    color: #2ecc71;
}

.btn-history:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    border-color: #333;
}

/* ==========================================================================
   Scrollable Middle Area
   ========================================================================== */
.sidebar-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px; /* Clear spacing between sections */
}

/* Custom Sleek Scrollbar */
.sidebar-scroll-area::-webkit-scrollbar {
    width: 6px;
}

.sidebar-scroll-area::-webkit-scrollbar-track {
    background: #161616;
}

.sidebar-scroll-area::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

.sidebar-scroll-area::-webkit-scrollbar-thumb:hover {
    background: #2ecc7188;
}

/* ==========================================================================
   Distinct Settings Blocks (No dropdowns)
   ========================================================================== */
.settings-block {
    background: #232323;
    border: 1px solid #353535;
    border-radius: 8px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.settings-block h3 {
    font-size: 0.84rem;
    color: #2ecc71;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-bottom: 1px solid #333;
    padding-bottom: 6px;
    margin-bottom: 2px;
}

/* Highlight Block for Global / Auto Settings */
.settings-block.highlight-block {
    background: #222723;
    border: 1px solid #2ecc7144;
    border-left: 3px solid #2ecc71;
}

.settings-block.highlight-block h3 {
    color: #4ade80;
    border-bottom-color: #2ecc7133;
}

/* Arch Loop Block Accent */
.settings-block#arch-loop-options {
    border-left: 3px solid #4ade80;
}

/* ==========================================================================
   Form Controls
   ========================================================================== */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-group label {
    font-size: 0.82rem;
    color: #bbb;
    font-weight: 500;
}

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.range-bounds {
    font-size: 0.70rem;
    color: #888;
    font-family: monospace;
    background: #1b1b1b;
    padding: 1px 5px;
    border-radius: 3px;
    border: 1px solid #333;
}

.checkbox-row label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #ddd;
    font-size: 0.82rem;
    font-weight: 500;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    background: #1b1b1b;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #333;
}

.checkbox-grid label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    cursor: pointer;
    color: #ccc;
}

.control-group input[type="text"],
.control-group select {
    background: #2a2a2a;
    border: 1px solid #444;
    color: #fff;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s;
}

.control-group input[type="text"]:focus,
.control-group select:focus {
    border-color: #2ecc71;
}

.control-group input[type="range"] {
    accent-color: #2ecc71;
    cursor: pointer;
}

/* ==========================================================================
   Pinned Export & Viewport Options Footer
   ========================================================================== */
.export-module {
    padding: 14px 16px 16px 16px;
    background: #161616;
    border-top: 1px solid #333;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.export-module h3 {
    font-size: 0.86rem;
    color: #bbb;
    margin-bottom: 2px;
}

.btn {
    width: 100%;
    padding: 9px 12px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

.btn.primary {
    background: #2ecc71;
    color: #fff;
}

.btn.primary:hover {
    background: #27ae60;
}

.btn.secondary {
    background: #34495e;
    color: #fff;
}

.btn.secondary:hover {
    background: #2c3e50;
}

/* ==========================================================================
   3D Viewport
   ========================================================================== */
#viewport-container {
    flex-grow: 1;
    position: relative;
    background: radial-gradient(circle at center, #2c3e50 0%, #1a252f 100%);
}

#loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 15px 25px;
    border-radius: 8px;
    font-weight: 500;
    letter-spacing: 0.5px;
    pointer-events: none;
    z-index: 5;
}