:root {
  --bg: #fbf7f4;
  --bg-elev: #ffffff;
  --bg-sunken: #f4ece6;
  --card: #ffffff;
  --ink: #2e2a33;
  --ink-soft: #6b6472;
  --ink-faint: #9a929f;
  --line: #eae1da;
  --line-strong: #ded2c8;

  --accent: #8a6fd1;
  --accent-soft: #f0eafb;
  --accent-ink: #6a4fb8;
  --night: #4d5f9e;
  --night-soft: #e6eaf6;
  --day: #e9a23b;
  --day-soft: #fdf2df;
  --wake: #d96a7a;
  --wake-soft: #fbe9ec;
  --mint: #4fa98b;

  --radius: 20px;
  --radius-sm: 12px;
  --shadow-1: 0 1px 2px rgba(58, 44, 32, .05), 0 4px 14px rgba(58, 44, 32, .05);
  --shadow-2: 0 2px 6px rgba(58, 44, 32, .07), 0 14px 34px rgba(58, 44, 32, .09);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --nav-h: 68px;

  --font: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #16141a;
  --bg-elev: #1f1c25;
  --bg-sunken: #100e14;
  --card: #211e28;
  --ink: #f2edf6;
  --ink-soft: #a9a1b3;
  --ink-faint: #746c80;
  --line: #302b3a;
  --line-strong: #3d3749;

  --accent: #a88ef0;
  --accent-soft: #2a2338;
  --accent-ink: #c2adf7;
  --night: #7d8fd0;
  --night-soft: #232a3f;
  --day: #efb45c;
  --day-soft: #33291a;
  --wake: #e58b98;
  --wake-soft: #38232a;
  --mint: #63c2a2;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
  --shadow-2: 0 2px 8px rgba(0, 0, 0, .35), 0 18px 40px rgba(0, 0, 0, .35);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body { min-height: 100vh; min-height: 100dvh; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; border: 0; background: none; }

a { color: var(--accent-ink); }

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.02em; }

/* ---------------------------------------------------------------- layout */

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px calc(var(--nav-h) + var(--safe-b) + 20px);
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(var(--safe-t) + 14px) 0 12px;
  background: linear-gradient(var(--bg) 72%, transparent);
  backdrop-filter: blur(10px);
}

.topbar h1 {
  font-size: 24px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar .sub { font-size: 13px; color: var(--ink-soft); font-weight: 500; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 18px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
}

.card.flush { padding: 0; overflow: hidden; }
.card h3 { font-size: 16px; margin-bottom: 4px; }
.muted { color: var(--ink-soft); font-size: 14px; }
.faint { color: var(--ink-faint); font-size: 13px; }

.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

/* ------------------------------------------------------------ navigation */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  align-items: stretch;
  /* Непрозрачный фон — база для браузеров без color-mix/backdrop-filter.
     Без него панель становится прозрачной и подписи теряются на контенте. */
  background: var(--card);
  border-top: 1px solid var(--line);
  /* Дальше — улучшение там, где поддерживается; при отсутствии
     поддержки объявление просто игнорируется, фон остаётся непрозрачным. */
  background: color-mix(in srgb, var(--card) 88%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  backdrop-filter: blur(18px) saturate(180%);
}

.tabbar-inner {
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  /* --ink-faint даёт контраст 3.0:1 — ниже нормы 4.5:1 для мелкого текста,
     поэтому подписи вкладок используем на ступень темнее (5.7:1). */
  color: var(--ink-soft);
  font-size: 10.5px;
  font-weight: 600;
  padding: 8px 2px;
  min-width: 0;
  transition: color .16s;
  position: relative;
}
.tab svg { width: 22px; height: 22px; stroke-width: 1.9; flex: none; }
/* Пять вкладок на узком экране: подпись не должна распирать ячейку. */
.tab span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tab.active { color: var(--accent-ink); }
.tab.active::before {
  content: "";
  position: absolute;
  top: 4px;
  width: 26px;
  height: 3px;
  border-radius: 3px;
  background: var(--accent);
}
.tab:active { transform: scale(.95); }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 18px;
  border-radius: 14px;
  font-weight: 650;
  font-size: 15px;
  background: var(--bg-sunken);
  color: var(--ink);
  border: 1px solid transparent;
  transition: transform .12s, filter .16s, background .16s;
  min-height: 48px;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 30%, transparent); }
.btn.ghost { background: transparent; border-color: var(--line-strong); color: var(--ink-soft); }
.btn.danger { background: var(--wake-soft); color: var(--wake); }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 12px; min-height: 36px; font-size: 13.5px; border-radius: 10px; }
.btn.icon-only { width: 40px; min-width: 40px; padding: 0; }

/* ------------------------------------------------------------ sleep hero */

.hero { text-align: center; padding: 6px 0 2px; }
.hero .clock { font-size: 13px; font-weight: 600; color: var(--ink-soft); letter-spacing: .04em; text-transform: uppercase; }

.donut-wrap { position: relative; width: 100%; max-width: 340px; margin: 4px auto 0; aspect-ratio: 1; }
.donut-wrap svg { width: 100%; height: 100%; display: block; overflow: visible; }
.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  gap: 2px;
}
.donut-center .total { font-size: 34px; font-weight: 750; letter-spacing: -.03em; line-height: 1.1; }
.donut-center .total small { font-size: 16px; font-weight: 600; color: var(--ink-soft); }
.donut-center .caption { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.donut-center .badge {
  margin-top: 6px;
  font-size: 11.5px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 650;
}

.arc-seg { transition: opacity .18s; cursor: pointer; }
.arc-seg:hover { opacity: .82; }

.seg-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; margin-top: 10px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.dot.night { background: var(--night); }
.dot.day { background: var(--day); }
.dot.wake { background: var(--wake); }
.dot.awake { background: var(--line-strong); }

/* ------------------------------------------------------------ stat grid */

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat {
  background: var(--bg-sunken);
  border-radius: var(--radius-sm);
  padding: 12px 13px;
}
.stat .k { font-size: 11.5px; color: var(--ink-soft); font-weight: 650; text-transform: uppercase; letter-spacing: .03em; }
.stat .v { font-size: 21px; font-weight: 750; letter-spacing: -.02em; margin-top: 2px; }
.stat .v small { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.stat .n { font-size: 12px; color: var(--ink-faint); margin-top: 1px; }

/* -------------------------------------------------------------- controls */

.controls { display: grid; gap: 10px; }

.ctrl {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 15px 16px;
  border-radius: 16px;
  text-align: left;
  transition: transform .12s, box-shadow .16s;
  border: 1.5px solid;
  position: relative;
  overflow: hidden;
}
.ctrl:active { transform: scale(.985); }
.ctrl:disabled { opacity: .5; pointer-events: none; }

.ctrl .ico {
  width: 42px; height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  flex: none;
}
.ctrl .ico svg { width: 22px; height: 22px; stroke-width: 2; }
.ctrl .body { flex: 1; min-width: 0; }
.ctrl .label { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.ctrl .hint { font-size: 12.5px; margin-top: 1px; opacity: .78; }
.ctrl .timer { font-variant-numeric: tabular-nums; font-weight: 750; font-size: 15px; }

.ctrl.day { background: var(--day-soft); border-color: color-mix(in srgb, var(--day) 32%, transparent); color: #7a4c05; }
.ctrl.day .ico { background: color-mix(in srgb, var(--day) 26%, transparent); color: #a86a10; }
[data-theme="dark"] .ctrl.day { color: #f3cd8a; }

.ctrl.night { background: var(--night-soft); border-color: color-mix(in srgb, var(--night) 32%, transparent); color: #33406e; }
.ctrl.night .ico { background: color-mix(in srgb, var(--night) 24%, transparent); color: #42548f; }
[data-theme="dark"] .ctrl.night { color: #bac6ec; }

.ctrl.waking { background: var(--wake-soft); border-color: color-mix(in srgb, var(--wake) 32%, transparent); color: #8a3444; }
.ctrl.waking .ico { background: color-mix(in srgb, var(--wake) 24%, transparent); color: #b04a5c; }
[data-theme="dark"] .ctrl.waking { color: #f0b0b9; }

.ctrl.live::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 2px currentColor;
  opacity: .3;
  animation: pulse 2.4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes pulse { 0%,100% { opacity: .18 } 50% { opacity: .42 } }

/* ----------------------------------------------------------- suggestions */

.sugg {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.sugg:last-child { border-bottom: 0; padding-bottom: 0; }
.sugg:first-child { padding-top: 0; }
.sugg .time {
  flex: none;
  width: 58px;
  font-weight: 750;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  padding-top: 1px;
}
.sugg .time small { display: block; font-size: 11.5px; font-weight: 600; opacity: .6; }
.sugg .info { flex: 1; min-width: 0; }
.sugg .t { font-weight: 650; font-size: 14.5px; }
.sugg .r { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.sugg.bed .time { color: var(--night); }
.sugg.nap .time { color: #b07513; }

/* ---------------------------------------------------------------- charts */

.chart { width: 100%; display: block; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--ink-faint); font-size: 10px; font-weight: 600; }
.chart .band { opacity: .17; }
.chart .p50 { stroke-width: 1.6; stroke-dasharray: 5 4; opacity: .55; fill: none; }
.chart .series { fill: none; stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt { stroke: var(--card); stroke-width: 2; }

/* -------------------------------------------------------------- segments */

.seglist { display: flex; flex-direction: column; }
.segrow {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.segrow:last-child { border-bottom: 0; }
.segrow .bar { width: 3px; align-self: stretch; border-radius: 3px; flex: none; min-height: 34px; }
.segrow.night .bar { background: var(--night); }
.segrow.day .bar { background: var(--day); }
.segrow.waking .bar { background: var(--wake); }
.segrow .main { flex: 1; min-width: 0; }
.segrow .t1 { font-weight: 650; font-size: 14.5px; font-variant-numeric: tabular-nums; }
.segrow .t2 { font-size: 12.5px; color: var(--ink-soft); }
.segrow .actions { display: flex; gap: 4px; flex: none; }

.iconbtn {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--ink-faint);
  transition: background .14s, color .14s;
}
.iconbtn:hover { background: var(--bg-sunken); color: var(--ink); }
.iconbtn.danger:hover { background: var(--wake-soft); color: var(--wake); }
.iconbtn svg { width: 17px; height: 17px; }

/* ----------------------------------------------------------------- tabs */

.segmented {
  display: flex;
  background: var(--bg-sunken);
  border-radius: 13px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 14px;
}
.segmented button {
  flex: 1;
  padding: 9px 10px;
  border-radius: 10px;
  font-weight: 650;
  font-size: 14px;
  color: var(--ink-soft);
  transition: all .18s;
  white-space: nowrap;
}
.segmented button.on {
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}

/* ----------------------------------------------------------------- forms */

.field { margin-bottom: 13px; }
.field > label { display: block; font-size: 12.5px; font-weight: 650; color: var(--ink-soft); margin-bottom: 5px; }
.input, .select, .textarea {
  width: 100%;
  padding: 12px 13px;
  border-radius: 12px;
  border: 1.5px solid var(--line-strong);
  background: var(--bg-elev);
  font-size: 15px;
  min-height: 46px;
  transition: border-color .16s, box-shadow .16s;
  appearance: none;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.textarea { min-height: 74px; resize: vertical; line-height: 1.45; }
.select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239a929f' stroke-width='2.4' stroke-linecap='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 17px;
  padding-right: 38px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ------------------------------------------------- выбор времени для кнопок */

.time-hero {
  text-align: center;
  padding: 6px 0 14px;
}
.time-value {
  font-size: 40px;
  font-weight: 720;
  letter-spacing: -1.4px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: var(--ink);
}
.time-sub {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-faint);
  margin-top: 2px;
}
.quick-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-bottom: 15px;
}
.quick {
  padding: 10px 4px;
  border-radius: 11px;
  border: 1.5px solid var(--line-strong);
  background: var(--bg-elev);
  font-size: 12.5px;
  font-weight: 650;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color .14s, background .14s, color .14s;
  min-height: 40px;
}
.quick:active { transform: scale(.97); }
.quick.on {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-elev));
  color: var(--accent-ink, var(--accent));
}
.note-line {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--ink-soft);
  margin: 2px 0 4px;
  line-height: 1.35;
}
.note-line svg { width: 15px; height: 15px; flex: none; opacity: .75; }
.note-line.faint { color: var(--ink-faint); margin-top: 0; }

/* Подсказка под кнопками пульта. */
.ctrl-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-top: 10px;
  font-size: 11.5px;
  font-weight: 550;
  color: var(--ink-faint);
}
.ctrl-note svg {
  width: 13px;
  height: 13px;
  transform: rotate(-90deg);
  opacity: .8;
}

@media (max-width: 360px) {
  .time-value { font-size: 34px; }
  .quick { font-size: 11.5px; }
}

/* ---------------------------------------------------------------- dialogs */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(24, 18, 30, .42);
  backdrop-filter: blur(3px);
  animation: fade .18s ease;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
@keyframes fade { from { opacity: 0 } }
.sheet {
  background: var(--bg-elev);
  width: 100%;
  max-width: 560px;
  border-radius: 24px 24px 0 0;
  padding: 20px 18px calc(20px + var(--safe-b));
  max-height: 92dvh;
  overflow-y: auto;
  animation: slideUp .24s cubic-bezier(.22,.9,.3,1);
  box-shadow: var(--shadow-2);
}
@keyframes slideUp { from { transform: translateY(40px); opacity: .6 } }
.sheet h3 { font-size: 19px; margin-bottom: 3px; }
.sheet .sub { font-size: 13.5px; color: var(--ink-soft); margin-bottom: 16px; }
.sheet-actions { display: flex; gap: 9px; margin-top: 18px; }
.sheet-actions .btn { flex: 1; }
.sheet-handle { width: 38px; height: 4px; border-radius: 3px; background: var(--line-strong); margin: 0 auto 14px; }

/* ----------------------------------------------------------------- misc */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  letter-spacing: .01em;
}
.pill.current { background: var(--accent-soft); color: var(--accent-ink); }
.pill.past { background: var(--bg-sunken); color: var(--ink-faint); }
.pill.future { background: var(--day-soft); color: #a06a12; }

.empty { text-align: center; padding: 28px 16px; color: var(--ink-faint); }
.empty .big { font-size: 30px; margin-bottom: 6px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  transform: translateX(-50%) translateY(10px);
  background: var(--ink);
  color: var(--bg);
  padding: 11px 18px;
  border-radius: 13px;
  font-size: 14px;
  font-weight: 600;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: calc(100vw - 40px);
  text-align: center;
  box-shadow: var(--shadow-2);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--wake); color: #fff; }

.leapcard { position: relative; overflow: hidden; }
.leapcard .glow {
  position: absolute;
  top: -60px; right: -50px;
  width: 180px; height: 180px;
  border-radius: 50%;
  filter: blur(38px);
  opacity: .3;
  pointer-events: none;
}
.leaprow {
  display: flex;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  align-items: flex-start;
}
.leaprow:last-child { border-bottom: 0; }
.leaprow .num {
  width: 38px; height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 750;
  font-size: 16px;
  flex: none;
}
.leaprow .main { flex: 1; min-width: 0; }
.leaprow .ttl { font-weight: 650; font-size: 14.5px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.leaprow .dsc { font-size: 12.5px; color: var(--ink-soft); margin-top: 1px; }
.leaprow .age { font-size: 11.5px; color: var(--ink-faint); margin-top: 3px; font-variant-numeric: tabular-nums; }

/* Текущий этап выделен в списке, пройденные приглушены. */
.leaprow.is-current {
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  border-radius: 12px;
  padding-left: 10px;
  padding-right: 10px;
  margin: 0 -10px;
}
.leaprow.is-past { opacity: .62; }
.leaprow.is-past:active { opacity: .8; }

/* ------------------------------------------------- фильтр и группы этапов */

.filter-row {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 2px 0 12px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.filter-row::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1.5px solid var(--line-strong);
  background: var(--bg-elev);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 620;
  white-space: nowrap;
  cursor: pointer;
  flex: none;
  min-height: 38px;
  transition: border-color .15s, background .15s, color .15s;
}
.chip:active { transform: scale(.97); }
.chip.on {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 13%, var(--bg-elev));
  color: var(--accent-ink);
}
.chip-n {
  font-size: 11.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg-sunken);
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.chip.on .chip-n { background: var(--accent-soft); color: var(--accent-ink); }

.group { padding: 0; overflow: hidden; }
.group.has-current { border-color: color-mix(in srgb, var(--accent) 38%, var(--line-strong)); }
.group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 15px 16px;
  background: none;
  border: 0;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
  font: inherit;
  min-height: 52px;
}
.group-name { font-weight: 700; font-size: 15px; flex: 1; }
.group-dots { display: flex; gap: 3px; }
.gp-dot { width: 7px; height: 7px; border-radius: 50%; display: block; opacity: .75; }
.group-count {
  font-size: 12px;
  font-weight: 650;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.group-chev { display: flex; color: var(--ink-faint); transition: transform .2s; }
.group-chev svg { width: 17px; height: 17px; }
.group.open .group-chev { transform: rotate(180deg); }
.group-body { padding: 0 16px 6px; }

@media (max-width: 360px) {
  .group-name { font-size: 14px; }
  .chip { padding: 7px 11px; font-size: 12.5px; }
}

.progress { height: 6px; border-radius: 4px; background: var(--bg-sunken); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 4px; background: var(--accent); transition: width .4s; }

.skill { display: flex; gap: 9px; padding: 7px 0; font-size: 14px; align-items: flex-start; }
.skill .tick { flex: none; color: var(--mint); margin-top: 1px; }
.skill .tick svg { width: 16px; height: 16px; }

.loading { display: grid; place-items: center; padding: 60px 0; color: var(--ink-faint); }
.spinner {
  width: 26px; height: 26px;
  border: 2.5px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

.today-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-left: 5px;
  vertical-align: middle;
}

@media (min-width: 620px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
  .controls { grid-template-columns: 1fr 1fr; }
  .donut-wrap { max-width: 360px; }
  .app { padding-left: 20px; padding-right: 20px; }
}

@media (max-width: 360px) {
  .donut-center .total { font-size: 29px; }
  .ctrl { padding: 13px 14px; }
  .ctrl .label { font-size: 14px; }
}

/* ------------------------------------------------------------------ кормление */

.datebar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
}
.datebar-label {
  flex: 1;
  text-align: center;
  font-size: 14px;
  font-weight: 650;
  color: var(--ink-soft);
}
.iconbtn.flip svg { transform: rotate(180deg); }
.iconbtn:disabled { opacity: .35; }

.feedsum {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 18px;
  margin-bottom: 12px;
}
.feedsum-main { text-align: center; padding-bottom: 14px; }
.feedsum-value {
  font-size: 42px;
  font-weight: 750;
  letter-spacing: -.03em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.feedsum-unit { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.feedsum-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.feedsum-grid > div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.feedsum-grid b {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.feedsum-grid span { font-size: 11.5px; color: var(--ink-soft); }

.chiprow {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 14px;
}
.chip.soft {
  cursor: default;
  background: var(--bg-sunken);
  border-color: transparent;
  color: var(--ink-soft);
  font-size: 12px;
  padding: 6px 11px;
  min-height: 0;
}

.feedlist { display: flex; flex-direction: column; gap: 8px; }
.feedrow {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-1);
  color: var(--ink);
  transition: transform .12s;
}
.feedrow:active { transform: scale(.985); }
.feedrow-icon {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--bg-sunken);
  color: var(--ink-soft);
}
.feedrow-icon svg { width: 20px; height: 20px; }
.feedrow-icon.k-formula,
.feedrow-icon.k-bottle { background: var(--night-soft); color: var(--night); }
.feedrow-icon.k-breast { background: var(--wake-soft); color: var(--wake); }
.feedrow-icon.k-solids { background: var(--day-soft); color: var(--day); }
.feedrow-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.feedrow-title {
  font-size: 14.5px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.feedrow-sub {
  font-size: 12px;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.feedrow-go { width: 17px; height: 17px; flex: none; color: var(--ink-faint); }

.kindgrid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}
.kindbtn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line-strong);
  background: var(--bg-elev);
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 620;
  transition: border-color .15s, color .15s, background .15s;
}
.kindbtn svg { width: 20px; height: 20px; }
.kindbtn.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 360px) {
  .feedsum-value { font-size: 36px; }
  .kindbtn { font-size: 10.5px; padding: 9px 3px; }
  .kindbtn svg { width: 18px; height: 18px; }
}

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

/* --- Вход и регистрация ------------------------------------------------ */

.authwrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px 16px 32px;
}

.authcard {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 26px 20px 22px;
  box-shadow: var(--shadow-2);
  text-align: center;
}

.authlogo {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.authlogo svg { width: 28px; height: 28px; }

.authtitle {
  font-size: 22px;
  font-weight: 780;
  margin: 0 0 4px;
}
.authsub {
  color: var(--ink-soft);
  font-size: 13.5px;
  margin: 0 0 18px;
}

.authseg { margin-bottom: 16px; }

.authform { text-align: left; display: grid; gap: 12px; }

.autherr {
  background: var(--wake-soft);
  color: var(--wake);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
}

.authhint {
  margin: 16px 0 0;
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.45;
}
.authhint b { color: var(--ink); }

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}
.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  flex: none;
}

/* Поля ввода на экране входа */
.field { display: grid; gap: 5px; }
.field-label {
  font-size: 12px;
  font-weight: 650;
  color: var(--ink-soft);
  letter-spacing: .01em;
}

/* --- Переключатель детей ----------------------------------------------- */

.childsw {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 0 10px;
  margin: -2px 0 2px;
  scrollbar-width: none;
}
.childsw::-webkit-scrollbar { display: none; }

.childbtn {
  flex: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 6px 13px;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.childbtn.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.childbtn:active { transform: scale(.97); }
