* { box-sizing: border-box; margin: 0; padding: 0; font-family: system-ui, -apple-system, sans-serif; }
body {
    background: linear-gradient(rgba(226, 232, 240, 0.88), rgba(203, 213, 225, 0.94)), url('/static/bg.jpg') center/cover no-repeat fixed;
    background-color: #cbd5e1;
    color: #1e293b;
    min-height: 100vh;
    padding: 16px 16px 48px;
}
.container { max-width: 440px; margin: 0 auto; }
header { display: flex; align-items: center; justify-content: space-between; padding-bottom: 14px; border-bottom: 1px solid #94a3b8; margin-bottom: 20px; }
h1 {
    font-family: 'Montserrat', system-ui, -apple-system, sans-serif;
    font-size: 21px;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(90deg, #312e81, #0369a1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.subtitle { font-size: 11px; color: #475569; margin-top: 2px; }
.balance-badge, .balance-pill { display: flex; align-items: center; gap: 6px; padding: 6px 12px; background: #e2e8f0; border: 1px solid #94a3b8; color: #1e293b; border-radius: 99px; font-size: 12px; font-weight: 600; cursor: pointer; }
.balance-badge span, .balance-pill span { color: #0369a1; }
.trial-banner { background: #d1fae5; border: 1px solid #6ee7b7; color: #064e3b; padding: 10px 12px; border-radius: 12px; font-size: 12px; margin-bottom: 18px; }
.section { margin-bottom: 20px; }
.label { display: block; font-size: 13px; color: #334155; margin-bottom: 8px; font-weight: 600; }
.upload-box { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; height: 115px; border: 2px dashed #64748b; border-radius: 16px; cursor: pointer; background: rgba(241, 245, 249, 0.78); backdrop-filter: blur(8px); text-align: center; padding: 14px; color: #1e293b; transition: 0.2s; }
.upload-box:hover { border-color: #4f46e5; background: #f8fafc; }
#file-count { color: #475569 !important; }
.preview-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.preview-grid img { width: 100%; height: 60px; object-fit: cover; border-radius: 8px; border: 1px solid #94a3b8; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.option-btn { padding: 12px; border-radius: 12px; border: 1px solid #94a3b8; background: rgba(241, 245, 249, 0.78); backdrop-filter: blur(8px); color: #1e293b; text-align: left; cursor: pointer; transition: 0.2s; }
.option-btn.active { border-color: #4f46e5; background: #e0e7ff; box-shadow: 0 2px 6px rgba(79, 70, 229, 0.15); }
.option-title { font-size: 13px; font-weight: 600; color: #1e293b; }
.option-desc { font-size: 11px; color: #475569; margin-top: 4px; }
.btn-primary { width: 100%; padding: 15px; border: none; border-radius: 16px; background: linear-gradient(90deg, #4338ca, #0369a1); color: #f8fafc; font-size: 15px; font-weight: 600; cursor: pointer; box-shadow: 0 4px 12px rgba(67, 56, 202, 0.25); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.progress-box, .result-box, .card { margin-top: 18px; padding: 16px; border-radius: 16px; background: #f1f5f9; border: 1px solid #94a3b8; }
.hidden { display: none !important; }
.progress-track { width: 100%; height: 10px; background: #cbd5e1; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; background: #4338ca; transition: width 0.3s; width: 5%; }
video { width: 100%; border-radius: 12px; background: #0f172a; margin-bottom: 12px; max-height: 360px; }
.btn-download { display: block; width: 100%; padding: 12px; border-radius: 12px; background: #047857; color: #fff; text-align: center; text-decoration: none; font-size: 14px; font-weight: 600; }
.modal-overlay, .modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.65); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal-card, .modal-sheet { background: #e2e8f0; border: 1px solid #94a3b8; color: #1e293b; width: 100%; max-width: 440px; border-radius: 20px; padding: 20px; box-shadow: 0 20px 40px rgba(15, 23, 42, 0.25); }
.plan-card { display: flex; justify-content: space-between; align-items: center; padding: 14px; border: 1px solid #94a3b8; border-radius: 14px; background: #f1f5f9; margin-bottom: 10px; cursor: pointer; transition: 0.2s; }
.plan-card:hover { border-color: #4338ca; background: #e0e7ff; }
.plan-price { font-size: 16px; font-weight: 700; color: #3730a3; white-space: nowrap; margin-left: 12px; }
.history-card {
    margin-top: 20px;
    padding: 14px;
    border-radius: 16px;
    background: rgba(241, 245, 249, 0.85);
    border: 1px solid #94a3b8;
}
.history-title {
    font-size: 13px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 10px;
}
.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    margin-bottom: 8px;
    font-size: 12px;
}
.history-item:last-child { margin-bottom: 0; }
.history-meta { color: #64748b; font-size: 11px; margin-top: 2px; }
.history-dl {
    padding: 6px 10px;
    border-radius: 8px;
    background: #047857;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 11px;
    white-space: nowrap;
}
.seo-card {
    margin-top: 24px;
    padding: 16px;
    border-radius: 16px;
    background: rgba(241, 245, 249, 0.7);
    border: 1px solid #cbd5e1;
    color: #334155;
}
.seo-title {
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 8px 0;
}
.seo-text {
    font-size: 12px;
    line-height: 1.5;
    color: #475569;
    margin: 0 0 12px 0;
}
.faq-item {
    border-top: 1px solid #cbd5e1;
    padding: 8px 0;
    font-size: 12px;
}
.faq-item:last-child {
    padding-bottom: 0;
}
.faq-item summary {
    font-weight: 600;
    color: #1e293b;
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.faq-item summary::after {
    content: "+";
    font-weight: 700;
    color: #64748b;
    margin-left: 8px;
}
.faq-item[open] summary::after {
    content: "−";
}
.faq-item p {
    margin: 6px 0 2px 0;
    line-height: 1.5;
    color: #475569;
}

#preview-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 10px !important; }


/* Cross-browser Grid, Upload Zone & Touch Hardening */
html, body {
    overscroll-behavior-y: contain;
    -webkit-text-size-adjust: 100%;
}

.upload-zone-modern {
    position: relative !important;
    overflow: hidden !important;
    isolation: isolate !important;
    background: #f1f5f9 !important;
    transition: height 0.32s cubic-bezier(0.22, 1, 0.36, 1),
                min-height 0.32s cubic-bezier(0.22, 1, 0.36, 1),
                padding 0.32s cubic-bezier(0.22, 1, 0.36, 1),
                border-color 0.25s ease !important;
}

.upload-zone-modern::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 220%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    background: var(--zone-fill, linear-gradient(115deg, #e0e7ff 0%, #c7d2fe 48%, transparent 52%));
    opacity: var(--zone-opacity, 0);
    transform: translate3d(var(--zone-shift, -52%), 0, 0);
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.25s ease;
    will-change: transform, opacity;
}

.upload-zone-modern > * {
    position: relative;
    z-index: 1;
}

#preview-grid {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 10px !important;
}

#preview-grid [data-card="1"] {
    position: relative !important;
    width: 100% !important;
    aspect-ratio: 1 / 1;
    min-width: 0;
    min-height: 0;
    background: #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
}

@supports not (aspect-ratio: 1 / 1) {
    #preview-grid [data-card="1"]::before {
        content: "";
        display: block;
        padding-top: 100%;
    }
}

#preview-grid [data-card="1"] img {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    -webkit-user-drag: none;
    pointer-events: none;
}


/* === FULL CROSS-BROWSER NORMALIZATION (Chrome, Firefox, Safari/iOS, Yandex, Telegram WebView) === */
*, *::before, *::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

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

body {
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

button, input, select, textarea {
    font-family: inherit;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

button {
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

/* Предотвращаем автозум экрана в iOS Safari при фокусе на полях ввода */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* Защита от распирания flex и grid контейнеров в Firefox и Safari */
.container {
    width: 100%;
    max-width: 680px;
    margin-left: auto;
    margin-right: auto;
}
.card, .section, .modal-content, .format-grid, .music-grid, .plans-grid {
    min-width: 0;
}

/* Поддержка размытия фона модальных окон в Safari */
.modal, [id$="-modal"] {
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

/* Плавный скролл внутри модальных окон на iOS */
.modal-content, #legal-body {
    -webkit-overflow-scrolling: touch;
}

/* Корректное отображение видеоплеера во всех браузерах */
video {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    background: #0f172a;
}
