/**
 * Оформление Mini App.
 *
 * Палитра «ночная сессия»: глубокий сине-чёрный фон, стальные панели,
 * один тёплый акцент. Золото закреплено за деньгами — итоговой суммой
 * и кнопкой оплаты; больше нигде акцента нет, чтобы взгляд шёл туда,
 * где принимается решение.
 *
 * Экран намеренно живёт в собственной тёмной теме, а не наследует тему
 * Telegram: это витрина, у неё должен быть узнаваемый вид. От Telegram
 * берём только безопасные отступы.
 */

:root {
  --void: #0b1119;
  --panel: #131c28;
  --panel-soft: #18222f;
  --line: #1f2d3d;
  --text: #e6edf6;
  --muted: #7a8aa0;
  --gold: #f5b544;
  --gold-press: #d99a2b;
  --danger: #ff6b6b;
  --ok: #5fd08a;

  --radius: 10px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--void);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

.screen {
  min-height: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
}

.form {
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: calc(100vh - 36px);
}

/* ----------------------------------------------------------- аккаунт */

.account { display: grid; gap: 8px; }

.account__label,
.amount__label {
  color: var(--muted);
  font-size: 13px;
}

.account__field { position: relative; }

.account__field input {
  width: 100%;
  padding: 15px 44px 15px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 16px; /* меньше 16px — iOS зумит страницу при фокусе */
}

.account__field input::placeholder { color: #55657a; }

/* Индикатор проверки логина: цвет — не единственный носитель смысла,
   рядом всегда есть текстовая подпись в .account__note */
.account__state {
  position: absolute;
  top: 50%;
  right: 14px;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
}

.account__state--checking::after,
.account__state--found::after,
.account__state--missing::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
}

.account__state--checking::after {
  border: 2px solid var(--line);
  border-top-color: var(--muted);
  animation: spin .7s linear infinite;
}

.account__state--found::after { background: var(--ok); }
.account__state--missing::after { background: var(--danger); }

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

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

.account__note {
  margin: 0;
  min-height: 18px;
  font-size: 13px;
  color: var(--muted);
}

.account__note--found { color: var(--ok); }
.account__note--missing { color: var(--danger); }

.account__save {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 14px;
}

.account__save input { accent-color: var(--gold); width: 17px; height: 17px; }

/* ------------------------------------------------------------- сумма */

.amount { display: grid; gap: 12px; }

.amount__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Сумма — герой экрана: не поле в рамке, а крупная цифра,
   вокруг которой принимается решение */
.amount__figure {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  padding: 6px 0 10px;
  border-bottom: 1px solid var(--line);
}

.amount__figure input {
  width: 100%;
  max-width: 230px;
  padding: 0;
  border: none;
  background: none;
  color: var(--text);
  font-family: Unbounded, Inter, sans-serif;
  font-weight: 600;
  font-size: 44px;
  letter-spacing: -0.02em;
  text-align: right;
}

.amount__figure input:focus { outline: none; }
.amount__figure:focus-within { border-bottom-color: var(--gold); }

.amount__sign {
  font-family: Unbounded, Inter, sans-serif;
  font-size: 26px;
  color: var(--muted);
}

.switch {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--panel);
  border-radius: 8px;
}

.switch button {
  min-width: 40px;
  padding: 6px 0;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

.switch button[aria-pressed='true'] { background: var(--panel-soft); color: var(--text); }

.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }

.chips button {
  padding: 11px 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}

.chips button[aria-pressed='true'] { border-color: var(--gold); color: var(--text); }

/* -------------------------------------------------------------- итог */

/* Разделители вместо карточки: строки итога — это данные,
   а не отдельный блок интерфейса */
.total { display: grid; gap: 10px; }

.total__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--muted);
  font-size: 14px;
}

.total__row--main {
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--text);
  font-size: 15px;
}

.total__row--main strong {
  font-family: Unbounded, Inter, sans-serif;
  font-weight: 600;
  font-size: 21px;
  color: var(--gold);
}

.error { margin: 0; color: var(--danger); font-size: 14px; }

/* ------------------------------------------------------------ кнопка */

.actions { margin-top: auto; display: grid; gap: 10px; }

.cta {
  width: 100%;
  padding: 17px;
  border: none;
  border-radius: var(--radius);
  background: var(--gold);
  color: #241a06;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

.cta:active { background: var(--gold-press); }

.cta:disabled {
  background: var(--panel-soft);
  color: var(--muted);
  cursor: default;
}

.actions__note {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

/* Клавиатурный фокус виден везде одинаково */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
