@font-face {
  font-family: "Ubuntu Local";
  src: url("../vendor/fonts/Ubuntu-Variable.ttf") format("truetype");
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
}

@font-face {
  font-family: "Ubuntu Mono Local";
  src: url("../vendor/fonts/UbuntuMono-Variable.ttf") format("truetype");
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #f4f1e8;
  --surface: #fffdf7;
  --ink: #17201c;
  --muted: #687169;
  --line: #d9d5c9;
  --green: #185b43;
  --green-2: #0f4532;
  --mint: #dceade;
  --amber: #f0b44b;
  --shadow: 0 16px 45px rgba(35, 42, 35, .08);
  --radius: 18px;
  --max: 1040px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --paper: #111713;
  --surface: #18201b;
  --ink: #edf3ed;
  --muted: #aab5ac;
  --line: #354039;
  --green: #66c29a;
  --green-2: #9cddbd;
  --mint: #233b2e;
  --amber: #f3bd59;
  --shadow: 0 16px 45px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Ubuntu Local", Ubuntu, ui-sans-serif, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input { font: inherit; }
a { color: inherit; }
.skip-link { position: fixed; z-index: 100; top: -60px; left: 12px; background: var(--ink); color: var(--paper); padding: 9px 14px; border-radius: 8px; }
.skip-link:focus { top: 10px; }

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 68px;
  padding: 8px max(18px, calc((100vw - var(--max)) / 2));
  border-bottom: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(14px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; width: max-content; text-decoration: none; line-height: 1.05; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--green); color: var(--surface); font-family: Georgia, serif; font-size: 27px; }
.brand b { display: block; letter-spacing: .06em; }
.brand small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.main-nav { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.main-nav a { padding: 7px 14px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 700; }
.main-nav a.active { background: var(--mint); color: var(--green-2); }
.icon-button { justify-self: end; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); cursor: pointer; }

.search-shell { position: relative; z-index: 25; width: min(calc(100% - 32px), 680px); margin: 20px auto 14px; }
.search-box { display: flex; align-items: center; gap: 10px; padding: 0 13px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 8px 28px rgba(35, 42, 35, .05); }
.search-box:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 15%, transparent); }
.search-box > span { color: var(--green); font-size: 24px; transform: rotate(-15deg); }
.search-box input { width: 100%; padding: 13px 2px; border: 0; outline: 0; color: var(--ink); background: transparent; }
.search-box kbd { padding: 1px 7px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; color: var(--muted); background: var(--paper); font-size: 12px; }
.search-results { position: absolute; top: calc(100% + 7px); right: 0; left: 0; max-height: min(62vh, 520px); overflow: auto; padding: 7px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.search-result { display: block; padding: 10px 12px; border-radius: 10px; text-decoration: none; }
.search-result:hover, .search-result:focus { background: var(--mint); outline: 0; }
.search-result b { display: block; color: var(--green-2); font-size: 13px; }
.search-result span { font-size: 14px; }
.search-empty { padding: 14px; color: var(--muted); text-align: center; }

main { width: min(calc(100% - 32px), var(--max)); margin: 0 auto; padding-bottom: 60px; }
.home-hero { margin: clamp(40px, 9vh, 90px) 0 28px; text-align: center; }
.home-hero h1 { font-size: clamp(40px, 8vw, 68px); }
.home-ticket-grid { display: grid; grid-template-columns: repeat(5, minmax(70px, 1fr)); gap: 12px; max-width: 720px; margin: 0 auto; }
.home-ticket { display: grid; place-items: center; min-height: 86px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--green-2); text-decoration: none; box-shadow: 0 7px 20px rgba(35, 42, 35, .035); transition: transform .12s ease, border-color .12s ease, background .12s ease; }
.home-ticket span { font-family: "Ubuntu Mono Local", monospace; font-size: 27px; font-weight: 800; }
.home-ticket:hover, .home-ticket:focus-visible { border-color: var(--green); background: var(--mint); outline: 0; transform: translateY(-2px); }
.home-formulas { display: block; width: max-content; margin: 24px auto 0; padding: 10px 18px; border: 1px solid var(--green); border-radius: 12px; color: var(--green); text-decoration: none; font-weight: 800; }
.back-home { display: inline-block; margin-bottom: 13px; color: var(--green); text-decoration: none; font-size: 14px; font-weight: 800; }
.ticket-rail-wrap { display: grid; grid-template-columns: 34px minmax(0, 1fr) 34px; align-items: center; gap: 5px; }
.ticket-rail { display: flex; gap: 7px; overflow-x: auto; padding: 7px 2px 10px; scrollbar-width: none; scroll-snap-type: x proximity; }
.ticket-rail::-webkit-scrollbar { display: none; }
.ticket-chip { flex: 0 0 42px; height: 38px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--muted); cursor: pointer; scroll-snap-align: center; font-family: "Ubuntu Mono Local", monospace; font-weight: 800; }
.ticket-chip:hover { border-color: var(--green); color: var(--green); }
.ticket-chip.active { border-color: var(--green); background: var(--green); color: var(--surface); }
.rail-arrow { width: 34px; height: 34px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; font-size: 24px; }
.rail-arrow:hover { background: var(--mint); color: var(--green-2); }

.ticket-head, .formula-hero { margin: 34px 0 20px; }
.ticket-head { display: block; }
.eyebrow { margin: 0 0 6px; color: var(--green); font-family: "Ubuntu Mono Local", monospace; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(36px, 7vw, 64px); line-height: 1.02; letter-spacing: -.035em; }
.ticket-summary { max-width: 720px; margin: 10px 0 0; color: var(--muted); }
.progress { height: 3px; margin-bottom: 18px; overflow: hidden; border-radius: 99px; background: var(--line); }
.progress span { display: block; width: 4%; height: 100%; background: var(--amber); transition: width .25s ease; }

.answer-list { display: grid; gap: 14px; }
.answer-card { width: 100%; max-width: 100%; overflow: clip; scroll-margin-top: 82px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 8px 24px rgba(35, 42, 35, .035); }
.answer-card:target { border-color: var(--amber); box-shadow: 0 0 0 3px color-mix(in srgb, var(--amber) 20%, transparent); }
.question-row { display: grid; grid-template-columns: 45px 1fr auto; align-items: start; gap: 13px; padding: 20px 20px 14px; }
.question-row > div { min-width: 0; }
.question-number { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: var(--mint); color: var(--green-2); font-family: "Ubuntu Mono Local", monospace; font-size: 20px; font-weight: 700; }
.question-label { margin: 0 0 2px; color: var(--muted); font-family: "Ubuntu Mono Local", monospace; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.question-row h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(20px, 4vw, 27px); line-height: 1.25; }
.anchor-link { padding: 5px; color: var(--muted); text-decoration: none; opacity: .6; }
.details-body { min-width: 0; overflow-x: auto; padding: 2px 20px 24px 78px; color: color-mix(in srgb, var(--ink) 92%, var(--muted)); }
.full-answer { padding-top: 0; }
.full-answer > h3:first-child { margin-top: 0; }
.details-body h3 { margin: 1.25em 0 .45em; font-size: 15px; }
.details-body ul, .details-body ol { padding-left: 22px; }
.details-body li + li { margin-top: 5px; }
.solution-steps { margin: 8px 0 20px; padding-left: 32px !important; }
.solution-steps li { padding-left: 7px; }
.solution-steps li + li { margin-top: 12px; }
.solution-steps li::marker { color: var(--green); font-family: "Ubuntu Mono Local", monospace; font-weight: 800; }
.question-beginner-toggle { margin-top: 18px; padding: 10px 13px; border: 1px solid var(--green); border-radius: 10px; background: transparent; color: var(--green); cursor: pointer; font-weight: 800; }
.question-beginner-toggle[aria-expanded="true"] { background: var(--mint); }
.beginner-block { margin-top: 22px; padding: clamp(16px, 3vw, 24px); border: 1px solid color-mix(in srgb, var(--amber) 60%, var(--line)); border-radius: 13px; background: color-mix(in srgb, var(--amber) 8%, var(--surface)); }
.beginner-block[hidden] { display: none; }
.beginner-block h3 { margin-top: 0; color: var(--green-2); }
.beginner-block h4 { margin: 24px 0 9px; color: var(--green-2); font-size: 15px; }
.beginner-heading { padding-bottom: 12px; border-bottom: 1px solid color-mix(in srgb, var(--amber) 45%, var(--line)); }
.beginner-heading span { display: block; margin-bottom: 5px; color: var(--muted); font-family: "Ubuntu Mono Local", monospace; font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.beginner-heading h3 { margin-bottom: 0; font-family: Georgia, "Times New Roman", serif; font-size: 23px; }
.beginner-plan { margin: 0; padding-left: 28px !important; }
.beginner-plan li { padding-left: 5px; }
.beginner-plan li + li { margin-top: 9px; }
.beginner-plan li::marker { color: var(--green); font-weight: 800; }
.beginner-step-notes { padding-left: 25px; }
.beginner-step-notes li + li { margin-top: 12px; }
.beginner-walkthrough { display: grid; gap: 10px; margin: 0; padding: 0 !important; list-style: none; counter-reset: beginner-step; }
.beginner-walkthrough > li { counter-increment: beginner-step; padding: 14px; border: 1px solid var(--line); border-radius: 11px; background: color-mix(in srgb, var(--surface) 88%, var(--mint)); }
.beginner-walkthrough > li::before { content: "Шаг " counter(beginner-step); display: inline-block; margin-bottom: 7px; color: var(--green); font-family: "Ubuntu Mono Local", monospace; font-size: 12px; font-weight: 800; text-transform: uppercase; }
.beginner-walkthrough p { margin: 0; }
.beginner-walkthrough p + p { margin-top: 8px; }
.walkthrough-action { color: var(--ink); }
.walkthrough-reason { padding-top: 8px; border-top: 1px dashed var(--line); color: var(--muted); }
.beginner-warning { margin-top: 22px; padding: 13px 14px; border-left: 4px solid var(--amber); border-radius: 8px; background: color-mix(in srgb, var(--amber) 13%, var(--surface)); }
.katex-display { margin: .8em 0; overflow-x: auto; overflow-y: hidden; padding: 4px 0; text-align: left; }
.katex-display > .katex { text-align: left; }
.katex { font-size: 1.05em; }

.ticket-pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 20px; }
.ticket-pager a { flex: 1 1 0; padding: 15px; border: 1px solid var(--line); border-radius: 13px; color: var(--green); background: var(--surface); text-decoration: none; font-weight: 800; }
.ticket-pager a:last-child { text-align: right; }

.formula-hero { max-width: 790px; }
.formula-hero p:last-child { color: var(--muted); font-size: 18px; }
.formula-jump { display: flex; gap: 7px; overflow-x: auto; padding: 6px 0 14px; scrollbar-width: none; }
.formula-jump a { flex: 0 0 auto; padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--green); text-decoration: none; font-size: 13px; font-weight: 800; }
.formula-grid { columns: 2 420px; column-gap: 14px; }
.formula-card { break-inside: avoid; margin: 0 0 14px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.formula-card h2 { margin: 0 0 10px; font-family: Georgia, serif; font-size: 23px; }
.formula-card .formula-line { overflow-x: auto; padding: 8px 0; border-top: 1px dashed var(--line); }
.formula-card .formula-line:first-of-type { border-top: 0; }
.formula-note { margin-top: 8px; color: var(--muted); font-size: 13px; }
.verification-note { margin-top: 22px; padding: 20px; border: 1px solid var(--line); border-left: 4px solid var(--green); border-radius: 14px; background: var(--surface); }
.verification-note h2 { margin: 0 0 8px; font-family: Georgia, serif; }
.verification-note p { margin: 6px 0; color: var(--muted); }
.verification-note a { color: var(--green); font-weight: 700; }
.to-top { position: fixed; right: 18px; bottom: max(18px, env(safe-area-inset-bottom)); z-index: 20; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--green); box-shadow: var(--shadow); cursor: pointer; opacity: 0; pointer-events: none; transform: translateY(8px); transition: .2s; }
.to-top.visible { opacity: 1; pointer-events: auto; transform: none; }

@media (max-width: 720px) {
  .topbar { grid-template-columns: 1fr auto; min-height: 54px; padding: 6px 16px; background: var(--paper); backdrop-filter: none; }
  .main-nav { position: fixed; right: 12px; bottom: max(10px, env(safe-area-inset-bottom)); left: 12px; z-index: 40; justify-content: stretch; box-shadow: var(--shadow); }
  .main-nav a { flex: 1; text-align: center; }
  .brand small { display: none; }
  .icon-button { grid-column: 2; }
  .search-shell { margin-top: 9px; margin-bottom: 5px; }
  .search-box input { padding-top: 10px; padding-bottom: 10px; }
  .search-box kbd { display: none; }
  main { width: min(calc(100% - 20px), var(--max)); padding-bottom: 100px; }
  .ticket-head { display: block; margin: 14px 0 14px; }
  .ticket-head .eyebrow, .ticket-summary { display: none; }
  .ticket-head h1 { font-size: 38px; }
  .home-hero { margin: 28px 0 20px; }
  .home-ticket-grid { grid-template-columns: repeat(5, minmax(48px, 1fr)); gap: 8px; }
  .home-ticket { min-height: 62px; border-radius: 12px; }
  .home-ticket span { font-size: 21px; }
  .question-row { grid-template-columns: 38px 1fr; gap: 10px; padding: 16px 14px 10px; }
  .question-number { width: 36px; height: 36px; border-radius: 11px; font-size: 18px; }
  .anchor-link { display: none; }
  .details-body { padding: 2px 14px 20px; }
  .katex { font-size: 1em; }
  .formula-grid { columns: 1; }
  .to-top { bottom: 74px; }
}

@media print {
  .topbar, .search-shell, .ticket-rail-wrap, .head-actions, .ticket-pager, .to-top, .main-nav { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  main { width: 100%; padding: 0; }
  .answer-card, .formula-card { break-inside: avoid; box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition: none !important; } }
