/* ==========================================================================
   Commodity Education - courses
   CommodityEducation.com

   Self-contained: no external fonts, no external stylesheets, no frameworks.
   The token block is copied verbatim from game.css so the two features are
   the same colour in both themes. Theme follows <html data-theme="dark">
   (the site toggle) and, absent that, the visitor's OS preference.
   ========================================================================== */

:root {
  --ce-bg:        #f7f6f3;
  --ce-panel:     #ffffff;
  --ce-panel-2:   #f0eee9;
  --ce-mat:       #e7e4dd;
  --ce-ink:       #1b1a17;
  --ce-ink-soft:  #5c584f;
  --ce-ink-faint: #8a857a;
  --ce-line:      #d9d5cb;
  --ce-accent:    #a8620d;
  --ce-accent-sf: #fdf2e2;
  --ce-tint:      #6b4a16;
  --ce-on-accent: #ffffff;
  --ce-ok:        #1d6f42;
  --ce-ok-bg:     #e6f4ea;
  --ce-bad:       #a32020;
  --ce-bad-bg:    #fbeaea;
  --ce-radius:    12px;
  --ce-shadow:    0 1px 2px rgba(0,0,0,.05), 0 8px 24px -12px rgba(0,0,0,.18);
  color-scheme:   light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ce-bg:        #12100d;
    --ce-panel:     #1c1a16;
    --ce-panel-2:   #24211c;
    --ce-mat:       #0b0a08;
    --ce-ink:       #f0ece4;
    --ce-ink-soft:  #b4ada0;
    --ce-ink-faint: #837c70;
    --ce-line:      #34302a;
    --ce-accent:    #e9a94d;
    --ce-accent-sf: #2c2318;
    --ce-tint:      #d9c39a;
    --ce-on-accent: #1b1408;
    --ce-ok:        #67d18f;
    --ce-ok-bg:     #152a1d;
    --ce-bad:       #f08b8b;
    --ce-bad-bg:    #2e1717;
    --ce-shadow:    0 1px 2px rgba(0,0,0,.4), 0 10px 30px -14px rgba(0,0,0,.7);
    color-scheme:   dark;
  }
}

:root[data-theme="dark"] {
  --ce-bg:        #12100d;
  --ce-panel:     #1c1a16;
  --ce-panel-2:   #24211c;
  --ce-mat:       #0b0a08;
  --ce-ink:       #f0ece4;
  --ce-ink-soft:  #b4ada0;
  --ce-ink-faint: #837c70;
  --ce-line:      #34302a;
  --ce-accent:    #e9a94d;
  --ce-accent-sf: #2c2318;
  --ce-tint:      #d9c39a;
  --ce-on-accent: #1b1408;
  --ce-ok:        #67d18f;
  --ce-ok-bg:     #152a1d;
  --ce-bad:       #f08b8b;
  --ce-bad-bg:    #2e1717;
  --ce-shadow:    0 1px 2px rgba(0,0,0,.4), 0 10px 30px -14px rgba(0,0,0,.7);
  color-scheme:   dark;
}

/* ---------- per-course identity ----------------------------------------
   Each course redefines the accent tokens on its own wrapper, so every
   accented thing in it - pills, rules, progress bars, links, step numbers -
   shifts together without a single component rule knowing which course it is
   in. Both themes are defined for every course, in the same three-block
   shape the base tokens use, because an accent defined only inside a media
   query is invisible to a viewer whose OS says the other thing.
   Oil keeps the site's own amber; copper takes a fired copper-red; lumber
   takes a green that still sits in the warm family rather than fighting it. */

[data-course="crude-oil-supply-chain"] {
  --ce-accent: #9a5a0c; --ce-accent-sf: #fdf1e0; --ce-on-accent: #fff;
  --ce-tint: #6b4a16;
}
[data-course="copper-supply-chain"] {
  --ce-accent: #a8481f; --ce-accent-sf: #fdeee7; --ce-on-accent: #fff;
  --ce-tint: #7d3a1c;
}
[data-course="lumber-and-timber"] {
  --ce-accent: #2f6b3a; --ce-accent-sf: #e8f3e9; --ce-on-accent: #fff;
  --ce-tint: #2b5330;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) [data-course="crude-oil-supply-chain"] {
    --ce-accent: #e9a94d; --ce-accent-sf: #2c2318; --ce-on-accent: #1b1408;
    --ce-tint: #d9c39a;
  }
  :root:not([data-theme="light"]) [data-course="copper-supply-chain"] {
    --ce-accent: #ef8f5e; --ce-accent-sf: #2e1d14; --ce-on-accent: #1d0f07;
    --ce-tint: #e0ab8c;
  }
  :root:not([data-theme="light"]) [data-course="lumber-and-timber"] {
    --ce-accent: #7fc48d; --ce-accent-sf: #16261a; --ce-on-accent: #07170c;
    --ce-tint: #a9d6b2;
  }
}

:root[data-theme="dark"] [data-course="crude-oil-supply-chain"] {
  --ce-accent: #e9a94d; --ce-accent-sf: #2c2318; --ce-on-accent: #1b1408;
  --ce-tint: #d9c39a;
}
:root[data-theme="dark"] [data-course="copper-supply-chain"] {
  --ce-accent: #ef8f5e; --ce-accent-sf: #2e1d14; --ce-on-accent: #1d0f07;
  --ce-tint: #e0ab8c;
}
:root[data-theme="dark"] [data-course="lumber-and-timber"] {
  --ce-accent: #7fc48d; --ce-accent-sf: #16261a; --ce-on-accent: #07170c;
  --ce-tint: #a9d6b2;
}

.ce-course {
  max-width: 68rem;
  margin: 0 auto;
  padding: 0 1rem 4rem;
  color: var(--ce-ink);
  font: 400 1rem/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.ce-course *,
.ce-course *::before,
.ce-course *::after { box-sizing: border-box; }

/* Long unbroken strings - a source URL, a chemical formula - wrap instead of
   widening the page. Wide tables are handled by .ce-tscroll instead; no
   overflow is set here, because clipping a table that failed to scroll would
   hide the failure rather than show it. */
.ce-course p, .ce-course li,
.ce-course dd, .ce-course dt { overflow-wrap: break-word; }

.ce-course a { color: var(--ce-accent); }

/* ---------- shared atoms ------------------------------------------------ */

.ce-eyebrow {
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ce-ink-faint);
  margin: 0 0 .5rem;
  font-weight: 600;
}

.ce-h1 {
  font-size: clamp(1.6rem, 1.1rem + 2vw, 2.4rem);
  line-height: 1.15;
  margin: 0 0 .6rem;
  letter-spacing: -.01em;
}

.ce-lede {
  color: var(--ce-ink-soft);
  font-size: 1.08rem;
  margin: 0 0 1.2rem;
  max-width: 46rem;
}

.ce-note {
  color: var(--ce-ink-faint);
  font-size: .85rem;
  line-height: 1.6;
  border-top: 1px solid var(--ce-line);
  padding-top: 1rem;
  margin-top: 2rem;
}

.ce-pill {
  display: inline-block;
  font-size: .7rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 600;
  padding: .22rem .5rem;
  border-radius: 999px;
  background: var(--ce-panel-2);
  color: var(--ce-ink-soft);
  border: 1px solid var(--ce-line);
  white-space: nowrap;
}

.ce-pill--lv1 { background: var(--ce-ok-bg);     color: var(--ce-ok);     border-color: transparent; }
.ce-pill--lv2 { background: var(--ce-accent-sf); color: var(--ce-accent); border-color: transparent; }
.ce-pill--lv3 { background: var(--ce-bad-bg);    color: var(--ce-bad);    border-color: transparent; }

.ce-btn {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid var(--ce-line);
  background: var(--ce-panel);
  color: var(--ce-ink);
  padding: .6rem 1.1rem;
  transition: background .12s ease, border-color .12s ease;
}
.ce-btn:hover:not(:disabled) { background: var(--ce-panel-2); }
.ce-btn:disabled { opacity: .45; cursor: default; }
.ce-btn--primary {
  background: var(--ce-accent);
  border-color: var(--ce-accent);
  color: var(--ce-on-accent);
}
.ce-btn--primary:hover:not(:disabled) { filter: brightness(1.06); background: var(--ce-accent); }
.ce-btn--ghost { background: transparent; }

.ce-course :focus-visible {
  outline: 2px solid var(--ce-accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- photographs ------------------------------------------------- */

/* Hero, inside a lesson. Fixed aspect so a page does not jump about as the
   pictures arrive, and object-fit so a portrait crops rather than distorts. */
.ce-hero {
  margin: 0 0 1.6rem;
  border-radius: var(--ce-radius);
  overflow: hidden;
  border: 1px solid var(--ce-line);
  background: var(--ce-panel-2);
}
.ce-hero img {
  display: block;
  width: 100%;
  /* height:auto matters. The markup carries width/height attributes so the
     browser can reserve space before the file arrives, but those become a
     presentational `height` declaration that beats aspect-ratio and renders
     the picture at its full natural height. Clearing it hands the ratio
     back to the rule below. */
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--ce-mat);
}
.ce-hero figcaption {
  padding: .7rem .9rem .8rem;
  background: var(--ce-panel);
  border-top: 3px solid var(--ce-accent);
}
.ce-hero .cap {
  display: block;
  font-size: .92rem;
  color: var(--ce-ink);
}
.ce-hero .cr {
  display: block;
  margin-top: .35rem;
  font-size: .72rem;
  color: var(--ce-ink-faint);
}
.ce-hero .cr a { color: inherit; }
.ce-hero .cr a:hover { color: var(--ce-accent); }

/* Cover, at the top of a course's contents page. */
.ce-cover {
  margin: 0 0 1.4rem;
  border-radius: var(--ce-radius);
  overflow: hidden;
  border: 1px solid var(--ce-line);
  position: relative;
}
.ce-cover img {
  display: block;
  width: 100%;
  aspect-ratio: 21 / 7;
  object-fit: cover;
  background: var(--ce-mat);
}
/* A wash in the course's own accent, so the three courses are told apart at
   a glance before a word is read. */
.ce-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 35%, var(--ce-tint) 160%);
  opacity: .35;
  pointer-events: none;
}
@media (max-width: 40rem) {
  .ce-cover img { aspect-ratio: 16 / 9; }
}

/* ---------- catalogue --------------------------------------------------- */

.ce-cards {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  margin: 1.6rem 0 0;
}

.ce-card {
  display: flex;
  flex-direction: column;
  border-radius: var(--ce-radius);
  border: 1px solid var(--ce-line);
  background: var(--ce-panel);
  box-shadow: var(--ce-shadow);
  color: inherit;
  text-decoration: none;
  font: inherit;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .12s ease, transform .12s ease;
}
.ce-card:hover { border-color: var(--ce-accent); transform: translateY(-2px); }
.ce-card-shot { display: block; position: relative; }
.ce-card-shot img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--ce-mat);
}
/* The accent wash again, so a card carries its course's colour even at
   thumbnail size. */
.ce-card-shot::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 40%, var(--ce-tint) 170%);
  opacity: .4;
}
.ce-card-body {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  padding: 1rem 1.15rem 1.15rem;
  flex: 1 1 auto;
  border-top: 3px solid var(--ce-accent);
}
.ce-card h3 { margin: 0; font-size: 1.15rem; line-height: 1.25; }
.ce-card p  { margin: 0; color: var(--ce-ink-soft); font-size: .92rem; }
.ce-card .ce-card-meta {
  margin-top: auto;
  padding-top: .5rem;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem .9rem;
  font-size: .78rem;
  color: var(--ce-ink-faint);
}

/* ---------- course shell ------------------------------------------------ */

.ce-crumbs {
  font-size: .78rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ce-ink-faint);
  margin: 1.2rem 0 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: center;
}
.ce-crumbs a { color: inherit; text-decoration: none; }
.ce-crumbs a:hover { color: var(--ce-accent); }
.ce-crumbs .sep { opacity: .45; }

.ce-shortver {
  border-left: 3px solid var(--ce-accent);
  padding: .1rem 0 .1rem 1rem;
  margin: 0 0 1.6rem;
  max-width: 46rem;
}
.ce-shortver p { margin: 0; color: var(--ce-ink-soft); }

.ce-facts {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem .75rem;
  margin: 0 0 1.6rem;
}
.ce-fact {
  background: var(--ce-panel);
  border: 1px solid var(--ce-line);
  border-radius: 10px;
  padding: .55rem .8rem;
  min-width: 6.5rem;
}
.ce-fact b { display: block; font-size: 1.25rem; line-height: 1.1; }
.ce-fact span {
  font-size: .7rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ce-ink-faint);
}

/* progress */

.ce-prog {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 0 0 1.4rem;
  font-size: .85rem;
  color: var(--ce-ink-soft);
  flex-wrap: wrap;
}
.ce-prog-bar {
  flex: 1 1 12rem;
  height: 8px;
  border-radius: 999px;
  background: var(--ce-mat);
  overflow: hidden;
}
/* Inside a catalogue card the bar is a flex ITEM in a column, where
   `flex: 1 1 12rem` means "grow vertically" and turns an 8px bar into a
   giant lozenge. Pin it. */
.ce-card .ce-prog-bar { flex: none; width: 100%; height: 6px; }
.ce-prog-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--ce-accent);
  transition: width .25s ease;
}

/* ---------- syllabus ---------------------------------------------------- */

.ce-module {
  border: 1px solid var(--ce-line);
  border-radius: var(--ce-radius);
  background: var(--ce-panel);
  margin: 0 0 .9rem;
  overflow: hidden;
}
.ce-module > summary {
  cursor: pointer;
  padding: 1rem 1.15rem;
  list-style: none;
  display: flex;
  gap: .9rem;
  align-items: baseline;
}
.ce-module > summary::-webkit-details-marker { display: none; }
.ce-module > summary::after {
  content: "";
  margin-left: auto;
  align-self: center;
  width: .5rem; height: .5rem;
  border-right: 2px solid var(--ce-ink-faint);
  border-bottom: 2px solid var(--ce-ink-faint);
  transform: rotate(45deg);
  transition: transform .15s ease;
  flex: none;
}
.ce-module[open] > summary::after { transform: rotate(-135deg); }
.ce-module-n {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: .78rem;
  flex: none;
  width: 1.9rem;
  height: 1.9rem;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ce-accent-sf);
  color: var(--ce-accent);
  align-self: center;
}
.ce-module-t { font-weight: 600; font-size: 1.02rem; }
.ce-module-b { color: var(--ce-ink-soft); font-size: .88rem; display: block; margin-top: .2rem; font-weight: 400; }

.ce-lesson-list { list-style: none; margin: 0; padding: 0 0 .5rem; }
.ce-lesson-list li { border-top: 1px solid var(--ce-line); }
.ce-lesson-row {
  display: flex;
  align-items: center;
  gap: .8rem;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: .75rem 1.15rem;
  cursor: pointer;
}
.ce-lesson-row:hover { background: var(--ce-panel-2); }
.ce-tick {
  flex: none;
  width: 1.15rem; height: 1.15rem;
  border-radius: 50%;
  border: 1.5px solid var(--ce-line);
  display: grid;
  place-items: center;
  font-size: .7rem;
  color: transparent;
}
.ce-lesson-row[data-done="1"] .ce-tick {
  background: var(--ce-ok);
  border-color: var(--ce-ok);
  color: #fff;
}
.ce-lesson-row .t { flex: 1 1 auto; }
.ce-lesson-row .m { color: var(--ce-ink-faint); font-size: .78rem; flex: none; }

/* ---------- lesson body ------------------------------------------------- */

.ce-reader { max-width: 44rem; }
.ce-reader h2 {
  font-size: 1.12rem;
  margin: 2rem 0 .6rem;
  letter-spacing: -.005em;
}
.ce-reader p { margin: 0 0 1rem; }
.ce-reader ul, .ce-reader ol { margin: 0 0 1.1rem; padding-left: 1.3rem; }
.ce-reader li { margin: 0 0 .45rem; }

.ce-box {
  border-radius: 10px;
  padding: .85rem 1rem;
  margin: 0 0 1.2rem;
  font-size: .94rem;
  border: 1px solid var(--ce-line);
  background: var(--ce-panel-2);
}
.ce-box b {
  display: block;
  font-size: .7rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: .3rem;
  color: var(--ce-ink-faint);
}
.ce-box--warn {
  background: var(--ce-accent-sf);
  border-color: transparent;
  border-left: 3px solid var(--ce-accent);
  border-radius: 4px 10px 10px 4px;
}
.ce-box--warn b { color: var(--ce-accent); }

.ce-quote {
  margin: 0 0 1.2rem;
  padding-left: 1rem;
  border-left: 3px solid var(--ce-line);
  color: var(--ce-ink-soft);
  font-size: 1.05rem;
}
.ce-quote cite { display: block; font-size: .8rem; font-style: normal; margin-top: .4rem; color: var(--ce-ink-faint); }

.ce-dl { margin: 0 0 1.2rem; }
.ce-dl div {
  display: grid;
  grid-template-columns: minmax(7rem, 12rem) 1fr;
  gap: .3rem 1rem;
  padding: .55rem 0;
  border-top: 1px solid var(--ce-line);
}
.ce-dl div:last-child { border-bottom: 1px solid var(--ce-line); }
.ce-dl dt { font-weight: 600; }
.ce-dl dd { margin: 0; color: var(--ce-ink-soft); }
@media (max-width: 34rem) { .ce-dl div { grid-template-columns: 1fr; } }

/* data tables */

.ce-tw { margin: 0 0 1.4rem; }
.ce-tw figcaption {
  font-size: .7rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ce-ink-faint);
  margin-bottom: .45rem;
  font-weight: 600;
}
.ce-tscroll { overflow-x: auto; border: 1px solid var(--ce-line); border-radius: 10px; }
.ce-tw table { border-collapse: collapse; width: 100%; font-size: .9rem; }
.ce-tw th, .ce-tw td {
  text-align: left;
  padding: .5rem .7rem;
  border-bottom: 1px solid var(--ce-line);
  white-space: nowrap;
}
.ce-tw th {
  background: var(--ce-panel-2);
  font-size: .72rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ce-ink-soft);
  position: sticky;
  top: 0;
}
.ce-tw td:first-child { white-space: normal; min-width: 8rem; }
.ce-tw tr:last-child td { border-bottom: 0; }
.ce-tw td.num { text-align: right; font-variant-numeric: tabular-nums; }
.ce-src {
  font-size: .76rem;
  color: var(--ce-ink-faint);
  margin: .45rem 0 0;
  line-height: 1.55;
}

/* process chain */

.ce-steps { margin: 0 0 1.4rem; counter-reset: st; }
.ce-step {
  position: relative;
  padding: 0 0 1.1rem 2.3rem;
  border-left: 2px solid var(--ce-line);
  margin-left: .6rem;
}
.ce-step:last-child { border-left-color: transparent; padding-bottom: 0; }
.ce-step::before {
  counter-increment: st;
  content: counter(st, decimal-leading-zero);
  position: absolute;
  left: -.85rem;
  top: -.1rem;
  width: 1.7rem; height: 1.7rem;
  border-radius: 50%;
  background: var(--ce-accent);
  border: 1px solid var(--ce-accent);
  display: grid;
  place-items: center;
  font-size: .68rem;
  font-weight: 700;
  color: var(--ce-on-accent);
  font-variant-numeric: tabular-nums;
}
.ce-step b { display: block; font-size: .95rem; }
.ce-step span { display: block; color: var(--ce-ink-soft); font-size: .92rem; }
.ce-step em {
  display: inline-block;
  margin-top: .3rem;
  font-style: normal;
  font-size: .78rem;
  color: var(--ce-accent);
  background: var(--ce-accent-sf);
  padding: .14rem .45rem;
  border-radius: 999px;
}

/* takeaways, terms, links */

.ce-panelbox {
  border: 1px solid var(--ce-line);
  background: var(--ce-panel);
  border-radius: var(--ce-radius);
  padding: 1.1rem 1.2rem;
  margin: 1.6rem 0;
}
.ce-panelbox > b {
  display: block;
  font-size: .72rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ce-ink-faint);
  margin-bottom: .6rem;
}
.ce-panelbox ul { margin: 0; padding-left: 1.2rem; }
.ce-linklist { list-style: none; margin: 0; padding: 0; }
.ce-linklist li { padding: .35rem 0; border-top: 1px solid var(--ce-line); }
.ce-linklist li:first-child { border-top: 0; }
.ce-linklist .k {
  font-size: .64rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ce-ink-faint);
  margin-left: .5rem;
}

/* ---------- quiz -------------------------------------------------------- */

.ce-quiz { margin: 1.6rem 0 0; }
.ce-q {
  border: 1px solid var(--ce-line);
  background: var(--ce-panel);
  border-radius: var(--ce-radius);
  padding: 1.1rem 1.2rem;
  margin: 0 0 .9rem;
}
.ce-q > p { margin: 0 0 .8rem; font-weight: 600; }
.ce-opts { display: grid; gap: .45rem; }
.ce-opt {
  display: flex;
  gap: .7rem;
  align-items: flex-start;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  padding: .6rem .8rem;
  border-radius: 9px;
  border: 1px solid var(--ce-line);
  background: var(--ce-bg);
  transition: border-color .12s ease, background .12s ease;
}
.ce-opt:hover:not(:disabled) { border-color: var(--ce-accent); }
.ce-opt:disabled { cursor: default; }
.ce-opt .key {
  flex: none;
  font-size: .72rem;
  font-weight: 700;
  width: 1.3rem; height: 1.3rem;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: var(--ce-panel-2);
  color: var(--ce-ink-faint);
}
.ce-opt[data-state="right"] { background: var(--ce-ok-bg);  border-color: var(--ce-ok);  color: var(--ce-ok); }
.ce-opt[data-state="right"] .key { background: var(--ce-ok); color: #fff; }
.ce-opt[data-state="wrong"] { background: var(--ce-bad-bg); border-color: var(--ce-bad); color: var(--ce-bad); }
.ce-opt[data-state="wrong"] .key { background: var(--ce-bad); color: #fff; }
.ce-why {
  margin: .8rem 0 0;
  font-size: .92rem;
  color: var(--ce-ink-soft);
  border-top: 1px solid var(--ce-line);
  padding-top: .7rem;
}

.ce-score {
  display: flex;
  align-items: center;
  gap: .8rem;
  flex-wrap: wrap;
  padding: 1rem 1.2rem;
  border-radius: var(--ce-radius);
  background: var(--ce-panel-2);
  border: 1px solid var(--ce-line);
  font-size: .95rem;
}

/* ---------- lesson nav -------------------------------------------------- */

.ce-lnav {
  display: flex;
  gap: .7rem;
  flex-wrap: wrap;
  align-items: center;
  margin: 2rem 0 0;
  padding-top: 1.4rem;
  border-top: 1px solid var(--ce-line);
}
.ce-lnav .spacer { flex: 1 1 auto; }

/* ---------- layout: reader plus contents -------------------------------- */

/* minmax(0, 1fr) rather than 1fr, and min-width:0 on the child: a grid item
   defaults to min-width:auto, which lets a wide data table push the whole
   page sideways instead of scrolling inside its own .ce-tscroll. */
.ce-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2rem;
}
.ce-reader, .ce-aside { min-width: 0; }
@media (min-width: 62rem) {
  .ce-split { grid-template-columns: minmax(0, 1fr) 15rem; }
  .ce-aside { position: sticky; top: 1rem; align-self: start; max-height: calc(100vh - 2rem); overflow-y: auto; }
}
.ce-aside ol { list-style: none; margin: 0; padding: 0; font-size: .85rem; }
.ce-aside li { margin: 0 0 .1rem; }
.ce-aside button {
  display: flex;
  gap: .5rem;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: .85rem;
  color: var(--ce-ink-soft);
  background: none;
  border: 0;
  border-left: 2px solid var(--ce-line);
  padding: .35rem .6rem;
  cursor: pointer;
}
.ce-aside button:hover { color: var(--ce-ink); background: var(--ce-panel-2); }
.ce-aside button[aria-current="true"] {
  color: var(--ce-accent);
  border-left-color: var(--ce-accent);
  font-weight: 600;
}
.ce-aside .n { font-variant-numeric: tabular-nums; opacity: .6; flex: none; }

/* ---------- printing ---------------------------------------------------- */

@media print {
  .ce-aside, .ce-lnav, .ce-prog, .ce-opt, .ce-btn { display: none !important; }
  .ce-course { max-width: none; }
  .ce-q, .ce-panelbox, .ce-card { break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) {
  .ce-course * { transition: none !important; }
}

/* ce-site-theme-adapter-20260930 */
/* ==========================================================================
   Site adapter - added 2026-09-30, when these courses were wired into
   commodityeducation.com.

   The bundle turns its dark tokens on in two ways: the visitor's OS
   preference, or an explicit <html data-theme="dark">. This site does
   neither. Dark is its DEFAULT, and light is the opt-in: the inline script in
   base.html sets data-theme="light" and nothing else, so on the dark theme the
   html element carries no data-theme attribute at all.

   Without this block, a visitor whose OS is in light mode gets the course
   CSS's LIGHT ink (#1b1a17) painted over the site's dark page - dark grey text
   on a near-black background, which is what /courses actually shipped as for
   about twenty minutes before this was caught in a browser.

   So: apply the dark tokens whenever the site is not explicitly in light mode,
   independent of the OS. Specificity (0,2,0) beats the base :root block and
   ties with the media-query version, and this comes last, so it wins. When
   data-theme="light" IS set these selectors stop matching and the base light
   tokens take over, which is exactly right.
   ========================================================================== */

:root:not([data-theme="light"]) {
  --ce-bg:        #12100d;
  --ce-panel:     #1c1a16;
  --ce-panel-2:   #24211c;
  --ce-mat:       #0b0a08;
  --ce-ink:       #f0ece4;
  --ce-ink-soft:  #b4ada0;
  --ce-ink-faint: #837c70;
  --ce-line:      #34302a;
  --ce-accent:    #e9a94d;
  --ce-accent-sf: #2c2318;
  --ce-tint:      #d9c39a;
  --ce-on-accent: #1b1408;
  --ce-ok:        #67d18f;
  --ce-ok-bg:     #152a1d;
  --ce-bad:       #f08b8b;
  --ce-bad-bg:    #2e1717;
  --ce-shadow:    0 1px 2px rgba(0,0,0,.4), 0 10px 30px -14px rgba(0,0,0,.7);
  color-scheme:   dark;
}

/* the same for each course's own accent, or the three courses would lose the
   colour identity the bundle gives them */
:root:not([data-theme="light"]) [data-course="crude-oil-supply-chain"] {
  --ce-accent: #e9a94d; --ce-accent-sf: #2c2318; --ce-on-accent: #1b1408;
  --ce-tint: #d9c39a;
}
:root:not([data-theme="light"]) [data-course="copper-supply-chain"] {
  --ce-accent: #ef8f5e; --ce-accent-sf: #2e1d14; --ce-on-accent: #1d0f07;
  --ce-tint: #e0ab8c;
}
:root:not([data-theme="light"]) [data-course="lumber-and-timber"] {
  --ce-accent: #7fc48d; --ce-accent-sf: #16261a; --ce-on-accent: #07170c;
  --ce-tint: #a9d6b2;
}
