@font-face {
  font-family: "Onest";
  src: url("/assets/onest-cyr.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "Onest";
  src: url("/assets/onest-lat.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Одна гарнитура, один акцент. Нейтрали — как у iOS, акцент — насыщенный синий. */
:root {
  --bg: #f2f2f6;
  --surface: #ffffff;
  --surface-2: #e9e9ef;
  --ink: #0b0b0f;
  --muted: #6b6b76;
  --line: rgba(11, 11, 15, 0.08);
  --accent: #1f66ff;
  --accent-ink: #ffffff;
  --accent-soft: rgba(31, 102, 255, 0.1);
  --positive: #0f9d58;
  --positive-soft: rgba(15, 157, 88, 0.12);
  --danger: #e0352b;
  --danger-soft: rgba(224, 53, 43, 0.1);
  --warn: #a86400;
  --warn-soft: rgba(255, 166, 0, 0.16);
  --plastic-ink: #f5f5f7;
  --plastic-dark: linear-gradient(152deg, #2a2a30 0%, #141418 48%, #060608 100%);
  --plastic-blue: linear-gradient(152deg, #5b95ff 0%, #2667f5 46%, #1442c2 100%);
  --shadow: 0 1px 2px rgba(11, 11, 15, 0.04), 0 10px 30px -18px rgba(11, 11, 15, 0.18);
  --font: "Onest", -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

:root[data-theme="dark"] {
  --bg: #09090b;
  --surface: #141418;
  --surface-2: #1f1f25;
  --ink: #f4f4f7;
  --muted: #8d8d98;
  --line: rgba(255, 255, 255, 0.07);
  --accent: #3b7bff;
  --accent-soft: rgba(59, 123, 255, 0.16);
  --positive: #3ccf86;
  --positive-soft: rgba(60, 207, 134, 0.14);
  --danger: #ff5c52;
  --danger-soft: rgba(255, 92, 82, 0.14);
  --warn: #ffb547;
  --warn-soft: rgba(255, 181, 71, 0.13);
  --shadow: none;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: -0.006em;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

input,
button {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

p,
h1,
h2,
h3,
dl,
dd,
ol,
ul,
figure {
  margin: 0;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.noscript {
  padding: 24px;
  text-align: center;
}

/* ------------------------------------------------------------ каркас */

.app {
  position: relative;
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 14px 16px calc(104px + var(--safe-bottom));
}

.view.no-tabs {
  padding-bottom: calc(32px + var(--safe-bottom));
}

.view > * {
  animation: rise 0.44s var(--ease) both;
}

.view > *:nth-child(2) { animation-delay: 0.05s; }
.view > *:nth-child(3) { animation-delay: 0.1s; }
.view > *:nth-child(4) { animation-delay: 0.15s; }
.view > *:nth-child(n + 5) { animation-delay: 0.2s; }

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

.icon {
  display: inline-flex;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
}

.icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.display {
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.num,
.cents {
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--muted);
  text-wrap: pretty;
}

.small {
  font-size: 13px;
  line-height: 1.45;
}

/* ---------------------------------------------------------- панель */

.tabs {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: flex;
  max-width: 480px;
  margin: 0 auto;
  padding: 6px 10px calc(6px + var(--safe-bottom));
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  border-top: 1px solid var(--line);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  backdrop-filter: blur(20px) saturate(1.6);
}

.tab {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 3px;
  align-items: center;
  min-height: 54px;
  padding: 7px 4px 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  background: none;
  border: 0;
  border-radius: 14px;
  transition: color 0.2s;
}

.tab .icon {
  width: 24px;
  height: 24px;
}

.tab[aria-current="page"] {
  color: var(--accent);
}

.tab[aria-current="page"] .icon svg {
  stroke-width: 2.2;
}

/* --------------------------------------------------------- главная */

.top {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: -10px;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 10px;
}

.brand__mark .icon {
  width: 18px;
  height: 18px;
}

.badge {
  padding: 6px 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.hero {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.hero__art {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1180 / 501;
  object-fit: cover;
}

.hero__body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px 20px;
}

.hero__label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.hero__balance {
  font-size: clamp(44px, 14vw, 60px);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.05em;
}

.hero__balance .cents {
  color: var(--muted);
  font-size: 0.5em;
  letter-spacing: -0.02em;
}

.quick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.quick .btn {
  padding: 0 12px;
  white-space: nowrap;
}

/* ---------------------------------------------------------- секции */

.bar {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  margin-bottom: -6px;
}

.bar__back {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 40px;
  height: 40px;
  color: var(--ink);
  background: var(--surface-2);
  border: 0;
  border-radius: 50%;
}

.bar__title {
  font-size: 30px;
}

.section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.section h2 {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.section__head {
  display: flex;
  gap: 12px;
  align-items: baseline;
  justify-content: space-between;
}

.section .section__title {
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.section__link {
  padding: 0;
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  background: none;
  border: 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.strip {
  display: flex;
  gap: 12px;
  margin: 0 -16px;
  padding: 2px 16px 18px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding: 0 16px;
  scrollbar-width: none;
}

.strip::-webkit-scrollbar {
  display: none;
}

.strip > * {
  flex: 0 0 84%;
  max-width: 340px;
  scroll-snap-align: start;
}

.strip > *:only-child {
  flex-basis: 100%;
  max-width: none;
}

/* ------------------------------------------------------------ карта */

.plastic {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;
  aspect-ratio: 1.586;
  padding: 18px 20px;
  overflow: hidden;
  color: var(--plastic-ink);
  text-align: left;
  background: var(--plastic-dark);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 22px;
  box-shadow: 0 22px 40px -24px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  isolation: isolate;
}

button.plastic {
  transition: transform 0.2s var(--ease);
}

button.plastic:active {
  transform: scale(0.98);
}

.plastic::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.07) 46%, transparent 62%);
  content: "";
}

.plastic--pearl {
  background: var(--plastic-blue);
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: 0 22px 40px -24px rgba(20, 66, 194, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.plastic__row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.plastic__row--end {
  align-items: flex-end;
}

.plastic__brand {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.plastic__chip {
  width: 40px;
  height: 30px;
  background:
    linear-gradient(90deg, transparent 31%, rgba(0, 0, 0, 0.18) 32%, rgba(0, 0, 0, 0.18) 34%, transparent 35%, transparent 65%, rgba(0, 0, 0, 0.18) 66%, rgba(0, 0, 0, 0.18) 68%, transparent 69%),
    linear-gradient(0deg, transparent 48%, rgba(0, 0, 0, 0.18) 49%, rgba(0, 0, 0, 0.18) 52%, transparent 53%),
    linear-gradient(135deg, #e9e9ee 0%, #b9b9c2 55%, #8e8e98 100%);
  border-radius: 7px;
}

.plastic__number {
  font-size: 17px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.plastic__label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  opacity: 0.62;
}

.plastic__value {
  display: block;
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.plastic__value .cents {
  opacity: 0.6;
  font-size: 0.72em;
}

.plastic__net svg {
  display: block;
  width: 52px;
  height: 52px;
  margin: -14px -4px -14px 0;
  fill: currentColor;
}

.pill {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
}

/* ----------------------------------------------------------- списки */

.list {
  margin: 0;
  padding: 0;
  overflow: hidden;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

fieldset.list {
  min-width: 0;
}

.row {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 64px;
  padding: 12px 16px;
  text-align: left;
  background: none;
  border: 0;
  border-top: 1px solid var(--line);
}

.row:first-child {
  border-top: 0;
}

.row > .icon {
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.row__badge {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 40px;
  height: 40px;
  color: var(--positive);
  background: var(--positive-soft);
  border-radius: 50%;
}

.row__badge .icon {
  width: 20px;
  height: 20px;
}

.row__badge--out {
  color: var(--ink);
  background: var(--surface-2);
}

.row__main {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.row__title {
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.012em;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.row__sub {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.row__value {
  flex-shrink: 0;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.row__value--in {
  color: var(--positive);
}

.row__value--bad {
  color: var(--danger);
}

.kv {
  display: flex;
  gap: 16px;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
}

.kv:first-child {
  border-top: 0;
}

.kv dt {
  flex-shrink: 0;
  color: var(--muted);
}

.kv dd {
  min-width: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  overflow-wrap: anywhere;
}

.kv--total dt {
  color: var(--ink);
  font-weight: 500;
}

.kv--total dd {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.secret {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.copy {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 0;
  border-radius: 10px;
}

.copy .icon {
  width: 16px;
  height: 16px;
}

.timer {
  height: 4px;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: 2px;
}

.timer__fill {
  height: 100%;
  background: var(--accent);
  transform-origin: left;
  transition: transform 1s linear;
}

/* ----------------------------------------------------------- кнопки */

.btn {
  position: relative;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 54px;
  padding: 0 20px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.015em;
  border: 0;
  border-radius: 16px;
  transition: transform 0.15s var(--ease), opacity 0.15s;
}

.btn .icon {
  width: 20px;
  height: 20px;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  cursor: default;
  opacity: 0.55;
}

.btn--primary {
  color: var(--accent-ink);
  background: var(--accent);
}

.btn--sun {
  color: var(--bg);
  background: var(--ink);
}

.btn--plain {
  color: var(--ink);
  background: var(--surface-2);
}

.btn--soft {
  color: var(--accent);
  background: var(--accent-soft);
}

.btn.is-busy .icon {
  display: none;
}

.btn.is-busy::before {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  content: "";
}

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

.actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 10px;
}

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

.amount {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 20px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s;
}

.amount:focus-within {
  border-color: var(--accent);
}

.amount__label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.amount__field {
  display: flex;
  gap: 2px;
  align-items: baseline;
  font-size: 52px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.05em;
}

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

.amount__field input {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 0;
  font-variant-numeric: tabular-nums;
  background: none;
  border: 0;
  outline: none;
}

.amount__field input::placeholder {
  color: var(--muted);
  opacity: 0.4;
}

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

.chip {
  padding: 10px 4px;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: background 0.15s, color 0.15s;
}

.chip[aria-pressed="true"] {
  color: var(--bg);
  background: var(--ink);
  border-color: var(--ink);
}

.option {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  cursor: pointer;
  border-top: 1px solid var(--line);
}

.option:first-of-type {
  border-top: 0;
}

.option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.option__mark {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 24px;
  height: 24px;
  color: transparent;
  border: 2px solid var(--surface-2);
  border-radius: 50%;
  transition: background 0.15s, border-color 0.15s;
}

.option input:checked + .option__mark {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

.option input:focus-visible + .option__mark {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.option__mark .icon {
  width: 14px;
  height: 14px;
}

.option__mark svg {
  stroke-width: 3.2;
}

/* -------------------------------------------------------- подсказки */

.note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.45;
  background: var(--surface-2);
  border-radius: 16px;
  text-wrap: pretty;
}

.note .icon {
  width: 20px;
  height: 20px;
  color: var(--muted);
}

.note--sun {
  background: var(--warn-soft);
}

.note--sun .icon {
  color: var(--warn);
}

.note--danger {
  background: var(--danger-soft);
}

.note--danger .icon {
  color: var(--danger);
}

.rules,
.fold__body ul,
.fold__body ol {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-left: 20px;
}

.rules {
  padding: 18px 18px 18px 36px;
  font-size: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
}

.rules li::marker,
.fold__body li::marker {
  color: var(--muted);
}

.fold {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.fold summary {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 18px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.015em;
  list-style: none;
  cursor: pointer;
}

.fold summary::-webkit-details-marker {
  display: none;
}

.fold summary .icon {
  width: 18px;
  height: 18px;
  color: var(--muted);
  transition: transform 0.2s var(--ease);
}

.fold[open] summary .icon {
  transform: rotate(90deg);
}

.fold__body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 18px 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-line;
  text-wrap: pretty;
}

/* -------------------------------------------------------- состояния */

.empty {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  padding: 20px 20px 24px;
  color: var(--muted);
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
}

.empty__art {
  width: 72%;
  max-width: 280px;
  height: auto;
}

.result {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 28px;
  text-align: center;
}

.result > p {
  color: var(--muted);
  text-wrap: pretty;
}

.result .list {
  text-align: left;
}

.result__art {
  width: 66%;
  max-width: 260px;
  height: auto;
  margin: 0 auto;
}

.result__title {
  font-size: 30px;
}

.result__badge {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin: 0 auto 6px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 50%;
}

.result__badge .icon {
  width: 34px;
  height: 34px;
}

.skeleton {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.skeleton div {
  height: 72px;
  background: var(--surface-2);
  border-radius: 20px;
  animation: pulse 1.2s ease-in-out infinite alternate;
}

.skeleton div:first-child {
  height: 300px;
  border-radius: 28px;
}

@keyframes pulse {
  to {
    opacity: 0.45;
  }
}

.toast {
  position: fixed;
  bottom: calc(96px + var(--safe-bottom));
  left: 50%;
  z-index: 30;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  background: var(--ink);
  border-radius: 14px;
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s, transform 0.25s var(--ease);
}

.toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}

.foot {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

@media (min-width: 520px) {
  .app {
    border-right: 1px solid var(--line);
    border-left: 1px solid var(--line);
  }
}

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