:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1c2024;
  --muted: #5f6773;
  --accent: #2f6f4f;
  --accent-soft: #e6f1ea;
  --danger: #b3261e;
  --warn: #9a6700;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
/* Dark palette: follows the OS unless the navbar toggle pinned a theme (data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a; --surface: #1c1f24; --border: #2c313a; --text: #e8eaed;
    --muted: #9aa3af; --accent: #5fb488; --accent-soft: #1e2f27; --danger: #f2857d;
    --warn: #e0ac47; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14161a; --surface: #1c1f24; --border: #2c313a; --text: #e8eaed;
  --muted: #9aa3af; --accent: #5fb488; --accent-soft: #1e2f27; --danger: #f2857d;
  --warn: #e0ac47; --shadow: none; color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }
* { box-sizing: border-box; }
/* Keep scrollIntoView / #anchor targets clear of the sticky header (60px, 56px on phones). */
html { scroll-padding-top: calc(60px + 1rem); }
body {
  margin: 0; font-family: var(--font); background: var(--bg); color: var(--text);
  line-height: 1.55; -webkit-font-smoothing: antialiased;
  min-height: 100vh; display: flex; flex-direction: column;
}
body > main { flex: 1 0 auto; width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; margin: 0 0 .2em; }
h2 { font-size: 1.2rem; }

.tagline { color: var(--muted); font-style: italic; margin: 0 0 1rem; }

/* ---- Site header ------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(12px); backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex; align-items: center; gap: 2rem;
  max-width: 1140px; height: 60px; margin: 0 auto; padding: 0 1.5rem;
}
.site-header .bi { margin-right: 0; }
.site-header form { margin: 0; }

.brand {
  display: inline-flex; align-items: center; gap: .6rem; flex-shrink: 0;
  color: var(--text); font-weight: 700; font-size: 1.05rem; letter-spacing: -.025em;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: #fff; font-size: .95rem;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .12);
}
:root.dark-theme .brand-mark { color: var(--bg); }

.main-nav { display: flex; align-items: center; gap: .25rem; flex: 1; min-width: 0; }
.nav-link {
  display: inline-flex; align-items: center; gap: .45rem; height: 36px; padding: 0 .8rem;
  border-radius: 8px; color: var(--muted); font-size: .9rem; font-weight: 500; white-space: nowrap;
  transition: color .15s, background-color .15s;
}
.nav-link .bi { font-size: .95rem; }
.nav-link:hover { color: var(--text); background: var(--bg); text-decoration: none; }
.nav-link.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.header-actions { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0;
  border: 1px solid transparent; border-radius: 8px; background: none; cursor: pointer;
  color: var(--muted); font-size: 1.05rem; line-height: 1;
  transition: color .15s, background-color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--text); background: var(--bg); border-color: var(--border); }
.site-header :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle .bi-sun { display: none; }
.dark-theme .theme-toggle .bi-sun { display: inline; }
.dark-theme .theme-toggle .bi-moon-stars { display: none; }
.nav-toggle { display: none; }
.nav-toggle .bi-x-lg, .nav-open .nav-toggle .bi-list { display: none; }
.nav-open .nav-toggle .bi-x-lg { display: inline; }

.user-menu { position: relative; }
.user-trigger {
  display: flex; align-items: center; gap: .55rem; height: 36px; padding: 0 .55rem 0 .3rem;
  border: 1px solid var(--border); border-radius: 999px; cursor: pointer; list-style: none;
  color: var(--text); font-size: .88rem; font-weight: 500; user-select: none;
  transition: background-color .15s, border-color .15s;
}
.user-trigger::-webkit-details-marker { display: none; }
.user-trigger:hover, .user-menu[open] .user-trigger { background: var(--bg); }
.avatar {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-size: .78rem; font-weight: 700;
}
.user-name { max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caret { font-size: .7rem; color: var(--muted); transition: transform .15s; }
.user-menu[open] .caret { transform: rotate(180deg); }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; padding: .35rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(16, 24, 40, .14), 0 2px 6px rgba(16, 24, 40, .06);
}
.menu-head { display: flex; flex-direction: column; padding: .5rem .65rem .6rem; line-height: 1.35; }
.menu-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-label { color: var(--muted); font-size: .76rem; }
.menu-sep { height: 1px; margin: .3rem 0; background: var(--border); }
.menu-item {
  display: flex; align-items: center; gap: .6rem; width: 100%; padding: .5rem .65rem;
  border: 0; border-radius: 7px; background: none; cursor: pointer; text-align: left;
  color: var(--text); font: inherit; font-size: .88rem;
}
.menu-item .bi { color: var(--muted); }
.menu-item:hover { background: var(--bg); text-decoration: none; }
.menu-item.active { color: var(--accent); }
.menu-item.active .bi { color: var(--accent); }
.menu-item.danger:hover, .menu-item.danger:hover .bi { color: var(--danger); }

@media (max-width: 760px) {
  html { scroll-padding-top: calc(56px + 1rem); }
  .header-inner { flex-wrap: wrap; height: auto; min-height: 56px; gap: 0 1rem; padding: 0 1rem; }
  .brand, .header-actions { height: 56px; }
  .nav-toggle { display: inline-grid; }
  .user-name { display: none; }
  .user-trigger { padding: 0 .45rem 0 .25rem; gap: .35rem; }
  .main-nav {
    display: none; order: 3; flex: 1 0 100%; flex-direction: column; align-items: stretch;
    gap: .15rem; padding: .5rem 0 .75rem; border-top: 1px solid var(--border);
  }
  .nav-open .main-nav { display: flex; }
  .nav-link { height: 42px; }
}

.container { max-width: 960px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
.container.wide { max-width: 1140px; }
/* ---- Site footer ------------------------------------------------------- */
.site-footer {
  display: flex; margin-top: 10em;
  background: var(--surface); border-top: 1px solid var(--border);
  font-size: .9rem; color: var(--text);
}
.footer-inner {
  display: flex; flex-direction: column; justify-content: space-between; gap: 3rem;
  width: 100%; max-width: 1140px; margin: 0 auto; padding: 3.5rem 1.5rem 2rem;
}
.site-footer .bi { margin-right: 0; }
.footer-top { display: flex; gap: 2.5rem; }
.footer-about { flex: 2 1 0; min-width: 0; }
.footer-about p { max-width: 22rem; }
.footer-tagline { margin: .9rem 0 .35rem; color: var(--text); font-style: italic; }
.footer-blurb { margin: 0; color: var(--muted); line-height: 1.6; }
.footer-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: .65rem; }
.footer-heading {
  margin: .35rem 0 .35rem; color: var(--text); font-size: .75rem; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
}
.footer-col a { color: var(--muted); transition: color .15s; }
.footer-col a:hover { color: var(--accent); text-decoration: none; }
.footer-theme, .footer-top-link {
  display: inline-flex; align-items: center; gap: .5rem; padding: 0; border: 0; background: none;
  cursor: pointer; color: var(--muted); font: inherit; transition: color .15s;
}
.footer-theme:hover, .footer-top-link:hover { color: var(--accent); }
.footer-theme .to-light, .dark-theme .footer-theme .to-dark { display: none; }
.dark-theme .footer-theme .to-light { display: inline; }
.footer-bottom {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding-top: 1.5rem; border-top: 1px solid var(--border); color: var(--muted); font-size: .85rem;
}
.site-footer :focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
@media (max-width: 760px) {
  .footer-inner { padding: 2.5rem 1rem 1.5rem; }
  .footer-top { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2rem 1.5rem; }
  .footer-about { grid-column: 1 / -1; }
  .footer-about p { max-width: none; }
}
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.exam-view { min-height: 100vh; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem 1.4rem; box-shadow: var(--shadow); margin-bottom: 1rem;
}
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.muted { color: var(--muted); }
.pill {
  display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .78rem;
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.pill-duplicate { background: rgba(179,38,30,.12); color: var(--danger); }
.pill-generic { background: rgba(154,103,0,.12); color: var(--warn); }
.pill-beta { background: rgba(154,103,0,.12); color: var(--warn); font-size: .68rem; letter-spacing: .04em; text-transform: uppercase; vertical-align: middle; }
.pill-private { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.stat { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; }

.btn {
  display: inline-flex; align-items: center; gap: .4rem; padding: .55rem 1rem;
  border-radius: 9px; border: 1px solid var(--accent); background: var(--accent); color: #fff;
  font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer;
}
.btn:hover { text-decoration: none; opacity: .93; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.subtle { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.sm { padding: .35rem .7rem; font-size: .84rem; }
.btn.subtle.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

label { display: block; font-size: .85rem; font-weight: 600; margin: .8rem 0 .25rem; }
input, select, textarea {
  width: 100%; padding: .5rem .65rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit;
}
input[type=checkbox], input[type=radio] { width: auto; }
label.check { display: flex; align-items: center; gap: .45rem; font-weight: 400; margin: .45rem 0; }
.check-list { columns: 2 260px; column-gap: 1.5rem; }
.check-list label.check { break-inside: avoid; margin: 0 0 .55rem; font-size: .9rem; }
.inline-form { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; }
.inline-form > div { flex: 1; min-width: 130px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--border); font-size: .92rem; }
th { color: var(--muted); font-weight: 600; }

.breadcrumb { font-size: .85rem; color: var(--muted); margin-bottom: 1rem; }
.breadcrumb ol { display: flex; flex-wrap: wrap; align-items: center; margin: 0; padding: 0; list-style: none; }
.breadcrumb li + li::before { content: "/"; margin: 0 .45rem; color: var(--muted); opacity: .55; }
.breadcrumb [aria-current] { color: var(--text); }
.messages { list-style: none; padding: 0; }
.messages li { padding: .6rem .9rem; border-radius: 8px; background: var(--accent-soft); margin-bottom: .5rem; }
.messages li i { margin-right: .4rem; color: var(--accent); }

.choices { display: flex; flex-direction: column; gap: .55rem; margin: 1rem 0 .4rem; }
.choice {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .7rem .85rem; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); cursor: pointer; transition: border-color .12s, background .12s;
}
.choice:hover { border-color: var(--accent); }
.choice-key {
  flex: none; width: 1.6rem; height: 1.6rem; border-radius: 50%;
  display: grid; place-items: center; font-size: .82rem; font-weight: 700;
  border: 1px solid var(--border); color: var(--muted); background: var(--bg);
}
.choice-body { display: flex; flex-direction: column; gap: .2rem; flex: 1; }
.choice-text { white-space: pre-wrap; }
.badge-ai { align-self: flex-start; font-size: .72rem; font-weight: 600; padding: .05rem .5rem; border-radius: 999px;
  border: 1px solid var(--border, currentColor); color: var(--muted); }
.badge-ai .bi { margin-right: .3rem; }
.choice-note { font-size: .84rem; color: var(--muted); }
.choice-mark { flex: none; font-weight: 700; color: var(--accent); }
.choice-mark.wrong { color: var(--danger); }

.choice.selected { border-color: var(--accent); background: var(--accent-soft); }
.choice.selected .choice-key { border-color: var(--accent); background: var(--accent); color: #fff; }
.choice.correct { border-color: var(--accent); background: var(--accent-soft); }
.choice.correct .choice-key { border-color: var(--accent); background: var(--accent); color: #fff; }
.choice.wrong { border-color: var(--danger); background: rgba(179,38,30,.08); }
.choice.wrong .choice-key { border-color: var(--danger); background: var(--danger); color: #fff; }

.explain {
  margin-top: .7rem; padding: .7rem .85rem; border-radius: 9px;
  background: var(--accent-soft); font-size: .92rem;
}
.explain strong { color: var(--accent); margin-right: .3rem; }
.navigator { display: flex; flex-wrap: wrap; gap: .35rem; }
.navigator button {
  width: 2rem; height: 2rem; border-radius: 7px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; font-size: .8rem;
}
.navigator button.answered { background: var(--accent-soft); border-color: var(--accent); }
.navigator button.active { outline: 2px solid var(--accent); }

/* Generated objective study material (markdown-rendered). */
.study-material > :first-child { margin-top: 0; }
.study-material > :last-child { margin-bottom: 0; }
.study-material h2, .study-material h3, .study-material h4 {
  font-size: .95rem; margin: 1rem 0 .4rem; color: var(--accent);
}
.study-material ul, .study-material ol { margin: .4rem 0; padding-left: 1.25rem; }
.study-material li { margin: .25rem 0; }
.study-material p { margin: .5rem 0; }
.study-material table { margin: .6rem 0; font-size: .9rem; }
.study-material th, .study-material td {
  border: 1px solid var(--border); padding: .35rem .5rem; text-align: left;
}
.study-material th { background: var(--accent-soft); }
.study-material code {
  background: var(--accent-soft); padding: .1rem .3rem; border-radius: 4px; font-size: .88rem;
}

.q-nav { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.q-nav .q-nav-pos { font-size: .85rem; margin: 0 .3rem; }

.bi { vertical-align: -.125em; margin-right: .4rem; }
.btn .bi { margin-right: 0; }
th a { white-space: nowrap; }
.truncate { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
th a .bi { margin-right: 0; margin-left: .3rem; }
.choice-mark .bi { margin-right: 0; }
.stat .bi { font-size: 1.4rem; color: var(--accent); vertical-align: .06em; }
.choice-mark i.bi-check-circle-fill { color: var(--accent); }
.choice-mark.wrong i.bi-x-circle-fill { color: var(--danger); }

/* Title + primary-action row, shared by the course and statistics pages. */
.page-head {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: .8rem; margin-bottom: 1rem;
}
.page-head h1 { margin-bottom: 0; }

/* Statistics page: progress meters and chart frames. */
.progress {
  display: block; height: 6px; border-radius: 999px; background: var(--border);
  overflow: hidden; margin-top: .55rem;
}
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

.stat-row { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.stat-row .stat { line-height: 1.1; }
.stat-sub { font-size: .85rem; margin-top: .4rem; }

.grid.stat-grid { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.chart-grid { grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); }
.chart-box { position: relative; height: 240px; margin-top: .4rem; }

.impersonating { display: flex; align-items: center; justify-content: center; gap: .75rem; padding: .4rem 1rem; background: var(--accent-soft); border-bottom: 2px solid var(--accent); }

/* "Ask a chatbot" buttons: logo only, expand to a label on hover/focus. */
.ask-bots { display: flex; align-items: center; gap: .4rem; margin-top: .6rem; }
.ask-label { font-size: .82rem; margin-right: .2rem; }
.ask-bot {
  --bot-bg: #444; --bot-fg: #fff;
  display: inline-flex; align-items: center; height: 2rem; padding: 0 .55rem; border-radius: 999px;
  background: var(--bot-bg); color: var(--bot-fg); overflow: hidden; text-decoration: none;
  font-size: .84rem; font-weight: 600; white-space: nowrap;
}
.ask-bot:hover, .ask-bot:focus-visible { text-decoration: none; opacity: 1; }
.ask-bot svg { width: 1.05rem; height: 1.05rem; flex: none; fill: currentColor; }
.ask-text { max-width: 0; opacity: 0; margin-left: 0; transition: max-width .25s ease, opacity .2s ease, margin-left .25s ease; }
.ask-bot:hover .ask-text, .ask-bot:focus-visible .ask-text { max-width: 9rem; opacity: 1; margin-left: .45rem; }
.ask-chatgpt { --bot-bg: #10a37f; }
.ask-claude { --bot-bg: #d97757; }
.ask-perplexity { --bot-bg: #20808d; }
.ask-deepseek { --bot-bg: #4d6bfe; }
.ask-grok { --bot-bg: #111; }
.ask-meta { --bot-bg: #0866ff; }
.ask-bots { flex-wrap: wrap; }
.ask-qwen { --bot-bg: #615ced; }
.ask-google { --bot-bg: #4285f4; }

/* Summarized stem with a "show original" toggle (catalog/_stem.html, exams/run.html) */
.stem-wrap p, .stem-summary { margin-bottom: .3rem; }
.link-btn, .stem-original summary {
  background: none; border: 0; padding: 0; font: inherit; font-size: .82rem; cursor: pointer;
  color: var(--muted); display: inline-flex; align-items: center; gap: .3rem; margin-bottom: .6rem;
}
.link-btn:hover, .stem-original summary:hover { color: var(--accent); }
.stem-original summary { list-style: none; }
.stem-original summary::-webkit-details-marker { display: none; }
.stem-original[open] summary .bi-eye::before { content: "\f340"; } /* bi-eye-slash */
.stem-original > p {
  margin: 0 0 .8rem; padding: .6rem .8rem; border-left: 3px solid var(--border);
  color: var(--muted); font-size: .92rem;
}
