html, body {
    height: 100%;
    margin: 0;
}
body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: Arial, sans-serif;
}
#sidebar {
    width: 240px;
    background: #252526;
    color: white;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    height: 100vh;
    box-sizing: border-box;
}
#sidebarFooter {
    margin-top: auto;
    text-align: center;
    font-size: 11px;
    color: #888;
    padding-top: 12px;
}
#sidebarFooter a {
    color: #4da6ff;
    text-decoration: none;
}
#sidebarFooter a:hover {
    text-decoration: underline;
}
#sidebarHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
#sidebarHeader h3 {
    margin: 0;
}
#showAllLabel {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #aaa;
    font-size: 12px;
    cursor: pointer;
    flex-shrink: 0;
}
#showAllLabel input {
    margin: 0;
}
.file {
    padding: 6px;
    cursor: pointer;
    border-radius: 4px;
}
.file:hover {
    background: #3c3c3c;
}
.file.active {
    background: #007acc;
}
#main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}
#topbar {
    background: #1e1e1e;
    color: white;
    padding: 8px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}
#topbarLeft {
    display: flex;
    align-items: center;
    gap: 10px;
}
#docsLink { color: #4da6ff; text-decoration: none; font-size: 13px; }
#docsLink:hover { text-decoration: underline; }
#topbarRight { display: flex; align-items: center; gap: 10px; margin-left: auto; }
#topbarDivider { width: 1px; height: 18px; background: #555; margin: 0 14px; }
#searchBox {
    background: #2d2d2d;
    border: 1px solid #444;
    border-radius: 4px;
    color: #ccc;
    font-size: 12px;
    padding: 4px 20px 4px 8px;
    width: 180px;
    outline: none;
}
#searchBox:focus { border-color: #4da6ff; }
#searchWrap { position: relative; display: inline-block; margin-left: 12px; }
#searchClear {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    color: #777;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: none;
    user-select: none;
}
#searchClear:hover { color: #ccc; }
#searchResults {
    display: none;
    width: 380px;
    flex-shrink: 0;
    overflow-y: auto;
    background: #252525;
    padding: 12px 16px;
    border-left: 1px solid #333;
}
#searchResults .sr-heading { color: #888; font-size: 12px; margin-bottom: 8px; }
#searchResults .sr-item {
    padding: 6px 8px;
    cursor: pointer;
    color: #ccc;
    border-radius: 3px;
    font-size: 13px;
    font-family: monospace;
    white-space: pre-wrap;
}
#searchResults .sr-item:hover { background: #2a2d2e; }
#searchResults .sr-item .sr-file { color: #4da6ff; }
#searchResults .sr-item .sr-line { color: #888; }
#searchResults .sr-item .sr-match { background: #665c00; border-radius: 2px; padding: 0 2px; }
.search-highlight-line { background: rgba(229, 192, 123, 0.2); }
#editorArea { flex: 1; display: flex; overflow: hidden; }
#modeToggle {
    display: none;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #aaa;
    flex-shrink: 0;
    cursor: pointer;
    user-select: none;
}
#modeToggle input {
    display: none;
}
#modeToggle .toggle-track {
    width: 40px;
    height: 20px;
    background: #555;
    border-radius: 10px;
    position: relative;
    transition: background .2s;
}
#modeToggle .toggle-track::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform .2s;
}
#modeToggle input:checked + .toggle-track {
    background: #007acc;
}
#modeToggle input:checked + .toggle-track::after {
    transform: translateX(20px);
}
#editor {
    flex: 1;
    overflow: hidden;
}
#guiContainer {
    flex: 1;
    overflow-y: auto;
    background: #1e1e1e;
    padding: 16px 20px;
    display: none;
}
#guiPlaceholder {
    color: #666;
    font-style: italic;
    text-align: center;
    margin-top: 60px;
}
#loadingOverlay {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    color: #666;
    font-style: italic;
}
/* GUI sidebar tiles */
#guiFileList {
    display: none;
}
#guiFileList .gui-divider {
    border: none;
    border-top: 1px solid #3c3c3c;
    margin: 12px 0 8px 0;
}
#guiFileList .gui-heading {
    color: #888;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 0 6px 0;
    padding: 0;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 3px;
}
#guiFileList .gui-heading::before {
    content: '\25B6';
    font-size: 8px;
    transition: transform .15s;
}
#guiFileList .gui-heading:not(.collapsed)::before {
    transform: rotate(90deg);
}
#alertBar {
    background: #ffc107;
    color: #000;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    position: relative;
}
#alertBar a {
    color: #000;
    font-weight: bold;
}
#alertBar .alertClose {
    position: absolute;
    right: 12px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    user-select: none;
}
#alertBar .alertClose:hover {
    opacity: .7;
}
.gui-tile-group {
    /* visibility toggled by heading.collapsed + sibling selector */
}
#guiFileList .gui-heading.collapsed + .gui-tile-group {
    display: none;
}
.gui-tile {
    padding: 8px 10px;
    margin-bottom: 4px;
    background: #2d2d2d;
    border: 1px solid #3c3c3c;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background .15s, border-color .15s;
}
.gui-tile:hover {
    background: #3c3c3c;
    border-color: #555;
}
.gui-tile.active {
    background: #094771;
    border-color: #007acc;
}
.gui-tile-icon {
    font-size: 16px;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}
.tree-icon {
    display: inline-block;
    width: 18px;
    text-align: center;
}
.tree-glyph {
    display: inline-block;
    width: 10px;
    color: #999;
}
/* GUI form fields */
.gui-form {
    max-width: 700px;
}
.gui-field {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #2a2a2a;
    min-height: 32px;
}
.gui-label {
    flex: 0 0 auto;
    white-space: nowrap;
    color: #ccc;
    font-size: 13px;
    padding-right: 12px;
    word-break: break-word;
}
.gui-input {
    width: 220px;
    padding: 5px 8px;
    border: 1px solid #3c3c3c;
    border-radius: 4px;
    background: #2d2d2d;
    color: #e0e0e0;
    font-size: 13px;
    outline: none;
    flex-shrink: 0;
    margin-left: auto;
}
.gui-input:focus {
    border-color: #007acc;
}
.gui-input[type="number"] {
    width: 120px;
}
.gui-help {
    cursor: help;
    font-size: 14px;
    margin-left: 4px;
    user-select: none;
    vertical-align: middle;
    display: inline-block;
    position: relative;
}
/* Toggle switch for booleans */
.gui-toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
    margin-left: auto;
}
.gui-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}
.gui-toggle .gui-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #555;
    border-radius: 22px;
    transition: background .2s;
}
.gui-toggle .gui-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform .2s;
}
.gui-toggle input:checked + .gui-slider {
    background: #007acc;
}
.gui-toggle input:checked + .gui-slider::before {
    transform: translateX(18px);
}
/* Collapsible sections */
.gui-section {
    display: block;
    border-bottom: none;
    min-height: 0;
    margin: 4px 0;
}
.gui-section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #4fc1ff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 0;
    user-select: none;
}
.gui-section-header::before {
    content: '\25BC';
    font-size: 10px;
    transition: transform .15s;
    color: #888;
}
.gui-section-header.collapsed::before {
    transform: rotate(-90deg);
}
.gui-section-header:hover {
    color: #7dd3ff;
}
.gui-section-content {
    padding-left: 16px;
    border-left: 2px solid #333;
    margin: 4px 0;
}
.gui-section-error > .gui-section-header {
    background: #5a1a1a;
    border-color: #e05a5a;
}
.gui-section-error > .gui-section-content {
    border-left-color: #e05a5a;
}
.gui-section-content.collapsed {
    display: none;
}
/* List editor */
.gui-list {
    border-bottom: 1px solid #2a2a2a;
    min-height: 0;
}
.gui-list-items {
    min-width: 200px;
    padding: 2px 0;
    margin-left: auto;
}
.gui-list-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
}
.gui-list-item .gui-input {
    width: 180px;
}
.gui-list-item .gui-toggle {
    width: 36px;
    height: 20px;
}
.gui-list-item .gui-toggle .gui-slider::before {
    width: 16px;
    height: 16px;
}
.gui-list-item .gui-toggle input:checked + .gui-slider::before {
    transform: translateX(16px);
}
.gui-remove-btn {
    background: none;
    border: none;
    color: #e05a5a;
    cursor: pointer;
    font-size: 18px;
    padding: 0 4px;
    line-height: 1;
    margin: 0;
}
.gui-remove-btn:hover {
    color: #ff7a7a;
}
.gui-add-btn {
    background: #2d2d2d;
    border: 1px dashed #555;
    color: #aaa;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    margin-top: 4px;
    width: 100%;
}
.gui-add-btn:hover {
    background: #3c3c3c;
    color: #ccc;
}
.gui-del-btn {
    background: none;
    border: none;
    color: #e05a5a;
    cursor: pointer;
    font-size: 18px;
    padding: 0 4px;
    line-height: 1;
    user-select: none;
}
.gui-del-btn:hover {
    color: #ff7a7a;
}
.gui-divider {
    border: none;
    border-top: 1px solid #2a2a2a;
    margin: 8px 0;
}
.gui-list-object {
    flex: 1;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 8px;
    background: #252525;
}
.gui-list-object .gui-field {
    border-bottom-color: #2a2a2a;
}
#errorBar {
    background: #3a1a1a;
    color: #ff6b6b;
    padding: 8px 12px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-y: auto;
    max-height: 80px;
    flex-shrink: 0;
    display: none;
}
#errorBar.visible {
    display: block;
}
#saveBtn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.gui-input[disabled] {
    background: #222;
    color: #666;
    cursor: not-allowed;
    border-color: #2a2a2a;
}
.gui-result-highlight {
    outline: 2px solid #ffa500;
    outline-offset: 2px;
    border-radius: 4px;
    transition: outline-color 0.3s;
}
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6); z-index: 1000;
    display: flex; align-items: center; justify-content: center;
}
.modal-box {
    background: #2d2d2d; border: 1px solid #555; border-radius: 6px;
    padding: 20px; min-width: 300px;
}
.modal-box h3 {
    margin: 0 0 12px 0; color: #ddd; font-size: 15px;
}
#helpTooltip {
    display: none;
    position: fixed;
    background: #333;
    color: #eee;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
    max-width: 320px;
    z-index: 9999;
    pointer-events: none;
    line-height: 1.4;
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
