/* Интерактивные виджеты в теории */
.widget { margin: 1.25rem 0; padding: 1rem; background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--primary); border-radius: var(--radius-sm); max-width: 46rem; }
.widget-hover { border-left-color: var(--amber); background: var(--amber-soft); border-color: var(--amber-border); }
.widget-graph { max-width: 46rem; }
.widget-trainer { border-left-color: var(--success); }
.widget-quiz { border-left-color: var(--success); }
.widget > :last-child { margin-bottom: 0; }
.widget__static > :last-child { margin-bottom: 0; }
.widget__title { font-weight: 700; margin: 0 0 0.6rem; }
.widget-btn {
  display: inline-flex; align-items: center; gap: 0.4rem; min-height: var(--tap); padding: 0.5rem 1rem; font: inherit; font-weight: 600;
  color: var(--primary-text); background: var(--primary-soft); border: 1.5px solid var(--primary-border); border-radius: var(--radius-sm); cursor: pointer;
}
.widget-btn:hover:not([disabled]) { background: var(--primary-soft-hover); }
.widget-btn[disabled] { opacity: 0.55; cursor: default; }

/* reveal */
.reveal__panel { margin-top: 0.8rem; }
.reveal__panel[hidden] { display: none; }
.reveal__panel > :last-child { margin-bottom: 0; }
.reveal__step { padding: 0.6rem 0.9rem; margin-bottom: 0.5rem; background: var(--primary-soft); border-radius: var(--radius-sm); animation: appear 0.25s ease-out; }
.reveal__step > :last-child { margin-bottom: 0; }
.reveal__counter { margin-left: 0.6rem; font-size: 0.875rem; color: var(--muted); }
@keyframes appear { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* hover / tap */
.hover-text { margin: 0; }
.hover-wrap { position: relative; display: inline; }
.hover-term {
  font: inherit; color: var(--amber-text); font-weight: 600; background: var(--glass); border: 0; border-bottom: 2px dotted var(--amber-text);
  display: inline-flex; align-items: center; vertical-align: middle; padding: 0.15rem 0.45rem; margin: 0 0.1rem; cursor: help; border-radius: 4px; min-height: var(--tap); min-width: var(--tap); text-align: left;
}
.hover-term:hover, .hover-term[aria-expanded="true"] { background: var(--amber-soft-hover); }
.hover-tip {
  position: fixed; z-index: 60; left: 0; top: 0; width: max-content; max-width: min(20rem, calc(100vw - 2rem));
  background: var(--tip-bg); color: var(--tip-fg); padding: 0.6rem 0.8rem; border-radius: var(--radius-sm); font-size: 0.95rem; line-height: 1.45; box-shadow: var(--shadow); font-weight: 400;
}
.hover-tip[hidden] { display: none; }
.hover-tip .katex { color: var(--tip-fg); }
.hover-tip a { color: var(--tip-link); }

/* graph */
.graph__title { font-weight: 700; margin-bottom: 0.5rem; }
.graph__canvas-wrap { position: relative; width: 100%; touch-action: pan-y; }
.graph__canvas { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; max-height: 70vh; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: crosshair; touch-action: pan-y; }
.graph__canvas:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.graph__controls { display: grid; gap: 0.35rem 1.25rem; margin-top: 0.8rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .graph__controls { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); } }
.graph__ctrl { display: grid; grid-template-columns: 2.5rem 1fr 3.5rem; align-items: center; gap: 0.5rem; min-height: var(--tap); }
.graph__ctrl label { font-weight: 700; font-style: italic; }
.graph__ctrl input[type="range"] { width: 100%; height: var(--tap); accent-color: var(--primary); margin: 0; }
.graph__ctrl output { font-variant-numeric: tabular-nums; text-align: right; font-weight: 600; }
.graph__formula { margin: 0.6rem 0 0; font-size: 1.1rem; text-align: center; overflow-x: auto; }
.graph__readout { margin: 0.5rem 0 0; font-size: 0.95rem; color: var(--muted); min-height: 2.9em; }
.graph__caption { margin: 0.4rem 0 0; font-size: 0.9rem; color: var(--muted); }

/* trainer */
.trainer__prompt { font-weight: 600; margin-bottom: 0.75rem; }
.trainer__slots { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; min-height: 3.2rem; padding: 0.5rem; background: var(--surface-2); border-radius: var(--radius-sm); border: 2px dashed var(--border-strong); margin-bottom: 0.75rem; overflow-x: auto; }
.trainer__slots.is-ok { border-color: var(--success); background: var(--success-soft); }
.trainer__slots.is-bad { border-color: var(--danger); background: var(--danger-soft); }
.trainer__bank { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.75rem; }
.chip { min-height: var(--tap); min-width: var(--tap); padding: 0.35rem 0.8rem; font: inherit; background: var(--surface); border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer; }
.chip:hover:not([disabled]) { border-color: var(--primary); background: var(--primary-soft); }
.chip[disabled] { opacity: 0.35; cursor: default; }
.chip--placed { background: var(--primary-soft); border-color: var(--primary-border); }
.trainer__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.trainer__fill { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; font-size: 1.15rem; padding: 0.6rem; background: var(--surface-2); border-radius: var(--radius-sm); margin-bottom: 0.75rem; }
.trainer__fill .select { width: auto; min-width: 6rem; }
.trainer__fill .select.is-ok { border-color: var(--success); background: var(--success-soft); }
.trainer__fill .select.is-bad { border-color: var(--danger); background: var(--danger-soft); }
.trainer__feedback, .quiz__feedback { min-height: 1.5em; font-weight: 600; margin: 0.5rem 0 0; }
.is-ok-text { color: var(--success-text); }
.is-bad-text { color: var(--danger-text); }

/* quiz */
.quiz__question { font-weight: 600; margin-bottom: 0.75rem; }
.quiz__options { list-style: none; padding: 0; margin: 0 0 0.5rem; display: grid; gap: 0.5rem; }
.quiz__option { display: flex; align-items: center; gap: 0.7rem; width: 100%; min-height: var(--tap); padding: 0.5rem 0.9rem; font: inherit; text-align: left; background: var(--surface); border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer; }
.quiz__option:hover:not([disabled]) { border-color: var(--primary); background: var(--primary-soft); }
.quiz__option[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); }
.quiz__option.is-correct { border-color: var(--success); background: var(--success-soft); }
.quiz__option.is-wrong { border-color: var(--danger); background: var(--danger-soft); }
.quiz__option[disabled] { cursor: default; }
.quiz__num { font-weight: 700; color: var(--muted); }
.quiz__explanation { margin-top: 0.6rem; padding: 0.6rem 0.9rem; background: var(--success-soft); border-radius: var(--radius-sm); }
.quiz__explanation > :last-child { margin-bottom: 0; }

/* vector-plane */
.widget-vector-plane { max-width: 46rem; }
.vp__svg { display: block; width: 100%; height: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); user-select: none; -webkit-user-select: none; }
.vp__line { stroke: var(--border); stroke-width: 0.03; }
.vp__axis { stroke: var(--muted); stroke-width: 0.06; }
.vp__tick { font-size: 0.42px; fill: var(--muted); font-family: var(--font); }
.vp__vec { stroke-width: 0.1; stroke-linecap: round; fill: none; }
.vp__vec--ghost { stroke-width: 0.06; opacity: 0.75; }
.vp__label { font-size: 0.55px; font-style: italic; font-weight: 700; font-family: var(--font); paint-order: stroke; stroke: var(--surface); stroke-width: 0.14; }
.vp__hit { fill: transparent; }
.vp__dot { stroke: var(--surface); stroke-width: 0.08; }
.vp__handle { outline: none; }
.vp__handle.is-draggable { cursor: grab; touch-action: none; }
.vp__handle:active { cursor: grabbing; }
.vp__handle:focus-visible .vp__dot { stroke: var(--text); stroke-width: 0.14; }
.vp__handle:focus-visible .vp__hit { stroke: var(--focus); stroke-width: 0.06; fill: var(--focus-soft); }
.vp__out { list-style: none; padding: 0; margin: 0.7rem 0 0; display: grid; gap: 0.15rem; font-size: 1.05rem; }
.vp__row { overflow-x: auto; overflow-y: hidden; }
.vp__hint { margin: 0.5rem 0 0.25rem; font-size: 0.92rem; }
.vp__reset { margin-top: 0.25rem; }

/* trig-circle */
.widget-trig-circle, .widget-derivative-graph { max-width: 46rem; }
.tc__svg { display: block; width: 100%; max-width: 420px; margin: 0 auto; height: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); user-select: none; -webkit-user-select: none; }
.tc__axis { stroke: var(--muted); stroke-width: 0.012; }
.tc__circle { fill: none; stroke: var(--text); stroke-width: 0.02; }
.tc__tline { stroke: var(--success); stroke-width: 0.012; stroke-dasharray: 0.05 0.04; opacity: 0.6; }
.tc__mark { stroke: var(--muted); stroke-width: 0.01; }
.tc__tick { font-size: 0.11px; fill: var(--muted); font-family: var(--font); }
.tc__radius { stroke: var(--text); stroke-width: 0.02; }
.tc__radius--beta { stroke: var(--danger); stroke-dasharray: 0.06 0.04; }
.tc__arc { fill: none; stroke: var(--text); stroke-width: 0.014; }
.tc__cos, .tc__sin, .tc__tg { stroke-width: 0.035; stroke-linecap: round; }
.tc__ray { stroke: var(--muted); stroke-width: 0.01; stroke-dasharray: 0.04 0.04; }
.tc__beta { fill: var(--surface); stroke: var(--danger); stroke-width: 0.03; }
.tc__hit { fill: transparent; }
.tc__dot { fill: var(--text); stroke: var(--surface); stroke-width: 0.02; }
.tc__handle { outline: none; cursor: grab; touch-action: none; }
.tc__handle:focus-visible .tc__hit { stroke: var(--focus); stroke-width: 0.02; fill: var(--focus-soft); }
.tc__controls { display: grid; grid-template-columns: 4.5rem 1fr 5rem; align-items: center; gap: 0.5rem; min-height: var(--tap); margin-top: 0.6rem; }
.tc__controls input[type="range"] { width: 100%; height: var(--tap); accent-color: var(--primary); margin: 0; }
.tc__label { font-weight: 700; }
.tc__angle { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.tc__reduction { display: flex; flex-wrap: wrap; gap: 0.5rem 0.8rem; align-items: center; margin-top: 0.4rem; }
.tc__out { list-style: none; padding: 0; margin: 0.6rem 0 0; display: grid; gap: 0.15rem; font-size: 1.05rem; }
.tc__row { overflow-x: auto; overflow-y: hidden; }

/* derivative-graph */
.dg__wrap { width: 100%; }
.dg__canvas { display: block; width: 100%; aspect-ratio: 16 / 8; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); touch-action: pan-y; cursor: crosshair; }
.dg__cap { margin: 0.7rem 0 0.25rem; font-weight: 600; }
.dg__legend { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.5rem 0 0; font-size: 0.9rem; }
.dg__chip { padding: 0.05rem 0.6rem; border-radius: 999px; }
.dg__chip--up { background: var(--success-soft); color: var(--success-text); }
.dg__chip--down { background: var(--danger-soft); color: var(--danger-text); }
.dg__verdict { font-weight: 600; }
