:root {
  --bg: #f6f7f5;
  --fg: #1a1c1a;
  --muted: #5d625d;
  --card: #ffffff;
  --line: #dfe2dd;
  --accent: #1f6f5c;
  --accent-soft: #e6f2ee;
  --accent-fg: #ffffff;
  --shadow: 0 1px 2px rgba(20, 30, 25, 0.06), 0 4px 16px rgba(20, 30, 25, 0.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131513;
    --fg: #ecefe9;
    --muted: #9ca39b;
    --card: #1c1f1c;
    --line: #313631;
    --accent: #5bc2a6;
    --accent-soft: #182a25;
    --accent-fg: #0d1512;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.25);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
.wrap { max-width: 880px; margin: 0 auto; padding: 0 20px; }

header.site { background: var(--card); border-bottom: 1px solid var(--line); padding: 14px 0; }
header.site a {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--fg); font-weight: 700; font-size: 1.1rem; letter-spacing: -0.01em; text-decoration: none;
}
header.site a::before {
  content: ""; width: 14px; height: 14px; border-radius: 4px; background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

h1 { font-size: 2rem; line-height: 1.2; letter-spacing: -0.02em; margin: 36px 0 10px; }
h2 { font-size: 1.25rem; line-height: 1.3; margin: 40px 0 12px; }
.lead { color: var(--muted); font-size: 1.05rem; margin: 0 0 24px; max-width: 62ch; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  box-shadow: var(--shadow);
}

/* калькулятор: поля слева, результат справа */
.calc { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
@media (min-width: 800px) {
  .calc { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .calc #calc-result { position: sticky; top: 16px; }
}

.row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.row:last-child { margin-bottom: 0; }
label { font-weight: 600; font-size: 0.92rem; }
input, select, textarea {
  font: inherit;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--fg);
  width: 100%; min-width: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { min-height: 160px; line-height: 1.5; resize: vertical; word-spacing: 0.25em; font-variant-numeric: tabular-nums; }
select {
  appearance: none; -webkit-appearance: none; padding-right: 38px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 19px) 50%, calc(100% - 14px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 4px var(--accent);
}

/* результат */
#calc-result { background: var(--accent-soft); border-color: transparent; min-height: 92px; }
#calc-result:empty::before { content: "…"; color: var(--muted); }
#calc-result p {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  margin: 0; padding: 10px 0; border-bottom: 1px solid var(--line);
}
#calc-result p:first-child { padding-top: 0; }
#calc-result p:last-child { border-bottom: 0; padding-bottom: 0; }
#calc-result strong { flex: 0 1 auto; overflow-wrap: break-word; text-align: right; font-size: 1.25rem; line-height: 1.3; color: var(--accent); font-variant-numeric: tabular-nums; }
#calc-result p:first-child strong { font-size: 1.6rem; }
#calc-result ul { margin: 6px 0 0; padding-left: 20px; }
.out-name { color: var(--muted); font-size: 0.95rem; }

.formula {
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 10px; padding: 14px 16px; margin: 0 0 12px;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.93rem; line-height: 1.55;
}

details { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 0 16px; margin-bottom: 8px; }
summary {
  cursor: pointer; font-weight: 600; padding: 13px 0; list-style: none;
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
}
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; color: var(--accent); font-size: 1.4rem; line-height: 1; flex: none; }
details[open] summary::after { content: "−"; }
details p { margin: 0 0 14px; color: var(--muted); }

.note { color: var(--muted); font-size: 0.88rem; margin-top: 36px; }

/* плитки: главная и «связанные» */
ul.tools {
  list-style: none; padding: 0; margin: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px;
}
ul.tools li { margin: 0; }
ul.tools a {
  display: block; height: 100%; padding: 14px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  color: var(--fg); font-weight: 600; font-size: 1rem; line-height: 1.35; text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
ul.tools a:hover, ul.tools a:focus-visible {
  border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); outline: none;
}
ul.tools a::after { content: "\00a0→"; color: var(--accent); }

footer.site { border-top: 1px solid var(--line); margin-top: 56px; padding: 22px 0 44px; color: var(--muted); font-size: 0.9rem; }
footer.site a { color: inherit; margin-left: 12px; }

@media (max-width: 480px) {
  body { font-size: 16px; }
  h1 { font-size: 1.55rem; margin-top: 26px; }
  .card { padding: 16px; }
  #calc-result p:first-child strong { font-size: 1.4rem; }
}

/* баннер согласия: карточка снизу, обе кнопки одинаковые по виду и размеру (отказ так же прост, как согласие) */
.consent {
  position: fixed; z-index: 20; left: 16px; right: 16px; bottom: 16px; max-width: 440px;
  display: flex; flex-direction: column; gap: 14px; padding: 18px 18px 16px;
  background: var(--card); color: var(--fg); font-size: 0.875rem; line-height: 1.5;
  border: 1px solid color-mix(in srgb, var(--fg) 14%, transparent); border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}
.consent-actions { display: flex; gap: 10px; }
.consent-actions button { flex: 1 1 0; }
footer.site button#consent-settings {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; margin-left: 12px;
  text-decoration: underline; cursor: pointer;
}
.consent p { margin: 0; }
.consent a { color: inherit; text-underline-offset: 3px; }
.consent button {
  font: inherit; font-weight: 600; min-height: 44px; padding: 8px 16px; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--fg) 45%, transparent); background: transparent; color: var(--fg); border-radius: 10px;
  transition: background 0.12s;
}
.consent button:hover { background: color-mix(in srgb, var(--fg) 8%, transparent); }
.consent button:focus-visible, footer.site button#consent-settings:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* телефон: короткий результат над формой, крупные зоны нажатия */
@media (max-width: 799px) {
  .calc #calc-result:not(.long) { order: -1; }
  summary { min-height: 48px; }
  footer.site a, footer.site button#consent-settings { display: inline-block; padding: 10px 4px; }
  header.site a { padding-top: 4px; padding-bottom: 4px; }
}

/* поле со единицей справа */
.field { position: relative; }
.field input { padding-right: calc(var(--u, 0ch) + 28px); }
.field .unit {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 0.88rem; font-weight: 500; pointer-events: none; white-space: nowrap;
}

@media (max-width: 799px) {
  header.site > .wrap > a:first-child { min-height: 44px; align-items: center; }
  header.site nav a { min-height: 40px; display: inline-flex; align-items: center; }
}

@media (max-width: 799px) {
  footer.site .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 0 14px; }
  footer.site a, footer.site button#consent-settings { margin-left: 0; }
}

/* флажки, кнопка действия и строки с копированием (generator haseł и др.) */
.row.check { flex-direction: row; align-items: center; gap: 12px; }
.row.check input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; flex: none; padding: 0; accent-color: var(--accent); cursor: pointer; }
.row.check label { font-weight: 500; font-size: 1rem; cursor: pointer; }
.btn {
  font: inherit; font-weight: 700; min-height: 48px; width: 100%; margin-top: 4px; padding: 10px 18px;
  border: 1px solid var(--accent); border-radius: 10px; background: var(--accent); color: var(--accent-fg); cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
#calc-result p.copyline { gap: 10px; }
#calc-result p.copyline code {
  flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; word-break: break-all;
  font: 600 1.02rem/1.45 ui-monospace, Menlo, Consolas, monospace; color: var(--accent);
}
#calc-result p.copyline .copy-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
#calc-result .copy-label { color: var(--muted); font-size: 0.82rem; }
#calc-result p.copyline .copy-body code { font: 500 1.15rem/1.5 system-ui, sans-serif; color: var(--fg); }
#calc-result button.copy {
  flex: none; min-height: 40px; padding: 6px 14px; font: inherit; font-size: 0.9rem; font-weight: 600;
  border: 1px solid var(--accent); border-radius: 8px; background: transparent; color: var(--accent); cursor: pointer;
}
#calc-result button.copy:hover, #calc-result button.copy.done { background: var(--accent); color: var(--accent-fg); }
#calc-result button.copy:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
