/* Дневник малыша. Одна колонка под телефон и большой палец: главное действие — самая большая кнопка.
   У каждого вида записи свой цвет (--c): сон синий, кормление оранжевое, подгузник зелёный, лекарство фиолетовое. */

@font-face {
  font-family: "Onest";
  src: url("/static/fonts/onest-cyrillic-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Onest";
  src: url("/static/fonts/onest-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --ink: #1a2430;
  --muted: #5b6a7d;
  --line: #e1e7ef;
  --on-c: #ffffff;
  --sleep: #2f6fdb; --sleep-btn: #2a63c6; --sleep-soft: #e6effd; --sleep-ink: #1c4ea8;
  --feed: #ea7424; --feed-btn: #c4560c; --feed-soft: #fdeede; --feed-ink: #9c4509;
  --diaper: #1f9370; --diaper-btn: #17785b; --diaper-soft: #e0f4ec; --diaper-ink: #125f49;
  --med: #8355d3; --med-btn: #6f43bd; --med-soft: #efe8fb; --med-ink: #5b35a3;
  --warn-soft: #fff0cf; --warn-ink: #6f4a00;
  --danger: #c23535;
  --shadow: 0 1px 2px rgba(20, 30, 45, .05), 0 6px 20px rgba(20, 30, 45, .05);
  --font: "Onest", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b;
    --surface: #19212b;
    --ink: #e9eef5;
    --muted: #9aa8ba;
    --line: #2a3542;
    --on-c: #0d1219;
    --sleep: #6ea3ff; --sleep-btn: #6ea3ff; --sleep-soft: #1a2b48; --sleep-ink: #b3cdff;
    --feed: #ff9b55; --feed-btn: #ff9b55; --feed-soft: #3d2718; --feed-ink: #ffc8a1;
    --diaper: #55cfa2; --diaper-btn: #55cfa2; --diaper-soft: #15362b; --diaper-ink: #a3e8cd;
    --med: #b594f5; --med-btn: #b594f5; --med-soft: #2b2346; --med-ink: #d6c5fb;
    --warn-soft: #3a2f14; --warn-ink: #f3d18a;
    --danger: #ff8080;
    --shadow: none;
    color-scheme: dark;
  }
}

.sleep  { --c: var(--sleep);  --c-btn: var(--sleep-btn);  --c-soft: var(--sleep-soft);  --c-ink: var(--sleep-ink); }
.feed   { --c: var(--feed);   --c-btn: var(--feed-btn);   --c-soft: var(--feed-soft);   --c-ink: var(--feed-ink); }
.diaper { --c: var(--diaper); --c-btn: var(--diaper-btn); --c-soft: var(--diaper-soft); --c-ink: var(--diaper-ink); }
.med    { --c: var(--med);    --c-btn: var(--med-btn);    --c-soft: var(--med-soft);    --c-ink: var(--med-ink); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
body.sheet-open { overflow: hidden; }
h1, h2, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--sleep); outline-offset: 2px; }
[hidden] { display: none !important; }

#app { max-width: 520px; margin: 0 auto; }
#view {
  display: grid;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(96px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
#view > * { min-width: 0; }
.muted { color: var(--muted); }
.pad { padding: 4px 2px; font-size: 14px; }
.center { text-align: center; }

/* шапка */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 2px 2px 4px; }
.top-text { min-width: 0; }
.top h1 { font-size: 26px; line-height: 1.15; font-weight: 700; letter-spacing: -.01em; overflow-wrap: anywhere; }
.top p { font-size: 14px; margin-top: 2px; }
.me {
  flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; font-size: 14px;
}

.banner { background: var(--sleep-soft); color: var(--sleep-ink); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.banner.warn { background: var(--warn-soft); color: var(--warn-ink); }

/* карточки */
/* minmax(0, 1fr): длинная подпись в одну строку сжимается с многоточием, а не распирает карточку шире экрана */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; box-shadow: var(--shadow); }
.card.on { background: var(--c-soft); border-color: var(--c); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 24px; }
.tag { display: inline-flex; align-items: center; gap: 6px; flex: none; font-weight: 600; font-size: 14px; color: var(--c-ink); }
.tag svg { width: 18px; height: 18px; color: var(--c); }
.by { font-size: 13px; color: var(--muted); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.state { font-size: 17px; font-weight: 600; }
.card.on .state { color: var(--c-ink); }
.big { font-size: 46px; line-height: 1.05; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; min-height: 48px; }
.sub { font-size: 14px; color: var(--muted); }
.sub b { color: var(--ink); font-weight: 600; }
.link { border: 0; background: none; padding: 0; color: var(--sleep-ink); text-decoration: underline; text-underline-offset: 2px; font-size: inherit; }
.hint { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 500; background: var(--bg); border-radius: 10px; padding: 9px 10px; }
.hint svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.hint.due { background: var(--warn-soft); color: var(--warn-ink); font-weight: 600; }
.hint.due svg { color: var(--warn-ink); }

/* кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 0; overflow-wrap: anywhere;
  min-height: 50px; padding: 8px 14px; border-radius: 13px; border: 1px solid transparent;
  font-weight: 600; font-size: 16px; line-height: 1.15; text-align: center; background: var(--bg); color: var(--ink);
  transition: transform .08s ease, filter .08s ease;
}
.btn:active, .side:active, .ev:active, .chip:active, .tab:active { transform: scale(.98); filter: brightness(.97); }
.btn.primary { background: var(--c-btn, var(--sleep-btn)); color: var(--on-c); }
.btn.soft { background: var(--c-soft, var(--bg)); color: var(--c-ink, var(--ink)); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); font-weight: 500; }
.btn.ghost svg { width: 18px; height: 18px; }
.btn.danger { background: transparent; border-color: var(--line); color: var(--danger); }
.btn.xl { min-height: 62px; font-size: 20px; border-radius: 16px; width: 100%; }
.btn.wide { width: 100%; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row.three .btn { padding: 8px 6px; font-size: 15px; }
.row.add { grid-template-columns: minmax(0, 1fr) auto; }

/* стороны груди */
.sides { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.side {
  display: grid; gap: 2px; align-content: center; justify-items: center; min-height: 86px; padding: 10px 6px;
  border-radius: 16px; border: 2px solid var(--line); background: var(--surface); text-align: center;
  transition: transform .08s ease, filter .08s ease;
}
.card.feed:not(.on) .side { border-color: var(--feed-soft); background: var(--feed-soft); color: var(--feed-ink); }
.side.active { border-color: var(--c); background: var(--c-btn); color: var(--on-c); }
.side-name { font-weight: 650; font-size: 18px; }
.side-time { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.1; }
.side-hint { font-size: 12px; opacity: .85; line-height: 1.2; }

/* итог за день */
.sec { font-size: 15px; font-weight: 650; margin: 10px 2px 0; color: var(--ink); }
.tiles { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; display: grid; gap: 1px; border-left: 4px solid var(--c, var(--line)); }
.tile.awake { --c: var(--muted); }
.tile-l { font-size: 13px; color: var(--muted); }
.tile-v { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.tile-x { font-size: 12px; color: var(--muted); }

/* список записей */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.ev {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) 12px; gap: 10px; align-items: center;
  width: 100%; min-height: 58px; padding: 9px 12px; border: 0; background: none; text-align: left;
}
.ev + .ev { border-top: 1px solid var(--line); }
.ev-ic { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--c-soft); color: var(--c); }
.ev-ic svg { width: 19px; height: 19px; }
.ev-main { display: grid; gap: 1px; min-width: 0; }
.ev-title { font-weight: 600; overflow-wrap: anywhere; }
.ev-sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.ev-chev { color: var(--muted); font-size: 20px; line-height: 1; }
.ev.live .ev-title { color: var(--c-ink); }
.ev.live .ev-ic { background: var(--c); color: var(--on-c); }
.day { display: grid; gap: 6px; scroll-margin-top: 12px; }
.day-sum { font-size: 13px; color: var(--muted); padding: 0 2px; }

/* фильтры и метки */
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px; margin: 0 -2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-size: 15px; font-weight: 500; white-space: nowrap;
}
.chip.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip.static { cursor: default; }
.chip.static button { border: 0; background: none; padding: 0 0 0 2px; font-size: 20px; line-height: 1; color: var(--muted); min-width: 24px; min-height: 36px; }
.chips.big .chip { min-height: 50px; padding: 0 20px; font-size: 17px; font-weight: 600; }

/* неделя */
.weeknav { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 8px; }
.weeknav-t { text-align: center; font-weight: 650; display: grid; }
.weeknav-t small { font-weight: 400; font-size: 13px; color: var(--muted); }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn svg { width: 20px; height: 20px; }
.chart { padding: 12px 10px 12px 6px; gap: 6px; }
.chart-heads, .chart-body { display: grid; grid-template-columns: 22px repeat(7, minmax(0, 1fr)); gap: 4px; }
.col-h { display: grid; justify-items: center; font-size: 11px; color: var(--muted); line-height: 1.2; }
.col-h b { font-size: 14px; color: var(--ink); font-weight: 600; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; }
.col-h.today b { background: var(--ink); color: var(--bg); }
.chart-body { height: 444px; margin: 8px 0 6px; }
.axis { position: relative; }
.axis span { position: absolute; right: 2px; transform: translateY(-50%); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.col {
  position: relative; overflow: hidden; padding: 0; border: 0; border-radius: 5px; background-color: var(--bg);
  background-image: repeating-linear-gradient(to bottom, var(--line) 0, var(--line) 1px, transparent 1px, transparent calc(100% / 12));
}
.blk { position: absolute; left: 0; right: 0; min-height: 2px; background: var(--c); }
.blk.feed { z-index: 1; min-height: 3px; }
.nowline { position: absolute; left: 0; right: 0; height: 2px; background: var(--ink); z-index: 2; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 13px; padding-left: 26px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .blk { position: static; width: 12px; height: 12px; min-height: 0; border-radius: 3px; display: inline-block; }
.stats { gap: 0; padding: 4px 14px; }
.stat { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; padding: 11px 0; }
.stat + .stat { border-top: 1px solid var(--line); }
.stat span { color: var(--muted); }
.stat b { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* формы */
.form { gap: 12px; }
.form p { font-size: 15px; }
.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.field.inline { grid-template-columns: minmax(0, 1fr) 84px; align-items: center; gap: 10px; }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
label, .label { font-size: 14px; font-weight: 600; }
.help { font-size: 13px !important; color: var(--muted); }
input:not([type="checkbox"]):not([type="radio"]), select {
  width: 100%; min-height: 50px; padding: 0 12px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--surface); font-size: 17px; min-width: 0; appearance: none; -webkit-appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 22px, calc(100% - 13px) 22px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
input:focus, select:focus { outline: none; border-color: var(--sleep); }
input:disabled { opacity: .5; }
input.time, input.num { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; text-align: center; letter-spacing: .02em; }
input.time::placeholder { font-weight: 400; font-size: 16px; letter-spacing: 0; }
input.num::placeholder { font-weight: 400; font-size: 15px; letter-spacing: 0; }
input.mono { font-size: 13px; color: var(--muted); }
.when { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 8px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 0; background: var(--bg); border-radius: 13px; padding: 4px; }
.seg > button, .seg > label > span {
  display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 4px 8px; border: 0; border-radius: 10px;
  background: none; font-weight: 600; font-size: 15px; text-align: center; cursor: pointer;
}
.seg > button.active, .seg input:checked + span { background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .14); }
.seg.check input:checked + span { background: var(--diaper-soft); color: var(--diaper-ink); }
.seg label { display: block; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:focus-visible + span { outline: 2px solid var(--sleep); }
.switch { display: flex; align-items: center; gap: 12px; font-size: 16px; font-weight: 500; min-height: 44px; }
.switch input { width: 24px; height: 24px; accent-color: var(--sleep); flex: none; }
.form-err { color: var(--danger); font-size: 14px; font-weight: 500; }
.actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.actions .btn.danger { max-width: 130px; }
.actions:has(.danger) { grid-auto-columns: auto 1fr; }

/* шторка */
.backdrop { position: fixed; inset: 0; background: rgba(8, 12, 18, .5); z-index: 20; animation: fade .15s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; margin: 0 auto; max-width: 520px; max-height: 92dvh; overflow-y: auto;
  background: var(--surface); border-radius: 22px 22px 0 0;
  padding: 20px max(16px, env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  animation: rise .18s ease;
}
.sheet > form, .sheet > div { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.sheet h2 { font-size: 21px; font-weight: 700; padding-right: 40px; }
.sheet .list { border-radius: 14px; }
.sheet-x { position: absolute; top: 12px; right: 12px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--bg); font-size: 24px; line-height: 1; color: var(--muted); }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes drop { from { transform: translateY(-16px); opacity: 0; } }

/* нижняя панель */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 4px max(8px, env(safe-area-inset-right, 0px)) calc(4px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
}
.tab { display: grid; justify-items: center; gap: 2px; min-height: 54px; padding: 6px 2px; border: 0; background: none; color: var(--muted); font-size: 11.500px; font-weight: 500; border-radius: 12px; }
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--sleep-ink); font-weight: 650; }

/* всплывающая строка */
/* сверху, а не снизу: внизу она закрывала бы кнопки, которые нажимают следом */
#toast-root { position: fixed; left: 0; right: 0; top: calc(10px + env(safe-area-inset-top, 0px)); z-index: 30; display: grid; justify-items: center; padding: 0 16px; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 14px; max-width: 480px; padding: 12px 16px; border-radius: 14px;
  background: #1c2632; color: #f1f5fa; font-size: 15px; box-shadow: 0 8px 28px rgba(0, 0, 0, .28); animation: drop .18s ease;
}
.toast button { border: 0; background: none; color: #9cc2ff; font-weight: 650; padding: 6px 2px; min-height: 36px; white-space: nowrap; }

/* вход */
.gate { display: grid; gap: 14px; justify-items: stretch; text-align: center; padding: 12vh 6px 0; }
.gate img { justify-self: center; border-radius: 18px; }
.gate h1 { font-size: 28px; font-weight: 700; }
.gate .chips { justify-content: center; }
.gate .row.add { text-align: left; }

@media (min-width: 560px) {
  #tabs { max-width: 520px; margin: 0 auto; border: 1px solid var(--line); border-bottom: 0; border-radius: 16px 16px 0 0; }
}
@media (max-width: 350px) {
  .big { font-size: 40px; }
  .row.three .btn { font-size: 13.500px; padding: 8px 3px; }
  .side-name { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
