/* Математика, которая работает — публичные страницы.
   Идея: тетрадь в клетку. Графит на холодно-белом, синий цвета шариковой ручки только для отметок. */

@font-face {
  font-family: "Onest";
  src: url("/static/fonts/onest-cyrillic.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Onest";
  src: url("/static/fonts/onest-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: oklch(0.985 0.004 250);
  --ink: oklch(0.21 0.012 255);
  --muted: oklch(0.5 0.012 255);
  --line: oklch(0.9 0.008 250);
  --grid: oklch(0.935 0.018 245);
  --accent: oklch(0.46 0.19 266);
  --accent-soft: oklch(0.955 0.03 266);
  --on-ink: oklch(0.99 0.002 250);
  --ok: oklch(0.5 0.12 155);
  --err: oklch(0.5 0.19 28);
  --warn-bg: oklch(0.96 0.05 95);
  --err-bg: oklch(0.96 0.03 28);
  --radius: 0.75rem;
  --ease: cubic-bezier(0.25, 1, 0.5, 1);
  --gutter: clamp(1.25rem, 5vw, 2rem);
  --arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2 8h11M9 3.5 13.5 8 9 12.5' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

/* клетка: только на лендинге, тает к краям */
body.grid::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 1.75rem 1.75rem;
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 15% 25%, #000 10%, transparent 75%);
  mask-image: radial-gradient(ellipse 80% 70% at 15% 25%, #000 10%, transparent 75%);
}

.wrap { width: 100%; max-width: 64rem; margin: 0 auto; padding-inline: var(--gutter); }
.col { max-width: 40rem; }
.col.col-wide { max-width: none; }
main.wrap { flex: 1; padding-block: clamp(1.5rem, 6vh, 3.5rem) 4rem; }
main.hero { padding-top: clamp(2rem, 14vh, 8rem); }

.top .wrap { padding-block: 1.5rem; }
.brand {
  display: inline-flex; align-items: center; gap: 0.6rem;
  color: var(--ink); font-weight: 600; font-size: 0.9375rem; letter-spacing: -0.005em; text-decoration: none;
}
.brand::before { content: ""; width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--accent); }
.top .wide-link { float: right; color: var(--muted); font-size: 0.9375rem; text-decoration: none; }

.foot { color: var(--muted); font-size: 0.875rem; }
.foot .wrap { padding-block: 2.5rem; display: flex; gap: 1.5rem; flex-wrap: wrap; }
.foot a { color: var(--muted); text-underline-offset: 0.2em; text-decoration-color: var(--line); }
.foot a:hover { color: var(--ink); }

/* типографика */
h1, h2, h3 { text-wrap: balance; }
h1 {
  margin: 0 0 1rem;
  font-size: clamp(2.25rem, 8vw, 3.75rem);
  font-weight: 600;
  line-height: 1.04;
  letter-spacing: -0.035em;
}
h1.display { max-width: 12em; font-size: clamp(2.5rem, 10.5vw, 5.25rem); line-height: 1; margin-bottom: 1.5rem; }
h2 { margin: 0 0 0.75rem; font-size: 1.5rem; font-weight: 600; line-height: 1.15; letter-spacing: -0.02em; }
h3 { margin: 0; font-size: 1.125rem; font-weight: 500; letter-spacing: -0.01em; }
p { margin: 0 0 1rem; }
a { color: var(--ink); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent); }
.lead { max-width: 28ch; margin-bottom: 2.25rem; color: var(--muted); font-size: clamp(1.125rem, 4vw, 1.375rem); line-height: 1.4; }
.muted { color: var(--muted); }
.small { font-size: 0.9375rem; }
.meta { color: var(--muted); font-size: 0.9375rem; }
.gap-lg { margin-top: clamp(2.5rem, 8vh, 4rem); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 0.25rem; }

/* кнопки */
.btn {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  width: 100%; min-height: 3.5rem; padding: 0.9rem 1.6rem;
  border: 1px solid var(--ink); border-radius: 999px;
  background: var(--ink); color: var(--on-ink);
  font: inherit; font-size: 1.0625rem; font-weight: 500; line-height: 1.2; text-align: left; text-decoration: none; cursor: pointer;
  transition: background-color 0.25s var(--ease), border-color 0.25s var(--ease), color 0.25s var(--ease);
}
.btn::after {
  content: ""; flex: none; width: 1.1rem; height: 1.1rem; background: currentColor;
  -webkit-mask: var(--arrow) center / contain no-repeat; mask: var(--arrow) center / contain no-repeat;
  transition: transform 0.3s var(--ease);
}
.btn:hover { background: var(--accent); border-color: var(--accent); color: var(--on-ink); }
.btn:hover::after { transform: translateX(0.25rem); }
.btn:active { transform: scale(0.99); }
.btn.secondary { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { border-color: var(--ink); background: transparent; color: var(--ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); min-height: 3rem; padding-inline: 0.25rem; justify-content: flex-start; }
.btn.ghost::after { display: none; }
.btn.ghost:hover { background: transparent; color: var(--ink); border-color: transparent; }
.btn.small-btn { display: inline-flex; width: auto; min-height: 2.25rem; padding: 0.35rem 0.9rem; font-size: 0.9375rem; }
.btn.small-btn::after { display: none; }
.btn[disabled] { opacity: 0.5; cursor: default; }
.btn-row { display: flex; flex-direction: column; gap: 0.5rem; }
@media (min-width: 40rem) {
  .btn { display: inline-flex; width: auto; min-width: 15rem; }
  .btn-row { flex-direction: row; align-items: center; gap: 1rem; }
}

/* формы: поля — линия, как строка в тетради */
label { display: block; margin-bottom: 0.25rem; color: var(--muted); font-size: 0.875rem; font-weight: 500; }
.field { margin-bottom: 1.75rem; }
input[type=text], input[type=number], input[type=password], select {
  width: 100%; min-height: 3rem; padding: 0.5rem 0;
  border: 0; border-bottom: 1px solid var(--ink); border-radius: 0; background: transparent;
  color: var(--ink); font: inherit; font-size: 1.25rem; outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
input::placeholder { color: var(--muted); opacity: 1; }
input:focus, select:focus { border-bottom-color: var(--accent); box-shadow: 0 1px 0 var(--accent); }
select {
  appearance: none; -webkit-appearance: none; padding-right: 1.75rem;
  background: no-repeat right 0.25rem center / 0.75rem
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23666' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.err { margin-top: 0.4rem; color: var(--err); font-size: 0.9375rem; }
.hint { margin-top: 0.4rem; color: var(--muted); font-size: 0.875rem; }
.check { display: flex; gap: 0.75rem; align-items: flex-start; margin: 0; color: var(--ink); font-size: 1rem; font-weight: 400; cursor: pointer; }
.check input { flex: none; width: 1.25rem; height: 1.25rem; margin: 0.2rem 0 0; accent-color: var(--accent); }

.notice { margin: 0 0 1.5rem; padding: 0.9rem 1.1rem; border-radius: var(--radius); background: var(--warn-bg); font-size: 0.9375rem; }
.notice.error { background: var(--err-bg); }

/* выбор времени */
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0 1.75rem; }
.chip {
  position: relative; display: inline-flex; align-items: center; margin: 0; padding: 0.65rem 1.1rem;
  border: 1px solid var(--line); border-radius: 999px; color: var(--ink); font-size: 1rem; font-weight: 400; cursor: pointer;
  transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease);
}
.chip:hover { border-color: var(--ink); }
.chip input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.chip:has(input:checked) { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }

/* группы: строки списка */
.slots { margin: 2.5rem 0 1.5rem; border-bottom: 1px solid var(--line); }
.slot {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.25rem 0; border-top: 1px solid var(--line); color: var(--ink); text-decoration: none;
}
.slot .t { display: block; font-size: 1.375rem; font-weight: 500; letter-spacing: -0.015em; line-height: 1.2; transition: color 0.2s var(--ease); }
.slot .s { display: block; margin-top: 0.2rem; color: var(--muted); font-size: 0.9375rem; }
.slot .go { display: flex; align-items: center; gap: 0.75rem; color: var(--muted); font-size: 0.9375rem; white-space: nowrap; }
.slot .go::after {
  content: ""; width: 1.1rem; height: 1.1rem; background: var(--ink);
  -webkit-mask: var(--arrow) center / contain no-repeat; mask: var(--arrow) center / contain no-repeat;
  transition: transform 0.3s var(--ease), background-color 0.2s var(--ease);
}
.slot:hover .t { color: var(--accent); }
.slot:hover .go::after { background: var(--accent); transform: translateX(0.25rem); }

/* диагностика */
.counter { color: var(--muted); font-size: 0.9375rem; }
.progress { height: 2px; margin: 0.75rem 0 clamp(2rem, 7vh, 3.5rem); background: var(--line); }
.progress div { height: 100%; background: var(--ink); transition: width 0.4s var(--ease); }
.task-text { min-height: 4.5em; margin-bottom: 2rem; font-size: clamp(1.375rem, 5.2vw, 1.75rem); font-weight: 450; line-height: 1.35; letter-spacing: -0.015em; }
#qans { font-size: 2rem; font-weight: 500; letter-spacing: -0.02em; }

/* результат */
.level { font-size: clamp(2.75rem, 12vw, 5rem); font-weight: 600; line-height: 1; letter-spacing: -0.04em; }
.level.solo { margin-bottom: clamp(2rem, 7vh, 3.5rem); }
.lede { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 1.5rem; margin: 0.75rem 0 clamp(2rem, 7vh, 3.5rem); }
.score { margin: 0; color: var(--muted); font-size: 1.125rem; }
.more { font-size: 1.0625rem; color: var(--accent); text-underline-offset: 0.25em; }
.more:hover { color: var(--ink); }

.topic { border-top: 1px solid var(--line); }
.topics-list { border-bottom: 1px solid var(--line); }
.topic > summary, .ans > summary { cursor: pointer; list-style: none; }
.topic > summary::-webkit-details-marker, .ans > summary::-webkit-details-marker { display: none; }
.topic > summary { display: flex; align-items: center; gap: 0.75rem; padding: 1.1rem 0; font-size: 1.1875rem; font-weight: 500; letter-spacing: -0.01em; }
.topic > summary::after {
  content: ""; flex: none; width: 0.75rem; height: 0.75rem; margin-left: auto;
  background:
    linear-gradient(var(--muted), var(--muted)) center / 100% 1.5px no-repeat,
    linear-gradient(var(--muted), var(--muted)) center / 1.5px 100% no-repeat;
  transition: transform 0.3s var(--ease);
}
.topic[open] > summary::after { transform: rotate(45deg); }
.topic > summary:hover { color: var(--accent); }
.tag { display: inline-flex; align-items: center; gap: 0.4rem; margin-left: 0.25rem; color: var(--accent); font-size: 0.875rem; font-weight: 500; }
.tag { flex: none; white-space: nowrap; }
.tag::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--accent); }
@media (max-width: 30rem) {
  .tag { gap: 0; }
  .tag span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
.tasks { margin: 0 0 1.5rem; padding-left: 1.5rem; }
.tasks li { margin-bottom: 1.5rem; padding-left: 0.25rem; text-wrap: pretty; }
.tasks li::marker { color: var(--muted); }
.ans > summary { display: inline-block; margin-top: 0.4rem; color: var(--accent); font-size: 0.9375rem; text-decoration: underline; text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
.ans[open] > summary { color: var(--muted); text-decoration: none; }
.ans > div { margin-top: 0.25rem; font-size: 1.125rem; font-weight: 600; }
.cta { margin-top: clamp(3rem, 10vh, 5rem); }

/* вход */
@keyframes rise { from { opacity: 0; transform: translateY(0.75rem); } to { opacity: 1; transform: none; } }
.rise { animation: rise 0.7s var(--ease) backwards; animation-delay: calc(var(--i, 0) * 70ms); }
@media (prefers-reduced-motion: reduce) {
  .rise { animation: none; }
  * { transition-duration: 0.01ms !important; }
}

/* ---------- админка (внутренний инструмент, без украшений) ---------- */
.wide h1 { font-size: 2rem; letter-spacing: -0.025em; }
.wide h2 { margin-top: 2.5rem; font-size: 1.25rem; }
.wide label { color: var(--ink); }
.wide input[type=text], .wide input[type=number], .wide input[type=password], .wide select {
  min-height: 2.25rem; padding: 0.25rem 0.6rem; border: 1px solid var(--line); border-radius: 0.5rem; font-size: 0.9375rem; box-shadow: none;
}
.wide select { padding-right: 1.75rem; background-position: right 0.6rem center; width: auto; }
.card { padding: 1rem 1.1rem; margin-bottom: 0.75rem; border: 1px solid var(--line); border-radius: var(--radius); }
.card .row { display: flex; justify-content: space-between; gap: 0.75rem; align-items: baseline; flex-wrap: wrap; }
.divider { margin: 2rem 0; border: 0; border-top: 1px solid var(--line); }
.funnel { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem; margin-bottom: 0.5rem; }
@media (min-width: 50rem) { .funnel { grid-template-columns: repeat(auto-fit, minmax(6.25rem, 1fr)); } }
.funnel .step { padding: 0.8rem; border: 1px solid var(--line); border-radius: var(--radius); }
.funnel .n { font-size: 1.75rem; font-weight: 600; line-height: 1.1; }
.funnel .t { margin-top: 0.25rem; color: var(--muted); font-size: 0.8125rem; }
.funnel .c { min-height: 1.3em; margin-top: 0.4rem; color: var(--accent); font-size: 0.8125rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
th, td { padding: 0.5rem 0.65rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; }
th { color: var(--muted); font-size: 0.8125rem; font-weight: 400; }
td.num, th.num { text-align: center; }
td.has { background: var(--accent-soft); font-weight: 600; }
td.gap { background: var(--warn-bg); font-weight: 600; }
.bar { width: 5rem; height: 6px; border-radius: 3px; background: var(--line); }
.bar div { height: 100%; border-radius: 3px; background: var(--accent); }
table input[type=number] { width: 4rem; }
.admin-nav { display: flex; gap: 1.25rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.legend { margin-top: 0.5rem; color: var(--muted); font-size: 0.8125rem; }
