@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #0c0c0e;
  --card: #161618;
  --tile: #1f1f23;
  --well: #111113;
  --text: #fff;
  --muted: #8b8b95;
  --green: #3dcf7c;
  --green-solid: #27a85c;
  --green-edge: #1a7a41;
  --red: #f25c5c;
  --live: #ff5b3d;
  --blue: #1f8fff;
  --blue-edge: #1463b8;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  background: var(--bg);
}

body {
  min-height: 100vh;
  color: var(--text);
  font: 500 15px/1.35 "Inter", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

button {
  margin: 0;
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 12px calc(20px + env(safe-area-inset-bottom));
}

/* --- Шапка ------------------------------------------------------------------ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand h1 {
  margin: 0;
  color: #fff;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: #fff;
  color: var(--bg);
}

.brand-mark svg {
  width: 19px;
  height: 19px;
}

.live,
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--live);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.live i,
.status i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.8s infinite;
}

/* --- Карточки --------------------------------------------------------------- */
.card {
  padding: 18px 16px 16px;
  border-radius: 18px;
  background: var(--card);
}

.card + .card {
  margin-top: 12px;
}

.label {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .05em;
  text-align: center;
  text-transform: uppercase;
}

/* --- Выбор актива ----------------------------------------------------------- */
.assets {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.asset {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 136px;
  max-width: calc(50% - 6px);
  padding: 16px 10px 14px;
  border: 1.5px solid transparent;
  border-radius: 16px;
  background: var(--tile);
  transition: background .2s, border-color .2s, box-shadow .2s, transform .1s;
}

/* Цвета монеты — и для кнопки актива, и для карточки анализа */
[data-asset="BTC"] {
  --coin: #f7931a;
  --coin-soft: rgba(247, 147, 26, .1);
  --coin-ring: rgba(247, 147, 26, .16);
}

[data-asset="ETH"] {
  --coin: #627eea;
  --coin-soft: rgba(98, 126, 234, .12);
  --coin-ring: rgba(98, 126, 234, .18);
}

.asset:active:not(:disabled) {
  transform: scale(.97);
}

.asset b {
  margin-top: 10px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
}

.asset small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.asset.selected {
  border-color: var(--coin);
  background: linear-gradient(var(--coin-soft), var(--coin-soft)), var(--tile);
  box-shadow: 0 0 0 4px var(--coin-ring);
}

.asset.selected::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--coin) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4.5 8.3 2.3 2.3 4.7-5'/%3E%3C/svg%3E") center / 16px no-repeat;
  animation: pop .3s var(--ease);
}

.coin {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--coin);
}

.coin svg {
  width: 32px;
  height: 32px;
}

/* --- Выбор времени ---------------------------------------------------------- */
.reveal {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows .35s var(--ease), margin-top .35s var(--ease), opacity .3s;
}

.reveal.open {
  grid-template-rows: 1fr;
  margin-top: 20px;
  opacity: 1;
}

.reveal-inner {
  min-height: 0;
  overflow: hidden;
}

.times {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding-bottom: 4px; /* место под «объёмный» нижний край кнопок */
}

.chip {
  flex: 1;
  max-width: 104px;
  padding: 11px 8px;
  border-radius: 12px;
  background: #2a2a30;
  box-shadow: 0 3px 0 #1a1a1e;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .15s, box-shadow .1s, transform .1s;
}

.chip b {
  font-size: 16px;
  font-weight: 700;
}

.chip span {
  color: var(--muted);
}

.chip:active:not(:disabled) {
  box-shadow: 0 1px 0 #1a1a1e;
  transform: translateY(2px);
}

.chip.selected {
  background: var(--blue);
  box-shadow: 0 3px 0 var(--blue-edge);
}

.chip.selected span {
  color: rgba(255, 255, 255, .82);
}

/* --- Кнопка «Получить сигнал» ---------------------------------------------- */
.cta {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 52px;
  margin: 20px 0 4px;
  overflow: hidden;
  border-radius: 14px;
  background: var(--green-solid);
  box-shadow: 0 4px 0 var(--green-edge);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: background .2s, box-shadow .15s, color .2s, transform .1s;
}

.cta > span {
  position: relative;
}

.cta:not(:disabled)::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -40%;
  width: 30%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .28), transparent);
  transform: skewX(-18deg);
  animation: shine 3.2s ease-in-out infinite;
}

.cta:active:not(:disabled) {
  box-shadow: 0 1px 0 var(--green-edge);
  transform: translateY(3px);
}

.cta:disabled {
  background: #232327;
  box-shadow: 0 4px 0 #18181b;
  color: #6c6c76;
}

.cta.waiting:disabled {
  color: #b9b9c2;
}

.cta-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  background: rgba(255, 255, 255, .07);
}

.cta-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.cta.busy:disabled {
  color: #d5d5db;
}

.cta.busy .cta-spinner {
  display: block;
}

/* --- Карточка анализа ------------------------------------------------------- */
.analysis {
  animation: rise .45s var(--ease);
}

.an-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.an-head .coin {
  width: 40px;
  height: 40px;
  border-radius: 11px;
}

.an-head .coin svg {
  width: 29px;
  height: 29px;
}

.an-title {
  flex: 1;
  min-width: 0;
}

.an-title b {
  display: block;
  font-size: 17px;
  font-weight: 700;
}

.status {
  display: flex;
  margin-top: 3px;
  white-space: nowrap;
}

.status i,
.status span {
  flex: none;
}

/* На узком экране название актива обрезается многоточием, а не переносится под шкалу */
.status em {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-style: normal;
  text-overflow: ellipsis;
}

.analysis[data-mode="scan"] .status {
  color: var(--blue);
}

.analysis[data-mode="result"] .status {
  color: var(--tone);
}

.gauge {
  position: relative;
  flex: none;
  width: 64px;
  height: 46px;
  text-align: center;
  transition: opacity .3s;
}

.gauge.off {
  opacity: 0;
}

.gauge svg {
  display: block;
  width: 64px;
  height: 36px;
}

.gauge path {
  fill: none;
  stroke-width: 5;
  stroke-linecap: round;
}

.gauge-track {
  stroke: #2a2a30;
}

.gauge-fill {
  stroke: var(--tone, var(--blue));
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset .3s linear, stroke .3s;
}

.gauge b {
  position: absolute;
  top: 15px;
  right: 0;
  left: 0;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.gauge small {
  position: absolute;
  top: 32px;
  right: 0;
  left: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
}

.chart {
  position: relative;
  height: 212px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 14px;
  background: var(--well);
}

.chart canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.corner {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid var(--blue);
  opacity: 0;
  transition: opacity .3s;
}

.corner.tl { top: 5px; left: 5px; border-right: 0; border-bottom: 0; border-top-left-radius: 6px; }
.corner.tr { top: 5px; right: 5px; border-bottom: 0; border-left: 0; border-top-right-radius: 6px; }
.corner.bl { bottom: 5px; left: 5px; border-top: 0; border-right: 0; border-bottom-left-radius: 6px; }
.corner.br { right: 5px; bottom: 5px; border-top: 0; border-left: 0; border-bottom-right-radius: 6px; }

.analysis[data-mode="scan"] .corner {
  opacity: 1;
  animation: blink 1.1s ease-in-out infinite;
}

.scan {
  margin-top: 12px;
}

.scan-text {
  display: block;
  color: #c9c9d1;
  font-size: 13px;
  font-weight: 600;
}

.scan-text.swap {
  animation: swap .3s var(--ease);
}

.scan-text::after {
  content: "...";
  display: inline-block;
  width: 0;
  overflow: hidden;
  vertical-align: bottom;
  animation: dots 1.2s steps(4, jump-none) infinite;
}

.scan-bar {
  height: 4px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 2px;
  background: #232327;
}

.scan-bar i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--blue), #7cc4ff);
  transition: width .2s linear;
}

/* --- Результат -------------------------------------------------------------- */
.verdict {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 12px;
  padding: 14px 14px 14px 16px;
  border: 1px solid var(--tone-line);
  border-radius: 16px;
  background: linear-gradient(135deg, var(--tone-a), var(--tone-b));
}

.analysis[data-direction="up"] {
  --tone: var(--green);
  --tone-a: rgba(61, 207, 124, .22);
  --tone-b: rgba(61, 207, 124, .07);
  --tone-line: rgba(61, 207, 124, .34);
  --tone-ring: rgba(61, 207, 124, .16);
}

.analysis[data-direction="down"] {
  --tone: var(--red);
  --tone-a: rgba(242, 92, 92, .22);
  --tone-b: rgba(242, 92, 92, .07);
  --tone-line: rgba(242, 92, 92, .34);
  --tone-ring: rgba(242, 92, 92, .16);
}

.verdict-arrow {
  display: grid;
  place-items: center;
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--tone);
  box-shadow: 0 0 0 6px var(--tone-ring);
  color: var(--bg);
}

.verdict-arrow svg {
  width: 24px;
  height: 24px;
}

.analysis[data-direction="down"] .verdict-arrow svg {
  transform: rotate(180deg);
}

.verdict-text {
  flex: 1;
  min-width: 0;
}

.verdict small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.verdict b {
  display: block;
  color: var(--tone);
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -.01em;
  line-height: 1.08;
}

.verdict p {
  margin: 2px 0 0;
  color: rgba(255, 255, 255, .72);
  font-size: 12.5px;
  line-height: 1.3;
}

.verdict-time {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .09);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.facts {
  display: grid;
  grid-template-columns: 1.35fr 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.facts div {
  min-width: 0;
  padding: 10px 11px;
  border-radius: 12px;
  background: var(--tile);
}

.facts small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.facts b {
  display: block;
  margin-top: 2px;
  font-size: 13.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.error {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  background: #33161a;
  color: #ffb9b9;
  font-size: 14px;
}

.error svg {
  flex: none;
  width: 22px;
  height: 22px;
  color: var(--red);
}

/* Что видно в каждом режиме карточки: scan — идёт анализ, result — сигнал, error — ошибка */
.analysis[data-mode="scan"] .result,
.analysis[data-mode="scan"] .error,
.analysis[data-mode="result"] .scan,
.analysis[data-mode="result"] .error,
.analysis[data-mode="error"] > :not(.error) {
  display: none;
}

.analysis.fresh .verdict {
  animation: pop .55s var(--ease);
}

.analysis.fresh .verdict-arrow {
  animation: ring 1.4s ease-out 2;
}

.analysis.fresh .facts {
  animation: rise .5s var(--ease);
}

/* --- Анимации --------------------------------------------------------------- */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
}

@keyframes pop {
  from { opacity: 0; transform: scale(.9); }
}

@keyframes ring {
  from { box-shadow: 0 0 0 0 var(--tone-line); }
  to { box-shadow: 0 0 0 16px transparent; }
}

@keyframes shine {
  0%, 55% { left: -40%; }
  100% { left: 120%; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

@keyframes swap {
  from { opacity: 0; transform: translateY(5px); }
}

@keyframes dots {
  to { width: .86em; }
}
