/* Раздел «Калорийность блюд» (/kalorii/). Токены и кнопки — из style.css.
   Inline-стили запрещены CSP, поэтому всё здесь. */

.proto-note { background: #b5404c; color: #fff; text-align: center; font-size: 13px; font-weight: 700; padding: 8px 16px; }

.dish { padding: 28px 0 80px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; font-size: 13.5px; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--ink); }

.dish-hero { margin-top: 28px; display: grid; grid-template-columns: 1.25fr 1fr; gap: 40px; align-items: center; }
@media (max-width: 860px) { .dish-hero { grid-template-columns: 1fr; gap: 24px; } }
.dish-hero h1 { font-size: clamp(26px, 4vw, 44px); font-weight: 800; line-height: 1.08; letter-spacing: -0.02em; }
.dish-lead { margin-top: 16px; color: var(--muted); font-size: 17px; max-width: 56ch; }

.answer { background: var(--paper-raised); border: 3px solid var(--line-strong); border-radius: 18px; padding: 22px; box-shadow: 8px 8px 0 var(--accent); }
@media (max-width: 480px) { .answer { box-shadow: 5px 5px 0 var(--accent); } }
.answer-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding-bottom: 14px; border-bottom: 6px solid var(--line-strong); }
.answer-k { display: block; font-size: 13px; font-weight: 700; color: var(--muted); }
.answer-v { display: block; font-family: var(--font-display); font-size: clamp(26px, 3.4vw, 36px); line-height: 1.1; margin-top: 4px; }
.answer-macros { display: flex; flex-wrap: wrap; gap: 8px 18px; padding-top: 14px; font-weight: 700; }
.answer-macros span { display: inline-flex; align-items: center; gap: 7px; }
.answer-macros i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-p { background: var(--protein); } .dot-f { background: var(--fat); } .dot-c { background: var(--carb); }
.answer-note { margin-top: 10px; font-size: 12.5px; color: var(--muted); }

.dish-block { margin-top: 64px; }
.dish-block h2 { font-size: clamp(22px, 2.8vw, 30px); font-weight: 700; line-height: 1.15; margin-bottom: 14px; }
.muted { color: var(--muted); max-width: 60ch; }

.breakdown { margin-top: 20px; background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); max-width: 720px; display: flex; flex-direction: column; gap: 14px; }
.bd-row { display: grid; grid-template-columns: minmax(150px, 1.2fr) 2fr 52px; align-items: center; gap: 14px; font-size: 15px; }
@media (max-width: 560px) { .bd-row { grid-template-columns: 1fr 52px; } .bd-row .bd-bar { grid-column: 1 / -1; grid-row: 2; } }
.bd-bar { display: block; height: 12px; border-radius: 9px; width: calc(var(--w) * 2.2); max-width: 100%; min-width: 10px; background: var(--accent-2); }
.bd-rice { background: var(--fat); } .bd-oil { background: var(--protein); } .bd-veg { background: var(--accent); }
.bd-row b, .bd-total b { font-family: var(--font-display); text-align: right; }
.bd-total { display: flex; justify-content: space-between; padding-top: 12px; border-top: 2px solid var(--line-strong); font-weight: 700; }

.table-wrap { overflow-x: auto; max-width: 720px; }
.kbju { width: 100%; border-collapse: collapse; background: var(--paper-raised); border-radius: 14px; overflow: hidden; border: 1px solid var(--line); font-size: 15px; }
.kbju th, .kbju td { padding: 12px 16px; text-align: right; border-bottom: 1px solid var(--line); }
.kbju th:first-child, .kbju td:first-child { text-align: left; }
.kbju th { font-size: 13px; color: var(--muted); font-weight: 700; background: var(--tint); }
.kbju tr:last-child td { border-bottom: none; }
.kbju .todo td { color: var(--muted); }

.factors { padding-left: 22px; display: flex; flex-direction: column; gap: 12px; max-width: 70ch; }
.factors li { padding-left: 4px; }
.factors b { font-weight: 700; }

.dish-cta { margin-top: 64px; display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap;
  background: linear-gradient(135deg, #1f5c33, #2f7a45 55%, #4f9a4a); color: #fff; border-radius: 24px; padding: 34px 36px; }
.dish-cta h2 { font-size: clamp(22px, 2.8vw, 30px); font-weight: 800; }
.dish-cta p { margin-top: 8px; color: rgba(255,255,255,.85); max-width: 52ch; }
@media (max-width: 560px) { .dish-cta { padding: 26px 22px; } .dish-cta .btn { width: 100%; } }

.related { display: flex; flex-wrap: wrap; gap: 10px; }
.related a { text-decoration: none; background: var(--paper-raised); border: 1px solid var(--line); border-radius: 999px; padding: 9px 16px; font-weight: 600; font-size: 14.5px; }
.related a:hover { border-color: var(--ink); }

.source { margin-top: 48px; font-size: 13px; color: var(--muted); max-width: 80ch; }

/* ---------- Калькулятор КБЖУ (/kalkulyator-kbzhu/) ---------- */
.calc-hero { margin-top: 28px; }
.calc-hero h1 { font-size: clamp(30px, 4.6vw, 52px); font-weight: 800; line-height: 1.05; letter-spacing: -0.02em; }
.calc { margin-top: 32px; display: grid; grid-template-columns: 1.1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 860px) { .calc { grid-template-columns: 1fr; } }
/* Длинные пункты select иначе распирают колонку сетки за край экрана. */
.calc > *, .calc-row > * { min-width: 0; }
.calc select { text-overflow: ellipsis; }
@media (max-width: 420px) { .calc-form, .calc-result { padding: 20px 16px; } .cm { padding: 10px 8px; } .calc-macros { gap: 6px; } }
.calc-form, .calc-result { background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); }
.calc-form { display: flex; flex-direction: column; gap: 18px; }
.calc-field { display: flex; flex-direction: column; gap: 7px; border: none; padding: 0; margin: 0; min-width: 0; }
.calc-field > span, .calc-field legend { font-size: 13.5px; font-weight: 700; color: var(--muted); padding: 0; }
.calc-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 480px) { .calc-row { grid-template-columns: 1fr 1fr; } .calc-row .calc-field:last-child { grid-column: 1 / -1; } }
.calc input[type="number"], .calc select {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: var(--paper);
  border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; min-height: 48px;
}
.calc input[type="number"]:focus, .calc select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.calc input[aria-invalid="true"] { border-color: var(--accent-2); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--paper); border: 1.5px solid var(--line); border-radius: 12px; padding: 4px; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: block; text-align: center; padding: 10px; border-radius: 9px; font-weight: 700; color: var(--muted); }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + span { outline: 3px solid var(--accent-2); outline-offset: 2px; }
.calc-error { color: var(--accent-2); font-weight: 600; font-size: 14.5px; }

.calc-result { min-height: 100%; }
.calc-empty { height: 100%; min-height: 220px; display: grid; place-items: center; text-align: center; color: var(--muted); border: 2px dashed var(--line); border-radius: 16px; padding: 24px; }
.calc-kcal { display: block; font-family: var(--font-display); font-size: clamp(40px, 6vw, 60px); line-height: 1; letter-spacing: -0.03em; margin-top: 6px; color: var(--accent); }
.calc-macros { margin-top: 20px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.cm { background: var(--tint); border-radius: 14px; padding: 12px; }
.cm > span { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
.cm > span i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.cm b { display: block; margin-top: 4px; font-family: var(--font-display); font-size: clamp(16px, 2vw, 20px); white-space: nowrap; }
.calc-note { margin-top: 14px; font-size: 13.5px; color: var(--muted); }
.calc-next { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 14px; font-size: 15px; }
.calc-next .btn { white-space: normal; text-align: center; line-height: 1.25; }
.nav-links a[aria-current="page"] { color: var(--ink); background: var(--tint); }

/* hidden должен побеждать display из правил выше */
[hidden] { display: none !important; }

/* ---------- Раздел /kalorii/: таблицы, добавки, рецептуры, конструктор, хаб ---------- */
.table-wide { max-width: none; }
.kbju td a { color: var(--ink); text-decoration-color: var(--line); text-underline-offset: 3px; }
.kbju td a:hover { color: var(--accent); }
.adds { list-style: none; padding: 0; margin: 14px 0 0; max-width: 620px; display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.adds li { display: flex; justify-content: space-between; gap: 16px; padding: 11px 2px; border-bottom: 1px solid var(--line); font-size: 15.5px; }
.adds b { font-family: var(--font-display); font-size: 14px; color: var(--accent-2); white-space: nowrap; }
.kasha { padding: 16px 0; border-top: 1px solid var(--line); max-width: 760px; }
.kasha h3 { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.kasha p { color: var(--muted); }
.kasha p b { color: var(--ink); }
.recipes { display: flex; flex-direction: column; gap: 8px; max-width: 760px; }
.recipe { background: var(--paper-raised); border: 1px solid var(--line); border-radius: 14px; }
.recipe summary { cursor: pointer; list-style: none; padding: 14px 18px; font-weight: 700; display: flex; justify-content: space-between; gap: 12px; }
.recipe summary::-webkit-details-marker { display: none; }
.recipe summary::after { content: "+"; color: var(--accent); font-weight: 800; }
.recipe[open] summary::after { content: "−"; }
.recipe-list { list-style: none; margin: 0; padding: 0 18px; }
.recipe-list li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 14.5px; }
.recipe-list li span:last-child { color: var(--muted); white-space: nowrap; }
.recipe .calc-note { padding: 0 18px 14px; }

.builder { margin-top: 18px; background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; max-width: 860px; }
.builder select, .builder input[type="number"] { font: inherit; font-size: 15.5px; color: var(--ink); background: var(--paper); border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; min-height: 44px; width: 100%; min-width: 0; }
.builder select:focus, .builder input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.builder-top { max-width: 420px; }
.builder-rows { display: flex; flex-direction: column; gap: 8px; }
.builder-row { display: grid; grid-template-columns: minmax(0, 1fr) 96px 18px 40px; gap: 8px; align-items: center; }
.builder-unit { color: var(--muted); font-weight: 700; }
.builder-del { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; }
.builder-del:hover { color: var(--accent-2); border-color: var(--accent-2); }
#builderAdd { align-self: flex-start; }
.builder-out { border-top: 1px solid var(--line); padding-top: 16px; }
.builder-bars { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.builder-bars .bd-bar { width: 2%; }
@media (max-width: 480px) {
  .builder { padding: 16px; }
  .builder-row { grid-template-columns: minmax(0, 1fr) 72px 14px 36px; gap: 6px; }
  .builder-del { width: 36px; height: 36px; }
}

.hub-cards { margin-top: 28px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 760px) { .hub-cards { grid-template-columns: 1fr; } }
.hub-card { display: flex; flex-direction: column; gap: 6px; text-decoration: none; background: var(--paper-raised); border: 2px solid var(--line); border-radius: 18px; padding: 22px; transition: border-color .15s, transform .15s; }
.hub-card:hover { border-color: var(--ink); transform: translateY(-2px); }
.hub-card b { font-family: var(--font-display); font-size: 22px; }
.hub-card span { color: var(--muted); }
