:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --surface: #ffffff;
    --text-main: #111827;
    --text-sub: #6b7280;
    --border: #e5e7eb;
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
    --radius: 16px;
    --success: #10b981;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', -apple-system, sans-serif; }

body {
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    padding: 20px;
    display: flex;
    justify-content: center;
}

.app-wrapper {
    width: 100%;
    max-width: 800px;
    margin-top: 2rem;
}

/* --- Main Card --- */
.converter-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    text-align: center;
    transition: transform 0.3s ease;
}

.badge {
    background: #e0e7ff;
    color: var(--primary);
    display: inline-block;
    padding: 4px 12px;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

h1 { font-size: 2rem; font-weight: 800; letter-spacing: -0.025em; margin-bottom: 0.5rem; }
.subtitle { color: var(--text-sub); margin-bottom: 2rem; }

/* --- Drop Zone --- */
.drop-zone {
    border: 2px dashed #d1d5db;
    border-radius: var(--radius);
    padding: 3rem 2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #f9fafb;
    outline: none;
}

.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--primary);
    background: #eef2ff;
    transform: scale(0.99);
}

.drop-zone:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.icon-circle {
    background: white;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    color: var(--primary);
}

.hint { color: var(--text-sub); font-size: 0.9rem; margin-top: 0.5rem; }

/* --- Workspace --- */
.workspace.hidden { display: none; }
.workspace { margin-top: 2rem; animation: slideDown 0.4s ease; }

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

/* --- Settings Grid --- */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    text-align: left;
    margin-bottom: 2rem;
    background: #f9fafb;
    padding: 1.5rem;
    border-radius: 12px;
}

.control-group.full-width { grid-column: span 2; }
label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.5rem; }
select, input[type="number"] {
    width: 100%; padding: 0.6rem; border: 1px solid var(--border); border-radius: 8px; font-size: 0.95rem; outline: none;
}
input[type="range"] { width: 100%; cursor: pointer; }
.label-row { display: flex; justify-content: space-between; margin-bottom: 0.5rem; }
#qualityValue { font-family: monospace; color: var(--primary); }

/* Resize Section */
.checkbox-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.resize-inputs { 
    display: flex; 
    gap: 8px; 
    align-items: flex-end;
    transition: opacity 0.2s; 
}
.resize-inputs.disabled { opacity: 0.4; pointer-events: none; }
.input-wrap { flex: 1; }

.aspect-lock-btn {
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px;
    cursor: pointer;
    color: var(--text-sub);
    transition: all 0.2s;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0;
}

.aspect-lock-btn:hover {
    background: #f9fafb;
    border-color: var(--primary);
    color: var(--primary);
}

.aspect-lock-btn.locked {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.aspect-lock-btn.locked .unlock-only {
    display: none;
}

.aspect-lock-btn:not(.locked) .unlock-only {
    display: block;
}

/* --- File Queue List --- */
.queue-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem;
}
.text-btn { background: none; border: none; color: var(--text-sub); cursor: pointer; font-size: 0.85rem; }
.text-btn:hover { color: #ef4444; }

.file-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 2rem;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    background: white;
    gap: 0.75rem;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.file-item:last-child { border-bottom: none; }

.file-item[draggable="true"] {
    cursor: move;
}

.file-item[draggable="true"]:hover {
    background: #f9fafb;
}

.file-item.drag-over-top {
    border-top: 3px solid var(--primary);
    margin-top: -3px;
}

.file-item.drag-over-bottom {
    border-bottom: 3px solid var(--primary);
    margin-bottom: -3px;
}

.file-thumbnail {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.file-thumbnail-placeholder {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border-radius: 6px;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.skeleton-loading {
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.file-info { flex: 1; text-align: left; overflow: hidden; min-width: 0; }
.file-name { font-size: 0.9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { 
    font-size: 0.75rem; 
    color: var(--text-sub); 
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2px;
}

.format-badge {
    display: inline-block;
    background: #dbeafe;
    color: #1e40af;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-indicator {
    font-size: 0.75rem; font-weight: 600; padding: 2px 8px; border-radius: 4px; background: #e5e7eb; color: var(--text-sub);
}
.status-indicator.done { background: #d1fae5; color: #065f46; }
.status-indicator.error { background: #fee2e2; color: #dc2626; }

.file-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 100px;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
}

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

.progress-text {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--primary);
    min-width: 35px;
    text-align: right;
}

.retry-btn {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    color: #92400e;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    line-height: 1;
    margin-left: 4px;
}

.retry-btn:hover {
    background: #fbbf24;
    color: #78350f;
    transform: rotate(180deg);
}

.size-estimate {
    color: var(--success);
    font-weight: 600;
    font-size: 0.7rem;
}

.remove-btn {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    line-height: 1;
}
.remove-btn:hover {
    background: #fee2e2;
    color: #dc2626;
}

/* Buttons */
.action-buttons { display: flex; gap: 1rem; }
.btn {
    flex: 1; padding: 0.85rem; border-radius: 8px; font-weight: 600; cursor: pointer; border: none; transition: all 0.2s;
    outline: none;
}
.btn-primary { background: var(--primary); color: white; box-shadow: 0 4px 6px rgba(79, 70, 229, 0.3); }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-primary:focus { box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.3), 0 4px 6px rgba(79, 70, 229, 0.3); }
.btn-secondary { background: white; border: 1px solid var(--border); color: var(--text-sub); }
.btn-secondary:hover { background: #f9fafb; color: var(--text-main); }
.btn-secondary:focus { box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); }

.keyboard-hints {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-sub);
}

.keyboard-hints kbd {
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid #d1d5db;
    font-family: monospace;
    font-size: 0.7rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* --- SEO Section --- */
.info-section { margin-top: 3rem; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1.5rem; }
.info-card {
    background: rgba(255, 255, 255, 0.6); padding: 1.5rem; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.5);
}
.info-card h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.info-card p { font-size: 0.9rem; color: var(--text-sub); line-height: 1.5; }

/* Toast */
#toast {
    position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(100px);
    background: #1f2937; color: white; padding: 12px 24px; border-radius: 50px;
    box-shadow: 0 10px 15px rgba(0,0,0,0.2); transition: transform 0.3s ease;
}
#toast.show { transform: translateX(-50%) translateY(0); }

@media (max-width: 600px) {
    .settings-grid { grid-template-columns: 1fr; }
    .converter-card { padding: 1.5rem; }
}