:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #e0e7ff;
    --secondary: #64748b;
    --secondary-hover: #475569;
    --success: #22c55e;
    --error: #ef4444;
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f172a;
        --surface: #1e293b;
        --border: #334155;
        --text: #f1f5f9;
        --text-muted: #94a3b8;
        --primary-light: #312e81;
    }
}

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

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.container {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
}

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

.panels {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    flex: 1;
    min-height: 400px;
}

@media (max-width: 900px) {
    .panels {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr auto 1fr;
        min-height: auto;
    }
    
    .panel {
        min-height: 200px;
    }
    
    .divider {
        padding: 0.75rem 0;
        justify-content: center;
    }
    
    .btn-convert {
        width: auto;
        min-width: 120px;
        max-width: 200px;
        height: auto;
        border-radius: 8px;
        padding: 0.75rem 1.5rem;
        flex-direction: row;
        gap: 0.5rem;
    }
    
    .btn-convert .btn-icon {
        font-size: 1rem;
        transform: rotate(90deg);
    }
    
    .btn-convert .btn-text {
        font-size: 0.875rem;
    }
}

.panel {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

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

.panel-header label {
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.char-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

textarea {
    flex: 1;
    width: 100%;
    padding: 1rem;
    border: none;
    resize: none;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    background: var(--surface);
    color: var(--text);
}

textarea:focus {
    outline: none;
}

textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

textarea[readonly] {
    background: var(--bg);
    cursor: default;
}

.panel-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

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

.btn-icon {
    font-size: 1rem;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: scale(1.02);
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--secondary);
    color: white;
}

.btn-convert {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    padding: 0;
    flex-direction: column;
    gap: 0.25rem;
    box-shadow: var(--shadow-lg);
}

.btn-convert .btn-icon {
    font-size: 1.25rem;
}

.btn-convert .btn-text {
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    border-radius: 4px;
    width: 0%;
    transition: width 0.2s ease;
}

.progress-text {
    font-size: 0.875rem;
    color: var(--text-muted);
    min-width: 100px;
    text-align: right;
}

.options {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 2rem;
    padding: 1rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text);
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkbox-custom {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: 4px;
    transition: all 0.15s ease;
    position: relative;
}

.checkbox-label input:checked + .checkbox-custom {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox-label input:checked + .checkbox-custom::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
}

footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

footer a {
    color: var(--primary);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 0.875rem 1.5rem;
    background: var(--text);
    color: var(--bg);
    border-radius: 8px;
    font-size: 0.875rem;
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s ease;
    z-index: 1000;
}

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

.toast.error {
    background: var(--error);
    color: white;
}

.toast.success {
    background: var(--success);
    color: white;
}

@media (max-width: 600px) {
    .container {
        padding: 1rem;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .options {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .panel-actions {
        flex-wrap: wrap;
    }
    
    .btn {
        flex: 1;
        min-width: 100px;
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.processing .btn-convert {
    animation: pulse 1s ease-in-out infinite;
    pointer-events: none;
}
