/* Сайт магазина: минимализм, светлая/тёмная тема (data-theme на <html>). */

:root {
    --bg: #ffffff;
    --fg: #111113;
    --muted: #6e6e76;
    --tile: #f3f3f4;
    --tile-hover: #ebebed;
    --line: #e7e7ea;
    --btn: #111113;
    --btn-fg: #ffffff;
    --ok: #1f8a4c;
    --ok-bg: #e7f6ee;
    --warn: #a55a0c;
    --warn-bg: #fff2e3;
    --danger: #c43c3c;
    --danger-bg: #fdecec;
    --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 16px rgba(0, 0, 0, .05);
    --r: 14px;
    --r-sm: 10px;
    --wrap: 1120px;
}

:root[data-theme="dark"] {
    --bg: #121214;
    --fg: #ececef;
    --muted: #8d8d96;
    --tile: #1d1d21;
    --tile-hover: #25252a;
    --line: #2a2a30;
    --btn: #ececef;
    --btn-fg: #121214;
    --ok: #4cc583;
    --ok-bg: #16281e;
    --warn: #f0a24a;
    --warn-bg: #2c2114;
    --danger: #f07171;
    --danger-bg: #2e1818;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
html { background: var(--bg); color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--fg);
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button, input { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; border-radius: 6px; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }
main.wrap { flex: 1; padding-top: 20px; padding-bottom: 48px; outline: none; }

/* --- Шапка ------------------------------------------------------------- */

.hdr {
    position: sticky; top: 0; z-index: 20;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: 1px solid var(--line);
}
.hdr-in {
    max-width: var(--wrap); margin: 0 auto; padding: 10px 20px;
    display: flex; align-items: center; gap: 20px;
}
.logo { font-weight: 800; font-size: 20px; letter-spacing: -.03em; text-decoration: none; }
.hdr-nav { display: flex; gap: 4px; }
.hdr-nav a {
    text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 8px;
    font-weight: 500;
}
.hdr-nav a:hover { color: var(--fg); }
.hdr-nav a.active { color: var(--fg); background: var(--tile); }
.hdr-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.pill {
    display: inline-flex; align-items: center; gap: 6px;
    height: 36px; padding: 0 14px; border-radius: 999px;
    border: 1px solid var(--line); background: transparent;
    font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer;
    white-space: nowrap;
}
.pill:hover { background: var(--tile); }
.pill-dark { background: var(--btn); color: var(--btn-fg); border-color: var(--btn); }
.pill-dark:hover { background: var(--btn); opacity: .88; }
.icon-pill { width: 36px; padding: 0; justify-content: center; }
#cart-count:not(:empty) {
    min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
    background: var(--btn-fg); color: var(--btn); font-size: 12px;
    display: inline-flex; align-items: center; justify-content: center;
}

/* --- Общие ------------------------------------------------------------------ */

h1 { font-size: 28px; line-height: 1.2; letter-spacing: -.025em; margin: 8px 0 6px; }
h2 { font-size: 18px; letter-spacing: -.01em; margin: 28px 0 12px; }
.lead { color: var(--muted); margin: 0 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.back {
    display: inline-flex; align-items: center; gap: 4px; color: var(--muted);
    text-decoration: none; font-size: 14px; margin-bottom: 4px; background: none; border: 0;
    padding: 0; cursor: pointer;
}
.back:hover { color: var(--fg); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 46px; padding: 0 20px; border-radius: 12px; border: 0;
    background: var(--btn); color: var(--btn-fg); font-weight: 650; cursor: pointer;
    text-decoration: none; transition: opacity .15s;
}
.btn:hover { opacity: .88; }
.btn:disabled { opacity: .4; cursor: default; }
.btn-block { width: 100%; }
.btn-ghost { background: var(--tile); color: var(--fg); }
.btn-sm { min-height: 36px; padding: 0 14px; border-radius: 10px; font-size: 14px; }

.input {
    width: 100%; height: 46px; padding: 0 14px; border-radius: 12px;
    border: 1px solid var(--line); background: var(--bg); outline: none;
}
.input:focus { border-color: var(--fg); }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field .note { color: var(--muted); font-size: 13px; margin-top: 6px; }

.card { background: var(--tile); border-radius: var(--r); padding: 18px; }
.notice {
    padding: 12px 14px; border-radius: 12px; font-size: 14px; margin: 12px 0;
    background: var(--tile);
}
.notice.err { background: var(--danger-bg); color: var(--danger); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.notice.warn { background: var(--warn-bg); color: var(--warn); }

.state { color: var(--muted); padding: 32px 0; text-align: center; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    height: 38px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line);
    background: transparent; cursor: pointer; font-weight: 600; font-size: 14px;
}
.chip:hover { background: var(--tile); }
.chip.active { background: var(--btn); color: var(--btn-fg); border-color: var(--btn); }
.chip:disabled { opacity: .35; cursor: default; }

.badge {
    display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 650;
    background: var(--tile); color: var(--muted);
}
.badge[data-tone="ok"] { background: var(--ok-bg); color: var(--ok); }
.badge[data-tone="warn"] { background: var(--warn-bg); color: var(--warn); }
.badge[data-tone="danger"] { background: var(--danger-bg); color: var(--danger); }

/* --- Главная ------------------------------------------------------------------ */

.hero {
    display: flex; align-items: center; justify-content: space-between; gap: 20px;
    background: var(--tile); border-radius: 18px; padding: 22px 24px; margin-bottom: 20px;
    text-decoration: none;
}
.hero:hover { background: var(--tile-hover); }
.hero-l { display: flex; align-items: center; gap: 16px; min-width: 0; }
.hero img { width: 52px; height: 52px; border-radius: 14px; flex: none; }
.hero b { font-size: 18px; letter-spacing: -.01em; display: block; }
.hero span { color: var(--muted); font-size: 14px; }

.search {
    position: relative; margin-bottom: 24px;
}
.search input { height: 52px; padding-left: 46px; font-size: 16px; border-radius: 14px; background: var(--tile); border-color: transparent; }
.search input:focus { border-color: var(--line); background: var(--bg); }
.search svg { position: absolute; left: 16px; top: 16px; color: var(--muted); }

.row-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 8px 0 12px; }
.row-head h2 { margin: 0; }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0; }
.link-btn:hover { color: var(--fg); }
.link-btn.active { color: var(--fg); font-weight: 600; }

.grid {
    display: grid; gap: 12px;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
}
.tile {
    position: relative; display: flex; flex-direction: column; gap: 10px;
    padding: 12px; border-radius: var(--r); background: var(--tile);
    text-decoration: none; cursor: pointer; border: 0; text-align: left;
    transition: background .15s;
}
.tile:hover { background: var(--tile-hover); }
.tile-img {
    aspect-ratio: 16 / 10; border-radius: 10px; overflow: hidden;
    background: var(--bg); display: flex; align-items: center; justify-content: center;
}
.tile-img img { width: 100%; height: 100%; object-fit: cover; }
.tile-img .fb { font-size: 28px; font-weight: 800; color: var(--muted); }
.tile-name { font-weight: 650; font-size: 14px; line-height: 1.3; }
.tile-meta { color: var(--muted); font-size: 12px; margin-top: -6px; }
.tile.off { opacity: .5; }
.tile-tags { position: absolute; top: 18px; left: 18px; display: flex; gap: 4px; }
.tag {
    padding: 2px 7px; border-radius: 6px; font-size: 11px; font-weight: 700;
    background: var(--btn); color: var(--btn-fg);
}
.tag.sale { background: #e5484d; color: #fff; }
.fav {
    position: absolute; top: 16px; right: 16px; width: 30px; height: 30px; border-radius: 50%;
    border: 0; background: color-mix(in srgb, var(--bg) 85%, transparent); cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 15px; color: var(--muted);
}
.fav.on { color: #e5484d; }

.feed {
    overflow: hidden; position: relative; margin: 0 -4px;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
            mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
}
.feed-track { display: flex; width: max-content; animation: feed-scroll var(--dur, 40s) linear infinite; }
.feed:hover .feed-track { animation-play-state: paused; }
.feed-half { display: flex; gap: 10px; padding: 2px 5px; }
.feed-item {
    flex: none; background: var(--tile); border-radius: 12px; padding: 10px 14px;
    font-size: 13px; max-width: 240px; border: 1px solid var(--line);
}
.feed-item b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-item .muted { white-space: nowrap; }
@keyframes feed-scroll { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) {
    .feed { overflow-x: auto; scrollbar-width: none; }
    .feed::-webkit-scrollbar { display: none; }
    .feed-track { animation: none; }
}

/* --- Номиналы -------------------------------------------------------------- */

.page-head { display: flex; gap: 18px; align-items: center; margin-bottom: 20px; }
.page-head img { width: 84px; height: 56px; border-radius: 10px; object-fit: cover; flex: none; }

.products { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.product {
    display: flex; flex-direction: column; gap: 10px;
    padding: 14px; border-radius: var(--r); background: var(--tile);
}
.product-title { font-weight: 650; }
.product-price { font-size: 20px; font-weight: 750; letter-spacing: -.02em; }
.price-old { color: var(--muted); text-decoration: line-through; font-size: 14px; font-weight: 500; margin-right: 8px; }
.product-actions { display: flex; gap: 8px; margin-top: auto; }
.product-actions .btn { flex: 1; min-height: 40px; font-size: 14px; padding: 0 10px; }

.recipient-box { max-width: 520px; margin-bottom: 20px; }

/* --- Формы Steam / Stars --------------------------------------------------- */

.two-col { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
.summary { position: sticky; top: 80px; }
.summary .sum-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; }
.summary .sum-total { font-size: 22px; font-weight: 750; letter-spacing: -.02em; }
.summary .btn { margin-top: 10px; }

.at-row { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.at-row span { padding: 0 4px 0 14px; color: var(--muted); }
.at-row input { border: 0; flex: 1; height: 44px; background: transparent; outline: none; padding: 0 8px; }
.at-row button { border: 0; background: var(--tile); height: 44px; padding: 0 14px; cursor: pointer; font-weight: 600; }

.guide img { border-radius: 12px; margin-top: 10px; border: 1px solid var(--line); }

/* --- Корзина -------------------------------------------------------------- */

.cart-list { display: flex; flex-direction: column; }
.cart-item {
    display: grid; grid-template-columns: 72px minmax(0, 1fr) auto auto 32px;
    gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line);
}
.cart-img {
    position: relative; width: 72px; height: 72px; border-radius: 12px; overflow: hidden;
    background: var(--tile); border: 0; padding: 0; cursor: pointer;
}
.cart-img img { width: 100%; height: 100%; object-fit: cover; }
.cart-img .fb { display: flex; align-items: center; justify-content: center; height: 100%; font-weight: 800; color: var(--muted); font-size: 22px; }
.cart-check {
    position: absolute; right: 5px; bottom: 5px; width: 22px; height: 22px; border-radius: 7px;
    background: var(--bg); border: 1.5px solid var(--muted);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
.cart-item.on .cart-check { background: var(--btn); border-color: var(--btn); color: var(--btn-fg); }
.cart-check svg { width: 14px; height: 14px; display: none; }
.cart-item.on .cart-check svg { display: block; }
.cart-item.off-sel .cart-info, .cart-item.off-sel .cart-price { color: var(--muted); }
.cart-item.na { opacity: .5; }
.cart-item.na .cart-img { cursor: not-allowed; }
.cart-info b { display: block; font-weight: 650; }
.cart-info .muted { font-size: 13px; }
.cart-price { font-weight: 700; text-align: right; white-space: nowrap; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; height: 34px; }
.qty button { width: 32px; height: 32px; border: 0; background: none; cursor: pointer; font-size: 17px; }
.qty span { min-width: 22px; text-align: center; font-weight: 600; }
.del { width: 32px; height: 32px; border-radius: 8px; border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 18px; }
.del:hover { background: var(--tile); color: var(--fg); }
.pay-methods { display: grid; gap: 8px; margin-top: 10px; }

/* --- Заказы ----------------------------------------------------------------- */

.orders { display: flex; flex-direction: column; gap: 8px; }
.order-row {
    display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--r);
    background: var(--tile); text-decoration: none;
}
.order-row:hover { background: var(--tile-hover); }
.order-main { flex: 1; min-width: 0; }
.order-main b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

.code-box {
    display: block; padding: 16px; border-radius: 12px; background: var(--bg); border: 1px dashed var(--line);
    font: 600 16px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all;
    margin: 10px 0; white-space: pre-wrap;
}
dl.kv { margin: 0; }
dl.kv div { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; text-align: right; font-weight: 600; word-break: break-word; }

/* --- Профиль ---------------------------------------------------------------- */

.acc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.balance-big { font-size: 34px; font-weight: 800; letter-spacing: -.03em; margin: 2px 0 14px; }
.list-item { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.list-item:last-child { border-bottom: 0; }
.inline-form { display: flex; gap: 8px; }
.inline-form .input { flex: 1; }

/* --- Вход / заглушка Mini App ---------------------------------------------- */

.center-card { max-width: 440px; margin: 40px auto; text-align: center; }
.center-card .btn { width: 100%; margin-top: 8px; }
.tg-icon { width: 56px; height: 56px; border-radius: 50%; background: #2aabee; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.spinner {
    width: 18px; height: 18px; border-radius: 50%;
    border: 2px solid currentColor; border-right-color: transparent;
    animation: spin .8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

body.miniapp .hdr, body.miniapp .ftr { display: none; }

/* --- Подвал, тост ------------------------------------------------------------ */

.ftr { border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.ftr-in { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-top: 18px; padding-bottom: 24px; }
.ftr-links { display: flex; gap: 16px; flex-wrap: wrap; }
.ftr a { text-decoration: none; }
.ftr a:hover { color: var(--fg); }

.toast {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
    background: var(--btn); color: var(--btn-fg); padding: 12px 18px; border-radius: 12px;
    font-weight: 600; font-size: 14px; box-shadow: var(--shadow); max-width: calc(100% - 32px);
}

/* --- Мобильные ----------------------------------------------------------- */

@media (max-width: 760px) {
    .hdr-in { gap: 10px; padding: 10px 14px; }
    .hdr-nav { display: none; }
    #balance-pill { padding: 0 10px; }
    .wrap { padding: 0 14px; }
    h1 { font-size: 24px; }
    .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .two-col { grid-template-columns: 1fr; }
    .summary { position: static; }
    .hero { padding: 16px; }
    .hero .btn { display: none; }
    .cart-item { grid-template-columns: 64px minmax(0, 1fr) auto; grid-template-areas: "img info del" "img qty price"; row-gap: 8px; }
    .del { justify-self: end; }
    .cart-img { grid-area: img; width: 64px; height: 64px; }
    .cart-info { grid-area: info; }
    .cart-item .qty { grid-area: qty; justify-self: start; }
    .cart-price { grid-area: price; }
    .del { grid-area: del; }
    .mnav { display: flex; }
    main.wrap { padding-bottom: 88px; }
}

.mnav {
    display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--bg); border-top: 1px solid var(--line);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
}
.mnav a { text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 500; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 12px; }
.mnav a.active { color: var(--fg); }
body.miniapp .mnav { display: none; }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation-duration: 0s !important; }
}

/* --- Диалог доплаты ------------------------------------------------------- */

.pay-dialog {
    width: min(440px, calc(100% - 28px)); border: 0; border-radius: 18px; padding: 22px;
    background: var(--bg); color: var(--fg); box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.pay-dialog::backdrop { background: rgba(0, 0, 0, .45); }
.pay-dialog .btn-ghost { margin-top: 8px; }

/* Страницы-«карточки» по центру (заказ). */
.narrow { max-width: 600px; margin: 0 auto; }

/* Аватарка Telegram в шапке. */
#profile-pill { overflow: hidden; padding: 0; }
#profile-pill .avatar { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
#profile-pill .avatar-fb { font-weight: 700; font-size: 14px; }
@media (max-width: 420px) {
    .logo { font-size: 17px; }
    #balance-pill { display: none !important; }
}
.narrow.wide { max-width: 760px; }
@media (max-width: 760px) {
    .mnav { display: flex; }
    body.miniapp .mnav { display: none; }
    .ftr-in { padding-bottom: 80px; }
    html, body { overflow-x: hidden; }
}

/* --- Профиль ---------------------------------------------------------------- */

.acc-head { display: flex; align-items: center; gap: 16px; margin: 4px 0 24px; }
.acc-ava {
    width: 64px; height: 64px; border-radius: 50%; flex: none; overflow: hidden;
    background: var(--tile); display: flex; align-items: center; justify-content: center;
    font-size: 26px; font-weight: 750; color: var(--muted);
}
.acc-ava img { width: 100%; height: 100%; object-fit: cover; }
.acc-name { min-width: 0; }
.acc-name h1 { margin: 0 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-actions { margin-left: auto; display: flex; gap: 8px; }
.acc-grid { align-items: start; }
.acc-lists { margin-top: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.card-label { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 10px; }

.copy-field {
    display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px;
    border: 1px solid var(--line); border-radius: 12px; background: var(--bg);
}
.copy-field span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }

.list-card { padding: 18px 18px 10px; }
.list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.list-head h2 { margin: 0; font-size: 17px; }
.lrow {
    display: flex; align-items: center; gap: 12px; padding: 11px 0;
    border-top: 1px solid var(--line);
}
.lrows .lrow:first-child { border-top: 0; }
.lrow-main { flex: 1; min-width: 0; }
.lrow-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrow-sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.lrow .badge { flex: none; white-space: nowrap; }
.mini-ava {
    width: 34px; height: 34px; border-radius: 50%; flex: none; background: var(--bg);
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
    color: var(--muted); border: 1px solid var(--line);
}
.more-btn {
    width: 100%; margin-top: 4px; padding: 10px 0 6px; border: 0; border-top: 1px solid var(--line);
    background: none; color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer;
}
.more-btn:hover { color: var(--fg); }
.chip-sm { height: 28px; padding: 0 12px; font-size: 12.5px; display: inline-flex; align-items: center; text-decoration: none; }

@media (max-width: 760px) {
    .acc-head { flex-wrap: wrap; }
    .acc-actions { margin-left: 0; width: 100%; }
    .acc-actions .btn { flex: 1; }
}
