/* Токены — 03 §2 (тёмная тема основная). Светлая — по colorScheme Telegram (решение владельца
   19.11.2026; в 03 §2.1 было «только тёмная» — см. ТЗ §19.9). */
:root {
  --bg-0: #0D1015; --bg-1: #151922; --bg-2: #1E2430; --bg-3: #2A3140;
  --line: rgba(42, 49, 64, .6);
  --text-1: #F2F4F8; --text-2: #A9B1C1; --text-3: #7C8597;
  --accent: #FFB547; --accent-press: #E89B28; --accent-soft: rgba(255, 181, 71, .14);
  --on-accent: #1A1204;
  --up: #3DDC97; --down: #FF5C6C; --info: #5AA9FF; --warn: #FFD166; --mono: #E8E8F0;
  --inner: inset 0 0 0 1px rgba(255, 255, 255, .06);
  --r-s: 8px; --r-m: 12px; --r-l: 16px; --r-xl: 24px;
  --ease-out: cubic-bezier(.2, .8, .2, 1); --ease-io: cubic-bezier(.4, 0, .2, 1);
  --spring: cubic-bezier(.34, 1.4, .64, 1);
  --tg-safe-top: 0px; --tg-safe-bottom: 0px;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg-0: #F4F5F8; --bg-1: #FFFFFF; --bg-2: #ECEEF3; --bg-3: #DDE1E9;
  --line: rgba(18, 22, 29, .1);
  --text-1: #12161D; --text-2: #4A5263; --text-3: #626B7C;
  --accent: #C77A00; --accent-press: #A86600; --accent-soft: rgba(199, 122, 0, .12);
  --on-accent: #FFFFFF;
  --up: #12895A; --down: #D12C3E; --info: #1F6FD1; --warn: #9A6A00; --mono: #2A3140;
  --inner: inset 0 0 0 1px rgba(18, 22, 29, .06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; background: var(--bg-0); color: var(--text-1);
  font: 400 0.9375rem/1.25rem -apple-system, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;
}
body.no-scroll { overflow: hidden; }
#app { max-width: 560px; margin: 0 auto; min-height: 100vh;
       padding: calc(var(--tg-safe-top) + 8px) 16px calc(72px + var(--tg-safe-bottom)); }
@media (max-width: 359px) { #app { padding-left: 12px; padding-right: 12px; } }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible, a:focus-visible, [tabindex]:focus-visible, input:focus-visible {
  outline: 2px solid var(--info); outline-offset: 2px; }
button:disabled { opacity: .4; cursor: default; }
h1, h2, h3, p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
small { font-size: .75rem; line-height: 1rem; font-weight: 500; }
.micro { font-size: .6875rem; line-height: .875rem; font-weight: 500; color: var(--text-2);
         font-variant-numeric: tabular-nums; white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.offscreen { position: fixed; left: -10000px; top: 0; pointer-events: none; }
.link { color: var(--info); font-weight: 600; min-height: 44px; }
.link.small { font-size: .8125rem; min-height: 32px; }
[hidden] { display: none !important; }

/* ---------- шапка и вкладки ---------- */
.top { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.title { font-size: 1.25rem; line-height: 1.5rem; font-weight: 700; }
.live-dot { width: 44px; height: 44px; position: relative; }
.live-dot::after { content: ""; position: absolute; left: 18px; top: 18px; width: 8px; height: 8px;
                   border-radius: 50%; background: var(--text-3); }
.live-dot.green::after { background: var(--up); }
.live-dot.yellow::after { background: var(--warn); }
.live-dot.pulse::before { content: ""; position: absolute; left: 14px; top: 14px; width: 16px;
  height: 16px; border-radius: 50%; border: 2px solid var(--up); opacity: 0;
  animation: pulse 600ms var(--ease-out); }
@keyframes pulse { from { transform: scale(.5); opacity: .9; } to { transform: scale(1.4); opacity: 0; } }
.offline-bar { background: var(--bg-2); color: var(--text-2); border-radius: var(--r-s);
               padding: 8px 12px; margin: 4px 0 8px; font-size: .8125rem; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex;
        justify-content: center; gap: 8px; background: var(--bg-1); box-shadow: var(--inner);
        padding: 4px 8px calc(4px + var(--tg-safe-bottom) + env(safe-area-inset-bottom, 0px)); }
.tab { flex: 1; max-width: 180px; min-height: 48px; display: flex; flex-direction: column;
       align-items: center; justify-content: center; gap: 2px; color: var(--text-2);
       font-size: .75rem; font-weight: 600; border-radius: var(--r-m); }
.tab.active { color: var(--accent); }
.page { animation: fade 140ms ease-out; }
@keyframes fade { from { opacity: 0; } }

/* ---------- блоки ---------- */
.block { margin: 12px 0 20px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
              margin-bottom: 10px; }
.block-head h2 { font-size: 1rem; line-height: 1.25rem; font-weight: 600; }
.placeholder { background: var(--bg-1); border-radius: var(--r-m); padding: 16px; display: grid;
               gap: 12px; box-shadow: var(--inner); }

/* ---------- карточка подарка (03 §5.1) ---------- */
.card { position: relative; aspect-ratio: 1 / 1; border-radius: var(--r-l); overflow: hidden;
        background: radial-gradient(circle at 50% 50%, var(--c, #3a4150) 0%, var(--e, #1e2430) 100%);
        isolation: isolate; }
.card .pattern { position: absolute; inset: 0; width: 100%; height: 100%; }
.card .model { position: absolute; inset: 16%; z-index: 1; }
.card .model canvas, .card .model .still { width: 100% !important; height: 100% !important;
  display: block; }
.card-S { width: 48px; flex: none; border-radius: var(--r-s); }
.card-S .model { inset: 10%; }
.card-L { width: min(220px, 60vw); margin: 0 auto; }
.card.skeleton { background: var(--bg-2); }
.card.ready .model { animation: pop 450ms var(--spring); }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }

/* ---------- витрина (03 §5.4, §6.3) ---------- */
.showcase { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cell { min-height: 150px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cell.empty { aspect-ratio: 1 / 1.3; min-height: 0; border: 1.5px dashed var(--bg-3);
  border-radius: var(--r-l); align-items: center; justify-content: center; color: var(--text-2);
  font-size: .8125rem; font-weight: 600; transition: border-color 90ms; }
.cell.empty:active { border-color: var(--accent); transform: scale(.97); }
.cell-open { display: block; width: 100%; border-radius: var(--r-l); }
.cell.filled .card { box-shadow: 0 0 24px var(--glow, transparent); }
.cell-name { display: flex; flex-direction: column; min-width: 0; }
.cell-name b, .cell-name small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-name b { font-size: .8125rem; }
.cell-est { display: flex; align-items: center; gap: 6px; min-height: 22px; font-size: 1rem; }
.cell-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.cell-missing { min-height: 120px; border-radius: var(--r-l); background: var(--bg-1);
                color: var(--text-2); font-size: .75rem; padding: 8px; }
.est-placeholder { display: inline-block; width: 60%; height: 16px; border-radius: 6px; }
.compare { margin-top: 8px; font-size: .8125rem; min-height: 1rem; }
.chip-mini { display: inline-flex; align-items: center; gap: 3px; font-size: .6875rem;
  font-weight: 600; color: var(--text-2); background: var(--bg-1); border-radius: 999px;
  padding: 2px 6px; font-variant-numeric: tabular-nums; }
.chip-mini.more { color: var(--text-3); }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; flex: none; }
.mono { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%;
        background: var(--mono); color: var(--bg-0); font-size: .625rem; }
.cell.reveal .card { animation: reveal 320ms var(--ease-out); }
.cell.reveal .cell-name, .cell.reveal .cell-est, .cell.reveal .cell-chips {
  animation: rise 180ms var(--ease-out) both; }
.cell.reveal .cell-est { animation-delay: 60ms; }
.cell.reveal .cell-chips { animation-delay: 120ms; }
@keyframes reveal { from { clip-path: circle(0% at 50% 50%); } to { clip-path: circle(75% at 50% 50%); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.cell.leaving { transform: scale(.9); opacity: 0; transition: transform 180ms, opacity 180ms; }
@media (max-width: 359px) { .cell-name small, .cell-chips { display: none; } }

/* ---------- стенд (03 §5.3, §6.1) ---------- */
.segment { display: flex; background: var(--bg-1); border-radius: 999px; padding: 3px;
           margin-bottom: 8px; box-shadow: var(--inner); }
.seg { flex: 1; min-height: 36px; border-radius: 999px; font-size: .8125rem; font-weight: 600;
       color: var(--text-2); }
.seg.active { background: var(--accent-soft); color: var(--text-1); }
.feed { display: flex; flex-direction: column; }
.upgrade { position: relative; display: flex; align-items: center; gap: 12px; min-height: 64px;
           padding: 8px 8px 8px 12px; border-radius: var(--r-m); cursor: pointer;
           transition: background-color 1200ms linear, transform 280ms var(--ease-out),
           opacity 280ms var(--ease-out); }
.upgrade:active { background: var(--bg-2); }
.upgrade.mine { background: var(--accent-soft); }
.upgrade.enter { opacity: 0; transform: translateY(-12px); background: var(--accent-soft); }
.mine-dot { position: absolute; left: 2px; top: 50%; width: 6px; height: 6px; margin-top: -3px;
            border-radius: 50%; background: var(--accent); }
.line1, .line2 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
                 min-width: 0; }
.line2 { font-size: .75rem; }
.owner { flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
         color: var(--text-2); font-size: .75rem; }
.owner.link { color: var(--info); text-decoration: none; font-weight: 600; padding: 6px 0; }
.owner.pending { border-bottom: 1px dotted var(--text-3); cursor: pointer; }
.owner-slot { display: flex; min-width: 0; max-width: 45%; }
.owner-slot .owner { max-width: 100%; }
.new-pill { position: sticky; top: calc(var(--tg-safe-top) + 8px); z-index: 5; display: block;
  margin: 0 auto 8px; background: var(--accent); color: var(--on-accent); font-weight: 700;
  font-size: .8125rem; border-radius: 999px; padding: 8px 14px; min-height: 36px;
  animation: fade 200ms ease-out; }
.sentinel { height: 1px; }
.empty { text-align: center; padding: 24px 8px; display: grid; gap: 6px; justify-items: center; }
.empty-title { font-weight: 600; }
.empty-line { color: var(--text-2); padding: 16px 4px; text-align: center; }
.banner { display: flex; align-items: center; gap: 8px; justify-content: space-between;
          border-radius: var(--r-s); padding: 6px 12px; margin-bottom: 8px; font-size: .8125rem;
          min-height: 48px; background: var(--bg-2); }
.banner.error { box-shadow: inset 3px 0 0 var(--down); }

/* ---------- кнопки, тост ---------- */
.btn { min-height: 48px; border-radius: var(--r-l); padding: 0 16px; font-weight: 600;
       transition: transform 90ms; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:active { background: var(--accent-press); }
.btn.secondary { box-shadow: inset 0 0 0 1px var(--bg-3); }
.btn.danger { background: var(--down); color: #fff; }
.btn.ghost-danger { color: var(--down); }
.btn.wide { width: 100%; margin: 4px 0 12px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.row-actions .btn { flex: 1; }
.icon-btn { width: 44px; height: 44px; font-size: 1.5rem; color: var(--text-2); }
.toast { position: fixed; left: 50%; bottom: calc(76px + var(--tg-safe-bottom)); z-index: 60;
         transform: translate(-50%, 16px); opacity: 0; pointer-events: none; max-width: 90vw;
         background: var(--bg-3); color: var(--text-1); border-radius: var(--r-m);
         padding: 10px 14px; font-size: .8125rem; transition: opacity 200ms, transform 200ms; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- нижний лист (03 §6.4) ---------- */
.sheet-root { position: fixed; inset: 0; z-index: 40; }
.shade { position: absolute; inset: 0; background: #000; opacity: 0; transition: opacity 200ms; }
.sheet-root.open .shade { opacity: .55; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto;
  background: var(--bg-1); border-radius: var(--r-xl) var(--r-xl) 0 0; display: flex;
  flex-direction: column; max-height: 88vh; transform: translateY(100%);
  transition: transform 220ms var(--ease-io); box-shadow: 0 -8px 32px rgba(0, 0, 0, .5);
  padding-bottom: calc(12px + var(--tg-safe-bottom)); outline: none; }
.sheet.tall { height: 88vh; }
.sheet-root.open .sheet { transform: translateY(0); transition-duration: 320ms;
                          transition-timing-function: var(--ease-out); }
.sheet.dragging { transition: none; }
.sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--bg-3);
                margin: 8px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 4px 16px;
              touch-action: none; }
.sheet-title { font-size: 1.0625rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis;
               white-space: nowrap; }
.sheet-body { overflow-y: auto; padding: 0 16px 8px; flex: 1; overscroll-behavior: contain; }
.card-wrap { padding: 8px 0 12px; }
.kv { display: flex; align-items: baseline; gap: 8px; min-height: 32px; border-bottom: 1px solid var(--line); }
.kv > span:first-child { width: 38%; flex: none; }
.est-box { margin-top: 12px; display: grid; gap: 2px; }
.est-big { display: flex; align-items: center; gap: 8px; font-size: 1.75rem; line-height: 2rem;
           font-weight: 700; margin-bottom: 8px; }
.est-big small { font-size: .75rem; font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 10px;
        border-radius: 999px; background: var(--bg-2); font-size: .8125rem; }

/* ---------- выбор связки (03 §5.5) ---------- */
.picker .sheet-body { display: flex; flex-direction: column; padding-bottom: 0; }
.stepper { display: flex; gap: 4px; overflow-x: auto; padding: 4px 0 8px; flex: none; }
.step { min-height: 36px; padding: 0 10px; border-radius: 999px; font-size: .8125rem;
        color: var(--text-2); white-space: nowrap; background: var(--bg-2); }
.step b { color: var(--text-3); }
.step.active { background: var(--accent-soft); color: var(--text-1); }
.search { width: 100%; min-height: 40px; border-radius: var(--r-s); border: 0; padding: 0 12px;
          background: var(--bg-2); color: var(--text-1); font: inherit; flex: none; }
.picker-list { flex: 1; overflow-y: auto; padding: 8px 0; animation: slide 200ms var(--ease-out); }
@keyframes slide { from { opacity: 0; transform: translateX(28px); } }
.list-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px;
            text-align: left; border-radius: var(--r-m); padding: 6px 8px; }
.list-row:active { background: var(--bg-2); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--bg-3); display: grid;
          place-items: center; font-weight: 700; flex: none; }
.tag { color: var(--accent); }
.group { font-size: .75rem; font-weight: 600; color: var(--text-2); margin: 12px 0 6px;
         text-transform: uppercase; letter-spacing: .02em; }
.tiles { display: grid; gap: 8px; }
.tiles-3 { grid-template-columns: repeat(3, 1fr); }
.tiles-4 { grid-template-columns: repeat(4, 1fr); }
.tile { min-height: 64px; border-radius: var(--r-m); background: var(--bg-2); padding: 8px 6px;
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        gap: 2px; text-align: center; min-width: 0; transition: transform 90ms; }
.tile b { font-size: .8125rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.tile:active { transform: scale(.97); }
.tile.selected { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-soft); }
.tile-bd { min-height: 84px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; margin-bottom: 4px;
          background: radial-gradient(circle, var(--c) 0%, var(--e) 100%); box-shadow: var(--inner); }
.picker-preview { flex: none; display: flex; align-items: center; gap: 12px; padding: 10px 0 4px;
                  border-top: 1px solid var(--line); min-height: 0; }
.picker-preview:empty { display: none; }
.picker-preview .est { text-align: right; display: flex; flex-direction: column; align-items: flex-end; }

/* ---------- экраны «Нет доступа» / «Нет связи» (03 §3.10) ---------- */
.screen.center { min-height: 80vh; display: flex; flex-direction: column; align-items: center;
                 justify-content: center; text-align: center; gap: 14px; padding: 24px; }
.screen h1 { font-size: 1.25rem; }
.lock { width: 72px; height: 72px; border-radius: 50%; background: var(--bg-1); display: grid;
        place-items: center; color: var(--text-3); }
.id-box { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.id-box code { font-size: 1rem; padding: 8px 12px; border-radius: var(--r-s); background: var(--bg-1);
               font-variant-numeric: tabular-nums; }

/* ---------- скелеты и шиммер ---------- */
.shimmer, .skeleton { background: linear-gradient(90deg, var(--bg-1), var(--bg-2), var(--bg-1));
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite; color: transparent; }
.skeleton-list { height: 240px; border-radius: var(--r-m); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- уменьшение движения (03 §6.7) ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important;
                           transition-duration: 100ms !important; }
  .shimmer, .skeleton { animation: none; }
  .upgrade.enter { transform: none; }
}
