/* ===========================================================
   BABY TRACKER — стили. Мобильный экран, крупные кнопки.
   =========================================================== */

:root {
  --bg:        #f4f1ee;
  --card:      #ffffff;
  --card-2:    #faf8f6;
  --text:      #22201e;
  --muted:     #8a8480;
  --line:      #e7e2dd;
  --shadow:    0 1px 2px rgba(30,25,20,.05), 0 6px 20px rgba(30,25,20,.06);

  --feed:      #e8904a;
  --feed-bg:   #fdf0e4;
  --sleep:     #6f7bd0;
  --sleep-bg:  #eceefb;
  --diaper:    #3ba893;
  --diaper-bg: #e4f5f1;
  --pump:      #d4789a;
  --pump-bg:   #fbeaf0;

  --danger:    #d9534f;
  --radius:    20px;
  --safe-b:    env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:     #17161a;
    --card:   #201f24;
    --card-2: #26252b;
    --text:   #f0eeec;
    --muted:  #918c95;
    --line:   #302e36;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);

    --feed-bg:   #33240f;
    --sleep-bg:  #1e2040;
    --diaper-bg: #10302a;
    --pump-bg:   #341824;
 }
}

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

html, body {
  margin: 0;
  padding: 0;
  background: #f4f1ee;
  background: var(--bg);
  color: #22201e;
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  overscroll-behavior-y: none;
}

body { padding-bottom: calc(72px + 0px); padding-bottom: calc(72px + var(--safe-b)); }

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, select { font: inherit; color: inherit; }

.wrap { max-width: 520px; margin: 0 auto; padding: 14px 16px 8px; }

/* ------------------------------------------------------ шапка */
.top {
  display: -webkit-box; display: -webkit-flex; display: flex; align-items: baseline;
  padding: 6px 2px 14px;
}
.top h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -.3px; }
.top .date { color: #8a8480; color: var(--muted); font-size: 14px; margin-left: auto; }
.top .age {
  color: #8a8480;
  color: var(--muted); font-size: 14px; font-weight: 500;
  white-space: nowrap; margin-left: 8px;
}
.iconbtn {
  font-size: 18px; line-height: 1; padding: 6px; border-radius: 10px;
  opacity: .65; align-self: center;
}
.iconbtn:active { opacity: 1; }

/* ------------------------------------------------------ активный таймер */
.timers { margin-bottom: 14px; }
.timers > * + * { margin-top: 10px; }
.timers:empty { display: none; }

.timer {
  display: flex; align-items: center; 
  background: #ffffff;
  background: var(--card); border-radius: 20px; border-radius: var(--radius);
  padding: 14px 14px 14px 16px; box-shadow: 0 1px 2px rgba(30,25,20,.05), 0 6px 20px rgba(30,25,20,.06); box-shadow: var(--shadow);
  border-left: 5px solid #e7e2dd;
  border-left: 5px solid var(--line);
}
.timer > * + * { margin-left: 12px; }
.timer.t-breast { border-left-color: #e8904a; border-left-color: var(--feed); }
.timer.t-sleep  { border-left-color: #6f7bd0; border-left-color: var(--sleep); }
.timer .em { font-size: 24px; }
.timer .info { flex: 1; min-width: 0; }
.timer .lbl  { font-size: 13px; color: #8a8480; color: var(--muted); }
.timer .val  { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.timer .stop {
  background: #22201e;
  background: var(--text); color: #f4f1ee; color: var(--bg);
  border-radius: 999px; padding: 11px 18px; font-weight: 600; font-size: 15px;
  white-space: nowrap;
}
.timer .stop:active { transform: scale(.96); }

/* ------------------------------------------------------ 4 большие кнопки */
/* flex + calc вместо grid: grid появился только в Chrome 57 */
.grid { display: -webkit-box; display: -webkit-flex; display: flex;
        -webkit-flex-wrap: wrap; flex-wrap: wrap; }
.grid > .big { width: 48.5%; width: calc(50% - 6px); margin: 0 12px 12px 0; }
.grid > .big:nth-child(2n) { margin-right: 0; }

.big {
  position: relative;
  border-radius: 20px;
  border-radius: var(--radius);
  padding: 20px 14px 18px;
  min-height: 108px;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between;
  box-shadow: 0 1px 2px rgba(30,25,20,.05), 0 6px 20px rgba(30,25,20,.06);
  box-shadow: var(--shadow);
  transition: transform .08s ease;
  text-align: left;
}
.big:active { transform: scale(.97); }
.big .em  { font-size: 30px; line-height: 1; }
.big .cap { display: block; font-size: 17px; font-weight: 650; margin-top: 10px; }
.big .sub { display: block; font-size: 12.5px; color: #8a8480; color: var(--muted); margin-top: 2px; min-height: 16px; }

.big.feed   { background: #fdf0e4; background: var(--feed-bg); }
.big.sleep  { background: #eceefb; background: var(--sleep-bg); }
.big.diaper { background: #e4f5f1; background: var(--diaper-bg); }
.big.pump   { background: #fbeaf0; background: var(--pump-bg); }
.big.on { outline: 2px solid currentColor; }
.big.feed.on  { color: #e8904a; color: var(--feed); }
.big.sleep.on { color: #6f7bd0; color: var(--sleep); }

/* ------------------------------------------------------ карточка «Сегодня» */
.card {
  background: #ffffff;
  background: var(--card); border-radius: 20px; border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(30,25,20,.05), 0 6px 20px rgba(30,25,20,.06);
  box-shadow: var(--shadow); padding: 16px; margin-top: 14px;
}
.card h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .6px;
  color: #8a8480;
  color: var(--muted); margin: 0 0 12px; font-weight: 600;
}
.stats { display: -webkit-box; display: -webkit-flex; display: flex;
         -webkit-flex-wrap: wrap; flex-wrap: wrap; }
.stats > .stat { width: 48%; width: calc(50% - 4px); margin: 0 8px 10px 0; }
.stats > .stat:nth-child(2n) { margin-right: 0; }

.stat { display: flex; align-items: center; }
.stat > * + * { margin-left: 9px; }
.stat .em { font-size: 19px; width: 24px; text-align: center; }
.stat .t  { font-size: 13px; color: #8a8480; color: var(--muted); }
.stat .v  { font-size: 16px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .col { display: flex; flex-direction: column; line-height: 1.25; }

/* ------------------------------------------------------ лента событий */
.feedlist { margin-top: 6px; }
.daygroup { margin-top: 18px; }
.daygroup > h3 {
  font-size: 12.5px; color: #8a8480; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px; margin: 0 0 8px 4px;
}

.row {
  display: flex; align-items: center; 
  background: #ffffff;
  background: var(--card); border-radius: 16px; padding: 12px 14px;
  margin-bottom: 8px; box-shadow: 0 1px 2px rgba(30,25,20,.05), 0 6px 20px rgba(30,25,20,.06); box-shadow: var(--shadow); width: 100%;
}
.row > * + * { margin-left: 12px; }
.row:active { background: #faf8f6; background: var(--card-2); }
.row .em { font-size: 21px; min-width: 26px; text-align: center; white-space: nowrap; }
.row .main { flex: 1; min-width: 0; text-align: left; }
.row .ttl { display: block; font-size: 15px; font-weight: 600; }
.row .meta { display: block; font-size: 12.5px; color: #8a8480; color: var(--muted); margin-top: 1px; }
.row .time { font-size: 14px; color: #8a8480; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.row .pen  { font-size: 13px; color: #8a8480; color: var(--muted); opacity: .5; }

.empty { text-align: center; color: #8a8480; color: var(--muted); padding: 34px 10px; font-size: 14px; }

.linkbtn {
  display: block; width: 100%; text-align: center; color: #8a8480; color: var(--muted);
  font-size: 14px; padding: 12px; font-weight: 550;
}

/* ------------------------------------------------------ нижняя навигация */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; background: #ffffff; background: var(--card); border-top: 1px solid #e7e2dd; border-top: 1px solid var(--line);
  padding-bottom: 0px;
  padding-bottom: var(--safe-b);
}

.nav button {
  flex: 1; padding: 11px 0 10px; color: #8a8480; color: var(--muted);
  font-size: 11px; display: flex; flex-direction: column; align-items: center; 
}
.nav button > * + * { margin-top: 3px; }
.nav button .em { font-size: 20px; }
.nav button.on { color: #22201e; color: var(--text); font-weight: 600; }

/* ------------------------------------------------------ шторки */
.backdrop {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(0,0,0,.42); z-index: 40;
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.backdrop.show { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: #ffffff;
  background: var(--card); border-radius: 26px 26px 0 0;
  padding: 10px 18px calc(22px + 0px);
  padding: 10px 18px calc(22px + var(--safe-b));
  transform: translateY(105%); transition: transform .26s cubic-bezier(.2,.8,.2,1);
  max-height: 88vh; overflow-y: auto;
  max-width: 520px; margin: 0 auto;
}
.sheet.show { transform: translateY(0); }
.handle { width: 38px; height: 4px; border-radius: 99px; background: #e7e2dd; background: var(--line); margin: 0 auto 14px; }
.sheet h2 { font-size: 19px; margin: 0 0 16px; font-weight: 700; }

.seg { display: flex; background: #faf8f6; background: var(--card-2); border-radius: 14px; padding: 4px;  margin-bottom: 16px; }
.seg > * + * { margin-left: 4px; }
.seg button { flex: 1; padding: 10px; border-radius: 11px; font-size: 15px; font-weight: 550; color: #8a8480; color: var(--muted); }
.seg button.on { background: #ffffff; background: var(--card); color: #22201e; color: var(--text); box-shadow: 0 1px 2px rgba(30,25,20,.05), 0 6px 20px rgba(30,25,20,.06); box-shadow: var(--shadow); }

.choice { display: -webkit-box; display: -webkit-flex; display: flex;
          -webkit-flex-wrap: wrap; flex-wrap: wrap; }
.choice > button { width: 32%; width: calc(33.333% - 6.7px); margin: 0 10px 10px 0; }
.choice > button:nth-child(3n) { margin-right: 0; }

.choice button {
  background: #faf8f6;
  background: var(--card-2); border-radius: 16px; padding: 18px 6px 14px;
  display: flex; flex-direction: column; align-items: center; 
  font-size: 14px; font-weight: 550; border: 2px solid transparent;
}
.choice button > * + * { margin-top: 7px; }
.choice button .em { font-size: 26px; }
.choice button:active { transform: scale(.96); }
.choice button.on { border-color: #22201e; border-color: var(--text); }

.field { margin-top: 16px; }
.field label { display: block; font-size: 13px; color: #8a8480; color: var(--muted); margin-bottom: 7px; }
.field input, .field select {
  width: 100%; background: #faf8f6; background: var(--card-2); border: 1px solid #e7e2dd; border: 1px solid var(--line);
  border-radius: 14px; padding: 13px 14px; font-size: 16px;
}

.mlrow { display: flex; align-items: center; }
.mlrow > * + * { margin-left: 10px; }
.mlrow input { text-align: center; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mlrow button {
  width: 52px; height: 52px; flex: none; border-radius: 16px;
  background: #faf8f6;
  background: var(--card-2); font-size: 24px; font-weight: 600;
}

.chips { display: flex;  margin-top: 10px; flex-wrap: wrap; }
.chips > * + * { margin-left: 8px; }
.chips button { background: #faf8f6; background: var(--card-2); border-radius: 999px; padding: 8px 14px; font-size: 14px; color: #8a8480; color: var(--muted); }

.primary {
  display: block; width: 100%; margin-top: 20px;
  background: #22201e;
  background: var(--text); color: #f4f1ee; color: var(--bg);
  border-radius: 16px; padding: 16px; font-size: 16px; font-weight: 650;
}
.primary:active { transform: scale(.985); }
.primary[disabled] { opacity: .4; }

.ghost {
  display: block; width: 100%; margin-top: 10px; padding: 14px;
  border-radius: 16px; font-size: 15px; font-weight: 550; color: #d9534f; color: var(--danger);
  background: #faf8f6;
  background: var(--card-2);
}/* ------------------------------------------------------ тост */
.toast {
  position: fixed; left: 50%; bottom: calc(86px + 0px); bottom: calc(86px + var(--safe-b)); z-index: 60;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  background: #22201e;
  background: var(--text); color: #f4f1ee; color: var(--bg);
  border-radius: 999px; padding: 11px 16px; font-size: 14px; font-weight: 550;
  display: flex; align-items: center;  box-shadow: 0 1px 2px rgba(30,25,20,.05), 0 6px 20px rgba(30,25,20,.06);  box-shadow: var(--shadow);
  max-width: 90vw;
}
/* ------------------------------------------------------ тост */
.toast > * + * { margin-left: 14px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { color: inherit; font-weight: 700; text-decoration: underline; font-size: 14px; }

/* ------------------------------------------------------ норма дня */
.normssub { font-size: 12px; color: #8a8480; color: var(--muted); margin: -6px 0 14px; }

.nrow { display: flex; align-items: flex-start;  margin-bottom: 13px; }
.nrow > * + * { margin-left: 11px; }
.nrow:last-child { margin-bottom: 4px; }
.nrow .em { font-size: 18px; width: 22px; text-align: center; line-height: 1.3; }
.nmain { flex: 1; min-width: 0; }

.ntop { display: flex; align-items: baseline; }
.ntop > * + * { margin-left: 8px; }
.nlbl { font-size: 13.5px; color: #8a8480; color: var(--muted); flex: 1; }
.nval { font-size: 14.5px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nval i { font-style: normal; font-weight: 500; color: #8a8480; color: var(--muted); font-size: 13px; }

.nbar {
  display: block; height: 5px; border-radius: 99px;
  background: #faf8f6;
  background: var(--card-2); margin-top: 6px; overflow: hidden;
}
.nbar i { display: block; height: 100%; border-radius: 99px; background: #8a8480; background: var(--muted); opacity: .55; }
.nbar.done i { background: #3ba893; background: var(--diaper); opacity: 1; }/* ------------------------------------------------------ ИИ-сводка дня */
.aibtn {
  display: flex; align-items: center; justify-content: center; 
  width: 100%; background: #faf8f6; background: var(--card-2); border-radius: 16px;
  padding: 15px; font-size: 15px; font-weight: 600;
}
/* ------------------------------------------------------ ИИ-сводка дня */
.aibtn > * + * { margin-left: 9px; }
.aibtn:active { transform: scale(.985); }
.aibtn .em { font-size: 18px; }

.aitext { margin: 0; font-size: 15px; line-height: 1.55; white-space: pre-wrap; }

.aisec + .aisec { margin-top: 15px; padding-top: 14px; border-top: 1px solid #e7e2dd; border-top: 1px solid var(--line); }
.aicap {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px;
  color: #8a8480;
  color: var(--muted); font-weight: 650; margin-bottom: 5px;
}
.aidis { margin-top: 10px; font-size: 11.5px; line-height: 1.4; color: #8a8480; color: var(--muted); opacity: .8; }

.airow {
  display: flex; align-items: center; 
  margin-top: 14px; padding-top: 12px; border-top: 1px solid #e7e2dd; border-top: 1px solid var(--line);
}
.airow > * + * { margin-left: 12px; }
.aimeta { flex: 1; font-size: 12px; color: #8a8480; color: var(--muted); }
.ailink { font-size: 13px; font-weight: 600; color: #8a8480; color: var(--muted); padding: 2px 4px; }

.aiwait { display: flex; align-items: center;  padding: 14px 2px; color: #8a8480; color: var(--muted); font-size: 14px; }
.aiwait > * + * { margin-left: 7px; }
.aiwait .dot {
  width: 7px; height: 7px; border-radius: 50%; background: #8a8480; background: var(--muted);
  animation: aipulse 1.1s infinite ease-in-out;
}
.aiwait .dot:nth-child(2) { animation-delay: .16s; }
.aiwait .dot:nth-child(3) { animation-delay: .32s; margin-right: 5px; }
@keyframes aipulse { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ------------------------------------------------------ настройки, участники */
.hint { color: #8a8480; color: var(--muted); font-size: 13px; margin: 14px 2px 0; line-height: 1.45; }

.member {
  display: flex; align-items: center;  width: 100%;
  background: #faf8f6;
  background: var(--card-2); border-radius: 14px;
  padding: 12px 14px; margin-bottom: 8px; text-align: left;
}
.member > * + * { margin-left: 10px; }
.member .mname { flex: 1; font-size: 15px; font-weight: 550; min-width: 0;
                 overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .mrole { font-size: 12px; color: #8a8480; color: var(--muted); }
.member .mrm   { font-size: 12.5px; color: #d9534f; color: var(--danger); padding: 4px 6px; }
.babyrow.on { border: 2px solid #22201e; border: 2px solid var(--text); }

.codebox {
  background: #faf8f6;
  background: var(--card-2); border: 1px solid #e7e2dd; border: 1px solid var(--line); border-radius: 14px;
  padding: 13px 14px; margin-top: 16px; font-size: 13px;
  word-break: break-all; color: #8a8480; color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace;
}

.byline { color: #8a8480; color: var(--muted); font-size: 12.5px; margin-top: 14px; text-align: center; }
.byline:empty { display: none; }

.hidden { display: none !important; }

/* ------------------------------------------------------ экран входа */
.gate {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 70;
  background: #f4f1ee;
  background: var(--bg);
  overflow-y: auto;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom, 0px));
}

.gatecard {
  max-width: 380px; margin: 0 auto;
  background: #ffffff;
  background: var(--card);
  border-radius: 20px;
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(30,25,20,.05), 0 6px 20px rgba(30,25,20,.06);
  box-shadow: var(--shadow);
  padding: 26px 20px 22px;
}

.gateem { font-size: 42px; text-align: center; line-height: 1; }

.gatecard h1 {
  font-size: 21px; font-weight: 700; text-align: center;
  margin: 12px 0 8px; letter-spacing: -.3px;
}

.gatetext {
  margin: 0 0 18px; text-align: center; font-size: 14px; line-height: 1.5;
  color: #8a8480;
  color: var(--muted);
}

.gatebtn { display: block; text-align: center; text-decoration: none; }

.gateor {
  text-align: center; margin: 22px 0 6px; position: relative;
  font-size: 12.5px;
  color: #8a8480;
  color: var(--muted);
}
.gateor:before {
  content: ''; position: absolute; left: 0; right: 0; top: 50%;
  border-top: 1px solid #e7e2dd;
  border-top: 1px solid var(--line);
}
.gateor span {
  position: relative; padding: 0 12px;
  background: #ffffff;
  background: var(--card);
}

.gateerr {
  margin-top: 14px; padding: 11px 13px; border-radius: 12px; font-size: 13.5px;
  background: #fdecea; color: #a8322e;
}

.gatehint {
  margin: 16px 2px 0; font-size: 12.5px; line-height: 1.45; text-align: center;
  color: #8a8480;
  color: var(--muted);
}

@media (prefers-color-scheme: dark) {
  .gateerr { background: #3a1e1c; color: #f0a9a6; }
}

/* ------------------------------------------------------ развитие */
.devhead { padding: 4px 2px 2px; }
.devhead h2 { font-size: 20px; font-weight: 700; margin: 0 0 4px; letter-spacing: -.3px; }
.devhead p { margin: 0; font-size: 14px; line-height: 1.5; color: #8a8480; color: var(--muted); }
.devcorr { margin-top: 8px !important; font-size: 12.5px !important; }

.devacts { margin: 0; padding-left: 20px; }
.devacts li { font-size: 14.5px; line-height: 1.5; margin-bottom: 9px; }
.devacts li:last-child { margin-bottom: 0; }

.mrow {
  display: flex; align-items: flex-start; padding: 10px 0;
  border-top: 1px solid #e7e2dd;
  border-top: 1px solid var(--line);
}
.mrow:first-of-type { border-top: 0; padding-top: 2px; }
.mtext { flex: 1; font-size: 14.5px; line-height: 1.45; padding-right: 10px; }
.mbtns { white-space: nowrap; }
.mbtn {
  font-size: 12px; padding: 6px 10px; border-radius: 999px; margin-left: 6px;
  background: #faf8f6;
  background: var(--card-2);
  color: #8a8480;
  color: var(--muted);
}
.mbtn.on {
  background: #3ba893;
  background: var(--diaper);
  color: #fff; font-weight: 600;
}
.mbtn.on[data-state="watch"] { background: #e8904a; background: var(--feed); }

.devcount { display: flex; }
.devcount > span { flex: 1; font-size: 12.5px; color: #8a8480; color: var(--muted); }
.devcount b { display: block; font-size: 22px; font-weight: 700; color: #22201e; color: var(--text); }
.devwarm { margin: 14px 0 0; font-size: 13.5px; }

.devnew { margin: 0; padding-left: 20px; }
.devnew li { font-size: 14.5px; line-height: 1.5; margin-bottom: 7px; }

.wrow { display: flex; align-items: flex-start; padding: 9px 0; }
.wrow .em { font-size: 18px; width: 26px; text-align: center; }
.wrow .main { flex: 1; min-width: 0; }
.wrow .ttl { display: block; font-size: 14.5px; font-weight: 600; }
.wrow .meta { display: block; font-size: 13px; line-height: 1.45; margin-top: 2px; color: #8a8480; color: var(--muted); }

.devchips { display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; }
.devchip {
  font-size: 13px; padding: 7px 12px; border-radius: 999px; margin: 0 7px 7px 0;
  background: #faf8f6;
  background: var(--card-2);
}
.devtip { margin: 6px 2px 0; font-size: 13.5px; line-height: 1.5; }

#pretermWrap input { width: 100%; background: #faf8f6; background: var(--card-2);
  border: 1px solid #e7e2dd; border: 1px solid var(--line);
  border-radius: 14px; padding: 13px 14px; font-size: 16px; margin-top: 10px; }
