:root {
    /* Light Theme */
    --bg-color: #f8fafc;
    --bg-gradient-1: rgba(99, 102, 241, 0.1);
    --bg-gradient-2: rgba(236, 72, 153, 0.1);
    --surface: #ffffff;
    --surface-border: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --input-bg: #f1f5f9;
    --input-border: #cbd5e1;
    --toast-bg: #ffffff;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
    /* Dark Theme */
    --bg-color: #0b0f19;
    --bg-gradient-1: rgba(99, 102, 241, 0.15);
    --bg-gradient-2: rgba(168, 85, 247, 0.15);
    --surface: #111827;
    --surface-border: #1f2937;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --input-bg: #0f172a;
    --input-border: #334155;
    --toast-bg: #1e293b;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, var(--bg-gradient-1) 0px, transparent 50%),
        radial-gradient(at 100% 100%, var(--bg-gradient-2) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
}

/* Layout */
.container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: clamp(1rem, 4vw, 2rem);
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: clamp(1.5rem, 4vw, 3rem);
}

.logo {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(1.25rem, 4vw, 1.5rem);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.logo-icon { color: var(--accent); }

.controls {
    display: flex;
    gap: 0.5rem;
}

/* Buttons */
button {
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    border: none;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 500;
}

.btn-ghost {
    background: transparent;
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border: 1px solid var(--surface-border);
    min-height: 40px; /* Better touch target */
}
.btn-ghost:hover {
    background: var(--surface-border);
}

.btn-icon {
    background: transparent;
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border: 1px solid var(--surface-border);
}
.btn-icon:hover { background: var(--surface-border); }

.btn-primary {
    background: var(--accent);
    color: #fff;
    padding: 0.5rem 1.25rem;
    font-weight: 600;
    min-height: 40px;
    gap: 0.5rem;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Typography & Welcome */
.welcome-section {
    text-align: center;
    margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
}
.welcome-text {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    font-weight: 700;
    min-height: 3rem;
}
.welcome-cursor {
    display: inline-block;
    width: 3px;
    height: clamp(1.75rem, 5vw, 2.5rem);
    background: var(--accent);
    vertical-align: middle;
    animation: blink 1s infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* Main App Panel */
.app-panel {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    padding: clamp(1rem, 4vw, 1.5rem);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(1rem, 3vw, 1.5rem);
}

/* Inputs */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.input-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.shortcut {
    font-size: 0.7rem;
    background: var(--input-bg);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    border: 1px solid var(--surface-border);
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-secondary);
}

.shortcut-primary {
    font-size: 0.7rem;
    background: rgba(0,0,0,0.2);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
}

textarea {
    width: 100%;
    height: clamp(150px, 30vh, 220px);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    padding: 1rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    color: var(--text-primary);
    resize: vertical;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    line-height: 1.5;
}
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Actions Section */
.actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--surface-border);
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Toggle Switch */
.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 500;
}
.toggle-checkbox {
    appearance: none;
    width: 36px; height: 20px;
    background: var(--input-border);
    border-radius: 20px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s;
}
.toggle-checkbox::after {
    content: ''; position: absolute;
    width: 16px; height: 16px;
    background: #fff;
    border-radius: 50%;
    top: 2px; left: 2px;
    transition: transform 0.3s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.toggle-checkbox:checked { background: var(--accent); }
.toggle-checkbox:checked::after { transform: translateX(16px); }

/* Loader */
.loader {
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: none;
}
.btn-primary.loading .loader { display: block; }
.btn-primary.loading .btn-text,
.btn-primary.loading .shortcut-primary { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Footer */
footer {
    text-align: center;
    padding: 2rem 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: auto;
}

/* Toasts */
.toast-container {
    position: fixed;
    bottom: clamp(1rem, 4vw, 2rem);
    right: clamp(1rem, 4vw, 2rem);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 50;
}
.toast {
    background: var(--toast-bg);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--surface-border);
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
}
.toast.show { transform: translateX(0); }
.toast.hide { opacity: 0; transform: translateX(100%); }

/* Responsive Adjustments */
@media (max-width: 768px) {
    .grid { grid-template-columns: 1fr; }
    
    .actions { 
        flex-direction: column; 
        align-items: stretch;
    }
    
    .action-buttons {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
    
    .action-buttons .btn-primary {
        grid-column: span 2;
    }

    .hide-mobile { display: none !important; }
    
    .toast-container {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
        align-items: center;
    }
    .toast {
        width: 100%;
        max-width: 400px;
        transform: translateY(120%);
    }
    .toast.show { transform: translateY(0); }
    .toast.hide { transform: translateY(100%); }
}

/* Clear Animation */
.clearing { animation: shake 0.3s ease-in-out; }
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}
