body {
    margin: 0;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #1e1e1e;
    color: #e0e0e0;
}

#canvas-container {
    width: 100vw;
    height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
}

#side-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 350px;
    height: 100vh;
    background: rgba(30, 30, 30, 0.9);
    backdrop-filter: blur(5px);
    border-left: 1px solid #444;
    display: flex;
    flex-direction: column;
    padding: 2px;
    box-sizing: border-box;
    z-index: 10;
    overflow-y: auto;
    /* Enable vertical scrolling */
    font-size: 10px;
}

#side-panel * {
    font-size: 10px;
}

.panel-section {
    margin-bottom: 5px;
}

.control-row {
    display: flex;
    gap: 2px;
    margin-bottom: 2px;
    align-items: center;
}

h3 {
    margin-top: 0;
    margin-bottom: 2px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #aaa;
    border-bottom: 1px solid #555;
    padding-bottom: 2px;
}

#log,
.log-box {
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: auto;
    /* Horizontal scroll */
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 10px;
    white-space: pre;
    /* No wrap */
    color: #8f8;
    background: #111;
    border: 1px solid #444;
    padding: 2px;
    min-height: 100px;
}

#script-input {
    width: 100%;
    height: 300px;
    background: #111;
    color: #ddd;
    border: 1px solid #555;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 10px;
    resize: vertical;
    box-sizing: border-box;
    padding: 2px;
    white-space: pre;
    /* No wrap */
    overflow-x: auto;
    /* Horizontal scroll */
}

button,
select {
    background: #444;
    color: #eee;
    border: 1px solid #666;
    padding: 2px 4px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 10px;
}

button:hover {
    background: #555;
}

#gui-resizer {
    width: 5px;
    background: #444;
    cursor: col-resize;
    z-index: 100;
    transition: background 0.2s;
    position: absolute;
    top: 0;
    right: 350px;
    /* Initial width of side-panel */
    height: 100vh;
}

#run-script-btn {
    width: 100%;
    margin-top: 5px;
    background: #2a6;
    border: none;
    color: white;
    font-weight: bold;
}

#run-script-btn:hover {
    background: #3b7;
}

/* Compact UI Helpers */
.compact-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 2px;
}

.compact-label {
    white-space: nowrap;
    color: #ccc;
}

.compact-input {
    background: #333;
    color: #fff;
    border: 1px solid #555;
    padding: 1px 2px;
    border-radius: 2px;
}

.compact-select {
    background: #333;
    color: #fff;
    border: 1px solid #555;
    padding: 1px;
    border-radius: 2px;
    flex-grow: 1;
}

.color-input {
    width: 20px;
    height: 16px;
    border: none;
    padding: 0;
    background: none;
    cursor: pointer;
}

.small-btn {
    padding: 1px 4px;
    font-size: 9px;
}

/* Selection rectangle overlay (copied from molgui_web) */
.selection-box {
    position: fixed;
    border: 1px solid rgba(255, 255, 0, 0.8);
    background-color: rgba(255, 255, 0, 0.2);
    display: none;
    pointer-events: none;
    z-index: 1000;
    top: 0;
    left: 0;
    will-change: transform, width, height;
}