/* ---------- palette ---------- */
:root {
  --md-primary-fg-color: #4f46e5;
  --md-primary-fg-color--light: #818cf8;
  --md-primary-fg-color--dark: #3730a3;
  --md-accent-fg-color: #0d9488;
  --brand-grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #0d9488 100%);
  --card-bg: #ffffff;
  --card-border: #e5e7eb;
  --muted: #6b7280;
  --chip-bg: #eef2ff;
  --chip-fg: #3730a3;
  --done-bg: #dcfce7;
  --done-fg: #166534;
  --todo-bg: #fef3c7;
  --todo-fg: #92400e;
  --diagram-bg: #0f172a;
  --diagram-fg: #e2e8f0;
}
[data-md-color-scheme="slate"] {
  --md-default-bg-color: #0b1020;
  --md-default-bg-color--light: #111733;
  --md-primary-fg-color: #6366f1;
  --md-accent-fg-color: #2dd4bf;
  --md-typeset-a-color: #a5b4fc;
  --card-bg: #121933;
  --card-border: #232c4f;
  --muted: #94a3b8;
  --chip-bg: #1e1b4b;
  --chip-fg: #c7d2fe;
  --done-bg: #052e16;
  --done-fg: #86efac;
  --todo-bg: #422006;
  --todo-fg: #fcd34d;
  --diagram-bg: #070b18;
}

/* ---------- header & tabs ---------- */
.md-header, .md-tabs { background: var(--brand-grad); }
.md-tabs__link { font-weight: 600; opacity: .85; }
.md-tabs__link--active, .md-tabs__link:hover { opacity: 1; }
.md-header__title { font-weight: 700; letter-spacing: -.01em; }

/* ---------- typography ---------- */
.md-typeset { font-size: .8rem; line-height: 1.7; }
.md-typeset h1 {
  font-weight: 800; letter-spacing: -.02em; margin-bottom: .6rem;
  background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.md-typeset h2 {
  font-weight: 700; letter-spacing: -.01em; margin-top: 2.4rem;
  padding-left: .7rem; border-left: 4px solid var(--md-primary-fg-color);
}
.md-typeset h3 { font-weight: 650; color: var(--md-primary-fg-color); }
.md-typeset code { border-radius: 6px; padding: .1em .35em; }

/* ---------- lab header chips ---------- */
.lab-meta { display: flex; flex-wrap: wrap; gap: .45rem; margin: .2rem 0 .5rem; }
.chip {
  display: inline-flex; align-items: center; gap: .3rem; padding: .22rem .7rem;
  border-radius: 999px; font-size: .68rem; font-weight: 600; line-height: 1.4;
  background: var(--chip-bg); color: var(--chip-fg); white-space: nowrap;
}
.chip--done { background: var(--done-bg); color: var(--done-fg); }
.chip--todo { background: var(--todo-bg); color: var(--todo-fg); }
.lab-services { font-size: .7rem; color: var(--muted); margin-bottom: 1.2rem; }
.lab-services strong { color: inherit; }

/* ---------- admonitions ---------- */
.md-typeset .admonition, .md-typeset details {
  border-radius: 12px; border-width: 1px; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.md-typeset .admonition.abstract {
  border: none; background: var(--card-bg); position: relative;
  box-shadow: 0 0 0 1px var(--card-border), 0 8px 24px -12px rgba(79,70,229,.35);
}
.md-typeset .admonition.abstract::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; border-radius: 12px 0 0 12px;
  background: var(--brand-grad);
}

/* ---------- quiz cards ---------- */
.md-typeset .admonition.question {
  border: 1px solid var(--card-border); background: var(--card-bg);
  box-shadow: 0 6px 20px -14px rgba(0,0,0,.35);
}
.md-typeset .admonition.question > .admonition-title {
  background: transparent; font-weight: 700; color: var(--md-primary-fg-color);
}
.md-typeset .admonition.question > .admonition-title::before { background-color: var(--md-primary-fg-color); }
.md-typeset .admonition.question details.success {
  border: 1px dashed var(--md-accent-fg-color); box-shadow: none; margin-top: .6rem;
}
.md-typeset .admonition.question details.success > summary {
  background: transparent; color: var(--md-accent-fg-color); font-weight: 650;
}

/* ---------- tables ---------- */
.md-typeset table:not([class]) {
  border: 1px solid var(--card-border); border-radius: 12px; overflow: hidden;
  font-size: .72rem; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.md-typeset table:not([class]) th {
  background: var(--chip-bg); color: var(--chip-fg); font-weight: 700;
}
.md-typeset table:not([class]) tr:hover td { background: rgba(99,102,241,.06); }
.md-typeset__scrollwrap { margin: 1em 0; }

/* ---------- ASCII diagrams / code ---------- */
.md-typeset pre > code {
  border-radius: 12px; font-size: .68rem; line-height: 1.5;
}
.md-typeset .highlight:not([class*="language-"]) pre > code,
.md-typeset pre > code:not([class*="language-"]) {
  background: var(--diagram-bg); color: var(--diagram-fg);
}

/* ---------- home: hero ---------- */
.hero {
  border-radius: 20px; padding: 2.4rem 2rem; margin: .5rem 0 2rem; color: #fff;
  background: var(--brand-grad); box-shadow: 0 20px 50px -25px rgba(79,70,229,.7);
}
.hero h1 { color: #fff !important; background: none; -webkit-text-fill-color: #fff; margin: 0 0 .4rem; font-size: 2rem; }
.hero p { font-size: .9rem; opacity: .92; max-width: 46rem; margin: 0 0 1.2rem; }
.hero .md-button { color: #fff; border-color: rgba(255,255,255,.7); border-radius: 999px; }
.hero .md-button--primary { background: #fff; color: #4f46e5; border-color: #fff; }
.hero-stats { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 1.4rem; }
.hero-stat {
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25);
  border-radius: 14px; padding: .6rem 1rem; min-width: 7.5rem; backdrop-filter: blur(4px);
}
.hero-stat b { display: block; font-size: 1.3rem; line-height: 1.2; }
.hero-stat span { font-size: .66rem; opacity: .85; text-transform: uppercase; letter-spacing: .06em; }
.progress { height: 8px; background: rgba(255,255,255,.25); border-radius: 999px; margin-top: 1.2rem; overflow: hidden; }
.progress > div { height: 100%; background: #fff; border-radius: 999px; }

/* ---------- home: lab cards ---------- */
.md-typeset .grid.cards > ul > li {
  border-radius: 16px; background: var(--card-bg); border: 1px solid var(--card-border);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.md-typeset .grid.cards > ul > li:hover {
  transform: translateY(-3px); border-color: var(--md-primary-fg-color);
  box-shadow: 0 14px 30px -18px rgba(79,70,229,.6);
}
.md-typeset .grid.cards .chip { font-size: .6rem; padding: .12rem .55rem; }
.card-num { font-family: var(--md-code-font-family); color: var(--muted); font-size: .7rem; }
.md-typeset .grid.cards > ul > li > p:first-child { margin-top: 0; }

@media screen and (max-width: 44.9375em) {
  .hero { padding: 1.6rem 1.2rem; border-radius: 16px; }
  .hero h1 { font-size: 1.5rem; }
}

/* ---------- random quiz ---------- */
.quiz-toolbar { display: flex; flex-wrap: wrap; gap: .8rem; margin: 1rem 0; }
.quiz-toolbar label { display: flex; flex-direction: column; font-size: .65rem; font-weight: 600; color: var(--muted); gap: .2rem; }
.quiz-toolbar select {
  font: inherit; font-size: .75rem; color: var(--md-default-fg-color); background: var(--card-bg);
  border: 1px solid var(--card-border); border-radius: 10px; padding: .4rem .6rem; min-width: 12rem;
}
.quiz-stats { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; margin-bottom: 1rem; }
.quiz-link { background: none; border: none; color: var(--muted); font-size: .65rem; text-decoration: underline; cursor: pointer; }
.quiz-card {
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 18px; padding: 1.4rem 1.6rem;
  box-shadow: 0 18px 40px -26px rgba(79,70,229,.55);
}
.quiz-meta { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .8rem; }
.quiz-meta a.chip { text-decoration: none; }
.quiz-question { font-size: .95rem; font-weight: 600; line-height: 1.6; }
.quiz-answer {
  margin-top: 1rem; padding: .9rem 1.1rem; border-radius: 12px; border: 1px dashed var(--md-accent-fg-color);
  background: rgba(13,148,136,.06);
}
.quiz-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.2rem; }
.quiz-actions .md-button { margin: 0; border-radius: 999px; }
.quiz-skip { margin-left: auto !important; opacity: .75; }
.quiz-empty, .quiz-loading { color: var(--muted); }
