:root {
  color-scheme: light;
  --bg: #edeaf7;
  --surface: #ffffff;
  --surface-2: #f5f3fb;
  --surface-3: #ebe7f7;
  --border: rgba(84, 66, 165, 0.1);
  --border-strong: rgba(84, 66, 165, 0.18);
  --text: #2c2745;
  --muted: #837e9d;
  --faint: #a9a5c0;
  --lime: #7263e3;
  --lime-dark: #e9e5fb;
  --protein: #e2559b;
  --fat: #f29f45;
  --carb: #3cb572;
  --red: #e2574f;
  --yellow: #e0a63a;
  --green: #3cb572;
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 14px;
  --shadow: 0 22px 60px rgba(96, 80, 200, 0.16);
  --shell: 1240px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    linear-gradient(rgba(84, 66, 165, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(84, 66, 165, 0.025) 1px, transparent 1px),
    var(--bg);
  background-size: 36px 36px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

button,
a,
label {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

:focus-visible {
  outline: 3px solid var(--lime);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.page-glow {
  position: fixed;
  top: -380px;
  left: 50%;
  z-index: -1;
  width: 900px;
  height: 620px;
  border-radius: 50%;
  background: rgba(114, 99, 227, 0.16);
  filter: blur(120px);
  transform: translateX(-50%);
  pointer-events: none;
}

.shell {
  width: min(calc(100% - 40px), var(--shell));
  margin-inline: auto;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--border);
  background: rgba(245, 243, 252, 0.86);
  backdrop-filter: blur(18px);
}

.header-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 76px;
}

.app-brand {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 10px;
  font-size: 19px;
  font-weight: 750;
  letter-spacing: -0.5px;
}

.app-logo {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  background: var(--lime);
  color: #ffffff;
}

.app-logo svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.desktop-nav {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px;
  border-radius: 13px;
  background: var(--surface);
}

.nav-tab {
  min-height: 42px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease;
}

.nav-tab:hover {
  color: var(--text);
  background: rgba(84, 66, 165, 0.07);
}

.nav-tab.is-active {
  background: var(--surface-3);
  color: var(--text);
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

.icon-button,
.avatar-button {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.icon-button:hover,
.avatar-button:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.avatar-button {
  border: 0;
  border-radius: 50%;
  background: var(--lime);
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
}

.app-main {
  padding-block: 58px 120px;
}

.app-view {
  animation: view-in 220ms ease both;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-heading,
.card-heading,
.dialog-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 22px;
}

.view-heading {
  margin-bottom: 30px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--lime);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(34px, 4vw, 52px);
  line-height: 1;
  letter-spacing: -0.055em;
}

h2 {
  margin-bottom: 0;
  font-size: 23px;
  line-height: 1.15;
  letter-spacing: -0.035em;
}

h3 {
  letter-spacing: -0.025em;
}

.date-switcher,
.month-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-switcher input,
.month-switcher strong {
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

.month-switcher strong {
  display: inline-flex;
  min-width: 145px;
  align-items: center;
  justify-content: center;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0.6;
}

.surface-card {
  border: 1px solid var(--border);
  background: #ffffff;
  box-shadow: 0 12px 38px rgba(96, 80, 200, 0.1);
}

.summary-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) repeat(3, minmax(150px, 0.8fr));
  gap: 14px;
}

.calorie-card {
  display: grid;
  grid-template-columns: 148px 1fr;
  align-items: center;
  min-height: 220px;
  padding: 28px;
  gap: 26px;
  border-radius: var(--radius-xl);
}

.calorie-ring {
  display: grid;
  width: 142px;
  height: 142px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--lime) var(--progress), var(--surface-3) 0);
}

.calorie-ring::before {
  grid-area: 1 / 1;
  width: 114px;
  height: 114px;
  border-radius: 50%;
  background: var(--surface);
  content: "";
}

.calorie-ring > div {
  z-index: 1;
  display: grid;
  grid-area: 1 / 1;
  justify-items: center;
}

.calorie-ring strong {
  font-size: 29px;
  letter-spacing: -0.06em;
}

.calorie-ring span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.status-chip {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--lime-dark);
  color: var(--lime);
  font-size: 10px;
  font-weight: 700;
}

.calorie-copy h2 {
  margin-top: 13px;
}

.calorie-copy > p {
  max-width: 330px;
  margin: 9px 0 22px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.goal-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
  color: var(--faint);
  font-size: 10px;
}

.goal-line strong {
  color: var(--text);
  font-size: 11px;
}

.macro-card {
  display: flex;
  min-height: 220px;
  padding: 22px;
  flex-direction: column;
  border-radius: var(--radius-xl);
}

.macro-icon {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  margin-bottom: 22px;
  border-radius: 11px;
  background: var(--surface-3);
  font-size: 12px;
  font-weight: 800;
}

.protein-card .macro-icon { color: var(--protein); }
.fat-card .macro-icon { color: var(--fat); }
.carb-card .macro-icon { color: var(--carb); }

.macro-card > span:nth-child(2) {
  color: var(--muted);
  font-size: 11px;
}

.macro-card strong {
  margin: 5px 0 17px;
  font-size: 20px;
  letter-spacing: -0.04em;
}

.macro-card strong b {
  font-size: 28px;
}

.mini-progress {
  height: 5px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--surface-3);
}

.mini-progress i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: currentColor;
  transition: width 380ms ease;
}

.protein-card .mini-progress { color: var(--protein); }
.fat-card .mini-progress { color: var(--fat); }
.carb-card .mini-progress { color: var(--carb); }

.macro-card small {
  margin-top: 9px;
  color: var(--faint);
  font-size: 9px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.75fr);
  align-items: start;
  gap: 16px;
  margin-top: 16px;
}

.food-section,
.compact-card,
.chart-card,
.log-card,
.calendar-card,
.injection-calendar-card,
.settings-card {
  border-radius: var(--radius-xl);
}

.food-section {
  min-height: 420px;
  padding: 26px;
}

.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  border: 0;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 720;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

.primary-button {
  background: var(--lime);
  color: #ffffff;
}

.primary-button:hover,
.secondary-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
}

.secondary-button {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.danger-button {
  background: rgba(226, 87, 79, 0.12);
  color: #d84a44;
}

.food-list {
  display: grid;
  gap: 1px;
  margin-top: 22px;
  overflow: hidden;
  border-radius: 18px;
  background: var(--border);
}

.food-item {
  position: relative;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 92px;
  padding: 15px 16px;
  gap: 14px;
  background: var(--surface-2);
}

.food-symbol {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 14px;
  background: var(--surface-3);
  font-size: 21px;
}

.food-main {
  min-width: 0;
}

.food-main h3 {
  margin: 0 0 7px;
  overflow: hidden;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.food-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 13px;
  color: var(--faint);
  font-size: 9px;
}

.confidence-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.confidence-dot::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  content: "";
}

.confidence-dot.close::before { background: var(--yellow); }
.confidence-dot.estimate::before { background: var(--red); }

.food-values {
  display: grid;
  min-width: 90px;
  justify-items: end;
  gap: 7px;
}

.food-values strong {
  font-size: 14px;
}

.food-values span {
  color: var(--muted);
  font-size: 9px;
}

.row-menu {
  display: flex;
  align-items: center;
  gap: 3px;
}

.row-action {
  display: grid;
  width: 32px;
  height: 32px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
}

.row-action:hover {
  background: var(--surface-3);
  color: var(--text);
}

.row-action.delete:hover {
  color: var(--red);
}

.empty-state {
  display: grid;
  min-height: 280px;
  place-content: center;
  justify-items: start;
}

.empty-state > span {
  margin-bottom: 14px;
  font-size: 32px;
}

.empty-state h3 {
  margin-bottom: 6px;
  font-size: 17px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.right-column {
  display: grid;
  gap: 16px;
}

.compact-card {
  padding: 23px;
}

.small-heading h2 {
  font-size: 18px;
}

.source-score {
  display: grid;
  min-width: 42px;
  min-height: 32px;
  place-items: center;
  border-radius: 10px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.source-list {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.source-row {
  display: grid;
  grid-template-columns: 9px 1fr auto;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 10px;
}

.source-row i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}

.source-row.close i { background: var(--yellow); }
.source-row.estimate i { background: var(--red); }

.source-row strong {
  color: var(--text);
  font-size: 11px;
}

.fine-print {
  margin: 18px 0 0;
  color: var(--faint);
  font-size: 9px;
}

.quick-health-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 18px;
}

.quick-health-button {
  display: grid;
  min-height: 88px;
  padding: 13px;
  align-content: space-between;
  justify-items: start;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface-2);
  cursor: pointer;
  text-align: left;
}

.quick-health-button span {
  color: var(--muted);
  font-size: 9px;
}

.quick-health-button strong {
  font-size: 11px;
}

.heading-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

#photo-status {
  margin-top: 12px;
  font-size: 10px;
  color: var(--muted);
}

.secondary-button:disabled {
  opacity: 0.6;
  cursor: default;
}

@media (max-width: 460px) {
  .heading-buttons {
    width: 100%;
  }

  .heading-buttons .primary-button,
  .heading-buttons .secondary-button {
    flex: 1;
  }
}

.deficit-block {
  margin-top: 14px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface-2);
}

.deficit-headline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.deficit-headline span {
  color: var(--muted);
  font-size: 9px;
}

.deficit-headline strong {
  font-size: 14px;
  color: var(--lime);
}

.deficit-block.surplus .deficit-headline strong {
  color: var(--red);
}

.deficit-meter {
  margin-top: 10px;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.deficit-meter i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--lime);
  transition: width 0.35s ease;
}

.deficit-block.surplus .deficit-meter i {
  background: var(--red);
}

.deficit-rows {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 9px;
  font-size: 10px;
  color: var(--text);
}

.deficit-block .fine-print {
  margin-top: 10px;
}

.calendar-card,
.chart-card,
.log-card,
.injection-calendar-card {
  padding: 26px;
}

/* Журнал препарата: расчётный уровень и настройки модели */
.med-stat > strong {
  color: var(--carb);
}

.med-model-card {
  margin-top: 20px;
  padding: 26px;
  border-radius: var(--radius-xl);
}

.med-model-card .form-grid {
  margin-top: 20px;
}

.med-toggle {
  display: flex;
  align-items: center;
  margin-top: 15px;
  padding: 13px 15px;
  gap: 11px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
}

.med-toggle input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  flex-shrink: 0;
  padding: 0;
  accent-color: var(--carb);
  cursor: pointer;
}

.med-model-card .fine-print {
  margin-top: 14px;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 7px;
}

.calendar-weekdays {
  margin-bottom: 8px;
}

.calendar-weekdays span {
  padding: 7px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 650;
}

.calendar-day {
  position: relative;
  min-height: 105px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-2);
  cursor: pointer;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease;
}

.calendar-day:hover {
  border-color: var(--border-strong);
  background: var(--surface-3);
}

.calendar-day.is-other-month {
  opacity: 0.25;
}

.calendar-day.is-today {
  border-color: rgba(114, 99, 227, 0.45);
}

.calendar-day > strong {
  display: block;
  margin-bottom: 13px;
  font-size: 12px;
}

.day-kcal,
.day-weight,
.day-dose {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  font-size: 9px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.day-kcal { color: var(--lime); }
.day-weight { color: var(--protein); }
.day-dose { color: var(--carb); }

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 17px;
  margin-top: 18px;
  color: var(--faint);
  font-size: 9px;
}

.calendar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.calendar-legend i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.legend-food { background: var(--lime); }
.legend-weight { background: var(--protein); }
.legend-injection { background: var(--carb); }

.chart-card,
.log-card {
  margin-top: 16px;
}

.chart-card canvas {
  display: block;
  width: 100%;
  margin-top: 27px;
}

.empty-chart {
  margin-top: -154px;
  margin-bottom: 126px;
  color: var(--faint);
  font-size: 12px;
}

.forecast-card {
  overflow: hidden;
}

.forecast-heading {
  align-items: center;
}

.forecast-basis {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  padding: 0 10px;
  border-radius: 10px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.forecast-controls {
  margin-top: 23px;
  padding: 18px 0 17px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.forecast-control-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.forecast-control-heading label {
  font-size: 12px;
  font-weight: 650;
}

.forecast-control-heading output {
  color: var(--lime);
  font-size: 11px;
  font-weight: 700;
}

.forecast-range {
  width: 100%;
  height: 18px;
  margin: 0;
  accent-color: var(--lime);
  cursor: pointer;
}

.forecast-range:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.forecast-range::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background:
    linear-gradient(
      90deg,
      var(--yellow),
      var(--lime) 50%,
      var(--green)
    );
}

.forecast-range::-webkit-slider-thumb {
  width: 20px;
  height: 20px;
  margin-top: -7px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 0 0 1px var(--border-strong);
  -webkit-appearance: none;
}

.forecast-range-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  color: var(--faint);
  font-size: 9px;
}

.forecast-rate {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.forecast-rate strong {
  margin-left: 5px;
  color: var(--text);
  font-size: 11px;
}

.forecast-empty {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 108px;
  margin-top: 22px;
  padding: 17px;
  gap: 14px;
  border: 1px dashed var(--border-strong);
  border-radius: 17px;
  background: rgba(84, 66, 165, 0.03);
}

.forecast-empty > span {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  background: var(--surface-3);
  font-size: 19px;
}

.forecast-empty strong {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
}

.forecast-empty p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
}

.forecast-results {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 22px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.forecast-result {
  min-width: 0;
  padding: 19px 17px;
}

.forecast-result + .forecast-result {
  border-left: 1px solid var(--border);
}

.forecast-result > span {
  color: var(--muted);
  font-size: 10px;
}

.forecast-result strong {
  display: block;
  margin: 9px 0 6px;
  font-size: 25px;
  letter-spacing: -0.045em;
}

.forecast-result small {
  display: block;
  overflow: hidden;
  color: var(--faint);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.forecast-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 9px 18px;
  margin-top: 18px;
  color: var(--faint);
  font-size: 9px;
}

.forecast-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.forecast-legend i {
  width: 17px;
  height: 3px;
  border-radius: 99px;
}

.legend-actual { background: var(--protein); }
.legend-band { background: rgba(114, 99, 227, 0.3); }
.legend-selected { background: var(--lime); }
.legend-target {
  height: 0 !important;
  border-top: 2px dashed var(--yellow);
}
.legend-shot {
  width: 9px !important;
  height: 9px !important;
  border: 2px solid var(--carb);
  border-radius: 50% !important;
  background: var(--surface);
}
.legend-level {
  height: 9px !important;
  border-bottom: 2px solid rgba(60, 181, 114, 0.62);
  border-radius: 3px !important;
  background: linear-gradient(rgba(60, 181, 114, 0.05), rgba(60, 181, 114, 0.32));
}
.legend-calories {
  height: 9px !important;
  border-bottom: 2px solid rgba(217, 142, 43, 0.65);
  border-radius: 3px !important;
  background: linear-gradient(rgba(217, 142, 43, 0.04), rgba(217, 142, 43, 0.26));
}

/* Масштаб графика веса */
.chart-zoom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 21px;
}

.chart-zoom-presets,
.chart-zoom-steps {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border-radius: 12px;
  background: var(--surface-2);
}

.chart-zoom-chip,
.chart-zoom-step {
  min-height: 28px;
  padding: 0 11px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.chart-zoom-step {
  width: 30px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
}

.chart-zoom-chip:hover,
.chart-zoom-step:hover {
  color: var(--text);
  background: var(--surface-3);
}

.chart-zoom-chip.is-active {
  color: var(--surface);
  background: var(--lime);
}

.chart-zoom-chip:disabled,
.chart-zoom-step:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.chart-viewport {
  position: relative;
  touch-action: pan-y;
}

.chart-viewport canvas {
  margin-top: 12px;
  cursor: crosshair;
}

.chart-viewport.is-panning canvas {
  cursor: grabbing;
}

.chart-tooltip {
  position: absolute;
  z-index: 3;
  max-width: 220px;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 12px 28px rgba(96, 80, 200, 0.18);
  font-size: 10px;
  line-height: 1.45;
  pointer-events: none;
  transform: translate(-50%, -100%);
}

.chart-tooltip[hidden] {
  display: none;
}

.chart-tooltip strong {
  display: block;
  margin-bottom: 3px;
  font-size: 12px;
  letter-spacing: -0.02em;
}

.chart-tooltip .tip-date {
  display: block;
  color: var(--muted);
  font-size: 9px;
}

.chart-tooltip .tip-row {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.chart-tooltip .tip-up { color: var(--red); }
.chart-tooltip .tip-down { color: var(--green); }

.chart-hint {
  margin: 10px 0 0;
  color: var(--faint);
  font-size: 9px;
}

.forecast-target-copy {
  margin: 19px 0 0;
  color: var(--text);
  font-size: 11px;
  font-weight: 650;
}

.forecast-method {
  margin: 8px 0 0;
  color: var(--faint);
  font-size: 9px;
  line-height: 1.55;
}

.health-stat-grid {
  display: grid;
  /* auto-fit: три карточки на вкладке веса и четыре в журнале препарата
     раскладываются одинаково ровно, без отдельного правила на каждую вкладку */
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.health-stat {
  min-height: 160px;
  padding: 24px;
  border-radius: var(--radius-xl);
}

.health-stat > span {
  color: var(--muted);
  font-size: 11px;
}

.health-stat > strong {
  display: block;
  margin: 26px 0 9px;
  font-size: 30px;
  letter-spacing: -0.055em;
}

.health-stat small {
  color: var(--faint);
  font-size: 10px;
}

.data-list {
  display: grid;
  gap: 1px;
  margin-top: 21px;
  overflow: hidden;
  border-radius: 15px;
  background: var(--border);
}

.data-row {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) repeat(2, minmax(90px, auto)) auto;
  align-items: center;
  min-height: 62px;
  padding: 12px 15px;
  gap: 15px;
  background: var(--surface-2);
}

.data-row > span {
  color: var(--muted);
  font-size: 10px;
}

.data-row strong {
  font-size: 12px;
}

.medical-note {
  display: flex;
  align-items: flex-start;
  margin-bottom: 16px;
  padding: 16px 18px;
  gap: 12px;
  border: 1px solid rgba(224, 166, 58, 0.3);
  border-radius: 16px;
  background: rgba(224, 166, 58, 0.1);
  color: #8a6a22;
}

.bmi-note {
  margin-top: 16px;
  margin-bottom: 0;
}

.medical-note span {
  font-size: 16px;
}

.medical-note p {
  margin: 0;
  font-size: 10px;
  line-height: 1.55;
}

.injection-calendar-card {
  margin-top: 16px;
}

.dose-timeline {
  display: grid;
  gap: 10px;
  margin-top: 23px;
}

.dose-entry {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 74px;
  padding: 13px;
  gap: 13px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-2);
}

.dose-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 14px;
  background: rgba(114, 99, 227, 0.12);
  color: var(--carb);
}

.dose-entry h3 {
  margin: 0 0 6px;
  font-size: 13px;
}

.dose-entry p {
  margin: 0;
  color: var(--muted);
  font-size: 9px;
}

.small-empty {
  min-height: 230px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  align-items: start;
  gap: 16px;
}

.settings-card {
  padding: 26px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
  margin-top: 24px;
}

.form-grid label {
  display: grid;
  gap: 8px;
}

.form-grid label > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: 0;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  transition: border-color 160ms ease, background 160ms ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--faint);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(114, 99, 227, 0.55);
  background: var(--surface-3);
}

.input-with-unit {
  position: relative;
}

.input-with-unit input {
  padding-right: 45px;
}

.input-with-unit i {
  position: absolute;
  top: 50%;
  right: 13px;
  color: var(--faint);
  font-size: 10px;
  font-style: normal;
  transform: translateY(-50%);
  pointer-events: none;
}

.full-button {
  width: 100%;
  margin-top: 22px;
}

.form-message {
  min-height: 18px;
  margin: 11px 0 0;
  color: var(--green);
  font-size: 10px;
}

.settings-copy {
  margin: 24px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.data-actions {
  display: grid;
  gap: 9px;
}

.import-button {
  cursor: pointer;
}

.import-button input {
  display: none;
}

.mobile-nav {
  display: none;
}

.app-dialog,
.confirm-dialog {
  width: min(calc(100% - 32px), 720px);
  max-height: min(88vh, 850px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: 26px;
  color: var(--text);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.app-dialog::backdrop,
.confirm-dialog::backdrop {
  background: rgba(44, 32, 90, 0.4);
  backdrop-filter: blur(7px);
}

.app-dialog form {
  padding: 27px;
}

.dialog-heading {
  align-items: flex-start;
}

.dialog-heading .icon-button {
  font-size: 24px;
  line-height: 1;
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 24px;
}

.food-form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.span-two {
  grid-column: span 2;
}

.small-dialog {
  max-width: 560px;
}

.confirm-dialog {
  max-width: 390px;
  text-align: left;
}

.confirm-dialog form {
  padding: 28px;
}

.confirm-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  margin-bottom: 20px;
  border-radius: 14px;
  background: rgba(226, 87, 79, 0.1);
}

.confirm-dialog h2 {
  margin-bottom: 10px;
}

.confirm-dialog p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 1050px) {
  .summary-grid {
    grid-template-columns: minmax(0, 2fr) repeat(3, minmax(120px, 0.7fr));
  }

  .calorie-card {
    grid-template-columns: 118px 1fr;
    padding: 22px;
    gap: 18px;
  }

  .calorie-ring {
    width: 116px;
    height: 116px;
  }

  .calorie-ring::before {
    width: 92px;
    height: 92px;
  }

  .calorie-ring strong {
    font-size: 24px;
  }

  .macro-card {
    padding: 18px;
  }

  .content-grid {
    grid-template-columns: minmax(0, 1fr) 300px;
  }
}

@media (max-width: 900px) {
  .desktop-nav {
    display: none;
  }

  .header-inner {
    grid-template-columns: 1fr auto;
  }

  .summary-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .calorie-card {
    grid-column: 1 / -1;
  }

  .macro-card {
    min-height: 190px;
  }

  .content-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .shell {
    width: min(calc(100% - 28px), var(--shell));
  }

  body {
    padding-bottom: calc(78px + env(safe-area-inset-bottom));
  }

  .app-header {
    position: relative;
  }

  .header-inner {
    min-height: 66px;
  }

  .header-actions .icon-button {
    display: none;
  }

  .app-main {
    padding-block: 36px 62px;
  }

  .view-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .date-switcher,
  .month-switcher {
    width: 100%;
  }

  .date-switcher input,
  .month-switcher strong {
    flex: 1;
  }

  h1 {
    font-size: 39px;
  }

  .calorie-card {
    grid-template-columns: 102px 1fr;
    min-height: 190px;
    padding: 18px;
  }

  .calorie-ring {
    width: 100px;
    height: 100px;
  }

  .calorie-ring::before {
    width: 78px;
    height: 78px;
  }

  .calorie-ring strong {
    font-size: 20px;
  }

  .calorie-copy > p {
    margin-bottom: 15px;
  }

  .goal-line {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .macro-card {
    min-height: 172px;
    padding: 15px;
  }

  .macro-icon {
    margin-bottom: 15px;
  }

  .macro-card strong b {
    font-size: 23px;
  }

  .food-section,
  .compact-card,
  .calendar-card,
  .chart-card,
  .log-card,
  .injection-calendar-card,
  .settings-card {
    padding: 19px;
  }

  .food-item {
    grid-template-columns: 42px minmax(0, 1fr) auto;
    padding-inline: 11px;
    gap: 10px;
  }

  .food-symbol {
    width: 42px;
    height: 42px;
  }

  .food-values {
    min-width: 72px;
  }

  .food-values span {
    display: none;
  }

  .calendar-day {
    min-height: 78px;
    padding: 7px;
  }

  .calendar-day > strong {
    margin-bottom: 7px;
  }

  .day-kcal,
  .day-weight,
  .day-dose {
    font-size: 8px;
  }

  .health-stat-grid {
    grid-template-columns: 1fr;
  }

  .health-stat {
    min-height: 130px;
  }

  .health-stat > strong {
    margin-top: 20px;
  }

  .forecast-empty {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .forecast-empty .secondary-button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .forecast-result {
    padding-inline: 10px;
  }

  .forecast-result strong {
    font-size: 21px;
  }

  .data-row {
    grid-template-columns: 1fr auto;
  }

  .data-row > span:nth-child(2),
  .data-row > span:nth-child(3) {
    display: none;
  }

  .mobile-nav {
    position: fixed;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    left: 10px;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 7px;
    border: 1px solid var(--border-strong);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 18px 60px rgba(96, 80, 200, 0.22);
    backdrop-filter: blur(18px);
  }

  .mobile-nav button {
    display: grid;
    min-height: 51px;
    padding: 4px;
    place-items: center;
    gap: 3px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: var(--faint);
    font-size: 8px;
    font-weight: 650;
    cursor: pointer;
  }

  .mobile-nav button span {
    font-size: 17px;
    filter: grayscale(1);
    opacity: 0.68;
  }

  .mobile-nav button.is-active {
    background: var(--surface-3);
    color: var(--text);
  }

  .mobile-nav button.is-active span {
    filter: none;
    opacity: 1;
  }

  .app-dialog form {
    padding: 20px;
  }

  .form-grid,
  .food-form-grid {
    grid-template-columns: 1fr;
  }

  .span-two {
    grid-column: auto;
  }
}

@media (max-width: 460px) {
  .summary-grid {
    gap: 8px;
  }

  .calorie-card {
    grid-template-columns: 88px 1fr;
    padding: 15px;
    gap: 14px;
    border-radius: 23px;
  }

  .calorie-ring {
    width: 86px;
    height: 86px;
  }

  .calorie-ring::before {
    width: 68px;
    height: 68px;
  }

  .calorie-ring strong {
    font-size: 18px;
  }

  .calorie-copy h2 {
    font-size: 18px;
  }

  .calorie-copy > p {
    display: none;
  }

  .macro-card {
    min-width: 0;
    min-height: 155px;
    padding: 12px;
    border-radius: 20px;
  }

  .macro-icon {
    width: 31px;
    height: 31px;
  }

  .macro-card strong {
    font-size: 14px;
  }

  .macro-card strong b {
    font-size: 20px;
  }

  .food-section .card-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .food-section .primary-button {
    width: 100%;
  }

  .food-item {
    grid-template-columns: 38px minmax(0, 1fr) 62px;
    min-height: 86px;
  }

  .food-symbol {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    font-size: 18px;
  }

  .food-main h3 {
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .row-menu {
    display: none;
  }

  .calendar-weekdays,
  .calendar-grid {
    gap: 3px;
  }

  .calendar-day {
    min-height: 69px;
    border-radius: 9px;
  }

  .day-weight,
  .day-dose {
    font-size: 0;
  }

  .day-weight::before {
    color: var(--protein);
    font-size: 8px;
    content: "●";
  }

  .day-dose::before {
    color: var(--carb);
    font-size: 8px;
    content: "●";
  }

  .quick-health-grid {
    grid-template-columns: 1fr;
  }

  .forecast-heading,
  .forecast-control-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }

  .forecast-result {
    padding-inline: 7px;
  }

  .measure-chart-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .measure-modes {
    align-self: flex-start;
  }

  .forecast-result > span {
    font-size: 8px;
  }

  .forecast-result strong {
    font-size: 18px;
  }

  .forecast-result small {
    font-size: 8px;
  }

  .dialog-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .dialog-actions button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Герой-карточка: фиолетовый блок в стиле референса --- */
.calorie-card {
  border: none;
  background:
    radial-gradient(560px 300px at 88% -10%, rgba(255, 255, 255, 0.16), transparent 60%),
    radial-gradient(480px 280px at 108% 120%, rgba(255, 255, 255, 0.1), transparent 60%),
    #7566e6;
  box-shadow: 0 24px 60px rgba(96, 80, 200, 0.32);
}

.calorie-card h2 {
  color: #ffffff;
}

.calorie-card .calorie-copy > p {
  color: rgba(255, 255, 255, 0.78);
}

.calorie-card .goal-line {
  border-color: rgba(255, 255, 255, 0.25);
}

.calorie-card .goal-line span {
  color: rgba(255, 255, 255, 0.72);
}

.calorie-card .goal-line strong {
  color: #ffffff;
}

.calorie-card .status-chip {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.calorie-card .calorie-ring {
  background: conic-gradient(#ffffff var(--progress), rgba(255, 255, 255, 0.24) 0);
}

.calorie-card .calorie-ring::before {
  background: #7566e6;
}

.calorie-card .calorie-ring strong {
  color: #ffffff;
}

.calorie-card .calorie-ring span {
  color: rgba(255, 255, 255, 0.75);
}

.calorie-card .deficit-block {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.13);
}

.calorie-card .deficit-headline span {
  color: rgba(255, 255, 255, 0.75);
}

.calorie-card .deficit-headline strong {
  color: #ffffff;
}

.calorie-card .deficit-block.surplus .deficit-headline strong {
  color: #ffd9d6;
}

.calorie-card .deficit-meter {
  background: rgba(255, 255, 255, 0.22);
}

.calorie-card .deficit-meter i {
  background: #ffffff;
}

.calorie-card .deficit-block.surplus .deficit-meter i {
  background: #ffb1aa;
}

.calorie-card .deficit-rows {
  color: #ffffff;
}

.calorie-card .deficit-block .fine-print {
  color: rgba(255, 255, 255, 0.66);
}

/* ── Панель проверки распознанного фото ───────────────────── */

.photo-review {
  margin-top: 22px;
  padding: 18px;
  border: 1px dashed rgba(114, 99, 227, 0.45);
  border-radius: 18px;
  background: rgba(114, 99, 227, 0.06);
}

.review-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.review-heading h3 {
  margin: 0 0 4px;
  font-size: 13px;
}

.review-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
}

.review-heading .secondary-button {
  min-height: 36px;
  background: var(--surface);
}

.review-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.review-item {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.review-top {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
}

.review-symbol {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 12px;
  background: var(--surface-3);
  font-size: 18px;
}

.review-name {
  min-width: 0;
}

.review-name h4 {
  margin: 0 0 4px;
  overflow: hidden;
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.review-name p {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  color: var(--faint);
  font-size: 9px;
}

.review-buttons {
  display: flex;
  gap: 3px;
}

.review-accept {
  display: grid;
  width: 32px;
  height: 32px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: rgba(60, 181, 114, 0.14);
  color: var(--green);
  font-weight: 700;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

.review-accept:hover {
  background: var(--green);
  color: #ffffff;
}

.review-steppers {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 12px;
}

.stepper {
  display: flex;
  overflow: hidden;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

.stepper button {
  width: 38px;
  min-height: 40px;
  border: 0;
  background: transparent;
  color: var(--lime);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}

.stepper button:hover {
  background: var(--surface-3);
}

.stepper label {
  position: relative;
  display: flex;
  align-items: center;
}

.stepper input {
  width: 64px;
  min-height: 40px;
  padding: 0 24px 0 6px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-weight: 650;
  text-align: right;
}

.stepper input:focus {
  background: var(--surface-3);
}

.stepper i {
  position: absolute;
  right: 7px;
  color: var(--faint);
  font-size: 9px;
  font-style: normal;
  pointer-events: none;
}

.review-macros {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
}

.review-macros-label {
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
}

.review-macros label {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--faint);
  font-size: 9px;
  font-weight: 600;
}

.review-macros input {
  width: 58px;
  min-height: 34px;
  padding: 0 7px;
  font-size: 11px;
}

.review-total {
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.review-total strong {
  color: var(--text);
  font-size: 12px;
}

/* ── Подсказки поиска по базе продуктов ───────────────────── */

.suggest-anchor {
  position: relative;
}

.suggest-box {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  z-index: 12;
  max-height: 380px;
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 18px 44px rgba(96, 80, 200, 0.22);
}

.suggest-row {
  display: grid;
  width: 100%;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 10px 13px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.suggest-row:last-of-type {
  border-bottom: 0;
}

.suggest-row:hover {
  background: var(--surface-2);
}

.suggest-badge {
  font-size: 14px;
}

.suggest-main {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.suggest-main strong {
  overflow: hidden;
  font-size: 11px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggest-main small {
  overflow: hidden;
  color: var(--faint);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggest-row.active {
  background: var(--surface-2);
  box-shadow: inset 3px 0 0 var(--lime);
}

.suggest-more {
  position: sticky;
  bottom: 0;
  display: block;
  width: 100%;
  padding: 10px 13px;
  border: 0;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--lime);
  font-size: 10px;
  font-weight: 650;
  cursor: pointer;
  text-align: left;
}

.suggest-more:hover {
  background: var(--surface-3);
}

.suggest-values {
  display: grid;
  justify-items: end;
  gap: 2px;
}

.suggest-values strong {
  font-size: 12px;
}

.suggest-values small {
  color: var(--faint);
  font-size: 8px;
  white-space: nowrap;
}

.suggest-loading {
  padding: 10px 13px;
  color: var(--muted);
  font-size: 10px;
}

@media (max-width: 560px) {
  .review-heading {
    flex-direction: column;
    align-items: flex-start;
  }

  .review-steppers .stepper {
    flex: 1;
    justify-content: space-between;
  }

  .suggest-box {
    max-height: 196px;
  }
}

/* ── Библиотека своих продуктов ───────────────────────────── */

.app-dialog .dialog-body {
  padding: 27px;
}

#library-search {
  margin-top: 22px;
}

.library-hint {
  margin: 10px 0 0;
}

.library-list {
  display: grid;
  gap: 1px;
  max-height: min(58vh, 560px);
  margin-top: 14px;
  overflow: auto;
  border-radius: 14px;
  background: var(--border);
}

.library-row {
  background: var(--surface-2);
  transition: background 200ms ease;
}

.library-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
}

.library-row.expanded .library-line {
  background: var(--surface-3);
}

.library-row.just-added {
  background: rgba(60, 181, 114, 0.18);
}

.library-main {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.library-main:hover {
  background: var(--surface-3);
}

.library-main .food-symbol {
  width: 40px;
  height: 40px;
  font-size: 18px;
}

.library-name {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.library-name strong {
  overflow: hidden;
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-name small {
  overflow: hidden;
  color: var(--faint);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-values {
  display: grid;
  justify-items: end;
  gap: 3px;
}

.library-values strong {
  font-size: 12px;
}

.library-values small {
  color: var(--faint);
  font-size: 8px;
  white-space: nowrap;
}

.library-line > .row-action {
  margin-right: 6px;
}

.library-line > .row-action:last-child {
  margin-right: 9px;
}

.library-line > .row-action[aria-expanded="true"] {
  background: var(--lime-dark);
  color: var(--lime);
}

.library-empty {
  padding: 26px 13px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

@media (max-width: 560px) {
  .heading-buttons {
    flex-wrap: wrap;
  }

  .library-values small {
    display: none;
  }
}

/* ── Замеры тела ──────────────────────────────────────────── */

.measure-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 9px;
  margin-top: 22px;
}

.measure-tile {
  display: grid;
  gap: 4px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
}

.measure-tile > span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
}

.measure-tile strong {
  font-size: 16px;
  letter-spacing: -0.03em;
}

.measure-tile small {
  font-size: 9px;
  font-weight: 650;
}

.measure-tile small.down { color: var(--green); }
.measure-tile small.up { color: var(--yellow); }
.measure-tile small.flat { color: var(--faint); }

.measure-ratio {
  margin: 13px 0 0;
}

#measure-list {
  margin-top: 18px;
}

.measure-form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 560px) {
  .measure-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ── Человечек с замерами и карточка «Тело» ───────────────── */

.body-figure {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: 4px 12px;
  margin-top: 16px;
}

.body-col {
  display: grid;
  align-content: space-between;
  gap: 9px;
  padding-block: 8px;
}

.body-col.right {
  justify-items: end;
  text-align: right;
}

.body-item {
  display: grid;
  gap: 1px;
}

.body-item span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
}

.body-item strong {
  font-size: 13px;
  letter-spacing: -0.02em;
}

.body-item small,
.body-weight-line small {
  font-size: 9px;
  font-weight: 750;
}

.body-item small.down,
.body-weight-line small.down { color: var(--green); }
.body-item small.up,
.body-weight-line small.up { color: var(--yellow); }
.body-item small.flat,
.body-weight-line small.flat { color: var(--faint); }

.body-silhouette {
  width: 92px;
  height: auto;
  align-self: center;
  fill: var(--lime-dark);
  stroke: rgba(114, 99, 227, 0.4);
  stroke-width: 1.4;
}

/* на вкладке «Вес» человечек крупнее */
.log-card .body-silhouette {
  width: 132px;
}

.log-card .body-figure {
  max-width: 560px;
  margin-inline: auto;
}

.body-weight-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 18px 0 0;
}

.body-weight-line strong {
  font-size: 25px;
  letter-spacing: -0.05em;
}

.body-weight-line small {
  font-size: 12px;
}

.body-weight-line span {
  color: var(--faint);
  font-size: 9px;
}

.body-card .fine-print {
  margin-top: 13px;
}

.body-open {
  min-height: 36px;
}

/* ── График динамики обхватов ─────────────────────────────── */

.measure-chart-card {
  overflow: hidden;
}

.measure-chart-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
  padding: 15px 0 14px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.measure-chips {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 6px;
}

.measure-chip {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.measure-chip:hover {
  background: rgba(84, 66, 165, 0.07);
  color: var(--text);
}

.measure-chip.is-active {
  border-color: transparent;
  background: var(--lime-dark);
  color: var(--lime);
}

.measure-chip:disabled {
  cursor: default;
  opacity: 0.5;
}

.measure-chip small {
  font-size: 9px;
  font-weight: 750;
}

.measure-chip small.down { color: var(--green); }
.measure-chip small.up { color: var(--yellow); }
.measure-chip small.flat { color: var(--faint); }

.measure-modes {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border-radius: 12px;
  background: var(--surface-3);
}

.measure-mode {
  min-height: 26px;
  padding: 0 11px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease;
}

.measure-mode:hover {
  color: var(--text);
}

.measure-mode.is-active {
  background: var(--surface);
  color: var(--text);
}

.measure-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 9px 18px;
  margin-top: 18px;
  color: var(--faint);
  font-size: 9px;
}

.measure-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.measure-legend i {
  width: 17px;
  height: 3px;
  border-radius: 99px;
}

.mlegend-median { background: var(--lime); }
.mlegend-band { background: rgba(114, 99, 227, 0.3); }
.mlegend-ghost { background: rgba(114, 99, 227, 0.22); }
.mlegend-weight { background: var(--protein); }

.mlegend-noise {
  height: 7px;
  border-radius: 3px;
  background: rgba(84, 66, 165, 0.1);
}

.mlegend-control {
  height: 0;
  border-top: 2px dashed var(--faint);
}

/* ── Поиск еды: чипы источников, секции, редактор порции ── */

.scope-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.scope-chip {
  padding: 7px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}

.scope-chip:hover {
  background: var(--surface-3);
  color: var(--text);
}

.scope-chip[aria-pressed="true"] {
  border-color: transparent;
  background: var(--lime);
  color: #fff;
}

.library-section {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 13px 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.library-section small {
  color: var(--faint);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.library-editor {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 9px;
  padding: 11px 13px 13px;
  border-top: 1px dashed var(--border-strong);
  background: var(--surface-3);
}

.library-editor .portion-chips {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.portion-chip {
  padding: 5px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 10px;
  cursor: pointer;
}

.portion-chip:hover {
  background: var(--surface-2);
}

.portion-chip[aria-pressed="true"] {
  border-color: var(--lime);
  background: var(--lime-dark);
  color: var(--lime);
  font-weight: 650;
}

.library-editor label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
}

.library-editor .editor-total {
  display: grid;
  gap: 2px;
  align-self: end;
  justify-items: end;
  padding-bottom: 6px;
}

.library-editor .editor-total strong {
  font-size: 14px;
}

.library-editor .editor-total small {
  color: var(--faint);
  font-size: 9px;
  white-space: nowrap;
}

.library-editor .primary-button {
  align-self: end;
}

.library-status,
.library-more {
  padding: 11px 13px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.library-more {
  width: 100%;
  border: 0;
  color: var(--lime);
  font-weight: 650;
  cursor: pointer;
}

.library-more:hover {
  background: var(--surface-3);
}

@media (max-width: 560px) {
  .library-editor {
    grid-template-columns: 1fr 1fr;
  }

  .library-editor .primary-button {
    grid-column: 1 / -1;
  }
}
