/* Студия эмодзи — Mini App.
 *
 * Идея оформления: лист стикеров на коврике для резки. Шаблоны — это
 * вырубленные стикеры с белым кантом, лежат на точечной сетке коврика.
 * Единственный акцент — золото звезды: это и валюта, и отметка выбора.
 */

:root {
    --mat: #E6E9EE;
    --mat-dot: rgba(26, 30, 38, 0.10);
    --surface: #FFFFFF;
    --surface-2: #F3F5F8;
    --ink: #1A1E26;
    --muted: #6F7786;
    --line: rgba(26, 30, 38, 0.10);
    --rim: #FFFFFF;
    --gold: #F2B705;
    --gold-deep: #C98F00;
    --gold-ink: #3A2A00;
    --danger: #D64545;
    --shadow-sticker: 0 1px 0 rgba(26, 30, 38, 0.06), 0 6px 14px -8px rgba(26, 30, 38, 0.35);
    --font: "Rubik", system-ui, -apple-system, "Segoe UI", sans-serif;
    color-scheme: light;
}

:root[data-theme="dark"] {
    --mat: #1C2028;
    --mat-dot: rgba(236, 239, 244, 0.07);
    --surface: #262B35;
    --surface-2: #2F3540;
    --ink: #ECEFF4;
    --muted: #98A1B2;
    --line: rgba(236, 239, 244, 0.10);
    --rim: #3A414E;
    --gold: #F5C02E;
    --gold-deep: #E0A800;
    --shadow-sticker: 0 1px 0 rgba(0, 0, 0, 0.3), 0 8px 18px -10px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--mat);
    color: var(--ink);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.4;
    -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 2px; }

.app {
    max-width: 640px;
    margin: 0 auto;
    padding: 12px 16px calc(150px + env(safe-area-inset-bottom));
}

/* ---- Шапка ------------------------------------------------------------- */

.top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0 14px;
}

.top__title {
    margin: 0;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.star { width: 18px; height: 18px; fill: var(--gold); flex: none; }
.star--big { width: 30px; height: 30px; }

.stars {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px 7px 10px;
    border: 0;
    border-radius: 999px;
    background: var(--surface);
    box-shadow: var(--shadow-sticker);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ---- Надпись и оформление --------------------------------------------- */

.composer {
    background: var(--surface);
    border-radius: 22px;
    padding: 14px;
    box-shadow: var(--shadow-sticker);
}

.composer__field { display: block; }

.composer__label {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin: 0 2px 6px;
}

.composer__field input {
    width: 100%;
    border: 0;
    border-radius: 14px;
    background: var(--surface-2);
    padding: 12px 14px;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.01em;
    outline: none;
}

.composer__field input:focus { box-shadow: inset 0 0 0 2px var(--gold); }
.composer__field input::placeholder { color: var(--muted); font-weight: 500; }

.seg {
    display: flex;
    gap: 4px;
    margin-top: 12px;
    padding: 4px;
    border-radius: 14px;
    background: var(--surface-2);
}

.seg__item {
    flex: 1;
    border: 0;
    background: transparent;
    border-radius: 10px;
    padding: 8px 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    white-space: nowrap;
}

.seg__item--on {
    background: var(--surface);
    color: var(--ink);
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.seg--small { margin: 0; flex: 1; max-width: 280px; }
.seg--small .seg__item { padding: 7px 8px; font-size: 13px; }

.panel { padding-top: 12px; }

.chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    margin: 0 -14px;
    padding: 0 14px 2px;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
    flex: none;
    border: 1.5px solid var(--line);
    background: var(--surface);
    border-radius: 12px;
    padding: 9px 14px;
    font-size: 15px;
    white-space: nowrap;
}

.chip--on { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 16%, var(--surface)); font-weight: 700; }

.row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.row__label { width: 74px; flex: none; font-size: 13px; color: var(--muted); }

.swatches {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 3px;
    margin: -3px;
}
.swatches::-webkit-scrollbar { display: none; }

.sw {
    flex: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid var(--surface);
    box-shadow: 0 0 0 1px var(--line);
    padding: 0;
    background: var(--c);
}

.sw--none {
    background:
        linear-gradient(135deg, transparent 45%, var(--danger) 45%, var(--danger) 55%, transparent 55%),
        var(--surface-2);
}

.sw--on { box-shadow: 0 0 0 2.5px var(--gold); }

.slider { display: flex; align-items: center; gap: 12px; margin: 4px 0 10px; font-size: 13px; color: var(--muted); }
.slider span { width: 116px; flex: none; }
.slider input { flex: 1; accent-color: var(--gold-deep); }
.slider--off { opacity: 0.4; pointer-events: none; }

.link {
    border: 0;
    background: none;
    padding: 4px 0;
    color: var(--gold-deep);
    font-weight: 500;
}

/* ---- Лист шаблонов ---------------------------------------------------- */

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 18px 0 10px;
}

.ghost {
    border: 0;
    border-radius: 12px;
    padding: 9px 14px;
    background: var(--surface);
    font-weight: 700;
    font-size: 14px;
    box-shadow: var(--shadow-sticker);
}

/* Коврик для резки: точечная сетка, на ней лежат стикеры */
.mat {
    margin: 0 -16px;
    padding: 10px 16px 20px;
    background-image: radial-gradient(var(--mat-dot) 1.2px, transparent 1.4px);
    background-size: 18px 18px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px 12px;
}

@media (min-width: 520px) { .grid { grid-template-columns: repeat(4, 1fr); } }

/* Карточка — вырубленный стикер: толстый белый кант и мягкая тень */
.card {
    position: relative;
    aspect-ratio: 1;
    border: 0;
    padding: 6px;
    border-radius: 24px;
    background: var(--rim);
    box-shadow: var(--shadow-sticker);
    transition: transform 0.16s ease;
}

.card__art {
    position: absolute;
    inset: 6px;
    border-radius: 18px;
    background: var(--surface-2);
    overflow: hidden;
}

.card__art img,
.card__art .lottie {
    position: absolute;
    inset: 4%;
    width: 92%;
    height: 92%;
}

.card__art img { object-fit: contain; opacity: 0.85; }
.card__art--live img { visibility: hidden; }

.card__no {
    position: absolute;
    left: 10px;
    bottom: 9px;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

/* Отметка — золотая звезда, приклеенная к углу стикера */
.card__mark {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 30px;
    height: 30px;
    fill: var(--gold);
    stroke: var(--rim);
    stroke-width: 2.4px;
    paint-order: stroke;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25));
    transform: scale(0) rotate(-40deg);
    transition: transform 0.22s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.card--on { transform: rotate(-2deg); box-shadow: 0 0 0 3px var(--gold), var(--shadow-sticker); }
.card--on:nth-child(2n) { transform: rotate(2deg); }
.card--on .card__mark { transform: scale(1) rotate(0); }
.card:active { transform: scale(0.95); }

.empty {
    margin: 24px auto;
    max-width: 300px;
    text-align: center;
    color: var(--muted);
}

/* ---- Планка заказа ----------------------------------------------------- */

.cart {
    position: fixed;
    left: 50%;
    bottom: calc(76px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    width: min(608px, calc(100% - 24px));
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 10px 10px 18px;
    border-radius: 20px;
    background: var(--gold);
    color: var(--gold-ink);
    box-shadow: 0 10px 28px -10px rgba(150, 100, 0, 0.7);
    z-index: 20;
    animation: cartIn 0.25s ease-out;
}

@keyframes cartIn { from { transform: translate(-50%, 24px); opacity: 0; } }

.cart__info { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.cart__info b { font-size: 16px; font-weight: 800; }
.cart__info span { font-size: 13px; font-weight: 500; }

.cart__btn {
    border: 0;
    border-radius: 14px;
    padding: 12px 20px;
    background: var(--gold-ink);
    color: #FFF6D8;
    font-weight: 700;
}

/* ---- Нижняя панель ----------------------------------------------------- */

.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--line);
    z-index: 15;
}

.tab {
    flex: 1;
    max-width: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    border: 0;
    background: none;
    padding: 4px 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}

.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.tab--on { color: var(--ink); font-weight: 700; }
.tab--on svg { stroke: var(--gold-deep); }

/* ---- Профиль ---------------------------------------------------------- */

/* Кошелёк — как у Crypto Bot: кто вы, крупный баланс, круглые действия */
.wallet {
    position: relative;
    background: var(--surface);
    border-radius: 26px;
    padding: 18px 16px 16px;
    box-shadow: var(--shadow-sticker);
    overflow: hidden;
}

/* Тихий узор коврика под кошельком — та же сетка, что под стикерами */
.wallet::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(var(--mat-dot) 1.2px, transparent 1.4px);
    background-size: 18px 18px;
    opacity: 0.7;
    pointer-events: none;
}

.wallet > * { position: relative; }

.who { display: flex; align-items: center; gap: 14px; }

/* Аватар в золотом кольце-канте, как вырубленный стикер */
.who__ava {
    flex: none;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--surface-2) center / cover no-repeat;
    box-shadow: 0 0 0 3px var(--rim), 0 0 0 5.5px var(--gold);
    font-size: 24px;
    font-weight: 800;
    color: var(--muted);
}

.who__body { min-width: 0; display: flex; flex-direction: column; }
.who__hi { font-size: 13px; color: var(--muted); }
.who__name { font-size: 21px; font-weight: 800; letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who__meta { display: flex; align-items: center; gap: 8px; margin-top: 2px; font-size: 13px; color: var(--muted); }

.idchip {
    border: 0;
    border-radius: 8px;
    padding: 2px 7px;
    background: var(--surface-2);
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.wallet__sum { display: flex; align-items: center; gap: 8px; margin-top: 18px; }
.wallet__sum b { font-size: 46px; line-height: 1; font-weight: 800; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.wallet__label { display: block; margin-top: 6px; color: var(--muted); font-size: 13px; max-width: 32ch; }

.acts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 18px; }

.act {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    border: 0;
    background: none;
    padding: 0;
    font-size: 12px;
    font-weight: 500;
}

.act__ic {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--surface-2);
}

.act__ic svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

#actTopup .act__ic { background: var(--gold); }
#actTopup .act__ic svg { stroke: var(--gold-ink); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }

.stat {
    background: var(--surface);
    border-radius: 18px;
    padding: 12px;
    display: flex;
    flex-direction: column;
}

.stat b { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); line-height: 1.25; }

/* Поддержка: живой стикер и «печатает…» */
.supcard {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin-top: 12px;
    padding: 12px 14px;
    border: 0;
    border-radius: 22px;
    background: var(--surface);
    text-align: left;
}

.supcard__sticker { flex: none; width: 56px; height: 56px; border-radius: 16px; background: var(--surface-2); overflow: hidden; }
.supcard__body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.supcard__body b { font-size: 17px; font-weight: 800; }
.supcard__hint, .supcard__who { font-size: 12px; color: var(--muted); }

.supcard__bubble { display: flex; gap: 3px; padding: 9px 11px; border-radius: 14px 14px 14px 4px; background: var(--surface-2); }
.supcard__bubble i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: typing 1.2s infinite ease-in-out; }
.supcard__bubble i:nth-child(2) { animation-delay: 0.15s; }
.supcard__bubble i:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-3px); opacity: 1; } }

/* Пополнение */
.own { display: flex; flex-direction: column; gap: 6px; margin: 14px 0 12px; font-size: 13px; color: var(--muted); }
.own input {
    border: 0;
    border-radius: 14px;
    background: var(--surface-2);
    padding: 12px 14px;
    font-size: 17px;
    font-weight: 700;
    color: var(--ink);
    outline: none;
}
.own input:focus { box-shadow: inset 0 0 0 2px var(--gold); }
.chips--big .chip--on { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 16%, var(--surface)); }

/* Студия закрыта */
.closed {
    background: var(--surface);
    border-radius: 22px;
    padding: 22px 18px;
    text-align: center;
    box-shadow: var(--shadow-sticker);
}
.closed b { font-size: 19px; font-weight: 800; }
.closed p { color: var(--muted); margin: 8px auto 6px; max-width: 30ch; }

.h2 { margin: 26px 2px 10px; font-size: 18px; font-weight: 800; letter-spacing: -0.01em; }

.list { display: flex; flex-direction: column; gap: 8px; }

.item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 0;
    border-radius: 16px;
    background: var(--surface);
    text-align: left;
    width: 100%;
}

.item__body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.item__body b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item__body span { color: var(--muted); font-size: 13px; }
.item__side { font-size: 13px; font-weight: 700; color: var(--gold-deep); white-space: nowrap; }

.badge {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--surface-2);
    font-weight: 800;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.list .empty { margin: 8px 0; text-align: left; }

/* ---- Нижние листы ------------------------------------------------------ */

.scrim {
    position: fixed;
    inset: 0;
    background: rgba(10, 12, 18, 0.45);
    z-index: 30;
    animation: fade 0.2s ease-out;
}

@keyframes fade { from { opacity: 0; } }

.sheet {
    position: fixed;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: min(640px, 100%);
    max-height: 88vh;
    overflow-y: auto;
    padding: 10px 16px calc(18px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-radius: 24px 24px 0 0;
    z-index: 31;
    animation: sheetIn 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes sheetIn { from { transform: translate(-50%, 100%); } }

.sheet__grip { display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 12px; }
.sheet__title { margin: 0 0 12px; font-size: 21px; font-weight: 800; letter-spacing: -0.02em; }

.strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    margin: 0 -16px 16px;
    padding: 4px 16px;
}
.strip::-webkit-scrollbar { display: none; }

.strip__item {
    flex: none;
    width: 68px;
    height: 68px;
    border-radius: 16px;
    background: var(--surface-2);
    position: relative;
}
.strip__item .lottie, .strip__item img { position: absolute; inset: 6%; width: 88%; height: 88%; object-fit: contain; }

.field-label { display: block; font-size: 13px; color: var(--muted); margin: 0 2px 6px; }

.kinds, .targets { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }

.option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    text-align: left;
}

.option__body { flex: 1; display: flex; flex-direction: column; }
.option__body b { font-weight: 700; }
.option__body span { font-size: 13px; color: var(--muted); }
.option__dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); flex: none; }
.option--on { border-color: var(--gold); }
.option--on .option__dot { border: 6px solid var(--gold); }

.sum { margin: 0 0 12px; padding: 12px 14px; border-radius: 16px; background: var(--surface-2); }
.sum div { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.sum dt { color: var(--muted); }
.sum dd { margin: 0; font-weight: 500; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sum__total { margin-top: 6px; padding-top: 9px !important; border-top: 1px solid var(--line); }
.sum__total dt { color: var(--ink); font-weight: 700; }
.sum__total dd { font-weight: 800; font-size: 17px; display: inline-flex; align-items: center; gap: 4px; }

.note { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.error { margin: 0 0 12px; color: var(--danger); font-size: 14px; font-weight: 500; }

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    border: 0;
    border-radius: 16px;
    padding: 15px;
    font-weight: 700;
    font-size: 16px;
    margin-top: 8px;
}

.btn--gold { background: var(--gold); color: var(--gold-ink); }
.btn--plain { background: var(--surface-2); }
.btn:disabled { opacity: 0.45; }
.btn .star { fill: var(--gold-ink); }

/* Шаги выдачи — это и правда последовательность */
.steps { list-style: none; margin: 4px 0 14px; padding: 0; counter-reset: s; }
.steps li {
    counter-increment: s;
    position: relative;
    padding: 9px 0 9px 42px;
    color: var(--muted);
}
.steps li::before {
    content: counter(s);
    position: absolute;
    left: 0;
    top: 5px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--surface-2);
    font-weight: 700;
    font-size: 14px;
}
.steps li.is-now { color: var(--ink); font-weight: 700; }
.steps li.is-now::before { background: var(--gold); color: var(--gold-ink); animation: pulse 1.4s ease-in-out infinite; }
.steps li.is-done { color: var(--ink); }
.steps li.is-done::before { content: "✓"; background: var(--gold); color: var(--gold-ink); }

@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--gold) 30%, transparent); } }

.chips--big { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
.chips--big .chip { min-width: 64px; text-align: center; font-weight: 700; font-size: 17px; padding: 12px 16px; }

.toast {
    position: fixed;
    left: 50%;
    top: 14px;
    transform: translateX(-50%);
    max-width: calc(100% - 32px);
    padding: 10px 16px;
    border-radius: 14px;
    background: var(--ink);
    color: var(--mat);
    font-weight: 500;
    z-index: 50;
    animation: fade 0.2s ease-out;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

#topupNote { margin-top: 10px; }
