:root {
    /* Colors - Terminal Green Theme */
    --bg-app: #000000;
    --bg-panel: rgba(0, 20, 0, 0.9);
    --bg-panel-solid: #001100;
    --bg-input: rgba(0, 30, 0, 0.8);
    --bg-hover: rgba(0, 255, 0, 0.1);
    --bg-active: rgba(0, 255, 0, 0.2);

    --border-color: #00ff00;
    --border-hover: #00ff00;

    --text-primary: #00ff00;
    --text-secondary: rgba(0, 255, 0, 0.7);
    --text-muted: rgba(0, 255, 0, 0.5);

    --accent-primary: #00ff00;
    --accent-hover: #33ff33;
    --accent-text: #000000;

    --success: #00ff00;
    --warning: #ffff00;
    --error: #ff0000;
    --info: #00ff00;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;

    /* Typography */
    --font-sans: 'Fira Code', monospace;
    /* Terminal font everywhere */
    --font-mono: 'Fira Code', monospace;

    /* Effects */
    --shadow-sm: 0 0 5px rgba(0, 255, 0, 0.2);
    --shadow-md: 0 0 10px rgba(0, 255, 0, 0.3);
    --shadow-lg: 0 0 20px rgba(0, 255, 0, 0.4);
    --glass-blur: none;
    /* No blur for crisp terminal look */
    --radius-sm: 0;
    --radius-md: 0;
    --radius-lg: 0;
    --radius-full: 0;

    /* Transitions */
    --transition-fast: 0s;
    --transition-normal: 0s;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-mono);
    background-color: var(--bg-app);
    color: var(--text-primary);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    background-image:
        linear-gradient(rgba(0, 255, 0, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 255, 0, 0.03) 1px, transparent 1px);
    background-size: 20px 20px;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 100vw;
}

/* Header */
.header {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-lg);
    background: var(--bg-panel);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.logo-icon {
    color: var(--accent-primary);
}

.version-badge {
    font-size: 0.75rem;
    background: var(--bg-active);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
}

.header-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.header-tabs {
    display: flex;
    background: var(--bg-input);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.header-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

.header-tab:hover {
    color: var(--text-primary);
}

.header-tab.active {
    background: var(--bg-active);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.header-right {
    display: flex;
    gap: var(--space-sm);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    border: 1px solid transparent;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-primary {
    background: var(--accent-primary);
    color: var(--accent-text);
}

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

.btn-secondary {
    background: var(--bg-active);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

.btn-icon {
    padding: 0.5rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Main Layout */
.main {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background: var(--bg-panel);
    backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform var(--transition-normal);
}

.sidebar-header {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-color);
}

.search-wrapper {
    position: relative;
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 12px 8px 36px;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: var(--transition-fast);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: var(--bg-app);
}

.sidebar-filters {
    padding: var(--space-sm) var(--space-md);
    display: flex;
    gap: var(--space-sm);
}

.filter-select {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
}

.sidebar-actions {
    padding: var(--space-sm) var(--space-md);
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-sm);
}

/* Editor Panel */
.editor-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: transparent;
    overflow: hidden;
    position: relative;
}

.editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: var(--space-lg);
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.editor-wrapper {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    padding-bottom: var(--space-xl);
}

.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-sm);
}

.editor-header-main {
    flex: 1;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.editor-name-input {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    width: 100%;
    padding: var(--space-xs);
}

.editor-name-input:focus {
    outline: none;
    background: var(--bg-hover);
    border-radius: var(--radius-sm);
}

.unsaved-indicator {
    color: var(--warning);
    font-weight: bold;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.unsaved-indicator.visible {
    opacity: 1;
}

.editor-header-actions {
    display: flex;
    gap: var(--space-xs);
}

.editor-action-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
}

.editor-action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.editor-action-btn.active {
    color: var(--warning);
}

.editor-action-btn.danger:hover {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

.editor-metadata {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.editor-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.editor-field.flex-grow {
    flex: 1;
}

.editor-field label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.editor-select,
.editor-input {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 0.875rem;
    min-width: 140px;
}

.editor-select:focus,
.editor-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.editor-mode-toggle {
    display: flex;
    background: var(--bg-input);
    padding: 4px;
    border-radius: var(--radius-md);
    width: fit-content;
    margin-bottom: var(--space-sm);
}

.mode-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.mode-btn.active {
    background: var(--bg-active);
    color: var(--text-primary);
}

/* Sections */
.editor-sections {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.editor-section {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: var(--transition-normal);
}

.section-header {
    padding: var(--space-md);
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.section-toggle {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.section-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: auto;
}

.section-content {
    padding: var(--space-md);
}

.editor-textarea-wrapper {
    position: relative;
    width: 100%;
}

.editor-textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.6;
    resize: vertical;
    transition: border-color var(--transition-fast);
}

.editor-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Right Panel */
.right-panel {
    width: 350px;
    background: var(--bg-panel);
    backdrop-filter: var(--glass-blur);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.panel-header {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-header h3 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.variable-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-bottom: 1px solid var(--border-color);
    max-height: 40%;
}

.variable-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
}

.preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.preview-inputs {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-color);
    max-height: 200px;
    overflow-y: auto;
}

.preview-output-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-app);
}

.preview-output {
    flex: 1;
    padding: var(--space-md);
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    white-space: pre-wrap;
    color: var(--text-primary);
}

.preview-stats {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-panel);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.token-counter {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.model-select {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
}

/* Empty State */
.panel-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-xl);
}

.empty-content {
    max-width: 480px;
}

.empty-icon {
    color: var(--accent-primary);
    margin-bottom: var(--space-lg);
    opacity: 0.8;
}

.empty-content h2 {
    font-size: 1.5rem;
    margin-bottom: var(--space-sm);
}

.empty-content p {
    color: var(--text-secondary);
    margin-bottom: var(--space-xl);
}

.empty-actions {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
    margin-bottom: var(--space-xl);
}

.empty-features {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
    text-align: left;
}

.feature {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.feature-icon {
    width: 24px;
    height: 24px;
    background: var(--bg-active);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    color: var(--accent-primary);
}

/* Header Center (Tabs) - Hidden globally as we use bottom nav now */
.header-center {
    display: none;
}

/* Bottom Navigation - Global */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-panel-solid);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    /* Centered on desktop looks better */
    gap: var(--space-xl);
    /* Spacing for desktop */
    align-items: center;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-item {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 0.7rem;
    padding: 8px;
    width: auto;
    /* Auto width for desktop */
    min-width: 80px;
    cursor: pointer;
}

.bottom-nav-item.active {
    color: var(--accent-primary);
}

.bottom-nav-item svg {
    width: 20px;
    height: 20px;
}

/* Main Layout Adjustment */
.main {
    padding-bottom: 60px;
}

/* Mobile Responsive Overrides */
@media (max-width: 768px) {
    .main {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        display: none;
        /* Hidden by default on mobile, toggled */
    }

    .sidebar.active {
        display: flex;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 20;
    }

    .right-panel {
        width: 100%;
        height: 40vh;
        border-left: none;
        border-top: 1px solid var(--border-color);
        display: none;
        /* Hidden by default, toggled */
    }

    .right-panel.active {
        display: flex;
        position: absolute;
        top: 60px;
        /* Below header */
        bottom: 0;
        left: 0;
        right: 0;
        height: auto;
        z-index: 20;
    }

    .btn-text {
        display: none;
    }

    /* Mobile specific bottom nav adjustments */
    .bottom-nav {
        justify-content: space-around;
        /* Spread out on mobile */
        gap: 0;
    }

    .bottom-nav-item {
        width: 100%;
    }
}

/* Desktop: Hide bottom nav */
@media (min-width: 769px) {
    .bottom-nav {
        display: none;
    }
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.toast {
    background: var(--bg-panel-solid);
    border: 1px solid var(--border-color);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    min-width: 300px;
    animation: slideIn 0.3s ease;
    color: var(--text-primary);
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--error);
}

.toast.info {
    border-left: 4px solid var(--info);
}

.toast.warning {
    border-left: 4px solid var(--warning);
}

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

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

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-panel-solid);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
}

.modal-header {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-weight: 600;
    font-size: 1.125rem;
}

.modal-body {
    padding: var(--space-md);
    overflow-y: auto;
}

.modal-footer {
    padding: var(--space-md);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
}