/* Трекер малыша — стили Mini App. Цвета — из темы Telegram (--tg-theme-*), запасные — для браузера. */

:root {
  --fb-page: #f2f2f7;
  --fb-card: #ffffff;
  --fb-text: #1c1c1e;
  --fb-hint: #8a8a90;
  --fb-link: #2f7cf6;
  --fb-btn: #2f7cf6;
  --fb-field: #f2f2f7;
  --line: rgba(60, 60, 67, 0.13);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 10px rgba(0, 0, 0, 0.04);

  --page: var(--tg-theme-secondary-bg-color, var(--fb-page));
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, var(--fb-card)));
  --text: var(--tg-theme-text-color, var(--fb-text));
  --hint: var(--tg-theme-hint-color, var(--fb-hint));
  --link: var(--tg-theme-link-color, var(--fb-link));
  --accent: var(--tg-theme-button-color, var(--fb-btn));
  --accent-text: var(--tg-theme-button-text-color, #fff);
  --field: var(--tg-theme-secondary-bg-color, var(--fb-field));
  --danger: var(--tg-theme-destructive-text-color, #e5484d);

  --pink: #e94f86;
  --pink-soft: rgba(233, 79, 134, 0.12);
  --blue: #4a7df0;
  --blue-soft: rgba(74, 125, 240, 0.12);
  --teal: #0fa596;
  --teal-soft: rgba(15, 165, 150, 0.12);
  --amber: #df9612;
  --amber-soft: rgba(223, 150, 18, 0.14);
  --violet: #8f63e8;
  --c-wet: #3fa7e0;
  --c-dirty: #a8744a;
  --warn-bg: #fff5d1;
  --warn-text: #5f4600;
  --warn-line: #f1cc55;
  --who-band: rgba(102, 187, 106, 0.10);
  --green: #2f9e57;
  --green-soft: rgba(47, 158, 87, 0.12);
  --red-soft: rgba(229, 72, 77, 0.12);

  --sel: var(--pink);
  --sel-soft: var(--pink-soft);
  --r: 16px;
  --tabbar-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

:root[data-scheme="dark"] {
  --fb-page: #0f1013;
  --fb-card: #1c1d22;
  --fb-text: #f2f2f5;
  --fb-hint: #8e8f98;
  --fb-link: #62a0ff;
  --fb-btn: #3d86f5;
  --fb-field: #2a2b31;
  --line: rgba(255, 255, 255, 0.08);
  --shadow: none;
  --pink: #ff6f9f;
  --pink-soft: rgba(255, 111, 159, 0.15);
  --blue: #7199ff;
  --blue-soft: rgba(113, 153, 255, 0.15);
  --teal: #2cc4b3;
  --teal-soft: rgba(44, 196, 179, 0.15);
  --amber: #f2b441;
  --amber-soft: rgba(242, 180, 65, 0.15);
  --violet: #a98bff;
  --c-wet: #5cc0f5;
  --c-dirty: #c9956a;
  --warn-bg: rgba(242, 180, 65, 0.13);
  --warn-text: #f6d28a;
  --warn-line: rgba(242, 180, 65, 0.45);
  --who-band: rgba(102, 187, 106, 0.14);
  --green: #4cc27a;
  --green-soft: rgba(76, 194, 122, 0.15);
  --red-soft: rgba(255, 99, 104, 0.16);
  color-scheme: dark;
}

/* В Telegram поля ввода на карточке — цвет вторичного фона; в тёмной теме он может совпадать с фоном страницы. */
:root[data-tg-theme][data-scheme="dark"] { --field: rgba(255, 255, 255, 0.07); }
:root[data-tg-theme][data-scheme="light"] { --field: rgba(0, 0, 0, 0.045); }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--page);
  color: var(--text);
  font: 16px/1.35 system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
body.no-scroll { overflow: hidden; }

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
.muted { color: var(--hint); }
.small { font-size: 13px; }

/* --- каркас и вкладки ------------------------------------------------------------------------ */

.screens {
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px calc(var(--tabbar-h) + var(--safe-b) + 20px);
}
.screen { display: flex; flex-direction: column; gap: 12px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 4px 8px var(--safe-b);
  background: var(--card);
  border-top: 1px solid var(--line);
}
.tabbar button {
  min-height: var(--tabbar-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--hint);
  font-size: 11.5px; font-weight: 500;
}
.tabbar button.active { color: var(--accent); }
.tab-icon svg { width: 25px; height: 25px; }

.placeholder-icon {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  background: var(--card); color: var(--hint); margin-bottom: 6px;
}

.fullscreen-msg {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 24px; text-align: center;
}
.fullscreen-msg h1 { font-size: 22px; }
.big-emoji { font-size: 48px; }
.loader {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

/* --- шапка --------------------------------------------------------------------------------------- */

.baby-head { display: flex; align-items: center; gap: 12px; padding: 4px 2px 2px; }
.avatar {
  flex: none; width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #ff8fb4, #ffb86b);
  color: #fff; font-size: 22px; font-weight: 700;
}
button.avatar { border: 0; padding: 0; cursor: pointer; font-family: inherit; min-width: 48px; min-height: 48px; }
.avatar.has-photo { background: var(--card); overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.avatar.loading { opacity: 0.5; }
.avatar-remove { margin-top: 10px; min-height: 48px; }
.baby-id { flex: 1; min-width: 0; }
.baby-name { font-size: 21px; font-weight: 700; letter-spacing: -0.2px; }
.baby-age { font-size: 13.5px; color: var(--hint); margin-top: 1px; }
.wet { text-align: right; padding: 6px 10px; border-radius: 12px; }
.wet-label { font-size: 12px; color: var(--hint); }
.wet-value { font-size: 15px; color: var(--hint); font-variant-numeric: tabular-nums; }
.wet-value b { font-size: 19px; color: var(--text); }
.wet.behind { background: var(--amber-soft); }
.wet.behind .wet-value b { color: var(--amber); }

/* --- плашка «с последнего кормления» ---------------------------------------------------------- */

.hint {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 14px;
  background: var(--pink-soft); font-size: 15px;
}
.hint-icon { color: var(--pink); display: flex; }
.hint b { font-variant-numeric: tabular-nums; }

/* --- грудь ------------------------------------------------------------------------------------- */

.breasts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.breast {
  position: relative;
  min-height: 120px; border-radius: 20px; padding: 14px 12px 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: var(--card); border: 2px solid transparent; box-shadow: var(--shadow);
  transition: transform 0.12s ease, background-color 0.2s, border-color 0.2s, opacity 0.2s;
}
.breast:active { transform: scale(0.97); }
.breast-top { display: flex; align-items: center; gap: 6px; font-size: 16px; font-weight: 600; }
.breast-timer {
  font-size: 26px; font-weight: 700; letter-spacing: 0.5px;
  font-family: ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums; color: var(--hint);
}
.breast-sub { font-size: 12.5px; color: var(--hint); }
.breast.running { background: var(--pink-soft); border-color: var(--pink); }
.breast.running .breast-timer, .breast.running .breast-top { color: var(--pink); }
.breast.suggested { border-color: var(--pink-soft); }
.badge {
  font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 10px;
  background: var(--pink-soft); color: var(--pink);
}
.live-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--pink);
  animation: pulse 1.4s ease-in-out infinite;
}

/* нажатие в процессе */
.spinner {
  display: none; position: absolute; top: 10px; right: 10px;
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; opacity: 0.6;
  animation: spin 0.7s linear infinite;
}
.pending .spinner { display: block; }
.pending { pointer-events: none; }
.locked { opacity: 0.55; pointer-events: none; }

/* --- плитки ------------------------------------------------------------------------------------ */

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  position: relative;
  min-height: 64px; border-radius: var(--r); padding: 10px 12px;
  display: flex; align-items: center; gap: 10px; text-align: left;
  background: var(--card); border: 2px solid transparent; box-shadow: var(--shadow);
  transition: transform 0.12s ease;
}
.tile:active { transform: scale(0.97); }
.tile-icon { flex: none; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; }
.tile-icon svg { width: 22px; height: 22px; }
.tile-text { display: flex; flex-direction: column; min-width: 0; }
.tile-title { font-size: 15.5px; font-weight: 600; white-space: nowrap; }
.tile-timer { font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 12.5px; color: var(--hint); }
.tile.sleep .tile-icon { background: var(--blue-soft); color: var(--blue); }
.tile.diaper .tile-icon { background: var(--teal-soft); color: var(--teal); }
.tile.bottle .tile-icon { background: var(--amber-soft); color: var(--amber); }
.tile.more .tile-icon { background: var(--field); color: var(--hint); }
.tile.sleep.active { background: var(--blue-soft); border-color: var(--blue); }
.tile.sleep.active .tile-title { color: var(--blue); }
.tile.sleep.active .tile-sub { color: var(--blue); font-weight: 600; }

/* --- переключатель дня --------------------------------------------------------------------------- */

.day-switch { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.icon-btn {
  width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; color: var(--link);
}
.icon-btn:disabled { color: var(--hint); opacity: 0.35; }
.day-label {
  position: relative; flex: 1; min-height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 16px; font-weight: 600;
}
.day-label svg { width: 18px; height: 18px; color: var(--hint); display: block; }
.date-input { position: absolute; left: 50%; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* --- карточки и записи ---------------------------------------------------------------------------- */

.card { background: var(--card); border-radius: var(--r); padding: 14px 16px 10px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 32px; margin-bottom: 4px; }
.card-head h3 { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.head-icon { color: var(--accent); display: flex; }
.loading-card { color: var(--hint); text-align: center; padding: 20px; }
.empty { color: var(--hint); font-size: 14.5px; padding: 6px 0 8px; }

.feed-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.feed-table th {
  font-size: 12px; font-weight: 500; color: var(--hint); text-align: left; padding: 6px 4px;
}
.feed-table td { padding: 14px 4px; border-top: 1px solid var(--line); font-size: 15px; white-space: nowrap; }
.feed-table tbody tr { cursor: pointer; }
.feed-table tbody tr:active { background: var(--field); }
.feed-table .t { font-weight: 600; }
.feed-table .total { font-weight: 600; }
.feed-table .total .live-dot { margin-right: 5px; vertical-align: middle; }
.feed-table .span { color: var(--text); }
.feed-table .row-active td { color: var(--pink); }
.feed-table .row-water .span { color: var(--blue); }
.feed-table th:last-child, .feed-table td.who { text-align: right; }
.feed-table tr:has(+ .seg-row) td { padding-bottom: 4px; }
.feed-table tr.seg-row td {
  border-top: 0; padding: 0 4px 12px; font-size: 13px; color: var(--hint); white-space: normal; line-height: 1.35;
}
.feed-table tr.row-active + tr.seg-row td { color: var(--pink); }
.seg-list { display: flex; flex-direction: column; gap: 12px; }
.seg-card {
  display: flex; flex-direction: column; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 14px;
}
.seg-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.seg-title { font-size: 15px; font-variant-numeric: tabular-nums; }
.seg-del { min-height: 48px; flex: none; padding: 0 12px; color: var(--danger); }
.who { color: var(--hint); font-size: 13px; }

.rec-list { list-style: none; margin: 0; padding: 0; }
.rec {
  display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line);
  cursor: pointer; min-height: 56px;
}
.rec:first-child { border-top: 0; }
.rec-icon { flex: none; width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-size: 17px; }
.rec-icon svg { width: 19px; height: 19px; }
.sleep-day { background: var(--amber-soft); color: var(--amber); }
.sleep-night { background: var(--blue-soft); color: var(--blue); }
.diaper-icon { background: var(--teal-soft); white-space: nowrap; letter-spacing: -3px; }
.diaper-icon.both { font-size: 12px; }
.rec.alarm .diaper-icon { background: var(--amber-soft); }
.rec-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rec-main b { font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; }
.rec-sub { font-size: 13px; color: var(--hint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-thumb { flex: none; width: 48px; height: 48px; border-radius: 10px; overflow: hidden; background: var(--field); }
.rec-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.warn-mark { color: var(--amber); }
.color-tag { display: inline-flex; align-items: center; gap: 4px; }
.dot {
  display: inline-block; flex: none; width: 12px; height: 12px; border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
}

.add-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 48px; padding: 0 2px;
  color: var(--link); font-size: 15px; font-weight: 600;
}
.add-btn svg { width: 18px; height: 18px; }
.card > .add-btn { margin-top: 2px; }

/* --- нижний лист ------------------------------------------------------------------------------ */

.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0); display: flex; align-items: flex-end; justify-content: center;
  transition: background-color 0.2s;
}
.overlay.open { background: rgba(0, 0, 0, 0.42); }
.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh;
  display: flex; flex-direction: column;
  background: var(--card); border-radius: 22px 22px 0 0;
  transform: translateY(100%); transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.overlay.open .sheet { transform: none; }
.sheet-grip { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 4px 20px; flex: none; }
.sheet-title { font-size: 20px; font-weight: 700; }
.sheet-head .icon-btn { color: var(--hint); }
.sheet-body { overflow-y: auto; padding: 6px 16px 18px; overscroll-behavior: contain; }
.sheet-foot {
  flex: none; display: flex; gap: 10px; padding: 10px 16px calc(12px + var(--safe-b));
  border-top: 1px solid var(--line);
}
.sheet-small .sheet-body { padding-bottom: 8px; }
.confirm-text { font-size: 16px; padding: 4px 4px 8px; }
.sheet-diaper { --sel: var(--teal); --sel-soft: var(--teal-soft); }

/* --- кнопки ------------------------------------------------------------------------------------ */

.btn {
  min-height: 50px; padding: 0 18px; border-radius: 14px;
  font-size: 16px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.12s ease, opacity 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn.busy { opacity: 0.6; }
.btn-wide { flex: 1; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-feed { background: var(--pink); color: #fff; }
.btn-sleep { background: var(--blue); color: #fff; }
.btn-diaper { background: var(--teal); color: #fff; }
.btn-ghost { background: var(--field); flex: 1; }
.btn-danger { background: var(--danger); color: #fff; flex: 1; }
.btn-ghost-danger { color: var(--danger); padding: 0 12px; }
.btn-soft { background: var(--field); color: var(--text); }
.link-btn { color: var(--link); font-size: 15px; font-weight: 500; min-height: 48px; padding: 0 4px; }

/* --- формы ------------------------------------------------------------------------------------- */

.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--hint); }
.field-hint { font-size: 12.5px; color: var(--hint); }
.field-error { font-size: 13px; color: var(--danger); }
.field-error:empty { display: none; }
.form-error { color: var(--danger); font-size: 14px; }
.form-error:empty { display: none; }
.input {
  width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 12px;
  border: 1.5px solid transparent; background: var(--field); color: var(--text);
  font: inherit; font-size: 16px; outline: none;
  -webkit-appearance: none; appearance: none;
}
.input:focus { border-color: var(--accent); }
textarea.input { resize: vertical; min-height: 64px; }
.has-error .input, .has-error .segmented, .has-error .type-row, .has-error .chips { border-color: var(--danger); box-shadow: 0 0 0 1.5px var(--danger); border-radius: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.info-box { padding: 12px 14px; border-radius: 12px; font-size: 15px; }
.info-box.feed { background: var(--pink-soft); }
.info-box.feed b { color: var(--pink); }

.segmented { display: flex; gap: 3px; padding: 3px; border-radius: 12px; background: var(--field); }
.segmented .choice {
  flex: 1; min-height: 48px; border-radius: 10px; font-size: 15px; font-weight: 500;
  display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 6px;
}
.segmented .choice.selected { background: var(--card); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
:root[data-scheme="dark"] .segmented .choice.selected { background: rgba(255, 255, 255, 0.14); }

.type-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.type-row .choice {
  min-height: 96px; border-radius: 18px; border: 2px solid transparent; background: var(--field);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  transition: transform 0.12s ease, background-color 0.15s, border-color 0.15s;
}
.type-row .choice:active { transform: scale(0.96); }
.type-row .choice-icon { font-size: 30px; line-height: 1; letter-spacing: -6px; padding-right: 6px; }
.type-row .choice-label { font-size: 15px; font-weight: 600; }
.type-row .choice.selected { border-color: var(--sel); background: var(--sel-soft); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips .choice {
  min-height: 48px; padding: 0 14px; border-radius: 24px; border: 1.5px solid transparent;
  background: var(--field); font-size: 14.5px; display: inline-flex; align-items: center; gap: 7px;
}
.chips .choice .dot { width: 16px; height: 16px; }
.chips .choice.selected { border-color: var(--sel); background: var(--sel-soft); font-weight: 600; }

.block { transition: opacity 0.2s; }
.block.inactive { opacity: 0.38; pointer-events: none; }
.alert {
  display: flex; gap: 10px; margin-top: 12px; padding: 12px 14px; border-radius: 12px;
  background: var(--warn-bg); color: var(--warn-text); border: 1px solid var(--warn-line); font-size: 14.5px;
}
.alert-icon { flex: none; color: var(--amber); display: flex; }
.alert p + p { margin-top: 4px; }
.alert-strong { font-weight: 700; }

.time-picker .input { display: none; }
.time-picker.editing .input { display: block; }
.time-picker.editing .time-row { display: none; }
.time-row { display: flex; align-items: center; gap: 10px; }
.time-text { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }

.ml-box { display: flex; flex-direction: column; gap: 10px; }
.ml-input { position: relative; }
.ml-input .input { padding-right: 44px; }
.ml-input span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--hint); }

.photo-row { display: flex; align-items: center; gap: 12px; }
.photo-btn { min-height: 48px; }
.photo-btn svg { width: 20px; height: 20px; }
.photo-thumbs { display: flex; gap: 8px; }
.thumb { position: relative; width: 64px; height: 64px; border-radius: 12px; overflow: hidden; background: var(--field); cursor: zoom-in; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.loading::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid #fff; border-right-color: transparent; animation: spin 0.7s linear infinite;
}
.thumb.loading img { opacity: 0.5; }
.thumb.failed { box-shadow: inset 0 0 0 2px var(--danger); }
.thumb.failed img { opacity: 0.4; }
.thumb-remove {
  position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.55); color: #fff; display: grid; place-items: center;
}
.thumb-remove::before { content: ""; position: absolute; inset: -12px; } /* зона нажатия 48 px */
.thumb-remove svg { width: 14px; height: 14px; }
img.broken { opacity: 0.2; }

.viewer { position: fixed; inset: 0; z-index: 120; background: #000; display: grid; place-items: center; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-close { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px; color: #fff; }

/* --- «Ещё» и настройки --------------------------------------------------------------------------- */

.soon { font-size: 12px; color: var(--hint); background: var(--field); padding: 3px 9px; border-radius: 10px; }

.settings { display: flex; flex-direction: column; gap: 12px; }
.settings .card > p { margin-bottom: 6px; }
.set-row {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px;
  padding: 11px 0; border-top: 1px solid var(--line);
}
.card-head + .set-row { border-top: 0; }
.set-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.set-title { font-size: 15.5px; }
.set-hint { font-size: 12.5px; color: var(--hint); }
.set-row .field-error { grid-column: 1 / -1; }
.set-control { display: flex; align-items: center; }
.input-sm { width: 76px; min-height: 48px; padding: 6px 8px; text-align: center; }
input[type="time"].input-sm { width: 92px; }
.unit-box, .range { display: inline-flex; align-items: center; gap: 6px; color: var(--hint); }

.switch { position: relative; display: inline-block; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; inset: -9px -4px; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch-track {
  position: absolute; inset: 0; border-radius: 16px; background: var(--line);
  transition: background-color 0.2s;
}
:root[data-scheme="light"] .switch-track { background: #e3e3e8; }
.switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.2s;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(20px); }

/* --- профиль ------------------------------------------------------------------------------------ */

.profile { display: flex; align-items: center; gap: 12px; padding: 4px 0 10px; }
.profile .avatar { width: 56px; height: 56px; font-size: 25px; }
.profile-name { font-size: 19px; font-weight: 700; }
.profile-age { font-size: 14px; color: var(--hint); margin-top: 2px; }

/* --- статистика -------------------------------------------------------------------------------- */

.screen-title { font-size: 26px; font-weight: 800; letter-spacing: -0.4px; }
.stats-head { display: flex; flex-direction: column; gap: 2px; padding: 4px 2px 2px; }
.stats-period { font-size: 14px; min-height: 19px; }
.custom-range { display: flex; flex-direction: column; gap: 12px; padding-bottom: 14px; }
.stats-body { display: flex; flex-direction: column; gap: 12px; transition: opacity 0.2s; }
.stats-body.loading { opacity: 0.45; pointer-events: none; }
.stats-empty {
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 36px 20px;
  text-align: center; color: var(--hint); font-size: 16px;
}
.stats-empty .placeholder-icon { background: var(--field); margin: 0; }

.stat-card { padding-bottom: 14px; }
.stat-card.is-empty .empty { padding-bottom: 2px; }
.sec-emoji {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; font-size: 18px;
  background: var(--field);
}
.sec-feeding { background: var(--pink-soft); }
.sec-sleep { background: var(--blue-soft); }
.sec-diapers { background: var(--teal-soft); }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 4px; }
.kpi { background: var(--field); border-radius: 14px; padding: 10px 10px 9px; min-width: 0; }
.kpi-value { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-caption { font-size: 12px; color: var(--hint); line-height: 1.25; margin-top: 2px; }
.kpi-sub { font-size: 11.5px; color: var(--amber); font-weight: 600; margin-top: 3px; line-height: 1.2; }
.kpi.warn { background: var(--amber-soft); }
.kpi.warn .kpi-value { color: var(--amber); }

.balance {
  display: flex; align-items: center; gap: 8px; margin: 10px 0 2px;
  font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.balance-l { color: var(--pink); }
.balance-r { color: var(--violet); }
.balance-bar { flex: 1; display: flex; gap: 2px; height: 10px; border-radius: 5px; overflow: hidden; }
.balance-left { background: var(--pink); }
.balance-right { background: var(--violet); }

.chart-block { margin-top: 16px; }
.chart-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis { stroke: var(--hint); stroke-opacity: 0.45; stroke-width: 1; }
.chart-tick { fill: var(--hint); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.chart-tick-main { fill: var(--text); fill-opacity: 0.75; }
.chart-value { fill: var(--text); font-size: 10.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-sel { fill: var(--field); }
.chart-hit { cursor: pointer; }
.chart-band { fill-opacity: 0.16; }
.chart-dot { stroke: var(--card); stroke-width: 2; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: 12.5px; color: var(--hint); }
.chart-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.chart-swatch { flex: none; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.chart-swatch-line { width: 16px; height: 2.5px; border-radius: 2px; }
.chart-swatch-dash { width: 16px; height: 0; border-top: 2.5px dashed var(--c); background: none; border-radius: 0; }
.chart-swatch-dot { border-radius: 50%; }
.chart-readout { font-size: 13px; color: var(--hint); margin-top: 6px; min-height: 18px; }
.chart-readout.on { color: var(--text); font-weight: 500; }

.color-counts { display: flex; flex-wrap: wrap; gap: 6px; }
.color-count {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 16px;
  background: var(--field); font-size: 13.5px;
}
.color-count.warn { background: var(--amber-soft); }
.alarm-title { display: flex; align-items: center; gap: 6px; color: var(--amber); }
.alarm-icon { display: flex; }
.alarm-icon svg { width: 18px; height: 18px; }
.rec.static { cursor: default; }
button.rec-thumb { padding: 0; }

.stat-lines {
  list-style: none; margin: 14px 0 0; padding: 10px 0 0; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 5px;
}
.stat-lines li { font-size: 14px; color: var(--hint); padding-left: 14px; position: relative; }
.stat-lines li::before {
  content: ""; position: absolute; left: 2px; top: 8px; width: 5px; height: 5px; border-radius: 50%;
  background: var(--hint); opacity: 0.6;
}

.stats-actions { padding-bottom: 14px; }
.actions-col { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.btn-icon { display: flex; }
.btn.busy .btn-icon { animation: pulse 1.2s ease-in-out infinite; }

/* --- тост ------------------------------------------------------------------------------------ */

.toast {
  position: fixed; left: 16px; right: 16px; top: calc(12px + env(safe-area-inset-top, 0px)); z-index: 200;
  max-width: 480px; margin: 0 auto; padding: 12px 16px; border-radius: 14px;
  background: rgba(32, 33, 37, 0.95); color: #fff; font-size: 15px; font-weight: 500; text-align: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
  opacity: 0; transform: translateY(-12px); pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: none; }
.toast-error { background: #c9303c; }

/* --- анимации ---------------------------------------------------------------------------------- */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

@media (max-width: 350px) {
  .breast-timer { font-size: 23px; }
  .feed-table td { font-size: 14px; }
  .type-row .choice { min-height: 84px; }
}

/* --- волна 2: лист «Ещё», занятия, окно сна ------------------------------------------------------ */

.btn-sm { min-height: 48px; padding: 0 14px; font-size: 15px; border-radius: 12px; }
.sheet.sheet-tall { height: 92dvh; }
.list-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; color: var(--hint); margin: 18px 2px 6px; }
.list-title:first-child { margin-top: 4px; }
.empty-state { text-align: center; padding: 28px 12px 12px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty-state p { color: var(--hint); font-size: 15.5px; max-width: 300px; }
.empty-state .btn { align-self: stretch; }

.more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 4px 0 6px; }
.more-tile {
  min-height: 96px; border-radius: 18px; background: var(--field); padding: 12px 6px 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  transition: transform 0.12s; border: 2px solid transparent; text-align: center;
}
.more-tile:active { transform: scale(0.96); }
.more-emoji { font-size: 28px; line-height: 1; }
.more-title { font-size: 14px; font-weight: 600; line-height: 1.15; }
.more-sub { font-size: 12px; color: var(--hint); font-variant-numeric: tabular-nums; }
.more-tile.running { background: var(--teal-soft); border-color: var(--teal); }
.more-tile.running .more-sub { color: var(--teal); font-weight: 700; font-size: 14px; }

.act-strip { display: flex; flex-direction: column; gap: 8px; }
.act-pill {
  display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 14px; border-radius: 16px;
  background: var(--teal-soft); border: 2px solid var(--teal);
}
.act-emoji { font-size: 24px; }
.act-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.act-text b { font-size: 15px; }
.act-timer { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 20px; font-weight: 700; color: var(--teal); font-variant-numeric: tabular-nums; }
.act-stop { background: var(--teal); color: #fff; }

.sleep-window {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px;
  background: var(--blue-soft); font-size: 15px;
}
.sleep-window .hint-icon { color: var(--blue); }
.sw-text { display: flex; flex-direction: column; gap: 2px; }
.sw-note { font-size: 12.5px; color: var(--hint); }

.extra-icon { background: var(--field); }
.extra-icon.pump { background: var(--pink-soft); }
.extra-icon.mom { background: var(--amber-soft); }
.mom-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.mom-tags .choice { min-height: 48px; }
.after-24h { padding: 12px 14px; border-radius: 12px; background: var(--teal-soft); }
.after-24h.alarm { background: var(--amber-soft); }
.after-24h .after-title { font-weight: 700; margin-bottom: 4px; }
.after-24h .after-note { font-size: 13px; color: var(--hint); margin-top: 6px; }
.extra-icon.temp { background: var(--amber-soft); }
.extra-icon.fever { background: var(--red-soft); }
.extra-icon.walk, .extra-icon.tummy { background: var(--teal-soft); }
.extra-icon.bath { background: var(--blue-soft); }
.rec.alarm .rec-main b { color: var(--danger); }

.input-big { font-size: 26px; font-weight: 700; min-height: 60px; font-variant-numeric: tabular-nums; }
.input.fever { color: var(--danger); box-shadow: inset 0 0 0 2px var(--danger); }
.fever-alert { background: var(--red-soft); color: var(--danger); border-color: transparent; margin-top: 0; }

/* --- рост -------------------------------------------------------------------------------------- */

.screen-growth { display: flex; flex-direction: column; gap: 12px; }
.screen-growth .stats-head { flex-direction: row; align-items: center; justify-content: space-between; }
.btn-add { min-height: 48px; padding: 0 16px 0 12px; }
.growth-body { display: flex; flex-direction: column; gap: 12px; }
.growth-card { padding-bottom: 12px; }
.pct-badge { font-size: 13.5px; font-weight: 700; color: var(--green); background: var(--green-soft); padding: 5px 10px; border-radius: 10px; white-space: nowrap; }
.growth-empty { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 20px 16px; }
.growth-empty .placeholder-icon { background: var(--field); font-size: 28px; margin: 0; }
.growth-empty p { color: var(--hint); font-size: 15px; }
.growth-icon { background: var(--green-soft); }
.growth-note { padding: 0 4px; }

/* --- лекарства --------------------------------------------------------------------------------- */

.med-card { background: var(--field); border-radius: 16px; padding: 8px 12px 4px; margin-bottom: 10px; }
.med-head { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.med-icon { font-size: 22px; }
.med-rec-icon { background: rgba(143, 99, 232, 0.14); }
.slot { display: flex; align-items: center; gap: 10px; min-height: 60px; border-top: 1px solid var(--line); }
.slot-time { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 52px; }
.slot.late .slot-time { color: var(--danger); }
.slot-actions { margin-left: auto; display: flex; gap: 8px; }
.slot-actions .btn-soft { background: var(--card); }
.dose-state { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--green); font-weight: 600; text-align: right; }
.dose-state.skipped { color: var(--hint); }
.dose-state .link-btn { font-size: 14px; font-weight: 500; }
.rec.inactive { opacity: 0.55; }
.times-box { display: flex; flex-direction: column; gap: 6px; }
.times-list { display: flex; flex-wrap: wrap; gap: 8px; }
.time-item { display: flex; align-items: center; gap: 2px; background: var(--field); border-radius: 12px; padding-left: 4px; }
.time-item .input-sm { background: transparent; }

/* --- прививки ---------------------------------------------------------------------------------- */

.vaccine-note { margin-top: 0; align-items: center; }
.suggest-box { margin-top: 10px; padding: 12px 14px; border-radius: 14px; background: var(--blue-soft); font-size: 15px; }
.suggest-actions { display: flex; gap: 8px; margin-top: 10px; }
.suggest-actions .btn { flex: 1; }
.vac-summary { margin: 12px 2px 0; }
.vac-icon { background: var(--field); font-weight: 800; font-size: 16px; }
.vac-done .vac-icon { background: var(--green-soft); color: var(--green); }
.vac-done .rec-main b { color: var(--hint); font-weight: 600; }
.vac-overdue .vac-icon { background: var(--red-soft); color: var(--danger); }
.vac-overdue .rec-sub { color: var(--danger); }
.vac-soon .vac-icon { background: var(--amber-soft); color: var(--amber); font-size: 26px; }
.vac-soon .rec-sub { color: var(--amber); font-weight: 600; }
.vac-group .rec:first-child { border-top: 0; }

/* --- дневник ----------------------------------------------------------------------------------- */

.diary { display: flex; flex-direction: column; gap: 10px; }
.diary-entry { background: var(--field); border-radius: 16px; padding: 12px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 8px; }
.diary-entry.milestone { background: var(--amber-soft); }
.diary-meta { display: flex; justify-content: space-between; align-items: center; }
.diary-date { font-size: 13px; font-weight: 700; color: var(--hint); text-transform: uppercase; letter-spacing: 0.3px; }
.milestone-badge { align-self: flex-start; font-weight: 700; font-size: 15px; padding: 4px 10px; border-radius: 10px; background: var(--card); }
.diary-text { font-size: 16px; line-height: 1.4; white-space: pre-wrap; }
.diary-photo { width: 100%; max-height: 260px; object-fit: cover; border-radius: 12px; background: var(--card); }

/* --- «Ещё»: профиль и разделы -------------------------------------------------------------------- */

.profile-id { flex: 1; min-width: 0; }
.form-actions { display: flex; gap: 10px; padding: 4px 0 6px; }
.form-actions .btn { flex: 1; }
.sections-card { padding-top: 4px; padding-bottom: 4px; }
.link-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; text-align: left; border-top: 1px solid var(--line); }
.link-row:first-child { border-top: 0; }
.link-row .more-emoji { font-size: 24px; width: 36px; text-align: center; }
.link-row .set-text { flex: 1; }
.link-arrow { color: var(--hint); display: flex; }

/* --- колёса выбора (wheel.js): вес, рост, голова ------------------------------------------ */
.measure-wheels { display: flex; flex-direction: column; gap: 10px; }
.mw-head { display: flex; align-items: center; gap: 10px; min-height: 48px; }
.mw-label { font-size: 13px; font-weight: 600; color: var(--hint); }
.mw-value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.mw-value.off { font-size: 17px; font-weight: 500; color: var(--hint); }
.mw-toggle { margin-left: auto; min-height: 48px; padding: 0 4px; }
.mw-wheels { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mw-wheels[hidden] { display: none; }
.mw-col { position: relative; }
.mw-unit { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: 15px; color: var(--hint); pointer-events: none; z-index: 2; }
.wheel { position: relative; border-radius: 14px; background: var(--field); overflow: hidden; outline: none; touch-action: pan-y; }
.wheel:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.wheel-band {
  position: absolute; left: 4px; right: 4px; top: 50%; height: 48px; transform: translateY(-50%);
  border-radius: 11px; background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14); pointer-events: none;
}
.wheel-list {
  position: relative; z-index: 1; height: 100%; overflow-y: auto; scroll-snap-type: y mandatory;
  overscroll-behavior: contain; scrollbar-width: none; cursor: grab; user-select: none; -webkit-user-select: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 32%, #000 68%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 32%, #000 68%, transparent);
}
.wheel-list::-webkit-scrollbar { display: none; }
.wheel-list.dragging { scroll-snap-type: none; cursor: grabbing; }
.wheel-item {
  height: 48px; display: flex; align-items: center; justify-content: center; scroll-snap-align: center;
  font-size: 19px; color: var(--hint); font-variant-numeric: tabular-nums; transition: color 0.12s, font-size 0.12s;
}
.wheel-item.selected { color: var(--text); font-size: 22px; font-weight: 700; }

/* --- G26/G28: плашка лекарств к кормлению, тост с «Отменить», правка идущего таймера --- */
.toast.toast-action { pointer-events: auto; display: flex; align-items: center; gap: 12px; }
.toast-btn { min-height: 40px; padding: 0 14px; border: 0; border-radius: 10px; background: rgba(255,255,255,.2);
  color: inherit; font: inherit; font-weight: 700; cursor: pointer; }
.med-banner { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.med-banner-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 14px; border-radius: 14px;
  background: #fff4d6; color: #5a4300; }
.med-banner-text { flex: 1; font-weight: 600; }
.med-banner-row .btn, .med-banner-row .link-btn { min-height: 48px; }
.act-pill.sleep { background: #e8e6fb; }
.act-edit { border: 0; background: none; text-align: left; font: inherit; color: inherit; padding: 0; min-height: 48px; cursor: pointer; }
.act-hint { font-size: 12px; opacity: .7; }
.seg-wrap { flex-wrap: wrap; }
.seg-wrap > * { flex: 1 1 30%; }
.time-wheel { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.time-wheel .wheel { flex: 1; }
.dose-hist { list-style: none; margin: 0; padding: 0; }
.dose-hist li { display: flex; align-items: center; gap: 8px; min-height: 48px; border-bottom: 1px solid rgba(0,0,0,.08); }
.dose-hist .dh-main { flex: 1; }
.med-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 14px; }

/* --- браузер без Telegram (G32) -------------------------------------------------------------- */

.session-card { display: flex; flex-direction: column; gap: 8px; }
.login-screen .btn { text-decoration: none; }
@media (min-width: 521px) {
  html.browser .screens, html.browser .tabbar, html.browser .sheet { max-width: 480px; }
  html.browser .tabbar { margin: 0 auto; }
}
