/* Пиня Mini App. Синий главный цвет, светлая и тёмная тема (html[data-theme]). */
:root {
  --bg: #F2F5FA; --card: #FFFFFF; --card-2: #F6F8FC; --ink: #121A27; --muted: #66728A; --line: #E1E7F0;
  --pri: #1F5FE0; --pri-ink: #FFFFFF; --pri-soft: #E3ECFD; --pri-text: #1B52C4;
  --sun: #F5B53F; --sun-soft: #FDF1D6; --ok: #1E9E6A; --ok-soft: #DDF3E9; --bad: #D2453A; --bad-soft: #FBE3E0;
  --shadow: 0 10px 30px -18px rgba(20, 40, 80, .35);
  --f-display: "Unbounded", "Golos Text", system-ui, sans-serif;
  --f-body: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 18px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0E131D; --card: #171F2D; --card-2: #1C2535; --ink: #E8EDF6; --muted: #95A1B6; --line: #263042;
  --pri: #5B93FF; --pri-ink: #0B1220; --pri-soft: #1A2742; --pri-text: #8DB5FF;
  --sun: #F5B53F; --sun-soft: #33291A; --ok: #45C68E; --ok-soft: #15302A; --bad: #F07A6E; --bad-soft: #3A201D;
  --shadow: 0 12px 30px -18px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.45 var(--f-body); min-height: 100vh; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--pri); outline-offset: 2px; }
h1, h2, h3 { margin: 0; font-family: var(--f-display); line-height: 1.15; text-wrap: balance; }
p { margin: 0; }

.app {
  max-width: 560px; margin: 0 auto;
  padding: calc(14px + var(--tg-content-safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right)) calc(110px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.view { display: flex; flex-direction: column; gap: 14px; animation: in .22s ease both; }
@keyframes in { from { opacity: .4; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* шапка */
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 32px; }
.brand { display: flex; align-items: center; gap: 8px; font: 700 17px var(--f-display); }
.brand svg { width: 30px; height: 30px; padding: 2px; border-radius: 50%; background: var(--pri-soft); }
.chip { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--pri-soft); color: var(--pri-text); white-space: nowrap; }
.chip.free { background: var(--card); color: var(--muted); border: 1px solid var(--line); }
.chip.plus { background: var(--sun-soft); color: #9A6410; }
:root[data-theme="dark"] .chip.plus { color: var(--sun); }
.page-title { font-size: 24px; font-weight: 700; }
.page-sub { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* карточки */
.card { background: var(--card); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); }
.card-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.card-h h3 { font-size: 15px; }
.link { background: none; border: 0; padding: 0; color: var(--pri-text); font-weight: 600; font-size: 13px; }

.hello { display: flex; align-items: center; gap: 12px; background: linear-gradient(135deg, var(--pri-soft), var(--card) 70%); }
.hello h1 { font-size: 22px; }
.hello p { color: var(--muted); font-size: 14px; margin-top: 6px; }
.hello .mascot { width: 84px; height: 84px; flex: none; border: 0; background: none; padding: 0; }
.hello .mascot svg { width: 100%; height: 100%; transition: transform .25s; }
.hello .mascot.pet svg { animation: pet .6s ease; }
@keyframes pet { 0%,100% { transform: rotate(0) } 25% { transform: rotate(-8deg) scale(1.05) } 60% { transform: rotate(6deg) } }
.blink { transform-origin: center; transform-box: fill-box; animation: blink 4.8s infinite; }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.12); } }

.row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.row:first-of-type { border-top: 0; padding-top: 2px; }
.ic { width: 38px; height: 38px; flex: none; border-radius: 12px; display: grid; place-items: center; font-size: 19px; background: var(--pri-soft); }
.ic.sun { background: var(--sun-soft); }
.row .tx { flex: 1; min-width: 0; }
.row .tx b { display: block; font-weight: 600; overflow-wrap: anywhere; }
.row .tx small { color: var(--muted); font-size: 12.5px; }
.time { font: 700 15px var(--f-display); font-variant-numeric: tabular-nums; min-width: 52px; }
.empty { color: var(--muted); font-size: 14px; display: flex; gap: 10px; align-items: center; }
.empty svg { width: 44px; height: 44px; flex: none; }

.quick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.quick button { background: var(--card); border: 0; border-radius: 16px; padding: 12px 4px 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; box-shadow: var(--shadow); }
.quick span { font-size: 22px; }

.meter { display: flex; flex-direction: column; gap: 8px; }
.meter-top { display: flex; justify-content: space-between; font-size: 14px; }
.meter-top b { font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: 8px; background: var(--card-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 8px; background: var(--pri); transition: width .4s; }
.bar.warn i { background: var(--sun); }
.meter small { color: var(--muted); font-size: 12.5px; }

.btn { border: 0; border-radius: 14px; padding: 13px 16px; font-weight: 700; font-size: 15px; background: var(--pri); color: var(--pri-ink); width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn.ghost { background: var(--card-2); color: var(--ink); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn[disabled] { opacity: .6; }
.ask { display: flex; align-items: center; gap: 12px; }
.ask .tx { flex: 1; }
.ask .tx b { display: block; }
.ask .tx small { color: var(--muted); font-size: 13px; }
.ask .btn { width: auto; padding: 11px 16px; }

/* каталог */
.search { display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 14px; padding: 0 14px; box-shadow: var(--shadow); }
.search svg { width: 18px; height: 18px; stroke: var(--muted); fill: none; stroke-width: 2; flex: none; }
.search input { flex: 1; border: 0; background: none; color: var(--ink); font: inherit; padding: 13px 0; outline: none; min-width: 0; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 13px; font-size: 13.5px; font-weight: 600; }
.chips button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { position: relative; overflow: hidden; border: 0; border-radius: var(--r); padding: 14px; min-height: 118px; text-align: left; display: flex; flex-direction: column; justify-content: space-between; color: #142033; }
.tile b { font: 700 14.5px var(--f-display); line-height: 1.2; max-width: 80%; }
.tile small { font-size: 12px; opacity: .75; max-width: 70%; }
.tile .em { position: absolute; right: 10px; bottom: 6px; font-size: 40px; filter: drop-shadow(0 4px 6px rgba(0,0,0,.15)); }
.c-blue { background: #D8E5FD; } .c-sun { background: #FBE6B5; } .c-mint { background: #D3F0E4; } .c-rose { background: #FADCE0; } .c-lilac { background: #E5DEFA; } .c-sand { background: #F1E5D5; }
:root[data-theme="dark"] .c-blue { background: #23365C; } :root[data-theme="dark"] .c-sun { background: #4A3A18; }
:root[data-theme="dark"] .c-mint { background: #183D33; } :root[data-theme="dark"] .c-rose { background: #4A2630; }
:root[data-theme="dark"] .c-lilac { background: #33294F; } :root[data-theme="dark"] .c-sand { background: #3F3224; }
:root[data-theme="dark"] .tile { color: var(--ink); }
.group h3 { font-size: 15px; display: flex; align-items: center; gap: 8px; margin: 6px 2px 8px; }
.list { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 2px 14px; }
.item { width: 100%; background: none; border: 0; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 12px 0; text-align: left; }
.item:first-child { border-top: 0; }
.item .tx { flex: 1; min-width: 0; }
.item .tx b { display: block; font-weight: 600; }
.item .tx small { color: var(--muted); font-size: 12.5px; }
.chev { color: var(--muted); font-size: 18px; }

/* дела */
.seg { display: flex; background: var(--card); border-radius: 14px; padding: 4px; gap: 4px; box-shadow: var(--shadow); }
.seg button { flex: 1; border: 0; background: none; border-radius: 10px; padding: 9px 4px; font-weight: 600; font-size: 13.5px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--pri); color: var(--pri-ink); }
.x { border: 0; background: var(--card-2); color: var(--muted); border-radius: 10px; padding: 7px 10px; font-size: 13px; font-weight: 600; flex: none; }
.x.armed { background: var(--bad-soft); color: var(--bad); }
.soon { text-align: center; padding: 26px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.soon svg { width: 72px; height: 72px; }
.soon p { color: var(--muted); font-size: 14px; max-width: 32ch; }

/* я */
.plan-card { display: flex; flex-direction: column; gap: 12px; }
.plan-card .price { font: 700 26px var(--f-display); }
.plan-card .price small { font: 500 14px var(--f-body); color: var(--muted); }
.plan-card ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; display: flex; flex-direction: column; gap: 3px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.kv:first-of-type { border-top: 0; }
.kv span { color: var(--muted); }
.kv b { text-align: right; overflow-wrap: anywhere; }

/* шторка */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(8, 14, 26, .45); z-index: 30; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 31; max-height: 92vh; overflow-y: auto; background: var(--bg); border-radius: 24px 24px 0 0;
  padding: 8px max(16px, env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); animation: up .26s cubic-bezier(.2,.8,.2,1); }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
.sheet-grip { width: 40px; height: 5px; border-radius: 5px; background: var(--line); margin: 0 auto 12px; }
.sheet-body { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.sheet-hero { border-radius: var(--r); height: 128px; display: grid; place-items: center; font-size: 64px; }
.sheet-body h2 { font-size: 21px; }
.sheet-body .desc { color: var(--muted); font-size: 14.5px; }
.label { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.demo { background: var(--card); border-radius: var(--r); padding: 12px; display: flex; flex-direction: column; gap: 8px; min-height: 120px; box-shadow: var(--shadow); }
.demo-h { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.demo-h svg { width: 26px; height: 26px; }
.demo-h small { color: var(--muted); font-weight: 400; display: block; font-size: 11.5px; }
.msg { max-width: 86%; padding: 8px 11px; border-radius: 14px; font-size: 13.5px; animation: pop .25s ease both; overflow-wrap: anywhere; }
@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(.98); } }
.msg.u { align-self: flex-end; background: var(--pri); color: var(--pri-ink); border-bottom-right-radius: 5px; }
.msg.b { align-self: flex-start; background: var(--card-2); border-bottom-left-radius: 5px; }
.typing { align-self: flex-start; background: var(--card-2); border-radius: 14px; padding: 10px 12px; display: flex; gap: 4px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: dot 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
.steps { display: flex; flex-direction: column; gap: 9px; }
.steps div { display: flex; gap: 10px; align-items: center; font-size: 14px; }
.steps em { font-style: normal; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: var(--bg); font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none; }
.prompt-box { background: var(--card); border-radius: 14px; padding: 10px 12px; font-size: 13.5px; color: var(--muted); border: 1px dashed var(--line); }
.prompt-box b { color: var(--ink); font-weight: 500; }

/* таббар */
.tabbar { position: fixed; z-index: 20; left: 50%; transform: translateX(-50%); bottom: calc(12px + env(safe-area-inset-bottom)); display: flex; gap: 2px; padding: 5px;
  background: var(--card); border-radius: 22px; box-shadow: 0 10px 30px -10px rgba(10, 25, 60, .35); border: 1px solid var(--line); width: min(420px, calc(100% - 24px)); }
.tabbar button { flex: 1; border: 0; background: none; border-radius: 17px; padding: 7px 4px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--muted); }
.tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.tabbar button[aria-current="page"] { background: var(--pri-soft); color: var(--pri-text); }

.toast { position: fixed; z-index: 40; left: 50%; transform: translateX(-50%); bottom: calc(86px + env(safe-area-inset-bottom)); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 500; max-width: calc(100% - 32px); text-align: center; animation: pop .2s; }

.skel { background: linear-gradient(90deg, var(--card-2), var(--line), var(--card-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; height: 14px; }
@keyframes sk { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* 3D-картинки: Пиня и иконки */
img.pinya, img.icon3d { object-fit: contain; display: block; flex: none; user-select: none; -webkit-user-drag: none; }
img.pinya { filter: drop-shadow(0 8px 14px rgba(15, 40, 90, .18)); }
.hello .mascot img.pinya { width: 100%; height: 100%; transform-origin: 50% 90%; }
.hello .mascot.pet img.pinya { animation: pet .6s ease; }
.hello .mascot img.pinya { animation: idle 3.6s ease-in-out infinite; }
@keyframes idle { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-2px) scale(1.015, .99); } }
.brand img.pinya { width: 32px; height: 32px; border-radius: 50%; background: var(--pri-soft); padding: 2px; filter: none; }
.quick button img { filter: drop-shadow(0 4px 6px rgba(15, 40, 90, .16)); }
.ic img.icon3d { width: 30px; height: 30px; }
.ic { background: var(--card-2); }
.ic.sun { background: var(--sun-soft); }
.tile .em { right: 6px; bottom: 4px; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .18)); }
.chips button { display: inline-flex; align-items: center; gap: 6px; }
.group h3 img.icon3d { width: 24px; height: 24px; }
.sheet-hero img.icon3d { filter: drop-shadow(0 10px 16px rgba(0, 0, 0, .2)); animation: float 3.2s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.soon img.pinya { width: 110px; height: 110px; }
.empty img.pinya { width: 56px; height: 56px; }
.demo-h img.pinya { width: 28px; height: 28px; border-radius: 50%; background: var(--pri-soft); filter: none; }

/* Сброс контекста */
.muted-p { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.btn.ghost.armed { background: var(--bad-soft); color: var(--bad); }
.btn img.icon3d { width: 22px; height: 22px; }

/* Админка */
.back { font-size: 14px; }
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.kpi { background: var(--card); border-radius: 16px; padding: 12px 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi-l { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi-v { font: 700 22px var(--f-display); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi small { font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.chart .card-h { align-items: center; }
.chart-max { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 120px; border-bottom: 1px solid var(--line); }
.bar-col { flex: 1; height: 100%; display: flex; align-items: flex-end; background: none; border: 0; padding: 0 1px; min-width: 0; }
.bar-fill { display: block; width: 100%; background: var(--pri); border-radius: 4px 4px 0 0; opacity: .85; transition: opacity .15s; }
.bar-col:hover .bar-fill, .bar-col.on .bar-fill { opacity: 1; box-shadow: 0 0 0 2px var(--pri-soft); }
.bar-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }
.bar-readout { font-size: 13px; color: var(--muted); margin-top: 8px; min-height: 18px; }
.bar-readout b { color: var(--ink); font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow-x: auto; margin: 0 -4px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 8px 4px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td:not(:first-child), .tbl th:not(:first-child) { text-align: right; white-space: nowrap; }
.muted-p.small { font-size: 12px; }

/* Оплата криптой */
.btn.crypto { background: var(--card-2); color: var(--ink); border: 1px solid var(--line); }

/* Скидка */
.sale-banner { width: 100%; text-align: left; border: 0; display: flex; flex-direction: column; gap: 2px;
  background: linear-gradient(120deg, #FF7A45, #F5B53F); color: #fff; }
.sale-banner span { font-size: 13px; opacity: .95; }
.price s.old { color: var(--muted); font-size: 18px; font-weight: 500; }
.chip.sale { background: #FFE6D6; color: #B44A12; align-self: flex-start; }
:root[data-theme="dark"] .chip.sale { background: #4A2A18; color: #FFB48A; }
/* Друзья */
.ref-link { font: 500 13px ui-monospace, Consolas, monospace; background: var(--card-2); border-radius: 10px; padding: 10px 12px;
  overflow-wrap: anywhere; user-select: all; margin-bottom: 10px; }
.ref-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.ref-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 12px; text-align: center; font-size: 12px; color: var(--muted); }
.ref-stats b { display: block; font: 700 18px var(--f-display); color: var(--ink); font-variant-numeric: tabular-nums; }
/* Формы админки */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.form-row label, .lbl { font-size: 12.5px; color: var(--muted); font-weight: 600; display: flex; flex-direction: column; gap: 6px; }
.lbl { margin: 10px 0 6px; }
.card input[type=number], .card select, .card textarea { font: inherit; color: var(--ink); background: var(--card-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; width: 100%; }
.card textarea { resize: vertical; min-height: 110px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-top: 10px; }
.check input { width: 18px; height: 18px; accent-color: var(--pri); }
.btn.danger.armed, .btn.armed { background: var(--bad-soft); color: var(--bad); }

/* Кнопка смены темы — правый верхний угол на всех экранах */
.theme-fab { position: fixed; z-index: 25; top: calc(12px + var(--tg-content-safe-area-inset-top, 0px) + env(safe-area-inset-top, 0px));
  right: max(14px, env(safe-area-inset-right, 0px)); width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; padding: 0; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  box-shadow: 0 6px 18px -10px rgba(10, 25, 60, .45); }
.theme-fab svg { width: 20px; height: 20px; grid-area: 1 / 1; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; transition: opacity .2s, transform .3s; }
.theme-fab .i-moon { fill: currentColor; stroke: none; }
/* В светлой теме показываем луну (включить тёмную), в тёмной — солнце */
:root .theme-fab .i-sun { opacity: 0; transform: rotate(-60deg) scale(.6); }
:root[data-theme="dark"] .theme-fab .i-sun { opacity: 1; transform: none; color: var(--sun); }
:root[data-theme="dark"] .theme-fab .i-moon { opacity: 0; transform: rotate(60deg) scale(.6); }
.theme-fab.spin { animation: fabspin .35s ease; }
@keyframes fabspin { 50% { transform: scale(.88) rotate(-12deg); } }
/* Место под кнопку, чтобы она не налезала на шапку и заголовки */
.view > .top, .view > div:first-child { padding-right: 50px; }
.view > .top .chip { margin-left: auto; }
