/* ==========================================================================
   Калькуляторкин — основной стиль.
   Mobile-first, без layout shift, минимум правил, светлая + тёмная тема.
   ========================================================================== */

:root {
  --bg:            #f6f8fb;
  --surface:       #ffffff;
  --surface-2:     #f1f4f9;
  --border:        #e2e8f0;
  --border-strong: #cbd5e1;
  --text:          #0f172a;
  --text-muted:    #64748b;
  --primary:       #2563eb;
  --primary-600:   #1d4ed8;
  --primary-050:   #eff6ff;
  --accent:        #0ea5a4;
  --success:       #16a34a;
  --danger:        #dc2626;
  --shadow:        0 1px 2px rgba(15,23,42,.04), 0 4px 16px rgba(15,23,42,.06);
  --shadow-lg:     0 8px 30px rgba(15,23,42,.10);
  --radius:        14px;
  --radius-sm:     10px;
  --maxw:          1100px;
  --font:          system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
  --bg:            #0b1120;
  --surface:       #111a2e;
  --surface-2:     #16213a;
  --border:        #233149;
  --border-strong: #334766;
  --text:          #e6edf7;
  --text-muted:    #94a3b8;
  --primary:       #3b82f6;
  --primary-600:   #2563eb;
  --primary-050:   #15233f;
  --shadow:        0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.35);
  --shadow-lg:     0 8px 30px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

main.container { display: block; padding-top: 20px; padding-bottom: 48px; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1,h2,h3 { line-height: 1.25; color: var(--text); }
h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); margin: .2em 0 .4em; }
h2 { font-size: clamp(1.25rem, 3vw, 1.6rem); margin: 1.6em 0 .6em; }
h3 { font-size: 1.1rem; margin: 1.2em 0 .4em; }

.muted { color: var(--text-muted); }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--primary); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.site-header__inner { display: flex; align-items: center; gap: 14px; min-height: 60px; }

.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.15rem; color: var(--text); }
.logo:hover { text-decoration: none; }
.logo__mark {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; font-weight: 800;
}

.main-nav { margin-left: auto; }
.main-nav > ul { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.main-nav a {
  display: block; padding: 8px 12px; border-radius: 8px; color: var(--text-muted); font-weight: 600; font-size: .92rem;
}
.main-nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }

/* Меню «Ещё» (выпадающее) */
.nav-more { position: relative; }
.nav-more__btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 8px 12px; border: 0; border-radius: 8px; cursor: pointer;
  font: inherit; font-weight: 600; font-size: .92rem; color: var(--text-muted);
  background: transparent;
}
.nav-more__btn:hover { color: var(--text); background: var(--surface-2); }
.nav-more__caret { font-size: .7rem; transition: transform .15s ease; }
.nav-more.open .nav-more__caret { transform: rotate(180deg); }
.nav-dropdown {
  display: block;
  position: absolute; top: calc(100% + 6px); right: 0; min-width: 230px;
  list-style: none; margin: 0; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); z-index: 60;
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity .15s ease, transform .15s ease, visibility .15s ease;
}
.nav-more:hover .nav-dropdown,
.nav-more.open .nav-dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
.nav-dropdown a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--text); font-weight: 600; font-size: .92rem; }
.nav-dropdown a:hover { background: var(--primary-050); color: var(--primary); text-decoration: none; }
.nav-dropdown__sep { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }
.nav-dropdown__sep a { color: var(--text-muted); font-size: .85rem; }

.header-tools { display: flex; align-items: center; gap: 8px; }

.header-search { position: relative; }
.header-search input {
  width: 200px; max-width: 42vw; padding: 9px 12px; font-size: .92rem;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text);
}
.header-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-050); }
.header-search__results {
  position: absolute; top: calc(100% + 6px); right: 0; width: min(360px, 80vw);
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
  overflow: hidden; z-index: 60;
}
.header-search__results a { display: block; padding: 10px 14px; color: var(--text); border-bottom: 1px solid var(--border); }
.header-search__results a:last-child { border-bottom: 0; }
.header-search__results a:hover { background: var(--primary-050); text-decoration: none; }
.header-search__results .sr-cat { display: block; font-size: .75rem; color: var(--text-muted); }
.header-search__results .sr-empty { padding: 12px 14px; color: var(--text-muted); }

.theme-toggle, .nav-toggle {
  display: grid; place-items: center; width: 40px; height: 40px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; color: var(--text);
}
.theme-toggle__icon { font-size: 1.1rem; }
.nav-toggle { display: none; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.nav-toggle span { width: 18px; height: 2px; background: var(--text); border-radius: 2px; }

/* ---------- Breadcrumbs ---------- */
.breadcrumbs ol { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 4px 0 14px; padding: 0; font-size: .85rem; }
.breadcrumbs li { display: flex; align-items: center; color: var(--text-muted); }
.breadcrumbs li + li::before { content: "/"; margin-right: 6px; color: var(--border-strong); }
.breadcrumbs a { color: var(--text-muted); }
.breadcrumbs a:hover { color: var(--primary); }

/* ---------- Hero (home) ---------- */
.hero { text-align: center; padding: 28px 0 8px; }
.hero__title { font-size: clamp(1.7rem, 5vw, 2.6rem); }
.hero__lead { font-size: 1.05rem; color: var(--text-muted); max-width: 620px; margin: 0 auto 18px; }
.hero__search { display: flex; gap: 8px; max-width: 600px; margin: 0 auto; }
.hero__search input {
  flex: 1; padding: 13px 16px; font-size: 1rem; border: 1px solid var(--border-strong);
  border-radius: 12px; background: var(--surface); color: var(--text);
}
.hero__search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-050); }
.hero__stat { margin-top: 14px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 18px; font-size: .95rem; font-weight: 600; font-family: inherit;
  border: 1px solid var(--border-strong); border-radius: 11px; background: var(--surface); color: var(--text);
  cursor: pointer; transition: transform .04s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-600); border-color: var(--primary-600); }

/* ---------- Tool grid / cards ---------- */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.tool-grid--big { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.tool-card {
  display: flex; flex-direction: column; gap: 4px; padding: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  color: var(--text); transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.tool-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.tool-card__title { font-weight: 700; }
.tool-card__desc { font-size: .85rem; color: var(--text-muted); }

/* ---------- Home category sections ---------- */
.home-cat { margin-top: 30px; }
.home-cat__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.home-cat__head h2 { margin: .4em 0; }
.home-cat__head h2 a { color: var(--text); }
.home-cat__all { font-weight: 600; white-space: nowrap; }
.home-about { margin-top: 40px; }

/* ---------- Category page ---------- */
.category-head { margin-bottom: 18px; }
.category-head__icon { margin-right: 4px; }
.category-head__intro { font-size: 1.05rem; color: var(--text-muted); max-width: 760px; }

/* ---------- Tool page ---------- */
.tool__head { margin-bottom: 14px; }
.tool__lead { font-size: 1.05rem; color: var(--text-muted); max-width: 760px; }

.calc {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin: 8px 0 18px;
}
.calc__inputs { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-weight: 600; font-size: .92rem; line-height: 1.3; }
/* На многоколоночной раскладке резервируем место под две строки подписи,
   чтобы поля ввода выравнивались по одной линии независимо от длины подписи. */
@media (min-width: 620px) {
  .calc__inputs .field__label { min-height: 2.5em; display: flex; align-items: flex-start; }
}
.field__unit { color: var(--text-muted); font-weight: 500; }
.field__control {
  width: 100%; padding: 12px 13px; font-size: 1rem; font-family: inherit;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
}
.field__control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-050); }
.field__control[aria-invalid="true"] { border-color: var(--danger); }
.field__hint { color: var(--text-muted); font-size: .8rem; }
.field__error { color: var(--danger); font-size: .8rem; }

.calc__result { margin-top: 18px; padding-top: 18px; border-top: 1px dashed var(--border-strong); }
.result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.result-card {
  background: var(--primary-050); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px;
}
.result-card__label { font-size: .85rem; color: var(--text-muted); margin-bottom: 4px; }
.result-card__value { font-size: 1.5rem; font-weight: 800; color: var(--text); word-break: break-word; }
.result-card__unit { font-size: .95rem; font-weight: 600; color: var(--text-muted); }
.result-card--primary .result-card__value { color: var(--primary); }

.calc__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; }
.calc__copied { color: var(--success); font-weight: 600; font-size: .9rem; }
.calc__noscript { color: var(--danger); margin-top: 12px; }

/* ---------- Content blocks ---------- */
.content-block { margin: 26px 0; }
.prose p { margin: .7em 0; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: .3em 0; }

.howto-list { counter-reset: step; list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.howto-list li {
  position: relative; padding: 12px 14px 12px 50px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.howto-list li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px; display: grid; place-items: center;
  background: var(--primary); color: #fff; border-radius: 50%; font-weight: 700; font-size: .85rem;
}

.examples { display: grid; gap: 12px; }
.example {
  padding: 14px 16px; background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--accent); border-radius: var(--radius-sm);
}
.example__title { margin: 0 0 6px; font-size: 1rem; }
.example__body { margin: 0; }

.faq { display: grid; gap: 10px; }
.faq__item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.faq__q { cursor: pointer; padding: 14px 16px; font-weight: 600; list-style: none; position: relative; padding-right: 44px; }
.faq__q::-webkit-details-marker { display: none; }
.faq__q::after { content: "+"; position: absolute; right: 16px; top: 12px; font-size: 1.3rem; color: var(--text-muted); }
.faq__item[open] .faq__q::after { content: "–"; }
.faq__a { padding: 0 16px 14px; color: var(--text-muted); }
.faq__a p { margin: .5em 0; }

/* ---------- Развёрнутая статья + «Читать далее» ---------- */
.article h2 { font-size: 1.5rem; margin: 0 0 .5em; }
.article h3 { font-size: 1.25rem; margin: 1.4em 0 .4em; }
.article h4 { font-size: 1.08rem; margin: 1.2em 0 .3em; }
.article table {
  width: 100%; border-collapse: collapse; margin: 1em 0; font-size: .94rem;
  display: block; overflow-x: auto;
}
.article th, .article td {
  border: 1px solid var(--border); padding: 8px 12px; text-align: left; vertical-align: top;
}
.article th { background: var(--surface); font-weight: 600; }
.article tr:nth-child(even) td { background: var(--surface); }
.article__rest > *:first-child { margin-top: 0; }

.article__more { margin-top: 4px; }
/* Прячем нативный треугольник <details> */
.article__more > summary { list-style: none; }
.article__more > summary::-webkit-details-marker { display: none; }
.article__toggle {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  margin-top: 10px; padding: 9px 18px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); color: var(--primary); font-weight: 600; font-size: .95rem;
  transition: background .15s, border-color .15s;
}
.article__toggle:hover { background: var(--surface-2); border-color: var(--primary); }
.article__toggle::after { content: "▾"; font-size: .8rem; }
.article__more[open] .article__toggle::after { content: "▴"; }
.article__toggle-less { display: none; }
.article__more[open] .article__toggle-more { display: none; }
.article__more[open] .article__toggle-less { display: inline; }

/* ---------- YMYL disclaimer ---------- */
.disclaimer {
  display: flex; gap: 10px; align-items: flex-start;
  margin: 18px 0; padding: 13px 16px;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent); border-radius: var(--radius-sm);
}
.disclaimer__icon { font-size: 1.1rem; line-height: 1.5; flex-shrink: 0; }
.disclaimer__text { margin: 0; font-size: .9rem; color: var(--text-muted); }

/* ---------- Ads / CPA ---------- */
.ad-slot { margin: 22px 0; min-height: 90px; display: flex; align-items: center; justify-content: center; }
.cpa-block { margin: 22px 0; padding: 16px; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); text-align: center; }
.cpa-block__link { font-weight: 700; }
.cpa-block__note { display: block; font-size: .75rem; color: var(--text-muted); margin-top: 4px; }

/* ---------- Sitemap / map ---------- */
.map-cat { margin: 20px 0; }
.map-list { columns: 2; column-gap: 24px; list-style: none; padding: 0; }
.map-list li { margin: 6px 0; break-inside: avoid; }

/* ---------- Search page ---------- */
.page-search-form { display: flex; gap: 8px; max-width: 600px; margin: 14px 0 24px; }
.page-search-form input { flex: 1; padding: 13px 16px; font-size: 1rem; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); color: var(--text); }
.search-page-results { display: grid; gap: 10px; }

/* ---------- 404 ---------- */
.error-page { text-align: center; padding: 40px 0; }
.error-page__code { font-size: 5rem; font-weight: 900; color: var(--primary); margin: 0; line-height: 1; }
.error-page .hero__search { margin: 20px auto; }
.error-page__cats { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 18px 0; }
.chip { padding: 7px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; font-size: .9rem; color: var(--text); }
.chip:hover { background: var(--surface-2); text-decoration: none; }

/* ---------- Footer ---------- */
.site-footer { margin-top: 40px; border-top: 1px solid var(--border); background: var(--surface); }
.site-footer__inner { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 24px; padding: 32px 16px; }
.site-footer__title { font-size: .95rem; margin: 0 0 10px; }
.site-footer__col ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.site-footer__col a { color: var(--text-muted); }
.site-footer__col a:hover { color: var(--primary); }
.logo--footer { font-size: 1rem; margin-bottom: 8px; }
.site-footer__bottom { padding: 14px 16px; border-top: 1px solid var(--border); font-size: .85rem; }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  .main-nav {
      display:none;
    position: fixed; inset: 59px 0 auto 0; margin: 0;
    background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-lg);
    transform: translateY(-12px); opacity: 0; visibility: hidden;
    transition: transform .2s ease, opacity .2s ease, visibility .2s ease; z-index: 49;
  }
  .main-nav.open { transform: translateY(0); opacity: 1; visibility: visible; display: block;}
  .main-nav > ul { flex-direction: column; gap: 0; padding: 8px; 
              height: 100%;
        max-height: 500px;
        overflow-y: auto;
  }
  .main-nav a { padding: 12px; border-radius: 10px; }

  /* На мобильных «Ещё» разворачивается списком прямо в меню */
  .nav-more { position: static; }
  .nav-more__btn { display: none; }
  .nav-dropdown {
    position: static; opacity: 1; visibility: visible; transform: none;
    min-width: 0; margin: 0; padding: 0; border: 0; box-shadow: none; background: transparent;
  }
  .nav-dropdown__sep { border-top: 1px solid var(--border); }
  .nav-toggle { display: flex; }
  .header-search input { width: 140px; }
  .site-header__inner { gap: 8px; }
}
@media (max-width: 600px) {
  .site-footer__inner { grid-template-columns: 1fr 1fr; }
  .site-footer__col:first-child { grid-column: 1 / -1; }
  .map-list { columns: 1; }
  .hero__search { flex-direction: column; }
  .header-search { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
