/* =========================================================
   ПРЕДЕЛ — визуальный стиль игры
   ========================================================= */

:root {
  --bg: #05080f;
  --bg-deep: #03060c;
  --panel: rgba(12, 20, 34, 0.78);
  --panel-solid: #0b1422;
  --line: rgba(127, 179, 235, 0.14);
  --line-soft: rgba(127, 179, 235, 0.08);
  --line-strong: rgba(127, 217, 245, 0.34);
  --text: #e9f1ff;
  --muted: #8da1bf;
  --muted-2: #657a99;
  --cyan: #67e8f9;
  --cyan-deep: #22d3ee;
  --blue: #60a5fa;
  --amber: #fbbf24;
  --green: #86efac;
  --pink: #fb7185;
  --violet: #c4b5fd;
  --teal: #5eead4;
  --danger: #f87171;
  --chapter: #67e8f9;
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --shadow-panel: 0 24px 60px rgba(0, 0, 0, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.035);
  --font-ui: "Segoe UI Variable", "Segoe UI", "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "Cascadia Code", "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
  --font-math: "Cambria Math", "STIX Two Math", "Times New Roman", Georgia, serif;
}

* { box-sizing: border-box; }

html {
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  padding-bottom: 28px;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.modal-open { overflow: hidden; }

button, input { font: inherit; }
button { color: inherit; }
a { color: var(--cyan); }

::selection {
  color: #041018;
  background: var(--cyan);
}

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: -100px;
  left: 16px;
  z-index: 300;
  padding: 10px 14px;
  border-radius: 10px;
  color: #041018;
  background: var(--cyan);
  font-weight: 700;
  text-decoration: none;
  transition: top 0.18s ease;
}
.skip-link:focus { top: 14px; }

/* ---------- атмосфера ---------- */

.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% -20%, rgba(23, 62, 101, 0.36), transparent 57%),
    radial-gradient(ellipse at 100% 20%, rgba(17, 79, 91, 0.16), transparent 42%),
    var(--bg);
}

.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.34;
}
.orb-a {
  top: 8vh;
  left: -12vw;
  width: 36vw;
  height: 36vw;
  background: rgba(37, 99, 235, 0.23);
}
.orb-b {
  right: -12vw;
  top: 36vh;
  width: 32vw;
  height: 32vw;
  background: rgba(20, 184, 166, 0.15);
}

.ambient-grid {
  position: absolute;
  inset: 0;
  opacity: 0.42;
  background-image:
    linear-gradient(rgba(123, 180, 240, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(123, 180, 240, 0.04) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse at 50% 22%, black, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 22%, black, transparent 75%);
}

/* ---------- верхняя панель ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  padding: 13px clamp(14px, 2.4vw, 32px);
  border-bottom: 1px solid rgba(129, 181, 236, 0.09);
  background: linear-gradient(180deg, rgba(5, 8, 15, 0.94), rgba(5, 8, 15, 0.74));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 1px solid rgba(103, 232, 249, 0.34);
  border-radius: 13px;
  background:
    radial-gradient(circle at 30% 20%, rgba(103, 232, 249, 0.22), transparent 60%),
    rgba(12, 26, 42, 0.8);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 0 24px rgba(34, 211, 238, 0.08);
  color: var(--cyan);
  font-family: var(--font-math);
  font-size: 29px;
  line-height: 1;
  padding-bottom: 3px;
}

.brand-copy { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.brand-copy strong {
  font-size: 14px;
  font-weight: 750;
  letter-spacing: 0.24em;
}
.brand-copy span {
  overflow: hidden;
  color: var(--muted-2);
  font-size: 11px;
  letter-spacing: 0.015em;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.hud {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-left: auto;
}

.hud-stat {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 100px;
  padding: 7px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgba(14, 24, 40, 0.52);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.hud-sparks {
  border-color: rgba(103, 232, 249, 0.2);
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.09), rgba(14, 24, 40, 0.4));
}

.spark-glyph {
  color: var(--cyan);
  font-size: 17px;
  line-height: 1;
  filter: drop-shadow(0 0 8px rgba(103, 232, 249, 0.45));
}

.hud-copy { display: flex; flex-direction: column; min-width: 0; }
.hud-copy strong {
  overflow: hidden;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  line-height: 1.15;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.hud-copy small {
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.11em;
  line-height: 1.3;
  text-transform: uppercase;
}

.hud-goal .hud-copy strong { color: var(--cyan); font-family: var(--font-ui); font-size: 14px; letter-spacing: -0.01em; }

.top-actions { display: flex; gap: 6px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(13, 22, 37, 0.7);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 16px;
  cursor: pointer;
  transition: color 0.16s ease, border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}
.icon-btn:hover {
  color: var(--cyan);
  border-color: rgba(103, 232, 249, 0.35);
  background: rgba(20, 35, 56, 0.85);
}
.icon-btn:active { transform: translateY(1px); }
.icon-btn[aria-pressed="false"] { color: var(--muted-2); opacity: 0.65; }

/* ---------- сетка ---------- */

.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr) 340px;
  gap: 14px;
  width: 100%;
  max-width: 1720px;
  margin: 0 auto;
  padding: 14px clamp(12px, 2vw, 26px) 0;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(155deg, rgba(21, 35, 56, 0.38), rgba(8, 14, 25, 0.1) 42%),
    var(--panel);
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
}

.journey,
.shop,
.lab-notes {
  position: sticky;
  top: 86px;
  max-height: calc(100vh - 108px);
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(103, 232, 249, 0.22) transparent;
}
.journey::-webkit-scrollbar,
.shop::-webkit-scrollbar,
.shop-scroll::-webkit-scrollbar { width: 7px; height: 7px; }
.journey::-webkit-scrollbar-thumb,
.shop::-webkit-scrollbar-thumb,
.shop-scroll::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: rgba(103, 232, 249, 0.2);
}
.journey::-webkit-scrollbar-track,
.shop::-webkit-scrollbar-track,
.shop-scroll::-webkit-scrollbar-track { background: transparent; }

.journey { padding: 16px 14px; min-width: 0; }
.shop, .workspace, .chapter-list, .shop-scroll, .gen-list, .upgrade-list { min-width: 0; }

.panel-heading,
.shop-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 3px;
}
.panel-title {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.panel-count {
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.journey-progress {
  height: 4px;
  margin: 11px 3px 14px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(120, 170, 225, 0.09);
}
.journey-progress i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan-deep), var(--cyan), var(--green));
  box-shadow: 0 0 12px rgba(103, 232, 249, 0.4);
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.chapter-list { display: flex; flex-direction: column; gap: 5px; min-width: 0; max-width: 100%; }

.chapter-card {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 9px 9px 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}
.chapter-card:hover {
  border-color: var(--line-soft);
  background: rgba(127, 179, 235, 0.055);
}
.chapter-card.is-active {
  border-color: color-mix(in srgb, var(--card-accent, var(--cyan)) 32%, transparent);
  background:
    linear-gradient(100deg, color-mix(in srgb, var(--card-accent, var(--cyan)) 12%, transparent), rgba(127, 179, 235, 0.02));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.chapter-card.is-active .chapter-number {
  border-color: color-mix(in srgb, var(--card-accent) 55%, transparent);
  color: var(--card-accent);
  box-shadow: 0 0 18px color-mix(in srgb, var(--card-accent) 17%, transparent);
}
.chapter-card.is-locked { cursor: pointer; opacity: 0.58; }
.chapter-card.is-locked:hover { opacity: 0.86; }
.chapter-card.is-openable {
  opacity: 0.9;
  border-color: rgba(251, 191, 36, 0.16);
  background: rgba(251, 191, 36, 0.025);
}
.chapter-card.is-openable .chapter-state { color: var(--amber); }
.workspace { scroll-margin-top: 88px; }
.chapter-card.is-done .chapter-number {
  border-color: rgba(134, 239, 172, 0.32);
  color: var(--green);
}

.chapter-number {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(8, 16, 28, 0.6);
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  transition: color 0.16s ease, border-color 0.16s ease;
}

.chapter-copy { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.chapter-copy strong {
  overflow: hidden;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.chapter-copy small {
  overflow: hidden;
  color: var(--muted-2);
  font-size: 10px;
  line-height: 1.35;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chapter-state {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 9px;
  white-space: nowrap;
}
.chapter-card.is-done .chapter-state { color: var(--green); }
.chapter-card.is-locked .chapter-state { color: var(--amber); }
.chapter-state .lock-glyph { font-size: 11px; opacity: 0.8; }

.chapter-mini {
  width: 24px;
  height: 3px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(127, 179, 235, 0.1);
}
.chapter-mini i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--card-accent, var(--cyan));
}

.journey-note {
  margin: 16px 4px 2px;
  padding-top: 13px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted-2);
  font-size: 10.5px;
  line-height: 1.5;
}
.journey-note span { margin-right: 4px; color: var(--cyan); }

/* ---------- рабочая область ---------- */

.workspace {
  min-width: 0;
  padding: clamp(15px, 1.6vw, 22px);
  border-color: color-mix(in srgb, var(--chapter) 16%, var(--line));
}

.workspace-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 13px;
}

.workspace-title { min-width: 0; }
.kicker {
  display: block;
  color: var(--chapter);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.workspace h1 {
  margin: 3px 0 5px;
  font-size: clamp(24px, 2.3vw, 33px);
  font-weight: 720;
  letter-spacing: -0.035em;
  line-height: 1.08;
}
.workspace-title > p {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}

.inline-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}
.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: rgba(8, 15, 26, 0.45);
  color: var(--muted-2);
  font-size: 10px;
  line-height: 1.5;
}
.meta-chip b {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.meta-chip.is-reward b { color: var(--green); }

.head-actions { display: flex; flex-shrink: 0; gap: 8px; }

.canvas-wrap {
  position: relative;
  min-height: 290px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  aspect-ratio: 16 / 8.35;
  scroll-margin-top: 90px;
  background:
    radial-gradient(ellipse at 52% 0%, color-mix(in srgb, var(--chapter) 7%, transparent), transparent 62%),
    linear-gradient(160deg, rgba(12, 26, 44, 0.55), rgba(4, 10, 19, 0.8));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03), 0 12px 32px rgba(0, 0, 0, 0.18);
}
.canvas-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(127, 179, 235, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(127, 179, 235, 0.025) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(ellipse at center, black, transparent 83%);
  -webkit-mask-image: radial-gradient(ellipse at center, black, transparent 83%);
}
#scene {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: pan-y;
}
.canvas-wrap.is-draggable #scene { touch-action: none; }
.canvas-wrap.is-tall { aspect-ratio: 16 / 9.6; }
.canvas-wrap.is-draggable #scene { cursor: grab; }
.canvas-wrap.is-draggable #scene:active { cursor: grabbing; }

.canvas-formula {
  position: absolute;
  top: 11px;
  left: 12px;
  z-index: 2;
  max-width: calc(100% - 24px);
  overflow: hidden;
  padding: 5px 9px;
  border: 1px solid color-mix(in srgb, var(--chapter) 18%, var(--line-soft));
  border-radius: 8px;
  background: rgba(4, 10, 19, 0.62);
  color: color-mix(in srgb, var(--chapter) 75%, white);
  font-family: var(--font-math);
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
  text-overflow: ellipsis;
  backdrop-filter: blur(8px);
  pointer-events: none;
}
.canvas-note {
  position: absolute;
  right: 13px;
  bottom: 9px;
  left: 13px;
  z-index: 2;
  overflow: hidden;
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.4;
  white-space: nowrap;
  text-overflow: ellipsis;
  pointer-events: none;
}

/* ---------- ползунки и элементы лаборатории ---------- */

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 11px;
}
.control {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  padding: 10px 12px 9px;
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  background: rgba(8, 15, 27, 0.47);
}
.control.is-wide { grid-column: 1 / -1; }
.control-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}
.control-label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.35;
}
.control-label .math-sym {
  color: var(--chapter);
  font-family: var(--font-math);
  font-size: 15px;
  line-height: 1;
}
.control output {
  flex-shrink: 0;
  padding: 2px 7px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: rgba(3, 9, 17, 0.55);
  color: var(--chapter);
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}

input[type="range"] {
  width: 100%;
  height: 24px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  border: 1px solid rgba(140, 190, 245, 0.08);
  border-radius: 99px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--chapter) 52%, transparent), rgba(130, 175, 230, 0.09));
}
input[type="range"]::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  margin-top: -7px;
  border: 3px solid #07111d;
  border-radius: 50%;
  background: var(--chapter);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--chapter) 62%, transparent), 0 0 14px color-mix(in srgb, var(--chapter) 38%, transparent);
  appearance: none;
  -webkit-appearance: none;
  transition: transform 0.12s ease;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.12); }
input[type="range"]::-moz-range-track {
  height: 5px;
  border: 1px solid rgba(140, 190, 245, 0.08);
  border-radius: 99px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--chapter) 52%, transparent), rgba(130, 175, 230, 0.09));
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 3px solid #07111d;
  border-radius: 50%;
  background: var(--chapter);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--chapter) 62%, transparent), 0 0 14px color-mix(in srgb, var(--chapter) 38%, transparent);
}
input[type="range"]:disabled { opacity: 0.45; cursor: default; }

.range-scale {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 8.5px;
  line-height: 1.2;
}

.live-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  grid-column: 1 / -1;
  min-width: 0;
}
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: rgba(7, 14, 25, 0.42);
  color: var(--muted-2);
  font-size: 10px;
  line-height: 1.35;
}
.live-pill b {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.live-pill.accent { border-color: color-mix(in srgb, var(--chapter) 20%, var(--line-soft)); }
.live-pill.accent b { color: var(--chapter); }
.live-pill.good { border-color: rgba(134, 239, 172, 0.2); }
.live-pill.good b { color: var(--green); }

.smoothing-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  grid-column: 1 / -1;
}
.smoothing-row .btn { flex: 0 0 auto; }
.smoothing-readout {
  margin-left: auto;
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-variant-numeric: tabular-nums;
}
.smoothing-readout b { color: var(--chapter); font-weight: 500; }

.wall-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  grid-column: 1 / -1;
}
.wall-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  grid-column: 1 / -1;
}

/* ---------- задачи ---------- */

.task-panel {
  position: relative;
  margin-top: 11px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(120deg, color-mix(in srgb, var(--chapter) 4%, transparent), transparent 40%),
    rgba(7, 14, 25, 0.56);
}
.task-inner {
  display: flex;
  align-items: flex-start;
  gap: 15px;
}
.task-copy { min-width: 0; flex: 1; }
.task-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  color: var(--chapter);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.task-eyebrow .task-step {
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0;
  text-transform: none;
}
.task-copy p {
  max-width: 780px;
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.52;
}
.task-copy p b { color: var(--text); font-weight: 600; }

.task-actions {
  display: flex;
  flex-shrink: 0;
  gap: 7px;
  align-items: center;
  padding-top: 2px;
}

.task-dots {
  display: flex;
  flex-shrink: 0;
  gap: 5px;
  align-items: center;
  padding-top: 3px;
}
.task-dot {
  width: 7px;
  height: 7px;
  border: 1px solid rgba(127, 179, 235, 0.25);
  border-radius: 50%;
  background: rgba(127, 179, 235, 0.08);
}
.task-dot.is-done {
  border-color: var(--green);
  background: var(--green);
  box-shadow: 0 0 8px rgba(134, 239, 172, 0.38);
}
.task-dot.is-current {
  border-color: var(--chapter);
  background: color-mix(in srgb, var(--chapter) 35%, transparent);
  box-shadow: 0 0 9px color-mix(in srgb, var(--chapter) 30%, transparent);
}

.feedback {
  display: none;
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: rgba(3, 9, 17, 0.42);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}
.feedback.is-visible { display: block; animation: feedback-in 0.22s ease-out; }
.feedback.is-good {
  border-color: rgba(134, 239, 172, 0.24);
  color: #c6f6d5;
  background: rgba(22, 54, 39, 0.28);
}
.feedback.is-bad {
  border-color: rgba(251, 191, 36, 0.24);
  color: #f7e4ad;
  background: rgba(57, 45, 15, 0.24);
}
.feedback b { color: var(--text); font-weight: 600; }

.hint-box {
  margin-top: 9px;
  padding: 8px 10px;
  border-left: 2px solid var(--amber);
  border-radius: 0 8px 8px 0;
  background: rgba(251, 191, 36, 0.055);
  color: #d9c99b;
  font-size: 11px;
  line-height: 1.5;
}
.hint-box b { color: #f6d979; }

.task-done {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.task-done .done-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 1px solid rgba(134, 239, 172, 0.28);
  border-radius: 10px;
  background: rgba(33, 75, 52, 0.25);
  color: var(--green);
  font-size: 17px;
}
.task-done strong { display: block; margin-bottom: 1px; color: var(--text); font-size: 12px; }

/* ---------- кнопки ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(20, 34, 54, 0.65);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}
.btn:hover {
  border-color: rgba(127, 217, 245, 0.33);
  background: rgba(28, 49, 75, 0.75);
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  border-color: color-mix(in srgb, var(--chapter) 42%, transparent);
  background: linear-gradient(135deg, color-mix(in srgb, var(--chapter) 86%, white), color-mix(in srgb, var(--chapter) 55%, #3b82f6));
  color: #04121b;
  font-weight: 750;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--chapter) 14%, transparent);
}
.btn.primary:hover {
  border-color: color-mix(in srgb, var(--chapter) 70%, white);
  background: linear-gradient(135deg, color-mix(in srgb, var(--chapter) 92%, white), color-mix(in srgb, var(--chapter) 65%, #60a5fa));
}
.btn.ghost {
  border-color: var(--line-soft);
  background: rgba(10, 18, 31, 0.4);
  color: var(--muted);
}
.btn.ghost:hover { color: var(--text); border-color: var(--line); background: rgba(19, 32, 51, 0.6); }
.btn.small { min-height: 29px; padding: 5px 9px; font-size: 10px; border-radius: 8px; }
.btn.danger { border-color: rgba(248, 113, 113, 0.3); color: #fecaca; background: rgba(127, 29, 29, 0.25); }
.btn.danger:hover { border-color: rgba(248, 113, 113, 0.55); background: rgba(127, 29, 29, 0.4); }
.btn:disabled {
  opacity: 0.42;
  cursor: default;
  transform: none;
  box-shadow: none;
}
.btn-glyph { font-size: 12px; line-height: 1; opacity: 0.8; }

/* ---------- формуляр ---------- */

.lab-notes {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  padding: 16px 14px;
}
.notes-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 0 3px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.notes-head .shop-sub { margin: 3px 0 0; max-width: 190px; }
.notes-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(103, 232, 249, 0.22) transparent;
}
.notes-now {
  margin-top: 13px;
  padding: 12px;
  border: 1px solid rgba(103, 232, 249, 0.17);
  border-left: 2px solid var(--cyan);
  border-radius: 4px 11px 11px 4px;
  background:
    radial-gradient(ellipse at 10% 0%, rgba(34, 211, 238, 0.07), transparent 65%),
    rgba(6, 13, 24, 0.42);
}
.notes-eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--cyan);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.notes-formula {
  overflow-x: auto;
  color: #ddf8ff;
  font-family: var(--font-math);
  font-size: 22px;
  line-height: 1.3;
  white-space: nowrap;
  scrollbar-width: none;
}
.notes-formula::-webkit-scrollbar { display: none; }
.notes-idea {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.5;
}
.notes-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 9px;
}
.notes-meta span {
  padding: 3px 6px;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  color: var(--muted-2);
  font-size: 8.5px;
  line-height: 1.4;
}
.notes-meta b { color: var(--muted); font-family: var(--font-mono); font-weight: 500; }
.notes-block { margin-top: 16px; }
.notes-heading {
  margin-bottom: 7px;
  color: var(--muted-2);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.notes-glossary { display: flex; flex-direction: column; gap: 5px; }
.notes-term {
  padding: 7px 8px 7px 9px;
  border-left: 1px solid rgba(127, 179, 235, 0.18);
  border-radius: 0 7px 7px 0;
  background: rgba(7, 14, 25, 0.33);
}
.notes-term b {
  display: block;
  color: var(--text);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.35;
}
.notes-term span {
  display: block;
  margin-top: 1px;
  color: var(--muted-2);
  font-size: 9.5px;
  line-height: 1.42;
}
.notes-archive { display: flex; flex-direction: column; gap: 4px; }
.notes-archive-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
  width: 100%;
  padding: 6px 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: rgba(7, 14, 25, 0.34);
  color: var(--muted-2);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.notes-archive-row:hover {
  border-color: var(--line-soft);
  background: rgba(101, 160, 220, 0.06);
}
.notes-archive-row > span {
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 8px;
}
.notes-archive-row > b {
  overflow: hidden;
  color: var(--muted);
  font-family: var(--font-math);
  font-size: 13px;
  font-weight: 400;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.notes-archive-row > i {
  color: var(--cyan);
  font-size: 11px;
  font-style: normal;
  opacity: 0.55;
}
.notes-empty {
  padding: 12px 8px;
  color: var(--muted-2);
  font-size: 9.5px;
  line-height: 1.5;
  text-align: center;
}
.notes-foot {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted-2);
  font-size: 9.5px;
  line-height: 1.5;
}
.notes-foot-mark { color: var(--amber); font-size: 11px; line-height: 1.3; }
.notes-foot b { color: var(--muted); font-weight: 600; }

/* ---------- магазин ---------- */

.shop { padding: 15px 13px 13px; }
.shop-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 0 3px 11px; }
.shop-sub { margin: 3px 0 0; color: var(--muted-2); font-size: 10px; line-height: 1.4; }

.bulk {
  display: flex;
  flex-shrink: 0;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(5, 11, 20, 0.48);
}
.bulk-btn {
  padding: 3px 6px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 9px;
  cursor: pointer;
}
.bulk-btn:hover { color: var(--text); }
.bulk-btn.is-active {
  background: rgba(103, 232, 249, 0.13);
  color: var(--cyan);
}

.shop-scroll { min-height: 0; overflow: auto; padding-right: 2px; }
.shop-divider { height: 1px; margin: 15px 1px 13px; background: var(--line-soft); }
.shop-heading { margin-bottom: 8px; }

.gen-list,
.upgrade-list { display: flex; flex-direction: column; gap: 7px; }

.gen-card {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background:
    linear-gradient(120deg, rgba(103, 232, 249, 0.025), transparent 55%),
    rgba(7, 13, 24, 0.55);
  transition: border-color 0.18s ease, background 0.18s ease;
}
.gen-card.is-unlocked:hover { border-color: var(--line); background-color: rgba(12, 23, 39, 0.72); }
.gen-card.is-locked { opacity: 0.48; border-style: dashed; }
.gen-glyph {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(10, 21, 36, 0.8);
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1;
}
.gen-copy { min-width: 0; }
.gen-name {
  display: flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.3;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.gen-level {
  flex-shrink: 0;
  padding: 1px 4px;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 500;
}
.gen-desc {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 2px;
  color: var(--muted-2);
  font-size: 10px;
  line-height: 1.38;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.gen-rate {
  margin-top: 4px;
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.gen-rate.is-muted { color: var(--muted-2); }

.buy-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 76px;
  padding: 6px 8px;
  border: 1px solid rgba(103, 232, 249, 0.2);
  border-radius: 8px;
  background: rgba(16, 41, 57, 0.7);
  color: var(--cyan);
  font-size: 9.5px;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}
.buy-btn:hover:not(:disabled) {
  border-color: rgba(103, 232, 249, 0.45);
  background: rgba(20, 57, 76, 0.82);
}
.buy-btn:active:not(:disabled) { transform: translateY(1px); }
.buy-btn:disabled { opacity: 0.4; cursor: default; }
.buy-cost {
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}
.buy-locked {
  align-items: center;
  justify-content: center;
  color: var(--muted-2);
  font-size: 9px;
  line-height: 1.25;
  text-align: center;
  border-color: var(--line-soft);
  background: transparent;
}

.upgrade-card {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(7, 13, 24, 0.5);
}
.upgrade-glyph {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  color: var(--amber);
  font-size: 13px;
}
.upgrade-copy { min-width: 0; }
.upgrade-name { color: var(--text); font-size: 11px; font-weight: 650; line-height: 1.3; }
.upgrade-desc { margin-top: 1px; color: var(--muted-2); font-size: 9.5px; line-height: 1.38; }
.upgrade-buy {
  padding: 5px 7px;
  border: 1px solid rgba(251, 191, 36, 0.18);
  border-radius: 7px;
  background: rgba(71, 48, 11, 0.22);
  color: #f5d58b;
  font-family: var(--font-mono);
  font-size: 9px;
  white-space: nowrap;
  cursor: pointer;
}
.upgrade-buy:hover:not(:disabled) { border-color: rgba(251, 191, 36, 0.38); background: rgba(95, 64, 13, 0.32); }
.upgrade-buy:disabled { opacity: 0.4; cursor: default; }
.shop-empty {
  padding: 16px 10px;
  border: 1px dashed var(--line-soft);
  border-radius: 10px;
  color: var(--muted-2);
  font-size: 10px;
  line-height: 1.5;
  text-align: center;
}
.shop-empty b { color: var(--muted); font-weight: 600; }

/* ---------- док с кнопкой шага ---------- */

.dock {
  position: fixed;
  bottom: 17px;
  left: 50%;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 11px;
  width: min(660px, calc(100vw - 28px));
  padding: 8px 9px;
  border: 1px solid rgba(103, 232, 249, 0.18);
  border-radius: 19px;
  background: linear-gradient(180deg, rgba(14, 27, 44, 0.93), rgba(6, 13, 24, 0.94));
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.55), 0 0 45px rgba(34, 211, 238, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transform: translateX(-50%);
}

.combo {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 126px;
  flex: 0 0 auto;
  padding-left: 5px;
  opacity: 0;
  transform: translateX(-5px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.combo.is-visible { opacity: 1; transform: translateX(0); }
.combo-label {
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.combo-label b { color: var(--cyan); font-weight: 500; font-variant-numeric: tabular-nums; }
.combo-track {
  display: block;
  width: 100%;
  height: 4px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(127, 179, 235, 0.1);
}
.combo-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--green));
  box-shadow: 0 0 8px rgba(103, 232, 249, 0.35);
  transition: width 0.12s ease;
}

.step-btn {
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 50px;
  padding: 11px 16px;
  overflow: hidden;
  border: 1px solid rgba(160, 246, 255, 0.45);
  border-radius: 13px;
  background:
    radial-gradient(ellipse at 10% 0%, rgba(255, 255, 255, 0.5), transparent 52%),
    linear-gradient(130deg, var(--cyan), #4fc3f7 46%, #60a5fa);
  color: #04141e;
  cursor: pointer;
  box-shadow: 0 9px 28px rgba(34, 211, 238, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.13s ease, box-shadow 0.13s ease, filter 0.13s ease;
}
.step-btn::after {
  content: "";
  position: absolute;
  top: -80%;
  left: -25%;
  width: 45%;
  height: 260%;
  transform: rotate(22deg);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.21), transparent);
  transition: left 0.4s ease;
  pointer-events: none;
}
.step-btn:hover { filter: brightness(1.05); box-shadow: 0 12px 36px rgba(34, 211, 238, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.4); }
.step-btn:hover::after { left: 120%; }
.step-btn:active,
.step-btn.is-pressed { transform: scale(0.985); }
.step-main {
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.step-gain {
  flex-shrink: 0;
  padding: 4px 8px;
  border: 1px solid rgba(3, 23, 33, 0.16);
  border-radius: 7px;
  background: rgba(3, 23, 33, 0.12);
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}
.dock-hint {
  padding: 0 5px 0 1px;
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 8.5px;
  white-space: nowrap;
  opacity: 0.7;
}

.float-gain {
  position: fixed;
  z-index: 70;
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  text-shadow: 0 2px 12px rgba(34, 211, 238, 0.5);
  pointer-events: none;
  animation: float-up 0.9s cubic-bezier(0.18, 0.7, 0.3, 1) forwards;
}

/* ---------- тосты ---------- */

.toasts {
  position: fixed;
  top: 122px;
  right: 18px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: min(330px, calc(100vw - 28px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 11px;
  border: 1px solid rgba(127, 179, 235, 0.19);
  border-radius: 10px;
  background: rgba(10, 20, 34, 0.94);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  backdrop-filter: blur(12px);
  animation: toast-in 0.24s ease-out;
}
.toast.is-good { border-color: rgba(134, 239, 172, 0.28); color: #c6f6d5; }
.toast.is-bad { border-color: rgba(251, 191, 36, 0.28); color: #f7e4ad; }
.toast.is-reward { border-color: rgba(103, 232, 249, 0.28); color: var(--text); }
.toast .toast-icon { flex: 0 0 auto; color: var(--cyan); font-size: 12px; line-height: 1.3; }
.toast.is-good .toast-icon { color: var(--green); }
.toast.is-bad .toast-icon { color: var(--amber); }
.toast.is-leaving { animation: toast-out 0.22s ease-in forwards; }

/* ---------- модальные окна ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(2, 5, 11, 0.72);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  animation: fade-in 0.18s ease-out;
}
.modal {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(680px, 100%);
  max-height: min(88vh, 940px);
  overflow: hidden;
  padding: 27px 27px 22px;
  border: 1px solid rgba(127, 179, 235, 0.19);
  border-radius: 22px;
  background:
    radial-gradient(ellipse at 10% 0%, rgba(34, 211, 238, 0.07), transparent 40%),
    linear-gradient(180deg, #0d1728, #07101d 82%);
  box-shadow: 0 35px 100px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  animation: modal-in 0.26s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal.is-wide { width: min(790px, 100%); }
.modal:focus { outline: none; }
.modal-head { flex: 0 0 auto; }
.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(103, 232, 249, 0.35) transparent;
}
.modal-body:focus { outline: none; }
.modal-body::-webkit-scrollbar { width: 8px; }
.modal-body::-webkit-scrollbar-thumb { border-radius: 99px; background: rgba(103, 232, 249, 0.25); }
.modal-body::-webkit-scrollbar-track { background: transparent; }

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: rgba(7, 14, 25, 0.7);
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.16s ease, border-color 0.16s ease;
}
.modal-close:hover { color: var(--text); border-color: var(--line); }
.modal-head { padding-right: 40px; }
.modal-kicker {
  margin-bottom: 6px;
  color: var(--cyan);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.modal-head h2 {
  margin: 0;
  color: var(--text);
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 720;
  letter-spacing: -0.035em;
  line-height: 1.1;
}
.modal-head .modal-sub {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.modal-body { margin-top: 18px; color: var(--muted); font-size: 13px; line-height: 1.62; }
.modal-body > p { margin: 0 0 12px; }
.modal-body > p:last-child { margin-bottom: 0; }
.modal-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
}
.modal-actions .btn { min-height: 38px; padding: 8px 15px; font-size: 12px; }
.modal-note { margin-top: 12px; color: var(--muted-2); font-size: 11px; }
.modal-actions-spacer { flex: 1; }

/* ---------- контент уроков ---------- */

.lesson { font-size: 14px; line-height: 1.65; color: var(--muted); }
.lesson > p { margin: 0 0 13px; }
.lesson b, .lesson strong { color: var(--text); font-weight: 650; }
.lesson code {
  padding: 1px 5px;
  border: 1px solid rgba(127, 179, 235, 0.12);
  border-radius: 5px;
  background: rgba(3, 9, 17, 0.5);
  color: #c9e9ff;
  font-family: var(--font-mono);
  font-size: 0.9em;
}
.lesson-lead {
  color: #c3d2e8;
  font-size: 15px;
  line-height: 1.6;
}
.lesson h3 {
  margin: 18px 0 8px;
  color: var(--text);
  font-size: 15px;
}
.lesson ul,
.lesson ol { margin: 8px 0 14px; padding-left: 20px; }
.lesson li { margin: 5px 0; }

.formula-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 14px 0;
  padding: 13px 15px;
  overflow-x: auto;
  border: 1px solid rgba(103, 232, 249, 0.16);
  border-left: 3px solid var(--cyan);
  border-radius: 4px 12px 12px 4px;
  background: linear-gradient(100deg, rgba(34, 211, 238, 0.07), rgba(6, 14, 25, 0.3));
  color: #d9f7ff;
  font-family: var(--font-math);
  font-size: 20px;
  line-height: 1.4;
  white-space: normal;
}
.formula-card .formula-tag {
  color: var(--cyan);
  font-family: var(--font-ui);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.formula-card .formula { font-size: clamp(18px, 2.4vw, 22px); }
.formula-card .formula-sub {
  color: var(--muted-2);
  font-family: var(--font-ui);
  font-size: 10.5px;
  line-height: 1.45;
}
.formula-card br + .formula { margin-top: 4px; }
.formula-card sup { font-size: 0.65em; }

.concept-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}
.concept-grid > div {
  padding: 10px 11px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(6, 13, 24, 0.44);
}
.concept-grid b { display: block; margin-bottom: 3px; color: var(--text); font-size: 11px; }
.concept-grid span { display: block; color: var(--muted-2); font-size: 10px; line-height: 1.4; }

.pair-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}
.pair-grid > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 11px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: rgba(6, 13, 24, 0.4);
}
.pair-grid span { color: var(--muted-2); font-size: 10px; }
.pair-grid code { align-self: flex-start; }

.pair-table {
  margin: 14px 0;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
}
.pair-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 8px 13px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 11.5px;
}
.pair-row:last-child { border-bottom: 0; }
.pair-row:nth-child(odd) { background: rgba(127, 179, 235, 0.025); }
.pair-row span { color: var(--muted); }
.pair-row code { color: var(--cyan); background: transparent; border: 0; font-size: 12px; }

.term-list { margin: 14px 0; display: grid; gap: 7px; }
.term-list > div {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 8px 11px;
  border-left: 2px solid rgba(196, 181, 253, 0.45);
  border-radius: 0 8px 8px 0;
  background: rgba(196, 181, 253, 0.035);
}
.term-list b { color: var(--violet); font-family: var(--font-math); font-size: 16px; }
.term-list span { color: var(--muted); font-size: 11.5px; }

.regime-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin: 14px 0; }
.regime-grid > div {
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(6, 13, 24, 0.4);
}
.regime-grid b { display: block; color: var(--violet); font-family: var(--font-mono); font-size: 11px; }
.regime-grid span { display: block; margin-top: 2px; color: var(--text); font-size: 10px; line-height: 1.35; }
.regime-grid em { display: block; margin-top: 4px; color: var(--muted-2); font-size: 9.5px; font-style: normal; line-height: 1.4; }

.callout {
  margin: 15px 0;
  padding: 11px 13px;
  border: 1px solid rgba(251, 191, 36, 0.16);
  border-radius: 10px;
  background: rgba(251, 191, 36, 0.035);
  color: #cfc3a3;
  font-size: 11.5px;
  line-height: 1.55;
}
.callout b { color: #f4dfab; }

.worked {
  margin: 16px 0;
  padding: 13px 14px;
  border: 1px solid rgba(96, 165, 250, 0.19);
  border-radius: 12px;
  background: rgba(30, 58, 95, 0.14);
}
.worked-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  color: var(--blue);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.worked > p { margin: 0 0 10px; font-size: 12px; }

.lesson-steps { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.lesson-steps li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 9px; align-items: start; }
.lesson-steps li > span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(96, 165, 250, 0.25);
  border-radius: 50%;
  color: var(--blue);
  font-family: var(--font-mono);
  font-size: 9px;
}
.lesson-steps li > div { color: var(--muted); font-size: 11.5px; line-height: 1.55; padding-top: 2px; }
.lesson-steps li b { color: var(--text); }

.lesson-details {
  margin: 13px 0;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(6, 13, 24, 0.34);
}
.lesson-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.lesson-details summary::-webkit-details-marker { display: none; }
.lesson-details summary span { color: var(--cyan); font-size: 15px; transition: transform 0.18s ease; }
.lesson-details[open] summary span { transform: rotate(45deg); }
.details-body { padding: 0 12px 12px; }

.pole-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin: 14px 0;
}
.pole-grid > div {
  position: relative;
  padding: 9px 10px 9px 28px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: rgba(6, 13, 24, 0.4);
}
.pole-grid b { display: block; color: var(--text); font-family: var(--font-mono); font-size: 10px; }
.pole-grid em { display: block; margin-top: 2px; color: var(--muted-2); font-size: 9.5px; font-style: normal; }
.pole-dot {
  position: absolute;
  top: 13px;
  left: 11px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  box-shadow: 0 0 9px currentColor;
}
.pole-real { color: var(--cyan); background: var(--cyan); }
.pole-imag { color: var(--blue); background: var(--blue); }
.pole-complex { color: var(--violet); background: var(--violet); }
.pole-grow { color: var(--pink); background: var(--pink); }

.average-demo {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  gap: 3px;
  width: max-content;
  margin: 16px auto 6px;
  padding: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgba(6, 13, 24, 0.4);
}
.average-cell {
  display: grid;
  place-items: center;
  height: 34px;
  border: 1px solid rgba(127, 179, 235, 0.1);
  border-radius: 6px;
  background: rgba(17, 40, 65, 0.55);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
}
.average-center {
  border-color: rgba(94, 234, 212, 0.5);
  background: rgba(94, 234, 212, 0.14);
  color: var(--teal);
  box-shadow: 0 0 18px rgba(94, 234, 212, 0.1);
}
.avg-caption { margin: -2px 0 14px; color: var(--muted-2); font-size: 10px; text-align: center; }

/* ---------- интро, победа, справка ---------- */

.intro-hero { padding: 4px 0 6px; }
.intro-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  border: 1px solid rgba(103, 232, 249, 0.32);
  border-radius: 18px;
  background: radial-gradient(circle at 30% 20%, rgba(103, 232, 249, 0.2), rgba(13, 30, 49, 0.8));
  color: var(--cyan);
  font-family: var(--font-math);
  font-size: 43px;
  line-height: 1;
  padding-bottom: 5px;
  box-shadow: 0 0 30px rgba(34, 211, 238, 0.08);
}
.intro-title {
  margin: 0 0 8px;
  color: var(--text);
  font-size: clamp(30px, 6vw, 45px);
  font-weight: 760;
  letter-spacing: 0.08em;
  line-height: 1;
}
.intro-tagline { margin: 0 0 16px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.intro-list { display: grid; gap: 8px; margin: 16px 0; }
.intro-list > div {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 9px;
  align-items: start;
  padding: 9px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: rgba(6, 13, 24, 0.37);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}
.intro-list span { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: rgba(103, 232, 249, 0.08); color: var(--cyan); font-family: var(--font-mono); font-size: 10px; }
.intro-list b { color: var(--text); }

.victory-mark {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border: 1px solid rgba(134, 239, 172, 0.35);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(134, 239, 172, 0.16), rgba(9, 24, 27, 0.5));
  color: var(--green);
  font-size: 29px;
  box-shadow: 0 0 40px rgba(134, 239, 172, 0.1);
}
.victory-title { text-align: center; }
.victory-sub { text-align: center; }
.diploma {
  margin: 17px 0;
  padding: 16px;
  border: 1px solid rgba(134, 239, 172, 0.2);
  border-radius: 12px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(134, 239, 172, 0.08), transparent 70%),
    rgba(8, 25, 25, 0.35);
  text-align: center;
}
.diploma small { display: block; color: var(--green); font-size: 8.5px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; }
.diploma strong { display: block; margin: 4px 0; color: var(--text); font-size: 17px; letter-spacing: -0.015em; }
.diploma span { color: var(--muted-2); font-size: 10px; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin: 13px 0;
}
.stats-grid > div {
  padding: 9px 11px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: rgba(6, 13, 24, 0.4);
}
.stats-grid span { display: block; color: var(--muted-2); font-size: 9px; }
.stats-grid b { display: block; margin-top: 2px; color: var(--text); font-family: var(--font-mono); font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }
.concept-recap { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.concept-recap span {
  padding: 5px 8px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: rgba(103, 232, 249, 0.035);
  color: var(--muted);
  font-size: 10px;
}

.help-section { margin-bottom: 17px; }
.help-section h3 { margin: 0 0 7px; color: var(--text); font-size: 12px; }
.help-section p { margin: 0 0 7px; font-size: 11.5px; }
.help-section ul { margin: 6px 0; padding-left: 18px; }
.help-section li { margin: 4px 0; font-size: 11.5px; }
.key {
  display: inline-block;
  min-width: 20px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: rgba(18, 32, 52, 0.8);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 9px;
  text-align: center;
}

/* ---------- анимации ---------- */

@keyframes float-up {
  0% { opacity: 0; transform: translate(-50%, 8px) scale(0.85); }
  18% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -52px) scale(0.96); }
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateX(12px); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes feedback-in {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes soft-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(103, 232, 249, 0.18); }
  50% { box-shadow: 0 0 0 5px rgba(103, 232, 249, 0); }
}
@keyframes spin-slow {
  to { transform: rotate(360deg); }
}

.pulse-once { animation: soft-pulse 0.6s ease-out; }

/* ---------- адаптив ---------- */

@media (max-width: 1360px) {
  .layout { grid-template-columns: 232px minmax(0, 1fr); }
  .shop,
  .lab-notes {
    position: relative;
    top: auto;
    grid-column: 1 / -1;
    max-height: none;
    overflow: visible;
  }
  .lab-notes .notes-scroll {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    gap: 14px 18px;
    align-items: start;
  }
  .lab-notes .notes-now { grid-column: 1; grid-row: 1; margin-top: 0; }
  .lab-notes .notes-block:nth-child(2) { grid-column: 2; grid-row: 1; margin-top: 0; }
  .lab-notes .notes-block:nth-child(3) { grid-column: 1; grid-row: 2; }
  .lab-notes .notes-foot { grid-column: 2; grid-row: 2; }
  .shop-scroll {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    gap: 18px;
    overflow: visible;
  }
  .shop-divider { display: none; }
  .shop-heading { margin-top: 2px; }
  .gen-list, .upgrade-list { align-content: start; }
  .gen-list { grid-row: 1 / span 2; }
  .shop-heading { grid-column: 2; }
  .upgrade-list { grid-column: 2; grid-row: 2 / span 2; align-self: start; }
}

@media (max-width: 1020px) {
  .workspace-head { flex-direction: column; gap: 10px; }
  .head-actions { width: 100%; }
  .head-actions .btn { width: auto; }
  .demo-canvas { min-height: 260px; }
}

@media (max-width: 980px) {
  body { padding-bottom: 28px; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .journey {
    position: relative;
    top: auto;
    max-height: none;
    overflow: hidden;
    padding: 12px 13px;
    min-width: 0;
  }
  .journey-progress { margin: 7px 3px 10px; }
  .chapter-list {
    flex-direction: row;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding-bottom: 2px;
    scrollbar-width: thin;
  }
  .chapter-card {
    flex: 0 0 174px;
    min-width: 174px;
    grid-template-columns: 25px minmax(0, 1fr);
    padding: 7px;
  }
  .chapter-number { width: 25px; height: 25px; border-radius: 7px; font-size: 9.5px; }
  .chapter-copy strong { font-size: 11px; }
  .chapter-copy small { font-size: 9px; }
  .chapter-state { grid-column: 2; justify-content: flex-start; padding-top: 1px; }
  .journey-note { display: none; }
  .shop { padding: 14px; }
  .shop-scroll { grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); }
  .lab-notes {
    position: relative;
    top: auto;
    max-height: none;
    overflow: visible;
    padding: 14px;
  }
  .canvas-wrap { aspect-ratio: 16 / 8.8; }
}

@media (max-width: 820px) {
  .topbar { gap: 9px 12px; padding: 11px 14px; }
  .brand { flex: 1 1 auto; }
  .brand-copy span { display: none; }
  .hud { order: 3; flex: 1 0 100%; width: 100%; margin-left: 0; gap: 6px; }
  .hud-stat { flex: 1; min-width: 0; padding: 6px 9px; }
  .hud-copy strong { font-size: 14px; }
  .hud-copy small { font-size: 8px; letter-spacing: 0.07em; }
  .top-actions { margin-left: auto; }
  .toasts { top: 158px; right: 12px; }
  .shop-scroll { grid-template-columns: 1fr; gap: 14px; }
  .shop-divider { display: block; }
  .shop-heading { grid-column: auto; }
  .upgrade-list { grid-column: auto; grid-row: auto; }
  .gen-list { grid-row: auto; }
  .lab-notes .notes-scroll { display: block; }
  .lab-notes .notes-block { margin-top: 15px; }
  .lab-notes .notes-foot { margin-top: 15px; }
}

@media (max-width: 700px) {
  body { padding-bottom: 18px; }
  .layout { padding: 10px 9px 0; gap: 9px; }
  .workspace { padding: 13px 11px; border-radius: 17px; }
  .journey, .shop, .lab-notes { border-radius: 17px; }
  .workspace h1 { font-size: 25px; }
  .workspace-title > p { font-size: 12px; }
  .canvas-wrap {
    min-height: 0;
    height: clamp(230px, 72vw, 340px);
    aspect-ratio: auto;
  }
  .canvas-wrap.is-tall {
    height: clamp(285px, 84vw, 380px);
    aspect-ratio: auto;
  }
  .canvas-formula { font-size: 10.5px; top: 8px; left: 8px; padding: 4px 7px; }
  .canvas-note { right: 9px; bottom: 7px; left: 9px; font-size: 8.5px; }
  .controls { grid-template-columns: 1fr; gap: 8px; }
  .control.is-wide { grid-column: auto; }
  .wall-grid { grid-template-columns: 1fr; }
  .task-inner { flex-direction: column; gap: 10px; }
  .task-actions { width: 100%; }
  .task-actions .btn { flex: 1; }
  .task-dots { order: -1; }
  .task-panel { padding: 11px; }
  .task-copy p { font-size: 12px; }
  .canvas-note { font-size: 9px; }
  .dock { bottom: 9px; width: calc(100vw - 18px); gap: 7px; padding: 7px; border-radius: 16px; }
  .combo { display: none; }
  .step-btn { min-height: 48px; padding: 10px 13px; }
  .step-main { font-size: 14px; }
  .step-gain { font-size: 10px; padding: 3px 6px; }
  .dock-hint { display: none; }
  .formula-card { padding: 11px 12px; }
  .concept-grid { grid-template-columns: 1fr; }
  .regime-grid { grid-template-columns: 1fr; }
  .pole-grid { grid-template-columns: 1fr; }
  .pair-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .modal { padding: 22px 17px 17px; border-radius: 18px; max-height: 90vh; }
  .modal-actions { justify-content: stretch; }
  .modal-actions .btn { flex: 1; }
  .modal-actions-spacer { display: none; }
  .intro-mark { display: none; }
  .intro-save-note { display: none; }
  .toasts { top: 158px; right: 9px; left: 9px; width: auto; }
  .toast { font-size: 10.5px; }
}

@media (max-width: 460px) {
  .brand-copy strong { letter-spacing: 0.16em; font-size: 13px; }
  .brand-mark { width: 37px; height: 37px; border-radius: 11px; font-size: 26px; }
  .hud-goal { display: none; }
  .hud-stat { padding: 5px 8px; }
  .icon-btn { width: 38px; height: 38px; border-radius: 9px; }
  .workspace-head { margin-bottom: 10px; }
  .inline-meta { margin-top: 7px; }
  .meta-chip { font-size: 9.5px; padding: 2px 6px; }
  .chapter-card { flex-basis: 160px; min-width: 160px; }
  .shop-head { flex-direction: column; gap: 8px; }
  .bulk { align-self: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* печать не нужна, игра живёт в браузере */
@media print {
  .ambient, .topbar, .dock, .toasts, .modal-backdrop, .shop, .journey { display: none !important; }
  body { background: white; color: black; padding: 0; }
  .layout { display: block; padding: 0; }
  .workspace { border: 0; box-shadow: none; background: white; color: black; }
}

.noscript {
  position: fixed;
  inset: 20px;
  z-index: 999;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #0b1422;
  color: var(--text);
  text-align: center;
}
