:root {
    --bg0: #101814;
    --bg1: #17241c;
    --surface: rgba(220, 245, 230, 0.06);
    --surface-strong: rgba(220, 245, 230, 0.1);
    --line: rgba(160, 210, 175, 0.2);
    --text: #eef7f1;
    --muted: #9fb8a8;
    --accent: #3d9b6a;
    --accent-deep: #2a704c;
    --radius: 18px;
    --font: "Segoe UI", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    color: var(--text);
    background:
        radial-gradient(900px 500px at 10% -10%, rgba(61, 155, 106, 0.3), transparent 60%),
        radial-gradient(700px 420px at 100% 0%, rgba(30, 80, 50, 0.4), transparent 55%),
        linear-gradient(165deg, var(--bg1), var(--bg0) 55%, #0a100d);
}

.page {
    width: min(720px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 2.5rem 0 3rem;
    display: grid;
    gap: 1.1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.brand img {
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(61, 155, 106, 0.4);
}

.brand-home {
    display: block;
    line-height: 0;
    border-radius: 50%;
    text-decoration: none;
}

.brand-home:hover img {
    filter: brightness(1.08);
}

.brand-home:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.brand-name {
    margin: 0;
    font-size: 0.8rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 700;
}

h1 {
    margin: 0.15rem 0 0;
    font-size: clamp(1.6rem, 4vw, 2.1rem);
    font-weight: 650;
    letter-spacing: -0.02em;
}

.lede {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.banner {
    padding: 0.85rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--muted);
    line-height: 1.45;
}

.dropzone {
    position: relative;
    border: 1.5px dashed rgba(61, 155, 106, 0.55);
    border-radius: var(--radius);
    background: var(--surface);
    min-height: 220px;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
    outline: none;
}

.dropzone:hover,
.dropzone:focus-visible {
    border-color: var(--accent);
    background: var(--surface-strong);
}

.dropzone.is-dragover {
    border-color: var(--accent);
    background: rgba(61, 155, 106, 0.16);
    transform: scale(1.01);
}

.dropzone.is-busy {
    pointer-events: none;
    cursor: progress;
}

.dropzone-inner {
    text-align: center;
    padding: 2rem 1.25rem;
}

.drop-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 0.9rem;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(85, 184, 130, 0.95), rgba(42, 112, 76, 0.9));
    position: relative;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
}

.drop-icon::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 22px;
    height: 18px;
    transform: translate(-50%, -50%);
    border: 2px solid #eef7f1;
    border-radius: 3px;
}

.drop-icon::after {
    content: "";
    position: absolute;
    left: 58%;
    top: 42%;
    width: 8px;
    height: 8px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: #eef7f1;
    box-shadow: -10px 6px 0 -1px #eef7f1;
}

.drop-title {
    margin: 0 0 0.35rem;
    font-size: 1.15rem;
    font-weight: 600;
}

.drop-sub {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.preview {
    position: absolute;
    inset: 0.75rem;
    width: calc(100% - 1.5rem);
    height: calc(100% - 1.5rem);
    object-fit: contain;
    border-radius: 12px;
    pointer-events: none;
    opacity: 0.55;
}

.progress {
    position: absolute;
    inset: 0;
    display: none;
    place-content: center;
    gap: 0.55rem;
    padding: 1.5rem;
    background: rgba(10, 16, 13, 0.78);
    border-radius: inherit;
    backdrop-filter: blur(2px);
}

.progress.is-active {
    display: grid;
}

.progress-head {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.75rem;
}

.progress-pct {
    font-size: 1.1rem;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
}

.progress-track {
    width: min(280px, 70vw);
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), #8fd0b0);
    transition: width 0.2s ease;
}

.progress-bar.is-indeterminate {
    width: 40% !important;
    animation: slide 1.1s ease-in-out infinite;
}

@keyframes slide {
    0% { transform: translateX(-120%); }
    100% { transform: translateX(320%); }
}

.progress-label {
    margin: 0;
    text-align: center;
    color: var(--muted);
}

.file-meta {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
    word-break: break-all;
}

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

.btn {
    appearance: none;
    border: 0;
    border-radius: 999px;
    padding: 0.65rem 1.15rem;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    color: #0a100d;
    background: linear-gradient(180deg, #55b882, var(--accent-deep));
}

.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }

.btn.secondary {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--line);
}

.status {
    margin: 0;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface);
}

.status.is-error {
    border-color: rgba(224, 122, 106, 0.45);
    background: rgba(224, 122, 106, 0.12);
    color: #f2c2ba;
}

.status.is-ok {
    border-color: rgba(125, 190, 116, 0.4);
    background: rgba(125, 190, 116, 0.1);
    color: #c8e4c3;
}

.savings {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 1rem 1.1rem 1.15rem;
    display: grid;
    gap: 0.85rem;
}

.savings-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.savings-head h2 {
    margin: 0;
    font-size: 1.05rem;
}

.savings-badge {
    margin: 0;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 750;
    letter-spacing: 0.02em;
}

.savings-badge.is-better {
    color: #0a100d;
    background: linear-gradient(180deg, #55b882, var(--accent-deep));
}

.savings-badge.is-worse {
    color: #f2c2ba;
    background: rgba(224, 122, 106, 0.18);
    border: 1px solid rgba(224, 122, 106, 0.4);
}

.savings-badge.is-neutral {
    color: var(--muted);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--line);
}

.savings-chart {
    display: grid;
    gap: 0.65rem;
}

.bar-row {
    display: grid;
    grid-template-columns: 4.5rem 1fr 4.2rem;
    align-items: center;
    gap: 0.65rem;
}

.bar-label {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.bar-track {
    height: 18px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    width: 0%;
    border-radius: inherit;
    transition: width 0.45s ease;
}

.bar-orig {
    background: linear-gradient(90deg, rgba(224, 176, 106, 0.95), rgba(200, 140, 70, 0.9));
}

.bar-result {
    background: linear-gradient(90deg, var(--accent), #8fd0b0);
}

.bar-size {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 650;
    font-size: 0.92rem;
}

.savings-summary {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
    font-size: 0.95rem;
}

.photo-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
}

.photo-compare figure {
    margin: 0;
    padding: 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface);
    display: grid;
    gap: 0.5rem;
}

.photo-compare figcaption {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.photo-compare img,
.photo-compare canvas {
    width: 100%;
    height: auto;
    max-height: 320px;
    object-fit: contain;
    border-radius: 10px;
    background:
        linear-gradient(45deg, rgba(255, 255, 255, 0.08) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(255, 255, 255, 0.08) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.08) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.08) 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.foot {
    margin-top: 0.5rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.foot a {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid transparent;
}

.foot a:hover {
    color: var(--text);
    border-bottom-color: var(--accent);
}

@media (max-width: 640px) {
    .photo-compare { grid-template-columns: 1fr; }
    .bar-row {
        grid-template-columns: 3.6rem 1fr 3.6rem;
        gap: 0.4rem;
    }
    .page { padding-top: 1.5rem; }
}
