:root {
    --bg: #1e1e1e;
    --bg-panel: #252526;
    --bg-elevated: #2d2d30;
    --bg-hover: #2a2d2e;
    --bg-active: #094771;
    --border: #3c3c3c;
    --text: #cccccc;
    --text-dim: #858585;
    --accent: #0e639c;
    --accent-hover: #1177bb;
    --danger: #c75050;
    --success: #4ec9b0;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', Tahoma, sans-serif;
    font-size: 13px;
    overflow: hidden;
}

body {
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    height: 44px;
    padding: 0 16px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 16px;
}

.brand {
    font-weight: 600;
    font-size: 14px;
}

.brand-sub {
    color: var(--text-dim);
    font-weight: 400;
    margin-left: 4px;
}

.current {
    flex: 1;
    text-align: center;
    color: var(--text-dim);
}

.current-name {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 13px;
}

.dirty-dot {
    color: var(--success);
    margin-left: 6px;
    font-size: 18px;
    line-height: 0;
    vertical-align: middle;
}

.actions {
    display: flex;
    gap: 8px;
}

.btn {
    background: var(--bg-elevated);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: background 0.1s;
}

.btn:hover:not(:disabled) {
    background: var(--bg-hover);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    font-weight: 500;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-small {
    padding: 3px 10px;
    font-size: 12px;
}

.layout {
    flex: 1;
    display: flex;
    min-height: 0;
}

.sidebar {
    width: 240px;
    background: var(--bg-panel);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-left {
    border-right: 1px solid var(--border);
}

.sidebar-right {
    border-left: 1px solid var(--border);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
    height: 36px;
    flex-shrink: 0;
}

.script-list,
.function-list {
    list-style: none;
    margin: 0;
    padding: 4px 0;
    overflow-y: auto;
    flex: 1;
}

.script-list li {
    padding: 6px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 13px;
    user-select: none;
}

.script-list li:hover {
    background: var(--bg-hover);
}

.script-list li.active {
    background: var(--bg-active);
    color: white;
}

.script-list li::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23519aba'><path d='M9 1H3a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h10a1 1 0 0 0 1-1V6L9 1zm0 1.5L12.5 6H9V2.5z'/></svg>");
    background-repeat: no-repeat;
    background-position: center;
    flex-shrink: 0;
}

.function-list li {
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.1s;
}

.function-list li:hover {
    background: var(--bg-hover);
}

.function-list li.fn-section {
    padding: 8px 14px 4px;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.6px;
    color: var(--text-dim);
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    cursor: default;
    user-select: none;
}

.function-list li.fn-section:hover {
    background: var(--bg-elevated);
}

.function-list .fn-sig {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 13px;
    color: #dcdcaa;
}

.function-list .fn-desc {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 3px;
    line-height: 1.4;
}

.editor-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

.editor {
    flex: 1;
    min-height: 0;
}

.editor-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-dim);
    font-size: 14px;
}

.status {
    height: 22px;
    padding: 0 14px;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    font-size: 11px;
    flex-shrink: 0;
    transition: background 0.2s;
}

.status.is-error {
    background: var(--danger);
}

.status.is-success {
    background: #007a3d;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 20px;
    min-width: 360px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.modal h3 {
    margin: 0 0 14px 0;
    font-size: 14px;
    font-weight: 500;
}

.modal input {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    outline: none;
}

.modal input:focus {
    border-color: var(--accent);
}

.modal-hint {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 6px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}
