/* DS1: «только факты». Токены — как в «Перевод» (F:/Perevod/docs/DESIGN.md), тёмная тема.
   Контраст WCAG AA: #EEF2EA и #A4ADA1 на #151915 (15,7 и 7,7), #0D1A04 на #B8F26C (13,7),
   #0A0C0A на #EEF2EA (17,3). Лайм — одно главное действие на экран и активная вкладка.
   Шрифты на экране — три размера: 32 (главная цифра), 22 (суммы и заголовок), 15 (всё остальное).
   Движение — только transform/opacity; prefers-reduced-motion — без анимаций. */

@font-face {
  font-family: "Onest";
  src: url("/static/fonts/onest-regular.woff2") format("woff2"), url("/static/fonts/onest-regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Onest";
  src: url("/static/fonts/onest-semibold.woff2") format("woff2"), url("/static/fonts/onest-semibold.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "Unbounded";
  src: url("/static/fonts/unbounded-semibold.woff2") format("woff2"), url("/static/fonts/unbounded-semibold.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}

:root {
  --bg: #0A0C0A;
  --card: #151915;
  --card-hi: #1B201B;
  --tonal: #232A22;
  --text: #EEF2EA;
  --hint: #A4ADA1;
  --line: #272E26;
  --accent: #B8F26C;
  --on-accent: #0D1A04;
  --error: #FF8F86;
  --warn: #FFC27A;
  --ok: #8EE5B8;
  --shadow: #5E7F31;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --radius-card: 24px;
  --gap: 16px;
  --fs-xl: 32px;
  --fs-l: 22px;
  --fs-m: 15px;
  --font-body: "Onest", system-ui, sans-serif;
  --font-head: "Unbounded", "Onest", system-ui, sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-m);
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

.num,
.amt,
.hero-num {
  font-feature-settings: "tnum" 1;
  font-variant-numeric: tabular-nums;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) calc(var(--gap) + env(safe-area-inset-right))
    calc(104px + env(safe-area-inset-bottom)) calc(var(--gap) + env(safe-area-inset-left));
}

/* --- шапка ------------------------------------------------------------------------------ */
.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.title {
  margin: 0;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: var(--fs-l);
  line-height: 1.25;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--hint);
  white-space: nowrap;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--hint);
  opacity: 0.5;
}

.loading .dot {
  animation: pulse 1s ease-in-out infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.25; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1.15); }
}

/* --- потянуть вниз ------------------------------------------------------------------------ */
.ptr {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  left: 50%;
  z-index: 6;
  width: 36px;
  height: 36px;
  margin-left: -18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--tonal);
  opacity: 0;
  transform: translateY(-48px);
  pointer-events: none;
}

.ptr-ring {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--text);
}

.ptr.spin .ptr-ring {
  animation: spin 0.7s linear infinite;
}

.ptr.back {
  transition: transform 260ms var(--ease), opacity 260ms var(--ease);
}

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

/* --- кнопки ------------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  font: 600 var(--fs-m) / 1.2 var(--font-body);
  text-decoration: none;
  cursor: pointer;
  transition: transform 220ms var(--spring), box-shadow 220ms var(--spring);
}

.btn:active:not(:disabled) {
  transform: scale(0.95);
}

.btn:focus-visible,
.chip:focus-visible,
.tab:focus-visible,
.switch:focus-visible,
.mode:focus-visible,
summary:focus-visible,
.sel:focus-visible,
.calc-input:focus-visible {
  outline: 3px solid var(--text);
  outline-offset: 2px;
}

.btn.primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 5px 0 var(--shadow);
}

.btn.primary:active:not(:disabled) {
  box-shadow: 0 1px 0 var(--shadow);
}

.btn.tonal {
  background: var(--tonal);
  color: var(--text);
  box-shadow: 0 5px 0 #0F130F;
}

.btn.tonal:active:not(:disabled) {
  box-shadow: 0 1px 0 #0F130F;
}

.btn.text {
  min-height: 44px;
  padding: 0 10px;
  background: transparent;
  color: var(--hint);
}

.btn.small {
  min-height: 40px;
  padding: 0 16px;
}

.btn.wide {
  width: 100%;
}

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

.btn .i {
  width: 18px;
  height: 18px;
}

.i {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- общая сетка и карточки -------------------------------------------------------------- */
.content {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.content.swap-r { animation: swap-r 260ms var(--ease) both; }
.content.swap-l { animation: swap-l 260ms var(--ease) both; }

@keyframes swap-r {
  from { opacity: 0; transform: translateX(28px); }
  to { opacity: 1; transform: none; }
}

@keyframes swap-l {
  from { opacity: 0; transform: translateX(-28px); }
  to { opacity: 1; transform: none; }
}

.in {
  animation: rise 360ms var(--ease) both;
}

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

.card {
  position: relative;
  margin: 0;
  padding: 16px 18px;
  border-radius: var(--radius-card);
  background: var(--card);
}

.card h2,
.label {
  margin: 0 0 8px;
  color: var(--hint);
  font-size: var(--fs-m);
  font-weight: 600;
  line-height: 1.35;
}

.card ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.card li {
  padding: 9px 0;
  border-top: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.card li:first-child {
  border-top: 0;
}

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

.row > :first-child {
  flex: 1 1 12ch;
  min-width: 0;
}

.row .num {
  margin-left: auto;
  text-align: right;
}

.hint {
  margin: 4px 0 0;
  color: var(--hint);
}

.one {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.one.open {
  white-space: normal;
}

.warn {
  color: var(--error);
}

.state {
  margin: 0;
  padding: 16px 18px;
  border-radius: var(--radius-card);
  background: var(--card);
}

.state.error {
  color: var(--error);
}

/* --- главная цифра ------------------------------------------------------------------------ */
.hero {
  padding: 16px 18px;
  background: linear-gradient(160deg, #1B231A 0%, var(--card) 60%);
  overflow: hidden;
}

.hero-num {
  margin: 2px 0 6px;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: var(--fs-xl);
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.hero-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  margin: 0;
  color: var(--hint);
}

.hero-sub b {
  color: var(--text);
  font-weight: 600;
}

/* DS2: разбивка главной цифры по валютам — мелко под ≈ $ */
.hero-split {
  margin: -4px 0 6px;
  color: var(--hint);
  font-feature-settings: "tnum" 1;
}

/* DS2: «Мелочь · N» — свёрнутые карточки внутри одной строки */
.petty .grp-body {
  display: grid;
  gap: 8px;
  padding: 0 0 8px;
}

.petty .offer {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

/* --- лента: фильтры и карточки ----------------------------------------------------------- */
.chips {
  display: flex;
  gap: 8px;
  margin: 4px -16px 0;
  padding: 0 16px 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

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

.chip {
  flex: none;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: 600 var(--fs-m) / 1.2 var(--font-body);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: transform 220ms var(--spring);
}

.chip:active {
  transform: scale(0.95);
}

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

.chip .n {
  margin-left: 6px;
  opacity: 0.7;
}

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

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

.amt {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: var(--fs-l);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.amt.none {
  font-family: var(--font-body);
  font-size: var(--fs-m);
  color: var(--hint);
}

.risk {
  flex: none;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--tonal);
  white-space: nowrap;
}

.o-do {
  margin: 0;
  font-weight: 600;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  background: var(--tonal);
  color: var(--text);
  white-space: nowrap;
}

.pill .i {
  width: 16px;
  height: 16px;
  color: var(--hint);
}

.o-why {
  margin: 0;
  color: var(--hint);
}

.o-act {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 4px;
  padding-top: 4px;
}

.o-more {
  display: grid;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.o-more[hidden] {
  display: none;
}

.o-more p {
  margin: 0;
  overflow-wrap: anywhere;
}

.o-more .pre {
  white-space: pre-line;
}

.fresh::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid var(--text);
  opacity: 0;
  pointer-events: none;
  animation: glow 1.6s var(--ease) 0.3s 1;
}

@keyframes glow {
  0%, 100% { opacity: 0; }
  30% { opacity: 0.7; }
}

.steps {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.howto-step {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  overflow-wrap: anywhere;
}

.howto-step input {
  flex: none;
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--accent);
}

.steps-done {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}

.steps-done[hidden] {
  display: none;
}

.after {
  overflow-wrap: anywhere;
}

.marks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* --- скелеты (сдвиг блика transform-ом — без перерисовки) --------------------------------- */
.skel {
  position: relative;
  overflow: hidden;
  height: 18px;
  margin: 8px 0;
  border-radius: 9px;
  background: var(--tonal);
}

.skel.big {
  height: 34px;
  width: 62%;
}

.skel.short {
  width: 40%;
}

.skel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(238, 242, 234, 0.07), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.3s ease-in-out infinite;
}

@keyframes shimmer {
  to { transform: translateX(100%); }
}

/* --- нижнее меню ------------------------------------------------------------------------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 6px var(--gap) calc(6px + env(safe-area-inset-bottom));
  background: #0D100D;
  border-top: 1px solid var(--line);
}

.tab {
  flex: 1;
  max-width: 160px;
  min-height: 58px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: var(--hint);
  font: 600 var(--fs-m) / 1.2 var(--font-body);
  cursor: pointer;
  transition: transform 220ms var(--spring);
}

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

.tab:active {
  transform: scale(0.94);
}

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

/* --- «Деньги» ----------------------------------------------------------------------------- */
.seg {
  display: flex;
  gap: 8px;
  padding: 0 0 10px;
}

.chart {
  padding-top: 8px;
}

.bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 110px;
  transform-origin: bottom;
  animation: grow 520ms var(--ease) both;
}

@keyframes grow {
  from { transform: scaleY(0); }
  to { transform: none; }
}

.bar {
  flex: 1 1 0;
  min-width: 2px;
  border-radius: 3px 3px 0 0;
  background: var(--hint);
}

.bar.top {
  background: var(--accent);
}

.bar.zero {
  height: 2px;
  background: var(--line);
}

.axis {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding-top: 6px;
  color: var(--hint);
}

/* --- «Ещё» -------------------------------------------------------------------------------- */
.modes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mode {
  min-height: 52px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  color: var(--text);
  font: 600 var(--fs-m) / 1.2 var(--font-body);
  cursor: pointer;
  transition: transform 220ms var(--spring);
}

.mode:active:not(:disabled) {
  transform: scale(0.95);
}

.mode[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

.grp {
  padding: 0;
}

.grp > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 0 18px;
  list-style: none;
  cursor: pointer;
  font-weight: 600;
}

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

.grp > summary .sum-v {
  margin-left: auto;
  color: var(--hint);
  font-weight: 400;
}

.grp > summary .i {
  color: var(--hint);
  transition: transform 220ms var(--ease);
}

.grp[open] > summary .i {
  transform: rotate(90deg);
}

.grp-body {
  padding: 0 18px 12px;
}

.grp[open] .grp-body {
  animation: rise 260ms var(--ease) both;
}

.set .row {
  align-items: center;
}

.set .num {
  color: var(--hint);
}

.set .num.live {
  color: var(--error);
}

.lock-line {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--hint);
}

.lock-line .i {
  width: 16px;
  height: 16px;
}

.switch {
  position: relative;
  flex: none;
  width: 52px;
  height: 32px;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--tonal);
  cursor: pointer;
  transition: background-color 220ms;
}

.switch::before {
  content: "";
  position: absolute;
  inset: -8px 0;
}

.switch .knob {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--hint);
  transition: transform 220ms var(--spring);
}

.switch[aria-checked="true"] {
  background: var(--text);
}

.switch[aria-checked="true"] .knob {
  transform: translateX(20px);
  background: var(--bg);
}

.switch:disabled {
  opacity: 0.6;
}

.sel {
  flex: none;
  min-height: 40px;
  margin-left: auto;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--tonal);
  color: var(--text);
  font: 600 var(--fs-m) / 1.2 var(--font-body);
}

.links {
  display: grid;
  gap: 10px;
}

/* --- банер и знакомство ------------------------------------------------------------------- */
.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px 10px 10px 16px;
  border-radius: var(--radius-card);
  background: var(--tonal);
}

.banner[hidden],
.onb[hidden] {
  display: none;
}

.onb {
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow-y: auto;
  background: var(--bg);
}

.onb-inner {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-height: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--gap) + env(safe-area-inset-top)) var(--gap)
    calc(24px + env(safe-area-inset-bottom));
}

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

.progress i {
  height: 6px;
  border-radius: 999px;
  background: var(--tonal);
}

.progress i.on {
  background: var(--text);
}

.step {
  flex: 1;
  display: grid;
  align-content: start;
  gap: 12px;
}

.step.enter {
  animation: swap-r 320ms var(--ease) both;
}

.step h2 {
  margin: 8px 0 0;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: var(--fs-l);
  line-height: 1.3;
}

.step p {
  margin: 0;
}

.choices {
  display: grid;
  gap: 10px;
}

.choices .btn[aria-pressed="true"] {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.onb-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

/* --- калькулятор (CL1) --------------------------------------------------------------------- */
.calc {
  margin-top: 8px;
}

.calc-label {
  display: block;
}

.calc-input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.calc-out p {
  margin: 4px 0;
}

.calc-details {
  margin-top: 6px;
}

.calc-details > summary {
  min-height: 40px;
  padding-top: 8px;
  color: var(--hint);
  cursor: pointer;
}

@media (prefers-reduced-motion: no-preference) {
  .calc-out p {
    animation: fade 0.18s ease-out;
  }
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

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