/* ────────────────────────────────────────────────────────────
   Tutorial Design System
   Builds on the root design tokens from /style.css
   ──────────────────────────────────────────────────────────── */

:root {
  --tut-content-width: 720px;
  --tut-wide-width: 1080px;
  --tut-side-pad: 1.5rem;

  --tut-text: #e8e8ee;
  --tut-muted: #8b8ba0;
  --tut-soft: #b4b4c8;
  --tut-bg: #0a0a0f;
  --tut-surface: #12121a;
  --tut-surface-2: #1a1a26;
  --tut-border: #25253a;
  --tut-border-soft: #1e1e2e;
  --tut-accent: #a78bfa;
  --tut-accent-2: #7c3aed;
  --tut-accent-glow: rgba(167, 139, 250, 0.18);
  --tut-success: #34d399;
  --tut-warn: #fbbf24;
  --tut-danger: #f87171;
  --tut-info: #60a5fa;

  --tut-code-bg: #0d0d15;
  --tut-code-border: #1f1f30;

  --serif: ui-serif, "Iowan Old Style", "Apple Garamond", Baskerville, "Georgia", "Times New Roman", serif;
  --mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --math: "Cambria Math", "Latin Modern Math", "STIX Two Math", "Noto Sans Math", "DejaVu Serif", Cambria, "Georgia", serif;
}

/* ── Visually-hidden text for screen-reader-only descriptions ── */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ── No-JS banner ── */
.noscript-banner {
  max-width: var(--tut-wide-width);
  margin: 1rem auto;
  padding: 0.85rem 1.1rem;
  background: rgba(251, 191, 36, 0.10);
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-left: 3px solid var(--tut-warn);
  border-radius: 6px;
  color: var(--tut-soft);
  font-size: 0.9rem;
  line-height: 1.55;
}

/* ── Honor reduced-motion preferences for users who ask for less animation ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Focus rings: explicit, visible, only for keyboard users ── */
.slider:focus-visible,
.dropdown:focus-visible,
textarea:focus-visible,
.gloss-link:focus-visible,
.cite a:focus-visible,
input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--tut-accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(167, 139, 250, 0.18);
}

canvas[tabindex]:focus-visible {
  outline: 2px solid var(--tut-accent);
  outline-offset: 2px;
}

/* ── Glossary trigger styled as inline link ── */
button.gloss-link {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  display: inline;
}

/* ── Trainer widget: grid uses a class so the mobile @media rule can collapse it ── */
.trainer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.25rem;
}
@media (max-width: 720px) {
  .trainer-grid { grid-template-columns: 1fr; }
}

/* ── Loss-curve legend swatches: distinguish train vs val by shape, not just color ── */
.curve-legend .swatch-solid {
  height: 3px;
  width: 22px;
  display: inline-block;
  border-radius: 1.5px;
}
.curve-legend .swatch-dashed {
  height: 3px;
  width: 22px;
  display: inline-block;
  background: transparent !important;
  border-top: 2px dashed currentColor;
  position: relative;
}
.curve-legend .swatch-dashed::before {
  content: '';
  position: absolute;
  inset: -2px 0 0 0;
  border-top: 2px dashed #f87171;
}

/* ── Reading container ── */
.tut-shell {
  max-width: var(--tut-wide-width);
  margin: 0 auto;
  padding: 0 var(--tut-side-pad);
  display: grid;
  grid-template-columns: 1fr min(var(--tut-content-width), calc(100% - 2rem)) 1fr;
  column-gap: 2rem;
}

.tut-shell > * { grid-column: 2; }

.tut-shell > .tut-wide   { grid-column: 1 / -1; }
.tut-shell > .tut-bleed  { grid-column: 1 / -1; max-width: var(--tut-wide-width); margin-left: auto; margin-right: auto; }

/* ── Hero ── */
.tut-hero {
  padding: 6rem 0 3rem;
  text-align: left;
  position: relative;
}

.tut-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--tut-accent);
  margin-bottom: 1.5rem;
}

.tut-eyebrow::before {
  content: '';
  width: 24px;
  height: 1px;
  background: var(--tut-accent);
}

.tut-hero h1 {
  font-size: clamp(2.5rem, 5.5vw, 4.25rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.04;
  margin: 0;
  background: linear-gradient(180deg, #fff 0%, #c6b8f5 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tut-hero-sub {
  margin-top: 1.5rem;
  font-size: 1.2rem;
  line-height: 1.5;
  color: var(--tut-soft);
  max-width: 640px;
}

.tut-meta {
  margin-top: 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  font-size: 0.85rem;
  color: var(--tut-muted);
  padding-top: 1.25rem;
  border-top: 1px solid var(--tut-border-soft);
}

.tut-meta strong {
  color: var(--tut-text);
  font-weight: 600;
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
  color: var(--tut-muted);
}

.tut-meta span { color: var(--tut-soft); font-weight: 500; }

/* ── Body typography ── */
.tut-shell h2 {
  margin-top: 5rem;
  margin-bottom: 1.25rem;
  font-size: clamp(1.6rem, 2.8vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  scroll-margin-top: 5rem;
}

.tut-shell h2 .tut-numeral {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.72em;
  color: var(--tut-accent);
  margin-right: 0.65rem;
  font-weight: 600;
  letter-spacing: 0;
}

.tut-shell h3 {
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--tut-text);
  scroll-margin-top: 5rem;
}

.tut-shell h4 {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tut-muted);
  font-weight: 700;
}

.tut-shell p {
  font-size: 1.04rem;
  line-height: 1.72;
  color: var(--tut-soft);
  margin: 0 0 1.15rem;
}

.tut-shell p strong { color: var(--tut-text); font-weight: 600; }
.tut-shell p em { color: var(--tut-text); font-style: italic; }

.tut-shell ul, .tut-shell ol {
  margin: 0 0 1.25rem 0;
  padding-left: 1.25rem;
  color: var(--tut-soft);
  font-size: 1.04rem;
  line-height: 1.7;
}

.tut-shell li { margin-bottom: 0.4rem; }
.tut-shell li::marker { color: var(--tut-accent); }

.tut-shell a {
  color: var(--tut-accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(167, 139, 250, 0.25);
  transition: border-color 0.15s, color 0.15s;
}
.tut-shell a:hover { color: #c6b8f5; border-bottom-color: var(--tut-accent); }

.tut-shell hr {
  border: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--tut-border), transparent);
  margin: 3rem 0;
}

/* ── Lead paragraph ── */
.tut-lead {
  font-size: 1.22rem !important;
  line-height: 1.6 !important;
  color: var(--tut-text) !important;
  font-weight: 400;
  letter-spacing: -0.01em;
  margin-bottom: 2rem !important;
}

.tut-lead::first-letter {
  font-family: var(--serif);
  float: left;
  font-size: 3.6rem;
  line-height: 0.85;
  padding-right: 0.6rem;
  padding-top: 0.4rem;
  font-weight: 700;
  color: var(--tut-accent);
}

/* ── Math ── */
.math {
  font-family: var(--math);
  font-style: italic;
  color: var(--tut-text);
}

.math-block {
  font-family: var(--math);
  margin: 1.75rem auto;
  padding: 1.25rem 1.5rem;
  background: var(--tut-surface);
  border: 1px solid var(--tut-border);
  border-radius: 10px;
  font-size: 1.15rem;
  color: var(--tut-text);
  position: relative;
  overflow: visible;
  text-align: center;
  line-height: 2;
}

.math-block .label {
  position: absolute;
  top: 0.5rem;
  right: 0.85rem;
  font-family: var(--mono);
  font-style: normal;
  font-size: 0.7rem;
  color: var(--tut-muted);
  letter-spacing: 0.08em;
}

/* ── Plain-English gloss below an equation ── */
.math-gloss {
  margin: -1.25rem 0 1.75rem !important;
  padding: 0.75rem 1.1rem !important;
  background: rgba(167, 139, 250, 0.05);
  border-left: 2px solid var(--tut-accent);
  border-radius: 0 6px 6px 0;
  font-size: 0.92rem !important;
  line-height: 1.55 !important;
  color: var(--tut-soft) !important;
  font-style: italic;
  position: relative;
}

.math-gloss::before {
  content: 'IN PLAIN ENGLISH';
  display: block;
  font-family: var(--mono);
  font-size: 0.62rem;
  font-style: normal;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--tut-accent);
  margin-bottom: 0.3rem;
}

.math-gloss strong {
  color: var(--tut-text);
  font-style: normal;
  font-weight: 600;
  background: rgba(167, 139, 250, 0.12);
  padding: 0 0.3em;
  border-radius: 3px;
}

/* ── Hoverable math variable ── */
.mvar {
  cursor: help;
  position: relative;
  padding: 0 0.05em;
  border-radius: 3px;
  transition: background 0.15s;
  font-style: italic;
}

.mvar:hover {
  background: rgba(167, 139, 250, 0.18);
}

.mvar::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  width: max-content;
  max-width: 220px;
  padding: 0.5rem 0.7rem;
  background: #14141f;
  border: 1px solid var(--tut-border);
  border-radius: 6px;
  font-family: var(--serif);
  font-style: normal;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--tut-text);
  text-align: left;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 30;
  box-shadow: 0 8px 22px rgba(0,0,0,0.6);
}

.mvar:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── "Stuck?" expandable refresher ── */
details.stuck {
  margin: 1.5rem 0;
  padding: 0;
  background: linear-gradient(180deg, rgba(96, 165, 250, 0.06), rgba(96, 165, 250, 0.02));
  border: 1px solid rgba(96, 165, 250, 0.22);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.2s;
}

details.stuck[open] {
  border-color: rgba(96, 165, 250, 0.5);
}

details.stuck > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.85rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--tut-info);
  user-select: none;
}

details.stuck > summary::-webkit-details-marker { display: none; }

details.stuck > summary::before {
  content: '?';
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(96, 165, 250, 0.15);
  border: 1px solid rgba(96, 165, 250, 0.4);
  color: var(--tut-info);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  transition: transform 0.2s, background 0.2s;
}

details.stuck[open] > summary::before {
  content: '✓';
  background: rgba(96, 165, 250, 0.25);
  transform: rotate(360deg);
}

details.stuck > summary::after {
  content: '▾';
  margin-left: auto;
  color: var(--tut-info);
  opacity: 0.5;
  transition: transform 0.2s;
}

details.stuck[open] > summary::after { transform: rotate(180deg); opacity: 1; }

details.stuck > summary:hover { background: rgba(96, 165, 250, 0.05); }

.stuck-body {
  padding: 0 1.1rem 1rem;
  font-size: 0.96rem;
  line-height: 1.65;
  color: var(--tut-soft);
  animation: slideDown 0.25s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.stuck-body p { font-size: 0.96rem !important; margin-bottom: 0.7rem; }
.stuck-body p:last-child { margin-bottom: 0; }
.stuck-body code { font-family: var(--mono); font-size: 0.86em; background: rgba(96, 165, 250, 0.1); padding: 0.05em 0.35em; border-radius: 3px; }

/* ─────────────────────────────────────────────────────────────
   Q&A "Check Your Understanding" Cards
   ───────────────────────────────────────────────────────────── */
.quiz {
  margin: 2.5rem 0;
  background: linear-gradient(180deg, #14101e, #1a1424);
  border: 1px solid rgba(167, 139, 250, 0.3);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  position: relative;
}

.quiz::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--tut-accent), var(--tut-accent-2), var(--tut-info));
}

.quiz-head {
  padding: 0.85rem 1.25rem 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.quiz-badge {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--tut-accent);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.quiz-badge::before {
  content: '✦';
  font-size: 0.85em;
  color: var(--tut-accent);
}

.quiz-progress {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--tut-muted);
  letter-spacing: 0.06em;
}

.quiz-question {
  padding: 0.25rem 1.25rem 0.75rem;
  margin: 0;
  font-size: 1.05rem !important;
  line-height: 1.55;
  color: var(--tut-text) !important;
  font-weight: 500;
}

.quiz-options {
  padding: 0 1.25rem 1rem;
  display: grid;
  gap: 0.5rem;
}

.quiz-option {
  text-align: left;
  padding: 0.75rem 0.95rem;
  background: var(--tut-bg);
  border: 1px solid var(--tut-border);
  border-radius: 8px;
  color: var(--tut-soft);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.45;
  cursor: pointer;
  transition: all 0.18s ease;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  position: relative;
}

.quiz-option::before {
  content: '';
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--tut-border);
  background: transparent;
  transition: all 0.18s;
  margin-top: 1px;
}

.quiz-option:hover:not(.locked) {
  border-color: var(--tut-accent);
  background: rgba(167, 139, 250, 0.06);
  color: var(--tut-text);
  transform: translateX(2px);
}

.quiz-option:hover:not(.locked)::before {
  border-color: var(--tut-accent);
  background: rgba(167, 139, 250, 0.15);
}

.quiz-option.locked { cursor: default; }

.quiz-option.correct {
  border-color: var(--tut-success);
  background: rgba(52, 211, 153, 0.08);
  color: var(--tut-text);
}

.quiz-option.correct::before {
  content: '✓';
  font-size: 0.7rem;
  font-weight: 800;
  color: #052e1a;
  border-color: var(--tut-success);
  background: var(--tut-success);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.quiz-option.wrong {
  border-color: var(--tut-danger);
  background: rgba(248, 113, 113, 0.07);
  color: var(--tut-text);
  opacity: 0.95;
}

.quiz-option.wrong::before {
  content: '✗';
  font-size: 0.7rem;
  font-weight: 800;
  color: #2a0e0e;
  border-color: var(--tut-danger);
  background: var(--tut-danger);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.quiz-option.dim:not(.correct):not(.wrong) {
  opacity: 0.45;
}

.quiz-explain {
  padding: 0.9rem 1.25rem 1.1rem;
  background: rgba(167, 139, 250, 0.04);
  border-top: 1px solid var(--tut-border-soft);
  font-size: 0.93rem;
  line-height: 1.6;
  color: var(--tut-soft);
  animation: slideDown 0.3s ease;
}

.quiz-explain p { font-size: 0.93rem !important; margin: 0 0 0.45rem; }
.quiz-explain p:last-child { margin-bottom: 0; }
.quiz-explain strong { color: var(--tut-text); }
.quiz-explain code { font-family: var(--mono); font-size: 0.86em; background: rgba(167, 139, 250, 0.12); padding: 0.05em 0.35em; border-radius: 3px; }

.quiz-explain[hidden] { display: none; }

.quiz-footer {
  padding: 0.65rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--tut-border-soft);
  font-family: var(--mono);
  font-size: 0.73rem;
  color: var(--tut-muted);
  background: rgba(0, 0, 0, 0.15);
}

.quiz-streak {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--tut-accent);
  font-weight: 600;
}

.quiz-streak.fire { color: var(--tut-warn); }
.quiz-streak.fire::before { content: '🔥'; font-size: 0.95em; }

.quiz-retry {
  background: transparent;
  border: 1px solid var(--tut-border);
  color: var(--tut-soft);
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 0.25rem 0.65rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.quiz-retry:hover { color: var(--tut-text); border-color: var(--tut-accent); }
.quiz-retry[hidden] { display: none; }

/* ─────────────────────────────────────────────────────────────
   Code-language Tabs
   ───────────────────────────────────────────────────────────── */
.code-tabs {
  margin: 1.75rem 0;
  background: var(--tut-code-bg);
  border: 1px solid var(--tut-code-border);
  border-radius: 10px;
  overflow: hidden;
}

.code-tabs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--tut-code-border);
  padding: 0 0.5rem 0 1rem;
}

.code-tabs-title {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--tut-muted);
  flex-shrink: 0;
  margin-right: 1rem;
  padding: 0.6rem 0;
}

.lang-tabs {
  display: flex;
  gap: 0;
  flex: 1;
  overflow-x: auto;
}

.lang-tab {
  font-family: var(--mono);
  font-size: 0.76rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--tut-soft);
  padding: 0.65rem 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  position: relative;
}

.lang-tab:hover {
  color: var(--tut-text);
  background: rgba(167, 139, 250, 0.06);
}

.lang-tab.active {
  color: var(--tut-accent);
  border-bottom-color: var(--tut-accent);
  background: rgba(167, 139, 250, 0.08);
}

.lang-tab .lang-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  margin-right: 0.45rem;
  vertical-align: -2px;
}

.lang-tab[data-lang="js"]  .lang-icon { background: #f7df1e; }
.lang-tab[data-lang="py"]  .lang-icon { background: linear-gradient(135deg, #3776ab 50%, #ffd43b 50%); }
.lang-tab[data-lang="cpp"] .lang-icon { background: #00599c; }
.lang-tab[data-lang="rs"]  .lang-icon { background: #ce422b; }

.code-tabs-actions { display: flex; gap: 0.4rem; padding: 0.4rem 0; }

.code-pane {
  display: none;
}
.code-pane.active { display: block; }

.code-pane pre { margin: 0; }

/* Language-specific token coloring shared with .code class */
pre.code .tp  { color: #a78bfa; }  /* type */
pre.code .mod { color: #fb923c; }  /* module/import */
pre.code .dec { color: #34d399; }  /* decorator/attribute */
pre.code .mac { color: #fbbf24; }  /* macro */
pre.code .lt  { color: #c084fc; }  /* lifetime */

/* ─────────────────────────────────────────────────────────────
   Optimizer Race widget
   ───────────────────────────────────────────────────────────── */
.opt-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  margin-top: 0.5rem;
}

.opt-legend .opt-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--tut-soft);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--tut-border-soft);
}

.opt-legend .opt-dot {
  width: 10px; height: 10px; border-radius: 50%;
  box-shadow: 0 0 6px currentColor;
}

.opt-legend .opt-step {
  color: var(--tut-muted);
  font-size: 0.7rem;
  margin-left: auto;
}

/* ─────────────────────────────────────────────────────────────
   3D Loss surface widget
   ───────────────────────────────────────────────────────────── */
.viz-3d-help {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--tut-muted);
  letter-spacing: 0.04em;
}

/* ─────────────────────────────────────────────────────────────
   Overfitting widget
   ───────────────────────────────────────────────────────────── */
.over-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 720px) {
  .over-grid { grid-template-columns: 1fr; }
}

.curve-legend {
  display: flex;
  gap: 1rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--tut-muted);
}

.curve-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.curve-legend .swatch { width: 12px; height: 2.5px; border-radius: 1px; }

/* ─────────────────────────────────────────────────────────────
   Neuron inspector (overlay inside trainer)
   ───────────────────────────────────────────────────────────── */
.neuron-inspector {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--tut-muted);
  padding: 0.55rem 0.75rem;
  background: var(--tut-bg);
  border: 1px solid var(--tut-border-soft);
  border-radius: 6px;
}

.neuron-inspector strong { color: var(--tut-accent); }

/* ─────────────────────────────────────────────────────────────
   Glossary modal
   ───────────────────────────────────────────────────────────── */
.gloss-link {
  cursor: pointer;
  color: var(--tut-accent);
  border-bottom: 1px dashed rgba(167, 139, 250, 0.5);
  transition: color 0.15s;
}

.gloss-link:hover {
  color: #c6b8f5;
  border-bottom-color: var(--tut-accent);
}

.gloss-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 1rem;
}

.gloss-modal.open { opacity: 1; pointer-events: auto; }

.gloss-panel {
  width: min(560px, 100%);
  max-height: 80vh;
  background: var(--tut-surface);
  border: 1px solid var(--tut-border);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(8px);
  transition: transform 0.2s ease;
}

.gloss-modal.open .gloss-panel { transform: translateY(0); }

.gloss-panel-header {
  padding: 0.85rem 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--tut-border);
  background: rgba(167, 139, 250, 0.05);
}

.gloss-term {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--tut-text);
}

.gloss-term .gloss-pron {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--tut-muted);
  margin-left: 0.5rem;
}

.gloss-close {
  background: transparent;
  border: none;
  color: var(--tut-muted);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0 0.3rem;
  line-height: 1;
}

.gloss-close:hover { color: var(--tut-text); }

.gloss-body {
  padding: 1.1rem 1.1rem 1.25rem;
  overflow-y: auto;
  font-size: 0.97rem;
  line-height: 1.6;
  color: var(--tut-soft);
}

.gloss-body p { font-size: 0.97rem !important; margin: 0 0 0.7rem; }
.gloss-body p:last-child { margin-bottom: 0; }
.gloss-body strong { color: var(--tut-text); }
.gloss-body code { font-family: var(--mono); font-size: 0.85em; background: rgba(167, 139, 250, 0.1); padding: 0.05em 0.35em; border-radius: 3px; }

/* ─────────────────────────────────────────────────────────────
   "Predict what happens" prompt
   ───────────────────────────────────────────────────────────── */
.predict {
  margin: 2rem 0;
  padding: 1rem 1.25rem;
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.07), transparent 70%);
  border-left: 3px solid var(--tut-warn);
  border-radius: 0 8px 8px 0;
  font-size: 0.97rem;
  line-height: 1.6;
  color: var(--tut-soft);
}

.predict-title {
  display: block;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--tut-warn);
  margin-bottom: 0.4rem;
}

.predict-title::before {
  content: '⌖ ';
  margin-right: 0.2em;
}

.predict p { font-size: 0.97rem !important; margin: 0; color: var(--tut-soft) !important; }

.math i, .math-block i { font-style: italic; font-family: var(--math); }
.math .op, .math-block .op { font-style: normal; padding: 0 0.18em; color: var(--tut-soft); }
.math .num, .math-block .num { font-style: normal; font-family: var(--math); }
.math .fn, .math-block .fn { font-style: normal; font-weight: 500; color: var(--tut-text); }
.math .vec, .math-block .vec { font-weight: 700; font-style: normal; }

.frac {
  display: inline-flex;
  flex-direction: column;
  text-align: center;
  vertical-align: middle;
  font-size: 0.85em;
  margin: 0 0.15em;
}
.frac .num-part { border-bottom: 1px solid currentColor; padding: 0 0.35em 0.1em; }
.frac .den-part { padding: 0.1em 0.35em 0; }

.sqrt {
  display: inline-flex;
  align-items: center;
  gap: 0.05em;
  vertical-align: middle;
}
.sqrt::before { content: '√'; font-size: 1.1em; }
.sqrt .radicand { border-top: 1px solid currentColor; padding: 0 0.2em; }

/* ── Callouts ── */
.callout {
  margin: 2rem 0;
  padding: 1rem 1.25rem 1rem 1.5rem;
  border-radius: 10px;
  border-left: 3px solid var(--tut-accent);
  background: linear-gradient(90deg, var(--tut-accent-glow), transparent 70%);
  font-size: 0.97rem;
  line-height: 1.6;
}

.callout .callout-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tut-accent);
  margin-bottom: 0.5rem;
}

.callout .callout-title svg { flex-shrink: 0; }

.callout p { margin: 0; color: var(--tut-soft); font-size: 0.97rem; }
.callout p + p { margin-top: 0.6rem; }

.callout.info       { border-color: var(--tut-info);    background: linear-gradient(90deg, rgba(96, 165, 250, 0.15), transparent 70%); }
.callout.info .callout-title { color: var(--tut-info); }

.callout.warn       { border-color: var(--tut-warn);    background: linear-gradient(90deg, rgba(251, 191, 36, 0.13), transparent 70%); }
.callout.warn .callout-title { color: var(--tut-warn); }

.callout.success    { border-color: var(--tut-success); background: linear-gradient(90deg, rgba(52, 211, 153, 0.13), transparent 70%); }
.callout.success .callout-title { color: var(--tut-success); }

.callout.danger     { border-color: var(--tut-danger);  background: linear-gradient(90deg, rgba(248, 113, 113, 0.13), transparent 70%); }
.callout.danger .callout-title { color: var(--tut-danger); }

/* ── Tooltip (jargon) ── */
.tip {
  position: relative;
  border-bottom: 1px dotted var(--tut-accent);
  color: var(--tut-text);
  cursor: help;
}

.tip::after,
.tip::before {
  position: absolute;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 30;
}

.tip::after {
  content: attr(data-tip);
  bottom: calc(100% + 10px);
  width: max-content;
  max-width: 280px;
  padding: 0.65rem 0.85rem;
  font-size: 0.83rem;
  line-height: 1.45;
  color: var(--tut-text);
  background: #14141f;
  border: 1px solid var(--tut-border);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
  white-space: normal;
  text-align: left;
  font-weight: 400;
  font-style: normal;
}

.tip::before {
  content: '';
  bottom: calc(100% + 4px);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid var(--tut-border);
}

.tip:hover::after,
.tip:hover::before,
.tip:focus::after,
.tip:focus::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Code blocks ── */
.code-card {
  margin: 1.75rem 0;
  background: var(--tut-code-bg);
  border: 1px solid var(--tut-code-border);
  border-radius: 10px;
  overflow: hidden;
}

.code-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--tut-code-border);
}

.code-card-title {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--tut-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.code-card-title::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--tut-accent);
  box-shadow: 0 0 8px var(--tut-accent);
}

.code-card-actions { display: flex; gap: 0.5rem; }

.code-btn {
  background: transparent;
  border: 1px solid var(--tut-border);
  color: var(--tut-soft);
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.32rem 0.7rem;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.code-btn:hover {
  border-color: var(--tut-accent);
  color: var(--tut-text);
  background: rgba(167, 139, 250, 0.08);
}

.code-btn.copied { color: var(--tut-success); border-color: var(--tut-success); }

pre.code {
  margin: 0;
  padding: 1.25rem 1.25rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.65;
  color: #d8d8e6;
  overflow-x: auto;
  tab-size: 2;
  white-space: pre;
}

pre.code .kw  { color: #c084fc; }
pre.code .fn  { color: #60a5fa; }
pre.code .str { color: #34d399; }
pre.code .num { color: #fb923c; }
pre.code .com { color: #5b5b78; font-style: italic; }
pre.code .op  { color: #94a3b8; }
pre.code .cls { color: #fbbf24; }
pre.code .prm { color: #e8e8ee; }

code.inline-code {
  font-family: var(--mono);
  font-size: 0.87em;
  background: rgba(167, 139, 250, 0.08);
  border: 1px solid var(--tut-border-soft);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  color: var(--tut-text);
}

/* ── Widget container ── */
.widget {
  margin: 2.5rem 0;
  background: linear-gradient(180deg, var(--tut-surface), var(--tut-surface-2));
  border: 1px solid var(--tut-border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.3);
}

.widget-header {
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--tut-border);
  background: rgba(167, 139, 250, 0.04);
}

.widget-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--tut-accent);
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.widget-title::before {
  content: '◆';
  font-size: 0.7em;
  color: var(--tut-accent);
}

.widget-body {
  padding: 1.25rem;
  display: grid;
  gap: 1.25rem;
}

.widget-body.split {
  grid-template-columns: minmax(320px, 1.4fr) minmax(220px, 1fr);
  align-items: center;
}

.widget canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #07070d;
  border-radius: 8px;
  border: 1px solid var(--tut-border-soft);
  cursor: crosshair;
  touch-action: none;
}

.widget-caption {
  font-size: 0.85rem;
  color: var(--tut-muted);
  padding: 0.75rem 1.25rem 1rem;
  border-top: 1px solid var(--tut-border-soft);
  background: rgba(0, 0, 0, 0.2);
  font-style: italic;
  line-height: 1.5;
}

/* ── Control panel inside widgets ── */
.controls {
  display: grid;
  gap: 0.85rem;
  font-size: 0.86rem;
}

.control-row { display: grid; gap: 0.35rem; }

.control-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--tut-muted);
  letter-spacing: 0.04em;
}

.control-label .val {
  color: var(--tut-accent);
  font-weight: 600;
  background: rgba(167, 139, 250, 0.12);
  padding: 0.1em 0.55em;
  border-radius: 4px;
}

input[type="range"].slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 4px;
  background: var(--tut-border);
  outline: none;
  cursor: pointer;
}

input[type="range"].slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--tut-accent);
  border: 2px solid #18182a;
  cursor: pointer;
  box-shadow: 0 0 10px var(--tut-accent-glow);
  transition: transform 0.15s;
}

input[type="range"].slider::-webkit-slider-thumb:hover { transform: scale(1.15); }

input[type="range"].slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--tut-accent);
  border: 2px solid #18182a;
  cursor: pointer;
}

.btn {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--tut-border);
  background: var(--tut-surface);
  color: var(--tut-text);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn:hover { border-color: var(--tut-accent); background: rgba(167, 139, 250, 0.08); }
.btn:active { transform: translateY(1px); }

.btn.primary {
  background: linear-gradient(135deg, var(--tut-accent), var(--tut-accent-2));
  border-color: var(--tut-accent-2);
  color: #fff;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35);
}
.btn.primary:hover { filter: brightness(1.1); }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

select.dropdown {
  font-family: var(--mono);
  font-size: 0.8rem;
  background: var(--tut-surface);
  color: var(--tut-text);
  border: 1px solid var(--tut-border);
  padding: 0.45rem 0.7rem;
  border-radius: 5px;
  cursor: pointer;
  outline: none;
}

select.dropdown:focus { border-color: var(--tut-accent); }

.toggle-group {
  display: inline-flex;
  background: var(--tut-bg);
  border: 1px solid var(--tut-border);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.toggle-group button {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  padding: 0.35rem 0.7rem;
  background: transparent;
  border: none;
  color: var(--tut-muted);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
  text-transform: uppercase;
  font-weight: 600;
}

.toggle-group button:hover { color: var(--tut-text); }
.toggle-group button.active {
  background: var(--tut-accent);
  color: #fff;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.65rem;
  margin-top: 0.5rem;
}

.stat {
  background: var(--tut-bg);
  border: 1px solid var(--tut-border-soft);
  border-radius: 6px;
  padding: 0.55rem 0.7rem;
}

.stat-label {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tut-muted);
  margin-bottom: 0.15rem;
}

.stat-value {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--tut-accent);
}

/* ── Table of contents (sticky sidebar) ── */
.tut-toc {
  position: fixed;
  top: 50%;
  right: 1.5rem;
  transform: translateY(-50%);
  z-index: 50;
  padding: 0.7rem 0.9rem;
  background: rgba(18, 18, 26, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid var(--tut-border);
  border-radius: 8px;
  font-size: 0.74rem;
  width: 210px;
}

.tut-toc-title {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--tut-muted);
  margin-bottom: 0.35rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--tut-border-soft);
}

.tut-toc ol {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  counter-reset: toc;
}

.tut-toc li {
  counter-increment: toc;
  font-size: 0.74rem;
  line-height: 1.25;
  margin: 0;
}

.tut-toc a {
  color: var(--tut-muted);
  text-decoration: none;
  border: none;
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.14rem 0.25rem;
  border-radius: 3px;
  transition: all 0.15s;
}

.tut-toc a::before {
  content: counter(toc, decimal-leading-zero);
  font-family: var(--mono);
  font-size: 0.6rem;
  opacity: 0.5;
  flex-shrink: 0;
}

.tut-toc a:hover { color: var(--tut-text); }
.tut-toc a.active { color: var(--tut-accent); font-weight: 600; }
.tut-toc a.active::before { opacity: 1; }

/* Very short viewports: hide TOC so it never overflows. The 1280px-wide
   rule below already covers most narrow screens. */
@media (max-height: 540px) {
  .tut-toc { display: none; }
}

@media (max-width: 1280px) {
  .tut-toc { display: none; }
}

/* ── Reading-progress bar ── */
.tut-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
  z-index: 200;
  pointer-events: none;
}

.tut-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--tut-accent), var(--tut-accent-2));
  width: 0%;
  transition: width 0.05s linear;
  box-shadow: 0 0 12px var(--tut-accent);
}

/* ── Network diagram (inline SVG) ── */
.network-diagram {
  display: block;
  margin: 1.5rem auto;
  max-width: 100%;
}

.network-diagram .node {
  fill: var(--tut-surface);
  stroke: var(--tut-accent);
  stroke-width: 1.5;
  transition: fill 0.2s;
}

.network-diagram .node.active { fill: var(--tut-accent); }
.network-diagram .node.input  { stroke: #60a5fa; }
.network-diagram .node.output { stroke: var(--tut-success); }

.network-diagram .edge {
  stroke: var(--tut-border);
  stroke-width: 1;
  transition: stroke 0.2s, stroke-width 0.2s;
}

.network-diagram .edge.active {
  stroke: var(--tut-accent);
  stroke-width: 1.8;
}

.network-diagram .label {
  font-family: var(--mono);
  font-size: 11px;
  fill: var(--tut-muted);
}

/* ── Code playground ── */
.playground {
  margin: 2.5rem 0;
  background: var(--tut-code-bg);
  border: 1px solid var(--tut-border);
  border-radius: 12px;
  overflow: hidden;
}

.playground-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1rem;
  background: var(--tut-surface);
  border-bottom: 1px solid var(--tut-border);
}

.playground-title {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--tut-accent);
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.playground-actions { display: flex; gap: 0.5rem; }

.playground-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 380px;
}

.playground-editor {
  position: relative;
  border-right: 1px solid var(--tut-border);
  overflow: hidden;
}

.playground-editor textarea {
  width: 100%;
  height: 100%;
  min-height: 380px;
  padding: 1rem;
  font-family: var(--mono);
  font-size: 0.83rem;
  line-height: 1.6;
  color: #d8d8e6;
  background: transparent;
  border: none;
  resize: none;
  outline: none;
  tab-size: 2;
  white-space: pre;
}

.playground-output {
  padding: 1rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.55;
  color: #c8c8d6;
  background: #07070d;
  overflow: auto;
  white-space: pre-wrap;
}

.playground-output .log-info  { color: #c8c8d6; }
.playground-output .log-warn  { color: var(--tut-warn); }
.playground-output .log-err   { color: var(--tut-danger); }
.playground-output .log-ok    { color: var(--tut-success); }
.playground-output .log-faint { color: var(--tut-muted); }

@media (max-width: 720px) {
  .playground-body { grid-template-columns: 1fr; }
  .playground-editor { border-right: none; border-bottom: 1px solid var(--tut-border); }
  .widget-body.split { grid-template-columns: 1fr; }
}

/* ── Footnote / source list ── */
.sources {
  margin-top: 2rem;
  font-size: 0.88rem;
  line-height: 1.6;
  counter-reset: src;
}

.sources li {
  list-style: none;
  counter-increment: src;
  position: relative;
  padding-left: 2.4rem;
  margin-bottom: 0.65rem;
  color: var(--tut-soft);
}

.sources li::before {
  content: "[" counter(src) "]";
  position: absolute;
  left: 0;
  top: 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--tut-accent);
  font-weight: 600;
}

.sources a { color: var(--tut-soft); }
.sources a:hover { color: var(--tut-accent); }

sup.cite {
  font-family: var(--mono);
  font-size: 0.7em;
  vertical-align: super;
  color: var(--tut-accent);
  cursor: pointer;
  margin-left: 0.1em;
}

sup.cite a {
  color: inherit;
  text-decoration: none;
  border: none;
}

/* ── Animations ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-in { opacity: 0; transform: translateY(16px); transition: opacity 0.6s ease, transform 0.6s ease; }
.fade-in.visible { opacity: 1; transform: translateY(0); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--tut-accent-glow); }
  50%      { box-shadow: 0 0 0 8px transparent; }
}

/* ── Tutorial nav header ── */
.tut-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 15, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--tut-border);
}

.tut-header-inner {
  max-width: var(--tut-wide-width);
  margin: 0 auto;
  padding: 0.85rem var(--tut-side-pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tut-back {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--tut-muted);
  text-decoration: none;
  border: none !important;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: color 0.15s;
  padding: 0.35rem 0;
}

.tut-back:hover { color: var(--tut-accent) !important; }
.tut-back::before { content: '←'; font-size: 1em; }

.tut-brand {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  color: var(--tut-text);
  text-decoration: none;
  border: none !important;
}

/* ── See also (related-tutorials block above the footer) ── */
.see-also {
  max-width: var(--tut-content-width);
  margin: 4rem auto 0;
  padding: 0 var(--tut-side-pad);
}

.see-also h2 {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tut-muted);
  margin: 0 0 1rem;
}

.see-also-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.75rem;
}

.see-also-card {
  display: block;
  padding: 0.95rem 1rem;
  background: var(--tut-surface);
  border: 1px solid var(--tut-border-soft);
  border-radius: 8px;
  text-decoration: none !important;
  color: var(--tut-text);
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.see-also-card:hover {
  border-color: var(--tut-accent);
  background: var(--tut-surface-2);
  transform: translateY(-1px);
}

.see-also-card strong {
  display: block;
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--tut-text);
  margin-bottom: 0.25rem;
}

.see-also-card span {
  display: block;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--tut-muted);
}

/* ── Footer ── */
.tut-footer {
  margin-top: 6rem;
  padding: 3rem var(--tut-side-pad);
  border-top: 1px solid var(--tut-border);
  font-size: 0.82rem;
  color: var(--tut-muted);
}

.tut-footer-inner {
  max-width: var(--tut-wide-width);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.tut-footer a {
  color: var(--tut-muted);
  text-decoration: none;
  border: none !important;
}
.tut-footer a:hover { color: var(--tut-accent); }

/* ── Index page (tutorials listing) ── */
.tut-index-hero {
  text-align: left;
  padding: 5rem var(--tut-side-pad) 3rem;
  max-width: var(--tut-wide-width);
  margin: 0 auto;
}

.tut-index-hero h1 {
  font-size: clamp(2.5rem, 5vw, 3.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin: 0.5rem 0 1rem;
  background: linear-gradient(180deg, #fff 0%, #c6b8f5 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tut-index-hero p {
  font-size: 1.15rem;
  color: var(--tut-soft);
  max-width: 640px;
  line-height: 1.55;
}

.tut-list {
  max-width: var(--tut-wide-width);
  margin: 0 auto;
  padding: 0 var(--tut-side-pad) 6rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.tut-card {
  display: block;
  background: var(--tut-surface);
  border: 1px solid var(--tut-border);
  border-radius: 14px;
  overflow: hidden;
  text-decoration: none !important;
  color: inherit;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  border-bottom: 1px solid var(--tut-border) !important;
}

.tut-card:hover {
  transform: translateY(-4px);
  border-color: var(--tut-accent) !important;
  box-shadow: 0 16px 36px rgba(167, 139, 250, 0.16);
}

.tut-card-visual {
  height: 160px;
  position: relative;
  display: flex;
  align-items: flex-end;
  padding: 1rem;
  overflow: hidden;
  background: linear-gradient(135deg, #1a0a2e 0%, #2d0a4e 60%, #0a0a1f 100%);
}

.tut-card-visual.nn-bg {
  background:
    radial-gradient(circle at 20% 30%, rgba(167, 139, 250, 0.4), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(96, 165, 250, 0.3), transparent 45%),
    linear-gradient(135deg, #0f0c29, #302b63 50%, #1a0a2e);
}

.tut-card-visual.soon-bg {
  background: linear-gradient(135deg, #0e1018, #1a1d2e 60%, #0e1018);
}

.tut-card-visual canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.tut-badge {
  background: var(--tut-accent-2);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.32rem 0.7rem;
  border-radius: 5px;
  z-index: 2;
  position: relative;
}

.tut-badge.soon { background: var(--tut-muted); }

.tut-card-body { padding: 1.25rem 1.25rem 1.4rem; }

.tut-card-body h3 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 0.4rem;
  color: var(--tut-text);
}

.tut-card-body p {
  font-size: 0.92rem;
  color: var(--tut-muted);
  line-height: 1.55;
  margin: 0 0 0.9rem;
}

.tut-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--tut-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.tut-card-meta span { display: inline-flex; align-items: center; gap: 0.3rem; white-space: nowrap; }

/* ── Mobile ── */
@media (max-width: 720px) {
  .tut-shell { padding: 0 1rem; }
  .tut-hero { padding: 3.5rem 0 2rem; }
  .tut-hero h1 { font-size: 2.25rem; }
  .tut-lead { font-size: 1.05rem !important; }
  .tut-lead::first-letter { font-size: 2.6rem; }
  .math-block { font-size: 1rem; padding: 1rem; }
  .widget-body { padding: 1rem; }
  .tut-shell h2 { margin-top: 3.5rem; }
}
