:root {
    --bg: #0f1419;
    --card: #1a2332;
    --text: #e7ecf3;
    --muted: #9aa8bc;
    --primary: #4f8cff;
    --primary-soft: rgba(79, 140, 255, 0.12);
    --success: #3ecf8e;
    --border: #2a3648;
    --ease: cubic-bezier(.4, 0, .2, 1);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, sans-serif;
    background: linear-gradient(160deg, #0b1020, #121a2b);
    color: var(--text);
    min-height: 100vh;
}

.container {
    max-width: 640px;
    margin: 0 auto;
    padding: 2.5rem 1rem 3rem;
}

/* ---------- Logo ---------- */
.site-header {
    margin-bottom: 1.5rem;
    animation: fadeInUp .5s var(--ease) both;
}

.logo {
    display: flex;
    align-items: center;
    gap: .65rem;
}

.logo-icon {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
}

.logo-icon .pixel {
    transform-origin: center;
    animation: pixelFloat 3.2s ease-in-out infinite;
}

.logo-icon .pixel:nth-child(2) {
    animation-delay: .15s;
}

.logo-icon .pixel:nth-child(3) {
    animation-delay: .3s;
}

.logo-text {
    font-size: 1.5rem;
    letter-spacing: .01em;
    line-height: 1;
}

.logo-light {
    font-weight: 400;
    color: var(--text);
}

.logo-bold {
    font-weight: 800;
    color: var(--primary);
    margin-left: .35rem;
}

.tagline {
    margin: .6rem 0 0;
    color: var(--muted);
}

/* ---------- Card ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    display: grid;
    gap: 1rem;
    animation: fadeInUp .5s var(--ease) .08s both;
}

/* ---------- Dropzone ---------- */
.dropzone {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    color: var(--muted);
    transition: border-color .25s var(--ease), background .25s var(--ease), transform .2s var(--ease);
    display: block;
    max-width: 560px;
}

.dropzone:hover {
    border-color: #3a4b66;
}

.dropzone:active {
    transform: scale(.995);
}

.dropzone.dragover {
    border-color: var(--primary);
    background: var(--primary-soft);
    transform: scale(1.01);
}

.dropzone-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
    animation: fadeIn .3s var(--ease);
}

.upload-icon {
    width: 34px;
    height: 34px;
    color: var(--muted);
    opacity: .8;
}

.dropzone-filled {
    display: flex;
    align-items: center;
    gap: .85rem;
    text-align: left;
    animation: scaleIn .35s var(--ease);
}

.thumb-wrap {
    position: relative;
    flex-shrink: 0;
}

.dropzone-filled img#thumb {
    display: block;
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
}

.file-meta {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    flex: 1;
    overflow: hidden;
    min-width: 0;
}

#file-name {
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.btn-clear {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #1a2332;
    border: 1px solid var(--border);
    color: var(--muted);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: .7rem;
    line-height: 1;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
    transition: background .2s var(--ease), color .2s var(--ease), transform .2s var(--ease);
}

.btn-clear:hover {
    background: rgba(255, 80, 80, .2);
    color: #ff8080;
    transform: rotate(90deg);
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(.92); }
    to { opacity: 1; transform: scale(1); }
}

/* ---------- Form ---------- */
.form-group {
    display: grid;
    gap: .5rem;
}

select,
input[type="range"] {
    width: 100%;
}

select {
    background: #0f1726;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .55rem .6rem;
}

input[type="range"] {
    accent-color: var(--primary);
}

#quality-value {
    display: inline-block;
    font-weight: 700;
    color: var(--primary);
    transition: transform .18s var(--ease);
}

/* #quality-value.pulse {
    transform: scale(1.25);
} */

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    text-align: center;
    padding: .75rem 1rem;
    border-radius: 8px;
    border: none;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    transition: transform .15s var(--ease), box-shadow .2s var(--ease), opacity .2s var(--ease);
}

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

.btn.primary:hover:not(:disabled) {
    box-shadow: 0 6px 18px rgba(79, 140, 255, .35);
}

.btn.primary:active:not(:disabled) {
    transform: scale(.97);
}

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

.btn.success {
    background: var(--success);
    color: #062015;
    transform: translateY(6px) scale(.98);
    opacity: 0;
}

.btn.success.show {
    animation: popIn .4s var(--ease) forwards;
}

.btn.success:hover {
    box-shadow: 0 6px 18px rgba(62, 207, 142, .3);
}

/* ---------- Progress ---------- */
.progress {
    display: grid;
    gap: .35rem;
    animation: fadeIn .3s var(--ease);
}

.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.progress-bar::after {
    content: '';
    display: block;
    height: 100%;
    width: var(--value, 0%);
    background: linear-gradient(90deg, var(--primary), #7db3ff);
    background-size: 200% 100%;
    transition: width .18s linear;
    animation: shimmer 1.1s linear infinite;
}

.status {
    min-height: 1.25rem;
    color: var(--muted);
    margin: 0;
    transition: opacity .2s var(--ease);
}

.hidden {
    display: none !important;
}

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 1.75rem;
    transform: translate(-50%, 16px);
    opacity: 0;
    pointer-events: none;
    background: #12261d;
    border: 1px solid #234a37;
    color: #baf3d6;
    padding: .7rem 1.1rem;
    border-radius: 999px;
    display: flex;
    align-items: center;
    gap: .55rem;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
    transition: opacity .35s var(--ease), transform .35s var(--ease);
    z-index: 10;
}

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

.toast-check {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.toast-check-circle {
    stroke: var(--success);
    stroke-width: 3;
    stroke-dasharray: 145;
    stroke-dashoffset: 145;
}

.toast-check-mark {
    stroke: var(--success);
    stroke-width: 4;
    stroke-dasharray: 34;
    stroke-dashoffset: 34;
}

.toast.show .toast-check-circle {
    animation: dash .5s var(--ease) forwards;
}

.toast.show .toast-check-mark {
    animation: dash .35s var(--ease) .4s forwards;
}

/* ---------- Modal ---------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(8, 12, 20, .72);
    display: grid;
    place-items: center;
    padding: 1.25rem;
    z-index: 20;
    animation: fadeIn .3s var(--ease);
}

.modal {
    width: min(100%, 400px);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.6rem 1.4rem 1.35rem;
    text-align: center;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
    animation: fadeInUp .4s var(--ease);
}

.modal-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto .9rem;
}

.modal-icon svg {
    width: 100%;
    height: 100%;
}

.modal-backdrop:not(.hidden) .modal-icon .toast-check-circle {
    animation: dash .5s var(--ease) forwards;
}

.modal-backdrop:not(.hidden) .modal-icon .toast-check-mark {
    animation: dash .35s var(--ease) .35s forwards;
}

.modal h2 {
    margin: 0 0 .55rem;
    font-size: 1.2rem;
    line-height: 1.35;
    color: var(--text);
}

.modal p {
    margin: 0 0 1.35rem;
    color: var(--muted);
    line-height: 1.5;
    font-size: .95rem;
}

.modal-actions {
    display: grid;
    gap: .65rem;
}

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

.btn.ghost:hover {
    color: var(--text);
    border-color: #3a4b66;
    background: rgba(255, 255, 255, .04);
}

/* ---------- Keyframes ---------- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes popIn {
    0% { opacity: 0; transform: translateY(6px) scale(.98); }
    60% { opacity: 1; transform: translateY(-2px) scale(1.02); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

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

@keyframes dash {
    to { stroke-dashoffset: 0; }
}

@keyframes pixelFloat {
    0%, 100% { opacity: .55; }
    50% { opacity: 1; }
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}
