:root {
    /* V8 Premium Dark Theme */
    --bg-color: #0f0f1a;
    --surface-color: #1a1a2e;
    --surface-hover: #252542;
    --text-color: #e8e8f0;
    --text-secondary: #8b8fa3;

    --accent-color: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.25);

    --border-color: rgba(99, 102, 241, 0.15);
    --input-bg: #0c0c18;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.1);

    --danger-color: #ef4444;

    /* Tab Accents */
    --button-color: #6366f1;
    --editor-color: #10b981;
    --ai-color: #f59e0b;

    /* Glass Effect */
    --glass-bg: rgba(26, 26, 46, 0.7);
    --glass-border: rgba(99, 102, 241, 0.12);

    /* Reusable Alpha Shades */
    --white-4: rgba(255, 255, 255, 0.04);
    --white-6: rgba(255, 255, 255, 0.06);
    --white-8: rgba(255, 255, 255, 0.08);
    --white-10: rgba(255, 255, 255, 0.1);
    --black-50: rgba(0, 0, 0, 0.5);
    --accent-8: rgba(99, 102, 241, 0.08);
    --accent-20: rgba(99, 102, 241, 0.2);
    --accent-30: rgba(99, 102, 241, 0.3);
}

body {
    background-color: var(--bg-color);
    background-image: radial-gradient(ellipse at top, rgba(99, 102, 241, 0.05) 0%, transparent 50%);
    color: var(--text-color);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    padding: 0;
    font-size: 11px;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    user-select: none;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--accent-30);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.5);
}

/* ==========================================
   Tabs — Premium Reference Adapted
   ========================================== */
.tabs {
    display: flex;
    background: linear-gradient(180deg, rgba(15, 15, 30, 0.95) 0%, var(--bg-color) 100%);
    padding: 0 6px;
    gap: 2px;
    flex-shrink: 0;
    border: none !important;
    border-bottom: none !important;
    box-shadow: none;
    backdrop-filter: blur(20px);
    position: relative;
    outline: none;
}

.tabs::before,
.tabs::after {
    display: none !important;
    content: none !important;
}



.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: none;
    color: rgba(255, 255, 255, 0.45);
    padding: 12px 4px 10px;
    cursor: pointer;
    font-size: 10px;
    font-weight: 600;
    position: relative;
    border-radius: 8px 8px 0 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin: 0;
    width: auto;
    overflow: hidden;
}

/* Hover overlay (reference: .tab-btn::before) */
.tab-btn::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12) 0%, rgba(168, 85, 247, 0.08) 100%);
    opacity: 0;
    transition: opacity 0.4s ease;
    border-radius: 8px 8px 0 0;
}

/* Bottom indicator bar (reference: .tab-btn::after) */
.tab-btn::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 70%;
    height: 3px;
    background: linear-gradient(90deg, #6366f1 0%, #a855f7 100%);
    border-radius: 4px 4px 0 0;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-btn:hover {
    color: rgba(255, 255, 255, 0.8);
    background: transparent;
}

.tab-btn:hover::before {
    opacity: 0.5;
}

.tab-btn.active {
    color: #fff;
    font-weight: 700;
}

.tab-btn.active::before {
    opacity: 1;
}

.tab-btn.active::after {
    transform: translateX(-50%) scaleX(1);
}

/* Per-Tab Accent Colors */
.tab-btn[data-tab="tab_button"].active::after {
    background: linear-gradient(90deg, #6366f1, #818cf8);
}

.tab-btn[data-tab="tab_button"].active {
    color: #818cf8;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.tab-btn[data-tab="tab_editor"].active::after {
    background: linear-gradient(90deg, #10b981, #34d399);
}

.tab-btn[data-tab="tab_editor"].active {
    color: #34d399;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.tab-btn[data-tab="tab_ai"].active::after {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.tab-btn[data-tab="tab_ai"].active {
    color: #fbbf24;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* ==========================================
   Tab Content — Animated Panels
   ========================================== */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    flex: 1;
    min-height: 0;
    height: auto;
    overflow-y: auto;
    padding-bottom: 8px;
    animation: fadeSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================
   Animations — Reference Adapted
   ========================================== */
@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-4px);
    }
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}


/* Controls */
.control-group {
    margin-bottom: 12px;
}

label {
    display: block;
    margin-bottom: 4px;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input[type="text"],
input[type="number"] {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 8px 10px;
    width: 100%;
    box-sizing: border-box;
    border-radius: 6px;
    /* Rounded */
    font-size: 11px;
    transition: all 0.2s ease;
    outline: none;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

input[type="text"]:focus,
input[type="number"]:focus {
    border-color: var(--accent-color);
    background: #202020;
    box-shadow: 0 0 0 2px var(--accent-glow);
}


/* Buttons */
button {
    background: linear-gradient(to bottom, #323232, #252525);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    width: 100%;
    margin-bottom: 4px;
    /* Tighten Button Gap */
    font-size: 11px;
    font-weight: 500;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

/* Glassy highlight on top */
button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--white-8);
}

button:hover {
    background: linear-gradient(to bottom, #3a3a3a, #2a2a2a);
    border-color: #555;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    color: #fff;
}

button:active {
    transform: translateY(0);
    box-shadow: none;
    background: #222;
}

.icon {
    width: 16px;
    height: 16px;
    fill: currentColor;
    flex-shrink: 0;
    opacity: 0.8;
    transition: opacity 0.2s;
}

button:hover .icon {
    opacity: 1;
}

/* Tab Specific Button Hovers */
#tab_button button:hover {
    border-color: var(--button-color);
}

#tab_button button:hover .icon {
    fill: var(--button-color);
}

/* Button Color Override Utilities - HOVER & ICON FIXES */





/* Color Picker Swatches */
.color-swatches {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 5px;
}

/* Icon Grid */
.icon-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    margin-top: 5px;
    max-height: 120px;
    overflow-y: auto;
    padding: 2px;
    /* Avoid cutoff outline */
}

.icon-option {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.icon-option svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.icon-option:hover {
    border-color: var(--text-color);
    color: var(--text-color);
    background: var(--surface-color);
}

.icon-option.selected {
    border-color: var(--accent-color);
    background: rgba(55, 113, 200, 0.2);
    color: white;
    box-shadow: 0 0 0 1px var(--accent-color);
}


.color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    /* default border */
    position: relative;
    transition: transform 0.1s, box-shadow 0.2s;
}

.color-swatch:hover {
    transform: scale(1.1);
}

.color-swatch.selected {
    border-color: white;
    box-shadow: 0 0 0 2px var(--accent-color);
}

/* Specific colors mirroring the .btn- classes */
.swatch-red {
    background-color: #e74c3c;
}

/* Input Stepper */
.input-stepper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px;
    width: fit-content;
}

.input-stepper button {
    width: 30px;
    height: 30px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 16px;
    cursor: pointer;
    border-radius: 2px;
}

.input-stepper button:hover {
    background: var(--surface-color);
}

.input-stepper span {
    min-width: 40px;
    text-align: center;
    font-weight: bold;
    color: var(--text-color);
    font-size: 14px;
}

/* ==========================================
   Section Collapsible Headers (V7 Tab Organization)
   ========================================== */
.script-section {
    width: 100%;
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
}

.script-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    /* Extremely small */
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    /* Purple Theme */
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.script-section .section-header:hover {
    background: #111111;
    /* Black like current */
}

.script-section .section-title {
    color: #ffffff;
    font-size: 8.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin: 0;
}

.script-section .section-arrow {
    fill: #ffffff;
    width: 12px;
    height: 12px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.script-section .section-header.collapsed .section-arrow {
    transform: rotate(-180deg);
}

.section-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 32px;
    gap: 4px;
    padding: 4px 12px 12px 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
}

.section-grid.collapsed {
    display: none;
    opacity: 0;
}

.swatch-blue {
    background-color: #3498db;
}

.swatch-green {
    background-color: #2ecc71;
}

.swatch-yellow {
    background-color: #f1c40f;
}

.swatch-purple {
    background-color: #9b59b6;
}

.swatch-orange {
    background-color: #e67e22;
}

.swatch-gray {
    background-color: #95a5a6;
}



button:active {
    transform: translateY(0);
    box-shadow: none;
}

button.primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-color: transparent;
    color: white;
}

button.primary:hover {
    background: linear-gradient(135deg, #818cf8, #a78bfa);
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

button.secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

button.secondary:hover {
    border-color: var(--text-color);
    color: var(--text-color);
}

/* Layout Helpers */
.row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
    min-height: 32px;
    /* Ensure drop target exists even if empty */
    border: 1px dashed transparent;
    /* Placeholder for drag feedback */
    border-radius: 4px;
    transition: border-color 0.2s, background 0.2s;
    position: relative;
    /* For drop indicators */
}

.row.drag-over {
    border-color: var(--accent-color);
    background: rgba(55, 113, 200, 0.1);
    /* Accent with opacity */
}



/* Force Disable Tab Interaction during Drag */
body.dragging-mode .tab-btn {
    pointer-events: none !important;
    opacity: 1;
}


.row input {
    flex: 1 1 auto;
    min-width: 40px;
}

.row button {
    width: auto;
    margin-bottom: 0;
    flex: 1;
    position: relative;
    /* For box-shadow relative to button */
}


.section {
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.section:last-child {
    border-bottom: none;
}

.section h3 {
    margin: 0;
}

#task_list li {
    padding: 8px 10px;
    border-bottom: 1px solid #333;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#task_list li:hover {
    background: #333;
}

#task_list li.selected {
    background: #357abd;
    /* Darker blue */
    color: white;
}

/* Footer for Run Script */
.footer {
    margin-top: auto;
    padding-top: 0;
    /* Removed padding */
    border-top: none;
    /* Removed border */
    display: flex;
    justify-content: center;
    background: var(--bg-color);
    /* Ensure opaque */
    position: relative;
    z-index: 100;
    /* Ensure Top Layer */
    flex-shrink: 0;
    /* PREVENT SQUASHING */
}

#btn_toggle_height {
    background: var(--input-bg);
    /* Darker background */
    border: none;
    width: 100%;
    height: 10px;
    /* Slim height */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    transition: background 0.2s;
}

#btn_toggle_height:hover {
    background: var(--accent-color);
    /* Highlight on hover */
    color: white;
}

#btn_toggle_height .icon {
    width: 12px;
    /* Smaller icon */
    height: 12px;
}

/* Hotkey Bar */
#hotkey-bar {
    padding: 4px;
    gap: 4px;
    background: var(--bg-color);
    border-bottom: 1px solid var(--white-4);
    min-height: 40px;
    /* Base height */
    height: auto;
    transition: height 0.2s;
    /* GRID LAYOUT */
    display: grid;
    grid-template-columns: repeat(var(--col-count, 5), 1fr);
    /* Default 5 cols */
    position: relative;
    z-index: 10;
}

.hotkey-slot {
    width: 100%;
    /* Fill Grid Cell */
    box-sizing: border-box;
    /* Include padding/border in width */

    height: 32px;
    background: var(--input-bg);
    border: 1px dashed var(--border-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    padding: 0 4px;
    position: relative;
    /* For absolute positioning of X */
}

.hotkey-slot:hover {
    border-color: var(--text-color);
}

.hotkey-slot.drag-over {
    border-color: var(--accent-color);
    background: var(--surface-color);
}

.hotkey-slot.filled {
    border-style: solid;
    color: white;
    font-weight: 500;
    flex-direction: column;
    gap: 1px;
    padding: 2px 4px;
}

.hotkey-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    flex-shrink: 0;
}

.hotkey-label {
    font-size: 7px;
    font-weight: 500;
    line-height: 1;
    opacity: 0.7;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: 0.01em;
    pointer-events: none;
}

/* Remove Button (X) */
.hotkey-remove {
    position: absolute;
    top: 0;
    right: 0;
    width: 14px;
    height: 14px;
    line-height: 14px;
    text-align: center;
    font-size: 12px;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(0, 0, 0, 0.2);
    border-bottom-left-radius: 4px;
    cursor: pointer;
    display: none;
    transition: background 0.2s;
}

.hotkey-slot.filled:hover .hotkey-remove {
    display: block;
}

.hotkey-remove:hover {
    background: rgba(255, 0, 0, 0.8);
    color: white;
}

/* Hotkey Colors */
.hotkey-slot.swift {
    background: var(--swift-color);
    border-color: var(--swift-color);
}

.hotkey-slot.creative {
    background: var(--creative-color);
    border-color: var(--creative-color);
    color: #1e1e1e;
    /* Dark text for yellow */
}

.hotkey-slot.creative .hotkey-remove {
    color: rgba(0, 0, 0, 0.6);
    /* Darker X for yellow bg */
}

.hotkey-slot.other {
    background: var(--other-color);
    border-color: var(--other-color);
}

.hotkey-slot svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    pointer-events: none;
    /* Let clicks pass through */
}

.hotkey-slot.dimension {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

/* Tab Actions Bar (New/Import/Export) — Floating bottom center */
.tab-actions {
    position: fixed;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 6px 14px;
    z-index: 500;
    background: rgba(15, 15, 30, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 15px rgba(99, 102, 241, 0.08);
}

.tab-actions .toolbar-btn {
    height: 28px;
    padding: 4px 14px;
    font-size: 10px;
}

/* Collapsed State */
body.collapsed .tabs,
body.collapsed .tab-content,
body.collapsed .tab-actions {
    display: none;
}

/* Modal — Premium Glass Card */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
}

/* Ensure AI Modal is above Script Modal */
#ai_prompt_modal {
    z-index: 1100;
    background: rgba(0, 0, 0, 0.7);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: linear-gradient(135deg, rgba(15, 15, 30, 0.95) 0%, rgba(25, 25, 45, 0.98) 100%);
    border: 1px solid var(--white-8);
    border-radius: 16px;
    padding: 24px;
    width: 270px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5), 0 0 80px rgba(99, 102, 241, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 14px;
    color: var(--text-color);
}


/* Hide tab content when collapsed */
body.collapsed .tab-content {
    display: none !important;
}

body.collapsed .footer {
    margin-top: 0 !important;
    border-top: 1px solid var(--border-color);
}

body.collapsed #btn_toggle_height {
    height: 10px !important;
    /* Force thin line */
    min-height: 10px;
    align-items: center;
}

/* Ensure Tabs stack correctly */
.tabs {
    position: relative;
    z-index: 5;
}

/* Modal sizing */
.modal-content.large-modal {
    width: 320px;
}

/* Ensure AI Modal is above Script Modal */
#ai_prompt_modal {
    z-index: 2000;
    /* Higher than standard modal (1000) */
    background: rgba(0, 0, 0, 0.7);
    /* Darker backdrop */
}

/* Spinner Animation */
.spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--accent-color);
    animation: spin 1s ease-in-out infinite;
    vertical-align: middle;
    margin-right: 4px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}


/* Fix Colors Tab Layout */
#creative.active {
    display: flex;
    flex-direction: column;
}

/* ===========================================
   ACCORDION SECTION CARD UI
   =========================================== */
.section-card {
    background: transparent;
    /* Card itself transparent */
    margin-bottom: 6px;
    display: flex;
    flex-direction: column;
    border: none;
    /* remove old border */
}

/* Header Base Style (Expanded by default) */
.section-header {
    background: #e0e0e0;
    /* Light Gray/White for Active */
    color: #222;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Push arrow to right */
    user-select: none;
    transition: background 0.2s, color 0.2s;
}

.section-header .icon {
    width: 16px;
    height: 16px;
    fill: currentColor;
    /* Adapt to text color */
}

/* Collapsed State Override */
.section-card.collapsed .section-header {
    background: #777;
    /* Dark Gray for Inactive */
    color: #eee;
    border-radius: 4px;
    /* Keep radius */
}

.section-content {
    background: #1e1e1e;
    /* Dark content bg */
    padding: 10px;
    margin-top: 4px;
    /* gap between header and content */
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Specific Adjustment for Harmony List in Card */
.section-card .harmony-list-container {
    max-height: none;
    /* Allow full growth */
    overflow-y: visible;
    /* No internal scroll */
    border-radius: 4px;
}

/* Collapsible Logic */
.section-card.collapsed .section-content {
    display: none !important;
}

/* Chevron Rotation */
.section-card .section-header .chevron {
    transform: rotate(0deg);
    /* Arrow Up (Expanded) */
    transition: transform 0.2s;
}

.section-card.collapsed .section-header .chevron {
    transform: rotate(180deg);
    /* Arrow Down (Collapsed) */
}

/* ====================================================================================
   ====================================   NOTIFICATIONS   ==============================
   ====================================================================================*/

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}


/* V8 Footer Toolbar — Premium Glass */
.footer-toolbar {
    width: 100%;
    height: 40px;
    background: linear-gradient(180deg, rgba(15, 15, 30, 0.95) 0%, rgba(10, 10, 24, 0.98) 100%);
    border-top: 1px solid var(--white-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    box-sizing: border-box;
    z-index: 100;
    flex-shrink: 0;
    position: relative;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* Glowing top edge */
.footer-toolbar::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.3), transparent);
}

.toolbar-left {
    display: flex;
    gap: 8px;
    align-items: center;
}

.toolbar-btn {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.06) 100%);
    color: #e0e0e0;
    border: 1px solid var(--white-10);
    border-radius: 8px;
    padding: 6px 16px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    margin-bottom: 0;
    backdrop-filter: blur(10px);
}

.toolbar-btn:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.1) 100%);
    box-shadow: 0 2px 12px rgba(99, 102, 241, 0.2);
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.toolbar-btn.primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-color: transparent;
    color: white;
}

.toolbar-btn.primary:hover {
    background: linear-gradient(135deg, #818cf8, #a78bfa);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.toolbar-right {
    display: flex;
    align-items: center;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--white-10);
    color: #888;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-bottom: 0;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--border-color);
    color: #fff;
    border-color: var(--accent-30);
    transform: rotate(30deg);
}

/* Hide old footer toggle if it exists */
.footer {
    display: none !important;
}

/* Toast Notification */
.toast-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(37, 37, 66, 0.95);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
    pointer-events: none;
    border: 1px solid rgba(99, 102, 241, 0.3);
    backdrop-filter: blur(10px);
}

.toast-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast-notification.success {
    background: rgba(16, 185, 129, 0.9);
    border-color: rgba(16, 185, 129, 0.5);
}

.toast-notification.error {
    background: rgba(239, 68, 68, 0.9);
    border-color: rgba(239, 68, 68, 0.5);
}

/* Grid Button Hover — uses --btn-color set by JS for per-button glow */
.grid-btn {
    --btn-color: transparent;
}

.grid-btn:hover {
    box-shadow: 0 0 8px var(--btn-color);
}

/* Export Mode Visuals */
body.export-mode .grid-btn {
    animation: shake 0.5s ease-in-out infinite alternate;
    border-color: #f1c40f !important;
    box-shadow: 0 0 8px rgba(241, 196, 15, 0.5);
    cursor: pointer !important;
    opacity: 1 !important;
}

body.export-mode .tab-btn,
body.export-mode .footer-toolbar,
body.export-mode .tab-actions {
    opacity: 0.3;
    pointer-events: none;
}

@keyframes shake {
    0% {
        transform: rotate(-1deg);
    }

    100% {
        transform: rotate(1deg);
    }
}

/* Z-Index Fixes */
.modal {
    z-index: 2000 !important;
    /* Ensure Modal is above Context Menu (1000) */
}

#context_menu {
    display: none;
    position: fixed;
    z-index: 1000;
    background: #2b2b2b;
    border: 1px solid #444;
    border-radius: 4px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    padding: 4px 0;
    min-width: 140px;
}

.ctx-colors {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    border-bottom: 1px solid #444;
    margin-bottom: 4px;
    justify-content: center;
    flex-wrap: wrap;
}

.ctx-item {
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.1s;
}

.ctx-edit {
    color: #a3e635;
}

.ctx-copy {
    color: #60a5fa;
}

.ctx-delete {
    color: #ff6b6b;
}

.ctx-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* Modal Divider */
.modal-divider {
    border: 0;
    border-top: 1px solid #444;
    margin: 15px 0;
}

/* Default Scripts — Reference Card Style */
.grid-btn.default-script {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.grid-btn.default-script:hover {
    background: var(--white-4);
    border-color: var(--accent-20);
}

/* Toggle Button Fixes */
#btn_toggle_height {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    margin-right: 8px;
    /* Extra spacing from New button */
}

/* Remove rotation for Toggle Button specifically */
#btn_toggle_height:hover {
    transform: none;
    /* No rotate */
    background: #444;
    /* Hover bg */
    border-color: #666;
}

#btn_toggle_height svg {
    width: 24px;
    height: 24px;
    fill: #ccc;
    transition: transform 0.2s;
}

/* Optional: Rotate icon only if needed, but 'none' is cleaner */
#btn_toggle_height:hover svg {
    fill: #fff;
    transform: scale(1.1);
}

/* Toggle Button Fixes - Final Polish */
#btn_toggle_height {
    width: 30px !important;
    /* Match Settings Button */
    height: 30px !important;
    border-radius: 50%;
    margin-right: 8px;
    flex-shrink: 0;
    /* Prevent squashing */
}

/* Ensure no rotation on hover */
#btn_toggle_height:hover {
    transform: none !important;
    background: #444;
}

#btn_toggle_height svg {
    width: 20px;
    /* Standard icon size */
    height: 20px;
    fill: #ccc;
    transition: transform 0.2s;
}

#btn_toggle_height:hover svg {
    fill: #fff;
    transform: scale(1.1);
}

/* Footer Toolbar Robustness */
.footer-toolbar {
    min-height: 40px;
    flex-shrink: 0;
    overflow: hidden;
}

/* Absolute Safety for Toggle Button */
#btn_toggle_height {
    min-width: 30px !important;
    min-height: 30px !important;
    max-width: 30px !important;
    max-height: 30px !important;
    padding: 0 !important;
    /* Ensure no padding squeeze */
}

/* Minimal Collapse Strip */
#collapsed_strip {
    height: 14px;
    /* Slightly taller for clickability, but looks like 10px */
    background: #1e1e1e;
    border-top: 1px solid #333;
    display: none;
    /* Hidden by default */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    width: 100%;
}

#collapsed_strip:hover {
    background: #3771c8;
    /* Accent */
}

#collapsed_strip svg {
    width: 14px;
    height: 14px;
    fill: #777;
    transition: fill 0.2s;
}

#collapsed_strip:hover svg {
    fill: #fff;
}

/* Collapsed State Logic */
body.collapsed .footer-toolbar {
    display: none !important;
}

body.collapsed #collapsed_strip {
    display: flex !important;
}

/* Ensure no other footer interferes */
body.collapsed .footer {
    display: none !important;
}

/* ==========================================
   V3: Light Theme
   ========================================== */
.light-theme {
    --bg-color: #f5f5f5;
    --surface-color: #ffffff;
    --text-color: #333333;
    --text-secondary: #666666;
    --accent-color: #2563eb;
    --accent-hover: #3b82f6;
    --border-color: #e0e0e0;
    --input-bg: #ffffff;
    --hover-color: #e8e8e8;
}

.light-theme ::-webkit-scrollbar {
    background: #f0f0f0;
}

.light-theme ::-webkit-scrollbar-thumb {
    background: #ccc;
}

.light-theme ::-webkit-scrollbar-thumb:hover {
    background: #bbb;
}

.light-theme .tab-btn {
    background: #e8e8e8;
    color: #333;
}

.light-theme .tab-btn.active {
    background: var(--accent-color);
    color: #fff;
}

.light-theme .grid-btn {
    background: #f0f0f0;
    border-color: #ddd;
    color: #333;
}

.light-theme .hotkey-slot {
    background: #e8e8e8;
    border-color: #ccc;
}

.light-theme .footer-toolbar {
    background: #f0f0f0;
    border-color: #ddd;
}

.light-theme .icon-btn {
    border-color: #ccc;
    color: #666;
}

.light-theme .icon-btn:hover {
    background: #ddd;
}

/* ===========================================
   RECENT CODE (Editor Tab)
   =========================================== */
.recent-code-section {
    margin-top: 12px;
    flex-shrink: 0;
}

.recent-code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
    margin-bottom: 6px;
}

.recent-code-label {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(255, 255, 255, 0.4);
}

.recent-code-clear {
    background: var(--white-6);
    border: 1px solid var(--white-10);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.4);
    padding: 4px 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.recent-code-clear:hover {
    background: rgba(255, 60, 60, 0.15);
    border-color: rgba(255, 60, 60, 0.3);
    color: #ff6b6b;
}

.recent-code-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.recent-code-empty {
    text-align: center;
    color: rgba(255, 255, 255, 0.2);
    font-size: 11px;
    padding: 12px;
}

.recent-code-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--white-6);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.recent-code-item:hover {
    background: var(--accent-8);
    border-color: var(--accent-20);
}

.rc-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.rc-info {
    flex: 1;
    min-width: 0;
}

.rc-name {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rc-time {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.3);
}

.rc-load {
    font-size: 9px;
    font-weight: 700;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.recent-code-item:hover .rc-load {
    opacity: 1;
}

/* AI Agent Mode Pills */
.agent-mode-pill {
    transition: all 0.2s ease;
    opacity: 0.6;
}
.agent-mode-pill:hover {
    opacity: 0.8;
}
.agent-mode-pill.active {
    opacity: 1;
    border-color: var(--accent-color) !important;
}
