/* Adapted from the approved CalcFatBot blog design handoff. */
:root {
  --bg: #eef1f6;
  --surface: #fff;
  --surface2: #f3f6fa;
  --border: #e3e7ee;
  --text: #15202e;
  --body: #2a3340;
  --muted: #6b7688;
  --faint: #8a93a3;
  --accent: #38bdf8;
  --accent-ink: #0c93bd;
  --green: #46d39a;
  --green-ink: #16a877;
  --warn: #f5b53d;
  --warn-ink: #8a6210;
  --warn-bg: #fdf6e6;
  --nav: #fff;
  --nav-cta-bg: #15202e;
  --nav-cta-fg: #fff;
  --card-shadow: 0 14px 36px -22px rgba(21, 32, 46, .2);
  --r-sm: 11px;
  --r: 14px;
  --r-md: 16px;
  --r-lg: 20px;
}

html[data-theme="dark"] {
  --bg: #0d1525;
  --surface: #16223a;
  --surface2: #172234;
  --border: rgba(148, 163, 184, .15);
  --text: #eef3fb;
  --body: #dbe5f3;
  --muted: #8b9bb4;
  --faint: #65758f;
  --accent-ink: #38bdf8;
  --green-ink: #46d39a;
  --warn-ink: #f5b53d;
  --warn-bg: rgba(245, 181, 61, .1);
  --nav: #15202e;
  --nav-cta-bg: #38bdf8;
  --nav-cta-fg: #06243a;
  --card-shadow: 0 14px 36px -22px rgba(3, 6, 12, .6);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Manrope, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background .25s, color .25s;
}

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

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

img {
  display: block;
  max-width: 100%;
}

button,
input,
select {
  font: inherit;
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.shell {
  max-width: 1200px;
  margin: 0 auto;
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 40px;
}

.hd {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 44px 0 0;
}

.kicker {
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 42px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -.025em;
  text-wrap: pretty;
}

.lead {
  max-width: 660px;
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
  text-wrap: pretty;
}

.meta {
  color: var(--faint);
  font-size: 13px;
  font-weight: 600;
}

/* Как на главной и в калькуляторе: без своего фона и без sticky — иначе внутри
   .shell шапка выглядит плашкой другого цвета поверх фона страницы. */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 40px;
  border-bottom: 1px solid var(--border);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.01em;
}

.nav-brand img {
  width: 32px;
  height: 32px;
  border-radius: 10px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
}

.nav-links a {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.nav-links a[aria-current="page"] {
  color: var(--accent-ink);
  font-weight: 800;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 800;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 20px 0 0;
  color: var(--faint);
  font-size: 13px;
  font-weight: 600;
}

.crumbs a {
  color: var(--muted);
}

.crumbs span[aria-current] {
  color: var(--body);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border: 1px solid transparent;
  border-radius: var(--r);
  cursor: pointer;
  font-size: 15px;
  font-weight: 800;
  transition: background .15s, border-color .15s, transform .12s;
}

.btn-primary {
  background: var(--accent);
  color: #06243a;
}

.btn-primary:hover {
  background: #22a8e2;
  color: #06243a;
}

.btn-secondary {
  border-color: var(--border);
  background: var(--surface2);
  color: var(--body);
  font-size: 14.5px;
  font-weight: 700;
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--text);
}

.btn[aria-disabled="true"] {
  opacity: .55;
  cursor: not-allowed;
}

.chip {
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 700;
  transition: background .15s, color .15s, border-color .15s;
}

.chip:hover {
  border-color: var(--accent);
}

.chip[aria-selected="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #06243a;
}

.tag {
  padding: 5px 11px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent-ink);
  font-size: 11.5px;
  font-weight: 800;
}

.tag--sugar {
  background: color-mix(in srgb, var(--warn) 16%, transparent);
  color: var(--warn-ink);
}

.tag--food {
  background: color-mix(in srgb, var(--green) 15%, transparent);
  color: var(--green-ink);
}

.tag--news {
  background: color-mix(in srgb, #a78bfa 16%, transparent);
  color: #8b5cf6;
}

.tag--soon {
  margin-left: auto;
  background: var(--surface2);
  color: var(--faint);
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.grid--2 {
  grid-template-columns: 1.4fr 1fr;
}

.post {
  display: flex;
  overflow: hidden;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--card-shadow);
  transition: border-color .15s;
}

.post:hover {
  border-color: var(--accent);
}

.post[hidden] {
  display: none;
}

.post-cover {
  aspect-ratio: 16 / 9;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.post-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.post-cover--contain {
  background: #050505;
}

.post-cover--contain img {
  object-fit: contain;
}

.post-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 11px;
  padding: 20px 22px 22px;
  color: var(--text);
}

.post-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.post-title {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -.015em;
}

.post-lead {
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.55;
}

.post-more {
  margin-top: auto;
  color: var(--faint);
  font-size: 13.5px;
  font-weight: 800;
}

.pager {
  display: flex;
  align-items: center;
  gap: 7px;
}

.pager button {
  min-width: 38px;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--body);
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
}

.pager button[aria-current="page"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #06243a;
}

.pager-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 26px 0 8px;
}

.card {
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--card-shadow);
}

.cta {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.cta .cta-text {
  display: flex;
  min-width: 220px;
  flex: 1;
  flex-direction: column;
  gap: 5px;
}

.cta-title {
  font-size: 17px;
  font-weight: 800;
}

.cta-sub {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 44px;
  align-items: start;
  padding: 24px 0 56px;
}

.article {
  min-width: 0;
}

.article h1 {
  margin: 14px 0 12px;
  font-size: 40px;
}

.article h2 {
  margin: 38px 0 12px;
  scroll-margin-top: 90px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.02em;
}

.article h3 {
  margin: 26px 0 8px;
  font-size: 19px;
  font-weight: 800;
}

.article p {
  margin: 0 0 14px;
  color: var(--body);
  font-size: 17px;
  line-height: 1.7;
  text-wrap: pretty;
}

.article-hero-image {
  overflow: hidden;
  margin: 24px 0 30px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface2);
}

.article-hero-image img {
  width: 100%;
  max-height: 720px;
  object-fit: cover;
}

.article-hero-image--contain {
  background: #050505;
}

.article-hero-image--contain img {
  object-fit: contain;
}

.article-hero-image figcaption {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--faint);
  font-size: 12.5px;
  font-weight: 600;
}

.article ul,
.article ol {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 16px;
  padding-left: 22px;
}

.article li {
  color: var(--body);
  font-size: 16.5px;
  line-height: 1.65;
}

.article blockquote {
  margin: 0 0 22px;
  padding: 4px 0 4px 20px;
  border-left: 3px solid var(--accent);
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.6;
}

.article table {
  width: 100%;
  margin: 6px 0 20px;
  border-collapse: collapse;
  font-size: 15px;
}

.article th {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: .06em;
  text-align: left;
  text-transform: uppercase;
}

.article td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--body);
}

.byline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 0 18px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.byline .avatar {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  object-fit: cover;
  flex: none;
}

.byline .author {
  color: var(--body);
  font-weight: 700;
}

.toc {
  position: sticky;
  top: 100px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.toc-title {
  color: var(--faint);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.toc a {
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.45;
}

.ymyl {
  display: flex;
  gap: 13px;
  margin: 26px 0;
  padding: 17px 19px;
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  border-radius: var(--r);
  background: var(--warn-bg);
}

.ymyl p {
  margin: 0;
  color: var(--warn-ink);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.6;
}

.footer {
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 36px 0 44px;
  border-top: 1px solid var(--border);
}

.footer-cols {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 26px;
}

.footer-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-col b {
  color: var(--faint);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.footer-col a {
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
}

.footer-note {
  color: var(--faint);
  font-size: 12.5px;
  font-weight: 600;
}

@media (max-width: 900px) {
  .wrap {
    padding: 0 20px;
  }

  .nav {
    padding: 14px 20px;
  }

  .nav-links a:not([aria-current]),
  .nav .btn {
    display: none;
  }

  h1 {
    font-size: 32px;
  }

  .article h1 {
    font-size: 30px;
  }

  .grid,
  .grid--2,
  .article-layout,
  .footer-cols {
    grid-template-columns: 1fr;
  }

  .toc {
    position: static;
  }
}

@media (max-width: 460px) {
  .nav {
    gap: 10px;
  }

  .nav-brand span {
    display: none;
  }

  .theme-toggle {
    padding: 7px 10px;
  }

  .post-body {
    padding: 18px;
  }

  .card {
    padding: 20px;
  }
}
