/* ============================================
   Lunora — Telegram Mini App
   Дизайн-система + компоненты
   ============================================ */

/* ---------- Переменные темы ---------- */
:root[data-theme="dark"] {
  --bg:            #1A1840;
  --bg-elev:       #1F1D47;
  --surface:       #252350;
  --surface-2:     #2D2B5C;
  --border:        rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --primary:       #7B6FC4;
  --primary-soft:  rgba(123, 111, 196, 0.18);
  --gold:          #F5C842;
  --gold-soft:     rgba(245, 200, 66, 0.15);
  --blue:          #8EC6F0;
  --blue-soft:     rgba(142, 198, 240, 0.15);
  --teal:          #4ECDC4;
  --teal-soft:     rgba(78, 205, 196, 0.18);
  --text:          #F0EFF8;
  --text-muted:    #9B99C4;
  --danger:        #E57373;
  --success:       #7BD389;
  --shadow:        0 2px 10px rgba(0, 0, 0, 0.18);
  --shadow-lg:     0 6px 24px rgba(0, 0, 0, 0.28);
  --gradient-card: linear-gradient(155deg, rgba(123, 111, 196, 0.22) 0%, rgba(37, 35, 80, 0.0) 55%);
  --nav-bg:        rgba(26, 24, 64, 0.85);
  --header-bg:     rgba(26, 24, 64, 0.78);
  --track:         rgba(255, 255, 255, 0.06);
  --input-bg:      rgba(255, 255, 255, 0.05);
  --backdrop:      rgba(5, 4, 20, 0.55);
}

:root[data-theme="light"] {
  /* Фон — очень светлый лаванд, как у референса */
  --bg:            #F0EEFF;
  --bg-elev:       #E8E4FA;
  --surface:       #FFFFFF;
  --surface-2:     #F7F5FF;
  --border:        rgba(100, 90, 180, 0.10);
  --border-strong: rgba(100, 90, 180, 0.18);
  /* Фиолетовый — чуть насыщеннее, чище */
  --primary:       #7C6FD4;
  --primary-soft:  rgba(124, 111, 212, 0.11);
  /* Золотой — убираем коричневатость, делаем тёплый солнечный */
  --gold:          #F5B800;
  --gold-soft:     rgba(245, 184, 0, 0.13);
  --blue:          #60A8E0;
  --blue-soft:     rgba(96, 168, 224, 0.12);
  --teal:          #3DBDB5;
  --teal-soft:     rgba(61, 189, 181, 0.15);
  --text:          #1E1A45;
  /* #655E9A: контраст 5.80:1 на белом, 5.08:1 на фоне — проходит WCAG AA */
  --text-muted:    #655E9A;
  --danger:        #E05C5C;
  --success:       #4DB868;
  --shadow:        0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg:     0 6px 20px rgba(0, 0, 0, 0.12);
  --gradient-card: linear-gradient(155deg, rgba(124, 111, 212, 0.08) 0%, rgba(255,255,255,0) 60%);
  --nav-bg:        rgba(240, 238, 255, 0.95);
  --header-bg:     rgba(240, 238, 255, 0.92);
  --track:         rgba(100, 90, 180, 0.09);
  --input-bg:      rgba(100, 90, 180, 0.05);
  --backdrop:      rgba(30, 26, 69, 0.35);
}

/* ---------- База ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  min-height: 100vh;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.35s ease, color 0.35s ease;
  overscroll-behavior-y: contain;
}

body {
  padding-top: calc(env(safe-area-inset-top) + 64px);
  padding-bottom: calc(env(safe-area-inset-bottom) + 92px);
  padding-left: 16px;
  padding-right: 16px;
  max-width: 560px;
  margin: 0 auto;
  position: relative;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { color: inherit; text-decoration: none; }
input { font-family: inherit; }

/* ---------- Декоративный фон (звёзды) ---------- */
.bg-stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, rgba(245, 200, 66, 0.9), transparent 60%),
    radial-gradient(1px 1px at 82% 12%, rgba(240, 239, 248, 0.7), transparent 60%),
    radial-gradient(1.2px 1.2px at 45% 8%,  rgba(142, 198, 240, 0.8), transparent 60%),
    radial-gradient(1px 1px at 70% 25%, rgba(240, 239, 248, 0.5), transparent 60%),
    radial-gradient(1.3px 1.3px at 25% 35%, rgba(245, 200, 66, 0.5), transparent 60%),
    radial-gradient(1px 1px at 92% 40%, rgba(240, 239, 248, 0.4), transparent 60%),
    radial-gradient(1.5px 1.5px at 8% 55%, rgba(142, 198, 240, 0.5), transparent 60%),
    radial-gradient(1px 1px at 55% 62%, rgba(245, 200, 66, 0.4), transparent 60%);
  transition: opacity 0.4s ease;
}
:root[data-theme="light"] .bg-stars { opacity: 0; }

/* ---------- Шапка ---------- */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: calc(env(safe-area-inset-top) + 60px);
  padding: env(safe-area-inset-top) 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--header-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  z-index: 30;
  max-width: 560px;
  margin: 0 auto;
}

.header-left { display: flex; align-items: center; gap: 10px; min-width: 0; position: relative; }
.logo { flex-shrink: 0; filter: drop-shadow(0 2px 8px rgba(245, 200, 66, 0.25)); }

.brand { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }

/* Переключатель детей */
.child-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px 5px 5px;
  border-radius: 999px;
  background: var(--primary-soft);
  transition: background 0.2s ease, transform 0.12s ease;
  min-width: 0;
}
.child-switcher:active { transform: scale(0.97); }
.child-switcher[aria-expanded="true"] { background: var(--primary); color: #fff; }

.child-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--gold) 130%);
  flex-shrink: 0;
}
.child-switcher[aria-expanded="true"] .child-avatar {
  background: rgba(255,255,255,0.25);
}
.child-name {
  font-size: 13px;
  font-weight: 600;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chev { transition: transform 0.25s ease; opacity: 0.7; }
.child-switcher[aria-expanded="true"] .chev { transform: rotate(180deg); opacity: 1; }

/* Дропдаун детей */
.child-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 42px;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 6px;
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 40;
  animation: dropIn 0.18s ease;
}
.child-dropdown.open { display: flex; }

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.child-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  text-align: left;
  transition: background 0.15s ease;
  width: 100%;
}
.child-option:hover { background: var(--primary-soft); }
.child-option.active {
  background: var(--primary-soft);
}
.child-option .child-avatar { width: 30px; height: 30px; font-size: 13px; }
.child-option-name { font-size: 14px; font-weight: 600; }
.child-option-age  { font-size: 12px; color: var(--text-muted); }
.child-option-meta { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.child-option-check {
  color: var(--primary);
  opacity: 0;
  transition: opacity 0.15s;
}
.child-option.active .child-option-check { opacity: 1; }

.header-right { display: flex; align-items: center; gap: 2px; }

.icon-btn {
  position: relative;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  color: var(--text);
  transition: background 0.2s ease, transform 0.15s ease;
}
.icon-btn:hover { background: var(--primary-soft); }
.icon-btn:active { transform: scale(0.93); }

.notif-dot {
  position: absolute;
  top: 10px; right: 10px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 2px var(--bg);
}

:root[data-theme="dark"] .icon-moon { display: none; }
:root[data-theme="light"] .icon-sun { display: none; }

/* ---------- Main ---------- */
.app-main { position: relative; z-index: 1; padding-top: 8px; }

/* Вкладки */
.tab-panel {
  display: none;
  animation: tabEnter 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.tab-panel.active { display: block; }

@keyframes tabEnter {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Карточки ---------- */
.card {
  background: var(--surface);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
}
.card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}

/* ---------- Карточка статуса ---------- */
.status-card {
  padding: 22px;
  background-image: var(--gradient-card);
}

.status-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
}
.status-card.is-sleeping .status-indicator {
  background: var(--primary-soft);
  color: var(--primary);
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 25%, transparent);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

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

.status-timer { margin: 6px 0 18px; }
.timer-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.timer-value {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  background: linear-gradient(135deg, var(--text) 0%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.timer-sub {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}
.timer-sub.over {
  color: var(--danger);
  font-weight: 600;
}

/* Прогресс-бар */
.progress { margin-bottom: 18px; position: relative; }
.progress::before {
  content: '';
  display: block;
  height: 8px;
  border-radius: 999px;
  background: var(--track);
  margin-bottom: 8px;
}
.progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold) 0%, #FFD66B 100%);
  transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.3s ease;
  width: 0;
  box-shadow: 0 0 12px rgba(245, 200, 66, 0.35);
}
.progress-bar.over {
  background: linear-gradient(90deg, #E57373 0%, #FF8A80 100%);
  box-shadow: 0 0 12px rgba(229, 115, 115, 0.4);
}
.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Кнопки действий */
.action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Базовая кнопка */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 600;
  transition: transform 0.12s ease, background 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #8A7ED5 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16); }

.btn-secondary {
  background: var(--gold);
  color: #1A1840;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.10);
}
.btn-secondary:hover:not(:disabled) { box-shadow: 0 6px 16px rgba(0, 0, 0, 0.14); }

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn-outline:hover { background: var(--surface-2); }

.btn-gold-gradient {
  background: linear-gradient(135deg, var(--gold) 0%, #FFD66B 100%);
  color: #1A1840;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.10);
}

.btn-block { width: 100%; }

.btn-ai {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold-soft);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
}
.btn-ai:hover { background: var(--gold-soft); }

/* Кнопка кормления — адаптивные цвета по теме */
.btn-feeding {
  width: 100%;
  margin-top: 10px;
  /* Базовый — переопределяется по темам ниже */
  background: #8A5A9E;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.20);
}
.btn-feeding:hover:not(:disabled) { opacity: 0.9; }

/* Тёмная тема — насыщенный фиолетовый, белый текст (контраст 5.2:1) */
:root[data-theme="dark"] .btn-feeding {
  background: #8A5A9E;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.20);
}

/* Светлая тема — нежно-лавандовый, тёмно-фиолетовый текст (контраст 9.3:1) */
:root[data-theme="light"] .btn-feeding {
  background: #E1CBE6;
  color: #3D1F4A;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.10);
}

/* ---------- Сегодня ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat {
  background: var(--surface-2);
  border-radius: 14px;
  padding: 14px 8px;
  text-align: center;
  border: 1px solid var(--border);
}
.stat-value {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}
.stat-sub { color: var(--text-muted); font-weight: 500; }
.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---------- Следующий сон ---------- */
.next-nap-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
}
.next-nap-icon {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: grid; place-items: center;
  background: var(--gold-soft);
  color: var(--gold);
  flex-shrink: 0;
}
.next-nap-info { flex: 1; }
.next-nap-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.next-nap-time {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.next-nap-countdown {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.countdown-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.countdown-unit {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ---------- План ---------- */
.plan-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 14px;
  padding: 4px 4px 0;
}
.plan-date-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.plan-date {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.plan-list { display: flex; flex-direction: column; gap: 10px; }

.plan-item {
  background: var(--surface);
  border-radius: 16px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.plan-num {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  font-size: 16px;
}
.plan-item.done .plan-num { background: rgba(123, 211, 137, 0.15); color: var(--success); }
.plan-item.missed .plan-num { background: rgba(229, 115, 115, 0.15); color: var(--danger); }

.plan-main-line {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
  font-variant-numeric: tabular-nums;
}
.plan-sub-line {
  font-size: 12px;
  color: var(--text-muted);
}
.plan-status {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.plan-status.done    { background: rgba(123, 211, 137, 0.15); color: var(--success); }
.plan-status.upcoming{ background: var(--blue-soft); color: var(--blue); }
.plan-status.missed  { background: rgba(229, 115, 115, 0.15); color: var(--danger); }

/* ---------- Журнал ---------- */
.journal-switcher {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-radius: 14px;
  padding: 6px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}
.day-nav-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  color: var(--text-muted);
  transition: background 0.2s ease, color 0.2s ease;
}
.day-nav-btn:not(:disabled):hover { background: var(--primary-soft); color: var(--text); }
.day-nav-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.day-label {
  flex: 1;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
}

.journal-list {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.journal-item {
  background: var(--surface);
  border-radius: 14px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
}
.journal-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 18px;
}
.journal-icon.sleep    { background: var(--primary-soft); color: var(--primary); }
.journal-icon.wake     { background: var(--gold-soft); color: var(--gold); }
/* Иконка кормления — розовый/лавандовый */
.journal-icon.feeding  { background: rgba(155, 106, 174, 0.15); color: #9B6AAE; }

.journal-main { display: flex; flex-direction: column; }
.journal-label { font-size: 14px; font-weight: 600; }
.journal-time {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.journal-duration {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Настройки ---------- */
.section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 8px 6px 8px;
  margin-top: 6px;
}
.section-title:first-child { margin-top: 0; }

.section-card {
  padding: 6px 16px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: none; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 14px; font-weight: 600; }
.row-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.row.as-link {
  transition: transform 0.12s ease;
  cursor: pointer;
}
.row.as-link:active { transform: scale(0.99); }
.row.as-link svg { color: var(--text-muted); }

.row-action {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
  width: 100%;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  text-align: left;
}
.row-action-icon {
  width: 32px; height: 32px;
  border-radius: 10px;
  background: var(--primary-soft);
  display: grid; place-items: center;
  color: var(--primary);
  flex-shrink: 0;
}

/* Дети — список */
.children-list { display: flex; flex-direction: column; }

.child-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.child-row .child-avatar {
  width: 40px; height: 40px;
  font-size: 15px;
}
.child-row-main { flex: 1; min-width: 0; }
.child-row-name { font-size: 14px; font-weight: 600; }
.child-row-age  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.child-row-actions {
  display: flex;
  gap: 4px;
}
.ghost-btn {
  width: 32px; height: 32px;
  border-radius: 10px;
  display: grid; place-items: center;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.ghost-btn:hover { background: var(--primary-soft); color: var(--text); }
.ghost-btn.danger:hover { background: rgba(229, 115, 115, 0.12); color: var(--danger); }

/* Семья — список */
.family-list { display: flex; flex-direction: column; }
.family-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.family-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.family-avatar.me    { background: linear-gradient(135deg, var(--primary) 0%, #8A7ED5 100%); }
.family-avatar.other { background: linear-gradient(135deg, var(--blue) 0%, #B4DBF5 100%); color: #1A1840; }
.family-row-main { flex: 1; min-width: 0; }
.family-name { font-size: 14px; font-weight: 600; }
.family-role { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Реферальная карточка */
.referral-card {
  background: var(--surface);
  background-image: linear-gradient(135deg, rgba(123, 111, 196, 0.10) 0%, rgba(142, 198, 240, 0.08) 100%);
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.referral-card::before {
  content: '';
  position: absolute;
  top: -40px; right: -30px;
  width: 140px; height: 140px;
  background: radial-gradient(circle, rgba(107, 95, 189, 0.18) 0%, transparent 70%);
  border-radius: 50%;
}
.referral-badge {
  display: inline-block;
  background: var(--gold);
  color: #1A1840;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}
.referral-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}
.referral-text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 14px;
}
.referral-link {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--input-bg);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 4px 4px 4px 12px;
}
.referral-link input {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  color: var(--text);
  font-size: 12px;
  padding: 10px 0;
  min-width: 0;
}
.copy-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--primary);
  color: #fff;
  transition: background 0.15s, transform 0.12s;
  flex-shrink: 0;
}
.copy-btn:hover { background: #8A7ED5; }
.copy-btn:active { transform: scale(0.92); }
.copy-btn.success { background: var(--success); }

/* Подписка */
.subscription-card {
  padding: 20px;
  background: var(--surface);
  background-image: linear-gradient(160deg, rgba(107, 95, 189, 0.13) 0%, rgba(142, 198, 240, 0.07) 100%);
  position: relative;
  overflow: hidden;
}
.sub-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.sub-title {
  font-size: 16px;
  font-weight: 700;
}
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.badge-trial   { background: var(--gold-soft); color: var(--gold); }
.badge-premium { background: rgba(123, 211, 137, 0.18); color: var(--success); }

.sub-progress {
  margin: 12px 0;
  position: relative;
}
.sub-progress::before {
  content: '';
  display: block;
  height: 8px;
  border-radius: 999px;
  background: var(--track);
  margin-bottom: 8px;
}
.sub-progress-bar {
  position: absolute;
  top: 0; left: 0;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold) 0%, var(--primary) 100%);
  transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sub-progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}
.sub-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 8px 0 14px;
}
.sub-cta {
  width: 100%;
  font-size: 15px;
  padding: 14px;
}

.star-icon {
  display: inline-block;
  color: var(--gold);
  vertical-align: -2px;
}

/* Сегмент-переключатель темы */
.theme-segment {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 3px;
  border: 1px solid var(--border);
}
.seg-btn {
  width: 34px; height: 30px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: var(--text-muted);
  transition: background 0.2s, color 0.2s;
}
.seg-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.footer-hint {
  margin-top: 18px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- Нижняя навигация ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  padding: 8px 8px calc(env(safe-area-inset-bottom) + 8px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: var(--nav-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border);
  z-index: 20;
  max-width: 560px;
  margin: 0 auto;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.2s ease, background 0.2s ease, transform 0.12s ease;
}
.nav-item:active { transform: scale(0.94); }
.nav-item.active {
  color: var(--primary);
  background: var(--primary-soft);
}
.nav-item svg { transition: transform 0.2s ease; }
.nav-item.active svg { transform: translateY(-1px); }

/* ---------- Тост ---------- */
.toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 100px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface);
  color: var(--text);
  padding: 14px 22px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-strong);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0.3s;
  z-index: 60;
  pointer-events: none;
  max-width: calc(100% - 32px);
}
.toast svg { color: var(--success); flex-shrink: 0; }
.toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Bottom Sheet ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  z-index: 70;
}
.sheet-backdrop.show { opacity: 1; visibility: visible; }

.sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 560px;
  margin: 0 auto;
  background: var(--bg-elev);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding: 8px 20px calc(env(safe-area-inset-bottom) + 24px);
  transform: translateY(100%);
  visibility: hidden;
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0.35s;
  z-index: 71;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-bottom: none;
  max-height: 88vh;
  overflow-y: auto;
}
.sheet.show {
  transform: translateY(0);
  visibility: visible;
}

.sheet-handle {
  width: 40px; height: 4px;
  background: var(--border-strong);
  border-radius: 2px;
  margin: 0 auto 12px;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.sheet-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.sheet-close {
  width: 32px; height: 32px;
  border-radius: 10px;
  display: grid; place-items: center;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: color 0.15s, background 0.15s;
}
.sheet-close:hover { color: var(--text); background: var(--surface-2); }

/* .sheet-body определён ниже в блоке Моод-грид */

/* Формы в sheet */
.field { margin-bottom: 14px; }
.field-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
}
.field-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--input-bg);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border 0.2s, background 0.2s;
}
.field-input:focus { border-color: var(--primary); }

.gender-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.gender-opt {
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  background: var(--input-bg);
  color: var(--text);
  transition: all 0.2s;
}
.gender-opt.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Sheet-ссылка на приглашение */
.invite-link-block {
  background: var(--input-bg);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text);
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.sheet-hint {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 16px;
}

/* ---------- Светлая тема — перекрытия ---------- */

/* Кнопка «Проснулся» — gold светлый, поэтому тёмный текст для контраста */
:root[data-theme="light"] .btn-secondary {
  background: var(--gold);
  color: #1E1A45;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.10);
}

/* Прогресс-бар подписки — чистый однотонный gold без грязного перехода */
:root[data-theme="light"] .sub-progress-bar {
  background: var(--gold);
  box-shadow: none;
}

/* Прогресс-бар трекера */
:root[data-theme="light"] .progress-bar {
  box-shadow: 0 0 10px rgba(245, 184, 0, 0.28);
}

/* Бейджи — trial делаем насыщеннее */
:root[data-theme="light"] .badge-trial {
  background: rgba(245, 184, 0, 0.16);
  color: #C98F00;
}

/* Реферальный бейдж — чистый gold с белым текстом */
:root[data-theme="light"] .referral-badge {
  background: var(--gold);
  color: #fff;
}

/* Аватары детей — убираем грязный gold в градиенте, делаем primary→blue */
:root[data-theme="light"] .child-avatar {
  background: linear-gradient(135deg, var(--primary) 0%, #A99EE8 100%);
}

/* Реферальная карточка — пастельно-фиолетовая как у референса */
:root[data-theme="light"] .referral-card {
  background: #FFFFFF;
  background-image: linear-gradient(135deg, rgba(124, 111, 212, 0.08) 0%, rgba(96, 168, 224, 0.05) 100%);
}
:root[data-theme="light"] .referral-card::before {
  background: radial-gradient(circle, rgba(124, 111, 212, 0.12) 0%, transparent 70%);
}

/* Карточка подписки */
:root[data-theme="light"] .subscription-card {
  background: #FFFFFF;
  background-image: linear-gradient(160deg, rgba(124, 111, 212, 0.08) 0%, rgba(96, 168, 224, 0.05) 100%);
}

/* Кнопка CTA (оформить Premium) — тёмно-фиолетовая, контрастная */
:root[data-theme="light"] .btn-gold-gradient {
  background: linear-gradient(135deg, #6B5FBD 0%, #8A7ED5 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* ---------- AI-инсайт ---------- */
.ai-insight-card {
  padding: 14px 16px;
  background-image: var(--gradient-card);
}
.ai-insight-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.ai-insight-text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ---------- Аналитика ---------- */
.analytics-switcher {
  display: flex;
  background: var(--surface);
  border-radius: 14px;
  padding: 5px;
  margin-bottom: 14px;
  gap: 4px;
  border: 1px solid var(--border);
}
.analytics-tab {
  flex: 1;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  transition: background 0.2s, color 0.2s;
  text-align: center;
}
.analytics-tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.10);
}

.chart-card { padding: 16px 18px; }
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.chart-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.chart-legend {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.legend-primary { background: var(--primary); }
.legend-blue    { background: var(--blue); }

.chart-canvas {
  width: 100%;
  height: 150px;
  position: relative;
}

/* ---------- Mood grid (шторки) ---------- */
.mood-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.mood-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 2px solid transparent;
  transition: all 0.18s ease;
  font-family: inherit;
  cursor: pointer;
}
.mood-card:active { transform: scale(0.96); }
.mood-card.active {
  background: var(--primary-soft);
  border-color: var(--primary);
}
.mood-emoji { font-size: 24px; line-height: 1; }
/* Текст под эмоджи — достаточный контраст (используем цвет текста, не muted) */
.mood-text { font-size: 11px; font-weight: 600; color: var(--text); opacity: 0.7; }
.mood-card.active .mood-text { color: var(--primary); opacity: 1; }

/* ---------- Counter (счётчик прерываний) ---------- */
.counter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.counter-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  font-size: 20px;
  font-weight: 300;
  display: grid; place-items: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  color: var(--text);
  font-family: inherit;
  flex-shrink: 0;
}
.counter-btn:active { transform: scale(0.92); background: var(--primary-soft); }
.counter-val {
  font-size: 22px;
  font-weight: 700;
  min-width: 32px;
  text-align: center;
  flex: 1;
  color: var(--text);
}
.counter-unit { font-size: 13px; color: var(--text); opacity: 0.6; flex-shrink: 0; }

/* ---------- Лейбл секции в шторке ---------- */
.sheet-section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  opacity: 0.55;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 10px;
}

/* Отступы внутри шторки */
.sheet-body {
  font-size: 14px;
  padding: 4px 0 16px;
}

/* ---------- Журнал — сводка дня ---------- */
.journal-summary-card {
  padding: 14px 16px;
  margin-bottom: 10px;
}
.journal-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-around;
}
.journal-summary-item { text-align: center; flex: 1; }
.journal-summary-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 3px;
}
.journal-summary-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.journal-summary-div {
  width: 1px;
  height: 32px;
  background: var(--border-strong);
}

/* ---------- Навигация 5 пунктов ---------- */
.bottom-nav {
  grid-template-columns: repeat(5, 1fr) !important;
}
.nav-item span { font-size: 10px; }

/* ---------- Адаптив ---------- */
@media (max-width: 360px) {
  .timer-value { font-size: 34px; }
  .stats-grid { gap: 6px; }
  .stat-value { font-size: 18px; }
  .btn { font-size: 14px; padding: 12px 12px; }
  .child-name { max-width: 60px; }
  .brand { display: none; }
}
