:root {
  --c-bg: #f6f7fb;
  --c-surface: #ffffff;
  --c-text: #1f2937;
  --c-muted: #6b7280;
  --c-border: #e3e6ee;
  --c-primary: #1d4ed8;
  --c-primary-soft: #e8efff;
  --c-accent: #f59e0b;
  --c-ok: #15803d;
  --c-warn: #b45309;
  --c-error: #b91c1c;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font: 16px/1.6 var(--font);
  color: var(--c-text);
  background: var(--c-bg);
}

a { color: var(--c-primary); }
a:hover { text-decoration-thickness: 2px; }

h1, h2, h3 { line-height: 1.25; margin: 1.6em 0 .6em; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem); margin-top: .4em; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }

.container { max-width: 960px; margin: 0 auto; padding: 0 16px; }

/* Шапка */
.site-header { background: var(--c-surface); border-bottom: 1px solid var(--c-border); position: sticky; top: 0; z-index: 20; }
.header-inner { display: flex; align-items: center; gap: 4px 16px; min-height: 56px; flex-wrap: wrap; padding-top: 8px; }
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.2rem; color: var(--c-text); text-decoration: none; }
.logo-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--c-primary); color: #fff; font-size: 1.3rem; }
.site-nav { display: flex; gap: 4px 20px; flex-wrap: wrap; width: 100%; padding-bottom: 8px; }
.site-nav a { color: var(--c-text); text-decoration: none; font-size: .95rem; padding: 4px 0; }
.site-nav a:hover { color: var(--c-primary); }
.nav-toggle { display: none; margin-left: auto; }

@media (max-width: 760px) {
  .nav-toggle { display: inline-block; background: var(--c-primary-soft); color: var(--c-primary); border: 0; border-radius: 8px; padding: 8px 12px; font: inherit; cursor: pointer; }
  .header-inner { padding-bottom: 8px; }
  .site-nav { display: none; flex-direction: column; padding-bottom: 4px; }
  .site-nav.open { display: flex; }
}

/* Хлебные крошки */
.breadcrumbs { font-size: .875rem; color: var(--c-muted); margin: 16px 0 0; }
.breadcrumbs a { color: var(--c-muted); }
.breadcrumbs .sep { margin: 0 4px; }

.lead { font-size: 1.1rem; color: var(--c-muted); margin-top: 0; }

/* Главная */
.hero { padding: 24px 0 8px; }
.search { width: 100%; font: inherit; font-size: 1.05rem; padding: 14px 16px; border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-surface); box-shadow: var(--shadow); }
.search:focus { outline: 2px solid var(--c-primary); outline-offset: 1px; }
.search-empty { color: var(--c-muted); }
.category-block h2 a { color: var(--c-text); text-decoration: none; }
.category-block h2 a:hover { color: var(--c-primary); }

/* Карточки */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card { display: flex; flex-direction: column; gap: 4px; padding: 16px; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); text-decoration: none; color: var(--c-text); transition: border-color .15s, box-shadow .15s; }
.card:hover { border-color: var(--c-primary); box-shadow: var(--shadow); }
.card-title { font-weight: 600; color: var(--c-primary); }
.card-text { font-size: .9rem; color: var(--c-muted); }
.card-ref { background: #fbfcff; border-style: dashed; }
.card-badge { align-self: flex-start; font-size: .7rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: #7c3aed; background: #f3e8ff; border-radius: 6px; padding: 1px 7px; }
.site-nav a.nav-ref { color: #7c3aed; font-weight: 600; }

/* Калькулятор */
.calc { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin: 20px 0; }
.calc > h2:first-child, .calc > h3:first-child { margin-top: 0; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.wide { grid-column: 1 / -1; }
.field label, .field .label { font-size: .9rem; font-weight: 600; }
.field input[type="text"], .field input[type="date"], .field input[type="number"], .field select, .field textarea {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid #cfd4df; border-radius: 8px; background: #fff; color: var(--c-text);
}
.field textarea { min-height: 120px; resize: vertical; font-family: ui-monospace, Consolas, monospace; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--c-primary); outline-offset: -1px; border-color: transparent; }
.hint { font-size: .8rem; color: var(--c-muted); }
.unit-input { position: relative; }
.unit-input input { padding-right: 48px !important; }
.unit-input .unit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--c-muted); font-size: .9rem; pointer-events: none; }
.radios { display: flex; flex-wrap: wrap; gap: 8px; }
.radios label { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border: 1px solid #cfd4df; border-radius: 8px; cursor: pointer; font-weight: 400; font-size: .95rem; }
.radios label:has(input:checked) { border-color: var(--c-primary); background: var(--c-primary-soft); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: .95rem; cursor: pointer; }

.calc-error { color: var(--c-error); background: #fef2f2; border: 1px solid #fecaca; padding: 10px 12px; border-radius: 8px; margin: 16px 0 0; }
.calc-output { margin-top: 20px; }

.results { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.result { background: var(--c-bg); border-radius: 10px; padding: 12px 14px; }
.result.main { background: var(--c-primary-soft); }
.result-label { display: block; font-size: .85rem; color: var(--c-muted); }
.result-value { display: block; font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; word-break: break-word; }
.result.main .result-value { color: var(--c-primary); font-size: 1.55rem; }
.result-note { display: block; font-size: .8rem; color: var(--c-muted); }
.answer { font-size: 1.15rem; margin: 12px 0 0; }
.answer strong { color: var(--c-primary); font-variant-numeric: tabular-nums; }
.formula-line { font-family: ui-monospace, Consolas, monospace; background: var(--c-bg); padding: 10px 12px; border-radius: 8px; overflow-x: auto; white-space: nowrap; }

/* Конвертер единиц */
.conv-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto minmax(0, 1fr) minmax(0, 1.4fr); gap: 14px 12px; align-items: end; }
.conv-grid input { font-size: 1.1rem !important; font-variant-numeric: tabular-nums; }
.conv-swap { font: inherit; font-size: 1.3rem; line-height: 1; width: 44px; height: 44px; border-radius: 50%; border: 1px solid #cfd4df; background: #fff; color: var(--c-primary); cursor: pointer; }
.conv-swap:hover { background: var(--c-primary-soft); }
.conv-options { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: .9rem; color: var(--c-muted); }
.conv-options select { font: inherit; padding: 6px 8px; border: 1px solid #cfd4df; border-radius: 8px; background: #fff; }
.conv-answer { font-size: 1.25rem; margin: 0; font-variant-numeric: tabular-nums; word-break: break-word; }
.conv-answer strong { color: var(--c-primary); }
.conv-formula { color: var(--c-muted); font-size: .9rem; margin: 6px 0 0; }
.conv-formula:empty { display: none; }
table.conv-all tbody tr { cursor: pointer; }
table.conv-all tr.is-current { background: var(--c-primary-soft); font-weight: 600; }
.muted { color: var(--c-muted); }
@media (max-width: 760px) {
  .conv-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); }
  .conv-swap { grid-column: 1 / -1; justify-self: center; transform: rotate(90deg); }
}

.chart-box { position: relative; height: 320px; margin: 20px 0 8px; }
.chart-box.chart-small { height: 220px; margin-top: 8px; }
.form-subtitle { font-size: 1.05rem; margin: 22px 0 6px; }
.load-row { margin-top: 10px; }

/* Чертежи */
.figure { margin: 20px 0 8px; text-align: center; }
.figure svg { width: 100%; max-width: 520px; height: auto; max-height: 340px; overflow: visible; }
.figure-row { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: center; align-items: center; }
.figure-row .figure { flex: 1 1 220px; }
.figure.figure-wide svg { max-width: 760px; max-height: 300px; }
.figure .fig-shape { fill: var(--c-primary-soft); stroke: var(--c-primary); stroke-width: 2; vector-effect: non-scaling-stroke; }
.figure .fig-line { stroke: var(--c-muted); stroke-width: 1.5; fill: none; vector-effect: non-scaling-stroke; }
.figure .fig-accent { stroke: var(--c-accent); stroke-width: 2.5; fill: none; vector-effect: non-scaling-stroke; }
.figure .fig-green { stroke: var(--c-ok); stroke-width: 2.5; fill: none; vector-effect: non-scaling-stroke; }
.figure .fig-dot { fill: var(--c-primary); }
.figure .fig-copper { fill: #e8a33d; stroke: #b45309; stroke-width: 1; vector-effect: non-scaling-stroke; }
.figure .fig-diel { fill: #d9ead3; stroke: #9cbf8f; stroke-width: 1; vector-effect: non-scaling-stroke; }
.figure .fig-hole { fill: #fff; stroke: var(--c-primary); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.figure .fig-load { stroke: var(--c-error); stroke-width: 2; fill: none; vector-effect: non-scaling-stroke; }
.figure .fig-load-head { fill: var(--c-error); stroke: none; }
.figure .fig-beam { fill: #cbd5e1; stroke: #475569; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.figure .fig-support { fill: #e2e8f0; stroke: #475569; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.figure text { font: 600 14px var(--font); fill: var(--c-text); }
.figure .fig-label { font-weight: 400; fill: var(--c-muted); }
.steps { margin: 12px 0 0; padding-left: 1.4em; }
.steps li { margin: 4px 0; font-variant-numeric: tabular-nums; }
.verdict { font-size: 1.1rem; padding: 12px 14px; border-radius: 10px; margin: 12px 0 0; }
.verdict.ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: var(--c-ok); }
.verdict.warn { background: #fffbeb; border: 1px solid #fde68a; color: var(--c-warn); }
.verdict.bad { background: #fef2f2; border: 1px solid #fecaca; color: var(--c-error); }
.bit-p { background: #dbeafe; }
.bit-err { background: #fecaca; color: var(--c-error); font-weight: 700; }
.bit-fix { background: #bbf7d0; font-weight: 700; }
.hl { background: #fde68a; border-radius: 3px; }
.bits { font-family: ui-monospace, Consolas, monospace; letter-spacing: .04em; word-break: break-all; }
.out-block { position: relative; margin: 12px 0 0; }
.out-block .out-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 4px; font-size: .9rem; font-weight: 600; }
.out-block .mono { white-space: pre-wrap; word-break: break-all; max-height: 360px; overflow: auto; }
.graph-fig { margin: 20px 0 8px; text-align: center; }
.graph-fig svg { width: 100%; max-width: 760px; height: auto; max-height: 500px; overflow: visible; }
.graph-fig .fig-note { margin: 4px 0 0; font-size: .85rem; color: var(--c-muted); }
.g-edge { stroke: #94a3b8; stroke-width: 2; fill: none; }
.g-edge.hl { stroke: var(--c-accent); stroke-width: 4.5; }
.g-edge.ok { stroke: var(--c-ok); stroke-width: 4; }
.g-edge.bad { stroke: var(--c-error); stroke-width: 3.5; stroke-dasharray: 8 4; }
.g-edge.dim { stroke: #cbd5e1; stroke-width: 1.5; stroke-dasharray: 5 4; }
.g-node circle { fill: #fff; stroke: var(--c-primary); stroke-width: 2; }
.g-node text { font: 600 14px var(--font); fill: var(--c-text); }
.g-node.hl circle { fill: #fde68a; stroke: #b45309; }
.g-node.side circle { fill: var(--c-primary-soft); }
.g-node.src circle { fill: var(--c-primary); }
.g-node.dst circle { fill: var(--c-ok); stroke: var(--c-ok); }
.g-node.src text, .g-node.dst text { fill: #fff; }
.g-w { font: 600 12px var(--font); fill: #334155; paint-order: stroke; stroke: #fff; stroke-width: 4px; stroke-linejoin: round; }
.g-w.hl { fill: #b45309; }
.g-w.ok { fill: var(--c-ok); }
.g-w.bad { fill: var(--c-error); }
.g-w.dim { fill: #94a3b8; font-weight: 400; }
.g-sub { font: 600 11px var(--font); fill: var(--c-primary); paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 1px solid #94a3b8; vertical-align: -1px; margin-right: 6px; }
.cols-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px 16px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 20px 0 8px; }
.toolbar h3 { margin: 0 auto 0 0; font-size: 1.05rem; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .9rem; background: #f6f7f9; border: 1px solid #e5e7eb; border-radius: 8px; padding: 10px 12px; margin: 0; word-break: break-word; }
.toolbar select { font: inherit; font-size: .9rem; padding: 7px 10px; border: 1px solid #cfd4df; border-radius: 8px; background: #fff; }
.btn { font: inherit; font-size: .9rem; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--c-primary); background: var(--c-primary); color: #fff; cursor: pointer; }
.btn:hover { filter: brightness(1.1); }
.btn.secondary { background: #fff; color: var(--c-primary); }
.btn-link { font: inherit; font-size: .9rem; background: none; border: 0; padding: 0; color: var(--c-primary); cursor: pointer; text-decoration: underline; }
.share-row { margin: 16px 0 0; font-size: .9rem; color: var(--c-muted); }

/* Таблицы */
.table-wrap { overflow: auto; max-height: 480px; border: 1px solid var(--c-border); border-radius: 10px; }
.table-wrap.tall { max-height: none; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--c-border); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { position: sticky; top: 0; background: #f1f4fa; font-weight: 600; z-index: 1; }
tbody tr:hover { background: #fafbff; }
.prize-input { width: 120px; font: inherit; padding: 4px 8px; border: 1px solid #cfd4df; border-radius: 6px; text-align: right; }

/* Шкала ИМТ */
.scale { position: relative; height: 14px; border-radius: 7px; margin: 28px 0 8px; background: linear-gradient(90deg, #60a5fa 0%, #60a5fa 14%, #22c55e 14%, #22c55e 40%, #facc15 40%, #facc15 60%, #f97316 60%, #f97316 80%, #ef4444 80%); }
.scale-marker { position: absolute; top: -8px; width: 4px; height: 30px; background: var(--c-text); border-radius: 2px; transform: translateX(-50%); transition: left .2s; }
.scale-labels { position: relative; height: 1.4em; font-size: .75rem; color: var(--c-muted); }
.scale-labels span { position: absolute; transform: translateX(-50%); }
.scale-labels span:first-child { transform: none; }
.scale-labels span:last-child { transform: translateX(-100%); }
.status { font-weight: 700; }
.status.ok { color: var(--c-ok); }
.status.warn { color: var(--c-warn); }
.status.bad { color: var(--c-error); }

/* Статья */
.article { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 4px 24px 20px; margin: 20px 0; }
.article p, .article li { max-width: 72ch; }
.article .table-wrap { margin: 12px 0; }
.formula { font-family: ui-monospace, Consolas, monospace; background: var(--c-bg); border-left: 3px solid var(--c-primary); padding: 10px 14px; border-radius: 0 8px 8px 0; overflow-x: auto; }
.formula-inline { font-family: ui-monospace, Consolas, monospace; background: var(--c-bg); padding: 1px 6px; border-radius: 4px; }
.note { background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 10px 14px; }
details { border-bottom: 1px solid var(--c-border); padding: 10px 0; }
details summary { cursor: pointer; font-weight: 600; }
details p { margin: 8px 0 0; }

/* Справочник и математические формулы */
.ref-page .article { padding-top: 8px; }
.article table.ref td, .article table.ref th { white-space: normal; }
table.ref td, table.ref th { text-align: left; vertical-align: top; }
table.ref td.c, table.ref th.c { text-align: center; }
table.ref td.r, table.ref th.r { text-align: right; }
table.grid td, table.grid th { text-align: center; padding: 6px 8px; }
table.grid tbody th { background: #f8fafc; }
.m { font-family: "Cambria Math", "STIX Two Math", "Latin Modern Math", Cambria, "Times New Roman", serif; font-size: 1.08em; white-space: nowrap; }
.m i, .math i { font-style: italic; }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; line-height: 1.15; margin: 0 2px; }
.frac > span:first-child { border-bottom: 1px solid currentColor; padding: 0 3px; }
.frac > span:last-child { padding: 0 3px; }
.math { font-family: "Cambria Math", "STIX Two Math", "Latin Modern Math", Cambria, "Times New Roman", serif; font-size: 1.15rem; line-height: 1.9; overflow-x: auto; padding: 10px 14px; background: var(--c-bg); border-radius: 8px; }
.math.big { font-size: 1.3rem; }
.math sup, .m sup { font-size: .72em; }
.sqrt { white-space: nowrap; }
.sqrt > span { border-top: 1px solid currentColor; padding: 0 2px; }
.ref-toc { columns: 2 220px; margin: 8px 0 0; padding-left: 1.2em; }
.ref-toc li { break-inside: avoid; }
.lims { display: inline-flex; flex-direction: column-reverse; vertical-align: middle; font-size: .68em; line-height: 1.15; margin: 0 2px 0 1px; text-align: left; }
.cas-steps { margin: 12px 0 0; padding-left: 1.4em; }
.cas-steps li { margin: 6px 0; }
.heat { width: 100%; max-width: 760px; height: auto; image-rendering: pixelated; border: 1px solid var(--c-border); border-radius: 8px; display: block; margin: 0 auto; }
.heat-legend { display: flex; align-items: center; gap: 8px; justify-content: center; font-size: .85rem; color: var(--c-muted); margin: 6px 0 0; }
.heat-legend .bar { width: 220px; height: 10px; border-radius: 5px; background: linear-gradient(90deg, #313695, #4575b4, #74add1, #abd9e9, #ffffbf, #fdae61, #f46d43, #d73027, #a50026); }
.examples { display: flex; flex-wrap: wrap; gap: 6px 8px; margin: 10px 0 0; font-size: .85rem; }
.examples .btn-link { font-size: .85rem; }

.prose { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 8px 24px 24px; margin: 20px 0; }

.related { margin: 28px 0; }

/* Комментарии */
.comments { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 4px 24px 24px; margin: 20px 0; }
.comment { border-bottom: 1px solid var(--c-border); padding: 12px 0; }
.comment-head { margin: 0; }
.comment-date { color: var(--c-muted); font-size: .85rem; }
.comment-text { margin: 6px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
.comment-reply { margin: 10px 0 0 16px; padding: 10px 14px; background: var(--c-primary-soft); border-radius: 8px; }
.comment-form { margin-top: 16px; }
.comment-status { margin: 12px 0 0; padding: 10px 12px; border-radius: 8px; }
.comment-status.ok { background: #f0fdf4; color: var(--c-ok); border: 1px solid #bbf7d0; }
.comment-status.error { background: #fef2f2; color: var(--c-error); border: 1px solid #fecaca; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.btn:disabled { opacity: .6; cursor: wait; }

/* Реклама */
.ad { margin: 24px 0; min-height: 90px; text-align: center; overflow: hidden; }
.ad-placeholder { display: grid; place-items: center; min-height: 120px; border: 2px dashed #cbd2e1; border-radius: var(--radius); color: var(--c-muted); font-size: .9rem; background: repeating-linear-gradient(45deg, #fafbfe, #fafbfe 10px, #f3f5fa 10px, #f3f5fa 20px); }

/* Подвал */
.site-footer { margin-top: 40px; padding: 24px 0; background: var(--c-surface); border-top: 1px solid var(--c-border); color: var(--c-muted); font-size: .875rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 18px; }

.cookie-banner { position: fixed; left: 16px; right: 16px; bottom: 16px; max-width: 720px; margin: 0 auto; display: flex; gap: 16px; align-items: center; padding: 14px 18px; background: #111827; color: #f3f4f6; border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0, 0, 0, .25); font-size: .9rem; z-index: 50; }
.cookie-banner[hidden] { display: none; }
.cookie-banner p { margin: 0; }
.cookie-banner a { color: #93c5fd; }

[hidden] { display: none !important; }

@media (max-width: 560px) {
  .calc { padding: 16px; }
  .article, .prose, .comments { padding: 2px 16px 16px; }
  .cookie-banner { flex-direction: column; align-items: stretch; }
}

@media print {
  .site-header, .site-footer, .ad, .related, .cookie-banner, .toolbar .btn { display: none !important; }
  .calc, .article { box-shadow: none; border: 0; }
  .table-wrap { max-height: none; overflow: visible; }
}
