/* ============================================================
   minenergy.com.ua — графитовая тема
   Мягкий графит вместо чёрного, светлее поверхности, зелёный
   как цвет энергии, янтарный — как цвет нагрузки.
   ============================================================ */

:root {
  --bg:          #1D2125;
  --bg-soft:     #22272B;
  --surface:     #282D32;
  --surface-2:   #30363B;
  --line:        rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .14);

  --text:  #EEF1EE;
  --muted: #A6AEA9;
  --faint: #7D8681;

  --green:      #5DD39E;
  --green-ink:  #0F2A1E;
  --green-deep: #2E8B63;
  --green-tint: rgba(93, 211, 158, .14);
  --amber:      #F2B45A;
  --amber-tint: rgba(242, 180, 90, .14);
  --alarm:      #EF766A;

  --display: "Geologica", "Segoe UI", system-ui, sans-serif;
  --body:    "Onest", "Segoe UI", system-ui, sans-serif;
  --mono:    "JetBrains Mono", ui-monospace, monospace;

  /* радиусы по иерархии: чем крупнее и важнее блок, тем мягче угол */
  --r-xl: 28px;
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 12px;
  --r-xs: 8px;

  /* тень только у приподнятых блоков: направленная, плюс блик сверху */
  --raise: 0 28px 56px -32px rgba(0, 0, 0, .65), inset 0 1px 0 rgba(255, 255, 255, .05);

  --shell: 1200px;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

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

a { color: inherit; }

.shell {
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 28px;
}

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 24px;
  top: 12px;
  z-index: 50;
  background: var(--green);
  color: var(--green-ink);
  padding: 8px 14px;
  border-radius: 999px;
}

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

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 650;
  letter-spacing: -.025em;
  line-height: 1.1;
  margin: 0;
  /* украинские и русские слова длинные: разрешаем перенос только там,
     где слово физически не влезает, без дефисов посреди заголовка */
  overflow-wrap: break-word;
}

h2 {
  font-size: clamp(28px, 3.2vw, 40px);
  max-width: 22ch;
}

.section-lead {
  color: var(--muted);
  max-width: 60ch;
  margin: 16px 0 0;
  font-size: 18px;
}

section { padding: 96px 0; }

.band { background: var(--bg-soft); }

/* ---------- Кнопки ---------- */

.btn {
  font: inherit;
  font-size: 15.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  transition: background .2s, border-color .2s, color .2s, transform .2s;
}

.btn-primary {
  background: var(--green);
  color: var(--green-ink);
}
.btn-primary:hover { background: #74DDAE; }

.btn-ghost {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--text);
}
.btn-ghost:hover { background: var(--surface-2); }

/* кнопка-инструмент: заметнее призрачной, но не спорит с главной */
.btn-tool {
  background: var(--green-tint);
  border-color: rgba(93, 211, 158, .45);
  color: var(--green);
}
.btn-tool:hover { background: rgba(93, 211, 158, .22); }

.btn-glyph {
  width: 15px;
  height: 15px;
  fill: currentColor;
  opacity: .85;
  flex: none;
}

.btn-danger {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--alarm);
}

/* ---------- Шапка ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(29, 33, 37, .8);
  backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 70px;
}

.mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.mark-glyph {
  width: 30px;
  height: 30px;
  padding: 6px 8px;
  border-radius: 10px;
  background: var(--green-tint);
  fill: var(--green);
}

.mark-word {
  font-family: var(--display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -.02em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 18px;
}

.nav {
  display: flex;
  gap: 4px;
  font-size: 15px;
}

.nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  transition: color .18s, background .18s;
}

.nav a:hover {
  color: var(--text);
  background: var(--surface);
}

/* ссылка на калькулятор: это инструмент, а не раздел со статьями */
.nav a.nav-tool {
  color: var(--green);
  background: var(--green-tint);
}
.nav a.nav-tool:hover { background: rgba(93, 211, 158, .22); }

.langs {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.langs a {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  padding: 5px 11px;
  border-radius: 999px;
  transition: color .18s, background .18s;
}

.langs a:hover { color: var(--text); }

.langs a.is-on {
  background: var(--green-tint);
  color: var(--green);
}

/* ---------- Флеш-сообщения ---------- */

.notices { padding-top: 20px; }

.notice {
  margin: 0 0 10px;
  padding: 12px 18px;
  border-radius: var(--r-sm);
  background: var(--green-tint);
  color: var(--text);
}

.notice-error { background: rgba(239, 118, 106, .16); }

/* ---------- Герой ---------- */

.hero {
  padding: 72px 0 104px;
  background: radial-gradient(1000px 560px at 85% 0%, rgba(93, 211, 158, .10), transparent 70%);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(0, 1.1fr);
  gap: 64px;
  align-items: center;
}

.hero-copy h1 {
  font-size: clamp(38px, 4.6vw, 64px);
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1.03;
  max-width: 16ch;
}

.hero-lead {
  color: var(--muted);
  font-size: 19px;
  max-width: 46ch;
  margin: 26px 0 0;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 36px;
}

/* Карточка устройства: схема, режимы и показания собраны в один виджет,
   как в приложении инвертора, а не разбросаны по колонке. */
.device {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--raise);
  padding: 22px;
}

.device-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.device-title {
  font-family: var(--display);
  font-weight: 500;
  font-size: 15px;
  color: var(--muted);
  margin: 0;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px var(--green-tint);
}

.scenario-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}

.scenario-tab {
  flex: 1 1 auto;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  padding: 9px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .18s, background .18s;
}

.scenario-tab:hover { color: var(--text); }

.scenario-tab[aria-selected="true"] {
  background: var(--green-tint);
  color: var(--green);
}

.hero-diagram { margin: 18px 0 6px; }

.hero-diagram svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.scenario-note {
  margin: 0;
  min-height: 3.2em;
  color: var(--text);
  font-size: 15.5px;
  padding: 0 4px;
}

.readouts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.readout {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.readout-key {
  font-size: 12.5px;
  color: var(--muted);
}

.readout-val {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 24px;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.readout-unit {
  font-size: 12px;
  color: var(--faint);
}

/* Схема */

.wire-base {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 2;
}

.wire-flow {
  fill: none;
  stroke: var(--green);
  stroke-width: 3;
  stroke-dasharray: 2 12;
  stroke-linecap: round;
  opacity: 0;
  transition: opacity .35s;
}

.wire-flow.is-live {
  opacity: 1;
  animation: current 1s linear infinite;
}

.wire-flow.is-reverse { animation-direction: reverse; }
.wire-flow.is-warm { stroke: var(--amber); }
.wire-flow.is-slow { animation-duration: 2.2s; }

@keyframes current {
  to { stroke-dashoffset: -28; }
}

.node rect {
  fill: var(--bg-soft);
  stroke: var(--line-strong);
  stroke-width: 1.5;
  transition: stroke .3s, fill .3s;
}

.node text {
  font-family: var(--display);
  font-size: 17px;
  font-weight: 600;
  fill: var(--text);
}

.node .node-sub {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  fill: var(--muted);
}

.node-core rect { fill: var(--surface-2); }

.node.is-active rect {
  stroke: var(--green);
  fill: #243A30;
}

.node.is-active .node-sub { fill: var(--green); }

.node.is-off rect { stroke: var(--alarm); fill: #3A2A28; }
.node.is-off .node-sub { fill: var(--alarm); }
.node.is-off text { fill: var(--muted); }

.soc-track { fill: var(--line-strong); stroke: none; }

.soc-fill {
  fill: var(--green);
  stroke: none;
  transition: width .7s ease, fill .3s;
}

.soc-fill.is-draining { fill: var(--amber); }

/* ---------- Маршруты: бенто с фото ---------- */

.bento {
  margin-top: 44px;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  grid-auto-rows: minmax(250px, auto);
  gap: 16px;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  min-height: 250px;
  padding: 26px;
  border-radius: var(--r-lg);
  overflow: hidden;
  isolation: isolate;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--raise);
}

.tile-big { grid-row: span 2; min-height: 520px; }
.tile-wide { grid-column: 1 / -1; min-height: 260px; }

.tile picture,
.tile > img {
  position: absolute;
  inset: 0;
  z-index: -2;
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .6s ease;
}

.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(to top,
    rgba(29, 33, 37, .96) 8%,
    rgba(29, 33, 37, .62) 48%,
    rgba(29, 33, 37, .12) 100%);
}

.tile:hover img { transform: scale(1.04); }

.tile-load {
  align-self: flex-start;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--green);
  background: rgba(29, 33, 37, .6);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 5px 12px;
  backdrop-filter: blur(6px);
}

.tile-place {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -.02em;
  line-height: 1.15;
}

.tile-big .tile-place { font-size: 32px; }

.tile-what {
  color: #C9D0CC;
  max-width: 52ch;
  font-size: 16px;
}

.tile-go {
  font-weight: 600;
  font-size: 15px;
  color: var(--green);
}

/* ---------- Этапы заряда: график ---------- */

.chart-card {
  margin-top: 44px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--raise);
  padding: 28px 28px 32px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 8px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend-swatch {
  width: 22px;
  height: 3px;
  border-radius: 2px;
}

.swatch-v { background: var(--green); }
.swatch-i { background: var(--amber); }

.chart svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-zone { fill: rgba(255, 255, 255, .025); }
.chart-zone-alt { fill: rgba(255, 255, 255, .05); }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-split { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 4 5; }
.curve-v { fill: none; stroke: var(--green); stroke-width: 3; stroke-linecap: round; }
.curve-i { fill: none; stroke: var(--amber); stroke-width: 3; stroke-linecap: round; }
.chart-axis { font-family: var(--mono); font-size: 12px; fill: var(--faint); }

.stage-list {
  list-style: none;
  margin: 24px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1.9fr 1fr .8fr;
  gap: 20px;
}

.stage {
  padding-top: 16px;
  border-top: 2px solid var(--line-strong);
}

.stage:first-child { border-color: var(--green); }

.stage-num {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--green);
}

.stage h3 {
  font-size: 19px;
  font-weight: 600;
  margin: 6px 0 8px;
}

.stage p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 15.5px;
}

.stage-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stage-meta span {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
}

/* ---------- Разделы портала ---------- */

.dir-list {
  list-style: none;
  margin: 40px 0 0;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

.dir-row a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-radius: var(--r-sm);
  text-decoration: none;
  transition: background .18s;
}

.dir-row a:hover { background: var(--surface-2); }

.dir-label {
  font-family: var(--display);
  font-size: 17px;
  font-weight: 500;
}

.dir-count {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 3px 10px;
}

/* ---------- Карточки статей ---------- */

.cards {
  margin-top: 40px;
  display: grid;
  /* min(…, 100%) — иначе на узком экране карточка шире контейнера */
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: background .2s, border-color .2s;
}

.card:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
}

.card a {
  display: flex;
  flex-direction: column;
  height: 100%;
  text-decoration: none;
}

.card-cover {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg-soft);
}

.card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .6s ease;
}

.card:hover .card-cover img { transform: scale(1.04); }

.card-body {
  padding: 20px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.card h3 {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -.015em;
  line-height: 1.25;
}

.card p {
  color: var(--muted);
  font-size: 15px;
  margin: 0;
}

.card-meta {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--faint);
}

.pill {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--green);
  background: var(--green-tint);
  border-radius: 999px;
  padding: 3px 10px;
  text-decoration: none;
}

/* ---------- Список статей и раздел ---------- */

.page-head { padding: 56px 0 8px; }

.page-head h1 {
  font-size: clamp(32px, 4vw, 50px);
  max-width: 24ch;
}

.cat-hero {
  position: relative;
  margin-top: 28px;
  min-height: 300px;
  border-radius: var(--r-xl);
  overflow: hidden;
  isolation: isolate;
  display: flex;
  align-items: flex-end;
  padding: 36px;
  border: 1px solid var(--line);
}

.cat-hero picture {
  position: absolute;
  inset: 0;
  z-index: -2;
}

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

.cat-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(to top, rgba(29, 33, 37, .92) 10%, rgba(29, 33, 37, .25) 100%);
}

.cat-hero h1 { max-width: 20ch; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 28px;
}

.filters a {
  font-size: 14.5px;
  color: var(--muted);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  transition: color .18s, background .18s;
}

.filters a:hover { color: var(--text); background: var(--surface-2); }

.filters a.is-on {
  color: var(--green);
  background: var(--green-tint);
  border-color: transparent;
}

.list-wrap { padding: 12px 0 96px; }

.empty {
  color: var(--muted);
  padding: 24px 0 0;
}

.empty a { color: var(--green); }

/* ---------- Страница статьи ---------- */

.article-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 64px;
  align-items: start;
  padding: 48px 0 40px;
}

.article-head h1 {
  font-size: clamp(32px, 4vw, 50px);
  max-width: 24ch;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 18px 0 0;
  font-size: 14px;
  color: var(--faint);
}

.article-cover {
  margin: 32px 0 0;
  border-radius: var(--r-xl);
  overflow: hidden;
  aspect-ratio: 16 / 8;
  border: 1px solid var(--line);
}

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

.article-summary {
  font-size: 20px;
  line-height: 1.6;
  color: var(--text);
  margin: 32px 0 0;
  max-width: 62ch;
}

.article-text {
  max-width: 68ch;
  margin-top: 28px;
  color: #D9DEDA;
  font-size: 18px;
  line-height: 1.75;
}

.article-text h2 {
  font-size: 28px;
  margin: 52px 0 14px;
  scroll-margin-top: 96px;
  /* общий лимит 22ch для секций главной здесь рвёт заголовки раньше колонки */
  max-width: none;
}

.article-text h3 {
  font-size: 21px;
  font-weight: 600;
  margin: 32px 0 10px;
  scroll-margin-top: 96px;
}

.article-text p { margin: 0 0 18px; }
.article-text ul, .article-text ol { padding-left: 24px; margin: 0 0 20px; }
.article-text li { margin-bottom: 8px; }
.article-text li::marker { color: var(--green); }
.article-text strong { color: var(--text); }

.article-text code {
  font-family: var(--mono);
  font-size: 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 1px 7px;
  border-radius: 6px;
}

.article-text blockquote {
  margin: 28px 0;
  padding: 18px 22px;
  background: var(--green-tint);
  border-radius: var(--r-md);
  color: var(--text);
}

.article-text blockquote p:last-child { margin-bottom: 0; }

.article-text blockquote.is-warn { background: var(--amber-tint); }

.table-wrap {
  margin: 24px 0 28px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}

.article-text table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15.5px;
  line-height: 1.5;
}

.article-text th, .article-text td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.article-text th {
  font-weight: 600;
  color: var(--text);
  background: var(--bg-soft);
}

.article-text tr:last-child td { border-bottom: 0; }

/* Оглавление */

.toc {
  position: sticky;
  top: 100px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

.toc-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: 15px;
  margin: 0 0 12px;
}

.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.toc a {
  display: block;
  font-size: 14px;
  line-height: 1.4;
  color: var(--muted);
  text-decoration: none;
  padding: 7px 10px;
  border-radius: var(--r-xs);
  transition: color .18s, background .18s;
}

.toc a:hover { color: var(--text); background: var(--surface-2); }

.related-wrap { padding: 24px 0 96px; }

/* ---------- Подвал ---------- */

.foot {
  background: var(--bg-soft);
  border-top: 1px solid var(--line);
  padding: 64px 0 40px;
}

.foot-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 40px 64px;
}

.foot-word {
  font-family: var(--display);
  font-weight: 700;
  font-size: 19px;
  margin: 0 0 12px;
}

.foot-about p {
  color: var(--muted);
  max-width: 46ch;
  margin: 0;
  font-size: 15.5px;
}

.foot-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 24px;
  align-content: start;
  font-size: 15px;
}

.foot-nav a {
  color: var(--muted);
  text-decoration: none;
  transition: color .18s;
}

.foot-nav a:hover { color: var(--green); }

/* материалы бесплатны, но со ссылкой: стоит на каждой странице */
.foot-free {
  grid-column: 1 / -1;
  margin: 0;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.foot-note {
  grid-column: 1 / -1;
  padding-top: 4px;
  margin: 0;
  color: var(--faint);
  font-size: 13.5px;
}

/* ---------- Админка ---------- */

.admin-wrap { padding: 56px 0 96px; }

.admin-wrap h1 { font-size: 34px; margin-bottom: 26px; }

.admin-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.form-grid {
  display: grid;
  gap: 18px;
  max-width: 780px;
}

.form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 18px;
}

.hint {
  color: var(--faint);
  font-size: 13px;
  line-height: 1.45;
}

label { display: grid; gap: 7px; font-size: 14.5px; color: var(--muted); }

input[type="text"], input[type="password"], input[type="number"],
textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  width: 100%;
}

textarea { min-height: 360px; resize: vertical; line-height: 1.55; }

.check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.check input { width: auto; }

/* галочки в цвет темы, а не системным синим */
input[type="checkbox"] { accent-color: var(--green); width: 17px; height: 17px; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  background: var(--surface);
  border-radius: var(--r-md);
  overflow: hidden;
}

.admin-table th, .admin-table td {
  text-align: left;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.admin-table th { color: var(--muted); font-weight: 500; font-size: 13.5px; }

.tag {
  font-size: 12px;
  border-radius: 999px;
  padding: 3px 10px;
  color: var(--muted);
  background: var(--bg-soft);
}

.tag-live { color: var(--green); background: var(--green-tint); }

.login-card {
  max-width: 420px;
  margin: 80px auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--raise);
  padding: 34px;
}

.login-card h1 { font-size: 26px; margin-bottom: 22px; }

/* ---------- Адаптив ---------- */

@media (max-width: 1080px) {
  .article-shell { grid-template-columns: 1fr; gap: 0; }
  .toc { display: none; }
}

@media (max-width: 980px) {
  .hero-grid { grid-template-columns: 1fr; gap: 48px; }
  .hero-copy h1 { max-width: 18ch; }
  .bento { grid-template-columns: 1fr; }
  .tile-big { grid-row: auto; min-height: 380px; }
  .tile-wide { grid-column: auto; }
  .stage-list { grid-template-columns: 1fr; }
  .dir-list { grid-template-columns: 1fr; }
  .foot-inner { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  /* Шапка в две строки: бренд и язык сверху, разделы — прокручиваемой лентой */
  .topbar-inner {
    flex-wrap: wrap;
    min-height: 0;
    padding: 12px 0 10px;
    gap: 10px;
  }
  .topbar-right {
    width: 100%;
    order: 3;
    justify-content: space-between;
    gap: 10px;
  }
  .nav {
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; padding: 7px 12px; }
}

@media (max-width: 620px) {
  body { font-size: 16px; }
  section { padding: 64px 0; }
  .shell { padding: 0 18px; }
  .hero { padding: 40px 0 64px; }
  .hero-copy h1 { font-size: clamp(30px, 9vw, 44px); }
  .page-head h1, .article-head h1 { font-size: clamp(26px, 7.8vw, 40px); }
  .hero-lead { font-size: 17px; }
  .device { padding: 14px; border-radius: var(--r-lg); }
  .scenario-tab { font-size: 13px; padding: 8px 10px; }
  .readouts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .readout-val { font-size: 21px; }
  .tile { padding: 20px; }
  .tile-place, .tile-big .tile-place { font-size: 22px; }
  .chart-card { padding: 18px; }
  .cat-hero { padding: 22px; min-height: 220px; }
  .article-text { font-size: 17px; }
  .form-row { grid-template-columns: 1fr; }
  .langs a { padding: 4px 9px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .wire-flow.is-live { animation: none; stroke-dasharray: none; opacity: .9; }
  .tile img, .card-cover img { transition: none; }
  .tile:hover img, .card:hover .card-cover img { transform: none; }
  * { transition-duration: .01ms !important; }
}

/* ---------- Калькулятор раскладки панелей ---------- */

.calc-section { padding: 40px 0 72px; }

.calc {
  display: grid;
  grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}

.calc-form {
  display: grid;
  gap: 16px;
}

.calc-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px 20px 22px;
  margin: 0;
  display: grid;
  gap: 14px;
}

.calc-box legend {
  font-family: var(--display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--green);
  padding: 0 10px;
  margin-left: -4px;
}

.calc-box .hint { margin: -4px 0 0; }

.calc-pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(130px, 100%), 1fr));
  gap: 12px;
}

.calc-box input[type="number"], .calc-box input[type="text"] {
  font-family: var(--mono);
  font-size: 15px;
  padding: 11px 12px;
}

.calc-box input:disabled, .calc-box .check input:disabled + * { opacity: .45; }
.calc-box .check:has(input:disabled) { opacity: .45; }

.calc-sub {
  margin: 2px 0 -6px;
  font-size: 13px;
  color: var(--faint);
}

.calc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 13px;
  cursor: pointer;
  transition: color .2s, background .2s, border-color .2s;
}
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip.is-on {
  color: var(--green);
  background: var(--green-tint);
  border-color: rgba(93, 211, 158, .4);
}

.calc-more summary {
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  padding: 4px 0;
}
.calc-more summary:hover { color: var(--text); }
.calc-more .calc-pair { margin-top: 12px; }

.calc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* --- вывод --- */

.calc-out {
  display: grid;
  gap: 18px;
}

.calc-board, .calc-result {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 20px;
}

.calc-board-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.calc-board-title {
  font-family: var(--display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0;
}

.calc-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12.5px;
  color: var(--muted);
}

.lg { display: inline-flex; align-items: center; gap: 7px; }
.lg::before {
  content: "";
  width: 11px;
  height: 11px;
  border-radius: 3px;
  border: 1px solid currentColor;
}
.lg-p { color: var(--green); }
.lg-p::before { background: var(--green-tint); }
.lg-l { color: var(--amber); }
.lg-l::before { background: var(--amber-tint); }
.lg-m { color: var(--faint); }
.lg-m::before { border-style: dashed; background: none; }

.calc-canvas {
  /* grid, а не flex: у SVG с viewBox во flex-контейнере ширина 100%
     разрешается по внутренним пропорциям и схема выходит мелкой */
  display: grid;
  place-items: center;
  min-height: 300px;
  padding: 6px;
  border-radius: var(--r-md);
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(93, 211, 158, .06), transparent 70%),
    var(--bg);
}

.calc-svg {
  width: 100%;
  height: auto;
  max-height: 62vh;
}

.cp-area {
  fill: rgba(255, 255, 255, .035);
  stroke: var(--line-strong);
  stroke-width: 1.5px;
  vector-effect: non-scaling-stroke;
}

.cp-usable {
  fill: none;
  stroke: var(--faint);
  stroke-width: 1px;
  stroke-dasharray: 5 5;
  opacity: .8;
  vector-effect: non-scaling-stroke;
}

.cp-panel {
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
}
.cp-p { fill: rgba(93, 211, 158, .26); stroke: var(--green); }
.cp-l { fill: rgba(242, 180, 90, .26); stroke: var(--amber); }

.cp-dims text {
  fill: var(--muted);
  font-family: var(--mono);
}

.calc-note {
  margin: 12px 0 0;
  font-size: 14px;
  color: var(--amber);
  line-height: 1.5;
}

.calc-big {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr));
  gap: 14px;
  margin: 14px 0 18px;
}

.calc-big-cell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px;
  display: grid;
  gap: 2px;
}

.calc-big-num {
  font-family: var(--mono);
  font-size: 34px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--green);
}

.calc-big-label {
  font-size: 13px;
  color: var(--muted);
}

.calc-rows {
  margin: 0;
  display: grid;
  gap: 0;
}

.calc-rows > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.calc-rows > div:last-child { border-bottom: none; }

.calc-rows dt {
  font-size: 14px;
  color: var(--muted);
}

.calc-rows dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 14.5px;
  text-align: right;
}

/* --- пояснения под калькулятором --- */

.calc-text { padding: 72px 0; }

.calc-text-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  gap: 40px;
}

.calc-text h2 {
  font-size: 24px;
  margin: 0 0 16px;
}

.calc-list {
  margin: 0;
  padding-left: 22px;
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.calc-list::marker, .calc-list li::marker { color: var(--green); }

.calc-disclaimer {
  margin: 20px 0 0;
  padding: 16px 18px;
  border-left: 3px solid var(--amber);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  background: var(--amber-tint);
  font-size: 15px;
  line-height: 1.55;
}

/* на широком экране схема остаётся на виду, пока крутишь длинную форму */
@media (min-width: 981px) {
  .calc-board { position: sticky; top: 84px; }
}

@media (max-width: 980px) {
  .calc { grid-template-columns: 1fr; }
  .calc-svg { max-height: 70vh; }
}

@media (max-width: 620px) {
  .calc-section { padding: 28px 0 56px; }
  .calc-box, .calc-board, .calc-result { padding: 16px; border-radius: var(--r-lg); }
  .calc-canvas { min-height: 240px; }
  .calc-big-num { font-size: 28px; }
  .calc-text { padding: 56px 0; }
}

/* ---------- Калькулятор: перешкоды и тень ---------- */

/* hidden должен побеждать display из .calc-rows > div и .lg */
[hidden] { display: none !important; }

.calc-obst-list {
  display: grid;
  gap: 12px;
}

.calc-obst {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 14px 14px;
  display: grid;
  gap: 10px;
}

.calc-obst-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.calc-obst-top select { flex: 1; padding: 8px 10px; }

.calc-obst-num {
  flex: none;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--alarm);
  color: #2A1613;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
}

.calc-obst-del {
  flex: none;
  font: inherit;
  font-size: 20px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color .2s, border-color .2s;
}
.calc-obst-del:hover { color: var(--alarm); border-color: var(--alarm); }

.calc-obst-shade {
  margin: 0;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--faint);
}

.chip-add {
  color: var(--green);
  border-color: rgba(93, 211, 158, .35);
  background: var(--green-tint);
}
.chip-add:hover { color: var(--green); background: rgba(93, 211, 158, .22); }

/* --- схема --- */

.cp-shade {
  fill: rgba(126, 148, 184, .34);
  stroke: rgba(160, 180, 210, .5);
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
}

.cp-obst {
  fill: var(--alarm);
  fill-opacity: .85;
  stroke: #FFD9D3;
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
}

.cp-obst-margin {
  fill: none;
  stroke: var(--alarm);
  stroke-width: 1px;
  stroke-dasharray: 4 4;
  opacity: .7;
  vector-effect: non-scaling-stroke;
}

.cp-obst-num {
  fill: var(--alarm);
  font-family: var(--mono);
  font-weight: 700;
}

/* панель в тени: считается, но видно, что она под трубой */
.cp-panel.cp-dim {
  fill-opacity: .35;
  stroke-dasharray: 4 3;
}

.cp-side { fill: var(--faint); }

.lg-o { color: var(--alarm); }
.lg-o::before { background: var(--alarm); }
.lg-s { color: #A9BEDC; }
.lg-s::before { background: rgba(126, 148, 184, .45); }

/* ---------- Калькулятор: стринги ---------- */

.calc-msgs {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.calc-msg {
  position: relative;
  padding: 10px 12px 10px 34px;
  border-radius: var(--r-sm);
  font-size: 14px;
  line-height: 1.5;
}

.calc-msg::before {
  position: absolute;
  left: 12px;
  top: 10px;
  font-family: var(--mono);
  font-weight: 700;
}

.calc-msg.is-ok {
  background: var(--green-tint);
  color: var(--text);
}
.calc-msg.is-ok::before { content: "✓"; color: var(--green); }

.calc-msg.is-warn {
  background: var(--amber-tint);
  color: var(--text);
}
.calc-msg.is-warn::before { content: "!"; color: var(--amber); }

.calc-note-quiet {
  color: var(--faint);
  font-size: 13px;
  margin-top: 14px;
}
