:root {
  --bg: var(--tg-theme-bg-color, #0b0d12);
  --card: color-mix(in srgb, var(--tg-theme-secondary-bg-color, #161a22) 82%, transparent);
  --text: var(--tg-theme-text-color, #eef0f5);
  --hint: var(--tg-theme-hint-color, #8b93a7);
  --accent: var(--tg-theme-button-color, #5b8cff);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --gold: #ffcf5c; --good: #3ccf8e; --warn: #ffb547; --bad: #ff6b6b; --violet: #b06bff;
  --radius: 18px;
  --ease-pop: cubic-bezier(.2, 1.35, .35, 1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; overflow-x: hidden; }

/* Живой фон */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.aurora i { position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%; filter: blur(70px); opacity: .22;
  animation: drift 18s ease-in-out infinite alternate; }
.aurora i:nth-child(1) { background: var(--accent); left: -20vmax; top: -20vmax; }
.aurora i:nth-child(2) { background: var(--violet); right: -25vmax; top: 10vmax; animation-duration: 23s; }
.aurora i:nth-child(3) { background: #19c3a5; left: 10vmax; bottom: -30vmax; animation-duration: 27s; }
@keyframes drift { to { transform: translate(8vmax, 6vmax) scale(1.15); } }

.glass { background: var(--card); backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid rgba(255,255,255,.06); border-radius: var(--radius); }

.top { position: sticky; top: 0; z-index: 10; padding: 12px 16px 8px;
  background: linear-gradient(var(--bg) 70%, transparent); }
.brand { font-weight: 800; font-size: 19px; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.logo { display: inline-block; animation: wobble 3s ease-in-out infinite; }
@keyframes wobble { 0%, 100% { transform: rotate(0); } 10% { transform: rotate(-12deg) scale(1.1); } 20% { transform: rotate(10deg); } 30% { transform: none; } }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 0 var(--good);
  animation: ping 1.8s infinite; margin-left: 4px; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(60,207,142,.7); } 100% { box-shadow: 0 0 0 10px rgba(60,207,142,0); } }

.tabs { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); background: var(--card);
  border-radius: 14px; padding: 4px; border: 1px solid rgba(255,255,255,.06); }
.tab { position: relative; z-index: 1; border: 0; background: none; color: var(--hint); padding: 9px; font: inherit;
  font-weight: 600; transition: color .25s; }
.tab.active { color: var(--accent-text); }
.tab-pill { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc((100% - 8px) / 3); border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--violet)); box-shadow: 0 6px 18px -6px var(--accent);
  transition: transform .45s var(--ease-pop); }

main { padding: 6px 16px 24px; max-width: 720px; margin: 0 auto; }
.screen { display: none; } .screen.active { display: block; animation: rise .45s var(--ease-pop); }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }

.search { display: flex; gap: 6px; padding: 6px; margin: 6px 0 14px; }
input, select { width: 100%; padding: 11px 12px; border-radius: 12px; border: 1px solid transparent;
  background: rgba(127,127,127,.12); color: var(--text); font: inherit; min-width: 0; transition: border-color .2s, box-shadow .2s; }
.search input { background: transparent; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); }
.btn { border: 0; border-radius: 12px; padding: 11px 16px; font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: transform .15s, filter .2s; }
.btn:active, .icon-btn:active, .card:active { transform: scale(.95); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--violet)); color: var(--accent-text);
  box-shadow: 0 8px 22px -10px var(--accent); }
.btn.ghost { background: rgba(127,127,127,.14); color: var(--text); }
.icon-btn { border: 0; background: rgba(127,127,127,.14); border-radius: 12px; width: 44px; font-size: 18px; transition: transform .15s; }
.link-btn { border: 0; background: none; color: var(--hint); font: inherit; display: block; margin: 8px auto; text-decoration: underline; }
.hint { color: var(--hint); font-size: 13px; } .center { text-align: center; margin-top: 24px; }
.hidden { display: none !important; }

/* ---------- Сцена «улучшения» ---------- */
.stage { position: relative; width: min(78vw, 320px); aspect-ratio: 1; margin: 6px auto 14px; border-radius: 28px;
  overflow: hidden; background: #1b1f29; box-shadow: 0 20px 50px -20px rgba(0,0,0,.7); }
.stage-bg { position: absolute; inset: 0; background: radial-gradient(circle at 50% 45%, var(--c, #2a2f3b), var(--e, #12151c) 75%);
  clip-path: circle(0% at 50% 50%); transition: clip-path .9s cubic-bezier(.6,.05,.25,1); }
.stage.bg-on .stage-bg { clip-path: circle(80% at 50% 50%); }
.stage-pattern { position: absolute; inset: 0; }
.stage-pattern img { position: absolute; width: 13%; opacity: 0; transform: scale(.2) rotate(-90deg);
  transition: opacity .5s, transform .7s var(--ease-pop); filter: drop-shadow(0 0 0 transparent); }
.stage.pat-on .stage-pattern img { opacity: .38; transform: none; }
.stage-model { position: absolute; left: 17%; top: 15%; width: 66%; opacity: 0; transform: translateY(-60%) scale(.4) rotate(-20deg);
  transition: opacity .3s, transform .8s var(--ease-pop); filter: drop-shadow(0 18px 24px rgba(0,0,0,.45)); }
.stage.model-on .stage-model { opacity: 1; transform: none; animation: float 3.2s ease-in-out 1s infinite; }
@keyframes float { 50% { transform: translateY(-4%) rotate(1.5deg); } }
.stage-orb { position: absolute; inset: 0; display: grid; place-items: center; font-size: 72px; animation: pulse 1s ease-in-out infinite;
  transition: opacity .3s, transform .4s; }
.stage.model-on .stage-orb { opacity: 0; transform: scale(2.4); }
@keyframes pulse { 50% { transform: scale(1.14) rotate(-6deg); } }
.ring { position: absolute; left: 50%; top: 50%; width: 70%; aspect-ratio: 1; margin: -35% 0 0 -35%; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent, var(--accent), var(--violet), var(--gold), transparent 70%);
  -webkit-mask: radial-gradient(farthest-side, transparent 72%, #000 73%); mask: radial-gradient(farthest-side, transparent 72%, #000 73%);
  animation: spin 1s linear infinite; filter: drop-shadow(0 0 16px var(--accent)); transition: opacity .5s; }
.ring.r2 { width: 88%; margin: -44% 0 0 -44%; animation-duration: 2s; animation-direction: reverse; opacity: .5; }
.stage.model-on .ring { opacity: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.stage-flash { position: absolute; inset: 0; background: radial-gradient(circle, rgba(255,255,255,.9), transparent 60%); opacity: 0; pointer-events: none; }
.stage.flash .stage-flash { animation: flash .6s ease-out; }
@keyframes flash { 0% { opacity: .9; transform: scale(.3); } 100% { opacity: 0; transform: scale(1.6); } }
.confetti i { position: absolute; left: 50%; top: 50%; width: 8px; height: 12px; border-radius: 2px; opacity: 0;
  animation: boom 1.3s cubic-bezier(.2,.7,.3,1) forwards; }
@keyframes boom { 0% { opacity: 1; transform: translate(-50%, -50%) rotate(0); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) rotate(var(--r)); } }

.price-board { text-align: center; padding: 12px 14px 14px; margin: 0 auto 10px; max-width: 380px; position: relative; overflow: hidden; }
.pb-label { color: var(--hint); font-size: 13px; min-height: 18px; transition: opacity .2s; }
.pb-value { font-size: 34px; font-weight: 900; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.pb-value small { font-size: 15px; color: var(--hint); font-weight: 600; }
.pb-value.bump { animation: bump .45s var(--ease-pop); }
@keyframes bump { 40% { transform: scale(1.14); color: var(--gold); } }
.pb-chip { position: absolute; right: 12px; top: 12px; font-weight: 800; font-size: 14px; padding: 3px 9px; border-radius: 999px;
  background: rgba(255,207,92,.18); color: var(--gold); opacity: 0; }
.pb-chip.show { animation: chip 1s var(--ease-pop); }
.pb-chip.down { background: rgba(255,107,107,.18); color: var(--bad); }
@keyframes chip { 0% { opacity: 0; transform: translateY(14px) scale(.6); } 25% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }

.steps { list-style: none; padding: 0; margin: 0 auto 6px; max-width: 420px; display: grid; gap: 6px; }
.steps li { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 8px; padding: 9px 12px;
  border-radius: 14px; background: var(--card); border: 1px solid rgba(255,255,255,.05); animation: slidein .5s var(--ease-pop) both; }
.steps li .ico { font-size: 20px; text-align: center; }
.steps li .lbl small { display: block; color: var(--hint); font-size: 12px; }
.steps li .mul { font-weight: 800; font-variant-numeric: tabular-nums; }
.steps li .mul.up { color: var(--good); } .steps li .mul.down { color: var(--bad); }
.steps li.special { border-color: rgba(255,207,92,.5); box-shadow: 0 0 22px -8px var(--gold); }
.steps li.unverified .mul::after { content: " ?"; color: var(--warn); }
@keyframes slidein { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }

/* Итоговая карточка */
.result { padding: 16px; margin-top: 10px; animation: rise .6s var(--ease-pop); }
.result h2 { margin: 0 0 8px; font-size: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { background: rgba(127,127,127,.15); border-radius: 999px; padding: 4px 10px; font-size: 13px; }
.chip b { font-weight: 700; } .chip .pct { color: var(--hint); }
.tier { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 800; vertical-align: middle;
  animation: popin .6s var(--ease-pop); }
@keyframes popin { from { transform: scale(0); } }
.tier.High { background: rgba(60,207,142,.18); color: var(--good); }
.tier.Medium { background: rgba(255,181,71,.18); color: var(--warn); }
.tier.Low { background: rgba(255,107,107,.18); color: var(--bad); }
.range { position: relative; height: 12px; border-radius: 999px; margin: 14px 0 6px; overflow: hidden;
  background: rgba(127,127,127,.18); }
.range .fill { position: absolute; inset: 0; background: linear-gradient(90deg, var(--bad), var(--warn), var(--good));
  transform-origin: left; transform: scaleX(0); animation: grow 1.2s .2s var(--ease-pop) forwards; }
.range .mid { position: absolute; top: -3px; width: 4px; height: 18px; border-radius: 2px; background: #fff; box-shadow: 0 0 10px #fff;
  opacity: 0; animation: fadein .4s 1.2s forwards; }
@keyframes grow { to { transform: scaleX(1); } } @keyframes fadein { to { opacity: 1; } }
.range-labels { display: flex; justify-content: space-between; font-size: 13px; color: var(--hint); font-variant-numeric: tabular-nums; }
.formula { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; background: rgba(127,127,127,.12);
  border-radius: 10px; padding: 8px 10px; margin: 12px 0 8px; word-break: break-word; }
.notes { margin: 6px 0 0; padding-left: 18px; color: var(--hint); font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; } .actions .btn { flex: 1; text-align: center; }
h3 { margin: 22px 0 10px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
h3 .count { font-size: 12px; color: var(--hint); font-weight: 600; }

/* Карточки лотов */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 10px; }
.card { position: relative; background: var(--card); border-radius: 16px; overflow: hidden; display: flex; flex-direction: column;
  cursor: pointer; border: 1px solid rgba(255,255,255,.06); animation: cardin .55s var(--ease-pop) both;
  animation-delay: calc(var(--i, 0) * 45ms); transition: transform .2s; }
@keyframes cardin { from { opacity: 0; transform: translateY(18px) scale(.92) rotate(-1deg); } }
.card img { width: 100%; aspect-ratio: 1; object-fit: cover; background: #222; transition: transform .5s; }
.card:hover img { transform: scale(1.06); }
.card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 40%, rgba(255,255,255,.14) 50%, transparent 60%);
  transform: translateX(-100%); pointer-events: none; }
.card:hover::after, .card.good::after { animation: shine 2.6s ease-in-out infinite; }
@keyframes shine { 60%, 100% { transform: translateX(100%); } }
.card.good { border: 1px solid transparent; background: linear-gradient(var(--card), var(--card)) padding-box,
  conic-gradient(from var(--a, 0deg), var(--gold), var(--good), var(--accent), var(--gold)) border-box; animation: cardin .55s var(--ease-pop) both, rot 4s linear infinite; }
@property --a { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes rot { to { --a: 360deg; } }
.card .c-body { padding: 8px 10px 10px; font-size: 13px; display: grid; gap: 3px; }
.card .t { font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .s { color: var(--hint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .p { font-weight: 900; font-size: 16px; }
.card .why { color: var(--hint); font-size: 11.5px; line-height: 1.25; }
.badge { display: inline-block; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px;
  background: rgba(91,140,255,.18); color: var(--accent); margin-right: 4px; }
.badge.gold { background: rgba(255,207,92,.2); color: var(--gold); }
.badge.good { background: rgba(60,207,142,.18); color: var(--good); animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 14px rgba(60,207,142,.6); } }
.card.new { animation: newpop 1.1s var(--ease-pop) both; box-shadow: 0 0 0 2px var(--gold), 0 0 28px -4px var(--gold); }
@keyframes newpop { 0% { transform: scale(.5) rotate(-10deg); opacity: 0; } 60% { transform: scale(1.06) rotate(2deg); opacity: 1; } }

/* Скелетоны */
.skeleton { border-radius: 16px; aspect-ratio: .78; background: linear-gradient(100deg, rgba(127,127,127,.12) 40%, rgba(127,127,127,.25) 50%, rgba(127,127,127,.12) 60%);
  background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.filters { padding: 10px 12px; margin: 6px 0 12px; } .filters summary { cursor: pointer; font-weight: 700; }
.filters .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.pair { display: flex; gap: 6px; grid-column: span 2; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; white-space: nowrap; } .check input { width: auto; }
#f-apply { grid-column: span 2; }
.feed-bar { display: flex; gap: 10px; align-items: center; padding: 8px 10px; margin: 6px 0 8px; } .feed-bar select { flex: 1; }
.live-badge { font-size: 11px; font-weight: 900; color: var(--bad); display: flex; align-items: center; gap: 5px; letter-spacing: .5px; }
.live-badge i { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.empty { text-align: center; color: var(--hint); padding: 30px 10px; }
.empty .big { font-size: 54px; display: block; animation: float 3s ease-in-out infinite; }
.section-note { color: var(--hint); font-size: 12.5px; margin: -4px 0 10px; }
.error { color: var(--bad); padding: 12px; background: rgba(255,107,107,.1); border-radius: 12px; animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.credit { text-align: center; color: var(--hint); font-size: 12px; padding: 12px 16px 28px; } .credit a { color: var(--accent); }
@media (max-width: 380px) { .cards { grid-template-columns: 1fr 1fr; } .pb-value { font-size: 28px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }

.asks { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 0 4px; font-size: 13px; color: var(--hint); }
.ask { background: rgba(127,127,127,.14); border-radius: 999px; padding: 3px 10px; color: var(--text); animation: popin .5s var(--ease-pop) both; }
.ask.best { background: rgba(60,207,142,.18); color: var(--good); box-shadow: 0 0 14px -4px var(--good); }

/* График цены */
.chart-box { margin: 12px 0 6px; padding: 10px 10px 8px; border-radius: 14px; background: rgba(127,127,127,.08); }
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 6px; }
.seg { display: inline-flex; background: rgba(127,127,127,.15); border-radius: 999px; padding: 2px; }
.seg button { border: 0; background: none; color: var(--hint); font: inherit; font-size: 12px; padding: 3px 9px; border-radius: 999px; }
.seg button.on { background: var(--accent); color: var(--accent-text); }
.chart { min-height: 120px; }
.c-svg { width: 100%; height: 150px; display: block; overflow: visible; }
.c-line { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round;
  stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.4s .1s var(--ease-pop) forwards; filter: drop-shadow(0 0 6px var(--accent)); }
@keyframes draw { to { stroke-dashoffset: 0; } }
.c-area { opacity: 0; animation: fadein .8s .8s forwards; }
.c-band { fill: rgba(255,207,92,.35); opacity: 0; animation: fadein .5s 1.3s forwards; }
.c-dot { fill: var(--gold); stroke: #fff; stroke-width: 2; opacity: 0; transform-box: fill-box; transform-origin: center;
  animation: dotpop .6s 1.5s var(--ease-pop) forwards; }
@keyframes dotpop { from { opacity: 0; transform: scale(0); } to { opacity: 1; transform: none; } }
.c-foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--hint); margin-top: 4px; }
.c-foot .up { color: var(--good); font-weight: 700; } .c-foot .down { color: var(--bad); font-weight: 700; }
