/* history: стили части «история» второго захода (18.10.2026).
   Вкладка «история» (неделя, месяц, календарь, фото), окно дня, просмотр
   фото во весь экран, окно «поделиться» и экран выписки для врача.
   Все классы с префиксом h, чтобы не задевать стили других частей. */

/* ---------- переключатель вида ---------- */

.hseg {
  display: flex; gap: 3px; padding: 3px;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 999px;
}
.hseg__btn {
  flex: 1 1 0; min-width: 0; min-height: 44px; padding: 0 6px;
  border: 0; border-radius: 999px; background: none;
  font-size: 14px; color: var(--muted); white-space: nowrap;
}
.hseg__btn.is-active {
  background: var(--card); color: var(--accent-dark); font-weight: 600;
  box-shadow: var(--shadow-soft);
}
.hseg--two .hseg__btn { white-space: normal; line-height: 1.2; padding: 4px 8px; font-size: 14px; }

/* ---------- ‹ 12-18 октября › ---------- */

.hnav { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 0; }
.hnav__btn {
  flex: none; display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  font-size: 24px; line-height: 1; padding: 0 0 3px;
}
.hnav__btn:disabled { opacity: .35; cursor: default; }
.hnav__label { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: center; text-align: center; }
.hnav__main { font-family: var(--serif); font-size: 19px; line-height: 1.2; }
.hnav__sub { font-size: 12.5px; color: var(--muted); }
.hnav--bottom { margin-top: -2px; }

/* ---------- общие части карточек ---------- */

.hcard__head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.hcard__head .card__title { margin: 0; }
.hcard__aside { font-size: 13px; color: var(--muted); }
.hlink {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0;
  border: 0; background: none; color: var(--muted);
  font-size: 13px; text-decoration: underline; text-underline-offset: 3px;
}
.hempty .card__title { margin-bottom: 4px; }

/* ---------- разбор ---------- */

.hstory .card__title { margin-bottom: 8px; }
.hstory__line { margin: 0; font-size: 15px; line-height: 1.5; }
.hstory__line + .hstory__line { margin-top: 6px; }

/* ---------- питание: столбики ---------- */

.hbars { display: flex; gap: 2px; align-items: stretch; margin: 2px -4px 4px; }
.hbars__col {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 4px 0 4px; border: 0; border-radius: 10px; background: none; color: var(--text);
}
button.hbars__col:active { background: var(--card-2); }
button.hbars__col:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.hbars__val {
  height: 16px; line-height: 16px; font-size: 12px; color: var(--muted);
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.is-over .hbars__val { color: var(--sand-deep); }
.hbars__plot { position: relative; width: 100%; height: 124px; display: flex; justify-content: center; align-items: flex-end; }
.hbars__bar {
  display: block; width: 58%; max-width: 30px; min-height: 4px;
  border-radius: 7px 7px 3px 3px; background: var(--accent);
}
.is-over .hbars__bar { background: var(--sand); }
.hbars__bar--none {
  height: 26%; background: none;
  border: 1.5px dashed var(--line); border-bottom-width: 1.5px;
}
.hbars__lim {
  position: absolute; left: 14%; right: 14%; height: 0;
  border-top: 2px solid var(--text); opacity: .5; border-radius: 2px;
}
.hbars__label { font-size: 13px; line-height: 1.2; }
.hbars__sub { font-size: 12px; line-height: 1.2; color: var(--muted); white-space: nowrap; }
.hbars__col.is-today .hbars__label { font-weight: 700; color: var(--accent-dark); }
.hbars__col.is-future { opacity: .4; }

.hfood__legend { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.hfood__limit { margin: 10px 0 0; font-size: 15px; }
.hfood__limit b { font-weight: 700; }
.hfood__macros { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }

.hmacro {
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
  padding: 10px 12px; border-radius: 12px;
  background: var(--bg-soft); border: 1px solid var(--line);
}
.hmacro__label { font-size: 12.5px; color: var(--muted); }
.hmacro__value { font-size: 14px; color: var(--muted); white-space: nowrap; }
.hmacro__value b { font-family: var(--serif); font-size: 22px; font-weight: 400; color: var(--text); }
.hmacro__track { display: block; height: 6px; border-radius: 3px; background: var(--card-2); overflow: hidden; }
.hmacro__track i { display: block; height: 100%; border-radius: 3px; background: var(--sand); }
.hmacro.is-ok .hmacro__track i { background: var(--accent); }

/* ---------- тело ---------- */

.hbody__rows { display: flex; flex-direction: column; }
.hbody__row {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; min-height: 44px; padding: 10px 0;
  border: 0; border-top: 1px solid var(--card-2); background: none; font: inherit; color: inherit; text-align: left;
}
.hbody__chev { align-self: center; margin-left: auto; padding-left: 8px; font-size: 20px; line-height: 1; color: var(--muted); }
.hbody__row:first-child { border-top: 0; padding-top: 0; }
.hbody__icon {
  flex: none; display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-dark);
}
.hbody__icon svg { width: 20px; height: 20px; }
.hbody__main { display: flex; flex-direction: column; min-width: 0; }
.hbody__label { font-size: 12.5px; color: var(--muted); }
.hbody__value { font-family: var(--serif); font-size: 18px; line-height: 1.3; }
.hbody__sub { font-size: 12.5px; color: var(--muted); line-height: 1.35; }

/* ---------- витамины ---------- */

/* та же раскладка, что у витаминов дня (день: .dmic), чтобы неделя читалась так же */
.hvit__cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.hvit__head { margin: 0 0 2px; font-size: 12px; font-weight: 600; }
.hvit__col.is-low .hvit__head { color: var(--sand-deep); }
.hvit__col.is-ok .hvit__head { color: var(--accent-dark); }
.hvit__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.hvit__list { gap: 0; }
.hvit__item {
  display: flex; justify-content: space-between; align-items: center; gap: 6px; width: 100%;
  min-height: 44px; padding: 0; border: 0; border-bottom: 1px solid var(--card-2);
  background: none; color: var(--text); font-size: 14px; line-height: 1.3; text-align: left;
}
.hvit__item:active { background: var(--card-2); }
.hvit__pct { flex: none; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hvit__none { margin: 0; padding: 12px 0; font-size: 13px; color: var(--muted); }
.hvit__foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0 12px; margin: 8px 0 -10px; font-size: 12.5px; color: var(--muted);
}

/* ---------- из чего набрано ---------- */

.hqual .rings { margin-top: 4px; }
.hqual .rings__label { font-size: 13.5px; }
.hqual__hint { margin: 6px 0 0; font-size: 13px; color: var(--muted); }

/* ---------- фото недели лентой ---------- */

.hstrip {
  display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity; margin: 0 -16px; padding: 0 16px 4px;
  scrollbar-width: none;
}
.hstrip::-webkit-scrollbar { display: none; }
.hstrip__tile {
  flex: none; width: 76px; height: 76px; padding: 0;
  border: 0; border-radius: 14px; scroll-snap-align: start;
  background: var(--card-2) center / cover no-repeat;
}

/* ---------- коллаж месяца ---------- */

.hcol__out:empty { display: none; }
.hcol__img { display: block; width: 100%; height: auto; margin-top: 10px; border-radius: 12px; border: 1px solid var(--line); }
.hcol__btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.hcol__btns .btn { flex: 1 1 0; min-height: 46px; white-space: nowrap; }
.hcol__make { width: 100%; min-height: 46px; margin-top: 12px; }

/* ---------- календарь ---------- */

/* Поля 8 и промежуток 1: на 360 клетка дня 44 в ширину, а не 43 (06 №17).
   Заголовок по-прежнему в 16 px от края карточки. */
.hcal { padding: 14px 8px 12px; }
.hcal__title { margin: 0 8px 10px; }
.hcal__weekdays, .hcal__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; }
.hcal__weekdays { margin-bottom: 2px; }
.hcal__weekdays span { text-align: center; font-size: 12px; color: var(--muted); }
.hcal__cell {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 0; min-height: 62px; padding: 3px 0 5px;
  border: 1.5px solid transparent; border-radius: 12px; background: none; color: var(--text);
}
button.hcal__cell:active { background: var(--card-2); }
button.hcal__cell:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.hcal__cell.is-today { border-color: var(--accent); }
.hcal__cell.is-today .hcal__num { font-weight: 700; color: var(--accent-dark); }
.hcal__cell.is-future { opacity: .4; }
.hcal__num { font-size: 12.5px; line-height: 1.25; }
/* обводка: доля лимита того дня, песочная при переборе */
.hcal__ring {
  --p: 0;
  display: block; flex: none; width: 40px; height: 40px; padding: 3px; border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--p) * 360deg), var(--card-2) 0);
}
.hcal__cell:not(.has-food) .hcal__ring { background: none; }
.hcal__cell.is-over .hcal__ring, .hcal__ring--key.is-over { background: var(--sand); }
.hcal__pic {
  display: grid; width: 100%; height: 100%; overflow: hidden;
  border-radius: 50%; border: 2px solid var(--card); background: var(--accent-soft);
}
.hcal__cell:not(.has-food) .hcal__pic { background: var(--bg); border: 1.5px dashed var(--line); }
.hcal__cell.is-future .hcal__pic { border-style: solid; border-color: transparent; }
.hcal__pic--2 { grid-template-columns: 1fr 1fr; }
.hcal__pic--3 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.hcal__pic--3 .hcal__ph:first-child { grid-row: span 2; }
.hcal__pic--4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.hcal__ph { display: block; min-width: 0; min-height: 0; background: var(--card-2) center / cover no-repeat; }
.hcal__ph.is-nophoto { background: var(--accent-soft); }

.hcal__legend {
  list-style: none; margin: 10px 6px 0; padding: 10px 0 0; border-top: 1px solid var(--card-2);
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px;
  font-size: 12.5px; color: var(--muted); line-height: 1.3;
}
.hcal__legend li { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hcal__ring--key { width: 22px; height: 22px; padding: 2.5px; }
.hcal__ring--key .hcal__pic { border-width: 1.5px; }
.hcal__key--photo {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  background: conic-gradient(#e2b26c 0 25%, #8cc56e 0 50%, #d9806a 0 75%, #efe0c0 0);
}
.hcal__key--today { flex: none; width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--accent); }

/* ---------- галерея ---------- */

.hgal { display: flex; flex-direction: column; gap: 8px; }
.hgal__title {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  margin: 6px 2px 0; font-family: var(--serif); font-size: 19px; font-weight: 400;
}
.hgal__count { font-family: var(--font); font-size: 13px; color: var(--muted); }
.hgal__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.hgal__tile {
  position: relative; aspect-ratio: 1; padding: 0; overflow: hidden;
  border: 0; border-radius: 12px; background: var(--card-2) center / cover no-repeat;
}
.hgal__tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hgal__day {
  position: absolute; left: 6px; bottom: 6px; padding: 1px 8px;
  border-radius: 999px; background: rgba(255, 253, 247, .92);
  font-size: 12px; line-height: 1.5; color: var(--text);
}
.hgal__tile.is-nophoto, .hstrip__tile.is-nophoto, .hday__thumb.is-nophoto {
  background-image: repeating-linear-gradient(-45deg, var(--card-2) 0 5px, transparent 5px 10px);
}

/* ---------- окно дня ---------- */

/* окно дня не выше 70% экрана: календарь за ним виден (макет A12) */
.sheet--day { max-height: 70vh; max-height: 70dvh; }
.hday__sum { padding: 2px 0 12px; border-bottom: 1px solid var(--card-2); }
.hday__kcal { margin: 0; font-size: 15px; color: var(--muted); }
.hday__kcal b { font-family: var(--serif); font-size: 32px; font-weight: 400; color: var(--text); }
.hday__kcal.is-over b { color: var(--sand-deep); }
.hday__sum > .hday__kcal:not(:has(b)).is-over { color: var(--sand-deep); }
.hday__macros { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-top: 6px; font-size: 14px; color: var(--muted); }
.hday__macro b { font-size: 16px; font-weight: 600; color: var(--text); }
.hday__mlabel { margin-right: 5px; }
.hday__empty { margin: 2px 0 6px; font-size: 15px; color: var(--muted); }
.hday__meal { padding: 10px 0 4px; border-bottom: 1px solid var(--card-2); }
.hday__mhead { display: flex; justify-content: space-between; gap: 8px; margin: 0 0 2px; font-size: 13px; color: var(--muted); }
.hday__dish {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 58px;
  padding: 5px 0; border: 0; border-radius: 10px; background: none; text-align: left; color: var(--text);
}
.hday__dish:active { background: var(--card-2); }
.hday__thumb { flex: none; width: 48px; height: 48px; border-radius: 50%; background: var(--card-2) center / cover no-repeat; }
.hday__dmain { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.hday__dname { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hday__dmeta { font-size: 12.5px; color: var(--muted); }
.hday__dkcal { flex: none; font-family: var(--serif); font-size: 17px; white-space: nowrap; }
.hday__vitals { display: flex; flex-direction: column; margin-top: 6px; }
.hday__vrow {
  display: grid; grid-template-columns: 24px auto minmax(0, 1fr); align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--card-2); font-size: 14px;
}
.hday__vrow:last-child { border-bottom: 0; }
.hday__vicon { display: grid; place-items: center; color: var(--muted); }
.hday__vicon svg { width: 20px; height: 20px; }
.hday__vlabel { font-size: 13px; color: var(--muted); }
.hday__vvalue { text-align: right; line-height: 1.35; min-width: 0; }
.hday__vline { display: block; }

/* ---------- просмотр фото во весь экран ---------- */

.pview {
  position: fixed; inset: 0; z-index: 45;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  background: #1f1c18; color: #fff;
  opacity: 0; transition: opacity .18s ease;
}
.pview.is-open { opacity: 1; }
.pview__top { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 6px 6px 6px 16px; }
.pview__count { font-size: 14px; color: rgba(255, 255, 255, .78); }
.pview__close {
  display: grid; place-items: center; width: 44px; height: 44px;
  border: 0; border-radius: 50%; background: none; color: #fff;
}
.pview__stage {
  position: relative; flex: 1 1 auto; min-height: 0;
  display: flex; align-items: center; justify-content: center; touch-action: pan-y;
}
/* снимок вписан в экран целиком: маленькая миниатюра тоже растягивается, а не висит маркой */
.pview__img { display: block; width: 100%; height: 100%; object-fit: contain; }
.pview__img:not([src]) { visibility: hidden; }
.pview__nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 44px; height: 44px;
  border: 0; border-radius: 50%; background: rgba(0, 0, 0, .38); color: #fff;
}
.pview__nav--prev { left: 8px; }
.pview__nav--next { right: 8px; }
.pview__nav:disabled { opacity: 0; pointer-events: none; }
.pview__bottom { flex: none; padding: 12px 16px 16px; }
.pview__cap { margin: 0; font-size: 13px; color: rgba(255, 255, 255, .78); }
.pview__name { margin: 2px 0 12px; font-family: var(--serif); font-size: 19px; line-height: 1.3; }
.pview__actions { display: flex; gap: 10px; }
.pview__btn {
  flex: 1 1 0; min-height: 48px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .4); background: transparent; color: #fff; font-size: 15px;
}
.pview__btn--main { background: var(--accent); border-color: var(--accent); font-weight: 600; }

/* ---------- поделиться ---------- */

.hshare__block { padding: 0 0 14px; border-bottom: 1px solid var(--card-2); }
.hshare__title { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.hshare__text { margin: 0 0 10px; font-size: 14px; color: var(--muted); line-height: 1.45; }
.hshare__btns { display: flex; gap: 8px; margin-top: 12px; }
.hshare__btns .btn { flex: 1 1 0; min-height: 46px; border-radius: 999px; }
.hshare__btns .btn--primary { flex-grow: 2; }
.hshare__status { margin: 8px 0 0; font-size: 13px; color: var(--accent-dark); }
.hshare__status:empty { display: none; }
.hcheck { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-top: 6px; font-size: 14px; }
.hcheck input { flex: none; width: 20px; height: 20px; accent-color: var(--accent); }
.hshare__row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 66px;
  padding: 10px 0; border: 0; border-bottom: 1px solid var(--card-2);
  background: none; text-align: left; color: var(--text);
}
.hshare__row:active { background: var(--card-2); }
.hshare__icon {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-dark);
}
.hshare__main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.hshare__name { font-size: 15px; font-weight: 600; }
.hshare__sub { font-size: 13px; color: var(--muted); line-height: 1.35; }
.hshare__chev { flex: none; display: grid; color: var(--muted); }
.hshare__privacy { margin: 12px 0 0; font-size: 12.5px; color: var(--muted); }

/* ---------- выписка для врача ---------- */

.hdoc__card .card__title { margin-bottom: 10px; }
.hdoc__dates { margin: 8px 2px 0; font-size: 13px; color: var(--muted); }
.hswitches { display: flex; flex-direction: column; }
.hswitch {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 50px; border-top: 1px solid var(--card-2); font-size: 15px; cursor: pointer;
}
.hswitch:first-child { border-top: 0; }
.hswitch__box {
  appearance: none; -webkit-appearance: none; flex: none; position: relative;
  width: 48px; height: 28px; margin: 0; border-radius: 999px;
  background: var(--line); transition: background .15s; cursor: pointer;
}
.hswitch__box::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .15s;
}
.hswitch__box:checked { background: var(--accent); }
.hswitch__box:checked::after { transform: translateX(20px); }
.hswitch__box:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hdoc__lock:empty { display: none; }
.hdoc__lock { padding: 10px 0 0; border-top: 1px solid var(--card-2); }
.hdoc__locktext { margin: 0 0 8px; font-size: 14px; color: var(--muted); }
.hdoc__pinrow { display: flex; gap: 8px; }
.hdoc__pin { flex: 1 1 auto; min-height: 46px; }
.hdoc__pinmsg { margin: 6px 0 0; font-size: 13px; color: var(--sand-deep); }
.hdoc__pinmsg:empty { display: none; }
.hdoc__preview {
  position: relative; height: 430px; overflow: hidden;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.hdoc__preview::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 56px;
  background: linear-gradient(rgba(255, 255, 255, 0), #fff); pointer-events: none;
}
.hdoc__frame {
  position: absolute; top: 0; left: 0; width: 640px; height: 860px;
  border: 0; background: #fff; transform-origin: 0 0; pointer-events: none;
}
.hdoc__status { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.hdoc__status:empty { display: none; }
.hdoc__print { margin-top: 2px; }
.hdoc__note { margin: 0 4px; font-size: 12.5px; color: var(--muted); }
.hdoc__foot {
  /* Липкий низ садится на край отступа ленты (у .layer__body снизу 32 px),
     поэтому опускаем его на этот отступ и закрываем фоном: иначе под кнопками
     просвечивала полоса листа. */
  position: sticky; bottom: -32px; z-index: 1;
  display: flex; gap: 8px; padding: 14px 0 42px; margin-bottom: -32px;
  background: linear-gradient(rgba(247, 244, 236, 0), var(--bg) 22%);
}
.hdoc__foot .btn { flex: 1 1 0; min-height: 48px; border-radius: 999px; }
