:root {
    /* Color Palette - Premium Dark Mode */
    --bg-main: #0f1115;
    --bg-surface: #1a1d24;
    --bg-surface-hover: #232730;
    --bg-elevated: #2a2e39;

    --text-primary: #f0f2f5;
    --text-secondary: #9ba1b0;
    --text-muted: #6b7280;

    --accent-primary: #6366f1;
    /* Indigo */
    --accent-primary-hover: #4f46e5;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-error: #ef4444;

    /* Styling vars */
    --border-color: rgba(255, 255, 255, 0.08);
    --border-radius-sm: 6px;
    --border-radius-md: 12px;
    --border-radius-lg: 20px;

    --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 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.2);

    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

:root[data-theme="light"] {
    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f1f5f9;
    --bg-elevated: #e2e8f0;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;

    --border-color: rgba(0, 0, 0, 0.1);

    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Typography */
h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    background: linear-gradient(to right, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

h3 {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

/* Layout */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    flex: 1;
}

.app-header {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 1rem 0;
}

.nav-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: var(--transition);
    width: fit-content;
    margin-bottom: -1rem; /* Adjustment to keep header spacing clean */
}

.nav-back-link:hover {
    color: var(--accent-primary);
    transform: translateX(-4px);
}

.nav-back-link i {
    width: 14px;
    height: 14px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo i {
    color: var(--accent-primary);
    width: 32px;
    height: 32px;
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    flex: 1;
}

/* Top Controls */
.top-controls {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .top-controls {
        grid-template-columns: 1fr;
    }
}

.upload-area {
    background-color: var(--bg-surface);
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 2.5rem 2rem;
    text-align: center;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--accent-primary);
    background-color: var(--bg-surface-hover);
    box-shadow: var(--shadow-glow);
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--accent-primary);
    margin-bottom: 1rem;
    transition: transform 0.3s ease;
}

.upload-area:hover .upload-icon {
    transform: translateY(-5px);
}

.upload-area p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.conversion-settings {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.setting-group label {
    font-weight: 500;
    color: var(--text-secondary);
}

/* Custom Select */
.custom-select {
    position: relative;
    width: 100%;
}

.custom-select select {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    padding: 0.875rem 1rem;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.custom-select select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.custom-select i {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
    width: 18px;
    height: 18px;
}

/* Editor Area */
.editor-area {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1.5rem;
    flex: 1;
    min-height: 500px;
}

@media (max-width: 900px) {
    .editor-area {
        grid-template-columns: 1fr;
        grid-auto-rows: minmax(300px, auto);
    }
}

.editor-pane {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    transition: var(--transition);
}

.editor-pane:focus-within {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.pane-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background-color: rgba(255, 255, 255, 0.02);
}

.pane-header h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.format-badge {
    background-color: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.success-badge {
    background-color: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.error-badge {
    background-color: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.pane-actions {
    display: flex;
    gap: 0.5rem;
}

textarea {
    flex: 1;
    width: 100%;
    resize: none;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    padding: 1.25rem;
    line-height: 1.6;
}

textarea:focus {
    outline: none;
}

textarea::placeholder {
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
}

/* Custom Scrollbar for Textareas */
textarea::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

textarea::-webkit-scrollbar-track {
    background: transparent;
}

textarea::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 5px;
    border: 2px solid var(--bg-surface);
}

textarea::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.conversion-actions {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

@media (max-width: 900px) {
    .conversion-actions {
        padding: 1rem 0;
    }
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: var(--border-radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    border-radius: var(--border-radius-sm);
}

.btn i {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-hover));
    color: white;
    box-shadow: 0 4px 14px 0 rgba(99, 102, 241, 0.39);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.23);
}

.btn-primary:active {
    transform: translateY(0);
}

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

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius-sm);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    background-color: var(--bg-elevated);
    color: var(--accent-error);
}

.btn-icon i {
    width: 16px;
    height: 16px;
}

.pulse-btn {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    border-radius: 999px;
}

.pulse-btn i {
    width: 20px;
    height: 20px;
}

/* Utilities */
.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 1000;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

.toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.toast.success .toast-icon {
    color: var(--accent-success);
}

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

.toast.error .toast-icon {
    color: var(--accent-error);
}

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

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