/* Нутри — Mini App. Цвета берём у Telegram (--tg-theme-*), своё — только «паприка» для отметок
   и звёзд. Фолбэки на случай открытия в обычном браузере (локальная проверка). */

@font-face {
  font-family: "Onest";
  src: url("fonts/onest-cyrillic.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("fonts/onest-latin.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+0304, U+0308,
    U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Unbounded";
  src: url("fonts/unbounded-cyrillic.woff2") format("woff2");
  font-weight: 200 900;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Unbounded";
  src: url("fonts/unbounded-latin.woff2") format("woff2");
  font-weight: 200 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308,
    U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light dark;
  --page: var(--tg-theme-secondary-bg-color, light-dark(oklch(0.955 0.012 80), oklch(0.17 0.01 60)));
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, light-dark(oklch(0.995 0.004 85), oklch(0.22 0.012 60))));
  --fg: var(--tg-theme-text-color, light-dark(oklch(0.24 0.02 50), oklch(0.94 0.01 80)));
  --hint: var(--tg-theme-hint-color, light-dark(oklch(0.56 0.02 60), oklch(0.66 0.015 70)));
  --accent: light-dark(oklch(0.6 0.165 37), oklch(0.72 0.15 45));
  --on-accent: oklch(0.99 0.01 80);
  --accent-soft: color-mix(in oklch, var(--accent) 13%, var(--card));
  --line: color-mix(in oklch, var(--fg) 9%, transparent);
  --press: color-mix(in oklch, var(--fg) 6%, transparent);

  --display: "Unbounded", "Onest", system-ui, sans-serif;
  --body: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 18px;
  --gutter: 16px;
  --tabs-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  background: var(--page);
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--page);
  color: var(--fg);
  font: 400 16px/1.45 var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  hyphens: auto;
  text-wrap: pretty;
}

::selection {
  background: color-mix(in oklch, var(--accent) 35%, transparent);
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: inherit;
}

h1,
h2,
.rate .title,
.chip {
  hyphens: manual;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 10px;
}

main {
  padding: 12px var(--gutter) calc(var(--tabs-h) + var(--safe-bottom) + 28px);
  max-width: 640px;
  margin-inline: auto;
}

/* --- общее ------------------------------------------------------------------ */

.eyebrow {
  font: 600 11px/1.2 var(--body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--hint);
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
}

.stack > * + * {
  margin-block-start: 12px;
}

.empty {
  text-align: center;
  color: var(--hint);
  padding: 48px 24px;
  text-wrap: balance;
}
.empty strong {
  display: block;
  font: 600 18px/1.3 var(--display);
  color: var(--fg);
  margin-block-end: 6px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.loading {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 64px 0;
}
.loading span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}
.loading span:nth-child(2) {
  animation-delay: 0.15s;
}
.loading span:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 0.25;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

/* --- меню: полоса дней -------------------------------------------------------- */

.weekhead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 2px 10px;
}

.days {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(46px, 1fr);
  gap: 6px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  margin-inline: calc(var(--gutter) * -1);
  padding: 2px var(--gutter) 6px;
}
.days::-webkit-scrollbar {
  display: none;
}

.day {
  scroll-snap-align: center;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 8px 0 10px;
  border-radius: 14px;
  background: var(--card);
  position: relative;
  transition: background 0.18s, color 0.18s, transform 0.12s;
}
.day:active {
  transform: scale(0.96);
}
.day b {
  font: 600 20px/1.1 var(--display);
  font-variant-numeric: tabular-nums;
}
.day small {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--hint);
}
.day.is-empty b {
  color: var(--hint);
  font-weight: 400;
}
.day.is-today::after {
  content: "";
  position: absolute;
  inset-block-end: 4px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}
.day[aria-pressed="true"] {
  background: var(--fg);
  color: var(--card);
}
.day[aria-pressed="true"] small {
  color: color-mix(in oklch, var(--card) 70%, transparent);
}

.weeknotes {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  color: var(--hint);
  font-size: 14px;
}
.weeknotes li + li {
  margin-block-start: 6px;
}
.weeknotes summary {
  cursor: pointer;
  list-style: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
  padding-block: 6px;
}
.weeknotes summary::-webkit-details-marker {
  display: none;
}

/* --- меню: день ------------------------------------------------------------------ */

.dayhead {
  margin: 22px 2px 14px;
}
.dayhead h1 {
  margin: 0;
  font: 600 26px/1.15 var(--display);
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.daynote {
  margin: 8px 0 0;
  padding-inline-start: 12px;
  border-inline-start: 3px solid var(--accent);
  color: var(--hint);
}

.meals {
  background: var(--card);
  border-radius: var(--radius);
  padding: 4px 16px;
}

.meal {
  display: grid;
  grid-template-columns: 3.6rem 1fr;
  gap: 0 12px;
  padding: 16px 0;
}
.meal + .meal {
  border-block-start: 1px solid var(--line);
}
.meal time {
  font: 500 15px/1.6 var(--display);
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.meal h2 {
  margin: 2px 0 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
}
.meal p {
  margin: 6px 0 0;
  font-size: 15px;
}
.meal .label {
  color: var(--hint);
}
.meal .note,
.meal .alt {
  color: var(--hint);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-block-start: 10px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 7px 14px 7px 12px;
  border-radius: 18px;
  line-height: 1.25;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}
.chip svg {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chip .score {
  font-variant-numeric: tabular-nums;
}

.tasks {
  margin-block-start: 12px;
}
.tasks h3 {
  margin: 0 0 8px;
}
.tasks p {
  margin: 0;
  padding: 8px 0;
  font-size: 15px;
}
.tasks p + p {
  border-block-start: 1px solid var(--line);
}

/* --- покупки -------------------------------------------------------------------- */

.list {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
}
.list + .list {
  margin-block-start: 14px;
}
.list > summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 16px 14px;
}
.list > summary::-webkit-details-marker {
  display: none;
}
.list h2 {
  margin: 0;
  font: 600 18px/1.25 var(--display);
  text-wrap: balance;
}
.list .meta {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--hint);
}
.list .meta .late {
  color: var(--accent);
  font-weight: 600;
}
.list .listnote {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--hint);
}
.progress {
  height: 4px;
  margin-block-start: 12px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
}
.progress i {
  display: block;
  height: 100%;
  width: var(--p, 0%);
  background: var(--accent);
  border-radius: inherit;
  transition: width 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.list.is-closed h2::after {
  content: " ✓";
  color: var(--accent);
}

.section h3 {
  margin: 0;
  padding: 14px 16px 4px;
}

.item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: start;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 12px 16px;
  transition: background 0.15s;
}
.item:active {
  background: var(--press);
}
.item {
  position: relative;
}
.item + .item::before {
  content: "";
  position: absolute;
  inset-block-start: 0;
  inset-inline: 56px 0;
  border-block-start: 1px solid var(--line);
}
.box {
  width: 26px;
  height: 26px;
  margin-block-start: -1px;
  border-radius: 50%;
  border: 2px solid color-mix(in oklch, var(--hint) 70%, transparent);
  display: grid;
  place-items: center;
  transition: background 0.18s, border-color 0.18s, transform 0.18s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.box svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--on-accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.15s, transform 0.2s;
}
.item[aria-checked="true"] .box {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.04);
}
.item[aria-checked="true"] .box svg {
  opacity: 1;
  transform: scale(1);
}
.item .name {
  font-size: 16px;
  line-height: 1.35;
}
.item .sub {
  display: block;
  margin-block-start: 2px;
  font-size: 13px;
  color: var(--hint);
}
.item .qty {
  font-size: 14px;
  color: var(--hint);
  font-variant-numeric: tabular-nums;
  text-align: end;
  max-width: 9.5em;
  line-height: 1.35;
  padding-block-start: 1px;
}
.item[aria-checked="true"] .name {
  color: var(--hint);
  text-decoration: line-through;
  text-decoration-color: color-mix(in oklch, var(--hint) 60%, transparent);
}

/* --- оценки -------------------------------------------------------------------- */

.intro {
  margin: 6px 2px 16px;
  color: var(--hint);
  font-size: 14px;
}
.intro h1 {
  margin: 0 0 6px;
  font: 600 24px/1.2 var(--display);
  color: var(--fg);
}

.rategroup + .rategroup {
  margin-block-start: 18px;
}
.rategroup > .eyebrow {
  margin: 0 2px 8px;
}

.rate {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
}
.rate + .rate {
  border-block-start: 1px solid var(--line);
}
.rate .title {
  font-weight: 600;
  line-height: 1.3;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}
.rate .title span:last-child {
  color: var(--hint);
  font-weight: 400;
  font-size: 14px;
  flex: none;
}

.stars {
  display: flex;
  gap: 4px;
  margin-inline-start: -6px;
}
.star {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
}
.star svg {
  width: 30px;
  height: 30px;
  fill: transparent;
  stroke: color-mix(in oklch, var(--hint) 75%, transparent);
  stroke-width: 1.6;
  stroke-linejoin: round;
  transition: fill 0.15s, stroke 0.15s, transform 0.2s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.star.on svg {
  fill: var(--accent);
  stroke: var(--accent);
}
.star:active svg {
  transform: scale(0.85);
}
.scale {
  font-size: 13px;
  color: var(--hint);
}

/* --- рецепт --------------------------------------------------------------------- */

.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  padding-inline-end: 12px;
  color: var(--accent);
  font-weight: 600;
}
.back svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.recipe h1 {
  margin: 10px 0 14px;
  font: 600 25px/1.18 var(--display);
  text-wrap: balance;
}
.recipe .yourscore {
  margin-block-end: 14px;
}
.recipe-body {
  white-space: pre-line;
  font-size: 16px;
  line-height: 1.55;
}
.recipe-body b {
  font-weight: 650;
}

/* --- вкладки и тост ----------------------------------------------------------- */

.tabs {
  position: fixed;
  inset-inline: 0;
  inset-block-end: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tabs-h) + var(--safe-bottom));
  padding-block-end: var(--safe-bottom);
  background: color-mix(in oklch, var(--card) 92%, transparent);
  border-block-start: 1px solid var(--line);
  backdrop-filter: saturate(1.4) blur(14px);
}
.tab {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 3px;
  color: var(--hint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.tab svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.2s;
}
.tab[aria-current="page"] {
  color: var(--accent);
}
.tab[aria-current="page"] svg {
  transform: translateY(-1px);
}

.toast {
  position: fixed;
  inset-inline: var(--gutter);
  inset-block-end: calc(var(--tabs-h) + var(--safe-bottom) + 12px);
  z-index: 20;
  max-width: 420px;
  margin-inline: auto;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--fg);
  color: var(--card);
  font-weight: 600;
  text-align: center;
  transition: opacity 0.2s, translate 0.2s;
  @starting-style {
    opacity: 0;
    translate: 0 8px;
  }
}

/* Появление экрана — коротко и только если человек не против движения. */
@media (prefers-reduced-motion: no-preference) {
  #view.enter > * {
    animation: rise 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  @keyframes rise {
    from {
      opacity: 0;
      translate: 0 6px;
    }
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
@media (forced-colors: active) {
  .item[aria-checked="true"] .box,
  .star.on svg {
    background: Highlight;
    fill: Highlight;
  }
}
