:root {
    --primary: #0F766E;
    /* Teal 700 */
    --primary-hover: #0d9488;
    /* Teal 600 */
    --bg-body: #F3F4F6;
    /* Gray 100 */
    --bg-card: #FFFFFF;
    --text-main: #1F2937;
    /* Gray 800 */
    --text-muted: #6B7280;
    /* Gray 500 */
    --border: #E5E7EB;
    /* Gray 200 */
    --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);
    --radius: 16px;
    --font-family: 'Outfit', sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Typography & Layout */
.app-container {
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
}

.app-header {
    text-align: center;
    margin-bottom: 3rem;
}

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

h1 {
    font-weight: 600;
    font-size: 2rem;
    letter-spacing: -0.025em;
    color: #111827;
}

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

.layout-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 2rem;
    margin-bottom: 3rem;
    align-items: start;
}

@media (max-width: 768px) {
    .layout-grid {
        grid-template-columns: 1fr;
    }
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

/* Dropzone */
.dropzone-section {
    height: 100%;
}

.dropzone {
    background: var(--bg-card);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    height: 100%;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dropzone:hover,
.dropzone.drag-over {
    border-color: var(--primary);
    background-color: rgba(15, 118, 110, 0.02);
}

.dropzone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    pointer-events: none;
    /* Let clicks pass to dropzone */
}

.dropzone-content label {
    pointer-events: auto;
    /* Re-enable for button */
}

.icon-upload {
    color: var(--text-muted);
    transition: color 0.3s;
}

.dropzone:hover .icon-upload {
    color: var(--primary);
}

.limit-info {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Buttons */
.btn-primary {
    background-color: var(--primary);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 99px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    border: none;
    font-size: 1rem;
    display: inline-block;
}

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

.btn-block {
    width: 100%;
}

.btn-secondary {
    background-color: white;
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn-secondary:hover {
    border-color: var(--text-muted);
    background-color: #F9FAFB;
}

.btn-convert {
    margin-top: 1rem;
    background: #1F2937;
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

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

.btn-convert:not(:disabled):hover {
    background: #000;
}

/* Settings Panel */
.settings-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.settings-card h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
}

.hint {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Inputs V2 (Select & Resize) */
.form-select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text-main);
}

.resize-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.input-wrap {
    position: relative;
}

.input-label {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
}

.input-wrap input {
    width: 100%;
    padding: 0.5rem 0.5rem 0.5rem 1.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
}

/* Custom Range Slider */
input[type=range] {
    width: 100%;
    accent-color: var(--primary);
}

/* Toggle Switch */
.toggle-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

/* Global Stats Banner */
.stats-banner {
    background: linear-gradient(135deg, var(--primary) 0%, #065f46 100%);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    color: white;
    display: flex;
    justify-content: space-around;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.stat-item {
    text-align: center;
}

.stat-val {
    display: block;
    font-weight: 700;
    font-size: 1.25rem;
}

.stat-lbl {
    font-size: 0.75rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Results Grid & Cards */
.results-section {
    margin-top: 2rem;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.result-card {
    background: var(--bg-card);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-wrap: wrap;
}

.result-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* V2 Card Layout */
.card-preview {
    width: 60px;
    height: 60px;
    background: #f0f0f0;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.img-compare {
    position: relative;
    width: 100%;
    height: 100%;
}

.img-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.no-preview {
    font-size: 10px;
    color: #999;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.filename {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.file-stats {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2px;
}

.val-orig {
    text-decoration: line-through;
    opacity: 0.7;
}

.val-webp {
    font-weight: 600;
    color: var(--text-main);
}

.gain-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #10B981;
    /* Green */
    color: white;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 6px;
    font-weight: 600;
}

.file-action {
    margin-left: auto;
}

.file-action .btn-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: var(--text-main);
    background: #F3F4F6;
    transition: background 0.2s;
}

.file-action .btn-icon:hover {
    background: #E5E7EB;
}

/* Dev Code Block */
.dev-code-block {
    background: #1f2937;
    color: #e5e7eb;
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-family: monospace;
    overflow-x: auto;
    width: 100%;
}

/* Footer */
.app-footer {
    text-align: center;
    margin-top: 4rem;
    padding-top: 2rem;
    padding-bottom: 1rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.brand-link {
    text-decoration: none;
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.025em;
    transition: color 0.2s;
}

.brand-link:hover {
    color: var(--primary);
}

.brand-logo {
    color: var(--primary);
}

.footer-note {
    font-size: 0.875rem;
}

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

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #374151;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 99px;
    box-shadow: var(--shadow-md);
    z-index: 100;
    font-size: 0.875rem;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translate(-50%, 20px);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}