/* ═══════════════════════════════════════════════════════════════════
   LW Images — Main Stylesheet
   ═══════════════════════════════════════════════════════════════════ */

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

:root {
    --primary:       #0693e3;
    --primary-light: #38b6f5;
    --primary-dark:  #0577c5;
    --primary-bg:    #E8F4FD;
    --success:       #10B981;
    --success-bg:    #D1FAE5;
    --success-dark:  #065F46;
    --warning:       #F59E0B;
    --danger:        #EF4444;
    --bg:            #F8FAFC;
    --card:          #FFFFFF;
    --border:        #E2E8F0;
    --text:          #0F172A;
    --text-muted:    #64748B;
    --text-light:    #94A3B8;
    --radius-sm:     8px;
    --radius-md:     12px;
    --radius-lg:     20px;
    --header-h:      60px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
}

/* ─── STATS BAR ───────────────────────────────────────────────────── */
.stats-bar {
    background: linear-gradient(90deg, #0577c5, #0693e3);
    color: rgba(255,255,255,0.9);
    text-align: center;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    letter-spacing: 0.01em;
}
.stats-bar strong { color: #fff; font-weight: 700; }

/* ─── HEADER ──────────────────────────────────────────────────────── */
header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 200;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    line-height: 1;
    flex-shrink: 0;
}
.logo svg { display: block; }

.logo-sub {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: lowercase;
    border-left: 1px solid var(--border);
    padding-left: 0.75rem;
    line-height: 1.3;
}
.logo-sub strong {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

nav { display: flex; align-items: center; gap: 1.75rem; }

nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.15s;
}
nav a:hover { color: var(--text); }

.burger {
    display: none;
    width: 36px;
    height: 36px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
.burger span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text);
    border-radius: 1px;
    transition: all 0.2s;
}

/* ─── BUTTONS ─────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
}
.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.8rem; }
.btn-ghost {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.3rem 0.5rem;
}
.btn-ghost:hover { color: var(--text); }

/* ─── HERO ────────────────────────────────────────────────────────── */
.hero {
    text-align: center;
    padding: 3.5rem 1.5rem 2rem;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--primary-bg);
    color: var(--primary);
    padding: 0.3rem 0.85rem;
    border-radius: 100px;
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 1.4rem;
}
.hero-badge .dot { width: 6px; height: 6px; background: var(--primary); border-radius: 50%; }

.hero h1 {
    font-size: clamp(2rem, 4vw, 2.8rem);
    font-weight: 800;
    letter-spacing: -0.025em;
    line-height: 1.15;
    margin-bottom: 1rem;
}
.hero h1 .gradient {
    background: linear-gradient(135deg, var(--primary) 0%, #0577c5 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero p {
    font-size: 1.05rem;
    color: var(--text-muted);
    max-width: 480px;
    margin: 0 auto 2.5rem;
}

/* ─── FORMAT PILLS ────────────────────────────────────────────────── */
.format-bar {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    padding: 0 1rem;
}

.fmt {
    padding: 0.35rem 0.9rem;
    border-radius: 100px;
    border: 1.5px solid var(--border);
    background: #fff;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}
.fmt:hover { border-color: var(--primary); color: var(--primary); }
.fmt.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.fmt .badge-new {
    position: absolute;
    top: -6px;
    right: -4px;
    background: var(--success);
    color: #fff;
    font-size: 0.55rem;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 4px;
    line-height: 1.4;
}

/* ─── MAIN CONTENT ────────────────────────────────────────────────── */
.main { max-width: 780px; margin: 0 auto; padding: 0 1.25rem 5rem; }

/* ─── DROP ZONE ───────────────────────────────────────────────────── */
.drop-zone {
    border: 2.5px dashed var(--border);
    border-radius: var(--radius-lg);
    background: #fff;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}
.drop-zone::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(99,102,241,0.03), rgba(139,92,246,0.03));
    opacity: 0;
    transition: opacity 0.2s;
}
.drop-zone:hover, .drop-zone.over {
    border-color: var(--primary);
    background: #FAFBFF;
}
.drop-zone:hover::before, .drop-zone.over::before { opacity: 1; }

.drop-icon-wrap {
    width: 68px;
    height: 68px;
    background: var(--primary-bg);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
    font-size: 30px;
    transition: transform 0.2s;
}
.drop-zone:hover .drop-icon-wrap { transform: scale(1.08); }

.drop-zone h2 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
}
.drop-zone p { color: var(--text-muted); font-size: 0.875rem; }
.browse { color: var(--primary); font-weight: 600; text-decoration: underline; cursor: pointer; }

.drop-limits {
    display: flex;
    justify-content: center;
    gap: 1.25rem;
    margin-top: 1.1rem;
    font-size: 0.75rem;
    color: var(--text-light);
}
.drop-limits span { display: flex; align-items: center; gap: 0.3rem; }

/* ─── OPTIONS ROW ─────────────────────────────────────────────────── */
.options-row {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-top: 0.875rem;
    padding: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.opt-format-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.25rem;
    flex-wrap: wrap;
}

.opt-controls-row {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.opt-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
    min-width: 180px;
}

.fmt-sm {
    padding: 0.18rem 0.6rem;
    border-radius: 5px;
    border: 1.5px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    white-space: nowrap;
}
.fmt-sm:hover { border-color: var(--primary); color: var(--primary); }
.fmt-sm.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.fmt-sm .badge-new {
    position: absolute;
    top: -5px; right: -3px;
    background: var(--success);
    color: #fff;
    font-size: 0.5rem;
    font-weight: 700;
    padding: 1px 3px;
    border-radius: 3px;
    line-height: 1.4;
}

.opt-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.pro-tag {
    font-size: 0.6rem;
    font-weight: 700;
    background: linear-gradient(135deg, #F59E0B, #EF4444);
    color: #fff;
    padding: 1px 5px;
    border-radius: 4px;
    letter-spacing: 0.02em;
}

input[type=range] {
    -webkit-appearance: none;
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(to right, var(--primary) 85%, var(--border) 85%);
    outline: none;
    cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    border: 2.5px solid #fff;
    box-shadow: 0 0 0 1.5px var(--primary);
    cursor: pointer;
}

.q-val {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    min-width: 28px;
    text-align: right;
}

.vdivider {
    width: 1px;
    height: 26px;
    background: var(--border);
    flex-shrink: 0;
}

.upscale-btns { display: flex; gap: 0.35rem; }
.up-btn {
    padding: 0.3rem 0.65rem;
    border-radius: 6px;
    border: 1.5px solid var(--border);
    background: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.15s;
}
.up-btn:hover { border-color: var(--primary); color: var(--primary); }
.up-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.compress-after {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-left: 0.4rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
}
.compress-after input[type=checkbox] {
    accent-color: var(--primary);
    width: 14px;
    height: 14px;
    cursor: pointer;
}

/* ─── RESULTS ─────────────────────────────────────────────────────── */
.results { margin-top: 1.5rem; }

.results-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.875rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.results-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.results-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.65rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 700;
}
.chip-green { background: var(--success-bg); color: var(--success-dark); }

/* ─── FILE CARD ───────────────────────────────────────────────────── */
.file-list { display: flex; flex-direction: column; gap: 0.5rem; }

.file-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.875rem 1.125rem;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    transition: box-shadow 0.2s, border-color 0.2s;
}
.file-card:hover {
    box-shadow: 0 2px 16px rgba(99,102,241,0.08);
    border-color: #C7D2FE;
}

.thumb {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    overflow: hidden;
}

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

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

.file-hint {
    font-size: 0.73rem;
    color: var(--text-light);
    margin-top: 2px;
    /* Перенос вместо nowrap+ellipsis: длинные сообщения (напр. ошибка про 50 Мп)
       иначе не переносятся и растягивают карточку за край экрана на мобиле. */
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.file-hint .tag {
    display: inline-block;
    background: var(--primary-bg);
    color: var(--primary);
    font-weight: 600;
    padding: 0 4px;
    border-radius: 3px;
    font-size: 0.68rem;
}
.file-hint .tag-green {
    background: var(--success-bg);
    color: var(--success-dark);
}

.file-sizes {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    white-space: nowrap;
}
.sz-old {
    font-size: 0.82rem;
    color: var(--text-light);
    text-decoration: line-through;
}
.sz-arrow { color: var(--text-light); font-size: 0.75rem; }
.sz-new { font-size: 0.9rem; font-weight: 700; }

.saving {
    padding: 0.18rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
}
.saving-great { background: #A7F3D0; color: #065F46; }
.saving-good  { background: var(--success-bg); color: var(--success-dark); }
.saving-bad   { background: var(--primary-bg); color: var(--primary); }
.saving-ai    { background: linear-gradient(135deg, #7B2FF7, #e3067a); color: #fff; }

.file-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }

.ico-btn {
    width: 32px;
    height: 32px;
    border-radius: 7px;
    border: 1.5px solid var(--border);
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.15s;
}
.ico-btn:hover { border-color: var(--primary); background: var(--primary-bg); }
.ico-btn:disabled { opacity: 0.35; cursor: default; }

.dl-btn {
    height: 32px;
    padding: 0 0.85rem;
    border-radius: 7px;
    border: none;
    background: var(--primary);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}
.dl-btn:hover { background: var(--primary-dark); }
.dl-btn:disabled { opacity: 0.35; cursor: default; background: var(--primary); }

/* Progress bar */
.prog-wrap { margin-top: 5px; display: flex; flex-direction: column; gap: 4px; }
.prog-bar {
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}
.prog-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 2px;
    width: 0;
    transition: width 0.25s linear;
    will-change: width;
}
.prog-fill-2 {
    height: 100%;
    background: linear-gradient(90deg, #22c55e, #4ade80);
    border-radius: 2px;
    width: 0;
    transition: width 0.25s linear;
    will-change: width;
}

/* ─── COMPARE MODAL ───────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.modal-backdrop.open { opacity: 1; pointer-events: all; }

.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    max-width: 640px;
    width: 100%;
    transform: translateY(12px);
    transition: transform 0.2s;
}
.modal-backdrop.open .modal { transform: translateY(0); }

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-close {
    width: 30px; height: 30px;
    border-radius: 6px;
    border: 1.5px solid var(--border);
    background: #fff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
}
.modal-close:hover { background: var(--bg); }

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

.compare-side {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.compare-label {
    padding: 0.5rem 0.875rem;
    font-size: 0.78rem;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.compare-label.before { background: #FFF7ED; color: #92400E; }
.compare-label.after  { background: #ECFDF5; color: #065F46; }

.compare-img {
    width: 100%;
    aspect-ratio: 4/3;
    background: repeating-conic-gradient(#e2e8f0 0% 25%, #f8fafc 0% 50%) 0 0 / 12px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
}

/* ─── FORMAT SHOWCASE ─────────────────────────────────────────────── */
.format-showcase {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    margin-top: 1.5rem;
}

.fcard {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.875rem;
    text-align: center;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.fcard:hover {
    border-color: var(--primary-light);
    box-shadow: 0 2px 12px rgba(99,102,241,0.07);
}
.fcard-name {
    font-size: 0.95rem;
    font-weight: 800;
    margin-bottom: 0.2rem;
}
.fcard-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.4;
}
.fcard-saving {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--success);
    margin-top: 0.4rem;
}
.fcard-compat {
    font-size: 0.68rem;
    color: var(--text-light);
    margin-top: 0.2rem;
}

/* ─── FOOTER ──────────────────────────────────────────────────────── */
footer {
    margin-top: auto;
    border-top: 1px solid var(--border);
    background: #fff;
    padding: 0.5rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-light);
    flex-wrap: wrap;
    gap: 0.75rem;
}
footer a { color: var(--text-muted); text-decoration: none; }
footer a:hover { color: var(--text); }
.footer-links { display: flex; gap: 1.25rem; flex-wrap: wrap; }

/* ─── FEATURE CARDS ───────────────────────────────────────────────── */
.features-section { margin-top: 2rem; }

.features-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.875rem;
}

.features-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.feat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    overflow: hidden;
    transition: transform .3s, box-shadow .3s;
}
.feat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 16px 40px rgba(0,0,0,0.10);
}

.feat-illust {
    width: 100%;
    height: 200px;
    position: relative;
    overflow: hidden;
}

.feat-body { padding: 1.25rem 1.25rem 1.5rem; }

.feat-tag {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    padding: 0.22rem 0.6rem;
    border-radius: 5px;
    margin-bottom: 0.6rem;
}
.tag-api   { background: #0693e3; color: #fff; }
.tag-ai-up { background: linear-gradient(90deg, #7B2FF7, #e3067a); color: #fff; }

.feat-body h2 {
    font-size: 1.05rem;
    font-weight: 800;
    margin-bottom: 0.4rem;
    letter-spacing: -0.01em;
}
.feat-body p {
    font-size: 0.83rem;
    color: var(--text-muted);
    line-height: 1.55;
    margin-bottom: 0.875rem;
}
.feat-list { list-style: none; display: flex; flex-direction: column; gap: 0.35rem; }
.feat-list li {
    font-size: 0.79rem;
    color: var(--text-muted);
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
}
.feat-list li::before {
    content: '\2713';
    color: var(--success);
    font-weight: 700;
    font-size: 0.72rem;
    flex-shrink: 0;
    margin-top: 2px;
}

/* ── API illustration ── */
.illust-api { background: linear-gradient(135deg, #0d1117, #161b27); }

.api-win {
    position: absolute;
    top: 16px; left: 16px; right: 16px; bottom: 16px;
    background: #0d1117;
    border-radius: 10px;
    border: 1px solid #30363d;
    overflow: hidden;
}
.api-win-bar {
    height: 26px;
    background: #1c2128;
    border-bottom: 1px solid #30363d;
    display: flex;
    align-items: center;
    padding: 0 10px;
    gap: 5px;
}
.api-dot { width: 9px; height: 9px; border-radius: 50%; }
.api-dot-r { background: #ff5f57; }
.api-dot-y { background: #ffbd2e; }
.api-dot-g { background: #28ca41; }
.api-win-title {
    flex: 1; text-align: center;
    font-size: 9px; color: #484f58; font-family: monospace;
}

.api-req, .api-proc, .api-resp {
    position: absolute;
    top: 26px; left: 0; right: 0;
    padding: 10px 14px;
    font-family: 'Courier New', monospace;
    font-size: 9.5px;
    line-height: 1.9;
    opacity: 0;
}
.api-req  { animation: api-phase 9s infinite 0s; }
.api-proc { animation: api-phase 9s infinite 3s; }
.api-resp { animation: api-phase 9s infinite 6s; }

@keyframes api-phase {
    0%        { opacity: 0; transform: translateY(6px); }
    6%        { opacity: 1; transform: translateY(0); }
    28%       { opacity: 1; transform: translateY(0); }
    34%, 100% { opacity: 0; transform: translateY(-5px); }
}

.api-comment { color: #484f58; }
.api-method  { color: #ff7b72; }
.api-url     { color: #79c0ff; }
.api-key     { color: #d2a8ff; }
.api-val     { color: #a5d6ff; }
.api-string  { color: #a5d6ff; }
.api-num     { color: #79c0ff; }
.api-ok      { color: #3fb950; }
.api-saving  { color: #3fb950; font-weight: 700; font-size: 11px; }

.api-pbar {
    height: 4px;
    background: #30363d;
    border-radius: 2px;
    overflow: hidden;
    margin: 3px 0;
}
.api-pbar-fill {
    height: 100%;
    background: #0693e3;
    border-radius: 2px;
    animation: api-pbar-anim 9s infinite 3s;
    width: 0%;
}
@keyframes api-pbar-anim {
    0%        { width: 0%; }
    6%        { width: 5%; }
    25%       { width: 95%; }
    32%, 100% { width: 100%; }
}

/* ── Upscale illustration ── */
.illust-upscale {
    background: #1a0533;
    display: flex;
    position: relative;
}

.up-before, .up-after {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.up-before::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(rgba(0,0,0,0.15) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,0,0,0.15) 1px, transparent 1px);
    background-size: 20px 20px;
}

.up-tag {
    position: absolute;
    top: 9px;
    font-size: 8.5px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.55);
    z-index: 5;
}
.up-before .up-tag { left: 10px; }
.up-after  .up-tag { right: 10px; }

.up-res {
    position: absolute;
    bottom: 9px;
    font-family: 'Courier New', monospace;
    font-size: 9px;
    font-weight: 700;
    color: rgba(255,255,255,0.7);
    background: rgba(0,0,0,0.45);
    padding: 2px 6px;
    border-radius: 4px;
    z-index: 5;
}
.up-before .up-res { left: 8px; }
.up-after  .up-res { right: 8px; }

.up-sweep {
    position: absolute;
    top: 0; bottom: 0;
    width: 2px;
    background: rgba(255,255,255,0.9);
    box-shadow: 0 0 14px 5px rgba(255,255,255,0.45);
    z-index: 10;
    animation: up-sweep 3.5s ease-in-out infinite;
}
@keyframes up-sweep {
    0%, 100% { left: 10%; }
    50%       { left: 88%; }
}

.up-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 15;
    background: linear-gradient(135deg, #7B2FF7, #e3067a);
    color: #fff;
    font-size: 13px;
    font-weight: 900;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255,255,255,0.3);
    animation: up-pulse 2.2s ease-in-out infinite;
    letter-spacing: -0.5px;
}
@keyframes up-pulse {
    0%, 100% { box-shadow: 0 0 18px rgba(123,47,247,0.7); }
    50%       { box-shadow: 0 0 28px rgba(227,6,122,0.9), 0 0 8px rgba(255,255,255,0.2); }
}


/* ═══════════════════════════════════════════════════════════════════
   DASHBOARD STYLES
   ═══════════════════════════════════════════════════════════════════ */

.dash-layout {
    display: flex;
    min-height: calc(100vh - var(--header-h));
}

.dash-sidebar {
    width: 240px;
    background: #fff;
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
    flex-shrink: 0;
    position: sticky;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    overflow-y: auto;
}

.dash-sidebar-section {
    padding: 0 0.75rem;
    margin-bottom: 1.5rem;
}

.dash-sidebar-label {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0 0.75rem;
    margin-bottom: 0.4rem;
}

.dash-nav-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s;
}
.dash-nav-item:hover { background: var(--bg); color: var(--text); }
.dash-nav-item.active {
    background: var(--primary-bg);
    color: var(--primary);
    font-weight: 600;
}
.dash-nav-item .nav-icon { font-size: 1rem; width: 20px; text-align: center; }

.dash-main {
    flex: 1;
    padding: 2rem;
    max-width: 1200px;
}

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

.dash-title {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.dash-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

/* ─── STATS CARDS ─────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem 1.125rem;
}

.stat-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.3rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.stat-change {
    font-size: 0.72rem;
    font-weight: 600;
    margin-top: 0.2rem;
}
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ─── TABLE ───────────────────────────────────────────────────────── */
.dash-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 1.25rem;
}

.dash-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.dash-card-title {
    font-size: 0.95rem;
    font-weight: 700;
}

.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}
thead th {
    text-align: left;
    padding: 0.65rem 1.25rem;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    white-space: nowrap;
}
tbody td {
    padding: 0.7rem 1.25rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FAFBFF; }

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.5rem;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 600;
}
.status-done    { background: var(--success-bg); color: var(--success-dark); }
.status-error   { background: #FEE2E2; color: #991B1B; }
.status-pending { background: #FEF3C7; color: #92400E; }

/* ─── API KEYS ────────────────────────────────────────────────────── */
.api-key-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border);
}
.api-key-row:last-child { border-bottom: none; }

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

.api-key-name {
    font-size: 0.875rem;
    font-weight: 600;
}

.api-key-value {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.2rem;
}

.api-key-mono {
    font-family: 'Courier New', monospace;
    font-size: 0.78rem;
    color: var(--text-muted);
    background: var(--bg);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.api-key-meta {
    font-size: 0.72rem;
    color: var(--text-light);
    margin-top: 0.15rem;
}

.api-key-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }

/* ─── BILLING ─────────────────────────────────────────────────────── */
.plan-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.875rem;
    margin-bottom: 1.5rem;
}

.plan-card {
    background: #fff;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    text-align: center;
    transition: all 0.2s;
    position: relative;
}
.plan-card:hover { border-color: var(--primary-light); }
.plan-card.current { border-color: var(--primary); }
.plan-card.current::after {
    content: 'Текущий';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 100px;
}

.plan-name {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
}

.plan-price {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}
.plan-price small {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
}

.plan-features {
    list-style: none;
    margin: 1rem 0;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.plan-features li {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.plan-features li::before {
    content: '\2713';
    color: var(--success);
    font-weight: 700;
    font-size: 0.72rem;
}

.usage-bar-wrap { margin-top: 0.5rem; }
.usage-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}
.usage-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s;
}
.usage-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

/* ─── PROFILE ─────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.form-input {
    width: 100%;
    padding: 0.55rem 0.875rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--text);
    background: #fff;
    transition: border-color 0.15s;
    font-family: inherit;
}
.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(6,147,227,0.1);
}

.form-hint {
    font-size: 0.72rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }

.toggle-info { flex: 1; }
.toggle-title {
    font-size: 0.85rem;
    font-weight: 600;
}
.toggle-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.toggle {
    position: relative;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}
.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-track {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 11px;
    cursor: pointer;
    transition: background 0.2s;
}
.toggle-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle input:checked + .toggle-track {
    background: var(--primary);
}
.toggle input:checked + .toggle-track::after {
    transform: translateX(18px);
}

/* ─── PAGINATION ──────────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 1rem;
}
.page-btn {
    min-width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1.5px solid var(--border);
    background: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ─── EMPTY STATE ─────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}
.empty-state .empty-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}
.empty-state h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.4rem;
}
.empty-state p {
    font-size: 0.85rem;
    max-width: 320px;
    margin: 0 auto;
}


/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE — Tablet (768px — 1024px)
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .features-grid { grid-template-columns: 1fr; }
    .format-showcase { grid-template-columns: 1fr 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .plan-cards { grid-template-columns: 1fr 1fr; }

    .dash-sidebar { width: 200px; }
    .dash-main { padding: 1.5rem; }

    .feat-illust { height: 180px; }

    nav { gap: 1rem; }
}

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile (< 768px)
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
    /* Header */
    header { padding: 0 1rem; }

    /* Логотип и подпись остаются как на десктопе/support (не ужимаем, подпись видна). */
    .burger { display: flex; }

    nav {
        display: none;
        position: fixed;
        top: var(--header-h);
        left: 0;
        right: 0;
        bottom: 0;
        background: #fff;
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
        gap: 0;
        z-index: 199;
        overflow-y: auto;
    }
    nav.open { display: flex; }
    /* Разделитель — только у обычных пунктов. У .btn НЕ трогаем border,
       иначе обрезается собственная рамка кнопки «Кабинет». */
    nav a:not(.btn) {
        padding: 0.875rem 0.75rem;
        font-size: 1rem;
        border-bottom: 1px solid var(--border);
    }
    nav .btn {
        margin-top: 0.5rem;
        justify-content: center;
        font-size: 1rem;
    }

    /* При открытом меню: блокируем скролл страницы и убираем stats-bar,
       чтобы шапка (sticky top:0) вставала вплотную к меню (nav top:var(--header-h))
       без наезда, а фон не скроллился. */
    body.menu-open { overflow: hidden; }
    body.menu-open .stats-bar { display: none; }

    /* Hero */
    .hero { padding: 2rem 1rem 1.5rem; }
    .hero h1 { font-size: 1.6rem; }
    .hero p { font-size: 0.92rem; margin-bottom: 1.5rem; }
    .hero-badge { font-size: 0.7rem; padding: 0.25rem 0.65rem; }

    /* Format bar */
    .format-bar { gap: 0.3rem; }
    .fmt { padding: 0.28rem 0.65rem; font-size: 0.75rem; }

    /* Main content */
    .main { padding: 0 0.75rem 3rem; }

    /* Drop zone */
    .drop-zone { padding: 2rem 1rem; }
    .drop-icon-wrap { width: 52px; height: 52px; font-size: 24px; border-radius: 14px; }
    .drop-zone h2 { font-size: 0.95rem; }
    .drop-limits { flex-direction: column; align-items: center; gap: 0.4rem; }

    /* Options */
    .opt-format-row {
        padding: 0.6rem 0.75rem;
        gap: 0.35rem;
    }
    .opt-controls-row {
        padding: 0.6rem 0.75rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    /* flex-wrap: содержимое (метка + Выкл/2×/4× + «Сжимать») переносится, а не
       уезжает за край экрана при включённом апскейлинге. */
    .opt-group { min-width: unset; flex-wrap: wrap; }
    .vdivider { display: none; }

    /* File cards */
    .file-card {
        padding: 0.65rem 0.75rem;
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    .thumb { width: 36px; height: 36px; }
    .file-body { min-width: calc(100% - 100px); }
    .file-sizes {
        order: 3;
        width: 100%;
        padding-left: 44px;
        gap: 0.35rem;
    }
    .file-actions {
        order: 4;
        margin-left: auto;
    }

    /* Features */
    .features-grid { grid-template-columns: 1fr; }
    .feat-illust { height: 160px; }

    /* Format showcase */
    .format-showcase { grid-template-columns: 1fr; }

    /* Compare modal */
    .compare-grid { grid-template-columns: 1fr; }
    .modal { padding: 1rem; }

    /* Footer */
    footer {
        padding: 0.42rem 1rem;
        flex-direction: column;
        text-align: center;
    }
    .footer-links { justify-content: center; }

    /* Dashboard */
    .dash-layout { flex-direction: column; }

    .dash-sidebar {
        width: 100%;
        position: static;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 0.75rem;
        display: flex;
        overflow-x: auto;
        gap: 0;
    }
    .dash-sidebar-section {
        display: flex;
        gap: 0.35rem;
        padding: 0;
        margin-bottom: 0;
    }
    .dash-sidebar-label { display: none; }
    .dash-nav-item {
        padding: 0.45rem 0.75rem;
        white-space: nowrap;
        font-size: 0.8rem;
        border-radius: 100px;
        border: 1.5px solid var(--border);
    }
    .dash-nav-item.active {
        border-color: var(--primary);
    }
    .dash-nav-item .nav-icon { display: none; }

    .dash-main { padding: 1rem 0.75rem; }
    .dash-title { font-size: 1.15rem; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
    .stat-card { padding: 0.75rem; }
    .stat-value { font-size: 1.2rem; }

    .plan-cards { grid-template-columns: 1fr; }

    .form-row { grid-template-columns: 1fr; }

    .api-key-row { flex-direction: column; align-items: stretch; }
    .api-key-actions { margin-top: 0.5rem; }

    /* Table horizontal scroll */
    thead th, tbody td { padding: 0.5rem 0.75rem; font-size: 0.78rem; }
}

/* ── Toast notifications ─────────────────────────────────────────────────────── */
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 280px;
  max-width: 420px;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm, 8px);
  font-size: 0.82rem;
  line-height: 1.4;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: toast-in 0.3s ease;
}
.toast.toast-out { animation: toast-out 0.3s ease forwards; }
.toast-success { background: #059669; }
.toast-error { background: #dc2626; }
.toast-info { background: #2563eb; }
.toast-icon { font-size: 1rem; flex-shrink: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(40px); } }

/* ── Button loading state ────────────────────────────────────────────────────── */
.btn.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn.btn-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
}
.btn-outline.btn-loading::after,
.btn-ghost.btn-loading::after {
  border-color: rgba(0,0,0,0.15);
  border-top-color: var(--primary);
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* ── CAPTCHA (антибот на форме входа) ───────────────────────────── */
.lw-captcha-inner { border:1px solid var(--border); border-radius:10px; padding:1rem; background:var(--bg); }
.lw-captcha-label { font-size:0.85rem; color:var(--text-muted,var(--text-light)); margin-bottom:0.75rem; text-align:center; }
.lw-captcha-label b { color:var(--text); }
.lw-captcha-grid { display:flex; justify-content:center; gap:0.75rem; }
.lw-cap-icon { width:56px; height:56px; display:flex; align-items:center; justify-content:center; border:2px solid var(--border); border-radius:10px; cursor:pointer; transition:border-color .15s, transform .15s, background .15s; color:var(--text); background:var(--card-bg,#fff); }
.lw-cap-icon:hover { border-color:var(--primary); transform:scale(1.08); }
.lw-cap-icon.selected { border-color:#22c55e; background:rgba(34,197,94,0.08); }
.lw-cap-icon.wrong { border-color:#ef4444; animation:lw-cap-shake .4s; }
@keyframes lw-cap-shake { 0%,100%{transform:translateX(0);} 20%{transform:translateX(-4px);} 40%{transform:translateX(4px);} 60%{transform:translateX(-3px);} 80%{transform:translateX(3px);} }
