/* ============ Life Hub — тёмная дизайн-система (референс: Verus) ============ */

:root {
  --bg: #101217;
  --surface: #191c24;
  --surface-2: #1f232e;
  --surface-3: #262b38;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #f5f7fa;
  --text-soft: #8b93a7;

  --blue: #2f6bff;          /* primary */
  --blue-hover: #1e50d4;
  --indigo: #5d8bf4;
  --light-blue: #5494cd;
  --blue-tint: rgba(47, 107, 255, 0.13);
  --indigo-tint: rgba(93, 139, 244, 0.12);

  --ok: #00ac4f;
  --ok-tint: rgba(0, 172, 79, 0.12);
  --danger: #f13636;
  --danger-tint: rgba(241, 54, 54, 0.12);
  --warn: #ffb82f;
  --warn-tint: rgba(255, 184, 47, 0.12);

  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 4px 14px rgba(0, 0, 0, 0.35);
  --glow-blue: 0 4px 18px rgba(47, 107, 255, 0.35);
  --r-pill: 999px;
  --r-card: 18px;
}

/* Светлая тема — включается по теме Telegram (data-theme на <html>) */
:root[data-theme="light"] {
  --bg: #eef0f5;
  --surface: #ffffff;
  --surface-2: #f3f4f8;
  --surface-3: #e7e9f0;
  --border: rgba(25, 35, 65, 0.08);
  --border-strong: rgba(25, 35, 65, 0.16);
  --text: #171a21;
  --text-soft: #6a7185;
  --blue-tint: rgba(47, 107, 255, 0.08);
  --indigo-tint: rgba(93, 139, 244, 0.09);
  --ok-tint: rgba(0, 172, 79, 0.09);
  --danger-tint: rgba(241, 54, 54, 0.08);
  --warn-tint: rgba(255, 184, 47, 0.12);
  --shadow: 0 8px 28px rgba(50, 60, 95, 0.14);
  --shadow-soft: 0 4px 14px rgba(50, 60, 95, 0.08);
}
:root[data-theme="light"] .blob { opacity: 0.10; }
:root[data-theme="light"] .tabbar { background: rgba(255, 255, 255, 0.9); }
:root[data-theme="light"] .field { color-scheme: light; }
:root[data-theme="light"] .chip.mint { color: #0b7c43; }
:root[data-theme="light"] .menu-ico.green { color: #0b7c43; }
:root[data-theme="light"] .menu-ico.red { color: #d12f2f; }
:root[data-theme="light"] .toast.err { color: var(--danger); }

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* приглушённое синее свечение на фоне */
.bg-blobs { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.blob { position: absolute; width: 52vw; height: 52vw; min-width: 260px; min-height: 260px; border-radius: 50%; filter: blur(90px); opacity: 0.16; }
.blob-mint { background: var(--blue); top: -12%; left: -12%; }
.blob-lav { background: var(--indigo); top: 30%; right: -18%; opacity: 0.10; }
.blob-peach { background: #163a8c; bottom: -10%; left: 10%; opacity: 0.18; }

/* ============ launch screen ============ */
#splash {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg);
  transition: opacity 0.35s ease;
}
#splash.hide { opacity: 0; pointer-events: none; }
.splash-glow {
  position: absolute; width: 320px; height: 320px; border-radius: 50%;
  background: radial-gradient(circle, rgba(47, 107, 255, 0.28) 0%, rgba(47, 107, 255, 0) 65%);
  animation: splashPulse 2s ease-in-out infinite;
}
:root[data-theme="light"] .splash-glow { background: radial-gradient(circle, rgba(47, 107, 255, 0.16) 0%, rgba(47, 107, 255, 0) 65%); }
@keyframes splashPulse { 0%, 100% { transform: scale(1); opacity: 0.8; } 50% { transform: scale(1.15); opacity: 1; } }
.splash-logo {
  position: relative;
  filter: drop-shadow(0 10px 30px rgba(47, 107, 255, 0.4));
  animation: splashIn 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes splashIn { from { transform: scale(0.7); opacity: 0; } to { transform: none; opacity: 1; } }
.splash-check {
  stroke: var(--text);
  stroke-dasharray: 12; stroke-dashoffset: 12;
  animation: splashCheck 0.6s ease 0.35s forwards;
}
@keyframes splashCheck { to { stroke-dashoffset: 0; } }
.splash-title {
  margin-top: 22px; font-size: 24px; font-weight: 700; letter-spacing: -0.5px;
  color: var(--text);
  animation: fadeUp 0.5s ease 0.15s both;
}
.splash-sub {
  margin-top: 4px; font-size: 13.5px; color: var(--text-soft);
  animation: fadeUp 0.5s ease 0.3s both;
}

/* ============ поверхности ============ */
.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.view {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 16px calc(104px + env(safe-area-inset-bottom));
  animation: fadeUp 0.28s ease;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ============ типографика ============ */
.h1 { font-size: clamp(21px, 6.4vw, 26px); font-weight: 700; letter-spacing: -0.5px; margin-bottom: 4px; overflow-wrap: anywhere; }
.h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.1px; margin: 22px 0 10px; }
.sub { color: var(--text-soft); font-size: 14px; letter-spacing: -0.1px; overflow-wrap: anywhere; }
.muted { color: var(--text-soft); }
.small { font-size: 12px; }

/* ============ карточки ============ */
.card {
  border-radius: var(--r-card);
  padding: 16px;
  margin-bottom: 12px;
  position: relative;
}
/* цветовые варианты: синяя семья + смысловые акценты сверху карточки */
.card.tint-mint { background: linear-gradient(180deg, var(--ok-tint), var(--surface) 70%); border-color: rgba(0, 172, 79, 0.22); }
.card.tint-lav { background: linear-gradient(180deg, var(--blue-tint), var(--surface) 70%); border-color: rgba(47, 107, 255, 0.28); }
.card.tint-peach { background: linear-gradient(180deg, var(--warn-tint), var(--surface) 70%); border-color: rgba(255, 184, 47, 0.22); }
.card.tint-blue { background: linear-gradient(180deg, var(--indigo-tint), var(--surface) 70%); border-color: rgba(93, 139, 244, 0.26); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 .card { margin-bottom: 0; }

/* длинные суммы и числа ужимаются, а не вылезают за карточку */
.stat-num { font-size: clamp(17px, 5.6vw, 24px); font-weight: 700; letter-spacing: -0.5px; margin-top: 6px; overflow-wrap: anywhere; }
.stat-cap { font-size: 12.5px; color: var(--text-soft); font-weight: 500; }

/* ============ кнопки ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  padding: 14px 22px;
  font-family: inherit;
  font-size: 15px; font-weight: 600; letter-spacing: -0.1px;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn { text-align: center; line-height: 1.25; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: var(--glow-blue); }
.btn.primary:active { background: var(--blue-hover); }
.btn.mint { background: var(--ok); border-color: var(--ok); color: #fff; box-shadow: 0 4px 18px rgba(0, 172, 79, 0.30); }
.btn.peach { background: var(--surface-2); border-color: var(--blue); color: var(--indigo); }
.btn.block { width: 100%; }
.btn.sm { padding: 9px 16px; font-size: 13.5px; }
.btn.icon { width: 46px; height: 46px; padding: 0; font-size: 19px; }
.btn.danger { color: var(--danger); border-color: rgba(241, 54, 54, 0.35); background: var(--surface-2); box-shadow: none; }

/* ============ формы ============ */
.field {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--surface-2);
  outline: none;
  margin-bottom: 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  color-scheme: dark;
}
.field::placeholder { color: var(--text-soft); }
.field:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.18); }
textarea.field { resize: none; min-height: 72px; }
.field { min-width: 0; }
/* date/time: не расползаются за экран (iOS задаёт им жёсткую внутреннюю ширину) */
input.field[type="date"], input.field[type="time"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; min-height: 49px;
  display: flex; align-items: center;
}
.field[type="date"]:not(:focus):invalid, .field[type="time"]:not(:focus):invalid { color: var(--text-soft); }
.field::-webkit-calendar-picker-indicator { filter: invert(0.6); cursor: pointer; }
:root[data-theme="light"] .field::-webkit-calendar-picker-indicator { filter: none; }
.field::-webkit-datetime-edit-fields-wrapper { color: inherit; }

/* подпись над полем (заменяет невидимый на iOS плейсхолдер у дат) */
.labeled { flex: 1 1 0; min-width: 0; }
.labeled .lab { font-size: 12px; color: var(--text-soft); margin: 0 0 4px 4px; font-weight: 500; }

/* три AI-кнопки одного размера независимо от переноса текста */
.btn-trio { display: flex; gap: 8px; margin-top: 12px; }
.btn-trio .btn { flex: 1 1 0; min-width: 0; min-height: 56px; padding: 8px 4px; font-size: 13px; }
select.field { appearance: none; }

.row { display: flex; gap: 10px; align-items: center; }
.row > .field { margin-bottom: 10px; }
.row > * { min-width: 0; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.spread > * { min-width: 0; }
.spread > .btn, .spread > .chip { flex: none; }

/* сегменты (переключатели) */
.seg {
  display: flex; padding: 4px; gap: 4px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin-bottom: 12px;
}
.seg button {
  flex: 1; border: 0; border-radius: 9px;
  padding: 10px 6px; font-family: inherit; font-size: 13.5px; font-weight: 600;
  background: transparent; color: var(--text-soft); cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.seg button.active {
  background: var(--blue);
  color: #fff;
  box-shadow: var(--glow-blue);
}

/* ============ списки ============ */
.item {
  display: flex; align-items: center; gap: 12px;
  border-radius: 14px; padding: 13px 15px; margin-bottom: 9px;
}
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 600; font-size: 15px; letter-spacing: -0.1px; overflow: hidden; text-overflow: ellipsis; }
.item .meta { font-size: 12.5px; color: var(--text-soft); margin-top: 2px; overflow-wrap: anywhere; }
.item.done .title { text-decoration: line-through; opacity: 0.5; }

.check {
  width: 26px; height: 26px; min-width: 26px;
  border-radius: 8px;
  border: 2px solid var(--border-strong);
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  color: #fff; cursor: pointer;
  transition: all 0.15s ease;
}
.check .ico { opacity: 0; transition: opacity 0.15s ease; }
.check.on { background: var(--blue); border-color: var(--blue); }
.check.on .ico { opacity: 1; }

.x-btn { border: 0; background: none; color: var(--text-soft); font-size: 17px; cursor: pointer; padding: 6px; }
.x-btn:active { color: var(--danger); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: var(--r-pill); padding: 7px 14px;
  font-size: 13px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text);
}
.chip.mint { background: var(--ok-tint); border-color: rgba(0, 172, 79, 0.35); color: #3ad07f; }
.chip.lav { background: var(--blue); border-color: var(--blue); color: #fff; }
.chip.peach { background: var(--warn-tint); border-color: rgba(255, 184, 47, 0.35); color: var(--warn); }

/* ============ прогресс и графики ============ */
.progress { height: 10px; border-radius: 6px; background: var(--surface-3); overflow: hidden; margin: 10px 0 6px; }
.progress > div { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--blue), var(--indigo)); transition: width 0.4s ease; }
.progress.over > div { background: linear-gradient(90deg, var(--warn), var(--danger)); }

.bars { display: flex; align-items: flex-end; gap: 8px; height: 110px; padding-top: 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.bar-track { width: 100%; max-width: 34px; height: 84px; display: flex; align-items: flex-end; gap: 3px; justify-content: center; }
.bar { width: 12px; border-radius: 6px 6px 3px 3px; min-height: 3px; }
.bar.inc { background: var(--ok); }
.bar.exp { background: var(--danger); }
.bar-cap { font-size: 10.5px; color: var(--text-soft); white-space: nowrap; }

.cat-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.cat-name { font-size: 13px; font-weight: 500; width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-track { flex: 1; height: 8px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.cat-track > div { height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--blue), var(--light-blue)); }
.cat-val { font-size: 12.5px; color: var(--text-soft); min-width: 64px; text-align: right; }

/* график веса */
.spark { width: 100%; height: 120px; display: block; }
.spark polyline { stroke: var(--indigo) !important; }
.spark circle { fill: var(--indigo) !important; }

/* ============ нижняя навигация ============ */
.tabbar {
  position: fixed; z-index: 20;
  left: 50%; transform: translateX(-50%);
  bottom: calc(12px + env(safe-area-inset-bottom));
  width: min(560px - 24px, calc(100vw - 24px));
  display: flex; justify-content: space-around;
  border-radius: 20px;
  padding: 8px;
  background: rgba(25, 28, 36, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
}
.tab {
  flex: 1; border: 0; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px; border-radius: 13px; color: var(--text-soft);
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.tab-ico { font-size: 20px; }
.tab-label { font-family: inherit; font-size: 10.5px; font-weight: 600; }
.tab.active { background: var(--blue); color: #fff; box-shadow: var(--glow-blue); }

/* ============ модальная шторка ============ */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(5, 6, 10, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: min(560px, 100vw);
  max-height: 86vh; overflow-y: auto;
  border-radius: 22px 22px 0 0;
  padding: 20px 18px calc(24px + env(safe-area-inset-bottom));
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-bottom: 0;
  box-shadow: var(--shadow);
  animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0.5; } to { transform: none; opacity: 1; } }
.sheet .handle { width: 42px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 0 auto 14px; }
.sheet .h1 { font-size: 21px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sheet-close {
  width: 34px; height: 34px; min-width: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-strong); background: var(--surface-3);
  color: var(--text-soft); cursor: pointer; flex: none;
  -webkit-tap-highlight-color: transparent;
}
.sheet-close:active { transform: scale(0.92); }
.sheet .field, .sheet .seg, .sheet .btn:not(.primary):not(.mint):not(.danger) { background: var(--surface-3); }
.sheet .card { background: var(--surface); }

/* ============ тосты ============ */
#toast-root { position: fixed; z-index: 60; left: 0; right: 0; top: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 11px;
  border-radius: 16px; padding: 13px 20px 13px 14px;
  font-size: 15px; font-weight: 600; letter-spacing: -0.1px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  animation: toastIn 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  max-width: 88vw;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(0.94); } to { opacity: 1; transform: none; } }
.toast .t-ico {
  width: 26px; height: 26px; min-width: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--ok); color: #fff;
}
.toast.err .t-ico { background: var(--danger); }
.toast.err { color: #ff9d9d; }
:root[data-theme="light"] .toast.err { color: var(--danger); }

/* ============ переключатели ============ */
.switch-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 0; }
.switch-row + .switch-row { border-top: 1px solid var(--border); }
.switch-label { font-size: 14.5px; font-weight: 500; }
.switch {
  width: 46px; height: 28px; min-width: 46px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-3);
  position: relative; cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: transform 0.18s ease;
}
.switch.on { background: var(--blue); border-color: var(--blue); }
.switch.on::after { transform: translateX(18px); }

/* ============ иконки ============ */
.ico { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.ico svg { display: block; }
.stat-cap { display: flex; align-items: center; gap: 7px; }
.stat-cap .ico { color: var(--text-soft); }
.h2 { display: flex; align-items: center; gap: 8px; }
.h2 .ico { color: var(--text-soft); }
.empty .big { color: var(--text-soft); opacity: 0.7; }
.menu-ico {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-3); border: 1px solid var(--border-strong);
}
.menu-ico.blue { color: var(--indigo); border-color: rgba(93, 139, 244, 0.35); background: var(--indigo-tint); }
.menu-ico.green { color: #3ad07f; border-color: rgba(0, 172, 79, 0.35); background: var(--ok-tint); }
.menu-ico.yellow { color: var(--warn); border-color: rgba(255, 184, 47, 0.35); background: var(--warn-tint); }
.menu-ico.red { color: #ff7a7a; border-color: rgba(241, 54, 54, 0.3); background: var(--danger-tint); }

/* ============ разное ============ */
.avatar { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; border: 2px solid var(--blue); }
.avatar-ph { width: 46px; height: 46px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; background: linear-gradient(135deg, var(--blue), var(--indigo)); color: #fff; }
.center { text-align: center; }
.mb { margin-bottom: 10px; } /* единый отступ у заголовков экранов */
.empty { text-align: center; padding: 32px 16px; color: var(--text-soft); font-size: 14px; }
.empty .big { font-size: 40px; margin-bottom: 10px; }
.mt { margin-top: 12px; }
.mb0 { margin-bottom: 0; }
.code-pill { font-family: ui-monospace, 'SF Mono', monospace; font-size: 22px; font-weight: 700; letter-spacing: 4px; color: var(--indigo); }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-soft); font-family: inherit; font-weight: 600; font-size: 14px; background: none; border: 0; cursor: pointer; padding: 4px 0; margin-bottom: 10px; }
.back-link:active { color: var(--indigo); }
.rec-card .dish { display: inline-block; margin: 3px 4px 0 0; }
.day-head { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; margin: 16px 0 8px; color: var(--text-soft); }
