/* Google Fonts @import OLIB TASHLANDI (2026-08-08 optimallashtirish).
   Sabab: CSS ichidagi @import eng sekin yuklash usuli — brauzer avval
   style.css ni yuklab, tahlil qilib, KEYIN googleapis CSS'ini, KEYIN
   gstatic'dan shrift fayllarini oladi (ketma-ket 3 ta so'rov, matn shu
   paytgacha kutadi). Bu 2 ta qo'shimcha tashqi domenga DNS+TLS qo'l
   siqishni ham qo'shardi. Endi tizim shrift steki — bosh sahifada ham
   xuddi shunday qilingan. */
/* ---- pro.html ---- */

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

:root {
    color-scheme: dark;
    --bg-start:var(--st-bg);
    --bg-end:var(--st-surface);
    --bg-gradient:var(--st-bg);

    --card-bg:var(--st-surface);
    --card-bg-hover:var(--st-surface-raised);
    --glass-border:var(--st-line);
    --glass-shadow:var(--st-shadow);

    --primary:var(--st-accent);
    --primary-light:var(--st-accent);
    --primary-dark:var(--st-cta);
    --primary-glow:var(--st-accent-soft);

    --secondary:var(--st-purple);
    --secondary-light:var(--st-purple);
    --secondary-dark:var(--st-purple);
    --secondary-glow:var(--st-card-purple);

    --text-primary:var(--st-text);
    --text-secondary:var(--st-muted);
    --text-tertiary:var(--st-faint);

    --border:var(--st-line);
    --navbar-bg:var(--st-surface);
    --input-bg:var(--st-surface-raised);

    --accent:var(--st-accent);
    --accent-glow:var(--st-accent-soft);
    --success:var(--st-success);
    --error:var(--st-danger);
    --badge-text:var(--st-on-cta);

    /* Pastki navigatsiya ("Aura Dock", 2026-08-08) — suzuvchi shisha kapsula.
       Alfa ataylab yuqori (.72): `backdrop-filter` qo'llab-quvvatlanmaydigan
       eski WebView'da ham fon o'qilarli qoladi. */
    --nav-glass:var(--st-surface);
    --nav-border:var(--st-line);
    --nav-shadow:var(--st-shadow);
}

[data-theme="light"] {
    color-scheme: light;
    --bg-start:var(--st-bg);
    --bg-end:var(--st-surface);
    --bg-gradient:var(--st-bg);
    --card-bg:var(--st-surface);
    --card-bg-hover:var(--st-surface-raised);
    --glass-border:var(--st-line);
    --glass-shadow:var(--st-shadow);

    --text-primary:var(--st-text);
    --text-secondary:var(--st-muted);
    --text-tertiary:var(--st-faint);

    --border:var(--st-line);
    --navbar-bg:var(--st-surface);
    --input-bg:var(--st-surface-raised);

    --accent:var(--st-accent);
    --accent-glow:var(--st-accent-soft);
    --badge-text:var(--st-on-cta);

    --nav-glass:var(--st-surface);
    --nav-border:var(--st-line);
    --nav-shadow:var(--st-shadow);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    /* Pastki padding "Aura Dock" balandligiga moslangan: dock 64px + pastdan
       10px chekinish + zaxira. (Dock 72->64px yupqalashtirilganda bu qiymat
       ham 116->108 ga tushirildi — bo'shagan joy kontentga qaytarildi.) */
    padding: 90px 20px 108px;
    transition: background 0.3s;
}

/* Navbar Styles */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--navbar-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    gap: 12px;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.balance-container {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 8px 20px;
    max-width: 100%;
}

.balance-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.balance-amount {
    color: var(--accent);
    font-weight: 700;
}

.topup-btn {
    background: linear-gradient(135deg, var(--accent) 0%, #0ea5e9 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.3rem;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.topup-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px var(--accent-glow);
}

.topup-btn:active {
    transform: scale(0.95);
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.ui-lang-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px;
    border-radius: 999px;
    background: var(--input-bg);
    border: 1px solid var(--border);
}

.ui-lang-btn {
    background: var(--input-bg);
    border: 1px solid transparent;
    border-radius: 999px;
    color: var(--text-primary);
    padding: 6px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.4px;
    cursor: pointer;
    outline: none;
}

.ui-lang-btn.active {
    background: var(--accent);
    color: var(--badge-text);
    box-shadow: 0 6px 14px var(--accent-glow);
}

.theme-toggle {
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 50px;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    transition: transform 0.2s, background 0.2s;
}

.theme-toggle:hover {
    background: var(--accent-glow);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

.header {
    text-align: center;
    margin-bottom: 40px;
}

.pro-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 999px;
    background: linear-gradient(135deg, #06b6d4 0%, #8b5cf6 100%);
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 1px;
    box-shadow: 0 6px 18px rgba(6, 182, 212, 0.3);
}

.pro-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.pro-title {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.pro-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

.pro-features {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin: 18px 0 6px;
}

.pro-feature {
    border: 1px solid var(--border);
    background: var(--input-bg);
    border-radius: 14px;
    padding: 14px;
    text-align: left;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.pro-feature strong {
    color: var(--text-primary);
    display: block;
    margin-bottom: 6px;
    font-size: 0.95rem;
}

@media (max-width: 768px) {
    .pro-features {
        grid-template-columns: 1fr;
    }
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 10px;
}

.header p {
    color: var(--text-secondary);
    font-size: 1rem;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 32px;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 28px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
}

input[type="text"],
input[type="number"],
textarea,
html body select {
    width: 100%;
    padding: 14px 16px;
    background: var(--input-bg);
    border: 2px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
    outline: none;
    resize: none;
}

select option {
    background: var(--bg-start);
    color: var(--text-primary);
    padding: 10px;
}

/* Native select'ning yopiq holatini barcha TWA sahifalarida bir xil qilamiz. */
select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    padding-right: 46px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 18px;
}

/* Bepul yakuniy slayd uchun izohli, katta bosish maydoniga ega toggle-karta. */
.thanks-option {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    margin: 0 0 24px;
    padding: 15px 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(6, 182, 212, .07), rgba(139, 92, 246, .05));
    cursor: pointer;
    transition: border-color .2s ease, background .2s ease, transform .2s ease, box-shadow .2s ease;
    -webkit-tap-highlight-color: transparent;
}

.thanks-option:hover {
    border-color: rgba(6, 182, 212, .55);
}

.thanks-option:active {
    transform: scale(.992);
}

.thanks-option:has(input:checked) {
    border-color: var(--accent);
    background: linear-gradient(135deg, rgba(6, 182, 212, .16), rgba(139, 92, 246, .09));
    box-shadow: 0 10px 28px rgba(6, 182, 212, .10);
}

.thanks-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.thanks-copy {
    min-width: 0;
    flex: 1;
}

.thanks-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 4px;
    color: var(--text-primary);
    font-size: .94rem;
    font-weight: 750;
    line-height: 1.3;
}

.thanks-badge {
    flex: 0 0 auto;
    padding: 3px 7px;
    border-radius: 999px;
    color: var(--accent);
    background: rgba(6, 182, 212, .12);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .02em;
}

.thanks-description {
    display: block;
    color: var(--text-secondary);
    font-size: .78rem;
    font-weight: 450;
    line-height: 1.45;
}

.thanks-switch {
    position: relative;
    flex: 0 0 auto;
    width: 46px;
    height: 27px;
    border: 1px solid rgba(148, 163, 184, .34);
    border-radius: 999px;
    background: rgba(100, 116, 139, .28);
    transition: background .2s ease, border-color .2s ease;
}

.thanks-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 19px;
    height: 19px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 7px rgba(0, 0, 0, .28);
    transition: transform .22s cubic-bezier(.2, .8, .2, 1);
}

.thanks-option input:checked ~ .thanks-switch {
    border-color: var(--accent);
    background: var(--accent);
}

.thanks-option input:checked ~ .thanks-switch::after {
    transform: translateX(19px);
}

.thanks-option input:focus-visible ~ .thanks-switch {
    outline: 3px solid var(--accent-glow);
    outline-offset: 3px;
}

/* Faylning keyingi takrorlangan tema bloklaridan keyin ham custom select saqlansin. */
html body select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    padding-right: 46px;
    background-color: var(--input-bg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 18px;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--accent);
}

input::placeholder {
    color: var(--text-secondary);
}

.input-hint {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
    background: rgba(255, 255, 255, 0.03);
    padding: 10px 12px;
    border-radius: 8px;
    border-left: 3px solid var(--accent);
    border-right: 3px solid var(--accent);
}

.input-hint i {
    font-style: normal;
    font-size: 1rem;
}

.hint-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(0, 217, 255, 0.08);
    border: 1px solid rgba(0, 217, 255, 0.25);
    color: var(--text-secondary);
    font-size: 0.78rem;
    line-height: 1.2;
    white-space: nowrap;
}

.hint-chip .hint-icon {
    font-size: 0.9rem;
}

.hint-chip .hint-text {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 520px;
}

@media (max-width: 768px) {
    .hint-chip {
        width: 100%;
        white-space: normal;
        border-radius: 12px;
    }

    .hint-chip .hint-text {
        max-width: 100%;
    }
}

/* Fayl yuklash tugmasi (source-upload) — native <input type="file"> vizual jihatdan
   yashirilib, o'rniga saytdagi ikkilamchi-tugma uslubidagi <label> ko'rsatiladi. */
.file-upload-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.file-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: 12px;
    border: 1px dashed var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.2s ease, border-style 0.2s ease, background 0.2s ease, color 0.2s ease;
    user-select: none;
}

.file-upload-btn:hover {
    border-color: var(--accent);
    border-style: solid;
    background: rgba(0, 217, 255, 0.08);
    color: var(--text-primary);
}

.file-upload-btn svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.file-upload-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
    min-height: 1.2em;
    margin-top: 8px;
}

.file-upload-status svg {
    vertical-align: -2px;
    margin-right: 4px;
    flex-shrink: 0;
}

.form-label-icon {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.form-label-icon svg {
    flex-shrink: 0;
    opacity: 0.85;
}

/* "O'z faylimdan" kabi ixtiyoriy bo'limlar — majburiy maydon labellaridan (.form-group label)
   vizual jihatdan yengilroq ko'rinishi kerak, aks holda foydalanuvchi buni majburiy deb o'ylaydi. */
.form-group label.form-label-icon.optional-label {
    color: var(--text-secondary);
    font-weight: 400;
    font-size: 0.85rem;
}

.source-upload-hint {
    font-size: 0.78rem;
    color: var(--text-secondary);
    opacity: 0.85;
    margin: 4px 0 10px;
    line-height: 1.4;
}

/* Biriktirilgan manba fayllari (chip'lar) — EPIC D ko'p-fayl / preview / "mening fayllarim" */
.source-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--input-bg);
    margin-bottom: 8px;
}

.source-chip-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.source-chip-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-chip-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.source-chip-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.source-chip-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.source-chip-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.source-chip-btn.remove:hover {
    color: var(--error);
}

.source-chip-preview {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    padding: 8px 10px;
    margin: -4px 0 8px 0;
    line-height: 1.4;
    font-style: italic;
}

.my-sources-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--accent);
    cursor: pointer;
    background: none;
    border: none;
    padding: 8px 0;
    user-select: none;
}

.my-sources-toggle:hover {
    text-decoration: underline;
}

.my-sources-list {
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 10px;
    overflow: hidden;
}

.my-sources-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s ease;
}

.my-sources-item:last-child {
    border-bottom: none;
}

.my-sources-item:hover {
    background: rgba(0, 217, 255, 0.08);
}

.my-sources-item-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.my-sources-item-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.my-sources-empty {
    padding: 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
}

.template-slider-wrapper {
    position: relative;
    margin-top: 12px;
}

.template-slider {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 8px 4px 12px 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}

.template-slider::-webkit-scrollbar {
    height: 6px;
}

.template-slider::-webkit-scrollbar-track {
    background: var(--input-bg);
    border-radius: 10px;
}

.template-slider::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 10px;
}

.template-card {
    flex: 0 0 200px;
    background: var(--input-bg);
    border: 2px solid var(--border);
    border-radius: 16px;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.2s;
    overflow: hidden;
}

.template-card:active {
    transform: scale(0.98);
}

.template-card.active {
    border-color: var(--accent);
}

.template-preview {
    width: 100%;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.template-card[data-template="modern"] .template-preview {
    background: linear-gradient(135deg, #00d9ff 0%, #0ea5e9 100%);
}

.template-card[data-template="minimal"] .template-preview {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

.template-card[data-template="business"] .template-preview {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.template-card[data-template="creative"] .template-preview {
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
}

.template-mockup {
    width: 80%;
    height: 70%;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 4px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mockup-line {
    height: 6px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
}

.mockup-line:first-child {
    width: 60%;
    height: 8px;
    background: rgba(0, 0, 0, 0.2);
}

.mockup-line:nth-child(2) {
    width: 80%;
}

.mockup-line:nth-child(3) {
    width: 70%;
}

.template-name {
    padding: 12px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
}

.radio-group {
    display: flex;
    gap: 16px;
    margin-top: 12px;
}

.radio-option {
    flex: 1;
    background: var(--input-bg);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: border-color 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.radio-option.active {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.radio-option input[type="radio"] {
    width: 20px;
    height: 20px;
    accent-color: var(--accent);
}

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    background: var(--input-bg);
    cursor: pointer;
    transition: border-color 0.2s;
    margin-top: 12px;
}

.upload-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.6;
}

.btn-primary {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, var(--accent) 0%, #0ea5e9 100%);
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
    margin-top: 20px;
}

.btn-primary:active {
    transform: scale(0.98);
}

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

.btn-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--accent);
    font-weight: 600;
    font-size: 1rem;
    text-decoration: none;
    padding: 10px 0;
    transition: all 0.2s;
}

.btn-link:hover {
    gap: 12px;
    opacity: 0.8;
}

.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    to {
        left: 100%;
    }
}

/* Bottom Navigation */

@media (max-width: 768px) {
    body {
        padding-top: 90px;
    }

    .navbar {
        padding: 10px 15px;
        height: auto;
        flex-wrap: nowrap;
    }

    .balance-container {
        padding: 6px 12px;
        font-size: 0.85rem;
        min-width: 0;
    }

    .balance-text {
        font-size: 0.85rem;
    }

    .topup-btn {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }

    .theme-toggle {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }

    .ui-lang-toggle {
        padding: 4px;
    }

    .ui-lang-btn {
        padding: 5px 8px;
        font-size: 0.75rem;
    }

    .header h1 {
        font-size: 2rem;
    }

    .card {
        padding: 24px;
    }

    .radio-group {
        flex-direction: column;
    }

    .template-card {
        flex: 0 0 160px;
    }

}

@media (max-width: 480px) {
    .balance-label {
        display: none;
    }
}

@media (max-width: 420px) {
    .navbar-left {
        gap: 8px;
    }

    .balance-text {
        max-width: 180px;
    }

    .ui-lang-toggle {
        gap: 4px;
    }

    .navbar {
        padding: 8px 10px;
    }

    .topup-btn {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    .theme-toggle {
        width: 38px;
        height: 38px;
        font-size: 18px;
    }
}

@media (max-width: 360px) {
    .balance-text {
        max-width: 120px;
        font-size: 0.78rem;
    }

    .ui-lang-btn {
        padding: 4px 6px;
        font-size: 0.7rem;
    }
}

.hidden {
    display: none !important;
}

/* Auth Loading & Error Styles */
#auth-loading,
#auth-error {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-start);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    text-align: center;
    padding: 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--input-bg);
    border-top: 4px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    backdrop-filter: blur(5px);
}

.modal.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 24px;
    max-width: 90%;
    max-height: 90%;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid var(--border);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal-content img {
    max-width: 100%;
    max-height: 60vh;
    border-radius: 12px;
    object-fit: contain;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.close-modal {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
    z-index: 10;
}

.close-modal:hover {
    color: var(--text-primary);
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.preview-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 1.2rem;
}

.template-card:hover .preview-btn {
    opacity: 1;
}

.preview-btn:hover {
    background: var(--accent);
    transform: scale(1.1);
}

@media (max-width: 768px) {
    .preview-btn {
        opacity: 1;
        background: rgba(0, 0, 0, 0.4);
    }
}

/* Custom Select Styles */
.custom-select-wrapper {
    position: relative;
    user-select: none;
    width: 100%;
}

.custom-select {
    position: relative;
    display: flex;
    flex-direction: column;
}

.custom-select-trigger {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-primary);
    background: var(--input-bg);
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 0; /* Overflows handling */
}

.custom-select-trigger span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
}

.custom-select-trigger img {
    flex-shrink: 0;
}

.custom-select-trigger:hover {
    border-color: var(--accent);
}

.custom-select.open .custom-select-trigger {
    border-color: var(--accent);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.custom-select-trigger::after {
    content: '';
    width: 10px;
    height: 10px;
    border-right: 2px solid var(--text-secondary);
    border-bottom: 2px solid var(--text-secondary);
    transform: rotate(45deg) translateY(-2px);
    transition: transform 0.2s;
    margin-left: 12px;
}

.custom-select.open .custom-select-trigger::after {
    transform: rotate(225deg) translateY(-2px);
}

.custom-options {
    position: absolute;
    display: block;
    top: 100%;
    left: 0;
    right: 0;
    border: 2px solid var(--accent);
    border-top: 0;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    background: var(--card-bg);
    transition: all 0.2s;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 1000;
    max-height: 250px;
    overflow-y: auto;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
}

.custom-select.open .custom-options {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.custom-option {
    position: relative;
    display: block;
    padding: 12px 16px;
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 1px solid var(--border);
}

.custom-option:last-of-type {
    border-bottom: 0;
}

.custom-option:hover,
.custom-option.selected {
    background: var(--accent-glow);
    color: var(--accent);
}

.custom-option.selected::after {
    content: '✓';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--accent);
    font-weight: bold;
}

.custom-options::-webkit-scrollbar {
    width: 6px;
}

.custom-options::-webkit-scrollbar-track {
    background: var(--input-bg);
}

.custom-options::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}

@media (max-width: 768px) {
    .preview-btn {
        opacity: 1;
        background: rgba(0, 0, 0, 0.4);
    }
}

/* ---- standard.html ---- */
/* Google Fonts @import OLIB TASHLANDI (2026-08-08 optimallashtirish).
   Sabab: CSS ichidagi @import eng sekin yuklash usuli — brauzer avval
   style.css ni yuklab, tahlil qilib, KEYIN googleapis CSS'ini, KEYIN
   gstatic'dan shrift fayllarini oladi (ketma-ket 3 ta so'rov, matn shu
   paytgacha kutadi). Bu 2 ta qo'shimcha tashqi domenga DNS+TLS qo'l
   siqishni ham qo'shardi. Endi tizim shrift steki — bosh sahifada ham
   xuddi shunday qilingan. */

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

:root {
    --bg-start:var(--st-bg);
    --bg-end:var(--st-surface);
    --bg-gradient:var(--st-bg);

    --card-bg:var(--st-surface);
    --card-bg-hover:var(--st-surface-raised);
    --glass-border:var(--st-line);
    --glass-shadow:var(--st-shadow);

    --primary:var(--st-accent);
    --primary-light:var(--st-accent);
    --primary-dark:var(--st-cta);
    --primary-glow:var(--st-accent-soft);

    --secondary:var(--st-purple);
    --secondary-light:var(--st-purple);
    --secondary-dark:var(--st-purple);
    --secondary-glow:var(--st-card-purple);

    --text-primary:var(--st-text);
    --text-secondary:var(--st-muted);
    --text-tertiary:var(--st-faint);

    --border:var(--st-line);
    --navbar-bg:var(--st-surface);
    --input-bg:var(--st-surface-raised);

    --accent:var(--st-accent);
    --accent-glow:var(--st-accent-soft);
    --success:var(--st-success);
    --error:var(--st-danger);
    --badge-text:var(--st-on-cta);

    /* Pastki navigatsiya ("Aura Dock", 2026-08-08) — suzuvchi shisha kapsula.
       Alfa ataylab yuqori (.72): `backdrop-filter` qo'llab-quvvatlanmaydigan
       eski WebView'da ham fon o'qilarli qoladi. */
    --nav-glass:var(--st-surface);
    --nav-border:var(--st-line);
    --nav-shadow:var(--st-shadow);
}

[data-theme="light"] {
    --bg-start:var(--st-bg);
    --bg-end:var(--st-surface);
    --bg-gradient:var(--st-bg);
    --card-bg:var(--st-surface);
    --card-bg-hover:var(--st-surface-raised);
    --glass-border:var(--st-line);
    --glass-shadow:var(--st-shadow);

    --text-primary:var(--st-text);
    --text-secondary:var(--st-muted);
    --text-tertiary:var(--st-faint);

    --border:var(--st-line);
    --navbar-bg:var(--st-surface);
    --input-bg:var(--st-surface-raised);

    --accent:var(--st-accent);
    --accent-glow:var(--st-accent-soft);
    --badge-text:var(--st-on-cta);

    --nav-glass:var(--st-surface);
    --nav-border:var(--st-line);
    --nav-shadow:var(--st-shadow);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    /* Pastki padding "Aura Dock" balandligiga moslangan: dock 64px + pastdan
       10px chekinish + zaxira. (Dock 72->64px yupqalashtirilganda bu qiymat
       ham 116->108 ga tushirildi — bo'shagan joy kontentga qaytarildi.) */
    padding: 90px 20px 108px;
    transition: background 0.3s;
}

/* Navbar Styles */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--navbar-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    gap: 12px;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.balance-container {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 8px 20px;
    max-width: 100%;
}

.balance-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.balance-amount {
    color: var(--accent);
    font-weight: 700;
}

.topup-btn {
    background: linear-gradient(135deg, var(--accent) 0%, #0ea5e9 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.3rem;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.topup-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px var(--accent-glow);
}

.topup-btn:active {
    transform: scale(0.95);
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.ui-lang-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px;
    border-radius: 999px;
    background: var(--input-bg);
    border: 1px solid var(--border);
}

.ui-lang-btn {
    background: var(--input-bg);
    border: 1px solid transparent;
    border-radius: 999px;
    color: var(--text-primary);
    padding: 6px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.4px;
    cursor: pointer;
    outline: none;
}

.ui-lang-btn.active {
    background: var(--accent);
    color: var(--badge-text);
    box-shadow: 0 6px 14px var(--accent-glow);
}

.theme-toggle {
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 50px;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    transition: transform 0.2s, background 0.2s;
}

.theme-toggle:hover {
    background: var(--accent-glow);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

.header {
    text-align: center;
    margin-bottom: 40px;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 10px;
}

.header p {
    color: var(--text-secondary);
    font-size: 1rem;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 32px;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 28px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
}

input[type="text"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 14px 16px;
    background: var(--input-bg);
    border: 2px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
    outline: none;
    resize: none;
}

select option {
    background: var(--bg-start);
    color: var(--text-primary);
    padding: 10px;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--accent);
}

input::placeholder {
    color: var(--text-secondary);
}

.input-hint {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
    background: rgba(255, 255, 255, 0.03);
    padding: 10px 12px;
    border-radius: 8px;
    border-left: 3px solid var(--accent);
    border-right: 3px solid var(--accent);
}

.input-hint i {
    font-style: normal;
    font-size: 1rem;
}

.hint-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(0, 217, 255, 0.08);
    border: 1px solid rgba(0, 217, 255, 0.25);
    color: var(--text-secondary);
    font-size: 0.78rem;
    line-height: 1.2;
    white-space: nowrap;
}

.hint-chip .hint-icon {
    font-size: 0.9rem;
}

.hint-chip .hint-text {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 520px;
}

@media (max-width: 768px) {
    .hint-chip {
        width: 100%;
        white-space: normal;
        border-radius: 12px;
    }

    .hint-chip .hint-text {
        max-width: 100%;
    }
}

.template-slider-wrapper {
    position: relative;
    margin-top: 12px;
}

.template-slider {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 4px 4px 12px 4px;
}

.template-slider::-webkit-scrollbar {
    height: 6px;
}

.template-slider::-webkit-scrollbar-track {
    background: var(--input-bg);
    border-radius: 10px;
}

.template-slider::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 10px;
}

.template-card {
    flex: 0 0 200px;
    background: var(--input-bg);
    border: 2px solid var(--border);
    border-radius: 16px;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.2s;
    overflow: hidden;
}

.template-card:active {
    transform: scale(0.98);
}

.template-card.active {
    border-color: var(--accent);
}

.template-preview {
    width: 100%;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.template-card[data-template="modern"] .template-preview {
    background: linear-gradient(135deg, #00d9ff 0%, #0ea5e9 100%);
}

.template-card[data-template="minimal"] .template-preview {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

.template-card[data-template="business"] .template-preview {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.template-card[data-template="creative"] .template-preview {
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
}

.template-mockup {
    width: 80%;
    height: 70%;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 4px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mockup-line {
    height: 6px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
}

.mockup-line:first-child {
    width: 60%;
    height: 8px;
    background: rgba(0, 0, 0, 0.2);
}

.mockup-line:nth-child(2) {
    width: 80%;
}

.mockup-line:nth-child(3) {
    width: 70%;
}

.template-name {
    padding: 12px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
}

.radio-group {
    display: flex;
    gap: 16px;
    margin-top: 12px;
}

.radio-option {
    flex: 1;
    background: var(--input-bg);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: border-color 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.radio-option.active {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.radio-option input[type="radio"] {
    width: 20px;
    height: 20px;
    accent-color: var(--accent);
}

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    background: var(--input-bg);
    cursor: pointer;
    transition: border-color 0.2s;
    margin-top: 12px;
}

.upload-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.6;
}

.btn-primary {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, var(--accent) 0%, #0ea5e9 100%);
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
    margin-top: 20px;
}

.btn-primary:active {
    transform: scale(0.98);
}

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

.btn-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--accent);
    font-weight: 600;
    font-size: 1rem;
    text-decoration: none;
    padding: 10px 0;
    transition: all 0.2s;
}

.btn-link:hover {
    gap: 12px;
    opacity: 0.8;
}

.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    to {
        left: 100%;
    }
}

/* ─── Bottom Navigation — "Aura Dock" (2026-08-08) ────────────────────────────
   Suzuvchi shisha kapsula + bo'lim rangi identifikatori.
   Har tugmaning rangi landing sahifasidagi o'sha bo'lim narx kartasi bilan
   bir xil — navigatsiya ekotizimning rangli xaritasiga aylanadi.

   MUHIM (arxitektura): bu blok butunlay SOF CSS — navigatsiya markup'i 4 ta
   HTML faylda takrorlangani uchun (pro/papers/summary/coursework), bo'lim
   rangi HTML'da allaqachon mavjud `href` atributi orqali aniqlanadi. Shu
   tufayli HTML fayllarga umuman tegilmaydi va kelajakda yangi bo'lim
   qo'shilganda faqat bitta selektor qo'shish kifoya.
   `color-mix()` ataylab ISHLATILMAGAN — eski Android WebView'da qo'llab-
   quvvatlanmaydi va butun qiymat tushib qoladi; ranglar tayyor rgba().
   ───────────────────────────────────────────────────────────────────────── */
.bottom-nav {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    width: min(calc(100% - 24px), 520px);
    display: flex;
    gap: 0;
    padding: 6px;
    border-radius: 22px;
    background: var(--nav-glass);
    backdrop-filter: blur(22px) saturate(140%);
    -webkit-backdrop-filter: blur(22px) saturate(140%);
    border: 1px solid var(--nav-border);
    box-shadow: var(--nav-shadow);
    z-index: 999;
}

/* Bo'lim identifikatori — landing narx kartalari ranglariga mos */
.nav-item[href="/pro"] {
    --sec:var(--st-accent);
    --sec-soft:var(--st-accent-soft);
    --sec-glow:transparent;
}

.nav-item[href="/papers"] {
    --sec:var(--st-accent);
    --sec-soft:var(--st-accent-soft);
    --sec-glow:transparent;
}

.nav-item[href="/summary"] {
    --sec:var(--st-accent);
    --sec-soft:var(--st-accent-soft);
    --sec-glow:transparent;
}

.nav-item[href="/coursework"] {
    --sec:var(--st-accent);
    --sec-soft:var(--st-accent-soft);
    --sec-glow:transparent;
}

/* Testlar — 5-bo'lim (2026-08-08). Qahrabo rang ataylab tanlandi: mavjud
   to'rttasidan (siyan/ko'k/binafsha/yashil) yetarlicha uzoq, shuning uchun
   faol holat bir qarashda ajralib turadi. */
.nav-item[href="/tests"] {
    --sec:var(--st-accent);
    --sec-soft:var(--st-accent-soft);
    --sec-glow:transparent;
}

.nav-item {
    position: relative;
    flex: 1;
    /* 2026-08-08: dock yupqalashtirildi (72 -> 64px). 8px aynan shu vertikal
       padding'dan olindi — dock'ning o'z padding'idan EMAS, chunki: (1) u
       bosish maydonini kattalashtirmaydi, (2) faol aura kapsulasi dock chetiga
       tegib, "kapsula ichidagi kapsula" ko'rinishi buzilardi.
       Natijada bosish maydoni 50x88px — Apple HIG (44pt), Material (48dp) va
       WCAG 2.2 AAA (44px) minimumlaridan yuqori. Bundan pastga tushirilmasin. */
    padding: 5px 2px 4px;
    border-radius: 16px;
    color: var(--text-tertiary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.7rem;
    letter-spacing: -0.01em;
    transition: color 0.18s ease, transform 0.12s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border: none;
    min-width: 0;
    background: transparent;
}

/* Yorliq matni tugma kengligidan oshmasin */
.nav-item span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-item svg {
    width: 22px;
    height: 22px;
    opacity: 0.55;
    transition: opacity 0.18s ease;
    flex-shrink: 0;
}

/* Faol tugma aurasi — pseudo-element (HTML'ga tegmaslik uchun) */
.nav-item.active::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    background: var(--sec-soft);
    box-shadow: 0 0 18px var(--sec-glow);
    animation: navSettle 0.18s ease-out;
    z-index: 0;
}

/* Ikonka va matn aura USTIDA qolishi kerak */
.nav-item>* {
    position: relative;
    z-index: 1;
}

@keyframes navSettle {
    from {
        opacity: 0;
        transform: scale(0.88);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.nav-item.active {
    color: var(--sec);
    font-weight: 600;
    background: transparent;
    border: none;
}

.nav-item.active svg {
    opacity: 1;
    color: var(--sec);
    stroke-width: 2.2;
}

/* Light mavzuda nur (glow) kir ko'rinadi — faqat tiniq fon qoladi */
[data-theme="light"] .nav-item.active::before {
    box-shadow: none;
    background: var(--sec-soft);
    filter: saturate(1.1);
}

.nav-item:active {
    transform: scale(0.94);
}

.nav-item:hover:not(.active) {
    background: transparent;
    color: var(--text-primary);
}

.nav-item:hover:not(.active) svg {
    opacity: 0.8;
}

/* Tor ekranlar (iPhone SE va shunga o'xshash) */
@media (max-width: 360px) {
    .bottom-nav {
        width: calc(100% - 12px);
        bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    }

    .nav-item {
        font-size: 0.64rem;
    }

    .nav-item svg {
        width: 20px;
        height: 20px;
    }
}

@media (prefers-reduced-motion: reduce) {

    .nav-item,
    .nav-item svg {
        transition: none;
    }

    .nav-item.active::before {
        animation: none;
    }

    .nav-item:active {
        transform: none;
    }
}

@media (max-width: 768px) {
    body {
        padding-top: 90px;
    }

    .navbar {
        padding: 10px 15px;
        height: auto;
        flex-wrap: nowrap;
    }

    .balance-container {
        padding: 6px 12px;
        font-size: 0.85rem;
        min-width: 0;
    }

    .balance-text {
        font-size: 0.85rem;
    }

    .topup-btn {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }

    .theme-toggle {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }

    .ui-lang-toggle {
        padding: 4px;
    }

    .ui-lang-btn {
        padding: 5px 8px;
        font-size: 0.75rem;
    }

    .header h1 {
        font-size: 2rem;
    }

    .card {
        padding: 24px;
    }

    .radio-group {
        flex-direction: column;
    }

    .template-card {
        flex: 0 0 160px;
    }
}

@media (max-width: 480px) {
    .balance-label {
        display: none;
    }
}

@media (max-width: 420px) {
    .navbar-left {
        gap: 8px;
    }

    .balance-text {
        max-width: 180px;
    }

    .ui-lang-toggle {
        gap: 4px;
    }

    .navbar {
        padding: 8px 10px;
    }

    .topup-btn {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    .theme-toggle {
        width: 38px;
        height: 38px;
        font-size: 18px;
    }
}

@media (max-width: 360px) {
    .balance-text {
        max-width: 120px;
        font-size: 0.78rem;
    }

    .ui-lang-btn {
        padding: 4px 6px;
        font-size: 0.7rem;
    }
}

.hidden {
    display: none !important;
}

/* Auth Loading & Error Styles */
#auth-loading,
#auth-error {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-start);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    text-align: center;
    padding: 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--input-bg);
    border-top: 4px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    backdrop-filter: blur(5px);
}

.modal.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 24px;
    max-width: 90%;
    max-height: 90%;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid var(--border);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal-content img {
    max-width: 100%;
    max-height: 60vh;
    border-radius: 12px;
    object-fit: contain;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.close-modal {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
    z-index: 10;
}

.close-modal:hover {
    color: var(--text-primary);
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.preview-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 1.2rem;
}

.template-card:hover .preview-btn {
    opacity: 1;
}

.preview-btn:hover {
    background: var(--accent);
    transform: scale(1.1);
}

@media (max-width: 768px) {
    .preview-btn {
        opacity: 1;
        background: rgba(0, 0, 0, 0.4);
    }
}

/* Custom Select Styles */
.custom-select-wrapper {
    position: relative;
    user-select: none;
    width: 100%;
}

.custom-select {
    position: relative;
    display: flex;
    flex-direction: column;
}

.custom-select-trigger {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-primary);
    background: var(--input-bg);
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 0;
}

.custom-select-trigger span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
}

.custom-select-trigger img {
    flex-shrink: 0;
}

.custom-select-trigger:hover {
    border-color: var(--accent);
}

.custom-select.open .custom-select-trigger {
    border-color: var(--accent);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.custom-select-trigger::after {
    content: '';
    width: 10px;
    height: 10px;
    border-right: 2px solid var(--text-secondary);
    border-bottom: 2px solid var(--text-secondary);
    transform: rotate(45deg) translateY(-2px);
    transition: transform 0.2s;
    margin-left: 12px;
}

.custom-select.open .custom-select-trigger::after {
    transform: rotate(225deg) translateY(-2px);
}

.custom-options {
    position: absolute;
    display: block;
    top: 100%;
    left: 0;
    right: 0;
    border: 2px solid var(--accent);
    border-top: 0;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    background: var(--card-bg);
    transition: all 0.2s;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 1000;
    max-height: 250px;
    overflow-y: auto;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
}

.custom-select.open .custom-options {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.custom-option {
    position: relative;
    display: block;
    padding: 12px 16px;
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 1px solid var(--border);
}

.custom-option:last-of-type {
    border-bottom: 0;
}

.custom-option:hover,
.custom-option.selected {
    background: var(--accent-glow);
    color: var(--accent);
}

.custom-option.selected::after {
    content: '✓';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--accent);
    font-weight: bold;
}

.custom-options::-webkit-scrollbar {
    width: 6px;
}

.custom-options::-webkit-scrollbar-track {
    background: var(--input-bg);
}

.custom-options::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}

@media (max-width: 768px) {
    .preview-btn {
        opacity: 1;
        background: rgba(0, 0, 0, 0.4);
    }
}

/* Responsive adjustments for bottom-nav on mobile */
@media (max-width: 480px) {

    .balance-text {
        font-size: 0.85rem;
    }
}

@media (max-width: 380px) {
    .navbar {
        padding: 6px 8px;
    }

    .navbar-left,
    .navbar-right {
        gap: 6px;
    }

    .balance-container {
        padding: 4px 8px;
    }

    .balance-amount {
        font-size: 0.75rem;
    }

    .topup-btn {
        width: 28px;
        height: 28px;
        font-size: 1.1rem;
    }

    .ui-lang-toggle {
        padding: 2px;
    }

    .ui-lang-btn {
        padding: 4px 6px;
        font-size: 0.65rem;
    }

    .theme-toggle {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
}

/* Language Dropdown Styles */
.ui-lang-dropdown {
    position: relative;
    z-index: 1001;
}

.ui-lang-trigger {
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 6px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    height: 40px;
}

.ui-lang-trigger:hover {
    background: var(--card-bg-hover);
}

.ui-lang-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--navbar-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    min-width: 140px;
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    gap: 4px;
    transform-origin: top right;
    animation: fadeInDown 0.2s ease-out;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.ui-lang-item {
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s, color 0.2s;
    font-weight: 500;
}

.ui-lang-item:hover, .ui-lang-item.active {
    background: var(--input-bg);
    color: var(--accent);
}

@media (max-width: 768px) {
    .ui-lang-trigger {
        height: 38px;
        padding: 4px 10px;
        font-size: 0.85rem;
    }
}
@media (max-width: 420px) {
    .ui-lang-trigger {
        height: 36px;
        padding: 2px 8px;
        gap: 4px;
        font-size: 0.8rem;
    }
}

/* ================================================================
   SVG Icon System
   ================================================================ */

.theme-toggle { font-size: 0; }

.theme-icon-moon,
.theme-icon-sun {
    color: var(--text-secondary);
    transition: color 0.2s;
    display: none;
}
.theme-icon-moon { display: block; }
[data-theme="light"] .theme-icon-moon { display: none; }
[data-theme="light"] .theme-icon-sun { display: block; }
.theme-toggle:hover .theme-icon-moon,
.theme-toggle:hover .theme-icon-sun { color: var(--text-primary); }

.settings-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    transition: all 0.2s ease;
    margin-left: 8px;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.settings-toggle:hover {
    background: var(--accent-glow);
    color: var(--accent);
    border-color: var(--accent);
}

.icon-warning-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}
.icon-warning {
    color: var(--error);
    filter: drop-shadow(0 0 16px rgba(239, 68, 68, 0.35));
}

.success-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
}
.checkmark {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: block;
    stroke: var(--success);
    stroke-width: 2;
    stroke-miterlimit: 10;
}
.checkmark__circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-width: 2;
    stroke: var(--success);
    fill: rgba(16, 185, 129, 0.08);
    animation: checkmark-stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}
.checkmark__check {
    transform-origin: 50% 50%;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    stroke: var(--success);
    stroke-width: 3;
    stroke-linecap: round;
    animation: checkmark-stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.6s forwards;
}
@keyframes checkmark-stroke { 100% { stroke-dashoffset: 0; } }

.hint-chip .hint-icon {
    font-size: 0;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    color: var(--accent);
}

.preview-btn { font-size: 0 !important; }
.preview-btn svg { width: 15px; height: 15px; color: white; }

.btn-primary { display: flex; align-items: center; justify-content: center; }
.upload-icon { font-size: 0; }
.upload-icon svg { color: var(--text-secondary); }
/* ================================================================
   Wizard (Multi-step form)
   ================================================================ */

/* Stepper */
.wizard-stepper {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    margin-bottom: 32px;
    gap: 4px;
}
.wizard-dot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    position: relative;
}
.wizard-dot-num {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    background: var(--input-bg);
    border: 2px solid var(--border);
    color: var(--text-secondary);
    transition: all 0.25s ease;
}
.wizard-dot-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    transition: color 0.25s ease;
    white-space: nowrap;
}
.wizard-dot.active .wizard-dot-num {
    background: linear-gradient(135deg, var(--accent) 0%, #0ea5e9 100%);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 12px var(--accent-glow);
}
.wizard-dot.active .wizard-dot-label {
    color: var(--text-primary);
    font-weight: 600;
}
.wizard-dot.done .wizard-dot-num {
    background: var(--accent-glow);
    border-color: var(--accent);
    color: var(--accent);
}
.wizard-line {
    flex: 1;
    height: 2px;
    background: var(--border);
    margin-top: 18px;
    min-width: 24px;
    max-width: 70px;
    border-radius: 2px;
}

/* Steps */
.wizard-step {
    display: none;
    animation: wizardFadeIn 0.3s ease;
}
.wizard-step.active {
    display: block;
}
@keyframes wizardFadeIn {
    from { opacity: 0; transform: translateX(8px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Navigation */
.wizard-nav {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}
.wizard-nav .btn-primary {
    margin-top: 0;
    flex: 1;
    gap: 6px;
}
.btn-secondary {
    padding: 18px 24px;
    background: var(--input-bg);
    color: var(--text-primary);
    border: 2px solid var(--border);
    border-radius: 14px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s, border-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-shrink: 0;
}
.btn-secondary:hover {
    background: var(--card-bg-hover);
    border-color: var(--accent);
}
.btn-secondary:active {
    transform: scale(0.98);
}

/* Price summary (step 3) */
.price-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 18px;
    margin-top: 8px;
    margin-bottom: 4px;
    background: var(--accent-glow);
    border: 1px solid var(--accent);
    border-radius: 14px;
    color: var(--text-primary);
}
.price-summary .hint-icon {
    color: var(--accent);
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.price-summary .hint-text {
    font-size: 0.95rem;
    line-height: 1.4;
}

@media (max-width: 480px) {
    .wizard-dot-label { font-size: 0.72rem; }
    .wizard-dot-num { width: 34px; height: 34px; font-size: 0.9rem; }
    .wizard-line { margin-top: 16px; }
    .btn-secondary { padding: 16px 18px; font-size: 1rem; }
    .wizard-nav .btn-primary { font-size: 1rem; }
}

/* Custom select: pastda joy yetmasa yuqoriga ochilishi */
.custom-select.open-up .custom-options {
    top: auto;
    bottom: 100%;
    border-top: 2px solid var(--accent);
    border-bottom: 0;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -10px 20px rgba(0, 0, 0, 0.2);
}
.custom-select.open-up.open .custom-select-trigger {
    border-radius: 0 0 12px 12px;
}

/* AI darajasi variantlari (Claude uslubidagi sarlavha + tavsif) */
.ai-level-option {
    align-items: flex-start;
}
.ai-level-option input[type="radio"] {
    margin-top: 2px;
    flex-shrink: 0;
}
.ai-level-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.ai-level-title {
    font-weight: 600;
    color: var(--text-primary);
}
.ai-level-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.35;
}

/* ================================================================
   Radio options — Checkmark karta dizayni (native radio yashirin)
   ================================================================ */
.radio-option {
    position: relative;
    padding: 16px 48px 16px 16px;
}
.radio-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
    margin: 0;
}
/* O'ng tomondagi indikator: tanlanmaganda bo'sh doira */
.radio-option::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 16px;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    box-sizing: border-box;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    color: transparent;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
/* Tanlanganda: accent doira + oq checkmark */
.radio-option.active::after {
    content: '\2713';
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    transform: translateY(-50%) scale(1.05);
}
.radio-option:hover {
    border-color: var(--accent);
}
.radio-option:active {
    transform: scale(0.99);
}
/* AI darajasi: indikator yuqoriga tekislansin (ko'p qatorli matn uchun) */
.ai-level-option::after {
    top: 18px;
    transform: none;
}
.ai-level-option.active::after {
    transform: scale(1.05);
}

/* ================================================================
   Sozlamalar modali — bo'limlar
   ================================================================ */
.settings-section {
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 16px;
    text-align: left;
}
.settings-section .form-group:last-child {
    margin-bottom: 0;
}
.settings-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 14px;
}
.settings-section-title svg {
    color: var(--accent);
    flex-shrink: 0;
}
.settings-section-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.35;
    margin: -6px 0 14px;
}

/* EPIC J3 — Qo'lyozma Konspekt uslub tanlovi sub-paneli */
.hw-style-panel {
    margin-top: 14px;
    padding: 14px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    background: var(--input-bg);
}
.hw-style-panel-group { margin-bottom: 14px; }
.hw-style-panel-group:last-child { margin-bottom: 0; }
.hw-style-panel-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 8px;
}
.hw-font-cards { display: flex; gap: 10px; flex-wrap: wrap; }
.hw-font-card {
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 6px;
    cursor: pointer;
    background: transparent;
    text-align: center;
    width: 132px;
    transition: border-color 0.2s ease;
}
.hw-font-card img { width: 100%; height: auto; border-radius: 6px; display: block; }
.hw-font-card span { display: block; font-size: 0.72rem; color: var(--text-secondary); margin-top: 4px; }
.hw-font-card.active { border-color: var(--accent); }
.hw-pen-options { display: flex; gap: 12px; align-items: center; }
.hw-pen-dot {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    box-shadow: 0 0 0 1px var(--border);
}
.hw-pen-dot.active { border-color: var(--accent); }
.hw-paper-options { display: flex; gap: 10px; flex-wrap: wrap; }
.hw-paper-btn {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 14px;
    cursor: pointer;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
}
.hw-paper-btn.active { border-color: var(--accent); background: rgba(6, 182, 212, 0.1); }

/* ─── Pro shablon galereyasi: tanlangan karta + bottom-sheet (2026-08-05) ─── */

/* Forma ichidagi ixcham "tanlangan shablon" kartasi (Dizayn qadamida) */
.tpl-selected-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: var(--input-bg);
    border: 2px solid var(--border);
    border-radius: 16px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.tpl-selected-card:active {
    transform: scale(0.99);
}

.tpl-selected-thumb {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.15);
}

.tpl-selected-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
}

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

.tpl-selected-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tpl-selected-meta {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.tpl-change-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    font-family: inherit;
}

.tpl-change-btn:hover {
    background: var(--accent-glow);
}

/* TOP bejigi — tanlangan karta ustida ham, galereya kartalarida ham ishlatiladi */
.tpl-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: linear-gradient(135deg, #f59e0b, #f97316);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    padding: 3px 7px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
    z-index: 2;
}

/* Galereya kartasida tanlangan belgisi (✓) */
.tpl-card-check {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    z-index: 2;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.template-card.active .tpl-card-check {
    display: flex;
}

/* Pastdan chiqadigan to'liq galereya (bottom sheet). z-index #previewModal
   (2000) dan PASTROQ qasddan — galereya ichidagi lupa tugmasi bosilganda
   ochiladigan preview modal SHEET USTIDA ko'rinishi kerak. */
.tpl-sheet {
    position: fixed;
    inset: 0;
    z-index: 1500;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.tpl-sheet.show {
    opacity: 1;
    pointer-events: auto;
}

.tpl-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
}

.tpl-sheet-panel {
    position: relative;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    transform: translateY(30px);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    overflow: hidden;
}

.tpl-sheet.show .tpl-sheet-panel {
    transform: translateY(0);
}

.tpl-sheet-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.tpl-sheet-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.tpl-sheet-count {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
}

.tpl-sheet-close {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
}

.tpl-sheet-close:hover {
    color: var(--text-primary);
}

.tpl-chip-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 12px 20px;
    flex-shrink: 0;
    scrollbar-width: none;
}

.tpl-chip-row::-webkit-scrollbar {
    display: none;
}

.tpl-chip {
    flex-shrink: 0;
    padding: 7px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    font-family: inherit;
}

.tpl-chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--badge-text, #fff);
}

.tpl-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 4px 20px 20px;
    overflow-y: auto;
    flex: 1;
}

.tpl-grid .template-card {
    flex: none;
    width: auto;
    position: relative;
    /* MUHIM (CSS Grid tuzog'i): `.template-card`da `overflow:hidden` bor —
       CSS spetsifikatsiyasiga ko'ra, `overflow:visible` bo'lmagan grid
       elementining "avtomatik minimal o'lchami" (`min-height:auto`) 0'ga
       tushiriladi, ya'ni grid QATOR balandligini FARZAND elementlar (140px
       rasm + nom) hisobiga EMAS, balki 0'dan hisoblaydi — natijada butun
       karta ~19px'gacha siqilib, ichidagi 140px balandlikdagi rasm
       `overflow:hidden` tufayli shu tor chiziqqacha kesib tashlanadi (real
       qurilmada shablon kartalari "rangli chiziq" bo'lib ko'ringan xato
       aynan shu). Yechim: aniq (auto BO'LMAGAN) `min-height` — bu maxsus
       "0'ga tushirish" qoidasini bekor qiladi. */
    min-height: 190px;
}

.tpl-grid .template-preview {
    height: 140px;
}

/* Progressiv JPEG bosqichma-bosqich yuklanayotganda "yarim tayyor" ko'rinish
   o'rniga silliq paydo bo'lishi uchun — `onload` orqali `.loaded` qo'shiladi. */
.tpl-thumb-img {
    opacity: 0;
    transition: opacity 0.25s ease;
}

.tpl-thumb-img.loaded {
    opacity: 1;
}

.tpl-sheet-cta {
    padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.tpl-sheet-cta .btn-primary {
    width: 100%;
    margin: 0;
}

/* ─── Sahifalararo silliq o'tish (2026-08-08) ──────────────────────────────
   Bo'limlar alohida sahifalar (har bosishda to'liq qayta yuklanish), shuning
   uchun ilgari o'tish "qo'pol" — oq ekran, keyin sakrab paydo bo'lish — edi.
   Cross-document View Transitions buni brauzer darajasida silliq fade'ga
   aylantiradi. Qo'llab-quvvatlamaydigan klientlarda (eski WebView) qoida
   e'tiborsiz qoladi — hech narsa buzilmaydi, oddiy holat qoladi.
   Dock'ning o'zi o'tish davomida "qotib" turishi uchun alohida nom beriladi. */
@view-transition {
    navigation: auto;
}

.bottom-nav {
    view-transition-name: bottom-nav;
}

::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 180ms;
}

@media (prefers-reduced-motion: reduce) {
    ::view-transition-group(*),
    ::view-transition-old(*),
    ::view-transition-new(*) {
        animation: none !important;
    }
}

/* ─── Shablon paneli: "Sevimlilar" (2026-09-18) ───────────────────────────────
   Mantiq: static/js/template-favorites.js. Uslublar shu yerda (JS'da emas):
   ♡ tugmasi server chizgan markup'da bor — sahifa bilan birga yuklanmasa, bir
   lahza uslubsiz ko'rinardi. */

/* Nom qatori: matn chapda (uzun nomlar uchun joy ko'proq), ♡ o'ngda.
   Avval nom markazda edi — o'ng tomonga tugma qo'shilganda markaz
   nosimmetrik ko'rinib qolardi va matn uchun joy ikki tomondan qisqarardi. */
.tpl-grid .template-name {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 4px 8px 12px;
    text-align: left;
}

.template-name-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tpl-fav-btn {
    flex-shrink: 0;
    /* 36px — barmoq bilan adashmasdan bosish uchun minimal nishon */
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.tpl-fav-btn:hover {
    color: var(--text-secondary);
    background: var(--input-bg);
}

.tpl-fav-btn.is-fav {
    color: #f43f5e;
}

.tpl-fav-btn.is-fav svg {
    fill: currentColor;
}

.tpl-fav-btn.pop svg {
    animation: tpl-fav-pop 0.35s ease;
}

@keyframes tpl-fav-pop {
    0% { transform: scale(1); }
    40% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* Chip: yurak + matn + son */
.tpl-chip[data-cat="fav"] {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tpl-chip-heart {
    flex-shrink: 0;
}

.tpl-chip-count {
    min-width: 18px;
    padding: 1px 6px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.18);
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.4;
    text-align: center;
}

.tpl-chip-count.hidden {
    display: none;
}

/* "Tavsiya" sarlavhasi — to'liq qator, o'ngga cho'zilgan ingichka chiziq bilan */
.tpl-section-head {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 2px 0;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.tpl-section-head::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* Sevimlilar bo'sh bo'lganda — ♡ ni o'rgatuvchi izoh */
.tpl-fav-hint {
    grid-column: 1 / -1;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px dashed var(--border);
    background: var(--input-bg);
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.45;
    text-align: center;
}

@media (prefers-reduced-motion: reduce) {
    .tpl-fav-btn.pop svg { animation: none; }
}


/* ─── Shablon preview karuseli (2026-11-04): namuna taqdimotning 10 ta slaydi ─── */
.tpl-badge-new {
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

.tpl-gallery {
    position: relative;
    width: min(86vw, 880px);
    margin-bottom: 20px;
}

.tpl-gallery.hidden,
.modal-content img.hidden {
    display: none;
}

.tpl-gallery-track {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.tpl-gallery-track::-webkit-scrollbar {
    display: none;
}

.modal-content .tpl-gallery-track img {
    flex: 0 0 100%;
    width: 100%;
    max-height: none;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    scroll-snap-align: center;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    background: rgba(255, 255, 255, 0.06);
}

.tpl-gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    backdrop-filter: blur(4px);
}

.tpl-gallery-nav.prev { left: 10px; }
.tpl-gallery-nav.next { right: 10px; }

.tpl-gallery-counter {
    position: absolute;
    right: 12px;
    bottom: 10px;
    padding: 3px 9px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
}

@media (max-width: 600px) {
    .tpl-gallery { width: 84vw; }
    .tpl-gallery-nav { width: 34px; height: 34px; font-size: 22px; }
}

.tpl-gallery-note {
    margin: 8px 0 0;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Hisoblagich va tugmalar rasm ustida qolsin (izoh sahnadan tashqarida) */
.tpl-gallery-stage {
    position: relative;
}

/* "Yangi dizaynlarni sinab ko'ring!" — shablon kartasi ustidagi bir martalik yorliq (2026-11-05) */
.tpl-promo {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    padding: 8px 8px 8px 12px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--st-cta, #4f46e5) 0%, var(--st-purple, #7c3aed) 100%);
    color: #fff;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(79, 70, 229, 0.35);
    animation: tplPromoIn 0.35s ease-out both;
}
.tpl-promo[hidden] { display: none; }
.tpl-promo::after {
    content: "";
    position: absolute;
    left: 28px;
    bottom: -6px;
    width: 12px;
    height: 12px;
    background: var(--st-cta, #4f46e5);
    transform: rotate(45deg);
    border-radius: 2px;
}
.tpl-promo svg { flex: none; }
.tpl-promo-close {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
}
.tpl-promo-close:hover { background: rgba(255, 255, 255, 0.32); }
.tpl-promo:focus-visible, .tpl-promo-close:focus-visible { outline: 3px solid var(--st-accent, #818cf8); outline-offset: 2px; }
.tpl-selected-card--promo {
    border-color: var(--st-cta, #4f46e5);
    animation: tplPromoGlow 2.4s ease-in-out infinite;
}
@keyframes tplPromoIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes tplPromoGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0); }
    50% { box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.22); }
}
@media (prefers-reduced-motion: reduce) {
    .tpl-promo, .tpl-selected-card--promo { animation: none; }
}

/* Shablon tanlash — to'liq ekran (2026-11-05, egasi: "ko'proq shablon ko'rinsin").
   Avval pastdan 85vh / 480px panel edi. Endi butun ekran; ustunlar soni kenglikka qarab
   (telefonda 2, planshetda 3–4, kompyuterda 5–6). Telegram to'liq ekran rejimidagi xavfsiz
   hudud o'zgaruvchilari bo'lmasa — 0. */
.tpl-sheet { align-items: stretch; }
.tpl-sheet-panel {
    max-width: none;
    max-height: none;
    height: 100%;
    height: 100dvh;
    border: none;
    border-radius: 0;
    box-shadow: none;
}
.tpl-sheet-header {
    padding-top: calc(16px + var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
}
.tpl-sheet-header, .tpl-chip-row, .tpl-grid, .tpl-sheet-cta {
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}
/* Telefonda doim eski 2 ustun (1fr 1fr) — "kamida 160px" qoidasi 360px va tor ekranlarda (ko'p Android,
   kattalashtirilgan Telegram Desktop) 1 ustunga tushib qolardi. Ko'proq ustun faqat keng ekranda. */
.tpl-grid { align-content: start; }
@media (min-width: 640px) {
    .tpl-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
}
@media (min-width: 768px) {
    .tpl-sheet-cta .btn-primary { max-width: 420px; display: block; margin: 0 auto; }
}
