:root {
    --bg: #0F172A;
    --bg2: #1E293B;
    --bg-card: rgba(30, 41, 59, .85);
    --border: rgba(255, 255, 255, .08);
    --text: #E2E8F0;
    --muted: #64748B;
    --primary: #8B5CF6;
    --primary2: #A78BFA;
    --accent: #06B6D4;
    --glow: rgba(139, 92, 246, .25);
    --r: 12px;
    --font: 'Inter', -apple-system, sans-serif
}

[data-theme="light"] {
    --bg: #F5F3FF;
    --bg2: #FFF;
    --bg-card: rgba(255, 255, 255, .9);
    --border: rgba(0, 0, 0, .08);
    --text: #1E1B4B;
    --muted: #6B7280
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    transition: background .25s
}

.app {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 16px 40px
}

.header {
    padding: 16px 0 8px
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px
}

.logo-icon {
    font-size: 1.4rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--r);
    box-shadow: 0 4px 16px var(--glow)
}

.logo h1 {
    font-size: 1.05rem;
    font-weight: 700
}

.tagline {
    font-size: .62rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: .25s
}

.icon-btn:hover {
    border-color: var(--primary)
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    font: 600 .8rem var(--font);
    cursor: pointer;
    transition: .25s
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff
}

.btn-secondary {
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--muted)
}

.btn-sm {
    padding: 6px 12px;
    font-size: .74rem
}

.section {
    margin-bottom: 16px
}

.upload-zone {
    padding: 32px;
    background: var(--bg-card);
    border: 2px dashed var(--border);
    border-radius: var(--r);
    text-align: center;
    cursor: pointer;
    transition: .25s
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary)
}

.upload-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 8px
}

.upload-hint {
    font-size: .72rem;
    color: var(--muted);
    margin-top: 4px
}

.quality-control {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r)
}

.quality-control label {
    font-size: .82rem;
    white-space: nowrap
}

.quality-control input[type="range"] {
    flex: 1;
    accent-color: var(--primary)
}

.compare-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px
}

.compare-card {
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r)
}

.compare-card h3 {
    font-size: .78rem;
    font-weight: 700;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px
}

.badge {
    font-size: .58rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--primary);
    color: #fff;
    font-weight: 600
}

.badge-jpeg {
    background: #F59E0B
}

.badge-webp {
    background: #10B981
}

.badge-png {
    background: #3B82F6
}

.img-wrap {
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg);
    margin-bottom: 6px
}

.img-wrap canvas {
    width: 100%;
    height: auto;
    display: block
}

.stats {
    font-size: .74rem;
    color: var(--muted)
}

.chart-section {
    margin-bottom: 12px
}

.chart-section h3 {
    font-size: .82rem;
    font-weight: 700;
    margin-bottom: 8px
}

.bar-chart {
    display: flex;
    flex-direction: column;
    gap: 6px
}

.bar-row {
    display: flex;
    align-items: center;
    gap: 8px
}

.bar-label {
    width: 50px;
    font-size: .72rem;
    font-weight: 600;
    color: var(--muted);
    text-align: right
}

.bar-track {
    flex: 1;
    height: 20px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
    position: relative
}

.bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width .5s ease
}

.bar-val {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: .64rem;
    font-weight: 600;
    color: #fff
}

.actions {
    display: flex;
    gap: 6px
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 10px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r);
    color: var(--text);
    font-size: .82rem;
    opacity: 0;
    transition: .35s;
    z-index: 100;
    pointer-events: none
}

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

.hidden {
    display: none !important
}

@media(max-width:600px) {
    .compare-grid {
        grid-template-columns: 1fr
    }
}