/* ============= THEME VARIABLES (V2 — design system) ============= */
/* MySkinly v2: дефолтная тема — light/cream. Все --bg-*, --text-*, --accent
   тянутся из --ds-* токенов design-system.css — поэтому весь старый код
   с .card, .btn-primary автоматически получает новую палитру.
   Dark — опция, активируется классом .ds-dark. */
:root {
  /* Surfaces — cream фон, белые карточки (без беж-на-беже) */
  --bg-app:        #ECE3CB;
  --bg-screen:     #FAF5E8;
  --bg-card:       #FFFFFF;
  --bg-card-elev:  #FFFFFF;
  --bg-card-hover: #F8F4E5;
  --bg-modal:      #FAF5E8;
  --bg-input:      #FFFFFF;

  /* Borders */
  --border:         #E5DEC9;
  --border-strong:  #D5CCB5;
  --border-handle:  #C5BAA0;

  /* Text — ink на cream */
  --text-primary:    #2A1F18;
  --text-secondary:  #6A5A4A;
  --text-muted:      #8A7A6A;
  --text-faint:      #A89A88;
  --text-version:    #B8AB99;

  /* Brand (legacy aliases — для совместимости с существующим кодом) */
  --brand-mint:        #69E094;
  --brand-mint-soft:   #B8F0D0;
  --brand-coral:       #F47B6A;
  --brand-coral-soft:  #FBC1B6;
  --brand-purple:      #B177ED;
  --brand-purple-soft: #DBC1F5;
  --brand-orange:      #FF7B03;
  --brand-blue:        #7DB8F2;
  --brand-blue-soft:   #C5DDF7;
  --brand-yellow:      #FFD945;
  --brand-cream:       #FAF5E8;

  /* Primary action: mint (только мятный, без зелёного) */
  --accent:             #69E094;
  --accent-soft:        #B8F0D0;
  --accent-soft-border: #B8F0D0;
  --splash-leaf:        #69E094;

  /* Status */
  --success:        #69E094;
  --warning:        #FFB84D;
  --danger:         #F47B6A;
  --danger-bg:      #FBEAE5;
  --danger-text:    #C04030;
  --danger-border:  #F8C5B5;

  /* Tier colors — должны совпадать с tierForScore() в app.js,
     чтобы карточка на главной и календарь говорили одно и то же */
  --tier-perfect:  #B177ED; /* ds-purple — Идеальный */
  --tier-good:     #69E094; /* success — Хороший */
  --tier-mid:      #FFB84D; /* warning — Средний */
  --tier-bad:      #F47B6A; /* danger — Негативно */

  /* Shadows */
  --shadow-card:    rgba(58, 40, 24, 0.08);
  --shadow-deep:    rgba(58, 40, 24, 0.15);
  --modal-backdrop: rgba(42, 31, 24, 0.30);

  --color-scheme-mode: light;
  color-scheme: light;
}

/* ===== Dark mode (опция через ds-dark) ===== */
html.theme-dark, html.ds-dark, body.theme-dark, body.ds-dark {
  --bg-app:        #18130E;
  --bg-screen:     #1F1A14;
  --bg-card:       #28221C;
  --bg-card-elev:  #322B22;
  --bg-card-hover: #3A2F25;
  --bg-modal:      #1F1A14;
  --bg-input:      #28221C;

  --border:         #3A2F25;
  --border-strong:  #4A3E30;
  --border-handle:  #5A4E40;

  --text-primary:    #F0E8D8;
  --text-secondary:  #B5A88E;
  --text-muted:      #8A7E6A;
  --text-faint:      #6F6354;
  --text-version:    #5A5044;

  --accent-soft:    #1F4A36;

  --danger-bg:    #3A1F1A;
  --danger-text:  #F47B6A;
  --danger-border: #4A2828;

  --shadow-card:    rgba(0, 0, 0, 0.3);
  --shadow-deep:    rgba(0, 0, 0, 0.5);
  --modal-backdrop: rgba(0, 0, 0, 0.6);

  --color-scheme-mode: dark;
  color-scheme: dark;
}

/* Compat: html.theme-light без класса dark — это default :root, ничего не меняем */
html.theme-light, body.theme-light { /* alias */ }

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif; background: var(--bg-app); color: var(--text-primary); min-height: 100vh; -webkit-font-smoothing: antialiased; }
button { cursor: pointer; font-family: inherit; border: none; background: none; font-size: inherit; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; }

.app-root { display: flex; min-height: 100vh; gap: 24px; padding: 24px; justify-content: center; align-items: flex-start; flex-wrap: wrap; }

/* ===== PHONE FRAME ===== */
.phone-wrapper { position: sticky; top: 24px; }
.phone { width: 390px; height: 844px; background: #000; border-radius: 48px; padding: 12px; position: relative; box-shadow: 0 20px 60px var(--shadow-deep); }
.phone-screen { width: 100%; height: 100%; background: var(--bg-screen); border-radius: 36px; overflow: hidden; position: relative; display: flex; flex-direction: column; }
.status-bar { height: 44px; display: flex; justify-content: space-between; align-items: center; padding: 0 28px; font-size: 15px; font-weight: 600; flex-shrink: 0; color: var(--text-primary); }
.screen-content { flex: 1; overflow-y: auto; padding: 0 16px 12px; }
/* Tab bar: белая подложка с тенью + контрастные иконки */
.tab-bar { height: 82px; display: flex; background: var(--bg-card); border-top: 1px solid var(--border); box-shadow: 0 -2px 12px var(--shadow-card); flex-shrink: 0; padding-bottom: 16px; }
.tab-btn { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 10px; font-weight: 600; color: var(--text-secondary); transition: color 0.15s ease; padding-top: 8px; }
.tab-btn.active { color: var(--text-primary); font-weight: 700; }
/* Активная иконка получает мятный фон-плашку для явного выделения.
   Иконка всегда тёмная — мятный pастель не меняется между темами,
   а var(--text-primary) в dark был бы светлым → light-on-light. */
.tab-btn .icon { display: flex; align-items: center; justify-content: center; width: 44px; height: 28px; border-radius: 14px; transition: background 0.15s ease; }
.tab-btn.active .icon { background: var(--accent); color: #2A1F18; }
.tab-btn .icon i, .tab-btn .icon svg { width: 22px; height: 22px; stroke-width: 2; }
.tab-btn.active .icon i, .tab-btn.active .icon svg { stroke-width: 2.4; }

/* ===== COMMON UI ===== */
.screen-title { font-size: 32px; font-weight: 800; letter-spacing: -1px; margin: 14px 0 6px; color: var(--text-primary); line-height: 1.1; }
.screen-subtitle { font-size: 14px; color: var(--text-muted); margin-bottom: 16px; line-height: 1.4; }
/* btn-primary: mint с тёмным текстом — основной CTA. Цвет фикс #2A1F18,
   а не var(--text-primary), потому что accent-mint светлый в обеих темах,
   а text-primary в dark становится светлым → light-on-light. */
.btn-primary { background: var(--accent); color: #2A1F18; padding: 16px; border-radius: 16px; font-size: 16px; font-weight: 700; width: 100%; letter-spacing: -0.2px; transition: opacity 0.15s ease, box-shadow 0.15s ease; }
.btn-primary:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.18); opacity: 0.95; }
.btn-primary:active { transform: scale(0.97); box-shadow: none; }
.btn-primary:disabled { opacity: 0.4; box-shadow: none; }
.btn-secondary { background: var(--bg-card-elev); color: var(--text-primary); padding: 14px; border-radius: 14px; font-size: 15px; font-weight: 600; width: 100%; border: 1px solid var(--border-strong); }
.btn-ghost { color: var(--accent); font-size: 14px; font-weight: 600; padding: 12px; }

.card { background: var(--bg-card); border-radius: 18px; padding: 16px; margin-bottom: 10px; border: none; color: var(--text-primary); box-shadow: 0 2px 6px rgba(58, 40, 24, 0.06); }
.section-title { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: var(--text-faint); margin: 20px 0 10px; }

.input { width: 100%; padding: 13px; border: 1px solid var(--border-strong); border-radius: 10px; font-size: 15px; background: var(--bg-input); color: var(--text-primary); }
.input:focus { outline: none; border-color: var(--accent); }

/* ===== PAGANO SCORE ===== */
.pagano-score { width: 180px; height: 180px; margin: 8px auto 16px; position: relative; display: flex; align-items: center; justify-content: center; flex-direction: column; }
.pagano-score svg { position: absolute; transform: rotate(-90deg); }
.pagano-value { font-size: 46px; font-weight: 700; line-height: 1; color: var(--text-primary); }
.pagano-label { font-size: 11px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 1px; }
.pagano-hint { text-align: center; color: var(--text-secondary); font-size: 13px; margin: -4px 8px 16px; line-height: 1.4; }

/* ===== FOOD ITEMS ===== */
.food-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg-card); border-radius: 10px; margin-bottom: 6px; border: 1px solid var(--border); }
.food-meal-group { margin-bottom: 16px; }
.food-meal-label { font-size: 12px; color: var(--text-faint); text-transform: uppercase; margin: 8px 4px 6px; font-weight: 600; letter-spacing: 0.5px; }
.zone-marker { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.zone-green { background: var(--success); }
.zone-yellow { background: var(--warning); }
.zone-red { background: var(--danger); }
.food-name { flex: 1; font-size: 14px; color: var(--text-primary); }
.food-meta { font-size: 11px; color: var(--text-faint); }

/* ===== STAT ROWS (быстрые отметки) =====
   Сгруппированный card-list a-la iOS Settings: иконка + параметр + значение.
   Filled-состояние — иконка получает mint-tint, value тоже выделяется цветом. */
.stat-rows {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  margin-top: 16px;
  box-shadow: 0 2px 6px var(--shadow-card);
}
.stat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: none;
  border-top: 1px solid var(--border);
  width: 100%;
  text-align: left;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s ease;
}
.stat-row:first-child { border-top: none; }
.stat-row:active { background: var(--bg-card-elev); }
.stat-icon {
  flex-shrink: 0;
  width: 32px; height: 32px;
  border-radius: 9px;
  background: var(--bg-card-elev);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
}
.stat-icon--mint   { background: var(--ds-mint-soft);   color: var(--ds-mint-dark); }
.stat-icon--coral  { background: var(--ds-coral-soft);  color: var(--ds-coral); }
.stat-icon--warning{ background: var(--ds-yellow-soft); color: var(--warning); }
.stat-icon--orange { background: var(--ds-orange-soft); color: var(--ds-orange); }
.stat-label { flex: 1; }
.stat-value { color: var(--text-faint); font-size: 13px; font-weight: 600; }
.stat-value--mint    { color: var(--ds-mint-dark); }
.stat-value--coral   { color: var(--ds-coral); }
.stat-value--warning { color: var(--warning); }
.stat-value--orange  { color: var(--ds-orange); }
/* Legacy alias — оставил .stat-icon--filled на случай где-то ещё есть */
.stat-icon--filled { background: var(--ds-mint-soft); color: var(--ds-mint-dark); }
.stat-value--filled { color: var(--ds-mint-dark); }

/* DEPRECATED: старый grid 3-в-ряд с эмодзи. Оставлено на случай если где
   ещё есть .quick-actions — на главной заменено на stat-rows. */
.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.quick-action { background: var(--bg-card); border-radius: 14px; padding: 14px 4px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; color: var(--text-secondary); border: none; box-shadow: 0 2px 6px rgba(58, 40, 24, 0.06); transition: background 0.15s ease; }
.quick-action .icon { font-size: 22px; }
.quick-action.active { background: var(--ds-mint-soft); color: var(--text-primary); font-weight: 700; box-shadow: inset 0 0 0 1.5px var(--ds-mint, var(--ds-mint-dark)), 0 2px 6px rgba(58, 40, 24, 0.06); }

/* Healing-звёздочка — лечебные продукты Пагано (скользкий вяз, сафлор, оливковое масло,
   чеснок, натуральный йогурт/кефир, лимонная вода). По книге восстанавливают кишечник. */
.healing-star { display: inline-block; color: #E8B441; font-size: 11px; font-weight: 700; margin-left: 2px; vertical-align: baseline; line-height: 1; text-shadow: 0 0 4px rgba(232, 180, 65, 0.35); }

/* ===== PUSH ===== */
.push { position: absolute; top: 12px; left: 16px; right: 16px; background: rgba(60,60,60,0.95); backdrop-filter: blur(20px); color: white; padding: 12px 16px; border-radius: 18px; z-index: 100; animation: slideDown 0.3s ease-out; box-shadow: 0 4px 20px var(--shadow-deep); cursor: pointer; border: 1px solid rgba(255,255,255,0.08); }
@keyframes slideDown { from { transform: translateY(-200%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.push-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.push-body { font-size: 12px; opacity: 0.9; }

/* ===== ADMIN ===== */
.admin { width: 340px; background: var(--bg-screen); border-radius: 16px; padding: 18px; border: 1px solid var(--border); position: sticky; top: 24px; max-height: calc(100vh - 48px); overflow-y: auto; color: var(--text-primary); }
.admin h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-faint); margin: 16px 0 8px; font-weight: 700; }
.admin h3:first-child { margin-top: 0; }
.admin button { width: 100%; padding: 9px 12px; background: var(--bg-card-elev); border-radius: 8px; font-size: 13px; margin-bottom: 5px; text-align: left; color: var(--text-primary); font-weight: 500; transition: background 0.15s; border: 1px solid var(--border-strong); }
.admin button:hover { background: var(--bg-card-hover); }
.admin button.danger { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }
.admin button.danger:hover { background: var(--danger-border); }
.admin .time-display { padding: 12px; background: var(--bg-app); color: var(--accent); border-radius: 10px; font-family: 'SF Mono', Menlo, monospace; font-size: 13px; text-align: center; margin-bottom: 12px; border: 1px solid var(--border); }
.admin .toggle-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: var(--bg-card-elev); border-radius: 8px; margin-bottom: 5px; font-size: 13px; border: 1px solid var(--border-strong); }
.admin .toggle-row input { transform: scale(1.3); cursor: pointer; accent-color: var(--accent); }

/* ===== MODAL ===== */
.modal-backdrop { position: absolute; inset: 0; background: var(--modal-backdrop); display: flex; align-items: flex-end; justify-content: center; z-index: 200; padding-bottom: var(--keyboard-offset, 0px); transition: padding-bottom 0.2s ease; }
/* Modal sheet: НЕ скроллит сам, transform для drag-to-dismiss */
.modal { background: var(--bg-modal); border-radius: 24px 24px 0 0; width: 100%; max-height: 85%; display: flex; flex-direction: column; box-shadow: 0 -8px 24px rgba(58, 40, 24, 0.15); transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1); position: relative; overflow: hidden; }
.modal.dragging { transition: none; }
/* Handle bar: прозрачная overlay-зона поверх контента, drag-friendly.
   Контент скроллится ПОД handle, как в нативных iOS sheet'ах. */
.modal-handle-bar {
  position: absolute; top: 0; left: 0; right: 0;
  padding: 6px 16px 10px;
  background: transparent;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  z-index: 2;
  display: flex;
  justify-content: center;
}
.modal-handle { width: 36px; height: 4px; background: var(--border-handle); border-radius: 2px; }
/* Content зона — занимает всю высоту, отступ сверху чтобы первая строка
   не пряталась под handle */
.modal-content { padding: 22px 16px 32px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.modal-title { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 14px; color: var(--text-primary); }

/* ===== ONBOARDING ===== */
.onboarding-dots { display: flex; gap: 6px; justify-content: center; margin: 8px 0 20px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border); }
.dot.active { background: var(--accent); width: 20px; border-radius: 4px; }
.onb-icon { font-size: 64px; text-align: center; margin: 40px auto 20px; display: block; }
.onb-title { font-size: 32px; font-weight: 800; letter-spacing: -1px; text-align: center; margin-bottom: 12px; padding: 0 10px; color: var(--text-primary); line-height: 1.1; }
.onb-desc { font-size: 15px; color: var(--text-secondary); text-align: center; line-height: 1.5; padding: 0 10px; margin-bottom: 24px; }

/* ===== CHECK LIST ===== */
.check-list { display: flex; flex-direction: column; gap: 8px; }
.check-item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--bg-card); border-radius: 12px; border: 2px solid transparent; cursor: pointer; font-size: 14px; color: var(--text-primary); }
.check-item.selected { border-color: var(--accent); background: var(--accent-soft); }
.check-item .check-box { margin-left: auto; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border-handle); display: flex; align-items: center; justify-content: center; font-size: 13px; }
.check-item.selected .check-box { background: var(--accent); border-color: var(--accent); color: #2A1F18; }

/* ===== CALENDAR ===== */
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-top: 12px; }
.cal-dow { text-align: center; font-size: 11px; color: var(--text-faint); padding: 6px 0; font-weight: 600; text-transform: uppercase; }
.cal-day { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border-radius: 8px; font-size: 13px; position: relative; background: var(--bg-card); color: var(--text-secondary); font-weight: 500; cursor: pointer; border: 1px solid var(--border); }
.cal-day.empty { background: transparent; cursor: default; border: none; }
/* Текст-контраст как на главной: пастельные/жёлтые → ink, насыщенные → white */
.cal-day.tier-perfect { background: var(--tier-perfect); color: white; border-color: var(--tier-perfect); }
.cal-day.tier-good { background: var(--tier-good); color: #2A1F18; border-color: var(--tier-good); }
.cal-day.tier-mid { background: var(--tier-mid); color: #2A1F18; border-color: var(--tier-mid); }
.cal-day.tier-bad { background: var(--tier-bad); color: white; border-color: var(--tier-bad); }
.cal-day.today { box-shadow: 0 0 0 2px var(--accent); }
/* Disabled: будущие дни и прошлые без данных — серые, некликабельные */
.cal-day.disabled { background: transparent; color: var(--text-faint); cursor: default; border: 1px dashed var(--border); opacity: 0.55; pointer-events: none; }
.cal-day .obostrenie-dot { position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%); width: 4px; height: 4px; background: #FF5555; border-radius: 50%; }

/* ===== FAKE CAMERA ===== */
.camera-view { background: #050505; border-radius: 16px; aspect-ratio: 3/4; position: relative; display: flex; align-items: center; justify-content: center; margin: 16px 0; overflow: hidden; }
.camera-view::before { content: ''; position: absolute; inset: 20px; border: 2px solid rgba(255,255,255,0.2); border-radius: 12px; }
.camera-center-dot { color: rgba(255,255,255,0.4); font-size: 30px; }
.camera-shutter { width: 70px; height: 70px; border-radius: 50%; background: white; border: 4px solid rgba(255,255,255,0.4); margin: 0 auto; }

/* ===== FAKE PHOTO ===== */
.fake-photo { width: 100%; aspect-ratio: 1; border-radius: 14px; background: linear-gradient(135deg, #3A2A20, #2A1E18); margin-bottom: 12px; display: flex; align-items: center; justify-content: center; font-size: 48px; border: 1px solid var(--border); }

/* ===== ANALYSIS CARD ===== */
.analysis-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; color: var(--text-primary); }
.analysis-row:last-child { border-bottom: none; }
.analysis-label { color: var(--text-muted); }
.analysis-value { font-weight: 600; }
.analysis-row input[type="time"] { color: var(--text-primary) !important; color-scheme: var(--color-scheme-mode); }

/* ===== SEGMENTED ===== */
.segmented { display: flex; background: var(--ds-cream-deep, var(--bg-card)); border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 10px; }
.segmented button { flex: 1; padding: 10px 4px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--ds-ink-soft, var(--text-secondary)); background: transparent; border: none; cursor: pointer; transition: background 0.15s ease, color 0.15s ease; }
.segmented button.active { background: var(--bg-card, white); color: var(--ds-ink, var(--text-primary)); box-shadow: 0 1px 3px rgba(58, 40, 24, 0.10); font-weight: 700; }

/* ===== PAYWALL ===== */
.benefit { display: flex; gap: 10px; padding: 12px 0; font-size: 14px; color: var(--text-primary); }
.benefit-check { color: var(--success); font-size: 18px; flex-shrink: 0; }
.tariff { padding: 14px; border: 2px solid var(--border); border-radius: 14px; margin-bottom: 8px; cursor: pointer; background: var(--bg-card); }
.tariff.selected { border-color: var(--accent); background: var(--accent-soft); }
.tariff-top { display: flex; justify-content: space-between; align-items: center; }
.tariff-name { font-weight: 700; font-size: 15px; color: var(--text-primary); }
.tariff-price { font-weight: 700; font-size: 15px; color: var(--text-primary); }
.tariff-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.tariff-badge { background: var(--accent); color: #2A1F18; font-size: 10px; padding: 3px 8px; border-radius: 6px; font-weight: 700; margin-left: 6px; }

/* ===== CORRELATION ===== */
.corr-item { padding: 12px; background: var(--bg-card); border-radius: 12px; margin-bottom: 8px; border: 1px solid var(--border); }
.corr-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; color: var(--text-primary); }
.corr-stat { font-size: 12px; color: var(--text-muted); }
.corr-bar { height: 4px; background: var(--border); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.corr-bar-fill { height: 100%; background: var(--danger); }

/* ===== INPUTS COLOR-SCHEME ===== */
input[type="time"], input[type="date"], input[type="number"] { color-scheme: var(--color-scheme-mode); }
input[type="range"] { accent-color: var(--accent); }
textarea.input { color: var(--text-primary); }

@media (max-width: 900px) { .app-root { flex-direction: column; align-items: center; } .phone-wrapper, .admin { position: static; } .admin { width: 390px; } }

/* ============= PWA MODE (clean fullscreen) ============= */
body.pwa {
  background: var(--bg-screen);
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
}
body.pwa #app-shell {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-screen);
  position: relative;
  overflow: hidden;
  padding-top: env(safe-area-inset-top);
}
body.pwa #screen-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 12px;
  -webkit-overflow-scrolling: touch;
}

/* Прячем скроллбар во всех скролл-контейнерах (включая iOS-индикатор) */
body.pwa, body.pwa * { scrollbar-width: none; -ms-overflow-style: none; }
body.pwa *::-webkit-scrollbar { width: 0 !important; height: 0 !important; display: none !important; }

body.pwa .tab-bar {
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: 0 -2px 12px var(--shadow-card);
  flex-shrink: 0;
  height: 56px;
  padding-bottom: env(safe-area-inset-bottom);
  box-sizing: content-box;
}
body.pwa .tab-btn { padding-bottom: 0; padding-top: 6px; }
body.pwa #push-container .push {
  top: calc(env(safe-area-inset-top) + 12px);
}
body.pwa #status-bar { display: none; }

/* === DESKTOP: PWA-MODE центрируем как «карточку» === */
@media (min-width: 600px) {
  body.pwa { background: var(--bg-app); padding: 24px; }
  body.pwa #app-shell {
    max-width: 420px;
    height: 90vh;
    border-radius: 24px;
    border: 1px solid var(--border);
    box-shadow: 0 20px 60px var(--shadow-card);
  }
}

/* ============= PHOTO TAG (chip-pill в углу превью) ============= */
.photo-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(20, 20, 20, 0.7);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: rgba(255, 255, 255, 0.95);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
  padding: 4px 9px;
  border-radius: 999px;
  text-transform: capitalize;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  max-width: calc(100% - 16px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============= PHOTO SHIMMER LOADER ============= */
/* Бегущий блик-плейсхолдер пока подгружается превью.
   На контейнер вешаем .photo-loading. Состояния:
   - default: шиммер бежит, img спрятан (opacity:0)
   - .loaded: шиммер выкл, img показан (загрузка успех)
   - .failed: шиммер выкл, img всё равно спрятан, ::after с пояснением
              (img без src или с broken src на iOS рисуется как «?» —
              .failed предотвращает это, показывая нормальный текст) */
.photo-loading {
  background: linear-gradient(90deg,
    var(--bg-card-elev) 0%,
    var(--bg-card-hover) 50%,
    var(--bg-card-elev) 100%);
  background-size: 200% 100%;
  animation: photo-shimmer 1.4s infinite linear;
}
.photo-loading img {
  opacity: 0;
  transition: opacity 0.15s ease-out;
}
.photo-loading.loaded {
  animation: none;
  background: transparent;
}
.photo-loading.loaded img {
  opacity: 1;
}
.photo-loading.failed {
  animation: none;
  background: var(--bg-card-elev);
}
.photo-loading.failed::after {
  content: 'Не загрузилось';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 11px;
  text-align: center;
  padding: 4px;
}
@keyframes photo-shimmer {
  0%   { background-position: -150% 0; }
  100% { background-position:  150% 0; }
}

/* ============= SPLASH SCREEN ============= */
#splash {
  position: fixed;
  inset: 0;
  background: var(--bg-screen);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.3s ease-out;
}
#splash.hide { opacity: 0; pointer-events: none; }
/* Старый эмоджи-листочек — оставляем для обратной совместимости */
.splash-leaf {
  font-size: 72px;
  animation: splash-pulse 1.6s ease-in-out infinite;
}
/* Новая иконка-Капу на splash */
.splash-icon {
  width: 120px;
  height: 120px;
  border-radius: 28px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  animation: splash-pulse 1.6s ease-in-out infinite;
}
.splash-name {
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
  font-size: 32px;
  font-weight: 800;
  margin-top: 8px;
  letter-spacing: -1px;
}
.splash-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--splash-leaf);
  border-radius: 50%;
  margin-top: 28px;
  animation: splash-spin 0.8s linear infinite;
}
.splash-version {
  position: absolute;
  bottom: max(24px, env(safe-area-inset-bottom));
  font-size: 11px;
  color: var(--text-version);
  letter-spacing: 0.5px;
  font-family: 'SF Mono', Menlo, monospace;
}
@keyframes splash-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.85; transform: scale(0.95); }
}
@keyframes splash-spin {
  to { transform: rotate(360deg); }
}

/* ============= ROTATE-LANDSCAPE OVERLAY =============
   iOS Safari PWA не позволяет залочить orientation. Когда юзер
   поворачивает телефон в landscape — показываем заглушку
   «поверните обратно». На планшете landscape допустим, не триггерим.
   Detect через max-height: 500px — phone в landscape всегда меньше. */
#rotate-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: var(--bg-screen);
  color: var(--text-primary);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
}
#rotate-overlay .rotate-icon {
  color: var(--ds-mint-dark);
  margin-bottom: 18px;
  animation: rotate-hint 2s ease-in-out infinite;
}
#rotate-overlay .rotate-title {
  font-family: var(--ds-font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
#rotate-overlay .rotate-sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 8px;
  max-width: 280px;
  line-height: 1.4;
}
@keyframes rotate-hint {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-15deg); }
}
@media (orientation: landscape) and (max-height: 500px) {
  #app-shell, #splash { display: none !important; }
  #rotate-overlay { display: flex; }
}

/* ============= ANIMATED CLOUDS (none tier) =============
   Облачка плывут слева направо в score-карточке когда ничего ещё
   не отмечено. Бесконечная анимация, разные скорости/задержки. */
.cloud-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.cloud {
  position: absolute;
  width: 90px;
  height: 30px;
  animation: cloud-drift linear infinite;
  will-change: transform;
}
.cloud-1 { top: 10%;  animation-duration: 55s; animation-delay: 0s;    transform: translateX(-120px); }
.cloud-2 { top: 48%;  animation-duration: 70s; animation-delay: -22s;  transform: translateX(-120px); opacity: 0.85; }
.cloud-3 { top: 78%;  animation-duration: 60s; animation-delay: -42s;  transform: translateX(-120px); opacity: 0.9; }

/* Финал — фиксированный 400px вправо (гарантированно за правым краем
   карточки шириной до ~310px). 100% в transform — это ширина САМОГО
   облака (90px), не контейнера, поэтому раньше облако пропадало рано. */
@keyframes cloud-drift {
  0%   { transform: translateX(-120px); }
  100% { transform: translateX(400px); }
}

/* ===== SETTINGS (iOS-style grouped list, v6.41) ===== */
.set-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--ds-ink-faint, var(--text-faint));
  margin: 22px 14px 8px;
}
.set-header:first-of-type { margin-top: 8px; }

.set-group {
  background: var(--bg-card);
  border-radius: 16px;
  margin: 0 0 4px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(58, 40, 24, 0.04);
}

.set-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  color: var(--text-primary);
  font-size: 15px;
  cursor: pointer;
  min-height: 48px;
  position: relative;
}
.set-row + .set-row::before {
  content: '';
  position: absolute;
  top: 0;
  left: 56px;
  right: 0;
  height: 1px;
  background: var(--ds-cream-deep, var(--border));
  opacity: 0.6;
}
.set-row:disabled { opacity: 0.4; cursor: default; }
.set-row__icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--ds-ink-soft, var(--text-secondary));
  font-size: 18px;
  line-height: 1;
}
.set-row__label {
  flex: 1;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.set-row__value {
  font-size: 14px;
  color: var(--ds-ink-faint, var(--text-faint));
  flex-shrink: 0;
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.set-row__chevron {
  color: var(--ds-ink-faint, var(--text-faint));
  font-size: 18px;
  flex-shrink: 0;
  line-height: 1;
}
.set-row--inline-input {
  cursor: default;
}
.set-row--inline-input input[type="time"] {
  border: none;
  background: transparent;
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
  text-align: right;
  padding: 0;
}
.set-row__switch {
  position: relative;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
  appearance: none;
  -webkit-appearance: none;
  background: var(--ds-cream-deep, #D7CDB8);
  border-radius: 999px;
  transition: background 0.18s ease;
  cursor: pointer;
}
.set-row__switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  transition: transform 0.18s ease;
}
.set-row__switch:checked {
  background: var(--ds-mint-dark, #6B8E3D);
}
.set-row__switch:checked::after {
  transform: translateX(18px);
}
.set-row--with-desc {
  flex-direction: row;
  align-items: center;
  padding: 12px 14px;
}
.set-row--with-desc .set-row__text {
  flex: 1;
  min-width: 0;
}
.set-row--with-desc .set-row__label {
  font-weight: 500;
  white-space: normal;
  text-overflow: clip;
  overflow: visible;
}
.set-row--with-desc .set-row__desc {
  font-size: 12px;
  color: var(--ds-ink-faint, var(--text-faint));
  margin-top: 3px;
  line-height: 1.35;
  font-weight: 400;
}
.set-row--destructive { color: var(--ds-coral, var(--danger-text)); font-weight: 600; }
.set-row--destructive .set-row__icon { color: var(--ds-coral, var(--danger-text)); }

.set-profile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 14px;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
}
.set-profile__avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--ds-mint-soft, #D4E5BC);
  color: var(--ds-mint-dark, #5F7F2F);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ds-font-display);
  font-size: 24px;
  font-weight: 800;
  flex-shrink: 0;
  overflow: hidden;
}
.set-profile__avatar img { width: 100%; height: 100%; object-fit: cover; }
.set-profile__text { flex: 1; min-width: 0; }
.set-profile__name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.set-profile__email {
  font-size: 13px;
  color: var(--ds-ink-faint, var(--text-faint));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.set-version {
  text-align: center;
  font-size: 12px;
  color: var(--ds-ink-faint, var(--text-version));
  margin: 26px 0 8px;
  letter-spacing: 0.2px;
}

/* Sticky CTA bar — закреплённая кнопка внизу модалки.
   .modal-content уже имеет overflow-y: auto (см. base CSS выше), поэтому
   position:sticky внутри него работает. .modal-scroll — просто div-обёртка
   для контента, не меняет layout. */
.modal-scroll {
  /* Empty wrapper — semantic-only marker. Контент скроллится потому что parent
     .modal-content уже scroll container. */
}
.modal-cta-bar {
  position: sticky;
  bottom: 0;
  margin: 12px -16px -32px;       /* выходит за padding modal-content */
  padding: 12px 16px max(20px, env(safe-area-inset-bottom));
  /* Градиент-fadeout сверху чтобы контент за CTA исчезал плавно */
  background: linear-gradient(to bottom, rgba(0,0,0,0) 0%, var(--bg-modal) 14px, var(--bg-modal) 100%);
  z-index: 2;
}
.modal-cta-bar > button { margin: 0; }

/* Lucide icons — гарантируем что размер из ic() переходит на SVG после createIcons.
   Lucide копирует data-* и атрибуты, но не всегда переносит inline style на сам <svg>.
   Обёртка-span с явным размером + overflow:hidden + правило ниже = SVG не вылезает. */
.ic { overflow: hidden; line-height: 1; }
.ic > svg, .ic > i > svg, .ic > i {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Input с встроенными actions справа (Save/Cancel через ✓/✕) */
.input-with-actions { position: relative; }
.input-actions {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  display: flex;
  gap: 4px;
  align-items: center;
}
.input-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: transparent;
  transition: background 0.12s ease, transform 0.1s ease;
}
.input-action-btn:active { transform: scale(0.92); }
.input-action-btn--save { color: var(--ds-mint-dark); background: var(--ds-mint-soft); }
.input-action-btn--cancel { color: var(--ds-ink-faint); }
.input-action-btn--cancel:hover { color: var(--ds-coral); background: var(--ds-coral-soft); }

/* Profile avatar — большая кнопка, тап → file picker */
.profile-avatar-btn {
  cursor: pointer;
  border: 3px solid var(--ds-cream-deep);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.profile-avatar-btn:hover { transform: scale(1.02); box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.profile-avatar-btn:active { transform: scale(0.98); }

/* Stress modal — кнопки уровня стресса с иконкой сверху, активное — выделено */
.stress-opt {
  transition: background 0.15s ease, border-color 0.15s ease;
}
.stress-opt--active {
  border-color: var(--ds-mint-dark);
  background: var(--ds-mint-soft);
  color: var(--ds-ink);
}

/* Dashed-кнопка — для secondary CTA «+ Добавить». Прозрачный фон, пунктир. */
.btn-dashed {
  background: transparent;
  color: var(--text-primary);
  padding: 14px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 600;
  width: 100%;
  border: 1.5px dashed var(--ds-cream-deep, var(--border-strong));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn-dashed:hover { background: var(--ds-cream-soft, var(--bg-card-elev)); border-color: var(--text-secondary); }
.btn-dashed:active { transform: scale(0.98); }

/* Чекбокс-карточка для боевых toggle-настроек в формах (вместо страшного native checkbox).
   Тап по всей карточке — переключает. Активная — mint-обводка + чекмарк. */
.check-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  background: var(--bg-card-elev);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  margin-bottom: 16px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.check-card--active { background: var(--ds-mint-soft); border-color: var(--ds-mint-dark); }
.check-card__box {
  width: 22px; height: 22px; flex-shrink: 0;
  border-radius: 6px;
  border: 1.5px solid var(--text-faint);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ds-mint-dark);
  margin-top: 1px;
  transition: all 0.15s ease;
}
.check-card--active .check-card__box {
  background: var(--ds-mint-dark);
  border-color: var(--ds-mint-dark);
  color: white;
}
.check-card__text { flex: 1; min-width: 0; }
.check-card__title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.check-card__desc { font-size: 12px; color: var(--text-faint); margin-top: 3px; line-height: 1.4; }

/* Pagano badge — мелкий шильдик для healing-добавок */
.pagano-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--ds-mint-soft);
  color: var(--ds-mint-dark);
  white-space: nowrap;
  cursor: help;
}
