/* User Provided Stylesheet */

/* Castalia program site — typography, reading rhythm, subtle polish */
@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400..700;1,9..40,400..700&family=Source+Serif+4:ital,opsz,wght@0,8..60,400..700;1,8..60,400..700&family=JetBrains+Mono:ital,wght@0,400..600;1,400..600&display=swap");

:root {
  --castalia-font-sans: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --castalia-font-serif: "Source Serif 4", "Georgia", "Times New Roman", serif;
  --castalia-font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", monospace;
  --castalia-text: #1a1a1f;
  --castalia-text-muted: #4b5563;
  --castalia-border: #e5e7eb;
  --castalia-accent: #0f766e;
  --castalia-accent-hover: #0d9488;
  --castalia-quote-bg: #f8fafc;
  /* Magisterium hub palette — match web/src/styles/global.css (cool navy, not Tailwind stone brown) */
  --magai-navy-950: #0a0e1a;
  --magai-navy-900: #0f1425;
  --magai-navy-800: #161c33;
  --magai-navy-700: #1e2642;
  --magai-gold: #c9a84c;
  --magai-gold-bright: #e0c972;
  --magai-gold-muted: rgba(201, 168, 76, 0.9);
  /* Text on navy: warm cream from Magisterium --color-stone-* */
  --magai-stone-100: #e8e0d0;
  --magai-stone-200: #d4cfc3;
  --magai-stone-300: #bfb49d;
  --magai-stone-400: #9e9279;
  --magai-stone-500: #8a7d68;
}

/* Hide theme “Made with MyST” chrome */
.myst-made-with-myst,
.myst-primary-sidebar-footer a[href*="mystmd.org/made-with-myst"] {
  display: none !important;
}

/* Base: UI chrome (nav, sidebar) + fallbacks */
html {
  font-family: var(--castalia-font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Prose: serif body for long-form curriculum */
article,
article.myst,
article.content,
main article,
[role="main"] article {
  font-family: var(--castalia-font-serif);
  font-size: 1.0625rem;
  line-height: 1.65;
  font-optical-sizing: auto;
  font-feature-settings: "kern" 1, "liga" 1;
  color: var(--castalia-text);
  letter-spacing: 0.01em;
}

article ol,
article ul {
  padding-left: 1.35em;
}

article p,
article li {
  max-width: min(68ch, 100%);
}

article .myst-fm-block-title {
  font-family: var(--castalia-font-sans);
  font-weight: 700;
  letter-spacing: -0.03em;
}

article h1,
article h2,
article h3,
article h4 {
  font-family: var(--castalia-font-sans);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: #111827;
}

article h1 {
  font-size: clamp(1.75rem, 1.2rem + 1.5vw, 2.25rem);
  margin-top: 0;
}

article h2 {
  margin-top: 2.25rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--castalia-border);
}

html.dark article h2 {
  border-bottom-color: var(--castalia-border);
}

article h3 {
  margin-top: 1.75rem;
}

article a,
article a.link {
  color: var(--castalia-accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

article a:hover,
article a.link:hover {
  color: var(--castalia-accent-hover);
}

article strong {
  font-weight: 650;
  color: #111827;
}

article blockquote {
  font-family: var(--castalia-font-sans);
  font-size: 0.98rem;
  margin: 1.25rem 0;
  padding: 0.75rem 1rem 0.75rem 1.1rem;
  border-left: 4px solid var(--castalia-accent);
  background: var(--castalia-quote-bg);
  color: var(--castalia-text-muted);
  border-radius: 0 0.25rem 0.25rem 0;
}

article code,
article td code {
  font-family: var(--castalia-font-mono);
  font-size: 0.88em;
  font-weight: 500;
  padding: 0.12em 0.35em;
  border-radius: 0.25rem;
  background: rgba(15, 118, 110, 0.08);
  color: #0f766e;
}

article pre {
  font-family: var(--castalia-font-mono);
  font-size: 0.875rem;
  line-height: 1.55;
  border-radius: 0.375rem;
  border: 1px solid var(--castalia-border);
}

article table {
  font-family: var(--castalia-font-sans);
  font-size: 0.95rem;
  border-collapse: collapse;
}

article th {
  font-weight: 650;
  text-align: left;
  background: #f9fafb;
}

article th,
article td {
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--castalia-border);
}

article table tr:nth-child(even) td {
  background: #fafafa;
}

/* Notes / admonitions: sans for UI contrast with serif body */
article .admonition,
article [class*="admonition"],
article .myst-admonition {
  font-family: var(--castalia-font-sans);
  font-size: 0.98rem;
  border-radius: 0.375rem;
}

/* Sidebar nav: match sans, readable hierarchy */
nav a,
aside a,
[role="navigation"] a {
  font-family: var(--castalia-font-sans);
  letter-spacing: 0.01em;
}

/* Dark palette — MyST book-theme uses html.dark (toggle), not only prefers-color-scheme */
html.dark {
  --castalia-text: #e5e7eb;
  --castalia-text-muted: #9ca3af;
  --castalia-border: #3f3f46;
  --castalia-accent: #2dd4bf;
  --castalia-accent-hover: #5eead4;
  --castalia-quote-bg: rgba(45, 212, 191, 0.1);
}

html.dark article h1,
html.dark article h2,
html.dark article h3,
html.dark article h4,
html.dark article strong {
  color: #f9fafb;
}

html.dark article th {
  background: #27272a;
}

html.dark article th,
html.dark article td {
  border-color: var(--castalia-border);
}

html.dark article table tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.04);
}

html.dark article code,
html.dark article td code {
  background: rgba(45, 212, 191, 0.12);
  color: #5eead4;
}

html.dark article pre {
  border-color: var(--castalia-border);
}

html.dark article blockquote {
  color: var(--castalia-text-muted);
}

/* --- Magisterium-aligned program hub (index.md only) — matches /magai/ layout --- */

article .magai-program-landing {
  margin: -1.25rem -0.5rem 2rem;
  max-width: none;
  font-family: var(--castalia-font-sans);
}

article .magai-program-hero {
  position: relative;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

article .magai-program-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 90% 80% at 80% -10%, rgba(201, 168, 76, 0.09) 0%, transparent 52%),
    radial-gradient(ellipse 120% 100% at 50% 0%, var(--magai-navy-800) 0%, var(--magai-navy-950) 72%);
  z-index: 0;
}

article .magai-program-hero-inner {
  position: relative;
  z-index: 1;
  max-width: 64rem;
  margin: 0 auto;
  padding: 3rem 1.5rem 2rem;
}

article .magai-program-hero-inner.magai-hero-split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  align-items: center;
  max-width: 72rem;
}

@media (min-width: 960px) {
  article .magai-program-hero-inner.magai-hero-split {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    gap: 2.5rem;
    padding-bottom: 2.5rem;
  }
}

article .magai-hero-copy {
  min-width: 0;
}

article .magai-hero-program {
  font-family: var(--castalia-font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(212, 168, 83, 0.95);
  margin: 0 0 0.75rem;
}

/* Cold-traffic hook: plain English before the emotional H1 */
article .magai-hero-plain {
  font-family: var(--castalia-font-sans);
  font-size: clamp(0.98rem, 0.92rem + 0.25vw, 1.0625rem);
  font-weight: 400;
  font-style: normal;
  line-height: 1.62;
  color: rgba(226, 232, 240, 0.94);
  margin: 0 0 1.15rem;
  max-width: 42rem;
  letter-spacing: 0.01em;
}

article .magai-hero-plain strong {
  color: var(--magai-stone-100);
  font-weight: 650;
}

article .magai-hero-sub,
article .magai-hero-lead {
  font-family: var(--castalia-font-serif);
  font-size: clamp(1.2rem, 1.05rem + 0.65vw, 1.55rem);
  font-weight: 650;
  font-style: italic;
  color: rgba(252, 250, 245, 0.96);
  margin: 0 0 1.1rem;
  max-width: 40rem;
  line-height: 1.42;
  border-bottom: none;
  padding-bottom: 0;
}

article .magai-hero-friction {
  margin: 0 0 1.25rem;
  padding: 1rem 1.1rem 1rem 1.15rem;
  max-width: 42rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(127, 29, 29, 0.35);
  background:
    linear-gradient(135deg, rgba(127, 29, 29, 0.14) 0%, rgba(15, 23, 42, 0.55) 55%, rgba(15, 23, 42, 0.35) 100%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2) inset;
}

article .magai-hero-friction p {
  margin: 0;
  font-family: var(--castalia-font-sans);
  font-size: 0.9375rem;
  line-height: 1.58;
  font-style: normal;
  color: rgba(226, 232, 240, 0.92);
}

article .magai-hero-friction strong {
  color: var(--magai-stone-100);
  font-weight: 650;
}

article .magai-hero-friction em {
  color: rgba(251, 191, 36, 0.88);
  font-style: normal;
  font-weight: 600;
}

article .magai-hero-ctas {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-top: 1.5rem;
}

article .magai-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.25rem;
  border-radius: 0.5rem;
  font-family: var(--castalia-font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

article .magai-btn--primary {
  background: linear-gradient(180deg, var(--magai-gold-bright) 0%, var(--magai-gold) 100%);
  color: var(--magai-navy-950);
  border: 1px solid rgba(212, 168, 83, 0.5);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset;
}

article .magai-btn--primary:hover {
  filter: brightness(1.06);
  color: var(--magai-navy-950);
}

article .magai-btn--ghost {
  background: rgba(15, 23, 42, 0.45);
  color: var(--magai-stone-100);
  border: 1px solid rgba(148, 163, 184, 0.45);
}

article .magai-btn--ghost:hover {
  border-color: var(--magai-gold-muted);
  color: var(--magai-gold-bright);
}

article .magai-hero-visual {
  min-width: 0;
}

article .magai-hero-figure {
  margin: 0;
}

/* MyST emits inline width/height on <img>; those beat normal CSS and distort when the
   layout scales. Override so images stay proportional inside the column. */
article .magai-hero-figure picture {
  display: block;
  width: 100%;
}

article .magai-hero-figure img {
  display: block;
  width: 100% !important;
  max-width: 100%;
  height: auto !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  border-radius: 0.625rem;
  border: 1px solid rgba(212, 168, 83, 0.32);
  box-shadow:
    0 4px 28px rgba(0, 0, 0, 0.4),
    0 0 48px rgba(201, 168, 76, 0.06),
    0 0 0 1px rgba(255, 255, 255, 0.05) inset;
  object-fit: contain;
}

article .magai-photo-credit {
  margin: 0.5rem 0 0;
  font-family: var(--castalia-font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.75);
}

article .magai-photo-credit a {
  color: rgba(212, 168, 83, 0.75);
  text-decoration: none;
}

article .magai-photo-credit a:hover {
  color: var(--magai-gold-bright);
  text-decoration: underline;
}

article .magai-photo-credit--block {
  margin-top: 1rem;
  text-align: center;
}

article .magai-stat-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem 1.75rem;
  margin: 0 0 2rem;
  padding: 1.25rem 1.5rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(71, 85, 105, 0.45);
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.55) 0%, rgba(17, 24, 39, 0.4) 100%);
}

article .magai-positioning-strip {
  margin: 0 0 1.75rem;
  padding: 1.15rem 1.35rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(212, 168, 83, 0.35);
  background: linear-gradient(125deg, rgba(212, 168, 76, 0.08) 0%, rgba(15, 23, 42, 0.45) 48%, rgba(17, 24, 39, 0.35) 100%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15) inset;
}

article .magai-positioning-strip p {
  margin: 0;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--magai-stone-200);
  max-width: none;
}

article .magai-positioning-strip strong {
  color: var(--magai-stone-100);
}

/* Verification strip — cold visitors can fact-check before enrolling */
article .magai-cold-proof {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem 1.25rem;
  margin: 0 0 1.75rem;
}

@media (max-width: 900px) {
  article .magai-cold-proof {
    grid-template-columns: 1fr;
  }
}

article .magai-cold-proof-card {
  margin: 0;
  padding: 1.1rem 1.2rem 1.15rem;
  border-radius: 0.65rem;
  border: 1px solid rgba(71, 85, 105, 0.45);
  background: linear-gradient(165deg, rgba(30, 41, 59, 0.35) 0%, rgba(15, 23, 42, 0.55) 100%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12) inset;
}

article .magai-cold-proof-title {
  font-family: var(--castalia-font-sans);
  font-size: 0.9375rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--magai-stone-100);
  margin: 0 0 0.5rem;
  line-height: 1.3;
}

article .magai-cold-proof-card p {
  margin: 0;
  font-family: var(--castalia-font-sans);
  font-size: 0.9rem;
  line-height: 1.58;
  color: rgba(203, 213, 225, 0.92);
  max-width: none;
}

article .magai-cold-proof-card a {
  color: var(--magai-gold-bright);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

article .magai-cold-proof-card a:hover {
  color: #f5e6b8;
}

article .magai-glossary-lead {
  font-family: var(--castalia-font-sans);
  font-size: 0.98rem;
  color: var(--castalia-text-muted);
  margin: -0.6rem 0 1rem;
  max-width: 52ch;
}

html:not(.light) article .magai-glossary-lead {
  color: var(--magai-stone-400);
}

article .magai-stat {
  text-align: center;
  min-width: 5.5rem;
}

article .magai-stat strong {
  display: block;
  font-family: var(--castalia-font-serif);
  font-size: clamp(1.5rem, 1.2rem + 1vw, 1.85rem);
  font-weight: 700;
  color: var(--magai-gold-bright);
  line-height: 1.15;
}

article .magai-stat span {
  display: block;
  margin-top: 0.2rem;
  font-family: var(--castalia-font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--magai-stone-400);
}

article .magai-prose-highlight {
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--magai-stone-200);
  max-width: 48rem;
  margin: 0 0 1rem;
  padding: 0 0 0 1rem;
  border-left: 3px solid rgba(212, 168, 83, 0.55);
}

article .magai-pillar-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin: 0 0 0.5rem;
  max-width: none;
}

@media (min-width: 720px) {
  article .magai-pillar-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
  }
}

article .magai-pillar-card {
  display: flex;
  flex-direction: column;
  border-radius: 0.75rem;
  overflow: hidden;
  border: 1px solid rgba(71, 85, 105, 0.45);
  background: rgba(17, 24, 39, 0.45);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

article .magai-pillar-card:hover {
  border-color: rgba(212, 168, 83, 0.35);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

article .magai-pillar-card picture {
  display: block;
  width: 100%;
}

article .magai-pillar-card img {
  width: 100% !important;
  max-width: 100%;
  height: auto !important;
  margin: 0 !important;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  object-position: center;
  display: block;
}

article .magai-pillar-body {
  padding: 1.1rem 1.15rem 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

article .magai-pillar-title,
article .magai-pillar-body > h3 {
  font-family: var(--castalia-font-sans);
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--magai-stone-100);
  margin: 0 0 0.5rem;
  line-height: 1.3;
  border-bottom: none;
}

article .magai-pillar-body p {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--magai-stone-400);
  max-width: none;
}

article .magai-pillar-body p strong {
  color: var(--magai-stone-200);
}

article .magai-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--castalia-font-mono);
  font-size: 0.875rem;
  color: var(--magai-stone-400);
  text-decoration: none;
  margin-bottom: 1.5rem;
}

article .magai-back-link::before {
  content: "←";
  opacity: 0.85;
}

article .magai-back-link:hover {
  color: var(--magai-gold-muted);
}

article .magai-eyebrow {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  border: 1px solid rgba(212, 168, 83, 0.35);
  background: rgba(212, 168, 83, 0.1);
  font-family: var(--castalia-font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(212, 168, 83, 0.88);
  margin-bottom: 1.5rem;
}

article .magai-hero-title,
article .magai-hero-copy > h2:first-of-type {
  font-family: var(--castalia-font-serif);
  font-size: clamp(2rem, 1.4rem + 2vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--magai-stone-100);
  margin: 0 0 0.5rem;
  line-height: 1.15;
  border-bottom: none;
  padding-bottom: 0;
}

article .magai-hero-copy > h2:first-of-type {
  margin-top: 0;
}

article .magai-hero-copy > h1.magai-hero-lead:first-of-type {
  margin-top: 0;
}

/* MyST wraps headings in .heading-text; keep hero lead typography. */
article .magai-hero-lead .heading-text {
  font-family: inherit !important;
  font-style: inherit;
  font-weight: inherit;
  color: inherit;
}

article .magai-hero-kicker,
article .magai-hero-copy > h1 + p.magai-hero-kicker {
  font-size: 1rem;
  color: var(--magai-stone-300);
  margin: 0 0 1.5rem;
  max-width: 42rem;
}

article .magai-hero-quote {
  margin: 0;
  padding: 1rem 1.25rem;
  border-left: 4px solid rgba(212, 168, 83, 0.65);
  border-radius: 0 0.25rem 0.25rem 0;
  background: rgba(15, 23, 42, 0.45);
  font-family: var(--castalia-font-serif);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--magai-stone-300);
  max-width: 42rem;
}

article .magai-hero-quote p {
  margin: 0;
  max-width: none;
}

article .magai-hero-quote strong {
  color: var(--magai-stone-100);
}

article .magai-program-main {
  border-top: 1px solid rgba(51, 65, 85, 0.45);
  background: var(--magai-navy-950);
  padding: 2.5rem 1.5rem 3rem;
  max-width: 64rem;
  margin: 0 auto;
}

article .magai-program-main h2 {
  font-family: var(--castalia-font-sans);
  font-size: 1.25rem;
  font-weight: 650;
  color: var(--magai-stone-100);
  border-bottom-color: rgba(51, 65, 85, 0.6);
  margin-top: 2rem;
}

article .magai-program-main h2:first-child {
  margin-top: 0;
}

article .magai-program-main h2.magai-section-label {
  font-family: var(--castalia-font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--magai-stone-500);
  border-bottom: none;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
}

article .magai-program-main h2.magai-section-label:first-child {
  margin-top: 0;
}

article .magai-program-main p,
article .magai-program-main li {
  color: var(--magai-stone-300);
  max-width: 42rem;
}

article .magai-program-main strong {
  color: var(--magai-stone-100);
}

article .magai-program-main a {
  color: var(--magai-gold-muted);
}

article .magai-program-main a:hover {
  color: var(--magai-gold-bright);
}

article .magai-program-main hr {
  border: none;
  border-top: 1px solid rgba(51, 65, 85, 0.5);
  margin: 2rem 0;
}

article .magai-program-main table {
  font-size: 0.95rem;
}

article .magai-program-main th {
  background: rgba(30, 41, 59, 0.85);
  color: var(--magai-stone-100);
  border-color: rgba(71, 85, 105, 0.55);
}

article .magai-program-main td {
  border-color: rgba(71, 85, 105, 0.45);
  color: var(--magai-stone-300);
  background: rgba(17, 24, 39, 0.35);
}

article .magai-program-main table tr:nth-child(even) td {
  background: rgba(17, 24, 39, 0.55);
}

article .magai-program-main td a {
  color: var(--magai-gold-muted);
}

article .magai-program-main td code,
article .magai-program-main p code {
  background: rgba(212, 168, 83, 0.12);
  color: var(--magai-gold-bright);
}

article .magai-prose-lead {
  font-size: 1rem;
  line-height: 1.65;
  margin-bottom: 1.25rem;
}

article ul.magai-link-rows {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  border: 1px solid rgba(71, 85, 105, 0.45);
  border-radius: 0.75rem;
  overflow: hidden;
  background: rgba(17, 24, 39, 0.35);
  max-width: none;
}

article ul.magai-link-rows li {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(71, 85, 105, 0.4);
  max-width: none;
}

article ul.magai-link-rows li:last-child {
  border-bottom: none;
}

article ul.magai-link-rows li:hover {
  background: rgba(30, 41, 59, 0.35);
}

article .magai-link-rows-body {
  min-width: 0;
  flex: 1;
}

article .magai-link-rows-title {
  margin: 0 0 0.35rem;
  font-weight: 650;
  font-size: 1rem;
  color: var(--magai-stone-100);
}

article .magai-link-rows-title a {
  color: var(--magai-stone-100);
  text-decoration: none;
}

article .magai-link-rows-title a:hover {
  color: var(--magai-gold-bright);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

article .magai-link-rows-meta {
  margin: 0;
  font-size: 0.875rem;
  color: var(--magai-stone-400);
  line-height: 1.5;
}

article .magai-link-rows-meta a {
  color: var(--magai-gold-muted);
}

article .magai-link-rows-actions {
  flex-shrink: 0;
  padding-top: 0.15rem;
}

article .magai-link-rows-actions a {
  font-family: var(--castalia-font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--magai-gold-muted);
  text-decoration: none;
}

article .magai-link-rows-actions a:hover {
  text-decoration: underline;
}

article ul.magai-link-rows--compact li {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

article .magai-related-panel {
  margin-top: 2.5rem;
  padding: 1.5rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(71, 85, 105, 0.4);
  background: rgba(12, 18, 34, 0.65);
}

article .magai-related-title {
  font-family: var(--castalia-font-serif);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--magai-stone-100);
  margin: 0 0 0.5rem;
}

article .magai-related-text {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--magai-stone-400);
  line-height: 1.6;
  max-width: none;
}

article .magai-related-text a {
  color: var(--magai-gold-muted);
}

article .magai-program-main .admonition,
article .magai-program-main [class*="admonition"] {
  border-color: rgba(71, 85, 105, 0.5);
  background: rgba(17, 24, 39, 0.5);
  color: var(--magai-stone-300);
}

article .magai-program-main ul:not(.magai-link-rows) {
  padding-left: 1.25rem;
}

article .magai-program-main ul:not(.magai-link-rows) li {
  margin-bottom: 0.35rem;
}

article .magai-program-main .margin-target,
article .magai-program-main [data-node-type="myst:toc"] {
  border: 1px solid rgba(71, 85, 105, 0.45);
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  background: rgba(17, 24, 39, 0.35);
}

article .magai-program-main .margin-target a,
article .magai-program-main [data-node-type="myst:toc"] a {
  color: var(--magai-gold-muted);
}

@media (prefers-color-scheme: dark) {
  html:not(.light):not(.dark) {
    --castalia-text: #e5e7eb;
    --castalia-text-muted: #9ca3af;
    --castalia-border: #3f3f46;
    --castalia-accent: #2dd4bf;
    --castalia-accent-hover: #5eead4;
    --castalia-quote-bg: rgba(45, 212, 191, 0.1);
  }

  html:not(.light):not(.dark) article h1,
  html:not(.light):not(.dark) article h2,
  html:not(.light):not(.dark) article h3,
  html:not(.light):not(.dark) article h4,
  html:not(.light):not(.dark) article strong {
    color: #f9fafb;
  }

  html:not(.light):not(.dark) article th {
    background: #27272a;
  }

  html:not(.light):not(.dark) article code,
  html:not(.light):not(.dark) article td code {
    background: rgba(45, 212, 191, 0.12);
    color: #5eead4;
  }
}

/* --- Full-site Magisterium shell (match https://magisterium.castalia.institute/magai/) --- */
/* MyST theme toggle sets html.light or html.dark; scope dark chrome to :not(.light) so light mode covers the whole page. */
html:not(.light) {
  color-scheme: dark;
}

html.light {
  color-scheme: light;
}

html:not(.light) {
  --castalia-text: #d6d3d1;
  --castalia-text-muted: #a8a29e;
  --castalia-border: rgba(71, 85, 105, 0.55);
  --castalia-accent: var(--magai-gold-muted);
  --castalia-accent-hover: var(--magai-gold-bright);
  --castalia-quote-bg: rgba(30, 41, 59, 0.55);
}

html.light {
  --castalia-text: #1a1a1f;
  --castalia-text-muted: #4b5563;
  --castalia-border: #e5e7eb;
  --castalia-accent: #0f766e;
  --castalia-accent-hover: #0d9488;
  --castalia-quote-bg: #f8fafc;
}

html:not(.light) body {
  background-color: var(--magai-navy-950) !important;
  color: var(--magai-stone-300) !important;
}

html.light body {
  background-color: #f8fafc !important;
  color: #334155 !important;
}

/* Top bar — dark */
html:not(.light) .myst-top-nav {
  background: rgba(12, 18, 34, 0.94) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(51, 65, 85, 0.55) !important;
  box-shadow: none !important;
}

html:not(.light) .myst-home-link,
html:not(.light) .myst-home-link span {
  font-family: var(--castalia-font-serif) !important;
  font-weight: 700 !important;
  letter-spacing: -0.02em !important;
  color: var(--magai-stone-100) !important;
}

html:not(.light) .myst-top-nav-menu-button {
  color: var(--magai-stone-300) !important;
  border-color: rgba(71, 85, 105, 0.6) !important;
}

html:not(.light) .myst-search-bar {
  background: rgba(30, 41, 59, 0.55) !important;
  border-color: rgba(71, 85, 105, 0.55) !important;
  color: var(--magai-stone-200) !important;
}

html:not(.light) .myst-search-bar .myst-search-text-placeholder,
html:not(.light) .myst-search-shortcut kbd {
  color: var(--magai-stone-400) !important;
  border-color: rgba(71, 85, 105, 0.6) !important;
}

html:not(.light) .myst-theme-button {
  border-color: rgba(212, 168, 83, 0.45) !important;
  color: var(--magai-gold-muted) !important;
  background: rgba(30, 41, 59, 0.4) !important;
}

html:not(.light) .myst-theme-button:hover {
  background: rgba(212, 168, 83, 0.12) !important;
  color: var(--magai-gold-bright) !important;
}

html:not(.light) .myst-action-menu-button,
html:not(.light) .myst-top-nav a[href*="magisterium"] {
  border-color: rgba(212, 168, 83, 0.4) !important;
  color: var(--magai-stone-200) !important;
}

html:not(.light) .myst-top-nav a[href*="magisterium"]:hover {
  background: rgba(212, 168, 83, 0.1) !important;
  color: var(--magai-gold-bright) !important;
}

/* Sidebar / TOC — dark */
html:not(.light) .myst-primary-sidebar .myst-toc a,
html:not(.light) .myst-primary-sidebar-toc .myst-toc-item {
  color: var(--magai-stone-300) !important;
}

html:not(.light) .myst-primary-sidebar .myst-toc a:hover,
html:not(.light) .myst-primary-sidebar .hover\:bg-slate-300\/30:hover {
  background: rgba(30, 41, 59, 0.65) !important;
  color: var(--magai-stone-100) !important;
}

html:not(.light) .myst-primary-sidebar .border-b-2.lg\:hidden {
  border-color: rgba(71, 85, 105, 0.45) !important;
}

/* Main article column — dark Magisterium reading (when not in light mode) */
html:not(.light) article.article,
html:not(.light) article.content {
  font-family: var(--castalia-font-serif);
  color: var(--magai-stone-300);
}

html:not(.light) article .myst-fm-block-title {
  font-family: var(--castalia-font-serif);
  font-weight: 700;
  font-size: clamp(1.85rem, 1.35rem + 1.4vw, 2.35rem);
  color: var(--magai-stone-100);
  letter-spacing: -0.03em;
}

html:not(.light) article h1 .heading-text,
html:not(.light) article h2 .heading-text,
html:not(.light) article h3 .heading-text {
  font-family: var(--castalia-font-sans);
  color: var(--magai-stone-100);
}

html:not(.light) article h2,
html:not(.light) article h3 {
  border-bottom-color: rgba(71, 85, 105, 0.45);
}

html:not(.light) article strong {
  color: var(--magai-stone-100);
}

html:not(.light) article a,
html:not(.light) article a.link,
html:not(.light) article a.hover-link {
  color: var(--magai-gold-muted) !important;
}

html:not(.light) article a:hover,
html:not(.light) article a.link:hover,
html:not(.light) article a.hover-link:hover {
  color: var(--magai-gold-bright) !important;
}

/* Hub CTAs are <a class="link magai-btn …"> — global gold link color must not apply on buttons. */
html:not(.light) article a.magai-btn--primary,
html:not(.light) article .magai-btn.magai-btn--primary {
  color: var(--magai-navy-950) !important;
}

html:not(.light) article a.magai-btn--primary:hover,
html:not(.light) article .magai-btn.magai-btn--primary:hover {
  color: var(--magai-navy-950) !important;
}

html:not(.light) article a.magai-btn--ghost,
html:not(.light) article .magai-btn.magai-btn--ghost {
  color: var(--magai-stone-100) !important;
}

html:not(.light) article a.magai-btn--ghost:hover,
html:not(.light) article .magai-btn.magai-btn--ghost:hover {
  color: var(--magai-gold-bright) !important;
}

html:not(.light) article blockquote {
  border-left-color: rgba(212, 168, 83, 0.55);
  background: rgba(30, 41, 59, 0.45);
  color: var(--magai-stone-300);
}

html:not(.light) article th {
  background: rgba(30, 41, 59, 0.9) !important;
  color: var(--magai-stone-100) !important;
  border-color: rgba(71, 85, 105, 0.5) !important;
}

html:not(.light) article td {
  background: rgba(17, 24, 39, 0.35) !important;
  color: var(--magai-stone-300) !important;
  border-color: rgba(71, 85, 105, 0.4) !important;
}

html:not(.light) article table tr:nth-child(even) td {
  background: rgba(17, 24, 39, 0.55) !important;
}

html:not(.light) article code,
html:not(.light) article td code {
  background: rgba(212, 168, 83, 0.12) !important;
  color: var(--magai-gold-bright) !important;
}

html:not(.light) article pre {
  border-color: rgba(71, 85, 105, 0.45) !important;
  background: rgba(12, 18, 34, 0.65) !important;
}

/* Prev/next footer — dark */
html:not(.light) .myst-footer-link {
  background: rgba(17, 24, 39, 0.45) !important;
  border-color: rgba(71, 85, 105, 0.45) !important;
  color: var(--magai-stone-200) !important;
}

html:not(.light) .myst-footer-link:hover {
  border-color: rgba(212, 168, 83, 0.45) !important;
  color: var(--magai-gold-bright) !important;
}

html:not(.light) .myst-footer-link-group {
  color: var(--magai-stone-500) !important;
}

html:not(.light) article hr {
  border-color: rgba(71, 85, 105, 0.45) !important;
}

/* --- Hub parity: MyST body shell — force Magisterium navy when dark --- */
html:not(.light) body.m-0,
html:not(.light) body {
  background-color: var(--magai-navy-950) !important;
}

main.article-grid {
  background-color: transparent !important;
}

html:not(.light) .myst-primary-sidebar,
html:not(.light) .myst-primary-sidebar-pointer {
  background-color: rgba(10, 14, 26, 0.98) !important;
}

/*
 * Mobile / tablet (< xl): MyST hides the primary nav panel with `hidden` (no motion).
 * Replace with a left-edge slide so the TOC feels like a drawer from the left.
 * (Desktop xl+ is unchanged — theme uses the grid column there.)
 */
@media (max-width: 1279px) {
  .myst-primary-sidebar {
    left: 0;
    right: auto;
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    will-change: transform;
  }

  .myst-primary-sidebar.hidden {
    display: flex !important;
    flex-direction: column;
    transform: translate3d(-100%, 0, 0);
    visibility: hidden;
    pointer-events: none;
  }

  .myst-primary-sidebar:not(.hidden) {
    transform: translate3d(0, 0, 0);
    visibility: visible;
    pointer-events: auto;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
  }

  .myst-navigation-overlay {
    transition: opacity 0.25s ease;
  }
}

@media (max-width: 1279px) and (prefers-reduced-motion: reduce) {
  .myst-primary-sidebar {
    transition: none;
  }
}

/* Right-rail / margin TOC strip if present */
[class*="col-margin"] {
  background-color: transparent !important;
}

/* --- Light mode — full page (header, sidebar, article, footer) --- */
html.light .myst-top-nav {
  background: rgba(255, 255, 255, 0.94) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid #e2e8f0 !important;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04) !important;
}

html.light .myst-home-link,
html.light .myst-home-link span {
  font-family: var(--castalia-font-serif) !important;
  font-weight: 700 !important;
  letter-spacing: -0.02em !important;
  color: #0f172a !important;
}

html.light .myst-top-nav-menu-button {
  color: #475569 !important;
  border-color: #cbd5e1 !important;
}

html.light .myst-search-bar {
  background: #f1f5f9 !important;
  border-color: #e2e8f0 !important;
  color: #1e293b !important;
}

html.light .myst-search-bar .myst-search-text-placeholder,
html.light .myst-search-shortcut kbd {
  color: #64748b !important;
  border-color: #cbd5e1 !important;
}

html.light .myst-theme-button {
  border-color: rgba(15, 118, 110, 0.35) !important;
  color: #0f766e !important;
  background: #f0fdfa !important;
}

html.light .myst-theme-button:hover {
  background: #ccfbf1 !important;
  color: #0d9488 !important;
}

html.light .myst-action-menu-button,
html.light .myst-top-nav a[href*="magisterium"] {
  border-color: rgba(15, 118, 110, 0.35) !important;
  color: #334155 !important;
}

html.light .myst-top-nav a[href*="magisterium"]:hover {
  background: rgba(15, 118, 110, 0.08) !important;
  color: #0f766e !important;
}

html.light .myst-primary-sidebar .myst-toc a,
html.light .myst-primary-sidebar-toc .myst-toc-item {
  color: #475569 !important;
}

html.light .myst-primary-sidebar .myst-toc a:hover,
html.light .myst-primary-sidebar .hover\:bg-slate-300\/30:hover {
  background: #f1f5f9 !important;
  color: #0f172a !important;
}

html.light .myst-primary-sidebar .border-b-2.lg\:hidden {
  border-color: #e2e8f0 !important;
}

html.light .myst-primary-sidebar,
html.light .myst-primary-sidebar-pointer {
  background-color: #f8fafc !important;
  border-color: #e2e8f0;
}

html.light article.article,
html.light article.content {
  font-family: var(--castalia-font-serif);
  color: #334155;
}

html.light article .myst-fm-block-title {
  color: #0f172a;
}

html.light article h1 .heading-text,
html.light article h2 .heading-text,
html.light article h3 .heading-text {
  font-family: var(--castalia-font-sans);
  color: #0f172a;
}

html.light article h2,
html.light article h3 {
  border-bottom-color: #e2e8f0;
}

html.light article strong {
  color: #0f172a;
}

html.light article a:not(.magai-btn),
html.light article a.link:not(.magai-btn),
html.light article a.hover-link:not(.magai-btn) {
  color: #0f766e !important;
}

html.light article a:not(.magai-btn):hover,
html.light article a.link:not(.magai-btn):hover,
html.light article a.hover-link:not(.magai-btn):hover {
  color: #0d9488 !important;
}

html.light article a.magai-btn--primary,
html.light article .magai-btn.magai-btn--primary {
  color: var(--magai-navy-950) !important;
}

html.light article a.magai-btn--ghost,
html.light article .magai-btn.magai-btn--ghost {
  color: #0f172a !important;
}

html.light article blockquote {
  border-left-color: rgba(15, 118, 110, 0.45);
  background: #f1f5f9;
  color: #475569;
}

html.light article th {
  background: #f1f5f9 !important;
  color: #0f172a !important;
  border-color: #e2e8f0 !important;
}

html.light article td {
  background: #ffffff !important;
  color: #334155 !important;
  border-color: #e2e8f0 !important;
}

html.light article table tr:nth-child(even) td {
  background: #f8fafc !important;
}

html.light article code,
html.light article td code {
  background: rgba(15, 118, 110, 0.1) !important;
  color: #0f766e !important;
}

html.light article pre {
  border-color: #e2e8f0 !important;
  background: #f1f5f9 !important;
}

html.light .myst-footer-link {
  background: #f1f5f9 !important;
  border-color: #e2e8f0 !important;
  color: #334155 !important;
}

html.light .myst-footer-link:hover {
  border-color: rgba(15, 118, 110, 0.35) !important;
  color: #0f766e !important;
}

html.light .myst-footer-link-group {
  color: #64748b !important;
}

html.light article hr {
  border-color: #e2e8f0 !important;
}

/* Marketing hub blocks — light */
html.light article .magai-program-hero::before {
  background: radial-gradient(ellipse 120% 100% at 50% 0%, #e2e8f0 0%, #f8fafc 72%);
}

html.light article .magai-hero-program {
  color: #0f766e;
}

html.light article .magai-hero-sub,
html.light article .magai-hero-lead,
html.light article .magai-hero-copy > h2 + p {
  color: #1e293b;
}

html.light article .magai-hero-friction {
  border-color: rgba(185, 28, 28, 0.28);
  background: linear-gradient(135deg, rgba(254, 226, 226, 0.6) 0%, #f8fafc 55%, #f1f5f9 100%);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.06) inset;
}

html.light article .magai-hero-friction p {
  color: #334155;
}

html.light article .magai-hero-friction strong {
  color: #0f172a;
}

html.light article .magai-hero-friction em {
  color: #b45309;
}

html.light article .magai-hero-kicker,
html.light article .magai-hero-copy > h1 + p.magai-hero-kicker,
html.light article .magai-hero-copy > h2 + p + p {
  color: #475569;
}

html.light article .magai-hero-title,
html.light article .magai-hero-copy > h2:first-of-type {
  color: #0f172a;
}

html.light article .magai-hero-quote {
  background: #f1f5f9;
  border-left-color: rgba(15, 118, 110, 0.45);
  color: #334155;
}

html.light article .magai-hero-quote strong {
  color: #0f172a;
}

html.light article .magai-btn--ghost {
  background: rgba(15, 23, 42, 0.06) !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
}

html.light article .magai-stat-strip {
  border-color: #e2e8f0;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

html.light article .magai-hero-plain {
  color: #334155;
}

html.light article .magai-hero-plain strong {
  color: #0f172a;
}

html.light article .magai-cold-proof-card {
  border-color: #e2e8f0;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: none;
}

html.light article .magai-cold-proof-title {
  color: #0f172a;
}

html.light article .magai-cold-proof-card p {
  color: #475569;
}

html.light article .magai-cold-proof-card a {
  color: #0f766e;
}

html.light article .magai-cold-proof-card a:hover {
  color: #0d9488;
}

html.light article .magai-glossary-lead {
  color: #64748b;
}

html.light article .magai-prose-highlight {
  color: #334155;
  border-left-color: rgba(15, 118, 110, 0.45);
}

html.light article .magai-pillar-card {
  border-color: #e2e8f0;
  background: #ffffff;
}

html.light article .magai-pillar-title,
html.light article .magai-pillar-body > h3 {
  color: #0f172a;
}

html.light article .magai-pillar-body p {
  color: #334155;
}

html.light article .magai-pillar-body p strong {
  color: #0f172a;
}

html.light article .magai-program-main {
  background: #f8fafc;
  border-top-color: #e2e8f0;
}

html.light article .magai-program-main h2 {
  color: #0f172a;
  border-bottom-color: #e2e8f0;
}

html.light article .magai-program-main h2.magai-section-label {
  color: #64748b;
}

html.light article .magai-program-main p,
html.light article .magai-program-main li {
  color: #334155;
}

html.light article .magai-program-main strong {
  color: #0f172a;
}

html.light article .magai-program-main a {
  color: #0f766e;
}

html.light article .magai-program-main a:hover {
  color: #0d9488;
}

html.light article .magai-program-main hr {
  border-top-color: #e2e8f0;
}

html.light article .magai-program-main th {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #e2e8f0;
}

html.light article .magai-program-main td {
  color: #334155;
  background: #ffffff;
  border-color: #e2e8f0;
}

html.light article .magai-program-main table tr:nth-child(even) td {
  background: #f8fafc;
}

html.light article .magai-program-main td a {
  color: #0f766e;
}

html.light article .magai-program-main td code,
html.light article .magai-program-main p code {
  background: rgba(15, 118, 110, 0.1);
  color: #0f766e;
}

html.light article ul.magai-link-rows {
  border-color: #e2e8f0;
  background: #ffffff;
}

html.light article ul.magai-link-rows li {
  border-bottom-color: #e2e8f0;
}

html.light article ul.magai-link-rows li:hover {
  background: #f1f5f9;
}

html.light article .magai-link-rows-title,
html.light article .magai-link-rows-title a {
  color: #0f172a;
}

html.light article .magai-link-rows-title a:hover {
  color: #0f766e;
}

html.light article .magai-link-rows-meta {
  color: #64748b;
}

html.light article .magai-link-rows-meta a,
html.light article .magai-link-rows-actions a {
  color: #0f766e;
}

html.light article .magai-related-panel {
  border-color: #e2e8f0;
  background: #ffffff;
}

html.light article .magai-related-title {
  color: #0f172a;
}

html.light article .magai-related-text {
  color: #475569;
}

html.light article .magai-related-text a {
  color: #0f766e;
}

html.light article .magai-program-main .admonition,
html.light article .magai-program-main [class*="admonition"] {
  border-color: #e2e8f0;
  background: #f8fafc;
  color: #334155;
}

html.light article .magai-program-main .margin-target,
html.light article .magai-program-main [data-node-type="myst:toc"] {
  border-color: #e2e8f0;
  background: #f1f5f9;
}

html.light article .magai-program-main .margin-target a,
html.light article .magai-program-main [data-node-type="myst:toc"] a {
  color: #0f766e;
}

html.light article .magai-back-link {
  color: #64748b;
}

html.light article .magai-back-link:hover {
  color: #0f766e;
}

html.light article .magai-eyebrow {
  border-color: rgba(15, 118, 110, 0.35);
  background: rgba(15, 118, 110, 0.08);
  color: #0f766e;
}

html.light article .magai-photo-credit {
  color: #64748b;
}

html.light article .magai-photo-credit a {
  color: #0f766e;
}

html.light article .magai-stat strong {
  color: #0f766e;
}

html.light article .magai-stat span {
  color: #64748b;
}
