/* ============================================================
   Tandri — мини-апп для пары. Розовая, мягкая, карточная тема.
   ============================================================ */

/* Self-hosted fonts (SIL OFL, see fonts/OFL-*.txt): no requests to Google. */
@font-face {
  font-family: 'Manrope'; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url(../fonts/manrope-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Manrope'; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url(../fonts/manrope-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Manrope'; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url(../fonts/manrope-latin.woff2) format('woff2');
  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;
}
@font-face {
  font-family: 'Pacifico'; font-style: normal; font-weight: 400; font-display: swap;
  src: url(../fonts/pacifico-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Pacifico'; font-style: normal; font-weight: 400; font-display: swap;
  src: url(../fonts/pacifico-latin.woff2) format('woff2');
  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;
}

:root {
  color-scheme: light;
  --bg: #FDF0F3;
  --bg-top: #FFF6F8;
  --panel: #FFFFFF;
  --panel-soft: #FFF7F9;

  --text: #2F2A2E;
  --text-2: #6C5C63;
  --muted: #A6959C;

  --pink: #EE6183;
  --pink-deep: #E2456B;
  --pink-soft: #FFDFE8;
  --pink-tint: #FFEFF3;
  --pink-grad: linear-gradient(135deg, #F0728F 0%, #E2456B 100%);
  --hero-grad: linear-gradient(135deg, #FFE6EC 0%, #FFD3DF 55%, #FFC9D8 100%);

  --green: #3FA877;
  --red: #D93A3A;
  --line: rgba(var(--shadow-rgb), 0.09);
  --shadow-sm: 0 2px 10px rgba(var(--shadow-rgb), 0.05);
  --shadow: 0 8px 24px rgba(var(--shadow-rgb), 0.08);
  --shadow-lg: 0 14px 34px rgba(var(--shadow-rgb), 0.16);

  --r-lg: 26px;
  --r-md: 20px;
  --r-sm: 14px;

  --safe-b: env(safe-area-inset-bottom, 0px);
  /* видимая высота приложения: в Telegram её задаёт скрипт из viewportStableHeight,
     потому что окно мини-аппа ниже, чем 100vh, и низ шторки уезжал за экран */
  --app-h: 100vh;

  --hero-text: #7A4653;
  --hero-text-2: #9A6B76;
  --hero-amount: #2F2A2E;
  --hero-chip: rgba(255, 255, 255, 0.72);
  --hero-art: rgba(255, 255, 255, 0.55);
  --muted-2: #DCC9CF;
  --divider: #EDDFE3;
  --scrim: rgba(28, 20, 24, 0.94);
  --scrim-soft: rgba(47, 42, 46, 0.45);
  --toast-bg: rgba(47, 42, 46, 0.92);
  --bg-wide: #F6E7EC;
  --bg-bottom: #FCE9EE;
  --shadow-rgb: 226, 69, 107;
}

/* палитра «кружков» категорий/иконок */
.ic-c0 { background: #FFDDE6; color: #E2456B; }
.ic-c1 { background: #FFE7D3; color: #DE8B3C; }
.ic-c2 { background: #E8E2FB; color: #7B69D6; }
.ic-c3 { background: #D8F1E3; color: #35A06E; }
.ic-c4 { background: #DBE8FC; color: #4A82D6; }
.ic-c5 { background: #FBECCC; color: #C4952B; }
.ic-rose { background: var(--pink-soft); color: var(--pink-deep); }
.ic-white { background: rgba(255, 255, 255, 0.7); color: var(--pink-deep); }

@supports (height: 100dvh) {
  :root { --app-h: 100dvh; }
}

/* ============================================================
   Тёмная тема

   Приложение читает тему Telegram (tg.colorScheme) и ставит data-theme на
   <html>; в профиле её можно закрепить светлой или тёмной. Медиа-запрос нужен
   для случая «открыли с иконки, без Telegram» — там тему задаёт система.
   Все цвета описаны токенами, поэтому здесь переопределяются только они.
   ============================================================ */

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171114;
  --bg-top: #1E1619;
  --bg-wide: #120D10;
  --bg-bottom: #1B1317;
  --panel: #241B20;
  --panel-soft: #2C2127;

  --text: #F5EBEE;
  --text-2: #C5B2B9;
  --muted: #98858C;
  --muted-2: #5C4A51;

  --pink: #FF7E9E;
  --pink-deep: #FF9BB4;
  --red: #FF7A70;
  --pink-soft: #4A2632;
  --pink-tint: #33202A;
  --pink-grad: linear-gradient(135deg, #E9557B 0%, #C93A61 100%);
  --hero-grad: linear-gradient(135deg, #3E2530 0%, #4C2B39 55%, #5A3141 100%);
  --hero-text: #F3D3DC;
  --hero-text-2: #C39EAB;
  --hero-amount: #FBEFF2;
  --hero-chip: rgba(255, 255, 255, 0.12);
  --hero-art: rgba(255, 255, 255, 0.16);

  --green: #74C79A;
  --line: rgba(255, 255, 255, 0.08);
  --divider: #3A2C32;
  --scrim: rgba(8, 5, 6, 0.94);
  --scrim-soft: rgba(8, 5, 6, 0.55);
  --toast-bg: rgba(58, 45, 51, 0.96);

  /* на тёмном фоне розовая тень выглядит грязным ореолом — тень чёрная */
  --shadow-rgb: 0, 0, 0;
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.3);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.38);
  --shadow-lg: 0 14px 34px rgba(0, 0, 0, 0.5);
}

/* кружки категорий: те же шесть оттенков, но приглушённые под тёмный фон */
:root[data-theme="dark"] .ic-c0 { background: #4A2530; color: #FF9DB4; }
:root[data-theme="dark"] .ic-c1 { background: #4A3221; color: #F0AE6E; }
:root[data-theme="dark"] .ic-c2 { background: #322A4C; color: #A896EE; }
:root[data-theme="dark"] .ic-c3 { background: #1F3A2C; color: #6ECB9B; }
:root[data-theme="dark"] .ic-c4 { background: #22334C; color: #7FADEE; }
:root[data-theme="dark"] .ic-c5 { background: #40361D; color: #DDBB63; }
:root[data-theme="dark"] .ic-white { background: rgba(255, 255, 255, 0.1); color: var(--pink-deep); }

/* вне Telegram тему задаёт система — но только пока её не закрепили руками */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;
    --bg: #171114;
    --bg-top: #1E1619;
    --bg-wide: #120D10;
    --bg-bottom: #1B1317;
    --panel: #241B20;
    --panel-soft: #2C2127;
    --text: #F5EBEE;
    --text-2: #C5B2B9;
    --muted: #98858C;
    --muted-2: #5C4A51;
    --pink: #FF7E9E;
    --pink-deep: #FF9BB4;
    --red: #FF7A70;
    --pink-soft: #4A2632;
    --pink-tint: #33202A;
    --pink-grad: linear-gradient(135deg, #E9557B 0%, #C93A61 100%);
    --hero-grad: linear-gradient(135deg, #3E2530 0%, #4C2B39 55%, #5A3141 100%);
    --hero-text: #F3D3DC;
    --hero-text-2: #C39EAB;
    --hero-amount: #FBEFF2;
    --hero-chip: rgba(255, 255, 255, 0.12);
    --hero-art: rgba(255, 255, 255, 0.16);
    --green: #74C79A;
    --line: rgba(255, 255, 255, 0.08);
    --divider: #3A2C32;
    --scrim: rgba(8, 5, 6, 0.94);
    --scrim-soft: rgba(8, 5, 6, 0.55);
    --toast-bg: rgba(58, 45, 51, 0.96);
    --shadow-rgb: 0, 0, 0;
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.3);
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.38);
    --shadow-lg: 0 14px 34px rgba(0, 0, 0, 0.5);
  }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .ic-c0 { background: #4A2530; color: #FF9DB4; }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .ic-c1 { background: #4A3221; color: #F0AE6E; }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .ic-c2 { background: #322A4C; color: #A896EE; }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .ic-c3 { background: #1F3A2C; color: #6ECB9B; }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .ic-c4 { background: #22334C; color: #7FADEE; }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .ic-c5 { background: #40361D; color: #DDBB63; }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .ic-white { background: rgba(255, 255, 255, 0.1); color: var(--pink-deep); }
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  /* вбок страницу не двигаем — при вводе текста её уводило горизонтально */
  overflow-x: hidden;
  max-width: 100%;
  touch-action: pan-y;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg) 40%, var(--bg-bottom) 100%);
  z-index: -1;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

.hidden { display: none !important; }

button { font: inherit; color: inherit; cursor: pointer; }

/* ============================================================
   Общие элементы
   ============================================================ */

.btn {
  border: none;
  border-radius: 999px;
  padding: 15px 20px;
  font-weight: 700;
  font-size: 15px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:active { transform: scale(0.975); }

.btn-primary {
  background: var(--pink-grad);
  color: #fff;
  box-shadow: 0 10px 22px rgba(var(--shadow-rgb), 0.28);
}
.btn-ghost { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }
.btn-plain { background: none; border: none; color: var(--muted); font-size: 14px; font-weight: 600; padding: 12px; }
.btn-wide { width: 100%; }
.btn-icon { display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-icon svg { width: 19px; height: 19px; }

.field {
  width: 100%;
  background: var(--panel-soft);
  border: 1.5px solid transparent;
  border-radius: var(--r-sm);
  padding: 14px 16px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.field::placeholder { color: var(--muted); }
.field:focus { border-color: var(--pink-soft); background: var(--panel); }
textarea.field { resize: none; line-height: 1.5; }
/* нативная дата в webkit шире контейнера — прижимаем к рамке */
input.field[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;
  max-width: 100%;
  display: block;
}
input.field[type="date"]::-webkit-date-and-time-value { text-align: left; margin: 0; }
input.field[type="date"]::-webkit-calendar-picker-indicator { margin: 0; opacity: 0.55; }
.field-title { font-weight: 700; font-size: 16px; }
.field-code {
  text-align: center;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 700;
  font-size: 17px;
}

.mini-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.01em;
}
.mini-sub { font-size: 11.5px; color: var(--muted); font-weight: 500; }

.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--pink-deep);
  font-size: 13px;
  font-weight: 700;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 2px -4px;
}
.section-head h3 { margin: 0; font-size: 15.5px; font-weight: 800; letter-spacing: -0.01em; }

.ic-circle {
  width: 44px; height: 44px;
  min-width: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  line-height: 1;
}
.ic-circle svg { width: 22px; height: 22px; }
.ic-lg { width: 48px; height: 48px; min-width: 48px; }
.ic-sq {
  width: 42px; height: 42px; min-width: 42px;
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px;
}
.ic-sq svg { width: 22px; height: 22px; }
/* line icons inline with text (chips, badges) */
.cat-chip svg, .pill svg, .todo-label-badge svg { width: 1.3em; height: 1.3em; vertical-align: -0.3em; flex-shrink: 0; }

.avatar {
  border-radius: 50%;
  background: var(--pink-soft);
  color: var(--pink-deep);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid #fff;
  box-shadow: var(--shadow-sm);
  padding: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-xs { width: 28px; height: 28px; font-size: 11px; border-width: 1.5px; }
.avatar-sm { width: 34px; height: 34px; font-size: 13px; }
.avatar-md { width: 46px; height: 46px; font-size: 17px; }
.avatar-xl { width: 84px; height: 84px; font-size: 30px; border-width: 3px; }

.empty {
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  padding: 28px 20px;
  line-height: 1.5;
}
.empty .emo { display: block; font-size: 26px; margin-bottom: 8px; }

/* ============================================================
   Экраны пары / ожидания
   ============================================================ */

#screen-splash {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#screen-consent, #screen-pairing, #screen-waiting {
  padding: 64px 24px calc(28px + var(--safe-b));
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.pairing-hero { text-align: center; }
.pairing-mark { font-size: 26px; color: var(--pink); }
.pairing-logo {
  font-family: 'Pacifico', cursive;
  font-size: 46px;
  color: var(--pink-deep);
  margin: 6px 0 14px;
  line-height: 1.15;
}
.logo-heart { font-family: 'Manrope', sans-serif; font-size: 0.42em; vertical-align: 0.55em; margin-left: 3px; }
.pairing-sub {
  color: var(--text-2);
  font-size: 15px;
  line-height: 1.55;
  max-width: 320px;
  margin: 0 auto;
}

.pairing-actions { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }

/* separate class, not .pairing-logo: e2e tests locate the pairing screen by it */
.consent-title {
  font-family: 'Pacifico', cursive;
  font-size: 40px;
  color: var(--pink-deep);
  margin: 6px 0 14px;
  line-height: 1.15;
}
.consent-check {
  display: flex; gap: 12px; align-items: flex-start;
  font-size: 14px; line-height: 1.5; color: var(--text-2);
  padding: 12px 14px; border-radius: var(--r-sm); background: var(--panel); box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.consent-check input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--pink-deep); }
.consent-check a { color: var(--pink-deep); }
.consent-age { text-align: center; font-size: 12px; color: var(--muted); }

.pairing-divider {
  display: flex; align-items: center;
  color: var(--muted); font-size: 13px; margin: 2px 0;
}
.pairing-divider::before, .pairing-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.pairing-divider span { padding: 0 12px; }

.code-card {
  margin-top: 34px;
  padding: 22px 20px;
  background: var(--panel);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  text-align: center;
}
.code {
  display: block;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--pink-deep);
  margin: 8px 0 16px;
}
.settings-card .code { margin-bottom: 0; }

.waiting-status { text-align: center; color: var(--muted); font-size: 14px; margin-top: 22px; }
.waiting-status::after {
  content: "";
  display: inline-block;
  width: 6px; height: 6px; margin-left: 7px;
  border-radius: 50%;
  background: var(--pink);
  animation: pulse 1.2s ease-in-out infinite;
  vertical-align: middle;
}
@keyframes pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
#btn-preview-solo { margin-top: auto; }

/* ============================================================
   Каркас главного экрана
   ============================================================ */

#views {
  flex: 1;
  padding: 14px 18px calc(120px + var(--safe-b));
  overflow-x: hidden;
}
.view { display: flex; flex-direction: column; gap: 14px; }
/* браузер не пересчитывает раскладку всей страницы из-за одной строки списка */
.tx-item, .note-item, .todo-item, .event-item, .plan-item { contain: layout; }
/* анимацию вешает switchView отдельным классом — так её видно только при
   смене вкладки, а не на каждой перерисовке содержимого */
.view.anim-in { animation: fade-up 0.22s ease; }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- шапка страницы (Бюджет / Календарь / ...) ---------- */

.page-head {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  padding: 4px 0 2px;
}
.page-title { margin: 0; text-align: center; font-size: 18px; font-weight: 800; letter-spacing: -0.01em; }
.icon-btn {
  width: 40px; height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:active { transform: scale(0.94); }
.icon-btn-ghost { background: none; box-shadow: none; }
.icon-btn-sm { width: 30px; height: 30px; }
.icon-btn-sm svg { width: 16px; height: 16px; }
