/* ===================================================================
   Promptheus Web UI - Alchemical Laboratory Design
   Transform prompts into gold through digital alchemy
   =================================================================== */

/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Crimson+Text:ital,wght@0,400;0,600;0,700;1,400&family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600&family=Anybody:wght@400..900&display=swap');

/* ===================================================================
   DESIGN SYSTEM - Alchemical Foundation
   =================================================================== */

:root {
    /* Color Palette - Dark Alchemical Theme */
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2332;
    --surface-elevated: #151f2e;
    --surface-overlay: rgba(21, 31, 46, 0.98);

    /* Alchemical Gradients - Gold, Copper, Teal */
    --gradient-primary: linear-gradient(135deg, #d4a574 0%, #8b6914 100%);
    --gradient-secondary: linear-gradient(135deg, #b87333 0%, #cd7f32 100%);
    --gradient-success: linear-gradient(135deg, #2dd4bf 0%, #14b8a6 100%);
    --gradient-transmute: linear-gradient(135deg, #fbbf24 0%, #d97706 50%, #b45309 100%);
    --gradient-energy: radial-gradient(circle at 50% 50%, rgba(251, 191, 36, 0.2) 0%, transparent 70%);

    /* Semantic Colors - Mystical Palette */
    --color-primary: #d4a574;
    --color-primary-hover: #e5b885;
    --color-secondary: #2dd4bf;
    --color-accent: #f59e0b;
    --color-success: #14b8a6;
    --color-warning: #fbbf24;
    --color-error: #ef4444;
    --color-energy: #8b5cf6;

    /* Text Colors - Luminous */
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #0a0e1a;
    --text-gold: #d4a574;
    --text-teal: #2dd4bf;

    /* Border & Dividers */
    --border-subtle: #1e293b;
    --border-medium: #334155;
    --border-emphasis: #475569;
    --border-glow: rgba(212, 165, 116, 0.3);

    /* Shadows - Alchemical Glow */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.6);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.6), 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.7), 0 2px 4px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.8), 0 4px 8px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.9), 0 10px 20px rgba(0, 0, 0, 0.7);
    --shadow-2xl: 0 30px 60px rgba(0, 0, 0, 0.95);

    /* Glowing Shadows - Energy Effects */
    --shadow-gold-glow: 0 0 20px rgba(212, 165, 116, 0.4), 0 0 40px rgba(212, 165, 116, 0.2);
    --shadow-teal-glow: 0 0 20px rgba(45, 212, 191, 0.4), 0 0 40px rgba(45, 212, 191, 0.2);
    --shadow-energy-glow: 0 0 30px rgba(251, 191, 36, 0.5), 0 0 60px rgba(251, 191, 36, 0.3);

    /* Spacing System (8px base grid) */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-20: 5rem;

    /* Border Radius - Geometric */
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
    --radius-2xl: 1rem;
    --radius-full: 9999px;

    /* Typography Scale */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;
    --text-5xl: 3rem;

    /* Font Families */
    --font-display: 'Anybody', sans-serif;
    --font-body: 'Crimson Text', serif;
    --font-mono: 'IBM Plex Mono', monospace;

    /* Font Weights */
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;

    /* Transitions - Smooth Alchemy */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 600ms cubic-bezier(0.68, -0.55, 0.265, 1.55);

    /* Z-Index Scale */
    --z-base: 0;
    --z-dropdown: 1000;
    --z-sticky: 1100;
    --z-overlay: 1200;
    --z-modal: 1300;
    --z-toast: 1400;
}

/* ===================================================================
   BASE STYLES - Alchemical Canvas
   =================================================================== */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Atmospheric Background Effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 20% 20%, rgba(212, 165, 116, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(45, 212, 191, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* Noise Texture Overlay */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' /%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 1;
    mix-blend-mode: overlay;
}

/* ===================================================================
   LAYOUT - Alchemical Apparatus
   =================================================================== */

.top-bar {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    background: var(--surface-overlay);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
    box-shadow:
        var(--shadow-md),
        0 1px 0 0 rgba(212, 165, 116, 0.1);
    padding: var(--space-5) var(--space-6);
}

.top-bar-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-6);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    text-decoration: none;
    transition: all var(--transition-base);
}

.logo:hover {
    transform: translateY(-2px);
}

.logo-icon {
    font-size: var(--text-3xl);
    filter: drop-shadow(0 0 8px rgba(212, 165, 116, 0.5));
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
}

.logo-text {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: 700;
    font-variation-settings: 'wdth' 100, 'wght' 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.02em;
    text-shadow: 0 0 20px rgba(212, 165, 116, 0.3);
}

.top-bar-controls {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

/* Main Content Area */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-10) var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-10);
    position: relative;
    z-index: 2;
}

/* Workspace Container - Side by Side Layout */
.workspace-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
    align-items: start;
}

@media (max-width: 1024px) {
    .workspace-container {
        grid-template-columns: 1fr;
    }
}

/* ===================================================================
   PROMPT CANVAS - Input Section
   =================================================================== */

.prompt-canvas {
    background: var(--surface-elevated);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
    transition: all var(--transition-base);
    min-height: 500px;
    display: flex;
    flex-direction: column;
}

/* Glowing Border Effect */
.prompt-canvas::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: var(--gradient-primary);
    border-radius: var(--radius-xl);
    opacity: 0;
    transition: opacity var(--transition-slow);
    z-index: -1;
    filter: blur(8px);
}

.prompt-canvas:focus-within::before {
    opacity: 0.3;
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.5; }
}

.prompt-canvas:focus-within {
    border-color: var(--color-primary);
    box-shadow:
        var(--shadow-xl),
        var(--shadow-gold-glow);
    transform: translateY(-4px);
}

.prompt-input-wrapper {
    margin-bottom: var(--space-6);
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
}

#prompt-input {
    width: 100%;
    flex: 1;
    min-height: 280px;
    padding: var(--space-5);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    font-family: var(--font-body);
    font-size: var(--text-lg);
    line-height: 1.8;
    color: var(--text-primary);
    background: var(--bg-secondary);
    resize: vertical;
    transition: all var(--transition-base);
}

#prompt-input:focus {
    outline: none;
    background: var(--bg-tertiary);
    border-color: var(--color-primary);
    box-shadow:
        0 0 0 3px rgba(212, 165, 116, 0.15),
        inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

#prompt-input::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

.prompt-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
    padding-top: var(--space-5);
    border-top: 1px solid var(--border-subtle);
}

.prompt-controls-left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.prompt-controls-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* Provider Selector - Alchemical Instrument */
.provider-selector {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.provider-selector:hover {
    border-color: var(--color-primary);
    background: var(--bg-tertiary);
    box-shadow: 0 0 10px rgba(212, 165, 116, 0.2);
}

.provider-selector select {
    border: none;
    background: transparent;
    color: var(--text-gold);
    font-family: var(--font-mono);
    font-weight: var(--font-medium);
    cursor: pointer;
    padding: var(--space-1);
    font-size: var(--text-sm);
}

.provider-selector select:focus {
    outline: none;
}

/* Select Label - Alchemical Dropdown */
.select-label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.select-label:hover {
    border-color: var(--color-primary);
    background: var(--bg-tertiary);
    box-shadow: 0 0 10px rgba(212, 165, 116, 0.2);
}

.select-label select {
    border: none;
    background: transparent;
    color: var(--text-gold);
    font-family: var(--font-mono);
    font-weight: var(--font-medium);
    cursor: pointer;
    padding: var(--space-1);
    font-size: var(--text-sm);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23d4a574' d='M1.41 0L6 4.58L10.59 0L12 1.41l-6 6l-6-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-2) center;
    padding-right: var(--space-8);
}

.select-label select:focus {
    outline: none;
}

.select-label select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: var(--space-2);
}

/* Checkbox Label - Mystical Toggle */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
}

.checkbox-label:hover {
    border-color: var(--color-secondary);
    background: var(--bg-tertiary);
    color: var(--text-teal);
    box-shadow: 0 0 10px rgba(45, 212, 191, 0.2);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--color-secondary);
}

/* ===================================================================
   BUTTONS - Alchemical Actions
   =================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    border: none;
    border-radius: var(--radius-lg);
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: 600;
    font-variation-settings: 'wdth' 100, 'wght' 600;
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Shimmer Effect */
.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -150%;
    width: 150%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transition: left 0.6s;
}

.btn:hover::before {
    left: 150%;
}

.btn-primary {
    background: var(--gradient-primary);
    color: var(--text-inverse);
    box-shadow:
        var(--shadow-md),
        0 0 20px rgba(212, 165, 116, 0.3);
    border: 1px solid rgba(212, 165, 116, 0.5);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow:
        var(--shadow-lg),
        var(--shadow-gold-glow);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-emphasis);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--surface-elevated);
    border-color: var(--color-secondary);
    box-shadow:
        var(--shadow-md),
        0 0 15px rgba(45, 212, 191, 0.2);
    transform: translateY(-2px);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: var(--text-primary);
    box-shadow:
        var(--shadow-md),
        0 0 20px rgba(239, 68, 68, 0.3);
    border: 1px solid rgba(239, 68, 68, 0.5);
}

.btn-danger:hover {
    transform: translateY(-3px);
    box-shadow:
        var(--shadow-lg),
        0 0 30px rgba(239, 68, 68, 0.4);
}

.btn-icon {
    padding: var(--space-3);
    width: 42px;
    height: 42px;
}

.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-xs);
}

/* Loading Spinner - Transmutation Animation */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Alchemical Progress Indicator - Refined Minimal */
.progress-indicator {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-6) var(--space-8);
    text-align: center;
    position: relative;
    min-height: 80px;
    background: rgba(212, 165, 116, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    animation: border-glow 2.5s ease-in-out infinite;
}

.progress-symbol {
    font-size: 1.8rem;
    animation: subtle-pulse 2.5s ease-in-out infinite;
    line-height: 1;
}

.progress-text {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    color: var(--text-gold);
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1;
}

@keyframes subtle-pulse {
    0%, 100% {
        opacity: 0.85;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

@keyframes border-glow {
    0%, 100% {
        border-color: var(--border-subtle);
        box-shadow: 0 0 0 rgba(212, 165, 116, 0);
    }
    50% {
        border-color: rgba(212, 165, 116, 0.4);
        box-shadow: 0 0 12px rgba(212, 165, 116, 0.2);
    }
}

/* ===================================================================
   OUTPUT AREA - Transmutation Result
   =================================================================== */

.output-section {
    background: var(--surface-elevated);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    box-shadow: var(--shadow-lg);
    min-height: 500px;
    max-height: 600px;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* Custom Alchemical Scrollbar */
.output-section::-webkit-scrollbar {
    width: 8px;
}

.output-section::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin: var(--space-2) 0;
}

.output-section::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--color-primary), var(--color-secondary));
    border-radius: var(--radius-md);
    box-shadow: 0 0 8px rgba(212, 165, 116, 0.4);
}

.output-section::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary);
    box-shadow: var(--shadow-gold-glow);
}

/* Firefox scrollbar */
.output-section {
    scrollbar-width: thin;
    scrollbar-color: var(--color-primary) var(--bg-secondary);
}

/* Loading State - Enhanced Indication */
.output-section.loading {
    border-color: var(--color-primary);
    animation: loading-pulse 2s ease-in-out infinite;
}

.output-section.loading::before {
    opacity: 1;
    animation: shimmer-flow 2s linear infinite;
}

@keyframes loading-pulse {
    0%, 100% {
        box-shadow:
            var(--shadow-lg),
            0 0 20px rgba(212, 165, 116, 0.3);
    }
    50% {
        box-shadow:
            var(--shadow-xl),
            var(--shadow-gold-glow);
    }
}

@keyframes shimmer-flow {
    0% {
        background-position: -200% center;
    }
    100% {
        background-position: 200% center;
    }
}

/* Alchemical Border Accent */
.output-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-transmute);
    opacity: 0;
    transition: opacity var(--transition-slow);
}

.output-section:hover::before {
    opacity: 1;
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.5);
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
}

.output-title {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: 700;
    font-variation-settings: 'wdth' 100, 'wght' 700;
    color: var(--text-gold);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    letter-spacing: 0.02em;
}

.output-actions {
    display: flex;
    gap: var(--space-2);
}

#output {
    font-family: var(--font-body);
    font-size: var(--text-lg);
    line-height: 1.8;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.optimized-prompt-content {
    padding: var(--space-8);
    background: linear-gradient(135deg, rgba(17, 24, 39, 0.95) 0%, rgba(26, 35, 50, 0.95) 100%);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-medium);
    box-shadow:
        inset 0 1px 3px rgba(0, 0, 0, 0.5),
        0 4px 20px rgba(0, 0, 0, 0.7),
        0 0 40px rgba(212, 165, 116, 0.1);
    position: relative;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
    line-height: 1.8;
    font-size: var(--text-lg);
    color: var(--text-primary);
    font-family: var(--font-body);
}

.optimized-prompt-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--gradient-transmute);
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.6);
    border-radius: var(--radius-xl) 0 0 var(--radius-xl);
}

/* Enhanced text formatting styles */
.optimized-prompt-content strong {
    color: var(--text-gold);
    font-weight: 700;
    font-family: var(--font-display);
    letter-spacing: 0.01em;
}

.optimized-prompt-content em {
    color: var(--text-teal);
    font-style: italic;
}

.optimized-prompt-content code {
    background: rgba(26, 35, 50, 0.8);
    padding: 0.25em 0.6em;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.9em;
    color: var(--color-accent);
    border: 1px solid var(--border-subtle);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* Streaming Animation - Energy Pulse */
.optimized-prompt-content.streaming {
    animation: energy-pulse 2s ease-in-out infinite;
}

@keyframes energy-pulse {
    0%, 100% {
        box-shadow:
            inset 0 1px 3px rgba(0, 0, 0, 0.5),
            0 4px 20px rgba(0, 0, 0, 0.7),
            0 0 40px rgba(212, 165, 116, 0.1);
    }
    50% {
        box-shadow:
            inset 0 1px 3px rgba(0, 0, 0, 0.5),
            0 4px 20px rgba(0, 0, 0, 0.7),
            0 0 50px rgba(251, 191, 36, 0.4),
            0 0 80px rgba(212, 165, 116, 0.2);
    }
}

.streaming-cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background: var(--color-accent);
    margin-left: 2px;
    animation: cursor-blink 1s step-end infinite;
    vertical-align: text-bottom;
    box-shadow: 0 0 8px var(--color-accent);
}

@keyframes cursor-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Status Messages - Alchemical Notifications */
.message {
    padding: var(--space-4) var(--space-6);
    border-radius: var(--radius-lg);
    font-family: var(--font-body);
    font-size: var(--text-base);
    font-weight: var(--font-medium);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    box-shadow: var(--shadow-sm);
    animation: message-appear 0.4s ease-out;
    border: 1px solid;
}

@keyframes message-appear {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message-success {
    background: rgba(20, 184, 166, 0.15);
    color: var(--color-secondary);
    border-color: var(--color-secondary);
}

.message-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-error);
    border-color: var(--color-error);
}

.message-info {
    background: rgba(212, 165, 116, 0.15);
    color: var(--color-primary);
    border-color: var(--color-primary);
}

/* ===================================================================
   HISTORY SECTION - Chronicle of Transmutations
   =================================================================== */

.history-section {
    background: var(--surface-elevated);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    box-shadow: var(--shadow-lg);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
}

.history-title {
    font-family: var(--font-display);
    font-size: var(--text-3xl);
    font-weight: 700;
    font-variation-settings: 'wdth' 100, 'wght' 700;
    color: var(--text-gold);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    letter-spacing: 0.02em;
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-6);
    margin-bottom: var(--space-6);
}

.history-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
    min-height: 200px;
    display: flex;
    flex-direction: column;
}

/* Diagonal accent line */
.history-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 40%,
        rgba(212, 165, 116, 0.1) 50%,
        transparent 60%
    );
    transition: all var(--transition-slow);
    transform: translateX(100%);
}

.history-card:hover::before {
    transform: translateX(-100%);
}

.history-card:hover {
    border-color: var(--color-primary);
    transform: translateY(-6px);
    box-shadow:
        var(--shadow-xl),
        0 0 25px rgba(212, 165, 116, 0.3);
}

.history-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-4);
    gap: var(--space-2);
}

.history-card-timestamp {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    font-weight: var(--font-medium);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.history-card-badge {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    color: var(--text-inverse);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-analysis {
    background: var(--color-secondary);
    box-shadow: 0 0 10px rgba(45, 212, 191, 0.4);
}

.badge-generation {
    background: var(--color-energy);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.4);
}

.badge-code {
    background: var(--color-success);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

.history-card-content {
    flex: 1;
    margin-bottom: var(--space-4);
}

.history-card-preview {
    font-family: var(--font-body);
    font-size: var(--text-base);
    color: var(--text-primary);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-subtle);
}

.history-card-meta {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    font-weight: var(--font-medium);
}

.history-card-delete {
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-base);
    opacity: 0;
    pointer-events: none;
}

.history-card:hover .history-card-delete {
    opacity: 1;
    pointer-events: auto;
}

.history-card-delete:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--color-error);
    color: var(--color-error);
    transform: scale(1.05);
}

/* History Pagination */
.history-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-4);
    padding-top: var(--space-6);
    border-top: 1px solid var(--border-subtle);
}

.pagination-info {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.pagination-current {
    padding: var(--space-2) var(--space-4);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    font-weight: var(--font-semibold);
    color: var(--text-gold);
}

.page-size-selector {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.page-size-selector select {
    padding: var(--space-2) var(--space-3);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.page-size-selector select:hover {
    border-color: var(--color-primary);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: var(--space-20) var(--space-8);
}

.empty-state-icon {
    font-size: 5rem;
    margin-bottom: var(--space-6);
    opacity: 0.3;
    filter: grayscale(1);
}

.empty-state-title {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-3);
}

.empty-state-description {
    font-family: var(--font-body);
    font-size: var(--text-lg);
    color: var(--text-tertiary);
    font-style: italic;
}

/* ===================================================================
   SETTINGS PANEL - Alchemical Configuration
   =================================================================== */

.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    z-index: var(--z-overlay);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
}

.settings-overlay.active {
    opacity: 1;
    visibility: visible;
}

.settings-panel {
    position: relative;
    width: 100%;
    max-width: 650px;
    max-height: 85vh;
    background: rgba(21, 31, 46, 0.95);
    backdrop-filter: blur(20px);
    border: 2px solid var(--border-emphasis);
    box-shadow:
        var(--shadow-2xl),
        0 0 60px rgba(212, 165, 116, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-2xl);
    z-index: var(--z-modal);
    opacity: 0;
    transform: scale(0.9) translateY(20px);
    transition: all var(--transition-slow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.settings-panel.active {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.settings-header {
    padding: var(--space-6);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(17, 24, 39, 0.6);
    flex-shrink: 0;
}

.settings-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.settings-title {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: 700;
    font-variation-settings: 'wdth' 100, 'wght' 700;
    color: var(--text-gold);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.settings-content {
    padding: var(--space-6);
    overflow-y: auto;
    flex: 1;
}

.settings-section {
    margin-bottom: var(--space-10);
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section-title {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-5);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding-bottom: var(--space-3);
    border-bottom: 2px solid var(--border-subtle);
}

.settings-item {
    margin-bottom: var(--space-5);
}

.settings-label {
    display: block;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.settings-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.settings-input:hover {
    border-color: var(--border-emphasis);
}

.settings-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.15);
    background: var(--surface-elevated);
}

.settings-category {
    margin-bottom: var(--space-8);
}

.settings-category-title {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--border-subtle);
}

.settings-label-container {
    margin-bottom: var(--space-3);
}

.settings-description {
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--text-tertiary);
    margin-top: var(--space-1);
    line-height: 1.6;
    font-style: italic;
}

.settings-input-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.settings-eye-btn {
    position: absolute;
    right: var(--space-3);
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: var(--text-lg);
    padding: var(--space-1);
    opacity: 0.5;
    transition: opacity var(--transition-fast);
    z-index: 1;
}

.settings-eye-btn:hover {
    opacity: 1;
}

/* API Key Validation States */
.api-key-container {
    position: relative;
}

.validation-status {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    margin-top: var(--space-2);
    animation: status-appear 0.3s ease-out;
}

@keyframes status-appear {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.validation-status.validating {
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.3);
    color: var(--color-warning);
}

.validation-status.success {
    background: rgba(20, 184, 166, 0.1);
    border: 1px solid rgba(20, 184, 166, 0.3);
    color: var(--color-success);
}

.validation-status.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--color-error);
}

.validation-status-icon {
    font-size: var(--text-base);
}

.validation-status-text {
    flex: 1;
}

.validation-status-time {
    font-size: var(--text-xs);
    opacity: 0.7;
}

.validation-error-details {
    margin-top: var(--space-2);
    padding: var(--space-3);
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.6;
}

.validation-retry-btn {
    margin-top: var(--space-2);
    padding: var(--space-1) var(--space-3);
    background: transparent;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.validation-retry-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--color-primary);
    color: var(--text-gold);
}

/* Validation button states */
.btn-validate {
    min-width: 120px;
    transition: all var(--transition-fast);
}

.btn-validate.validating {
    background: var(--gradient-transmute);
    animation: validation-pulse 1.5s ease-in-out infinite;
}

@keyframes validation-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(251, 191, 36, 0);
    }
}

.btn-validate.success {
    background: var(--gradient-success);
}

.btn-validate.error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

/* Input field validation states */
.settings-input.validating {
    border-color: var(--color-warning);
    box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.15);
}

.settings-input.valid {
    border-color: var(--color-success);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}

.settings-input.invalid {
    border-color: var(--color-error);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.settings-checkbox {
    width: auto;
    height: 20px;
    cursor: pointer;
    accent-color: var(--color-secondary);
}

.settings-save-container {
    margin-top: var(--space-8);
    padding-top: var(--space-6);
    border-top: 2px solid var(--border-subtle);
    display: flex;
    justify-content: center;
}

.btn-save-settings {
    min-width: 220px;
    font-weight: var(--font-semibold);
    box-shadow: var(--shadow-lg);
}

.btn-save-settings:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-gold-glow);
}

/* Provider Card in Settings */
.provider-card {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    margin-bottom: var(--space-4);
    transition: all var(--transition-fast);
}

.provider-card:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
}

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

.provider-name {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.provider-status {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    text-transform: uppercase;
}

.provider-status.available {
    background: rgba(20, 184, 166, 0.2);
    color: var(--color-secondary);
    border: 1px solid var(--color-secondary);
}

.provider-status.unavailable {
    background: rgba(239, 68, 68, 0.2);
    color: var(--color-error);
    border: 1px solid var(--color-error);
}

.provider-model {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--text-tertiary);
}

/* ===================================================================
   QUESTIONS FORM - Clarification Ritual
   =================================================================== */

.questions-container {
    background: var(--surface-elevated);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    box-shadow: var(--shadow-lg);
    animation: appear 0.4s ease-out;
}

@keyframes appear {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.questions-header {
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
}

.questions-title {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text-gold);
    margin-bottom: var(--space-2);
}

.questions-description {
    font-family: var(--font-body);
    font-size: var(--text-lg);
    color: var(--text-secondary);
    font-style: italic;
}

.question-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    margin-bottom: var(--space-5);
}

.question-label {
    display: block;
    font-family: var(--font-body);
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-3);
}

.question-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--surface-elevated);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: var(--text-base);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.question-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.15);
}

.questions-actions {
    display: flex;
    gap: var(--space-3);
    margin-top: var(--space-6);
    padding-top: var(--space-6);
    border-top: 1px solid var(--border-subtle);
}

/* ===================================================================
   QUESTION WIZARD - One-at-a-Time Flow
   =================================================================== */

.question-wizard {
    position: relative;
    background: var(--surface-elevated);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    box-shadow: var(--shadow-lg);
    animation: wizardFadeIn 0.3s ease-out;
}

@keyframes wizardFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wizard-progress {
    display: flex;
    justify-content: center;
    gap: var(--space-3);
    margin-bottom: var(--space-8);
}

.progress-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--border-subtle);
    transition: all var(--transition-fast);
}

.progress-dot.active {
    background: var(--color-primary);
    box-shadow: 0 0 12px rgba(212, 165, 116, 0.6);
    transform: scale(1.3);
}

.progress-dot.completed {
    background: var(--color-secondary);
}

.wizard-content {
    animation: wizardContentFade 0.3s ease-out;
}

@keyframes wizardContentFade {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.wizard-question-number {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: var(--space-2);
}

.wizard-question-text {
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: var(--text-lg);
    font-weight: 500;
    color: var(--text-gold);
    margin-bottom: var(--space-6);
    line-height: 1.45;
    letter-spacing: -0.01em;
}

.wizard-input-container {
    margin-bottom: var(--space-6);
}

.wizard-input {
    width: 100%;
    min-height: 120px;
    padding: var(--space-4);
    background: var(--bg-secondary);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    font-family: var(--font-body);
    font-size: var(--text-base);
    color: var(--text-primary);
    resize: vertical;
    transition: all var(--transition-fast);
    line-height: 1.6;
}

.wizard-input:focus {
    outline: none;
    border-color: var(--color-primary);
    background: var(--surface-elevated);
    box-shadow: 0 0 0 4px rgba(212, 165, 116, 0.1);
}

.wizard-input::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

.wizard-option {
    display: flex;
    align-items: center;
    padding: var(--space-4);
    margin-bottom: var(--space-3);
    background: var(--bg-secondary);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.wizard-option:hover {
    background: var(--surface-elevated);
    border-color: var(--border-medium);
    transform: translateX(4px);
}

.wizard-option:has(input:checked) {
    background: var(--surface-elevated);
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.1);
}

.wizard-option input[type="radio"],
.wizard-option input[type="checkbox"] {
    margin-right: var(--space-3);
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--color-primary);
}

.wizard-option-text {
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: var(--text-base);
    color: var(--text-primary);
    flex: 1;
    line-height: 1.5;
}

.wizard-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    margin-top: var(--space-6);
    padding-top: var(--space-6);
    border-top: 1px solid var(--border-subtle);
}

.wizard-cancel-btn {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: var(--text-lg);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.wizard-cancel-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-error);
    transform: scale(1.1);
}

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

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

/* ===================================================================
   TWEAK PROMPT SECTION
   =================================================================== */

.tweak-container {
    background: var(--surface-elevated);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
}

.tweak-header {
    margin-bottom: var(--space-5);
}

.tweak-title {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--text-gold);
    margin-bottom: var(--space-2);
}

.tweak-description {
    font-family: var(--font-body);
    font-size: var(--text-base);
    color: var(--text-secondary);
    line-height: 1.6;
    font-style: italic;
}

.tweak-item {
    margin-bottom: var(--space-4);
}

.tweak-input {
    width: 100%;
    min-height: 130px;
    padding: var(--space-4);
    background: var(--bg-secondary);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: var(--text-base);
    color: var(--text-primary);
    resize: vertical;
    transition: all var(--transition-fast);
    line-height: 1.7;
}

.tweak-input:focus {
    outline: none;
    border-color: var(--color-primary);
    background: var(--surface-elevated);
    box-shadow: 0 0 0 4px rgba(212, 165, 116, 0.1);
}

.tweak-input::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

.tweak-examples {
    background: var(--bg-secondary);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-5);
    border-left: 3px solid var(--color-secondary);
}

.tweak-examples p {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.tweak-examples ul {
    margin: var(--space-2) 0 0 0;
    list-style-position: inside;
}

.tweak-examples li {
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--text-tertiary);
    line-height: 1.8;
}

.tweak-actions {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
    margin-top: var(--space-5);
    padding-top: var(--space-5);
    border-top: 1px solid var(--border-subtle);
}

/* ===================================================================
   TOAST NOTIFICATIONS - Alchemical Alerts
   =================================================================== */

.toast {
    position: fixed;
    bottom: var(--space-8);
    right: var(--space-8);
    background: var(--surface-elevated);
    color: var(--text-primary);
    padding: var(--space-4) var(--space-6);
    border-radius: var(--radius-lg);
    box-shadow:
        var(--shadow-xl),
        0 0 30px rgba(212, 165, 116, 0.3);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    transform: translateX(400px);
    opacity: 0;
    transition: all var(--transition-base);
    z-index: var(--z-toast);
    max-width: 420px;
    border: 2px solid;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-success {
    border-color: var(--color-secondary);
    box-shadow:
        var(--shadow-xl),
        var(--shadow-teal-glow);
}

.toast-error {
    border-color: var(--color-error);
    box-shadow:
        var(--shadow-xl),
        0 0 30px rgba(239, 68, 68, 0.3);
}

.toast-info {
    border-color: var(--color-primary);
    box-shadow:
        var(--shadow-xl),
        var(--shadow-gold-glow);
}

.toast-icon {
    font-size: var(--text-xl);
    flex-shrink: 0;
}

.toast-message {
    font-family: var(--font-body);
    font-size: var(--text-base);
    font-weight: 500;
}

/* ===================================================================
   MARKDOWN RENDERING - Scholarly Text
   =================================================================== */

.markdown-content {
    font-family: var(--font-body);
    line-height: 1.5;
    color: var(--text-primary);
    overflow-wrap: break-word;
    word-wrap: break-word;
    max-width: 100%;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    font-family: var(--font-display);
    margin-top: var(--space-3);
    margin-bottom: var(--space-1-5);
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-gold);
}

.markdown-content h1 { font-size: 2em; }
.markdown-content h2 { font-size: 1.5em; }
.markdown-content h3 { font-size: 1.25em; }
.markdown-content h4 { font-size: 1.1em; }

.markdown-content p {
    margin-bottom: var(--space-2);
}

.markdown-content ul,
.markdown-content ol {
    margin-bottom: var(--space-2);
    margin-top: var(--space-2);
    padding-left: var(--space-6);
}

.markdown-content li {
    margin-bottom: var(--space-0-5);
    line-height: 1.4;
}

.markdown-content code {
    background: var(--bg-tertiary);
    padding: 0.2em 0.5em;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.9em;
    color: var(--color-accent);
    border: 1px solid var(--border-subtle);
}

.markdown-content pre {
    background: var(--bg-tertiary);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: var(--space-3) 0;
    border: 1px solid var(--border-medium);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
    line-height: 1.4;
    max-width: 100%;
}

/* Custom scrollbar for code blocks */
.markdown-content pre::-webkit-scrollbar {
    height: 6px;
}

.markdown-content pre::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
}

.markdown-content pre::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: var(--radius-sm);
}

.markdown-content pre::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary);
}

/* Firefox scrollbar for code blocks */
.markdown-content pre {
    scrollbar-width: thin;
    scrollbar-color: var(--border-medium) var(--bg-primary);
}

.markdown-content pre code {
    background: transparent;
    padding: 0;
    color: var(--text-primary);
    border: none;
    line-height: 1.3;
    display: block;
    overflow-wrap: normal;
    word-break: normal;
    white-space: pre;
}

.markdown-content blockquote {
    border-left: 4px solid var(--color-primary);
    padding-left: var(--space-5);
    margin: var(--space-4) 0;
    color: var(--text-secondary);
    font-style: italic;
}

.markdown-content a {
    color: var(--color-secondary);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color var(--transition-fast);
}

.markdown-content a:hover {
    border-bottom-color: var(--color-secondary);
}

.markdown-content table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: var(--space-4);
}

.markdown-content th,
.markdown-content td {
    border: 1px solid var(--border-subtle);
    padding: var(--space-3) var(--space-4);
    text-align: left;
}

.markdown-content th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-gold);
}

.markdown-content hr {
    border: none;
    border-top: 2px solid var(--border-subtle);
    margin: var(--space-8) 0;
}

/* ===================================================================
   RESPONSIVE DESIGN
   =================================================================== */

@media (max-width: 768px) {
    .top-bar {
        padding: var(--space-4);
    }

    .top-bar-content {
        flex-direction: column;
        gap: var(--space-4);
    }

    .main-content {
        padding: var(--space-8) var(--space-4);
        gap: var(--space-8);
    }

    .prompt-canvas,
    .output-section,
    .history-section {
        padding: var(--space-6);
    }

    .prompt-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .prompt-controls-left,
    .prompt-controls-right {
        width: 100%;
        justify-content: center;
    }

    .history-grid {
        grid-template-columns: 1fr;
        gap: var(--space-5);
    }

    .settings-panel {
        max-width: 100%;
    }

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

/* ===================================================================
   ACCESSIBILITY & UTILITIES
   =================================================================== */

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus Visible */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}
