/* ============================================================
   Раздел «Теория» (rail → хаб тем → статья).
   На токенах приложения; тёмная тема — автоматически.
   ============================================================ */

.theory-progress { height: 7px; background: var(--line); border-radius: 999px; overflow: hidden; }
.theory-progress-fill { height: 100%; background: linear-gradient(90deg, #F3B880, var(--brand)); border-radius: 999px; transition: width var(--dur-smooth) var(--ease-spring); }

/* ── Хаб: hero ── */
.theory-hub { display: flex; flex-direction: column; gap: 20px; }
.theory-hub-hero {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 20px;
  padding: 26px 30px; border-radius: var(--radius-card); overflow: hidden;
  background:
    radial-gradient(540px 200px at 88% -20%, rgba(223,153,91,.20), transparent 70%),
    linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.theory-eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: "Unbounded", sans-serif; font-size: .7rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--brand-deep); background: var(--brand-soft); padding: 6px 12px; border-radius: 999px;
}
.theory-eyebrow svg { width: 14px; height: 14px; }
.theory-hub-hero h2 { font-size: 1.7rem; line-height: 1.1; margin: 12px 0 6px; }
.theory-hub-hero .muted { font-size: .95rem; max-width: 56ch; }
.theory-hub-progress { margin-top: 16px; max-width: 460px; }
.theory-hub-progress .lbl { display: flex; justify-content: space-between; font-size: .82rem; font-weight: 600; color: var(--ink-2); margin-bottom: 7px; }
.theory-hub-progress .lbl b { font-family: "Unbounded", sans-serif; color: var(--brand-deep); }
.theory-hub-mascot { width: 130px; height: auto; filter: drop-shadow(0 18px 26px rgba(79,54,24,.22)); }

/* ── Хаб: сетка тем ── */
.theory-hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.theory-topic-card {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 9px; width: 100%; text-align: left;
  padding: 20px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-card); cursor: pointer;
  transition: box-shadow var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast);
}
.theory-topic-card:hover { border-color: var(--brand-soft); box-shadow: var(--shadow-md); transform: translateY(-3px); }
.theory-topic-card:active { transform: scale(.99); }
.theory-topic-card.done { border-color: var(--good); }
.theory-topic-num {
  position: absolute; top: 12px; right: 18px; pointer-events: none;
  font-family: "Unbounded", sans-serif; font-weight: 800; font-size: 2.6rem; line-height: 1;
  color: var(--brand); opacity: .12;
}
.theory-topic-top { display: flex; align-items: center; gap: 8px; }
.theory-topic-kim { font-size: .7rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }
.theory-topic-check { width: 22px; height: 22px; border-radius: 50%; background: var(--good); color: #fff; display: grid; place-items: center; font-size: .78rem; font-weight: 800; }
.theory-topic-check svg { width: 13px; height: 13px; stroke-width: 3; }
.theory-topic-title { font-weight: 700; font-size: 1.08rem; line-height: 1.2; padding-right: 40px; }
.theory-topic-desc { font-size: .85rem; color: var(--ink-2); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.theory-topic-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.theory-tag { font-size: .72rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--bg-warm); color: var(--ink-2); }
.theory-tag.gold { background: #FFEDC9; color: #B97500; }
[data-theme="dark"] .theory-tag.gold { background: rgba(245,158,11,.18); color: var(--gold); }
.theory-topic-go { display: inline-flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 6px; font-size: .85rem; font-weight: 700; color: var(--brand-ink); }
.theory-topic-go svg { width: 15px; height: 15px; transition: transform var(--dur-fast); }
.theory-topic-card:hover .theory-topic-go svg { transform: translateX(3px); }

.theory-empty { text-align: center; padding: 40px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.theory-empty img { width: 120px; height: auto; }
.theory-empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

/* ── Хаб: поиск, фильтр по разделам, счётчик ── */
/* .is-filtered-out скрывает то, что не прошло поиск или фильтр; сами узлы остаются в DOM */
.theory-hub .is-filtered-out { display: none; }

.theory-hub-tools { display: flex; flex-direction: column; gap: 12px; }
.theory-search-wrap { position: relative; display: flex; align-items: center; }
.theory-search-icon { position: absolute; left: 15px; display: flex; color: var(--ink-3); pointer-events: none; }
.theory-search-icon svg { width: 17px; height: 17px; }
.theory-search {
  padding: 13px 44px 13px 44px; border-radius: var(--radius-pill);
  font-family: inherit; font-size: .95rem; background: var(--surface);
}
.theory-search::placeholder { color: var(--ink-3); }
.theory-search-clear {
  position: absolute; right: 9px; display: none; place-items: center;
  width: 30px; height: 30px; border: none; border-radius: 50%;
  background: var(--bg-warm); color: var(--ink-2); cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.theory-search-clear svg { width: 15px; height: 15px; }
.theory-search-clear:hover { background: var(--brand-soft); color: var(--brand-deep); }
.theory-search-wrap.has-query .theory-search-clear { display: grid; }

.theory-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.theory-filter { cursor: pointer; font-family: inherit; font-size: .8rem; padding: 8px 13px; }
.theory-filter b { font-family: "Unbounded", sans-serif; font-size: .68rem; color: var(--ink-3); }
.theory-filter.active b { color: var(--brand-deep); }
.theory-filter:hover { border-color: var(--brand-soft); }

.theory-no-results { padding: 28px 24px; }
.theory-no-results img { width: 92px; }
.theory-hub-toolsbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.theory-hub-shown { font-size: .84rem; font-weight: 600; color: var(--ink-3); }
.theory-expand-all { font-size: .8rem; }

/* ── Хаб: разделы кодификатора ── */
.theory-hub-groups { display: flex; flex-direction: column; gap: 10px; }
.theory-group { border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow-sm); overflow: hidden; }
.theory-group.open { border-color: var(--brand-soft); }
.theory-group-head {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 15px 18px; border: none; background: transparent; cursor: pointer;
  font-family: inherit; color: var(--ink); transition: background var(--dur-fast);
}
.theory-group-head:hover { background: var(--bg-soft); }
.theory-group-badge {
  flex-shrink: 0; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px;
  background: var(--brand-soft); color: var(--brand-deep);
  font-family: "Unbounded", sans-serif; font-weight: 800; font-size: .86rem;
}
.theory-group-tx { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.theory-group-title { font-family: "Unbounded", sans-serif; font-weight: 700; font-size: .98rem; line-height: 1.2; }
.theory-group-meta { display: flex; flex-wrap: wrap; gap: 7px; font-size: .78rem; font-weight: 600; color: var(--ink-3); }
.theory-group-meta b { color: var(--brand-ink); font-weight: 700; }
.theory-group-meta > span::before { content: "·"; margin-right: 7px; color: var(--line-2); }
.theory-group-chevron { flex-shrink: 0; display: flex; color: var(--ink-3); transition: transform var(--dur-smooth) var(--ease-spring); }
.theory-group-chevron svg { width: 18px; height: 18px; }
.theory-group.open .theory-group-chevron { transform: rotate(90deg); color: var(--brand-ink); }
.theory-group-body { display: none; padding: 0 18px 18px; }
.theory-group.open .theory-group-body { display: block; animation: fade-in var(--dur-fast) ease both; }

@media (max-width: 640px) {
  .theory-group-head { padding: 13px 14px; gap: 11px; }
  .theory-group-badge { width: 32px; height: 32px; font-size: .78rem; }
  .theory-group-body { padding: 0 14px 14px; }
  .theory-hub-toolsbar { justify-content: flex-start; }
  /* На телефоне список разделов едет в одну строку, а не съедает пол-экрана */
  .theory-filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px 2px; }
  .theory-filters::-webkit-scrollbar { display: none; }
  .theory-filter { flex-shrink: 0; white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  .theory-group-chevron { transition: none; }
  .theory-group.open .theory-group-body { animation: none; }
}

/* ── Статья: двухколоночный лейаут ── */
.theory-view { display: grid; grid-template-columns: 256px 1fr; gap: 26px; align-items: start; }
/* без translateY-анимации на прямом родителе sticky — иначе .theory-view станет containing block и сломает .theory-side */
.content.page-enter > .theory-view { animation: none; }
.theory-main { min-width: 0; display: flex; flex-direction: column; gap: 18px; }

/* sticky-сайдбар оглавления */
.theory-side { position: sticky; top: calc(var(--topbar-h) + 12px); }
.theory-side-inner { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow-sm); padding: 18px; }
.theory-side-title { font-size: 1.05rem; line-height: 1.2; margin: 0 0 14px; }
.theory-side-progress { margin-bottom: 14px; }
.theory-side-progress .lbl { display: flex; justify-content: space-between; font-size: .76rem; font-weight: 600; color: var(--ink-3); margin-bottom: 7px; }
.theory-side-progress .lbl b { font-family: "Unbounded", sans-serif; color: var(--brand-deep); }
.theory-nav { display: flex; flex-direction: column; gap: 2px; }
.theory-nav-group { font-family: "Unbounded", sans-serif; font-size: .62rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); padding: 14px 10px 6px; }
.theory-nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 8px 11px; border-radius: var(--radius-action); border: none; background: transparent; cursor: pointer;
  font-family: inherit; font-size: .84rem; font-weight: 600; color: var(--ink-2); transition: all var(--dur-fast);
}
.theory-nav-item:hover { background: var(--bg-warm); color: var(--brand-deep); }
.theory-nav-item.active { background: var(--brand-soft); color: var(--brand-deep); }
.theory-nav-item .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-2); flex-shrink: 0; transition: background var(--dur-fast); }
.theory-nav-item.active .dot { background: var(--brand); }
.theory-side-pn { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line-2); }
.theory-side-pn-link { text-align: left; background: none; border: none; cursor: pointer; font-family: inherit; font-size: .8rem; font-weight: 700; color: var(--ink-3); padding: 2px 0; transition: color var(--dur-fast); }
.theory-side-pn-link.next { text-align: right; }
.theory-side-pn-link:hover { color: var(--brand-ink); }

/* шапка статьи */
.theory-view-header { display: flex; align-items: center; gap: 14px; }
.theory-view-title { font-size: 1.5rem; line-height: 1.1; }
.theory-back-btn { flex-shrink: 0; gap: 8px; }
.theory-article { display: flex; flex-direction: column; gap: 18px; scroll-margin-top: 96px; }
.theory-article-head { margin-bottom: 2px; }
.theory-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.theory-chip { font-size: .78rem; font-weight: 600; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px; }
.theory-lead { font-size: 1.02rem; color: var(--ink-2); line-height: 1.6; max-width: 70ch; }

.theory-article .card,
.theory-train-cta { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow-sm); padding: 22px 24px; scroll-margin-top: 96px; }
.theory-article .card h3 { font-size: 1.18rem; line-height: 1.2; margin: 0 0 12px; }
.theory-article .card p { color: var(--ink-2); font-size: .98rem; line-height: 1.7; margin: 0 0 10px; }
.theory-article .card p:last-child { margin-bottom: 0; }
.theory-article .card p b, .theory-article .card li b { color: var(--ink); font-weight: 700; }

/* Флагманский урок: визуальная завязка */
.theory-lesson-hero {
  position: relative; min-height: 310px; overflow: hidden; isolation: isolate;
  border: 1px solid rgba(59,130,246,.22); border-radius: var(--radius-card);
  background: var(--surface); box-shadow: var(--shadow-md);
}
.theory-lesson-hero::after {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(255,250,239,.98) 0%, rgba(255,250,239,.9) 35%, rgba(255,250,239,.16) 65%, transparent 100%);
}
.theory-lesson-hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.theory-lesson-hero-copy {
  position: relative; z-index: 1; display: flex; flex-direction: column; justify-content: center;
  min-height: 310px; width: min(52%, 470px); padding: 30px;
}
.theory-lesson-hero-copy > span {
  align-self: flex-start; padding: 6px 10px; border-radius: 999px;
  color: #245CA8; background: rgba(59,130,246,.12); border: 1px solid rgba(59,130,246,.2);
  font-family: "Unbounded", sans-serif; font-size: .64rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
}
.theory-lesson-hero-copy h3 { margin: 13px 0 10px; font-size: clamp(1.3rem, 2.5vw, 1.8rem); line-height: 1.15; }
.theory-lesson-hero-copy p { margin: 0; color: var(--ink-2); font-size: .94rem; line-height: 1.62; }

/* Встроенная лаборатория второго закона Ньютона */
.theory-article .theory-interactive-card {
  padding: 0; overflow: hidden; border-color: rgba(59,130,246,.28);
  background: linear-gradient(145deg, var(--surface), var(--surface-2));
}
.theory-interactive-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 18px;
  padding: 22px 24px 18px; border-bottom: 1px solid var(--line);
}
.theory-interactive-head h3 { margin: 5px 0 6px !important; }
.theory-interactive-head p { margin: 0 !important; max-width: 64ch; font-size: .9rem !important; }
.theory-interactive-kicker {
  color: #245CA8; font-family: "Unbounded", sans-serif; font-size: .63rem; font-weight: 700;
  letter-spacing: .11em; text-transform: uppercase;
}
.theory-touch-hint {
  flex: 0 0 auto; padding: 7px 11px; border-radius: 999px; background: rgba(59,130,246,.1);
  color: #245CA8; font-size: .74rem; font-weight: 800;
}
.newton-lab { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(230px, .75fr); }
.newton-scene-wrap { min-width: 0; padding: 20px 22px 22px; border-right: 1px solid var(--line); }
.newton-goal {
  display: inline-flex; align-items: center; min-height: 28px; margin-bottom: 10px; padding: 5px 10px;
  border: 1px dashed rgba(59,130,246,.42); border-radius: 999px; color: #245CA8;
  background: rgba(59,130,246,.07); font-size: .74rem; font-weight: 750; transition: color var(--dur-fast), background var(--dur-fast);
}
.newton-goal.done { color: #0E7557; border-color: rgba(16,185,129,.45); background: rgba(16,185,129,.12); }
.newton-scene {
  position: relative; height: 205px; overflow: hidden; border: 1px solid rgba(59,130,246,.16);
  border-radius: 16px; background:
    linear-gradient(rgba(59,130,246,.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59,130,246,.055) 1px, transparent 1px),
    linear-gradient(180deg, #F8FCFF, #EEF6FA);
  background-size: 24px 24px, 24px 24px, auto;
}
.newton-track { position: absolute; left: 16px; right: 16px; bottom: 30px; height: 3px; border-radius: 999px; background: #6B7280; opacity: .44; }
.newton-track::after { content: ""; position: absolute; inset: 8px 0 auto; border-top: 1px dashed rgba(73,111,130,.35); }
.newton-cart { position: absolute; z-index: 2; left: 19px; bottom: 34px; width: 132px; height: 72px; will-change: transform; }
.newton-cart-body {
  position: absolute; left: 0; right: 0; bottom: 13px; height: 28px; border: 2px solid #245CA8;
  border-bottom-width: 5px; border-radius: 8px 8px 12px 12px; background: #3B82F6;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 6px 14px rgba(36,92,168,.18);
}
.newton-cart .wheel { position: absolute; z-index: 3; bottom: 0; width: 23px; height: 23px; border: 5px solid #2F4E5E; border-radius: 50%; background: #9DC2D5; }
.newton-cart .wheel.a { left: 18px; } .newton-cart .wheel.b { right: 18px; }
.newton-loads { position: absolute; z-index: 1; left: 19px; right: 19px; bottom: 40px; display: flex; align-items: flex-end; justify-content: center; gap: 3px; height: 35px; }
.newton-loads i { width: 19px; height: 25px; border: 1px solid #8C5422; border-radius: 4px; background: #DF995B; box-shadow: inset 0 1px 0 rgba(255,255,255,.55); }
.newton-loads i:nth-child(even) { height: 34px; }
.newton-loads i[hidden] { display: none; }
.newton-force-arrow { position: absolute; z-index: 4; top: 46px; height: 3px; border-radius: 999px; }
.newton-force-arrow::after { content: ""; position: absolute; top: 50%; width: 9px; height: 9px; border-top: 3px solid; border-right: 3px solid; }
.newton-force-arrow span { position: absolute; top: -23px; white-space: nowrap; font-size: .7rem; font-weight: 800; }
.newton-force-arrow.push { left: 75px; width: var(--push-size, 66px); color: #245CA8; background: #3B82F6; }
.newton-force-arrow.push::after { right: -1px; transform: translateY(-50%) rotate(45deg); }
.newton-force-arrow.push span { left: 0; }
.newton-force-arrow.resist { right: 28px; width: var(--resist-size, 42px); color: #9A4B3D; background: #D96755; }
.newton-force-arrow.resist::after { left: -1px; transform: translateY(-50%) rotate(-135deg); }
.newton-force-arrow.resist span { right: 0; }
.newton-live-formula {
  display: grid; grid-template-columns: 1fr auto 1fr auto 1.1fr; align-items: center; gap: 9px;
  margin-top: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
}
.newton-live-formula > span:not(.op) { display: flex; flex-direction: column; gap: 1px; }
.newton-live-formula small { color: var(--ink-3); font-size: .65rem; font-weight: 650; }
.newton-live-formula b { color: var(--ink); font-family: "Unbounded", sans-serif; font-size: .88rem; }
.newton-live-formula .op { color: var(--ink-3); font-weight: 800; }
.newton-live-formula .answer { padding: 8px 10px; border-radius: 10px; background: rgba(59,130,246,.1); }
.newton-live-formula .answer b { color: #245CA8; }
.newton-run-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.newton-run-row .btn { flex: 0 0 auto; }
.newton-run-row > span { color: var(--ink-3); font-size: .76rem; line-height: 1.4; }
.newton-controls { display: flex; flex-direction: column; gap: 18px; padding: 22px; background: rgba(255,255,255,.22); }
.newton-control { display: flex; flex-direction: column; gap: 8px; }
.newton-control > span { display: flex; justify-content: space-between; gap: 10px; color: var(--ink-2); font-size: .82rem; }
.newton-control output { color: #245CA8; font-weight: 850; font-variant-numeric: tabular-nums; }
.newton-control small { color: var(--ink-3); font-size: .69rem; line-height: 1.35; }
.newton-control input[type="range"] { width: 100%; accent-color: #3B82F6; cursor: ew-resize; }
.newton-vector-summary { display: flex; flex-direction: column; gap: 8px; margin-top: 2px; padding-top: 16px; border-top: 1px dashed var(--line-2); }
.newton-vector-summary > div { display: grid; grid-template-columns: 86px 1fr; align-items: center; gap: 8px; color: var(--ink-3); font-size: .68rem; font-weight: 700; }
.newton-vector-summary i { position: relative; display: block; height: 7px; overflow: hidden; border-radius: 99px; background: var(--line); }
.newton-vector-summary b { display: block; width: 0; height: 100%; border-radius: inherit; background: #3B82F6; transition: width var(--dur-smooth) var(--ease-spring); }
.newton-vector-summary .back b { margin-left: auto; background: #D96755; }
.newton-vector-summary .net b { background: var(--good); }

[data-theme="dark"] .theory-lesson-hero::after { background: linear-gradient(90deg, rgba(36,30,23,.98), rgba(36,30,23,.88) 38%, rgba(36,30,23,.18) 72%, transparent); }
[data-theme="dark"] .theory-lesson-hero img { filter: brightness(.78) saturate(.9); }
[data-theme="dark"] .theory-lesson-hero-copy > span,
[data-theme="dark"] .theory-interactive-kicker,
[data-theme="dark"] .theory-touch-hint,
[data-theme="dark"] .newton-goal,
[data-theme="dark"] .newton-control output,
[data-theme="dark"] .newton-live-formula .answer b { color: #79ACF7; }
[data-theme="dark"] .newton-scene { background: linear-gradient(rgba(121,172,247,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(121,172,247,.06) 1px, transparent 1px), #211D1A; background-size: 24px 24px, 24px 24px, auto; }

@media (max-width: 900px) {
  .newton-lab { grid-template-columns: 1fr; }
  .newton-scene-wrap { border-right: 0; border-bottom: 1px solid var(--line); }
  .newton-controls { display: grid; grid-template-columns: repeat(3, 1fr); }
  .newton-vector-summary { grid-column: 1 / -1; }
}
@media (max-width: 620px) {
  .theory-lesson-hero { min-height: 410px; }
  .theory-lesson-hero::after { background: linear-gradient(0deg, rgba(255,250,239,.99) 0%, rgba(255,250,239,.93) 48%, rgba(255,250,239,.04) 76%); }
  .theory-lesson-hero img { height: 58%; object-position: 66% center; }
  .theory-lesson-hero-copy { justify-content: flex-end; width: 100%; min-height: 410px; padding: 20px; }
  .theory-lesson-hero-copy h3 { font-size: 1.26rem; }
  .theory-interactive-head { padding: 18px; }
  .theory-touch-hint { display: none; }
  .newton-scene-wrap, .newton-controls { padding: 16px; }
  .newton-controls { display: flex; }
  .newton-live-formula { grid-template-columns: 1fr auto 1fr; }
  .newton-live-formula > span:nth-child(4), .newton-live-formula > span:nth-child(5) { margin-top: 4px; }
  .newton-live-formula .answer { grid-column: 1 / -1; }
  .newton-run-row { align-items: stretch; flex-direction: column; }
  .newton-run-row .btn { width: 100%; }
  [data-theme="dark"] .theory-lesson-hero::after { background: linear-gradient(0deg, rgba(36,30,23,.99), rgba(36,30,23,.92) 50%, rgba(36,30,23,.08) 78%); }
}

/* теория-карточка: текст + рисунок */
.theory-card .row { display: grid; grid-template-columns: 1fr 280px; gap: 24px; align-items: center; }
.theory-card .figure { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.theory-card .figure svg { max-width: 100%; height: auto; }
.theory-card .figure .cap { font-size: .78rem; color: var(--ink-3); font-weight: 600; text-align: center; }
@media (max-width: 720px) { .theory-card .row { grid-template-columns: 1fr; } }

/* формула */
.formula-box {
  margin: 14px 0; padding: 16px 20px; border-radius: var(--radius); text-align: center; overflow-x: auto;
  background: var(--surface-2); border: 1px solid var(--brand-soft);
}
.formula-box .katex { font-size: 1.3em; }
[data-theme="dark"] .theory-article .katex { color: var(--ink); }

/* пример */
.example-box { background: rgba(245,158,11,.10); border: 1px solid rgba(245,158,11,.28); border-left: 4px solid var(--gold); border-radius: var(--radius); padding: 18px 20px; }
.example-box .lbl { display: inline-block; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); font-weight: 800; margin-bottom: 10px; }
.example-box .q { font-size: .96rem; color: var(--ink); font-weight: 600; margin-bottom: 10px; }
.example-box .sol { font-size: .92rem; color: var(--ink-2); line-height: 1.8; }
.example-box .step { display: block; }

/* алгоритм */
.algorithm-card .algorithm-step { display: flex; gap: 14px; padding: 11px 0; border-top: 1px dashed var(--line-2); }
.algorithm-card .algorithm-step:first-of-type { border-top: none; }
.algorithm-card .algorithm-step .n { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; background: var(--sec); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: .82rem; }
.algorithm-card .algorithm-step .tx { font-size: .96rem; color: var(--ink-2); line-height: 1.55; padding-top: 3px; }
.algorithm-card .algorithm-step .tx b { color: var(--ink); }

/* типичные ошибки */
.mistakes-card .mistake-item { display: flex; gap: 14px; padding: 16px 0; border-top: 1px dashed var(--line-2); }
.mistakes-card .mistake-item:first-of-type { border-top: none; }
.mistakes-card .mistake-item .badge { flex-shrink: 0; align-self: flex-start; font-size: .7rem; font-weight: 800; letter-spacing: .03em; background: var(--bad-soft); color: var(--bad); padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.mistakes-card .mistake-item .body p { font-size: .92rem; margin: 0; }

/* шпаргалка */
.remember-card { background: var(--surface-2); border-color: var(--brand-soft); }
.remember-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.remember-grid .tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 15px; display: flex; flex-direction: column; gap: 8px; }
.remember-grid .tile .n { width: 22px; height: 22px; border-radius: var(--radius-sm); background: var(--brand-soft); color: var(--brand-deep); display: grid; place-items: center; font-weight: 800; font-size: .7rem; }
.remember-grid .tile .f { font-size: .9rem; color: var(--ink); font-weight: 600; line-height: 1.4; }
@media (max-width: 720px) { .remember-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 460px) { .remember-grid { grid-template-columns: 1fr; } }

/* стратегия */
.strategy-card { border-left: 4px solid var(--gold); }
.strategy-card ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.strategy-card li { display: flex; gap: 12px; font-size: .96rem; color: var(--ink-2); line-height: 1.55; }
.strategy-card li .v { flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%; background: rgba(245,158,11,.18); color: var(--gold); display: grid; place-items: center; margin-top: 1px; }
.strategy-card li .v svg { width: 12px; height: 12px; }

/* кнопка «изучено» */
.mark-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.btn-mark-read { display: inline-flex; align-items: center; gap: 10px; padding: 13px 22px; border-radius: var(--radius-btn); background: var(--surface); border: 2px solid var(--brand); color: var(--brand-deep); font-family: inherit; font-weight: 700; font-size: .95rem; cursor: pointer; transition: all var(--dur-fast); }
.btn-mark-read svg { width: 18px; height: 18px; }
.btn-mark-read:hover { background: var(--brand-soft); }
.btn-mark-read.done { background: var(--good); border-color: var(--good); color: #fff; }
.mark-row .hint { font-size: .82rem; color: var(--ink-3); }

/* CTA на тренажёр (с маскотом) */
.theory-train-cta {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 20px; padding: 24px 28px;
  background:
    radial-gradient(420px 160px at 92% -30%, rgba(73,111,130,.18), transparent 70%),
    linear-gradient(135deg, var(--sec) 0%, var(--sec-ink) 100%);
  border: none; color: #fff;
}
.theory-train-cta .tx h3 { margin: 0 0 6px; color: #fff; font-size: 1.2rem; }
.theory-train-cta .tx p { margin: 0 0 16px; color: rgba(255,255,255,.82); font-size: .92rem; line-height: 1.5; max-width: 46ch; }
.theory-train-cta .btn-primary { background: var(--brand); color: #fff; }
.theory-train-cta .btn svg { width: 16px; height: 16px; }
.theory-cta-mascot { width: 120px; height: auto; filter: drop-shadow(0 16px 22px rgba(0,0,0,.28)); }

/* prev / next */
.theory-pn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.theory-pn-card {
  display: flex; flex-direction: column; gap: 8px; text-align: left; cursor: pointer;
  padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm); transition: transform var(--dur-fast), box-shadow var(--dur-fast), border-color var(--dur-fast); font-family: inherit;
}
.theory-pn-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--brand-soft); }
.theory-pn-card .dir { display: flex; align-items: center; gap: 6px; font-size: .76rem; font-weight: 700; color: var(--ink-3); }
.theory-pn-card .dir svg { width: 14px; height: 14px; }
.theory-pn-card .nm { font-family: "Unbounded", sans-serif; font-weight: 700; font-size: 1rem; line-height: 1.2; }
.theory-pn-card.next { text-align: right; }
.theory-pn-card.next .dir { justify-content: flex-end; }

/* ── Адаптив ── */
@media (max-width: 980px) {
  .theory-view { grid-template-columns: 1fr; }
  .theory-side { display: none; }
}
@media (max-width: 760px) {
  .theory-hub-hero { grid-template-columns: 1fr; text-align: left; }
  .theory-hub-mascot { display: none; }
  .theory-train-cta { grid-template-columns: 1fr; }
  .theory-cta-mascot { display: none; }
  .theory-pn-grid { grid-template-columns: 1fr; }
  .theory-pn-card.next, .theory-pn-card.next .dir { text-align: left; justify-content: flex-start; }
}

/* ── Тёмная тема: подписи внутри SVG читаемы (перебиваем хардкод fill) ── */
[data-theme="dark"] .theory-card .figure svg text { fill: var(--ink); }

/* ── Кнопка «Спросить Мишу» в карточке теории ── */
.theory-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.theory-article .theory-card-head h3 { margin: 0; }
.theory-ask-btn { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); font-family: inherit; font-size: .76rem; font-weight: 600; cursor: pointer; transition: all var(--dur-fast); }
.theory-ask-btn:hover { border-color: var(--brand-soft); color: var(--brand-deep); background: var(--brand-soft); }
.theory-ask-btn svg { width: 14px; height: 14px; }
@media (max-width: 560px) { .theory-ask-btn span { display: none; } }

/* ── Блок «Проверь себя» (встроенная мини-практика) ── */
.theory-check-card { border-color: var(--brand-soft); }
.theory-article .theory-check-card h3 { display: flex; align-items: center; gap: 8px; }
.theory-check-card h3 svg { width: 18px; height: 18px; color: var(--good); }
.theory-check-intro { color: var(--ink-2); margin-bottom: 14px; }

/* ── Мобильное оглавление статьи (chips) — видно когда сайдбар скрыт ── */
.theory-mobile-nav { display: none; }
@media (max-width: 980px) {
  .theory-mobile-nav { display: block; position: sticky; top: var(--topbar-h); z-index: 6; margin: 0 -4px 10px; padding: 8px 4px; background: var(--bg); }
  .theory-mobile-nav-track { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .theory-mobile-nav-track::-webkit-scrollbar { display: none; }
  .theory-chip-nav { flex: 0 0 auto; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-family: inherit; font-size: .8rem; font-weight: 600; white-space: nowrap; cursor: pointer; transition: all var(--dur-fast); }
  .theory-chip-nav.active { background: var(--brand-soft); color: var(--brand-deep); border-color: var(--brand-soft); }
}

/* ── Тень-подсказка горизонтального скролла длинных формул ── */
.formula-box { background-image: linear-gradient(var(--surface-2), var(--surface-2)), linear-gradient(var(--surface-2), var(--surface-2)), linear-gradient(90deg, rgba(79,54,24,.10), transparent), linear-gradient(270deg, rgba(79,54,24,.10), transparent); background-position: left center, right center, left center, right center; background-repeat: no-repeat; background-size: 24px 100%, 24px 100%, 12px 100%, 12px 100%; background-attachment: local, local, scroll, scroll; }

/* ── Словарь темы (glossary) ── */
.glossary-grid { display: grid; gap: 10px; }
.glossary-item { display: grid; grid-template-columns: minmax(120px, 180px) 1fr; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.glossary-item b { color: var(--brand-deep); font-size: .9rem; }
.glossary-item span { color: var(--ink-2); font-size: .9rem; }
@media (max-width: 560px) { .glossary-item { grid-template-columns: 1fr; gap: 4px; } }

/* ── Растровая иллюстрация (image) ── */
.theory-image-card .figure { margin: 0; }
.theory-image-card img { max-width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--line); }
.theory-image-card .cap { display: block; margin-top: 8px; color: var(--ink-2); font-size: .8rem; }

/* ── Текстовый fallback эксперимента (пока лаборатории не встроены) ── */
.theory-interactive-fallback .theory-interactive-kicker { display: inline-block; margin-bottom: 6px; }
