@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

/* ===== Gramix — палитра редизайна (NutriLens) =====
 * Мятно-зелёный — основной акцент.
 * Персик — углеводы / вторичные действия.
 * Лавандовый — белки.
 * Мягкий коралл — жиры / превышение нормы (НЕ агрессивно-красный).
 */

:root {
  --brand-mint: oklch(0.78 0.14 165);
  --brand-mint-deep: oklch(0.55 0.14 165);
  --brand-mint-glow: oklch(0.78 0.14 165 / 0.55);

  --brand-peach: oklch(0.82 0.10 55);
  --brand-peach-deep: oklch(0.65 0.13 50);

  --brand-lilac: oklch(0.78 0.08 290);
  --brand-lilac-deep: oklch(0.62 0.10 290);

  --brand-coral: oklch(0.74 0.14 30);
  --brand-coral-deep: oklch(0.62 0.16 28);

  --brand-green: oklch(0.72 0.15 165);
  --brand-green-deep: oklch(0.55 0.15 165);

  --bg-base: #0E1410;
  --surface-1: #161D18;
  --surface-2: #1F2823;
  --line-soft: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.12);

  --text-primary: #ECF1ED;
  --text-dim: #8C9690;
  --text-mute: #5C6660;
}

html { font-size: 120%; }

body {
  margin: 0;
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto',
    'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: var(--bg-base);
  color: var(--text-primary);
}

code {
  font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
}

/* ===== PAGE SLIDE TRANSITIONS ===== */

@keyframes slideInFromRight {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

@keyframes slideInFromLeft {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}

.page-anim-wrapper {
  width: 100%;
  height: 100vh;
}

.page-anim-wrapper.slide-in-right {
  animation: slideInFromRight 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.page-anim-wrapper.slide-in-left {
  animation: slideInFromLeft 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Centered loading state used by App.jsx, Profile/Stats/History/Main pages */

.loading-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  color: var(--text-primary);
  z-index: 4000;
  padding: 24px;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}

.loading-screen h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--text-dim);
  text-align: center;
}
.verify-screen {
  position: fixed;
  inset: 0;
  z-index: 8500;
  background: var(--bg-base);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.verify-blob {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--brand-peach) 0%, transparent 60%);
  opacity: 0.18;
  filter: blur(50px);
  pointer-events: none;
  z-index: 0;
}

.verify-topbar {
  padding: max(env(safe-area-inset-top, 12px), 12px) 18px 0;
  position: relative;
  z-index: 1;
}
.verify-back {
  width: 40px;
  height: 40px;
  border-radius: 20px;
  background: var(--surface-1);
  border: 1px solid var(--line-strong);
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--text-primary);
  font-family: inherit;
}

.verify-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 32px;
  position: relative;
  z-index: 1;
  text-align: center;
}

.verify-icon {
  width: 88px;
  height: 88px;
  border-radius: 26px;
  background: linear-gradient(135deg, var(--brand-peach) 0%, var(--brand-mint) 100%);
  display: grid;
  place-items: center;
  margin-bottom: 28px;
  box-shadow: 0 16px 40px -10px var(--brand-mint-glow);
}

.verify-title {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.7px;
  line-height: 1.15;
  margin: 0;
}

.verify-sub {
  font-size: 17px;
  color: var(--text-dim);
  margin: 12px 0 0;
  line-height: 1.5;
  font-weight: 500;
  max-width: 300px;
}
.verify-sub strong {
  color: var(--text-primary);
  font-weight: 600;
}

.verify-hint {
  margin-top: 28px;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--surface-1);
  border: 1px solid var(--line-strong);
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.5;
  max-width: 320px;
}

.verify-error {
  color: var(--brand-coral-deep);
  font-size: 16px;
  margin-top: 16px;
}

.verify-actions {
  padding: 0 24px calc(env(safe-area-inset-bottom, 0px) + 96px);
  position: relative;
  z-index: 1;
}

.verify-resend {
  width: 100%;
  height: 56px;
  border-radius: 18px;
  border: none;
  cursor: pointer;
  background: var(--brand-mint);
  color: #0E1410;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 8px 20px -6px var(--brand-mint-glow);
  font-family: inherit;
  transition: background 0.4s ease, color 0.4s ease;
}
.verify-resend.is-cooling {
  background: var(--surface-1);
  color: var(--text-mute);
  border: 1px solid var(--line-strong);
  box-shadow: none;
  cursor: default;
}
.verify-resend-label {
  opacity: 0.85;
}
.verify-resend-pill {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
}
.bs-popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
  padding: 20px;
  animation: bs-fade-in 0.18s ease-out;
  box-sizing: border-box;
}

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

.bs-popup-card {
  width: 100%;
  max-width: 360px;
  padding: 22px 20px 18px;
  border-radius: 22px;
  background: var(--surface-1);
  border: 1px solid var(--line-soft);
  box-shadow: 0 24px 60px -10px rgba(0, 0, 0, 0.6);
  animation: bs-pop-in 0.22s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes bs-pop-in {
  from { transform: scale(0.94); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.bs-popup-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.bs-popup-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}

.bs-popup-icon-warning,
.bs-popup-icon-error {
  background: oklch(0.7 0.18 25 / 0.12);
  color: var(--brand-coral-deep);
  border: 1px solid oklch(0.7 0.18 25 / 0.25);
}

.bs-popup-icon-info {
  background: oklch(0.78 0.14 165 / 0.15);
  color: var(--brand-mint-deep);
  border: 1px solid oklch(0.78 0.14 165 / 0.25);
}

.bs-popup-text {
  flex: 1;
  min-width: 0;
  padding-top: 1px;
}
.bs-popup-row:has(.bs-popup-icon) .bs-popup-text {
  padding-top: 1px;
}
.bs-popup-row:not(:has(.bs-popup-icon)) .bs-popup-text {
  padding-top: 10px;
}

.bs-popup-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.2px;
  line-height: 1.25;
  color: var(--text-primary);
  text-wrap: pretty;
}

.bs-popup-desc {
  font-size: 14px;
  color: var(--text-dim);
  font-weight: 500;
  margin-top: 4px;
  line-height: 1.45;
  text-wrap: pretty;
}

.bs-popup-actions {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 8px;
}

.bs-popup-actions:has(> :only-child) {
  grid-template-columns: 1fr;
}

.bs-popup-secondary,
.bs-popup-primary {
  height: 44px;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.1px;
}

.bs-popup-secondary {
  background: var(--bg-base);
  color: var(--text-dim);
  border: 1px solid var(--line-soft);
}

.bs-popup-primary {
  background: var(--brand-mint);
  color: var(--bg-base);
  border: none;
}

.bs-popup-primary:active {
  transform: scale(0.98);
}
/* Geist font is loaded once in src/index.css */

:root {
    /* Имена «red/blue/yellow» сохранены для совместимости с inline-стилями.
       Реальные значения теперь — палитра NutriLens. */
    --primary-red: var(--brand-mint);
    --bg-dark: var(--bg-base);
    --card-bg: var(--surface-1);
    --header-bg: var(--surface-1);
    --text-gray: var(--text-dim);
    --accent-blue: var(--brand-mint);     /* калории */
    --accent-yellow: var(--brand-lilac);  /* белки */
    --accent-fat: var(--brand-coral);     /* жиры */
    --accent-carb: var(--brand-peach);    /* углеводы */
    --accent-over: var(--brand-coral);    /* превышение нормы */
}

/* ===== 1. ФУНДАМЕНТ АРХІТЕКТУРИ ===== */
* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    -webkit-tap-highlight-color: transparent;
}

html, body, #root {
    background-color: var(--bg-dark) !important;
    color: var(--text-primary);
    font-family: 'Geist', -apple-system, BlinkMacSystemFont, sans-serif;
    width: 100%;
    height: 100vh;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden;
    overscroll-behavior-y: none;
}

/* Оболонки всіх сторінок */
.main-page, .profile-page, .history-page, .stats-page {
    display: flex;
    justify-content: center;
    width: 100%;
    height: 100vh;
    background-color: var(--bg-dark) !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Головний контейнер телефону (ЖОДНИХ ПАДДІНГІВ ТУТ) */
.main-phone, .profile-phone, .history-phone, .stats-phone {
    background-color: var(--bg-dark) !important;
    width: 100%;
    max-width: 430px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    margin: 0 auto;
    padding: 0 !important; /* Саме це гарантує, що шапка торкається країв */
    box-shadow: none !important;
}

/* ===== 2. ІДЕАЛЬНА ШАПКА (Фон вгорі, текст опущений) ===== */
.main-header {
    background-color: var(--header-bg) !important;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;

    width: 100% !important;
    margin: 0 !important;

    padding: max(env(safe-area-inset-top, 20px), 20px) 20px 12px !important;

    min-height: calc(58px + env(safe-area-inset-top, 0px));
    box-sizing: border-box;
    border-bottom: 1px solid var(--line-soft);
    z-index: 1000;
    flex-shrink: 0;
}

.main-header-text {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary) !important;
    display: flex;
    align-items: center;
    margin: 0;
    line-height: 1;
    letter-spacing: -0.4px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

/* «red-part» ← теперь это «Calorie» — нейтральный белый. Имя класса оставлено,
   чтобы не править JSX. Зелёный акцент идёт на «Snap» (см. ниже). */
.red-part { color: var(--text-primary) !important; margin-right: 2px; }
.main-header-text > :not(.red-part) { color: var(--text-primary); }

/* Mechanical word for Gramix — sharp, industrial look (entire word) */
.red-part,
.red-part .mechanical-g,
.main-header-text > :not(.red-part) {
  font-family: Georgia, serif;
  font-weight: 700;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
}

.main-profile-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--surface-2);
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-primary);
    cursor: pointer;
    border: 1px solid var(--line-soft);
    margin: 0;
    flex-shrink: 0;
    position: absolute;
    right: 20px;
}

/* ===== 3. КОНТЕНТНА ОБЛАСТЬ (Паддінги тільки тут) ===== */
/* Ми забрали .scroll-container з цього списку, щоб він не стискав телефон */
.main-content, .profile-fixed-content, .stats-content, .history-content {
    flex: 1;
    width: 100%;
    height: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: none;

    padding: 10px 15px !important;
    padding-bottom: 180px !important;

    display: flex;
    flex-direction: column;
    gap: 8px;
    background-color: var(--bg-dark) !important;
}

/* Базовий клас скролу (без паддінгів, щоб не ламати сітку) */
.scroll-container {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.main-content::-webkit-scrollbar, .scroll-container::-webkit-scrollbar, .profile-fixed-content::-webkit-scrollbar {
    display: none;
}

/* ===== 4. НИЖНЯ НАВІГАЦІЯ ===== */
.main-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: calc(47px + env(safe-area-inset-bottom, 0px));
    background: var(--header-bg) !important;
    box-shadow: none !important;
    border-top: 1px solid var(--line-soft) !important;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    z-index: 2000;
    backdrop-filter: blur(12px);
}

.main-bottom-nav .nav-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
}

/* ===== 5. КАРТКА НОРМИ ТА БЖУ ===== */
.daily-norm-card {
    background-color: var(--card-bg);
    border: 1px solid var(--line-soft);
    border-radius: 22px;
    padding: 20px;
    box-shadow: 0 12px 32px -16px rgba(0, 0, 0, 0.4);
}

.norm-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
    color: var(--text-dim);
    letter-spacing: -0.1px;
}
.norm-title::first-letter { text-transform: uppercase; }

.progress-group { margin-bottom: 18px; }
.progress-group:last-child { margin-bottom: 0; }

.macro-info {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: -0.1px;
}
.macro-info > span:first-child { color: var(--text-dim); font-weight: 500; }
.macro-info > span:last-child { color: var(--text-primary); font-variant-numeric: tabular-nums; }

.progress-bg {
    width: 100%;
    height: 8px;
    background-color: var(--surface-2);
    border-radius: 4px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

.cal-fill { background-color: var(--accent-blue) !important; }   /* мятный */
.pro-fill { background-color: var(--accent-yellow) !important; } /* лавандовый */
.fat-fill { background-color: var(--accent-fat) !important; }    /* коралл */
.carb-fill { background-color: var(--accent-carb) !important; }  /* персик */

.progress-group.is-over .macro-info span { color: var(--brand-coral-deep) !important; font-weight: 700; }
.progress-group.is-over .progress-fill { background: var(--brand-coral) !important; }

/* ===== 6. СПИСОК СТРАВ ===== */
.meals-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dim);
    margin: 4px 4px 0;
    letter-spacing: 0.2px;
}
.meals-list { display: flex; flex-direction: column; gap: 10px; }
.meal-card {
    background-color: var(--card-bg);
    border: 1px solid var(--line-soft);
    border-radius: 16px;
    padding: 12px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
}
.meal-card:active { transform: scale(0.98); border-color: var(--brand-mint); }

.meal-card-img {
    width: 56px !important;
    height: 56px !important;
    min-width: 56px !important;
    min-height: 56px !important;
    border-radius: 14px;
    object-fit: cover !important;
    border: 1px solid var(--line-strong);
    margin-right: 12px;
}
.meal-card-info { flex: 1; min-width: 0; }
.meal-card-info h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
    letter-spacing: -0.1px;
    line-height: 1.3;
    text-wrap: pretty;
}
.meal-card-info p {
    color: var(--text-dim);
    font-size: 0.8rem;
    margin: 0;
    font-variant-numeric: tabular-nums;
}
.meal-card-info p .kcal-accent {
    color: var(--brand-mint-deep);
    font-weight: 600;
}

/* ===== 7. ПЛАВАЮЧІ КНОПКИ КАМЕРИ ===== */
.fab-container {
    position: fixed;
    bottom: calc(67px + env(safe-area-inset-bottom, 0px));
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1500;
}
.fab-btn {
    background-color: var(--brand-mint) !important;
    color: var(--bg-base);
    border: none;
    box-shadow: 0 12px 28px -8px var(--brand-mint-glow), 0 2px 6px rgba(0, 0, 0, 0.2);
    width: 60px;
    height: 60px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease;
}
.fab-btn:active { transform: scale(0.94); }
.fab-btn svg { width: 28px; height: 28px; }
/* Вторичные FAB-ки (галерея, ввод вручную) — вторичный визуальный вес. */
.fab-btn.pen,
.fab-btn:nth-child(n+2) {
    background-color: var(--surface-1) !important;
    color: var(--text-primary);
    border: 1px solid var(--line-strong);
    box-shadow: 0 6px 16px -8px rgba(0, 0, 0, 0.5);
}

/* ===== 8. ВІКНО РЕЗУЛЬТАТУ (Оверлей) ===== */
.result-overlay-full {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-dark);
    z-index: 2500;
    display: flex; justify-content: center;
}
.result-full-page {
    width: 100%;
    max-width: 430px;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
}

.sheet-header {
    display: flex; justify-content: center; align-items: center;
    padding-top: max(env(safe-area-inset-top, 20px), 20px);
    padding-bottom: 15px;
    width: 100%;
    position: relative;
    border-bottom: 1px solid var(--line-soft);
}
.sheet-logo-center { font-size: 1.4rem; font-weight: 700; text-align: center; margin: 0; color: var(--text-primary); letter-spacing: -0.4px;}
.sheet-close { position: absolute; right: 20px; background: none; border: none; color: var(--text-primary); font-size: 2.2rem; line-height: 1; cursor: pointer; }

.sheet-body { flex: 1; overflow-y: auto; padding: 20px; }
.sheet-top-info { display: flex; gap: 15px; margin-bottom: 20px; align-items: center; }
.sheet-img {
    width: 96px !important; height: 96px !important;
    min-width: 96px !important; min-height: 96px !important;
    border-radius: 22px; object-fit: cover !important;
    border: 1px solid var(--line-strong);
    flex-shrink: 0;
}
.sheet-img--no-photo {
    background-color: var(--surface-2);
}

.edit-name-input {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--brand-mint);
    color: var(--text-primary);
    font-size: 1.3rem;
    font-weight: 700;
    width: 100%;
    outline: none;
    padding-bottom: 5px;
    letter-spacing: -0.4px;
}
.sheet-cals {
    color: var(--brand-mint-deep);
    font-size: 1.4rem;
    font-weight: 700;
    margin: 8px 0;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.4px;
}
.sheet-macros-line { color: var(--text-dim); font-size: 0.85rem; line-height: 1.4; font-variant-numeric: tabular-nums; }

.sheet-divider { height: 1px; background: var(--line-soft); margin: 20px 0; width: 100%; }

.weight-editor label { color: var(--text-dim); font-size: 0.85rem; display: block; margin-bottom: 10px; font-weight: 500; }
.editor-row { display: flex; gap: 10px; margin-bottom: 25px; }
.editor-row input {
    flex: 1;
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    color: var(--text-primary);
    padding: 12px;
    outline: none;
    font-size: 1rem;
    font-family: inherit;
}
.editor-row input:focus { border-color: var(--brand-mint); }
.editor-row button {
    background: var(--brand-mint);
    border: none;
    color: var(--bg-base);
    border-radius: 12px;
    padding: 0 16px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}

.ingredients-section h4 { margin-bottom: 15px; font-size: 1rem; font-weight: 600; color: var(--text-primary); letter-spacing: -0.1px; }
.ing-item {
    background: var(--surface-2);
    border: 1px solid var(--line-soft);
    border-radius: 14px;
    padding: 12px 0 12px 15px !important;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    overflow: hidden;
}
.ing-name { color: var(--text-primary); font-weight: 600; display: block; margin-bottom: 4px; letter-spacing: -0.1px; }
.ing-details p { font-size: 0.82rem; color: var(--text-dim) !important; margin-top: 4px; font-variant-numeric: tabular-nums; }
.ing-details span { color: var(--text-dim) !important; }
.ing-details .kcal-accent { color: var(--brand-mint-deep) !important; font-weight: 600; }

.ing-actions-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    border-left: 1px solid var(--line-soft);
    margin-left: 12px;
    min-width: 44px;
}
.ing-action-divider {
    width: 100%;
    height: 1px;
    background: var(--line-soft);
}
.remove-ing-btn, .edit-ing-btn {
    flex: 1;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0;
}
.remove-ing-btn { color: var(--text-mute); }
.edit-ing-btn { color: var(--text-mute); }
.edit-ing-btn:hover { color: var(--brand-mint-deep); }

.ing-search-wrapper { position: relative; }
.ing-search-suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    max-height: 150px;
    overflow-y: auto;
    z-index: 10;
}
.ing-search-suggestions.above {
    top: auto;
    bottom: calc(100% + 4px);
}
.ing-suggestion-item {
    padding: 10px 14px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--line-soft);
}
.ing-suggestion-item:last-child { border-bottom: none; }
.ing-suggestion-item:active { background: var(--surface-1); }

.ing-kcal-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.ing-kcal-row label { color: var(--text-dim); font-size: 0.85rem; white-space: nowrap; }
.ing-kcal-row input { flex: 1; }

.ing-three-btns { display: flex; gap: 8px; }
.ing-three-btns .manual-cancel-btn { flex: 1; }
.ing-three-btns .ing-save-btn {
    flex: 1.2;
    height: 48px;
    background: var(--surface-2);
    color: var(--text-primary);
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
}
.ing-three-btns .ing-save-btn:disabled { opacity: 0.4; cursor: default; }
.ing-three-btns .manual-submit-btn { flex: 1.5; }

.ing-confirm-msg {
    color: var(--text-primary);
    font-size: 1rem;
    text-align: center;
    margin: 4px 0 8px;
}

/* Equal-size buttons inside ingredient edit/delete popups */
.ing-edit-modal .manual-cancel-btn,
.ing-edit-modal .manual-submit-btn {
    flex: 1;
    height: 48px;
}

/* Red delete button in the delete-ingredient confirm popup */
.ing-delete-confirm-btn {
    flex: 1;
    height: 48px;
    background: var(--brand-coral);
    color: var(--bg-base);
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
}

.sheet-footer {
    padding: 15px !important;
    background: var(--card-bg);
    width: 100%;
    border-top: 1px solid var(--line-soft);
    padding-bottom: max(env(safe-area-inset-bottom, 0px), 15px) !important;
    backdrop-filter: blur(12px);
}

.combined-ingredients {
    background: var(--card-bg, #161D18);
    border: 1px solid var(--line-soft);
    border-radius: 16px;
    padding: 16px;
    margin-top: 16px;
}
.combined-ingredients-title {
    color: var(--text-primary, #ECF1ED);
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 10px 0;
}
.edits-left-badge {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-bottom: 8px;
}
.action-buttons-row { display: flex; flex-direction: row; gap: 10px; width: 100%; }
.save-btn-large, .delete-meal-btn-v2 {
    flex: 1; height: 52px; border-radius: 14px; font-size: 1rem; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; letter-spacing: -0.1px;
}
.save-btn-large {
    flex: 2;
    background: var(--brand-mint);
    color: var(--bg-base);
    border: none;
    box-shadow: 0 6px 16px -6px var(--brand-mint-glow);
}
.delete-meal-btn-v2 {
    background: var(--surface-2);
    color: var(--text-dim);
    border: 1px solid var(--line-strong);
}

.bomb-save-btn {
    margin-top: 28px;
    background: var(--brand-mint);
    color: var(--bg-base);
    border: none;
    border-radius: 14px;
    padding: 13px 34px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 16px -6px var(--brand-mint-glow);
}

/* ===== 9. СПІНЕР ===== */
.analyzing-overlay {
    position: fixed; inset: 0; background: rgba(14, 20, 16, 0.92); backdrop-filter: blur(8px); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 3000;
}
.analyzing-overlay--fullscreen {
    background: var(--bg-base);
    backdrop-filter: none;
    padding: 32px 24px;
}
.analyzing-photo {
    width: min(72vw, 320px);
    height: min(72vw, 320px);
    object-fit: cover;
    border-radius: 24px;
    margin-bottom: 28px;
    box-shadow: 0 12px 32px -10px rgba(0,0,0,0.6);
}
.loading-spinner {
    width: 56px; height: 56px;
    border: 4px solid var(--surface-2);
    border-top: 4px solid var(--brand-mint);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}
.analyzing-cancel-btn {
    margin-top: 24px;
    min-width: 140px;
    height: 44px;
    padding: 0 22px;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    background: var(--surface-1);
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
    font-family: inherit;
}
.analyzing-cancel-btn:active { background: var(--surface-2); }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* ===== 10. ТАБЛИЦЯ ІСТОРІЇ ===== */
.ingredients-table-card {
    background: var(--card-bg);
    border-radius: 22px;
    padding: 20px;
    border: 1px solid var(--line-soft);
}

.table-header {
    display: flex;
    justify-content: space-between;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line-soft);
    font-size: 0.72rem;
    color: var(--text-mute);
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.col-weight { width: 50px; }
.col-name { flex: 1; padding: 0 10px; }
.col-metrics { display: flex; gap: 8px; width: 150px; justify-content: flex-end; }
.col-metrics span { width: 32px; text-align: center; }

.table-row {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--line-soft);
}
.table-row:last-child { border-bottom: none; }

.ing-weight { width: 50px; color: var(--text-dim); font-weight: 600; font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.ing-name-wrap { flex: 1; color: var(--text-primary); font-weight: 600; font-size: 0.92rem; padding: 0 10px; word-break: break-word; line-height: 1.25; letter-spacing: -0.1px; }

.ing-metrics { display: flex; gap: 8px; width: 150px; justify-content: flex-end; }
.ing-metrics span { width: 32px; text-align: center; font-size: 0.82rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.m-cal { color: var(--brand-mint-deep); }
.m-val { color: var(--text-dim); }

.empty-msg { text-align: center; padding: 30px; color: var(--text-mute); font-size: 0.95rem; }

/* ===== INGREDIENT EDIT POPUP ===== */
.ing-item-info { flex: 1; }
.ing-edit-modal {
    background: var(--surface-1);
    border-radius: 20px;
    padding: 24px;
    width: calc(100% - 48px);
    max-width: 340px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border: 1px solid var(--line-strong);
    box-shadow: 0 24px 60px -16px rgba(0, 0, 0, 0.7);
}
.ing-edit-modal h4 {
    color: var(--text-primary);
    font-size: 1.05rem;
    font-weight: 700;
    text-align: center;
    margin: 0;
    letter-spacing: -0.2px;
}
.ing-edit-loading {
    display: flex;
    justify-content: center;
    padding: 8px 0;
}
.ing-edit-loading .loading-spinner {
    width: 36px; height: 36px;
    margin-bottom: 0;
}

/* ===== MANUAL TEXT ENTRY MODAL ===== */
.manual-entry-card {
    background: var(--surface-1);
    border-radius: 20px;
    padding: 24px;
    width: calc(100% - 48px);
    max-width: 380px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    border: 1px solid var(--line-strong);
    box-shadow: 0 24px 60px -16px rgba(0, 0, 0, 0.7);
}
.manual-entry-label {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    margin: 0;
}
.manual-entry-textarea {
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    padding: 12px;
    resize: none;
    outline: none;
    width: 100%;
    box-sizing: border-box;
    line-height: 1.5;
}
.manual-entry-textarea:focus { border-color: var(--brand-mint); }
.manual-entry-actions {
    display: flex;
    gap: 10px;
}
.manual-cancel-btn {
    flex: 1;
    height: 48px;
    background: var(--surface-2);
    color: var(--text-dim);
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}
.manual-submit-btn {
    flex: 2;
    height: 48px;
    background: var(--brand-mint);
    color: var(--bg-base);
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 6px 16px -8px var(--brand-mint-glow);
}
.manual-submit-btn:disabled { opacity: 0.4; cursor: default; }

/* pen FAB sizing — matches camera/gallery button scale */
.fab-btn.pen {
    width: 65px;
    height: 65px;
}
.fab-btn.pen img {
    width: 44px;
    height: 44px;
    object-fit: contain;
}

/* ===== ERROR MODAL CARD ===== */
.error-modal-card {
    background: var(--surface-1);
    border-radius: 22px;
    padding: 32px 24px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: min(320px, 88vw);
    border: 1px solid var(--line-strong);
    box-shadow: 0 24px 60px -16px rgba(0, 0, 0, 0.7);
}
.error-modal-logo {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.3px;
}
.error-circle-illustration {
    margin: 4px 0 2px;
}
.error-modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin: 0;
    line-height: 1.4;
}
.error-ok-btn {
    margin-top: 4px;
    background: var(--brand-mint);
    color: var(--bg-base);
    border: none;
    border-radius: 14px;
    padding: 13px 0;
    width: 100%;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 6px 16px -8px var(--brand-mint-glow);
}
.error-stub-image {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--surface-1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

/* ===== MANUAL ENTRY PAGE ===== */
.manual-entry-page {
    position: fixed;
    inset: 0;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    z-index: 100;
}
.manual-entry-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(env(safe-area-inset-top, 12px) + 12px) 16px 12px;
    background: var(--bg-dark);
    border-bottom: 1px solid var(--line-soft);
    flex-shrink: 0;
}
.me-back-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}
.me-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    text-align: center;
}
.me-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.me-placeholder-img {
    width: 120px;
    height: 120px;
    border-radius: 60px;
    background: var(--surface-1);
    border: 1.5px dashed var(--line-strong);
    color: var(--brand-mint);
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    flex-shrink: 0;
}
.me-field-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.me-field-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-mute);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.me-text-input {
    background: var(--surface-1);
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.95rem;
    padding: 12px 14px;
    outline: none;
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
}
.me-text-input:focus { border-color: var(--brand-mint); }
.me-ingredients-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.me-ingredient-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.me-ing-name { flex: 2; min-width: 0; }
.me-ing-grams { flex: 1; min-width: 60px; }
.me-ing-macro {
    flex: 1;
    min-width: 50px;
    text-align: right;
    color: var(--text-mute);
    font-size: 15px;
    font-weight: 500;
    padding-right: 4px;
}
.me-ingredients-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.me-ingredients-label { margin-bottom: 0; }
.me-macro-select {
    background: var(--surface-1);
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    padding: 6px 10px;
    cursor: pointer;
}
.me-remove-btn {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    background: var(--surface-2);
    border: 1px solid var(--line-soft);
    border-radius: 10px;
    color: var(--text-mute);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.me-add-ingredient-btn {
    background: transparent;
    border: 1.5px dashed var(--brand-mint);
    border-radius: 12px;
    color: var(--brand-mint);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    padding: 12px;
    text-align: center;
    width: 100%;
    font-family: inherit;
}
.me-validation-error {
    color: var(--brand-coral-deep);
    font-size: 0.85rem;
    text-align: center;
    margin: 0;
}
.me-footer {
    padding: 12px 16px calc(env(safe-area-inset-bottom, 12px) + 12px);
    background: var(--bg-dark);
    border-top: 1px solid var(--line-soft);
    flex-shrink: 0;
}
.me-submit-btn {
    background: var(--brand-mint);
    color: var(--bg-base);
    border: none;
    border-radius: 16px;
    padding: 16px;
    width: 100%;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 8px 20px -8px var(--brand-mint-glow);
}
.me-submit-btn:disabled { opacity: 0.5; cursor: default; }

/* ===== 11. КАЛЕНДАР ТА СЕЛЕКТОР ПЕРІОДІВ (Статистика та Історія) ===== */
.period-selector {
    display: flex;
    justify-content: space-around;
    background: var(--card-bg);
    padding: 4px;
    border-radius: 14px;
    border: 1px solid var(--line-soft);
    gap: 2px;
}
.period-selector button {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 9px 0;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.18s, color 0.18s;
}
.period-selector button.active { background: var(--brand-mint); color: var(--bg-base); }

.calendar-card {
    background: var(--card-bg);
    border-radius: 22px;
    padding: 20px;
    border: 1px solid var(--line-soft);
}
.calendar-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.calendar-nav h3 { font-size: 1rem; text-transform: capitalize; color: var(--text-primary); font-weight: 600; margin: 0; letter-spacing: -0.2px;}
.nav-btns button { background: var(--surface-2); border: 1px solid var(--line-soft); color: var(--text-primary); padding: 5px 12px; border-radius: 8px; margin-left: 8px; font-weight: 600; cursor: pointer; font-family: inherit; }

/* СІТКА КАЛЕНДАРЯ */
.calendar-grid { 
    display: grid; 
    grid-template-columns: repeat(7, 1fr); 
    gap: 8px; 
    text-align: center; 
}
.weekday { font-size: 0.7rem; color: var(--text-mute); font-weight: 600; margin-bottom: 5px; letter-spacing: 0.4px; text-transform: uppercase; }
.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 50%;
    cursor: pointer;
    font-variant-numeric: tabular-nums;
}

/* Кольори днів */
.calendar-day.day-good { color: var(--brand-mint); }
.calendar-day.day-over { color: var(--brand-coral-deep); }
.calendar-day.day-empty { color: var(--text-mute); }
.calendar-day.day-future { color: var(--text-mute); opacity: 0.4; pointer-events: none; }

/* ── Photo fullscreen popup ── */
.photo-fullscreen-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.93);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.photo-fullscreen-wrap {
    position: relative;
    display: inline-block;
    max-width: 95vw;
    max-height: 85vh;
    line-height: 0;
}
.photo-fullscreen-img {
    display: block;
    max-width: 95vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 12px;
}
.photo-fullscreen-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
}

/* ── History day meal cards ── */
.history-day-meals {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}
.history-meal-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card-bg);
    border: 1px solid var(--line-soft);
    border-radius: 16px;
    padding: 10px 14px;
}
.history-meal-img {
    width: 56px !important;
    height: 56px !important;
    min-width: 56px !important;
    border-radius: 14px;
    object-fit: cover;
    border: 1px solid var(--line-strong);
    cursor: pointer;
    flex-shrink: 0;
}
.history-meal-info h4 {
    margin: 0 0 2px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}
.history-meal-info p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}
.calendar-day.selected { background: var(--brand-mint) !important; color: var(--bg-base) !important; border: none;}
/* ===== HOME REDESIGN (rings + nav + bottom-sheet) ===== */
.home-date-row {
  padding: 4px 18px 6px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.home-date-sub {
  display: none;
}
.home-date-today {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}
.home-date-main {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.1px;
  color: var(--text-dim);
  text-transform: capitalize;
}
.home-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: var(--surface-1);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 14px;
  color: var(--text-dim);
  font-weight: 600;
}
.home-status-pill.is-over { color: var(--brand-coral-deep); }
.home-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 3px;
  background: var(--brand-mint);
}
.home-status-pill.is-over .home-status-dot { background: var(--brand-coral); }

.home-rings-card {
  margin: 0 4px 6px;
  padding: 16px 16px;
  background: var(--surface-1);
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.ring-kcal {
  font-size: 46px;
  font-weight: 700;
  letter-spacing: -1.2px;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.ring-kcal.is-over { color: #ffffff; }
.ring-kcal-eaten {
  font-size: 41px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--brand-mint);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
}
.ring-kcal-eaten.is-over { color: var(--brand-coral); }
.ring-kcal-of {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.75);
  font-weight: 500;
  margin-top: 4px;
  white-space: nowrap;
}
.ring-kcal-rem {
  font-size: 12px;
  color: var(--brand-mint);
  font-weight: 600;
  margin-top: 4px;
  white-space: nowrap;
}
.ring-kcal-rem.is-over { color: var(--brand-coral); }

.home-mini-rings {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
  width: 100%;
}
.home-mini-ring {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.mini-ring-val {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.mini-ring-val.is-over { color: var(--brand-coral); }
.mini-ring-goal {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 500;
  white-space: nowrap;
}
.home-mini-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Pulse on over-norm — heart rhythm (lub-dub then rest) */
.ring-progress.ring-pulse {
  animation: ring-heartbeat 1.1s ease-in-out infinite;
  transform-origin: center;
  will-change: transform, filter;
}
@keyframes ring-heartbeat {
  0%   { transform: scale(1);    filter: drop-shadow(0 0 0   oklch(0.74 0.14 30 / 0)); }
  8%   { transform: scale(1.06); filter: drop-shadow(0 0 16px oklch(0.74 0.14 30 / 0.65)); }
  16%  { transform: scale(1.01); filter: drop-shadow(0 0 4px  oklch(0.74 0.14 30 / 0.25)); }
  26%  { transform: scale(1.04); filter: drop-shadow(0 0 12px oklch(0.74 0.14 30 / 0.55)); }
  40%  { transform: scale(1);    filter: drop-shadow(0 0 0   oklch(0.74 0.14 30 / 0)); }
  100% { transform: scale(1);    filter: drop-shadow(0 0 0   oklch(0.74 0.14 30 / 0)); }
}

/* Meal card stats row */
.meal-card-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.meal-card-row h3 {
  flex: 1;
  min-width: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.1px;
  color: var(--text-primary);
}
.meal-card-time {
  font-size: 13px;
  color: var(--text-mute);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  margin-top: 1px;
}
.meal-card-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.meal-card-kcal {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--brand-mint-deep);
  font-weight: 600;
}
.meal-card-dot {
  width: 2px;
  height: 2px;
  border-radius: 1px;
  background: var(--line-strong);
}
.meal-card-bju {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.meal-bju-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.meal-bju-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* Floating camera button (single FAB) */
.home-fab {
  position: fixed;
  right: max(22px, calc((100vw - 430px) / 2 + 22px));
  bottom: 100px;
  width: 60px;
  height: 60px;
  border-radius: 30px;
  background: var(--brand-mint);
  color: #0E1410;
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow:
    0 12px 28px -8px var(--brand-mint-glow),
    0 2px 6px rgba(0, 0, 0, 0.2);
  z-index: 50;
  font-family: inherit;
}
.home-fab:active { transform: scale(0.96); }
.home-fab-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 22px;
  height: 22px;
  border-radius: 11px;
  background: #0E1410;
  color: var(--brand-mint);
  display: grid;
  place-items: center;
  border: 2px solid var(--bg-base);
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
}

/* Bottom tab bar (Home / Stats only) */
.home-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding-bottom: max(env(safe-area-inset-bottom, 20px), 20px);
  padding-top: 10px;
  background: linear-gradient(180deg, rgba(14, 20, 16, 0) 0%, rgba(14, 20, 16, 0.92) 30%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 40;
}
.home-tabbar-inner {
  margin: 0 18px;
  max-width: 430px;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: var(--surface-1);
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  padding: 6px;
}
.home-tab {
  flex: 1;
  padding: 10px 8px;
  border-radius: 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--text-dim);
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.18s;
}
.home-tab.is-active {
  background: var(--surface-2);
  color: var(--brand-mint-deep);
}

/* Add bottom-sheet popup */
.add-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 9000;
  animation: add-sheet-bg 0.18s ease-out;
}
@keyframes add-sheet-bg {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.add-sheet {
  width: 100%;
  max-width: 430px;
  background: var(--surface-1);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  border-top: 1px solid var(--line-strong);
  padding: 10px 18px max(env(safe-area-inset-bottom, 24px), 24px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: add-sheet-up 0.22s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
@keyframes add-sheet-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.add-sheet-grip {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--line-strong);
  margin: 4px auto 8px;
}
.add-sheet-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  letter-spacing: -0.3px;
  padding-bottom: 6px;
}
.add-sheet-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--text-primary);
  transition: transform 0.1s;
}
.add-sheet-row:active { transform: scale(0.98); }
.add-sheet-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: oklch(0.78 0.14 165 / 0.14);
  color: var(--brand-mint);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.add-sheet-text { flex: 1; min-width: 0; }
.add-sheet-row-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.1px;
}
.add-sheet-row-sub {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
  font-weight: 500;
}
.add-sheet-cancel {
  margin-top: 4px;
  height: 48px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  border-radius: 12px;
}

/* ===== Manual entry — фото placeholder (пустое состояние) ===== */
.me-photo-placeholder {
  width: 100%;
  height: 240px;
  border-radius: 22px;
  background: var(--surface-1);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin: 0 0 16px;
  overflow: hidden;
  pointer-events: none;
}
.me-photo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.me-submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.me-submit-hint {
  text-align: center;
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--text-mute);
  font-weight: 500;
}
/* ===== Meal detail (08) — pixel-perfect overlay ===== */

.meal-detail-page {
  position: absolute;
  inset: 0;
  background: var(--bg-base);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 3000;
}

/* Hero */
.md-hero {
  position: relative;
  height: 240px;
  background: var(--surface-2);
  flex-shrink: 0;
  overflow: hidden;
}
.md-hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
}
.md-hero-img-stub {
  object-fit: contain;
  padding: 40px;
  opacity: 0.55;
  cursor: default;
}
.md-hero-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
}
.md-hero-placeholder-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-mute);
}
.md-hero-placeholder-inner svg {
  opacity: 0.6;
}
.md-hero-placeholder-inner span {
  font-size: 16px;
  font-weight: 500;
}
.md-hero-grad {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(14, 20, 16, 0.45) 0%,
    rgba(14, 20, 16, 0.05) 45%,
    var(--bg-base) 100%
  );
  pointer-events: none;
}
.md-back-btn {
  position: absolute;
  top: 52px;
  left: 18px;
  width: 36px;
  height: 36px;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #fff;
  z-index: 2;
}

/* Body */
.md-body {
  padding: 0 18px;
  flex: 1;
}

.md-title-block {
  padding: 14px 0 0;
}
.md-title-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.4px;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  padding: 0;
  resize: none;
  min-height: 1.25em;
  word-break: break-word;
}
.md-title-input:focus {
  background: var(--surface-1);
  border-radius: 8px;
  padding: 4px 8px;
  margin: -4px -8px;
}

/* Stat strip */
.md-stat-strip {
  margin-top: 12px;
  padding: 16px;
  background: var(--surface-1);
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.5);
}
.md-stat-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}
.md-stat-cell {
  min-width: 0;
}
.md-stat-right {
  text-align: right;
}
.md-stat-label {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.6px;
  font-weight: 600;
  text-transform: uppercase;
}
.md-stat-cals {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.8px;
  color: var(--brand-mint-deep);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
  line-height: 1;
}
.md-stat-weight {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.4px;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
  line-height: 1;
}
.md-stat-unit {
  font-size: 16px;
  color: var(--text-dim);
  font-weight: 500;
}

/* BJU pills */
.md-bju-pills {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.md-bju-pill {
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 12px;
  min-width: 0;
}
.md-bju-pill-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}
.md-bju-dot {
  width: 7px;
  height: 7px;
  border-radius: 4px;
  flex-shrink: 0;
}
.md-bju-name {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
  line-height: 1.25;
  word-break: break-word;
}
.md-bju-val {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.3px;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}
.md-bju-unit {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
}

/* Compact weight editor */
.md-weight-editor {
  margin-top: 12px;
  padding: 12px;
  background: var(--surface-1);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.md-weight-label {
  font-size: 14px;
  color: var(--text-dim);
  font-weight: 500;
  flex-shrink: 0;
}
.md-weight-input {
  flex: 1;
  min-width: 0;
  max-width: 110px;
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0 10px;
}
.md-weight-input input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 8px 0;
  width: 100%;
}
.md-weight-input-unit {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
  margin-left: 4px;
}
.md-recalc-btn {
  margin-left: auto;
  padding: 0 12px;
  height: 36px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  background: var(--brand-mint);
  color: var(--bg-base);
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.1px;
  white-space: nowrap;
  flex-shrink: 1;
  min-width: 0;
}
.md-recalc-btn:active {
  transform: scale(0.97);
}

/* Ingredients header */
.md-ing-header {
  margin-top: 16px;
  padding: 0 2px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.md-ing-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}
.md-ing-count {
  color: var(--text-mute);
  font-weight: 500;
}
.md-ing-add {
  background: none;
  border: none;
  color: var(--brand-mint-deep);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Ingredient cards */
.md-ing-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.md-ing-card {
  padding: 12px;
  border-radius: 14px;
  background: var(--surface-1);
  border: 1px solid var(--line-soft);
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.md-ing-info {
  flex: 1;
  min-width: 0;
}
.md-ing-name-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.md-ing-name {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.1px;
  color: var(--text-primary);
}
.md-ing-w {
  font-size: 13px;
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.md-ing-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 16px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.md-ing-kcal {
  color: var(--brand-mint-deep);
  font-weight: 700;
  font-size: 18px;
}
.md-ing-sep {
  width: 2px;
  height: 2px;
  border-radius: 1px;
  background: var(--line-strong);
}
.md-ing-tags {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.md-ing-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.md-ing-tag-dot {
  width: 6px;
  height: 6px;
  border-radius: 3px;
}
.md-ing-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.md-ing-iconbtn {
  width: 30px;
  height: 30px;
  border-radius: 15px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  padding: 0;
}
.md-ing-iconbtn:active {
  transform: scale(0.95);
}
.md-ing-delete-btn {
  background: var(--surface-2);
  border-color: var(--line-soft);
  color: var(--text-dim);
}

/* Edits remaining hint */
.md-edits-hint {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-mute);
  font-weight: 500;
}

/* Save dock */
.md-save-dock {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  padding: 12px 18px calc(env(safe-area-inset-bottom, 12px) + 16px);
  background: rgba(14, 20, 16, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line-soft);
  display: flex;
  gap: 10px;
  z-index: 10;
}
.md-delete-btn {
  flex: 1;
  padding: 13px 0;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--line-strong);
  font-family: inherit;
  font-weight: 600;
  font-size: 17px;
  cursor: pointer;
}
.md-save-btn {
  flex: 2;
  padding: 13px 0;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  background: var(--brand-mint);
  color: var(--bg-base);
  font-family: inherit;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.1px;
  box-shadow: 0 6px 16px -6px var(--brand-mint-glow);
}
.md-save-btn:only-child {
  flex: 1;
}
.md-save-btn:active,
.md-delete-btn:active {
  transform: scale(0.98);
}
.onb-page {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
  color: var(--text-primary);
  padding: 0 24px;
  overflow: hidden;
}

.onb-glow {
  position: absolute;
  top: 60px;
  left: 50%;
  width: 360px;
  height: 360px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, var(--brand-mint) 0%, transparent 60%);
  opacity: 0.10;
  filter: blur(60px);
  pointer-events: none;
  z-index: 0;
}

.onb-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 1;
  padding: 24px 0;
}

.onb-icon {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: var(--surface-1);
  border: 1px solid var(--line-soft);
  color: var(--brand-mint);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 32px;
  box-shadow: 0 16px 32px -16px var(--brand-mint-glow, rgba(0, 0, 0, 0.4));
}
.onb-icon svg { width: 64px; height: 64px; }

.onb-title {
  font-size: 30px;
  font-weight: 700;
  margin: 0 0 12px;
  letter-spacing: -0.6px;
  line-height: 1.15;
  max-width: 320px;
}

.onb-desc {
  font-size: 16px;
  color: var(--text-dim);
  line-height: 1.5;
  margin: 0;
  max-width: 320px;
}

.onb-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 16px;
  z-index: 1;
}
.onb-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--surface-2);
  transition: background 0.18s ease, width 0.18s ease;
}
.onb-dot.is-active {
  background: var(--brand-mint);
  width: 22px;
  border-radius: 4px;
}

.onb-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 1;
}

.onb-primary {
  height: 56px;
  background: var(--brand-mint);
  color: var(--bg-base);
  border: none;
  border-radius: 18px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.1px;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.2s, transform 0.1s;
  box-shadow: 0 8px 20px -6px var(--brand-mint-glow, rgba(14, 155, 142, 0.4));
}
.onb-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.onb-primary:active:not(:disabled) { transform: scale(0.98); }

.onb-skip {
  background: transparent;
  border: none;
  color: var(--text-mute);
  font-size: 14px;
  font-weight: 500;
  padding: 10px;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.1px;
}
.onb-skip:disabled { opacity: 0.4; cursor: not-allowed; }

/* Coachmark over /main FAB. No backdrop — the FAB stays tappable; tapping it
 * dismisses the hint and opens the add-sheet in one motion. */
.coachmark-pulse,
.coachmark-bubble {
  position: fixed;
  z-index: 49;
  pointer-events: none;
}
.coachmark-pulse {
  right: max(22px, calc((100vw - 430px) / 2 + 22px));
  bottom: 100px;
  width: 60px;
  height: 60px;
  border-radius: 30px;
  border: 2px solid var(--brand-mint);
  animation: coach-pulse 1.4s ease-out infinite;
}
.coachmark-bubble {
  right: max(22px, calc((100vw - 430px) / 2 + 22px));
  bottom: 175px;
  background: var(--brand-mint);
  color: var(--bg-base);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.1px;
  border-radius: 12px;
  padding: 10px 14px;
  max-width: 220px;
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.5);
  animation: coach-fade-in 0.3s ease;
}
.coachmark-bubble::after {
  content: "";
  position: absolute;
  right: 24px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  background: var(--brand-mint);
  transform: rotate(45deg);
  border-radius: 2px;
}
@keyframes coach-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes coach-pulse {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.4); opacity: 0; }
}
/* Geist font is loaded once in src/index.css */

:root {
    --primary-red: var(--brand-mint);
    --bg-dark: var(--bg-base);
    --header-bg: var(--surface-1);
    --card-bg: var(--surface-1);
    --text-gray: var(--text-dim);
    --accent-gold: var(--brand-mint);
}

/* ===== СТАТИСТИКА - ОПТИМІЗОВАНА АРХІТЕКТУРА ===== */
.stats-page {
    display: flex;
    justify-content: center;
    height: 100vh;
    width: 100%;
    background: var(--bg-dark) !important;
    overflow: hidden;
    overscroll-behavior-y: none;
}

.stats-phone {
    width: 100%;
    max-width: 430px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--bg-dark) !important;
    box-shadow: none !important;
}

/* Хедер (Синхронізовано з Головною) */
.stats-header {
    background-color: var(--header-bg) !important;
    display: flex;
    justify-content: center;
    align-items: center;
    padding-top: calc(env(safe-area-inset-top, 20px) + 20px) !important;
    padding-bottom: 15px !important;
    width: 100%;
    min-height: 60px;
    height: auto;
    box-sizing: border-box;
    border-bottom: 1px solid var(--line-soft);
    z-index: 1000;
    flex-shrink: 0;
    position: relative;
}

.stats-header-text { font-size: 1.4rem; font-weight: 700; color: var(--text-primary); letter-spacing: -0.4px;}
.stats-header-text span:first-child,
.stats-header-text span:last-child {
  color: var(--text-primary);
  font-family: Georgia, serif;
  font-weight: 700;
}

.stats-profile-icon {
    position: absolute;
    right: 20px;
    background: var(--surface-2);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    border: 1px solid var(--line-soft);
    color: var(--text-primary);
}

/* Контентна частина */
.stats-content {
    flex: 1;
    height: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: none;
    padding: 20px;
    padding-bottom: 100px !important; /* Уніфікований відступ */
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.stats-content::-webkit-scrollbar { display: none; }

/* Селектор періодів */
.period-selector {
    display: flex;
    justify-content: space-around;
    background: var(--card-bg);
    padding: 4px;
    border-radius: 14px;
    border: 1px solid var(--line-soft);
    gap: 2px;
}
.period-selector button {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 9px 0;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.18s, color 0.18s;
}
.period-selector button.active { background: var(--brand-mint); color: var(--bg-base); }

/* Календар */
.calendar-card {
    background: var(--card-bg);
    border-radius: 22px;
    padding: 20px;
    border: 1px solid var(--line-soft);
}
.calendar-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.calendar-nav h3 { font-size: 1rem; text-transform: capitalize; color: var(--text-primary); font-weight: 600; letter-spacing: -0.2px;}
.calendar-toggle { display: inline-flex; align-items: center; gap: 6px; background: transparent; border: none; padding: 0; margin: 0; color: var(--text-primary); font: inherit; font-size: 1rem; font-weight: 600; letter-spacing: -0.2px; cursor: pointer; font-family: inherit; }
.calendar-toggle .calendar-chev { transition: transform 0.18s ease; color: var(--text-dim); }
.calendar-toggle .calendar-chev.open { transform: rotate(180deg); }
.nav-btns button { background: var(--surface-2); border: 1px solid var(--line-soft); color: var(--text-primary); padding: 5px 12px; border-radius: 8px; margin-left: 8px; font-weight: 600; cursor: pointer; font-family: inherit;}

.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; text-align: center; }
.weekday { font-size: 0.7rem; color: var(--text-mute); font-weight: 600; margin-bottom: 5px; letter-spacing: 0.4px; text-transform: uppercase; }
.calendar-day { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; font-weight: 600; border-radius: 50%; cursor: pointer; font-variant-numeric: tabular-nums; }

/* Чисті правила кольорів для днів */
.calendar-day.day-good { color: var(--brand-mint); }
.calendar-day.day-over { color: var(--brand-coral-deep); }
.calendar-day.day-empty { color: var(--text-mute); }
.calendar-day.day-future { color: var(--text-mute); opacity: 0.4; pointer-events: none; }
.calendar-day.selected { background: var(--brand-mint) !important; color: var(--bg-base) !important; border: none;}

/* Картка підсумків */
.stats-card {
    background: var(--card-bg);
    border-radius: 22px;
    padding: 20px;
    border: 1px solid var(--line-soft);
}
.stats-title { font-size: 0.9rem; color: var(--text-dim); margin-bottom: 15px; font-weight: 600; letter-spacing: -0.1px; }
.stats-row { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 0.9rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.stats-progress-bar { width: 100%; height: 8px; background-color: var(--surface-2); border-radius: 4px; margin-bottom: 18px; overflow: hidden; }
.stats-progress-fill { height: 100%; border-radius: 4px; transition: width 0.6s ease; }

.cal-fill { background-color: var(--brand-mint); }
.pro-fill { background-color: var(--brand-lilac); }
.fat-fill { background-color: var(--brand-coral); }
.carb-fill { background-color: var(--brand-peach); }
.fill-exceeded { background: var(--brand-coral) !important; }

/* Список страв */
.meals-list-card {
    background: var(--card-bg);
    border-radius: 22px;
    padding: 10px 20px;
    border: 1px solid var(--line-soft);
    display: flex; flex-direction: column;
}
.stats-meals h3 { font-size: 1rem; margin-bottom: 12px; margin-top: 10px; color: var(--text-primary); font-weight: 600; letter-spacing: -0.1px;}
.meal-item-row { padding: 14px 0; border-bottom: 1px solid var(--line-soft); display: flex; justify-content: space-between; align-items: center; }
.meal-item-row:last-child { border-bottom: none; }
.meal-name { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; letter-spacing: -0.1px; }
.meal-sub-calories { font-size: 0.85rem; color: var(--brand-mint-deep); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ===== Category breakdown ===== */
.category-breakdown {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.cat-section-title {
    font-size: 0.9rem;
    color: var(--text-dim);
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.1px;
}

/* Header row: section title left, sort dropdown right. */
.cat-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
    margin-bottom: 4px;
    gap: 12px;
}

/* Sort dropdown — anchor on the right edge of the section header. */
.cat-sort {
    position: relative;
}
.cat-sort-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 10px;
    border-radius: 10px;
    background: var(--surface-1);
    border: 1px solid var(--line-soft);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    letter-spacing: -0.1px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
    text-transform: capitalize;
}
.cat-sort.open .cat-sort-trigger,
.cat-sort-trigger:active {
    border-color: var(--brand-mint);
    background: var(--surface-2);
}
.cat-sort-trigger svg {
    transition: transform 0.18s ease;
    color: var(--text-dim);
}
.cat-sort.open .cat-sort-trigger svg {
    transform: rotate(180deg);
    color: var(--brand-mint);
}

/* Invisible click-catcher under the open menu — closes on tap-outside. */
.cat-sort-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
}
.cat-sort-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 60;
    min-width: 140px;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: var(--surface-1);
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    box-shadow: 0 12px 30px -6px rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    gap: 2px;
    animation: cat-sort-pop 0.16s ease-out;
}
@keyframes cat-sort-pop {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.cat-sort-item {
    width: 100%;
    text-align: left;
    padding: 9px 10px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-transform: capitalize;
}
.cat-sort-item:hover,
.cat-sort-item:active {
    background: var(--surface-2);
}
.cat-sort-item.is-active {
    background: var(--brand-mint);
    color: var(--bg-base);
}
.cat-row {
    background: var(--card-bg);
    border: 1px solid var(--line-soft);
    border-radius: 16px;
    overflow: hidden;
    transition: border-color 0.2s;
}
.cat-row:has(.cat-chevron.open) { border-color: var(--brand-mint); }
.cat-row:has(.cat-kbju-dropdown.open) { overflow: visible; }
.category-breakdown:has(.cat-kbju-dropdown.open) { overflow: visible; }
.cat-header {
    width: 100%;
    background: transparent;
    border: 0;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-primary);
    cursor: pointer;
    font: inherit;
}
.cat-header-left {
    display: block;
    min-width: 0;
    flex: 1;
    padding-right: 8px;
    text-align: left;
}
.cat-header-right {
    display: flex;
    align-items: center;
    gap: 6px;
}
.cat-chevron {
    display: inline-block;
    transition: transform 0.15s ease;
    color: var(--text-dim);
    font-size: 1.2rem;
    line-height: 1.1;
    margin-right: 6px;
    vertical-align: -2px;
}
.cat-chevron.open { transform: rotate(90deg); color: var(--brand-mint); }
.cat-name { font-size: 0.95rem; font-weight: 600; letter-spacing: -0.1px; }
.cat-header-right .cat-macro-dot {
    width: 8px; height: 8px; border-radius: 4px;
}
.cat-cals-total {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--brand-mint);
    font-variant-numeric: tabular-nums;
}
.cat-body {
    padding: 0 16px 14px 16px;
    border-top: 1px solid var(--line-soft);
}
.cat-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    gap: 12px;
    flex-wrap: wrap;
}
.cat-summary-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.cat-macro-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    font-weight: 600;
}
.cat-macro-dot-small {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.cat-macro-item.p .cat-macro-dot-small { background: var(--brand-lilac); }
.cat-macro-item.f .cat-macro-dot-small { background: var(--brand-coral); }
.cat-macro-item.c .cat-macro-dot-small { background: var(--brand-peach); }
.cat-macro-item .cat-macro-label { color: var(--text-dim); }
.cat-macro-item .cat-macro-val { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.cat-summary-right {
    display: flex;
    align-items: center;
}
.cat-total-weight {
    font-size: 0.75rem;
    font-weight: 500;
    color: #666;
    font-variant-numeric: tabular-nums;
}
.cat-macros {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    align-items: center;
    color: var(--text-dim);
    font-size: 0.78rem;
    padding: 12px 0;
    font-variant-numeric: tabular-nums;
}
.cat-macros > span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}
.cat-macro-dot {
    width: 6px; height: 6px; border-radius: 3px; flex-shrink: 0;
}
.cat-macro-weight {
    margin-left: auto;
    color: var(--text-mute);
    font-size: 0.75rem;
}
.cat-ing-table {
    background: var(--surface-2);
    border: 1px solid var(--line-soft);
    border-radius: 12px;
    overflow: hidden;
    margin-top: 4px;
}
.cat-ing-table:has(.cat-kbju-dropdown.open) { overflow: visible; }
.cat-ing-th {
    display: grid;
    grid-template-columns: 1fr 50px 70px;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--line-soft);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: #888;
    align-items: center;
}
.cat-ing-th .th-weight {
    color: #666;
    text-align: right;
}
.cat-ing-th > span:not(:first-child):not(.cat-kbju-dropdown) { text-align: right; }
.cat-kbju-btn {
    background: transparent;
    border: none;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-mute);
    cursor: pointer;
    padding: 0;
    letter-spacing: 0.4px;
    transition: color 0.15s;
}
.cat-kbju-btn:hover { color: var(--text-dim); }
.cat-kbju-btn.active { color: var(--brand-mint); }
.cat-kbju-dropdown {
  position: relative;
  display: flex;
  align-items: center;
  justify-self: stretch;
  width: 100%;
}
.cat-kbju-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 3px;
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--surface-1);
  border: 1px solid var(--line-soft);
  color: var(--text-primary);
  font-size: 0.62rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  text-transform: lowercase;
  letter-spacing: 0;
  white-space: nowrap;
  width: 100%;
  box-sizing: border-box;
}
.cat-kbju-dropdown-label {
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.cat-kbju-dropdown-trigger svg { flex-shrink: 0; }
.cat-kbju-dropdown-trigger svg {
  transition: transform 0.15s;
}
.cat-kbju-dropdown.open .cat-kbju-dropdown-trigger svg {
  transform: rotate(180deg);
}
.cat-kbju-dropdown.open .cat-kbju-dropdown-trigger {
  border-color: var(--brand-mint);
}
.cat-kbju-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
}
.cat-kbju-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 50;
  background: var(--surface-1);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 8px 24px -4px rgba(0,0,0,0.5);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 130px;
  animation: cat-kbju-pop 0.14s ease-out;
}
@keyframes cat-kbju-pop {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.cat-kbju-item {
  padding: 8px 12px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  text-transform: lowercase;
  white-space: nowrap;
}
.cat-kbju-item:hover,
.cat-kbju-item:active {
  background: var(--surface-2);
}
.cat-kbju-item.active {
  color: var(--brand-mint);
  background: rgba(120, 200, 170, 0.15);
}
.cat-ing-macro.highlight { font-weight: 700; }
.cat-ing-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}
.cat-ing-item {
    display: grid;
    grid-template-columns: 1fr 45px 30px 30px 30px 40px;
    gap: 4px;
    align-items: baseline;
    padding: 9px 12px;
    border-bottom: 1px solid var(--line-soft);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}
.cat-ing-item:last-child { border-bottom: 0; }
.cat-ing-name {
    color: var(--text-primary);
    line-height: 1.3;
    word-break: break-word;
    overflow-wrap: anywhere;
    min-width: 0;
}
.cat-ing-kcal { text-align: right; color: var(--brand-mint-deep); font-weight: 600; font-size: 0.82rem; }
.cat-ing-row {
    display: grid;
    grid-template-columns: 1fr 50px 70px;
    gap: 8px;
    align-items: center;
    padding: 8px 16px;
    border-bottom: 1px solid var(--line-soft);
}
.cat-ing-row:last-child { border-bottom: 0; }
.cat-ing-name {
    color: var(--text-primary);
    font-size: 0.85rem;
    line-height: 1.3;
    word-break: break-word;
    overflow-wrap: anywhere;
    min-width: 0;
}
.cat-ing-w {
    text-align: right;
    color: #888;
    font-size: 0.8rem;
    font-weight: 500;
}
.cat-ing-w .weight-unit {
    color: #666;
    font-size: 0.7rem;
    margin-left: 1px;
}
.cat-ing-row:last-child { border-bottom: 0; }
.cat-ing-w {
    text-align: right;
    color: #888;
    font-size: 0.8rem;
    font-weight: 600;
}
.cat-ing-w .weight-unit {
    color: #666;
    font-size: 0.7rem;
    margin-left: 1px;
}
.cat-ing-macros {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.cat-ing-macro {
    font-size: 0.75rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: right;
}
.cat-ing-macro.cal { color: var(--brand-mint); }
.cat-ing-macro.p { color: #9B59B6; }
.cat-ing-macro.f { color: #E74C3C; }
.cat-ing-macro.c { color: #F1C40F; }
.cat-ing-macro.only { color: var(--brand-mint); }
/* ===== Analytics rings card override (Stats page) ===== */
.stats-rings-card { margin-top: 4px !important; }

/* ===== Analytics tabs (Ингредиенты / Блюда) ===== */
.stats-tabs {
  display: flex;
  gap: 2px;
  padding: 4px;
  background: var(--surface-1);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  margin: 14px 0 12px;
}
.stats-tab {
  flex: 1;
  padding: 10px 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.1px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}
.stats-tab.is-active {
  background: var(--brand-mint);
  color: var(--bg-base);
}
.stats-empty {
  text-align: center;
  padding: 36px 16px;
  color: var(--text-mute);
  font-size: 16px;
  font-weight: 500;
}
/* ===== Meal cards (period meals list) =====
 * Layout: photo | title + cals/weight | date+time stack on the right.
 * Each meal sits in its own bordered box so the user can scan quickly. */
.stats-meals-list {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.stats-meals-heading {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: -0.1px;
  text-transform: uppercase;
  margin: 0 4px 2px;
}
.stats-meal-card {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
  background: var(--surface-1);
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
}
.stats-meal-card:active {
  background: var(--surface-2);
  transform: scale(0.99);
  border-color: var(--line-strong);
}
.stats-meal-img {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--surface-2);
  flex-shrink: 0;
}
.stats-meal-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stats-meal-name {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.15px;
  color: var(--text-primary);
  line-height: 1.25;
  /* Allow up to 2 lines, drop down if longer. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  text-wrap: pretty;
}
.stats-meal-meta {
  font-size: 14px;
  color: var(--text-dim);
  font-weight: 500;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.stats-meal-cals {
  color: var(--brand-mint);
  font-weight: 700;
}
.stats-meal-weight {
  color: var(--text-mute);
}
.stats-meal-time {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
  padding-left: 6px;
}
.stats-meal-date {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: -0.1px;
  text-transform: capitalize;
}
.stats-meal-clock {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
  font-variant-numeric: tabular-nums;
}

/* Metric filter pills above category breakdown (Calories | Protein | Fat | Carbs) */
.ing-metric-row {
  display: flex;
  gap: 6px;
  margin: 0 0 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.ing-metric-row::-webkit-scrollbar { display: none; }
.ing-metric-pill {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--surface-1);
  border: 1px solid var(--line-soft);
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.ing-metric-pill.is-active {
  background: var(--brand-mint);
  color: var(--bg-base);
  border-color: var(--brand-mint);
}
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9500;
  padding: 24px;
}

.confirm-card {
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 22px 22px 22px;
  max-width: 360px;
  width: 100%;
  color: var(--text-primary);
  box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.6);
  box-sizing: border-box;
}

.confirm-title {
  margin: 0 0 8px 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.confirm-message {
  margin: 0 0 20px 0;
  color: var(--text-dim);
  font-size: 17px;
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  gap: 10px;
}

.confirm-btn {
  flex: 1;
  height: 46px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  transition: opacity 0.15s ease;
  box-sizing: border-box;
}
.confirm-btn:active { opacity: 0.85; }

.confirm-btn-cancel {
  background: var(--surface-1);
  color: var(--text-primary);
  border: 1px solid var(--line-strong);
}

.confirm-btn-primary {
  background: var(--brand-mint);
  color: var(--bg-base);
  border: 1px solid transparent;
}

.confirm-btn-primary.is-destructive {
  background: var(--brand-coral);
  color: var(--bg-base);
  border: 1px solid transparent;
}
/* ===== Profile — NutriLens redesign (10) ===== */
.profile-page {
  background: var(--bg-base) !important;
  height: 100vh;
  width: 100%;
  display: flex;
  justify-content: center;
  overflow: hidden;
  overscroll-behavior-y: none;
}

.profile-phone {
  width: 100%;
  max-width: 430px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg-base) !important;
  box-shadow: none !important;
}

.profile-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding-bottom: 110px;
}

/* ── Hero ── */
.profile-hero {
  padding: 8px 22px 18px;
}
.profile-hero-label {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.profile-hero-email {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text-primary);
  margin-top: 4px;
  word-break: break-all;
}
.profile-norm-pill {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: oklch(0.78 0.14 165 / 0.15);
  border: 1px solid oklch(0.78 0.14 165 / 0.4);
  font-size: 12px;
  color: var(--brand-mint-deep);
  font-weight: 700;
  letter-spacing: 0.3px;
  font-variant-numeric: tabular-nums;
}
.profile-norm-dot {
  width: 6px;
  height: 6px;
  border-radius: 3px;
  background: var(--brand-mint-deep);
}

/* ── Section header ── */
.profile-section-header {
  padding: 20px 22px 8px;
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}

/* ── Body tiles row ── */
.profile-tiles {
  margin: 0 18px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.profile-tile {
  padding: 12px 10px;
  background: var(--surface-1);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  cursor: text;
  color: var(--text-primary);
  transition: border-color 0.15s;
}
.profile-tile:focus-within {
  border-color: var(--brand-mint);
}
.profile-tile-label {
  font-size: 12px;
  color: var(--text-mute);
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.profile-tile-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
  width: 100%;
}
.profile-tile-input {
  flex: 1;
  min-width: 0;
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  padding: 0;
  margin: 0;
  color: var(--text-primary);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.6px;
  font-variant-numeric: tabular-nums;
  font-family: inherit;
  -moz-appearance: textfield;
}
.profile-tile-input::-webkit-outer-spin-button,
.profile-tile-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.profile-tile-unit {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
}

/* ── Group card (для О себе / Предпочтения / Поддержка) ── */
.profile-group {
  margin: 0 18px;
  border-radius: 18px;
  background: var(--surface-1);
  border: 1px solid var(--line-soft);
  overflow: hidden;
}

/* ── Segmented row ── */
.profile-segrow {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line-soft);
}
.profile-segrow--last { border-bottom: none; }
.profile-segrow-label {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  flex-shrink: 0;
}
.profile-segctrl {
  margin-left: auto;
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border-radius: 10px;
  border: 1px solid var(--line-strong);
}
.profile-segbtn {
  padding: 6px 10px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.1px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.profile-segbtn.is-active {
  background: var(--bg-base);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

/* ── Plain row (Язык, Политика) ── */
.profile-row {
  position: relative;
  padding: 14px 16px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  color: var(--text-primary);
  font-family: inherit;
  cursor: pointer;
}
.profile-row--last { border-bottom: none; }
.profile-activity-row:last-child { border-bottom: none; }
.profile-activity-row.is-active { color: var(--brand-mint); }
.profile-activity-row.is-active .profile-row-label { color: var(--brand-mint); font-weight: 600; }
.profile-activity-row svg { color: var(--brand-mint); }
.profile-row-label {
  flex: 1;
  font-size: 17px;
  font-weight: 500;
  color: var(--text-primary);
}
.profile-row-value {
  font-size: 16px;
  color: var(--text-dim);
  font-weight: 500;
}
.profile-row--link .profile-chev {
  color: var(--text-mute);
}
.profile-row-select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-family: inherit;
}

/* ── Save button ── */
.profile-save-wrap {
  padding: 20px 18px 0;
}
.profile-save-btn {
  width: 100%;
  height: 52px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  background: var(--brand-mint);
  color: var(--bg-base);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.1px;
  font-family: inherit;
  box-shadow: 0 8px 20px -8px var(--brand-mint-glow);
  transition: opacity 0.15s;
}
.profile-save-btn:active { opacity: 0.85; }

/* ── Version ── */
.profile-version {
  text-align: center;
  padding: 20px 18px 8px;
  font-size: 12px;
  color: var(--text-primary);
  font-weight: 500;
  letter-spacing: 0.3px;
  font-family: Georgia, serif;
}

/* ── Danger zone ── */
.profile-danger {
  margin: 4px 18px 0;
}
.profile-danger-toggle {
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-mute);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
}
.profile-danger-caret {
  display: inline-flex;
  transition: transform 0.25s;
}
.profile-danger-caret.is-open { transform: rotate(180deg); }

.profile-danger-panel {
  margin-top: 4px;
  padding: 6px;
  background: var(--surface-1);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: dangerFadeIn 0.2s ease-out;
}
@keyframes dangerFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.profile-danger-row {
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: 10px;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  color: var(--text-primary);
  text-align: left;
  font-family: inherit;
}
.profile-danger-row--coral { color: var(--brand-coral-deep); }
.profile-danger-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}
.profile-danger-icon--neutral {
  background: var(--surface-2);
  color: var(--text-dim);
}
.profile-danger-icon--coral {
  background: oklch(0.7 0.18 25 / 0.12);
  color: var(--brand-coral-deep);
}
.profile-danger-text { flex: 1; }
.profile-danger-title {
  font-size: 16px;
  font-weight: 600;
  color: inherit;
}
.profile-danger-sub {
  font-size: 12px;
  color: var(--text-mute);
  margin-top: 1px;
  font-weight: 500;
}
.profile-danger-divider {
  height: 1px;
  background: var(--line-soft);
  margin: 0 12px;
}

/* ===== Language picker popup (centered, with flags) ===== */
.lang-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9500;
  padding: 24px;
}
.lang-picker-card {
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 18px 14px 14px;
  max-width: 360px;
  width: 100%;
  max-height: 80vh;
  overflow: hidden;
  color: var(--text-primary);
  box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
}
.lang-picker-title {
  margin: 0 4px 12px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text-primary);
}
.lang-picker-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.lang-picker-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 18px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}
.lang-picker-item:active { background: var(--surface-1); }
.lang-picker-item.is-active {
  background: var(--surface-1);
  border-color: var(--brand-mint);
  color: var(--brand-mint);
}
.lang-picker-flag { font-size: 26px; line-height: 1; }
.lang-picker-label { flex: 1; }
.lang-picker-check { color: var(--brand-mint); flex-shrink: 0; }
