/* ==========================================================================
   PixSqueeze — styles
   ========================================================================== */

:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #f0f3f9;
    --border: #e2e7f0;
    --text: #131a26;
    --text-soft: #5d6b82;
    --text-faint: #8b98ad;
    --accent: #4f46e5;
    --accent-2: #0891b2;
    --accent-soft: #eef0ff;
    --danger: #d92d20;
    --danger-soft: #fef3f2;
    --success: #059669;
    --success-soft: #ecfdf5;
    --warning-soft: #fffaeb;
    --warning-border: #fec84b;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --shadow: 0 4px 16px rgba(16, 24, 40, .07);
    --radius: 14px;
    --radius-sm: 10px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b0f16;
        --surface: #141a24;
        --surface-2: #1b2230;
        --border: #262f3f;
        --text: #eaeef5;
        --text-soft: #9aa7bd;
        --text-faint: #6d7b92;
        --accent: #7c7cf8;
        --accent-2: #22d3ee;
        --accent-soft: #1c2140;
        --danger: #ff7a70;
        --danger-soft: #2a1614;
        --success: #34d399;
        --success-soft: #10241d;
        --warning-soft: #2a2110;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow: 0 4px 18px rgba(0, 0, 0, .45);
    }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.25; margin: 0; letter-spacing: -.01em; }

/* ---------- Top bar ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -.02em;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    flex: none;
}

.brand-mark svg { width: 18px; height: 18px; }

.brand-mark-lg { width: 52px; height: 52px; border-radius: 14px; margin-bottom: 16px; }
.brand-mark-lg svg { width: 28px; height: 28px; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.credit-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-soft);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .15s, color .15s;
}
.credit-pill:hover { border-color: var(--accent); color: var(--text); }

.credit-pill .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--success); flex: none;
}
.credit-pill.is-low .dot { background: #f79009; }
.credit-pill.is-out .dot { background: var(--danger); }

.refresh-icon { width: 14px; height: 14px; opacity: .5; }
.credit-pill:hover .refresh-icon { opacity: .9; }
.credit-pill.is-busy .refresh-icon { animation: spin .8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.ghost-btn {
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid transparent;
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}
.ghost-btn:hover { color: var(--text); border-color: var(--border); }

/* ---------- Layout ---------- */

.wrap {
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 20px 64px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.hero { text-align: center; padding: 12px 4px 4px; }
.hero h1 { font-size: clamp(26px, 5vw, 38px); font-weight: 800; }
.hero p {
    margin: 12px auto 0;
    max-width: 620px;
    color: var(--text-soft);
    font-size: 15.5px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
}

/* ---------- Dropzone ---------- */

.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    background: var(--surface-2);
    transition: border-color .18s, background .18s, transform .18s;
}
.dropzone:hover,
.dropzone:focus-visible { border-color: var(--accent); outline: none; }
.dropzone.is-dragging {
    border-color: var(--accent);
    background: var(--accent-soft);
    transform: scale(1.005);
}

.dropzone-icon {
    width: 54px; height: 54px;
    margin: 0 auto 14px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--accent-soft);
    color: var(--accent);
}
.dropzone-icon svg { width: 26px; height: 26px; }

.dropzone-title { margin: 0; font-weight: 700; font-size: 17px; }
.dropzone-sub { margin: 4px 0 0; color: var(--text-soft); }
.dropzone-sub .link { color: var(--accent); font-weight: 600; text-decoration: underline; }
.dropzone-note { margin: 14px 0 0; color: var(--text-faint); font-size: 12.5px; }

/* ---------- Options ---------- */

.options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.field-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-faint);
}

.field-info .field-value { color: var(--text-soft); font-size: 14px; padding-top: 4px; }

select, input[type="text"], input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 14px;
}
select:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

.suffix-wrap { display: flex; flex-direction: column; gap: 4px; }
.suffix-hint { font-size: 12px; color: var(--text-faint); }

.convert-note {
    margin: 16px 0 0;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 13.5px;
    color: var(--text-soft);
}
.convert-note strong { color: var(--text); }

/* ---------- Results ---------- */

.results-head {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.results-summary h2 { font-size: 18px; }
.results-meta { margin: 3px 0 0; color: var(--text-soft); font-size: 13.5px; }
.results-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform .12s, box-shadow .15s, opacity .15s, border-color .15s;
    white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 35%, transparent);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 4px 16px color-mix(in srgb, var(--accent) 45%, transparent); }

.btn-quiet { color: var(--text-soft); }
.btn-block { width: 100%; }

.progress {
    height: 6px;
    border-radius: 999px;
    background: var(--surface-2);
    overflow: hidden;
    margin-bottom: 16px;
}
.progress-bar {
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    transition: width .25s ease;
}

.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.file-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}
.file-row.is-error { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); background: var(--danger-soft); }
.file-row.is-done { border-color: color-mix(in srgb, var(--success) 30%, var(--border)); }

.file-thumb {
    width: 44px; height: 44px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--surface-2);
    border: 1px solid var(--border);
    flex: none;
}

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

.file-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta { font-size: 12.5px; color: var(--text-soft); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.file-meta .arrow { color: var(--text-faint); }
.file-meta .saved { color: var(--success); font-weight: 700; }
.file-meta .err { color: var(--danger); }

.badge {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-faint);
}
.badge.is-working { background: var(--accent-soft); color: var(--accent); }
.badge.is-done { background: var(--success-soft); color: var(--success); }
.badge.is-error { background: var(--danger-soft); color: var(--danger); }

.file-actions { display: flex; gap: 6px; flex: none; }

.icon-btn {
    width: 34px; height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text-soft);
    cursor: pointer;
    transition: color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.icon-btn svg { width: 16px; height: 16px; }

/* ---------- How it works ---------- */

.how h2 { font-size: 18px; margin-bottom: 12px; }
.steps { margin: 0; padding-left: 20px; color: var(--text-soft); display: flex; flex-direction: column; gap: 8px; }
.steps strong { color: var(--text); }
.fine-print { margin: 16px 0 0; font-size: 13px; color: var(--text-faint); }

/* ---------- Alerts / toast ---------- */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
}
.alert-error { background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); color: var(--text); }

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    background: var(--text);
    color: var(--bg);
    padding: 11px 18px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: var(--shadow);
    z-index: 50;
    max-width: calc(100vw - 40px);
    text-align: center;
}

/* ---------- Login ---------- */

.login-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; }

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px 28px;
    text-align: center;
}
.login-card h1 { font-size: 22px; }
.login-sub { color: var(--text-soft); font-size: 14px; margin: 6px 0 20px; }
.login-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.login-form .field-label { text-align: left; }

/* ---------- Footer ---------- */

.footer {
    padding: 20px;
    text-align: center;
    color: var(--text-faint);
    font-size: 12.5px;
}

/* ---------- Mobile ---------- */

@media (max-width: 560px) {
    .wrap { padding: 20px 14px 48px; }
    .panel { padding: 16px; }
    .dropzone { padding: 28px 14px; }
    .results-head { flex-direction: column; align-items: stretch; }
    .results-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .results-actions .btn-primary { grid-column: 1 / -1; }
    .file-thumb { width: 38px; height: 38px; }
    .brand-text { font-size: 15px; }
    .credit-pill { font-size: 12px; padding: 6px 10px; }
}
