/* QaltaLab — светлая тема по умолчанию, тёмная переключателем.
   Минимализм здесь не стиль ради стиля: на экране должны выделяться числа,
   которые измерил школьник, а не рамки и тени вокруг них. */

:root,
:root[data-theme="light"] {
  --bg: #FFFFFF;
  --bg-soft: #F6F7F9;
  --surface: #FFFFFF;
  --surface-2: #F2F4F7;
  --line: #E7E9EE;
  --line-soft: #F0F2F5;

  --text: #0E1420;
  --text-2: #5A6373;
  --text-3: #8A93A3;

  --accent: #2563EB;
  --accent-ink: #1D4ED8;
  --accent-soft: #EEF3FF;

  --ok: #0F9D6E;
  --ok-soft: #E9F8F2;
  --warn: #B4750B;
  --warn-soft: #FFF6E6;
  --bad: #D33A3A;
  --bad-soft: #FDEDED;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 6px 24px rgba(16, 24, 40, .07);

  --r-lg: 18px;
  --r-md: 13px;
  --r-sm: 9px;

  --pad: 20px;
  --safe-b: env(safe-area-inset-bottom, 0px);

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

  --ease: cubic-bezier(.22, .61, .36, 1);
  --fast: .16s var(--ease);
  --mid: .26s var(--ease);
}

:root[data-theme="dark"] {
  --bg: #0E1116;
  --bg-soft: #141922;
  --surface: #151A22;
  --surface-2: #1D242F;
  --line: #262E3B;
  --line-soft: #1E2530;

  --text: #F1F4F9;
  --text-2: #A3ADBE;
  --text-3: #79849A;

  --accent: #6B9BFF;
  --accent-ink: #9CBEFF;
  --accent-soft: #17233A;

  --ok: #3BD39B;
  --ok-soft: #10281F;
  --warn: #E3A94A;
  --warn-soft: #2A2113;
  --bad: #F07070;
  --bad-soft: #2B1717;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 8px 28px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background var(--mid), color var(--mid);
}

button { font: inherit; color: inherit; }

::selection { background: var(--accent-soft); }

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

#app {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 var(--pad) calc(56px + var(--safe-b));
}

/* ======================= шапка ======================= */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0 10px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  background: none;
  border: 0;
  padding: 4px;
  margin: -4px;
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: opacity var(--fast);
}
.brand:hover { opacity: .72; }

.brand__mark { width: 24px; height: 24px; display: block; flex: none; transition: transform var(--mid); }
.brand:hover .brand__mark { transform: rotate(-10deg); }
.brand__mark .mk-bg { fill: var(--accent); transition: fill var(--mid); }
.brand__mark .mk-fg { stroke: var(--bg); transition: stroke var(--mid); }

.brand__name {
  font-weight: 650;
  font-size: 16.5px;
  letter-spacing: -.3px;
}

.topbar__right { display: flex; align-items: center; gap: 8px; }

.segmented {
  display: flex;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 2px;
}
.segmented button {
  border: 0;
  background: none;
  color: var(--text-3);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .3px;
  padding: 6px 11px;
  border-radius: 999px;
  cursor: pointer;
  min-height: 30px;
  transition: color var(--fast), background var(--fast);
}
.segmented button:hover { color: var(--text-2); }
.segmented button.is-on {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--fast), color var(--fast), transform var(--fast);
}
.icon-btn:hover { color: var(--text); }
.icon-btn:active { transform: scale(.9); }
.icon-btn svg { width: 16px; height: 16px; display: block; }

/* ======================= общее ======================= */

.content > * { animation: rise .34s var(--ease) both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.hero { padding: 26px 0 4px; }
.hero h1 {
  font-size: clamp(30px, 8vw, 42px);
  line-height: 1.1;
  letter-spacing: -1px;
  font-weight: 700;
  margin: 0 0 14px;
}
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p {
  margin: 0;
  color: var(--text-2);
  font-size: 16px;
  line-height: 1.6;
  max-width: 44ch;
}

.section-title {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .9px;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 34px 0 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
}

.note { font-size: 13px; color: var(--text-3); line-height: 1.55; margin: 14px 0 0; }

/* ======================= счётчик ======================= */

.score {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-soft);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  margin-top: 26px;
}
.score__n {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  letter-spacing: -1px;
  flex: none;
}
.score__t { font-size: 13.5px; color: var(--text-2); line-height: 1.5; }

/* ======================= карточки опытов ======================= */

.labs { display: grid; gap: 10px; }

.labcard {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 14px;
  align-items: start;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  cursor: pointer;
  transition: border-color var(--fast), box-shadow var(--fast), transform var(--fast);
  animation: rise .4s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 55ms);
}
.labcard:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.labcard:active { transform: translateY(0) scale(.995); }

.labcard__icon {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  font-size: 18px;
  border-radius: 11px;
  background: var(--surface-2);
  transition: background var(--fast);
}
.labcard:hover .labcard__icon { background: var(--accent-soft); }

.labcard__t { font-weight: 650; font-size: 16px; margin: 1px 0 4px; letter-spacing: -.2px; }
.labcard__s { color: var(--text-2); font-size: 14px; line-height: 1.5; }
.labcard__meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }

.tag {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-3);
  white-space: nowrap;
}
.tag--gear { color: var(--accent-ink); background: var(--accent-soft); }
.tag--done { color: var(--ok); background: var(--ok-soft); }

.labcard--soon { cursor: default; background: var(--bg-soft); border-color: transparent; }
.labcard--soon:hover { border-color: transparent; box-shadow: none; transform: none; }
.labcard--soon .labcard__t { color: var(--text-2); }
.labcard--soon .labcard__s { color: var(--text-3); }

/* ======================= научная основа ======================= */

.sources { display: grid; }
.src {
  padding: 15px 0;
  border-top: 1px solid var(--line-soft);
  animation: rise .4s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}
.src:first-child { border-top: 0; padding-top: 0; }
.src__t { font-size: 14.5px; font-weight: 600; line-height: 1.45; }
.src__w { font-size: 13px; color: var(--accent-ink); margin-top: 3px; }
.src__d { font-size: 13px; color: var(--text-3); line-height: 1.55; margin-top: 5px; }

/* ======================= шаги ======================= */

.steps { display: flex; gap: 5px; margin: 12px 0 22px; }
.steps i {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: var(--line);
  transition: background var(--mid);
}
.steps i.is-on { background: var(--accent); }
.steps i.is-done { background: var(--text-3); }

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 0;
  color: var(--text-3);
  font-size: 14px;
  padding: 10px 0;
  cursor: pointer;
  transition: color var(--fast);
}
.back:hover { color: var(--text); }

.lab-h {
  font-size: clamp(22px, 6vw, 27px);
  line-height: 1.2;
  letter-spacing: -.6px;
  margin: 2px 0 10px;
}
.lab-q { color: var(--text-2); font-size: 15.5px; line-height: 1.6; margin: 0 0 16px; }

/* ======================= кнопки ======================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--r-md);
  padding: 13px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  min-height: 48px;
  transition: transform var(--fast), background var(--fast), border-color var(--fast), opacity var(--fast);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.985); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn--wide { width: 100%; }
.btn:disabled { opacity: .4; cursor: default; }
.btn--primary:disabled:hover { background: var(--accent); border-color: var(--accent); }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* ======================= гипотеза ======================= */

.hyp { display: grid; gap: 9px; }
.hyp button {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 15px 16px;
  font-size: 15px;
  line-height: 1.5;
  cursor: pointer;
  transition: border-color var(--fast), background var(--fast), color var(--fast), transform var(--fast);
  animation: rise .35s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 50ms);
}
.hyp button:hover { border-color: var(--text-3); }
.hyp button:active { transform: scale(.995); }
.hyp button.is-on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

/* ======================= измерение ======================= */

.readout {
  font-family: var(--mono);
  font-size: clamp(38px, 13vw, 58px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -2px;
  text-align: center;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  transition: color var(--mid);
}
.readout small {
  font-size: 17px;
  color: var(--text-3);
  font-weight: 600;
  letter-spacing: 0;
  margin-left: 3px;
}

.pad {
  margin-top: 4px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  min-height: 220px;
  display: grid;
  place-items: center;
  padding: 22px 18px;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: background var(--mid), border-color var(--mid);
}
.pad--go { background: var(--ok-soft); border-color: var(--ok); }
.pad--early { background: var(--bad-soft); border-color: var(--bad); }
.pad--early .readout { color: var(--bad); }
.pad__hint { color: var(--text-3); font-size: 14px; line-height: 1.5; margin-top: 10px; }

.targets { display: grid; gap: 8px; width: 100%; margin-top: 16px; }
.targets button {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: var(--r-md);
  min-height: 56px;
  cursor: pointer;
  font-size: 20px;
  color: var(--text-3);
  transition: background .1s var(--ease), color .1s var(--ease), border-color .1s var(--ease), transform .1s var(--ease);
}
.targets button.is-target {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
  transform: scale(1.03);
}

/* ======================= график ======================= */

.chart {
  width: 100%;
  display: block;
  border-radius: var(--r-md);
  background: var(--bg-soft);
  touch-action: pan-y;
  margin-bottom: 4px;
}

/* ======================= подгонка ======================= */

.models { display: flex; gap: 7px; flex-wrap: wrap; margin: 16px 0 6px; }
.models button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-family: var(--mono);
  cursor: pointer;
  min-height: 38px;
  transition: border-color var(--fast), color var(--fast), background var(--fast);
}
.models button:hover { border-color: var(--text-3); }
.models button.is-on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.slider { margin: 16px 0; }
.slider__top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  color: var(--text-3);
  margin-bottom: 4px;
}
.slider__val {
  font-family: var(--mono);
  color: var(--text);
  font-size: 14.5px;
  font-variant-numeric: tabular-nums;
}

input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  background: none;
  cursor: pointer;
  margin: 0;
}
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--line); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  margin-top: -9px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--fast);
}
input[type=range]:active::-webkit-slider-thumb { transform: scale(1.12); }
input[type=range]::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
}

.match { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.match__n {
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  min-width: 4.2ch;
  letter-spacing: -1.5px;
  font-variant-numeric: tabular-nums;
  transition: color var(--mid);
}
.match__bar { flex: 1; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.match__bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: var(--accent);
  transition: width var(--mid), background var(--mid);
}
.match__t { font-size: 13.5px; color: var(--text-3); line-height: 1.5; margin-top: 8px; }

/* ======================= карточка открытия ======================= */

.law {
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  padding: 28px 22px;
  text-align: center;
  animation: pop .5s var(--ease) both;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to   { opacity: 1; transform: none; }
}
.law__kicker {
  font-size: 11.5px;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}
.law__name {
  font-size: clamp(22px, 6vw, 28px);
  font-weight: 700;
  letter-spacing: -.7px;
  margin: 10px 0 16px;
  line-height: 1.2;
}
.law__f {
  font-family: var(--mono);
  font-size: clamp(16px, 5vw, 21px);
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-radius: var(--r-md);
  padding: 14px 12px;
  margin: 0 0 18px;
  overflow-x: auto;
}
.law__who { color: var(--text-2); font-size: 14.5px; line-height: 1.65; text-align: left; }
.law__who b { color: var(--text); }
.law__you {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  text-align: left;
}

/* ======================= разбор гипотезы ======================= */

.verdict {
  border-radius: var(--r-md);
  padding: 16px;
  margin-top: 14px;
  font-size: 14.5px;
  line-height: 1.6;
  background: var(--bg-soft);
  animation: rise .4s var(--ease) both;
  animation-delay: .1s;
}
.verdict--hit { background: var(--ok-soft); }
.verdict--miss { background: var(--warn-soft); }
.verdict b { display: block; margin-bottom: 8px; font-size: 15px; }
.verdict--hit b { color: var(--ok); }
.verdict--miss b { color: var(--warn); }

/* ======================= подвал ======================= */

.foot {
  margin-top: 44px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
  color: var(--text-3);
  font-size: 12.5px;
  line-height: 1.7;
}
.foot a { color: var(--text-2); }

@media (min-width: 560px) {
  .targets { grid-template-columns: repeat(4, 1fr); }
}

/* Кому анимации мешают — выключаем. Это доступность, а не украшение. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0ms !important;
    transition-duration: .01ms !important;
  }
}
