/* Единая тема сайта: технический справочник в духе ГОСТ.
   Внешних ресурсов нет — шрифты системные, картинок нет. */

:root {
  color-scheme: light dark;

  --bg:        #f3eee2;
  --surface:   #fbf9f4;
  --surface-2: #ece5d5;
  --text:      #191817;
  --muted:     #544f48;
  --faint:     #7d766c;
  --border:    #ded5c3;
  --border-2:  #c6bba5;
  --rule:      #191817;
  --accent:    #b4291f;
  --accent-2:  #b4291f;
  --warn:      #4a3b1e;
  --warn-bg:   #efe4d4;
  --warn-line: #b4291f;
  --err:       #8c1c14;
  --err-bg:    #f2ded9;

  --radius: 0;
  --cond: "Arial Narrow", "Helvetica Neue Condensed", "Roboto Condensed", "Liberation Sans Narrow", "Nimbus Sans Narrow", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #171614;
    --surface:   #1e1c19;
    --surface-2: #262320;
    --text:      #ece7dc;
    --muted:     #ada598;
    --faint:     #8a8377;
    --border:    #33302a;
    --border-2:  #4a443b;
    --rule:      #ece7dc;
    --accent:    #e0685c;
    --accent-2:  #e0685c;
    --warn:      #dcb677;
    --warn-bg:   #2a2318;
    --warn-line: #b4291f;
    --err:       #e88478;
    --err-bg:    #2d1a17;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15.5px/1.62 var(--sans);
  padding: 0;
  overflow-wrap: break-word;
}

.wrap {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 22px 60px;
  border-left: 5px solid var(--accent);
  min-height: 100vh;
}

/* Длина строки в прозе ограничена — на широком экране иначе не читается. */
.lead { max-width: 62ch; }
.wrap > p { max-width: 78ch; }
.source { max-width: 92ch; }
.note, .alert { max-width: 94ch; }
details .body { max-width: 88ch; }

/* ---------- Шапка и подвал ---------- */

.top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 0 10px;
  border-bottom: 3px double var(--rule);
  margin-bottom: 28px;
  font-family: var(--cond);
  text-transform: uppercase;
  letter-spacing: .1em;
  font-size: 12.5px;
}
.top a.home {
  font-weight: 700;
  letter-spacing: .14em;
  color: var(--text);
  text-decoration: none;
}
.top a.home:hover { color: var(--accent); }
.top .tagline { color: var(--faint); }

footer {
  margin-top: 56px;
  padding-top: 16px;
  border-top: 3px double var(--rule);
  color: var(--muted);
  font-size: 13px;
  max-width: 88ch;
}
footer a { color: var(--muted); }
footer a:hover { color: var(--accent); }

/* ---------- Текст ---------- */

h1 {
  font-family: var(--cond);
  font-weight: 700;
  font-size: 38px;
  line-height: 1.08;
  letter-spacing: .012em;
  text-transform: uppercase;
  margin: 22px 0 12px;
  max-width: 34ch;
}
h2 {
  font-family: var(--cond);
  font-weight: 700;
  font-size: 19px;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 42px 0 12px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--rule);
}
h3 { font-size: 14px; margin: 24px 0 10px; font-weight: 700; }
p  { margin: 0 0 13px; }
a  { color: var(--accent); }

.source {
  font-size: 13.5px;
  color: var(--muted);
  border-left: 3px solid var(--accent);
  padding: 2px 0 2px 12px;
  margin: 0 0 26px;
  line-height: 1.6;
}
.source b { color: var(--text); font-weight: 700; }

/* Рубрика раздела: «§ 1. Отопление» */
.eyebrow {
  font-family: var(--cond);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
  border-bottom: 1px solid var(--accent);
  padding-bottom: 4px;
  margin: 34px 0 0;
}

ul, ol { margin: 0 0 13px; padding-left: 22px; }
li { margin-bottom: 7px; }

code, .num { font-family: var(--mono); font-size: .92em; }

.formula {
  font-family: var(--mono);
  font-size: 13.5px;
  background: var(--surface-2);
  border-left: 3px solid var(--border-2);
  padding: 13px 15px;
  margin: 0 0 15px;
  overflow-x: auto;
  white-space: pre;
  line-height: 1.75;
}

/* ---------- Главная: нумерованный перечень ---------- */

.cards { margin: 0; padding: 0; list-style: none; }
.cards li { margin: 0; border-bottom: 1px solid var(--border); }
.cards a {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 3px 14px;
  padding: 14px 4px 14px 0;
  text-decoration: none;
  color: inherit;
}
.cards a:hover { background: var(--surface-2); }
.cards a:hover .t { color: var(--accent); }
.cards .n {
  grid-column: 1;
  grid-row: 1 / span 3;
  font-family: var(--cond);
  font-weight: 700;
  font-size: 22px;
  line-height: 1.15;
  color: var(--accent);
}
.cards .t { grid-column: 2; font-size: 16.5px; font-weight: 700; }
.cards .d { grid-column: 2; color: var(--muted); font-size: 14.5px; line-height: 1.55; max-width: 82ch; }
.cards .s { grid-column: 2; color: var(--faint); font-size: 12.5px; font-family: var(--mono); margin-top: 3px; }

/* ---------- Форма ---------- */

.form {
  background: var(--surface);
  border: 1px solid var(--border-2);
  padding: 18px 20px 20px;
  margin: 0 0 24px;
}
.form h3:first-child { margin-top: 0; }
.form h3 {
  font-family: var(--cond);
  font-weight: 700;
  color: var(--text);
  font-size: 14px;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.form > p { max-width: 88ch; }

/* На широком экране колонок больше — форма становится короче. */
.grid { display: grid; gap: 15px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .grid.two { grid-template-columns: repeat(auto-fit, minmax(258px, 1fr)); } }

.f { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.f > label { font-size: 13px; color: var(--muted); line-height: 1.4; }
.f > label .hint { display: block; font-size: 12px; color: var(--faint); margin-top: 2px; }

/* Подписи бывают в одну строку и в три — без выравнивания поля ввода
   разъезжаются по высоте. Subgrid даёт всему ряду общую высоту строки подписей;
   там, где его нет, остаётся прежнее поведение. */
/* Поле с длинным списком занимает две колонки — иначе текст варианта обрезается.
   Класс проставляет ui.js по фактической ширине самого длинного варианта. */
@media (min-width: 620px) {
  .grid.two > .f.span2 { grid-column: span 2; }
}

@supports (grid-template-rows: subgrid) {
  @media (min-width: 620px) {
    .grid.two > .f {
      display: grid;
      grid-template-rows: subgrid;
      grid-row: span 2;
      row-gap: 6px;
      align-content: start;
    }
    .grid.two > .f > label { align-self: end; }
  }
}

input[type=number], input[type=text], input[type=search], select {
  font: 15px/1.4 var(--sans);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 0;
  padding: 9px 11px;
  width: 100%;
  min-height: 42px;
  appearance: none;
  font-variant-numeric: tabular-nums;
}
select { background-image: none; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; margin: 0 8px 0 0; accent-color: var(--accent); }

.check { display: flex; align-items: flex-start; font-size: 14px; line-height: 1.45; cursor: pointer; }
.check input { flex: none; margin-top: 3px; }

.unit { color: var(--muted); font-weight: 400; }

button.btn {
  font-family: var(--cond);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: 0;
  padding: 11px 16px;
  min-height: 42px;
  cursor: pointer;
}
button.btn:hover { background: var(--rule); color: var(--bg); }

/* ---------- Строки-повторители ---------- */

.rows { display: grid; gap: 10px; }
.row {
  display: grid;
  gap: 9px;
  grid-template-columns: 1fr;
  align-items: end;
  background: var(--surface-2);
  border-left: 3px solid var(--border-2);
  padding: 11px 12px;
}
@media (min-width: 620px) {
  .row.c5 { grid-template-columns: 1.25fr .8fr .8fr 1.25fr .8fr auto; }
  .row.c4 { grid-template-columns: 1.4fr 1fr 1fr 1fr auto; }
  .row.c3 { grid-template-columns: 1.6fr 1fr 1fr auto; }
}
.row .del {
  justify-self: start;
  background: none;
  border: 1px solid var(--border-2);
  color: var(--faint);
  border-radius: 0;
  min-height: 42px;
  min-width: 42px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.row .del:hover { color: var(--err); border-color: var(--err); }

/* ---------- Результат: рамка с подписной плашкой ---------- */

.res {
  background: var(--surface);
  border: 2px solid var(--rule);
  border-radius: 0;
  padding: 0 0 18px;
  margin: 0 0 22px;
  max-width: 94ch;
}
.res .main {
  font-family: var(--cond);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .14em;
  text-transform: uppercase;
  background: var(--rule);
  color: var(--bg);
  padding: 5px 16px;
  margin-bottom: 16px;
}
.res .big {
  font-family: var(--cond);
  font-weight: 700;
  font-size: 46px;
  line-height: 1.02;
  letter-spacing: .01em;
  padding: 0 18px;
  font-variant-numeric: tabular-nums;
}
.res .big .unit { font-size: 18px; font-family: var(--sans); font-weight: 400; margin-left: 4px; }
.res .sub { margin-top: 12px; padding: 0 18px; font-size: 14px; color: var(--muted); line-height: 1.6; }

table.det { width: calc(100% - 36px); border-collapse: collapse; font-size: 14px; margin: 16px 18px 0; }
table.det th, table.det td { text-align: left; padding: 7px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
table.det th { font-weight: 400; color: var(--muted); }
table.det td { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 12px; font-family: var(--mono); font-size: 13px; }
table.det tr:last-child th, table.det tr:last-child td { border-bottom: none; }

@media (max-width: 430px) {
  table.det td { white-space: normal; }
  table.det th, table.det td { font-size: 12.5px; }
  .res .big { font-size: 40px; }
}

.scroll { overflow-x: auto; }
table.ref { width: 100%; border-collapse: collapse; font-size: 14px; margin: 0 0 15px; border-top: 2px solid var(--rule); }
table.ref th, table.ref td { text-align: left; padding: 7px 12px 7px 0; border-bottom: 1px solid var(--border); }
table.ref th { font-weight: 700; }
table.ref td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-family: var(--mono); font-size: 13px; }

/* ---------- Предупреждения ---------- */

.note, .alert {
  border: 0;
  border-left: 5px solid var(--warn-line);
  border-radius: 0;
  padding: 12px 16px;
  margin: 0 0 18px;
  font-size: 14.5px;
  line-height: 1.6;
}
.note  { background: var(--warn-bg); color: var(--warn); }
.alert { background: var(--err-bg);  color: var(--err); }
.note b, .alert b { font-weight: 700; }
.note:empty, .alert:empty { display: none; padding: 0; margin: 0; border: 0; }
.note p:last-child, .alert p:last-child { margin-bottom: 0; }
.note a, .alert a { color: inherit; }

/* ---------- Раскрывающиеся блоки ---------- */

details {
  background: none;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  margin: 0;
  padding: 0;
  max-width: none;
}
details:first-of-type { border-top: 1px solid var(--border-2); }
details > summary {
  cursor: pointer;
  padding: 13px 0;
  font-family: var(--cond);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .08em;
  text-transform: uppercase;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
  content: "";
  width: 6px; height: 6px;
  border-right: 1.5px solid var(--accent);
  border-bottom: 1.5px solid var(--accent);
  transform: rotate(-45deg);
  transition: transform .15s;
  flex: none;
  margin-left: 2px;
}
details[open] > summary::before { transform: rotate(45deg); }
details > summary:hover { color: var(--accent); }
details .body { padding: 2px 0 18px; font-size: 14.5px; color: var(--text); }
details .body > :last-child { margin-bottom: 0; }
details .body h3 { color: var(--text); font-size: 14px; }

/* ---------- Печать ---------- */

@media print {
  body { background: #fff; color: #000; font-size: 10.5pt; }
  .wrap { border-left: 0; padding: 0; max-width: none; }
  .top, footer, .del, button.btn { display: none; }
  /* Блоки раскрываются перед печатью скриптом (см. ui.js) — здесь только оформление. */
  details { border: none; padding: 0; break-inside: avoid; }
  details > summary { font-size: 12pt; padding: 10px 0 4px; }
  details > summary::before { display: none; }
  .res { border: 2px solid #000; break-inside: avoid; }
  .res .main { background: #000; color: #fff; }
  .form { border: 1px solid #999; }
  .note, .alert { border-left: 4px solid #666; background: none; color: #000; }
  h1, h2, .eyebrow { color: #000; border-color: #000; }
  a { color: #000; text-decoration: none; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 8pt; color: #555; }
}
