:root {
  --brand: #002880;
  --brand-2: #0a3a9e;
  --brand-light: #e6ecf8;
  --bg: #ffffff;
  --tint: #f4f7fb;
  --text: #1a2433;
  --muted: #5b6b82;
  --line: #dde4ef;
  --c-xi: #2e86de;
  --c-o: #27ae60;
  --c-model: #e74c3c;
  --c-source: #e67e22;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0, 40, 128, .08);
  font-family: Inter, Roboto, "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; }
body { margin: 0; color: var(--text); background: var(--bg); line-height: 1.5; }
h1, h2 { line-height: 1.2; margin: 0; }
h2 { font-size: clamp(1.6rem, 2.6vw, 2.2rem); color: var(--brand); }
sub, sup { font-size: .7em; line-height: 0; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

/* Шапка */
.hero { position: relative; color: #fff; min-height: 92vh; display: flex; flex-direction: column; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(1200px 600px at 80% -10%, rgba(46, 134, 222, .35), transparent 60%), linear-gradient(160deg, #002880 0%, #001c5c 100%);
}
.nav { position: relative; display: flex; gap: 12px; padding: 16px 32px; font-weight: 600; }
.pill {
  flex: 1 1 0; text-align: center; padding: 14px 22px; border-radius: 12px; font-size: 1.05rem;
  background: #fff; color: var(--brand); text-decoration: none; transition: background .2s, transform .1s;
}
.pill:hover { background: var(--brand-light); }
.pill:active { transform: translateY(1px); }
.hero__content { position: relative; margin: auto; max-width: 980px; padding: 40px 24px 80px; text-align: center; }
.hero__kicker { text-transform: uppercase; letter-spacing: .12em; font-size: .85rem; opacity: .8; margin: 0 0 14px; }
.hero h1 { font-size: clamp(1.9rem, 4vw, 3.2rem); font-weight: 700; overflow-wrap: break-word; hyphens: auto; }
.hero__lead { font-size: 1.15rem; opacity: .85; margin: 18px auto 34px; max-width: 720px; }

/* Разделы */
.section { padding: 88px 0; }
.section--tint { background: var(--tint); }
.section--brand { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }
.section--brand h2 { color: #fff; text-align: center; }
.section__lead { color: var(--muted); margin: 10px 0 28px; font-size: 1.05rem; }

.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }

/* Кнопки и поля */
.btn {
  display: inline-flex; align-items: center; gap: 8px; border: 0; cursor: pointer;
  background: var(--brand); color: #fff; padding: 10px 20px; border-radius: 10px;
  font: inherit; font-weight: 600; text-decoration: none; transition: background .2s, transform .1s;
}
.btn:hover { background: var(--brand-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn--ghost { background: var(--brand-light); color: var(--brand); }
.btn--ghost:hover { background: #d6e0f3; }
.btn--light { background: #fff; color: var(--brand); padding: 14px 28px; }
.btn--light:hover { background: var(--brand-light); }
.btn--wide { width: 100%; justify-content: center; padding: 12px; }

input[type=range] { accent-color: var(--brand); width: 100%; }
select { font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

/* Графики */
.chart { width: 100%; height: 420px; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 20px; font-size: .95rem; color: var(--muted); margin-bottom: 8px; }
.legend i { display: inline-block; width: 22px; height: 4px; border-radius: 2px; vertical-align: middle; margin-right: 8px; }
.sw--xi { background: var(--c-xi); }
.sw--o { background: var(--c-o); }
.legend i.sw--model { height: 0; border-top: 3px dashed var(--c-model); background: none; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 14px; }
.range { display: flex; align-items: center; gap: 10px; color: var(--muted); min-width: 220px; }
.day { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }

.density { display: grid; grid-template-columns: 1fr 320px; gap: 22px; }
.sliders h3 { font-size: 1rem; margin: 0 0 8px; color: var(--brand); }
.sliders .group { padding: 12px 0; border-bottom: 1px solid var(--line); }
.sliders .group:last-child { border-bottom: 0; }
.slider { display: grid; grid-template-columns: 30px 1fr 42px; align-items: center; gap: 8px; font-size: .9rem; }
.slider output { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* Результаты */
.results { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; margin-top: 36px; }
.result { background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .22); border-radius: var(--radius); padding: 34px 24px; text-align: center; }
.result--live { background: #fff; color: var(--brand); }
.result__value { font-size: clamp(2.4rem, 5vw, 3.4rem); font-weight: 700; font-variant-numeric: tabular-nums; }
.result__name { margin-top: 8px; opacity: .9; }

/* Граф */
.graph { display: grid; grid-template-columns: 1fr 300px; gap: 22px; }
.graph__canvas { padding: 0; overflow: hidden; }
#graphCanvas { width: 100%; height: 520px; display: block; touch-action: pan-y; background: #fbfcfe; }
.graph__panel { display: flex; flex-direction: column; gap: 14px; }
.modes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.modes button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 4px; font: inherit; font-size: .9rem; cursor: pointer; color: var(--text); }
.modes button.is-active { background: var(--brand); color: #fff; border-color: var(--brand); }
.hint { color: var(--muted); font-size: .9rem; margin: 0; min-height: 2.6em; }
.row { display: flex; gap: 8px; }
.row .btn { flex: 1; justify-content: center; }
.field { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: .95rem; }
.graph__result { min-height: 90px; }
.graph__result .big { font-size: 1.25rem; font-weight: 700; color: var(--brand); }
.graph__result .small { color: var(--muted); font-size: .88rem; margin-top: 4px; }
.graph__result .err { color: #b3261e; }

/* Подвал */
.footer { background: #001a55; color: rgba(255, 255, 255, .85); padding: 44px 0; }
.footer__grid { display: flex; gap: 24px; align-items: flex-start; }
.footer p { margin: 0 0 4px; }

@media (max-width: 900px) {
  .density, .graph, .results { grid-template-columns: 1fr; }
  .section { padding: 56px 0; }
  .hero { min-height: 88vh; }
  .chart { height: 320px; }
  #graphCanvas { height: 440px; }
  .day { margin-left: 0; width: 100%; }
  .results { gap: 14px; margin-top: 24px; }
  .result { padding: 24px 18px; }
}

@media (max-width: 560px) {
  .wrap { padding: 0 14px; }
  .section { padding: 44px 0; }
  .section__lead { font-size: .95rem; margin-bottom: 18px; }
  .card { padding: 14px; border-radius: 12px; }

  .nav { flex-wrap: wrap; gap: 6px; padding: 10px 12px; }
  .pill { flex: 1 1 auto; text-align: center; padding: 9px 8px; font-size: .88rem; border-radius: 10px; }

  .hero { min-height: auto; }
  .hero__content { padding: 36px 16px 56px; }
  .hero__kicker { font-size: .72rem; letter-spacing: .08em; }
  .hero h1 { font-size: clamp(1.25rem, 6.4vw, 1.7rem); }
  .hero__lead { font-size: 1rem; margin: 14px auto 26px; }
  .btn--light { padding: 12px 22px; }

  .chart { height: 260px; }
  .legend { gap: 6px 14px; font-size: .85rem; }
  .controls { gap: 10px; }
  .controls .btn { padding: 9px 14px; }
  .range { flex: 1 1 100%; min-width: 0; }

  .sliders .group { padding: 8px 0; }
  .slider { grid-template-columns: 26px 1fr 36px; font-size: .85rem; }
  input[type=range] { height: 28px; }

  .result__value { font-size: 2.3rem; }
  .result__name { font-size: .95rem; }

  #graphCanvas { height: 360px; }
  .modes button { padding: 10px 2px; font-size: .85rem; }
  .field { flex-direction: column; align-items: stretch; gap: 4px; font-size: .9rem; }
  .field select { width: 100%; padding: 8px 10px; }
  .graph__result .big { font-size: clamp(.95rem, 4.6vw, 1.2rem); white-space: nowrap; }
  .graph__result .small { font-size: .82rem; }

  .footer { padding: 32px 0; }
  .footer__grid { flex-direction: column; gap: 14px; }
  .footer p { font-size: .92rem; }
}
