:root {
  --bg: #eef3ec;
  --panel: #ffffff;
  --panel2: #f4f8f2;
  --ink: #17221a;
  --muted: #5b6b5f;
  --line: #d3dfd1;
  --accent: #2f8f3a;
  --accent-ink: #ffffff;
  --accent2: #a6781e;
  --cell-empty: #e3ebe1;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111513;
    --panel: #1a201c;
    --panel2: #151a17;
    --ink: #e7efe8;
    --muted: #96a59a;
    --line: #2b352e;
    --accent: #5cb85c;
    --accent-ink: #0d1a0f;
    --accent2: #d3a94f;
    --cell-empty: #232b25;
  }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.65; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 3px; }
.wrap { width: min(1040px, 100% - 2rem); margin-inline: auto; }

/* Шапка */
.site-header { background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; height: 60px; }
.logo { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.1rem; text-decoration: none; color: var(--ink); letter-spacing: -.01em; }
.logo svg { width: 26px; height: 26px; flex: none; }
.menu { display: flex; gap: 1.3rem; list-style: none; font-size: .95rem; }
.menu a { color: var(--muted); text-decoration: none; }
.menu a:hover, .menu a[aria-current="page"] { color: var(--ink); }

/* Главная */
.hero { padding: 3.5rem 0 2rem; }
.hero h1 { font-size: clamp(1.9rem, 5vw, 3rem); line-height: 1.12; letter-spacing: -.03em; max-width: 20ch; }
.hero p { color: var(--muted); font-size: 1.1rem; max-width: 58ch; margin-top: 1rem; }
.tools-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); padding: 1rem 0 3rem; }
.tcard {
  display: block; background: var(--panel); border: 1px solid var(--line); border-bottom: 4px solid var(--accent);
  border-radius: var(--radius); padding: 1.3rem 1.3rem 1.2rem; text-decoration: none; color: var(--ink);
  transition: transform .12s, border-color .12s;
}
.tcard:hover { transform: translateY(-2px); border-color: var(--accent); }
.tcard .ico { font-size: .8rem; font-weight: 700; letter-spacing: .08em; color: var(--accent2); text-transform: uppercase; }
.tcard h2 { font-size: 1.2rem; margin: .3rem 0 .35rem; letter-spacing: -.01em; }
.tcard p { color: var(--muted); font-size: .94rem; }

/* Страница инструмента */
.page-head { padding: 2.2rem 0 1rem; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: .6rem; }
.crumbs a { color: var(--muted); }
.page-head h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); letter-spacing: -.025em; line-height: 1.15; }
.page-head p { color: var(--muted); margin-top: .6rem; max-width: 62ch; }
.tool { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem; margin: 1rem 0 1.5rem; }
.tool + .tool { margin-top: 0; }
.tool h2 { font-size: 1.05rem; margin-bottom: .9rem; }
.fields { display: grid; gap: .9rem 1rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 1.1rem; }
label.f { display: block; font-size: .82rem; color: var(--muted); font-weight: 600; }
label.f input, label.f select {
  display: block; width: 100%; margin-top: .3rem; padding: .6rem .7rem; font: inherit; font-size: 1rem; color: var(--ink);
  background: var(--panel2); border: 1px solid var(--line); border-radius: 6px;
}
label.f input:focus, label.f select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
label.f input:disabled { opacity: .55; }
.choices { display: flex; flex-wrap: wrap; gap: .5rem 1.2rem; margin-bottom: 1.1rem; font-size: .95rem; }
.choices label { display: flex; align-items: center; gap: .4rem; cursor: pointer; }
.choices input { accent-color: var(--accent); width: 1.05rem; height: 1.05rem; }
.results { display: grid; gap: .5rem; }
.res { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: .65rem .9rem; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; }
.res span { color: var(--muted); font-size: .92rem; }
.res b { font-size: 1.02rem; text-align: right; font-variant-numeric: tabular-nums; }
.res.big { border-color: var(--accent); }
.res.big b { color: var(--accent); font-size: 1.25rem; }
canvas { max-width: 100%; height: auto; display: block; margin: 1rem 0; border: 1px solid var(--line); border-radius: 6px; image-rendering: pixelated; }
details { margin-top: 1rem; }
summary { cursor: pointer; font-weight: 600; font-size: .95rem; }
pre#rows { margin-top: .7rem; max-height: 320px; overflow: auto; padding: .8rem; font-size: .8rem; line-height: 1.5; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; }

.article { max-width: 70ch; padding-bottom: 1rem; }
.article h2 { font-size: 1.3rem; margin: 1.8rem 0 .6rem; letter-spacing: -.015em; }
.article p, .article li { color: var(--muted); }
.article p { margin-bottom: .8rem; }
.article ul, .article ol { padding-left: 1.3rem; margin-bottom: .8rem; }
.article li { margin-bottom: .3rem; }
.article code { background: var(--panel2); border: 1px solid var(--line); padding: .05rem .35rem; border-radius: 4px; font-size: .9em; color: var(--ink); }
table.t { border-collapse: collapse; width: 100%; margin: .5rem 0 1rem; font-size: .92rem; }
table.t th, table.t td { text-align: left; padding: .45rem .7rem; border-bottom: 1px solid var(--line); }
table.t th { color: var(--ink); }
table.t td { color: var(--muted); }
.related { padding: 1.5rem 0 3rem; }
.related h2 { font-size: 1.1rem; margin-bottom: .8rem; }
.related ul { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem; }
.related a { display: block; padding: .45rem .9rem; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--ink); font-size: .92rem; }
.related a:hover { border-color: var(--accent); }

.notfound { min-height: 55vh; display: grid; place-content: center; text-align: center; padding: 3rem 0; }
.notfound .code { font-size: clamp(5rem, 18vw, 9rem); font-weight: 800; letter-spacing: -.05em; line-height: 1; color: var(--accent); }
.notfound p { color: var(--muted); margin: .8rem 0 1.5rem; }
.btn { display: inline-block; padding: .7rem 1.3rem; background: var(--accent); color: var(--accent-ink); border-radius: 6px; font-weight: 700; text-decoration: none; }

.site-footer { border-top: 1px solid var(--line); background: var(--panel); padding: 1.8rem 0; color: var(--muted); font-size: .88rem; }
.site-footer .wrap { display: grid; gap: .8rem; }
.site-footer ul { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--ink); }

@media (max-width: 640px) {
  .logo span { display: none; }
  .res { flex-direction: column; gap: .15rem; }
  .res b { text-align: left; }
}

/* ===== Расширение: иллюстрации, формы, контакты ===== */
.ill { margin: 1.2rem 0 1.6rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.ill svg { display: block; width: 100%; max-width: 620px; height: auto; margin: 0 auto; }
.ill figcaption { color: var(--muted); font-size: .88rem; margin-top: .7rem; text-align: center; }
.ill .a { fill: var(--accent); }
.ill .b { fill: var(--accent2); }
.ill .c { fill: #4f7fbf; }
.ill .d { fill: var(--ink); }
.ill .e { fill: var(--cell-empty); }
.ill .tx { fill: var(--ink); }
.ill .tm { fill: var(--muted); }
.ill .onc { fill: #ffffff; }
.ill .ln { stroke: var(--line); stroke-width: 1; }
.ill .dash { stroke: var(--muted); stroke-width: 1.2; stroke-dasharray: 4 4; }
.ill .curve { stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.ill .curve2 { stroke: var(--accent2); stroke-width: 2.5; stroke-linejoin: round; }
.ill .dot { fill: var(--accent2); stroke: var(--panel); stroke-width: 2; }
.ill .slot { fill: var(--cell-empty); stroke: var(--line); }
.ill .beam { fill: var(--accent2); opacity: .55; }
.ill .c1 { fill: #8fd694; stroke: var(--panel); stroke-width: 1; }
.ill .c2 { fill: #4fa75a; stroke: var(--panel); stroke-width: 1; }
.ill .c3 { fill: #2f7a3a; stroke: var(--panel); stroke-width: 1; }
.article .ill + .ill { margin-top: -.6rem; }

.hero { display: grid; grid-template-columns: 1.3fr .9fr; gap: 2rem; align-items: center; }
.hero-art svg { width: 100%; max-width: 320px; height: auto; display: block; margin-inline: auto; }
.search { margin-top: 1.4rem; width: 100%; max-width: 440px; padding: .75rem 1rem; font: inherit; font-size: 1rem; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; }
.search:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

label.f textarea { display: block; width: 100%; margin-top: .4rem; padding: .7rem; font: inherit; font-size: .95rem; line-height: 1.5; color: var(--ink); background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; resize: vertical; min-height: 9rem; }
label.f textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
label.f input[type="range"] { padding: 0; accent-color: var(--accent); border: 0; background: none; }
.hint { color: var(--muted); font-size: .85rem; margin: -.4rem 0 .8rem; }
.hint code, .tool code { background: var(--panel2); border: 1px solid var(--line); padding: .02rem .3rem; border-radius: 4px; font-size: .9em; }
.tool-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: .2rem 0 1.4rem; }
.btn.sm { padding: .5rem 1rem; font-size: .88rem; border: 1px solid var(--accent); cursor: pointer; font-family: inherit; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--accent); }
.notice { margin-bottom: .6rem; padding: .65rem .9rem; border-left: 4px solid var(--accent2); background: var(--panel2); border-radius: 6px; font-size: .9rem; color: var(--ink); }
.okbox { margin: .3rem 0; padding: .65rem .9rem; border-left: 4px solid var(--accent); background: var(--panel2); border-radius: 6px; font-size: .9rem; }
.res small { color: var(--muted); font-weight: 400; }
h3.sub { font-size: .95rem; margin: .9rem 0 .2rem; color: var(--muted); }
.tablewrap { overflow-x: auto; margin-bottom: .6rem; }
.tablewrap table.t { min-width: 460px; }

.contact-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin: 1rem 0 1.5rem; }
.ccard { display: grid; gap: .3rem; padding: 1.4rem; background: var(--panel); border: 1px solid var(--line); border-bottom: 4px solid var(--accent); border-radius: var(--radius); text-decoration: none; color: var(--ink); transition: transform .12s, border-color .12s; }
.ccard:hover { transform: translateY(-2px); border-color: var(--accent); }
.ccard .ico { font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent2); }
.ccard b { font-size: 1.35rem; letter-spacing: -.01em; word-break: break-word; }
.ccard span:last-child { color: var(--muted); font-size: .92rem; }
.site-footer p a { color: var(--ink); }

@media (max-width: 760px) { .hero { grid-template-columns: 1fr; } .hero-art { order: -1; } .hero-art svg { max-width: 220px; } }
.hero-art .c1 { fill: #8fd694; stroke: var(--bg); stroke-width: 1; }
.hero-art .c2 { fill: #4fa75a; stroke: var(--bg); stroke-width: 1; }
.hero-art .c3 { fill: #2f7a3a; stroke: var(--bg); stroke-width: 1; }

/* ===== Живые визуализации результатов ===== */
.viz { margin-top: 1rem; }
.viz:empty { display: none; }
.viz svg { display: block; width: 100%; height: auto; }
.viz .a { fill: var(--accent); }
.viz .b { fill: var(--accent2); }
.viz .c { fill: #4f7fbf; }
.viz .d { fill: var(--ink); }
.viz .e { fill: var(--cell-empty); }
.viz .bm { fill: var(--muted); opacity: .4; }
.viz .tx { fill: var(--ink); }
.viz .tm { fill: var(--muted); }
.viz .warn { fill: #c0392b; }
@media (prefers-color-scheme: dark) { .viz .warn { fill: #ff7a66; } }
.viz .halo { stroke: var(--panel); stroke-width: 4px; paint-order: stroke; stroke-linejoin: round; }
.viz .ln { stroke: var(--line); stroke-width: 1; }
.viz .dash { stroke: var(--muted); stroke-width: 1.2; stroke-dasharray: 4 4; }
.viz .boxline { fill: none; stroke: var(--line); stroke-width: 1.2; stroke-dasharray: 3 3; }
.viz .scale { stroke: var(--ink); stroke-width: 2; }
.viz .limit { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 3 3; }
.viz .curve { stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.viz .curve2 { stroke: var(--accent2); stroke-width: 2.5; stroke-linejoin: round; }
.viz .dot { fill: var(--accent2); stroke: var(--panel); stroke-width: 2; }
.viz .area { fill: var(--accent); opacity: .22; }
.viz .slot { fill: var(--cell-empty); stroke: var(--line); }
.viz .slot.off { opacity: .35; }
.viz .ghost { fill: none; stroke: var(--muted); stroke-width: 1.2; stroke-dasharray: 4 3; opacity: .7; }
.viz .lay { stroke: var(--panel); stroke-width: 1; }
.viz .beam { fill: var(--accent2); opacity: .55; }
.viz .ring { fill: none; stroke: var(--accent2); stroke-width: 2; }
