/* ============================================================
   AINALAY — «тихая степь»
   Warm bone paper · deep spruce ink · terracotta accent
   Display: Unbounded · Body: Golos Text
   ============================================================ */

:root {
  --bg: #F6F2E9;
  --bg-deep: #EFE9DC;
  --card: #FDFBF6;
  --ink: #22312B;
  --ink-soft: #4C594F;      /* ≥6:1 на фоне */
  --ink-faint: #667169;     /* ≥4.5:1 — читаемый вторичный текст */
  --line: #E3DCCC;
  --terra: #C96F4A;         /* графика и акценты */
  --terra-ink: #A24E2B;     /* терракотовый ТЕКСТ: ≥4.5:1 */
  --terra-strong: #A8552F;  /* терракотовая кнопка: белый текст ≥4.5:1 */
  --terra-soft: #F3E0D6;
  --sage: #5E7B6A;
  --sage-soft: #E2E9E2;
  --gold: #B08A3E;
  --gold-soft: #F1E8D2;
  --danger: #8F4747;
  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(34,49,43,.05), 0 8px 24px -12px rgba(34,49,43,.14);
  --font-display: 'Unbounded', 'Golos Text', system-ui, sans-serif;
  --font-body: 'Golos Text', system-ui, -apple-system, sans-serif;
}

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

html { height: 100%; }
body {
  min-height: 100%;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  /* faint radial "circle of care" atmosphere */
  background-image:
    radial-gradient(1100px 500px at 50% -220px, rgba(201,111,74,.075), transparent 65%),
    radial-gradient(900px 600px at 110% 105%, rgba(94,123,106,.07), transparent 60%);
  background-attachment: fixed;
}

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

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 20px 10px;
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(var(--bg) 78%, transparent);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand-mark { width: 34px; height: 34px; color: var(--terra); }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 500; font-size: 15px; letter-spacing: .12em;
}
.brand-sub { font-size: 11px; color: var(--ink-faint); letter-spacing: .03em; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.lang-toggle {
  font-family: var(--font-display); font-size: 11.5px; font-weight: 500; letter-spacing: .06em;
  border: 1.4px solid var(--line); background: var(--card); color: var(--ink-faint);
  border-radius: 999px; padding: 12px 14px; min-height: 44px; cursor: pointer; transition: .18s;
  display: inline-flex; align-items: center; gap: 6px;
}
.lang-toggle:active { transform: scale(.94); }
.lang-opt.on { color: var(--ink); font-weight: 600; }
.lang-sep { opacity: .5; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--ink); color: var(--bg);
  display: grid; place-items: center;
  font-family: var(--font-display); font-size: 15px; font-weight: 500;
}

/* видимый фокус с клавиатуры */
:focus-visible { outline: 2.5px solid var(--sage); outline-offset: 2px; border-radius: 6px; }

/* ---------- main view ---------- */
.view {
  flex: 1;
  padding: 6px 20px calc(96px + env(safe-area-inset-bottom));
  animation: viewIn .35s cubic-bezier(.2,.8,.2,1);
}
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- greeting / hero (компактный: первым делом — дела) ---------- */
.hero { padding: 18px 2px 6px; }
.hero.compact { padding: 8px 2px 0; }
.hero-kk {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 400; letter-spacing: .01em;
  line-height: 1.22;
}
.hero-kk em { font-style: normal; color: var(--terra-ink); }
.hero-date { margin-top: 3px; color: var(--ink-faint); font-size: 13.5px; }

/* ---------- раздельный прогресс: приёмы ≠ дом ---------- */
.prog-card { margin-top: 16px; padding: 16px; }
.prog-row + .prog-row { margin-top: 13px; }
.prog-head { display: flex; justify-content: space-between; align-items: baseline; }
.prog-label {
  font-family: var(--font-display); font-size: 12px; font-weight: 500;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft);
}
.prog-count { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.prog-track { height: 8px; border-radius: 999px; background: var(--bg-deep); margin-top: 7px; overflow: hidden; }
.prog-fill { height: 100%; border-radius: 999px; background: var(--sage); transition: width .5s cubic-bezier(.2,.8,.2,1); }
.prog-fill.terra { background: var(--terra); }

/* ---------- приоритетная карточка ---------- */
.section-title.attn { color: var(--terra-ink); }
.attn-card { border-color: #E5C6B4; box-shadow: 0 1px 2px rgba(34,49,43,.05), 0 10px 26px -12px rgba(162,78,43,.25); }

/* ---------- sections ---------- */
.section { margin-top: 26px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 10px; padding: 0 2px;
}
.section-title {
  font-family: var(--font-display);
  font-size: 12.5px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-soft);
}
.section-note { font-size: 12.5px; color: var(--ink-faint); }
.section-action {
  font-size: 13.5px; color: var(--terra-ink); background: none; border: none;
  font-family: var(--font-body); font-weight: 600; cursor: pointer;
  min-height: 44px; padding: 10px 6px; display: inline-flex; align-items: center;
}

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card + .card { margin-top: 10px; }

.item {
  display: flex; align-items: center; gap: 13px;
  padding: 14px 16px;
  transition: background .2s, opacity .3s;
}
.item + .item { border-top: 1px solid var(--line); }
.item.done-state { opacity: .48; }
.item.done-state .item-name { text-decoration: line-through; text-decoration-color: var(--ink-faint); text-decoration-thickness: 1.5px; }

.item-icon {
  width: 42px; height: 42px; flex: none; border-radius: 14px;
  display: grid; place-items: center; font-size: 18px;
  background: var(--bg-deep); color: var(--ink-soft);
}
.item-icon.terra { background: var(--terra-soft); color: var(--terra); }
.item-icon.sage  { background: var(--sage-soft);  color: var(--sage); }
.item-icon.gold  { background: var(--gold-soft);  color: var(--gold); }

.item-body { flex: 1; min-width: 0; }
/* длинные названия переносятся по словам, а не по одному слову в строку */
.item-name { font-weight: 600; font-size: 15px; overflow-wrap: break-word; hyphens: auto; }
.item-meta { margin-top: 2px; font-size: 13px; color: var(--ink-faint); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.meta-late { color: var(--danger); font-weight: 600; }
.meta-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg-deep); border-radius: 999px; padding: 2.5px 9px;
  font-size: 12px; color: var(--ink-soft); font-weight: 600;
}

/* action buttons on cards: иконки (подписи ломали вёрстку), тап-цель ≥44px.
   nowrap — чтобы кнопки не переносились и не сжимали название задачи. */
.item-actions { display: flex; gap: 7px; flex: none; flex-wrap: nowrap; justify-content: flex-end; }
.btn-round {
  width: 46px; height: 46px; flex: none; border-radius: 50%;
  border: 1.4px solid var(--line); background: var(--card);
  display: grid; place-items: center; cursor: pointer;
  color: var(--ink-soft); transition: .16s;
  font-size: 17px; line-height: 1;
}
.btn-round:active { transform: scale(.9); }
.btn-round.primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn-round.primary:active { background: var(--terra-strong); border-color: var(--terra-strong); }

/* refill alert */
.alert {
  display: flex; gap: 12px; align-items: center;
  background: var(--terra-soft);
  border: 1px solid #E9CDBC;
  border-radius: var(--radius);
  padding: 13px 16px;
  margin-top: 14px;
}
.alert-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--terra); flex: none;
  animation: pulse 2.2s infinite;
}
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(201,111,74,.35);} 55% { box-shadow: 0 0 0 8px rgba(201,111,74,0);} }
.alert-text { flex: 1; font-size: 13.5px; color: #7C4426; line-height: 1.35; }
.alert-btn {
  border: none; background: var(--terra-strong); color: #fff; font-weight: 600; font-size: 13.5px;
  border-radius: 999px; padding: 12px 16px; min-height: 44px; cursor: pointer; font-family: var(--font-body);
}

/* empty / all done */
.all-clear {
  text-align: center; padding: 34px 20px;
  color: var(--ink-faint); font-size: 14px;
}
.all-clear .big {
  font-family: var(--font-display); font-size: 19px; color: var(--ink);
  margin-bottom: 6px; font-weight: 400;
}

/* ---------- «вместе» (без сравнительного бегунка) ---------- */
.fair { padding: 16px; }
.together-num {
  font-family: var(--font-display); font-size: 21px; font-weight: 500;
  margin-top: 8px; line-height: 1.15;
}
.together-sub { font-size: 12.5px; color: var(--ink-faint); margin-top: 3px; }
.together-row { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 12px; }
.together-pill {
  border-radius: 999px; padding: 5px 12px;
  font-size: 12.5px; font-weight: 600;
}

/* ---------- profile ---------- */
.p-input {
  width: 100%; border: none; border-bottom: 1.4px solid transparent;
  background: transparent; font-family: var(--font-body);
  font-size: 15px; font-weight: 600; color: var(--ink);
  padding: 4px 0; outline: none; transition: border-color .15s;
}
.p-input:focus { border-bottom-color: var(--sage); }

/* ---------- icon picker ---------- */
.icon-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; margin-top: 8px;
}
.ipick {
  aspect-ratio: 1; border-radius: 12px; border: 1.4px solid var(--line);
  background: var(--card); font-size: 19px; cursor: pointer;
  display: grid; place-items: center; transition: .14s;
  padding: 0;
}
.ipick:active { transform: scale(.9); }
.ipick.on { border-color: var(--terra); background: var(--terra-soft); box-shadow: 0 0 0 1px var(--terra) inset; }

/* ---------- med photo ---------- */
.item-icon.photo { padding: 0; overflow: hidden; background: var(--bg-deep); }
.item-icon.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.photo-preview {
  width: 52px; height: 52px; border-radius: 14px; overflow: hidden;
  border: 1.4px solid var(--line); background: var(--bg-deep); flex: none;
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- room groups ---------- */
.room-title {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 14px; color: var(--ink-soft);
  margin: 18px 2px 8px;
}
.room-title .cnt { color: var(--ink-faint); font-weight: 400; font-size: 12.5px; }

/* ---------- dose / stock ---------- */
.stock-track { height: 5px; border-radius: 999px; background: var(--bg-deep); margin-top: 7px; overflow: hidden; max-width: 150px; }
.stock-fill { height: 100%; border-radius: 999px; background: var(--sage); }
.stock-fill.low { background: var(--terra); }
.dose-times { display: flex; gap: 6px; }
.time-pill {
  font-size: 11.5px; font-weight: 600; letter-spacing: .02em;
  background: var(--bg-deep); border-radius: 999px; padding: 2px 8px; color: var(--ink-soft);
}
.member-head {
  display: flex; align-items: center; gap: 9px;
  margin: 20px 2px 8px;
}
.member-ava {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #fff;
}
.member-name { font-weight: 600; font-size: 14px; }

/* history dots */
.dots { display: flex; gap: 4px; margin-top: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--bg-deep); }
.dot.t { background: var(--sage); }
.dot.s { background: var(--gold); }
.dot.m { background: var(--line); }

/* ---------- shopping ---------- */
.shop-add {
  display: flex; gap: 8px; padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.shop-add input {
  flex: 1; border: none; background: var(--bg-deep); border-radius: 12px;
  padding: 11px 14px; font-family: var(--font-body); font-size: 14.5px; color: var(--ink);
  outline: none;
}
.shop-add input::placeholder { color: var(--ink-faint); }
.shop-add button {
  width: 46px; min-height: 46px; border: none; border-radius: 12px; background: var(--ink); color: var(--bg);
  font-size: 20px; cursor: pointer;
}
.check {
  width: 34px; height: 34px; border-radius: 50%; border: 1.7px solid var(--line);
  flex: none; display: grid; place-items: center; cursor: pointer; transition: .15s;
  background: var(--card); color: transparent; font-size: 14px;
  /* невидимое расширение зоны нажатия до 44px */
  position: relative;
}
.check::after { content: ''; position: absolute; inset: -6px; border-radius: 50%; }
.check.on { background: var(--sage); border-color: var(--sage); color: #fff; }

/* ---------- insights ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.stat-num {
  font-family: var(--font-display); font-size: 26px; font-weight: 500; line-height: 1.1;
}
.stat-num small { font-size: 14px; font-weight: 400; color: var(--ink-faint); }
.stat-label { margin-top: 4px; font-size: 12.5px; color: var(--ink-soft); line-height: 1.3; }
.stat.wide { grid-column: 1 / -1; }

/* ритм по неделям: пропуск — нейтральный, не «провал» */
.week-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.week-lbl { font-size: 12.5px; color: var(--ink-faint); width: 96px; flex: none; }
.week-dots { display: flex; gap: 5px; flex: 1; }
.week-dots i {
  flex: 1; aspect-ratio: 1; max-width: 22px; border-radius: 6px; display: block;
  background: var(--bg-deep);
}
.week-dots i.h1 { background: #CFDACF; }
.week-dots i.h2 { background: #9DB8A6; }
.week-dots i.h3 { background: var(--sage); }
.trend { margin-top: 13px; font-size: 13.5px; color: var(--ink-soft); line-height: 1.4; }
.together-mini { margin-top: 6px; font-size: 12.5px; color: var(--ink-faint); }

.gentle {
  margin-top: 14px; padding: 15px 17px;
  background: var(--sage-soft); border-radius: var(--radius);
  font-size: 13.5px; color: #3E5347; line-height: 1.5;
  border: 1px solid #D3DED3;
}
.gentle b { font-family: var(--font-display); font-weight: 500; font-size: 12.5px; letter-spacing: .06em; display: block; margin-bottom: 4px; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  display: flex; z-index: 40;
  background: rgba(253,251,246,.92);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; cursor: pointer; min-height: 48px;
  color: var(--ink-faint); font-family: var(--font-body); font-size: 12px; font-weight: 600;
  letter-spacing: .02em; padding: 4px 0; transition: color .2s;
}
.tab svg { width: 23px; height: 23px; }
.tab.active { color: var(--ink); }
.tab.active svg { color: var(--terra); }

/* ---------- bottom sheet ---------- */
.sheet-overlay {
  position: fixed; inset: 0; background: rgba(34,49,43,.4); z-index: 60;
  animation: fadeIn .2s;
}
@keyframes fadeIn { from { opacity: 0; } }
.sheet {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; z-index: 70;
  background: var(--card); border-radius: 24px 24px 0 0;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
  animation: sheetUp .28s cubic-bezier(.2,.8,.2,1);
  max-height: 82dvh; overflow-y: auto;
}
@keyframes sheetUp { from { transform: translate(-50%, 40%); opacity: .4; } }
.sheet-grip { width: 40px; height: 4px; border-radius: 999px; background: var(--line); margin: 4px auto 10px; }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 14px;
}
.sheet h3 { font-family: var(--font-display); font-weight: 500; font-size: 16px; margin: 0; }
.sheet-close {
  width: 44px; height: 44px; flex: none; border-radius: 50%;
  border: 1.4px solid var(--line); background: var(--card); color: var(--ink-soft);
  font-size: 16px; cursor: pointer; display: grid; place-items: center;
}
.field { margin-bottom: 12px; display: block; }
.field .flabel { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
.field input, .field select {
  width: 100%; border: 1.4px solid var(--line); background: var(--bg);
  border-radius: 12px; padding: 12px 14px; font-family: var(--font-body); font-size: 15px;
  color: var(--ink); outline: none; min-height: 46px;
}
.field input:focus, .field select:focus { border-color: var(--sage); }
.seg-row { display: flex; gap: 7px; flex-wrap: wrap; }
.seg {
  border: 1.4px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 11px 15px; min-height: 44px; font-size: 13.5px; font-weight: 600; color: var(--ink-soft);
  cursor: pointer; font-family: var(--font-body); transition: .15s;
  display: inline-flex; align-items: center;
}
.seg.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.seg.big { font-size: 15px; padding: 12px 18px; }
.sheet-btn {
  width: 100%; margin-top: 8px; border: none; border-radius: 14px;
  background: var(--ink); color: var(--bg); font-family: var(--font-display);
  font-size: 14px; font-weight: 500; letter-spacing: .04em; padding: 16px; min-height: 50px;
  cursor: pointer; transition: .15s;
}
.sheet-btn:active { transform: scale(.98); background: var(--terra-strong); }
.sheet-btn.ghost { background: none; color: var(--danger); font-family: var(--font-body); font-weight: 600; padding: 12px; min-height: 44px; }

/* выбор человека при передаче */
.member-pick { display: flex; flex-direction: column; gap: 8px; }
.member-pick-btn {
  display: flex; align-items: center; gap: 12px;
  border: 1.4px solid var(--line); background: var(--card); border-radius: 14px;
  padding: 12px 14px; min-height: 56px; cursor: pointer;
  font-family: var(--font-body); font-size: 15px; font-weight: 600; color: var(--ink);
  text-align: left;
}
.member-pick-btn .member-ava { width: 32px; height: 32px; font-size: 13px; }
.member-pick-btn.current { opacity: .55; cursor: default; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: calc(92px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%); z-index: 80;
  background: var(--ink); color: var(--bg);
  padding: 9px 12px 9px 20px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  box-shadow: 0 10px 30px -8px rgba(34,49,43,.4);
  animation: toastIn .25s cubic-bezier(.2,.8,.2,1);
  white-space: nowrap; display: flex; align-items: center; gap: 12px;
}
.toast-undo {
  border: none; border-radius: 999px; background: rgba(246,242,233,.16);
  color: #F3C9B4; font-family: var(--font-body); font-size: 13.5px; font-weight: 700;
  padding: 9px 14px; min-height: 38px; cursor: pointer;
}
@keyframes toastIn { from { transform: translate(-50%, 14px); opacity: 0; } }

/* staggered list reveal */
.stagger > * { animation: viewIn .4s cubic-bezier(.2,.8,.2,1) backwards; }
.stagger > *:nth-child(1) { animation-delay: .02s; }
.stagger > *:nth-child(2) { animation-delay: .06s; }
.stagger > *:nth-child(3) { animation-delay: .1s; }
.stagger > *:nth-child(4) { animation-delay: .14s; }
.stagger > *:nth-child(5) { animation-delay: .18s; }
.stagger > *:nth-child(6) { animation-delay: .22s; }

@media (min-width: 500px) {
  body { padding: 0 0 0; }
  .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}
