:root {
  color-scheme: light;
  --night: #0f1115;
  --graphite: #3a414a;
  --steel: #8fa2b6;
  --ivory: #e9e5db;
  --paper: #f7f6f1;
  --paper-hi: #fcfbf7;
  --ink: #20262b;
  --dim: #525b63;
  --rule: #d5d5ce;
  --side: 264px;
  --head: 64px;
  --serif: 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', Georgia, serif;
  --mono: ui-monospace, 'SFMono-Regular', Consolas, monospace;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--head) + 20px); }
body { margin: 0; background: var(--paper); color: var(--ink); line-height: 1.6; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
a { color: inherit; }
button, input, select, textarea { max-width: 100%; }
button:focus-visible, summary:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #5185a8; outline-offset: 3px; }
[hidden] { display: none !important; }
::selection { background: #c9d7e1; color: #11181d; }
.topbar {
  min-height: var(--head); position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 30px 0 23px; background: var(--night); color: var(--ivory);
  border-bottom: 1px solid #333941;
}
.brand { display: inline-flex; gap: 11px; align-items: center; color: var(--ivory); text-decoration: none; font-weight: 650; font-size: 19px; line-height: 1; letter-spacing: .24em; }
.brand svg { width: 31px; height: 31px; flex: none; }
.app-shell { min-height: calc(100dvh - var(--head)); display: grid; grid-template-columns: var(--side) minmax(0, 1fr); align-items: start; }
.sidebar {
  position: sticky; top: var(--head); height: calc(100dvh - var(--head)); overflow: auto;
  overscroll-behavior: contain; scrollbar-color: #414951 transparent;
  background: #191d22; color: #c8ced4; padding: 33px 18px 24px;
  border-right: 1px solid #2e353d;
}
.sidebar a { text-decoration: none; }
.sidebar button { color: inherit; }
.sidebar a, .sidebar button { touch-action: manipulation; }
.lesson-main { min-width: 0; width: min(100%, 1090px); margin: 0 auto; padding: 38px clamp(26px, 6vw, 90px) 110px; }
.lesson-header { margin: 0 0 22px; }
.eyebrow, .section-label {
  margin: 0 0 10px; color: #596c79; font: 600 10.5px/1.5 var(--mono); letter-spacing: .13em; text-transform: uppercase;
}
h1, h2, h3, h4, p, figure { margin-top: 0; }
h1, .lesson-title {
  font-family: var(--serif); font-weight: 500; font-size: clamp(40px, 4.6vw, 67px);
  line-height: 1.04; letter-spacing: -.052em; text-wrap: balance; margin-bottom: 16px;
}
h2 { font: 500 clamp(28px, 2.8vw, 40px)/1.12 var(--serif); letter-spacing: -.038em; margin-bottom: 16px; }
h3 { line-height: 1.25; }
p { margin-bottom: 1em; }
math { font-size: 1.15em; }
math[display=block] { margin: .7em 0; }
.lesson-main :is(p, ul, ol, dl) { overflow-wrap: break-word; }
.lesson-main :is(pre, .math-block) { max-width: 100%; overflow-x: auto; }
.lesson-main section, .lesson-main [id] { scroll-margin-top: 16px; }
.lesson-main code, .lesson-main pre { font-family: var(--mono); }
.lesson-main pre { background: #e9eae4; padding: 16px; border: 1px solid var(--rule); border-radius: 5px; font-size: .85em; }
.lesson-main input:not([type=range],[type=radio],[type=checkbox]), .lesson-main select, dialog input, dialog select, .tutor-panel textarea {
  background: var(--paper-hi); color: var(--ink); border: 1px solid #a6abb0; border-radius: 4px; padding: 9px 12px;
  font-size: 16px; min-height: 42px;
}
input[type=radio], input[type=checkbox] { accent-color: #425b6f; }
button.primary, .btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: .55em;
  color: white; background: #2d404e; border: 1px solid #2d404e; border-radius: 4px;
  padding: 10px 17px; font-size: 14px; font-weight: 600; text-decoration: none;
}
button.primary:hover, .btn-primary:hover { background: #1d303f; }
dialog {
  width: min(430px, calc(100% - 32px)); max-height: calc(100dvh - 48px); overflow: auto;
  padding: 27px; color: var(--ink); border: 1px solid #969da2; border-radius: 8px; background: var(--paper-hi);
  box-shadow: 0 20px 75px #10182042;
}
dialog::backdrop { background: rgb(10 13 16 / .6); }
dialog label { display: grid; gap: 6px; margin-bottom: 14px; font-size: 14px; font-weight: 550; }
.tutor-panel {
  position: fixed; z-index: 41; bottom: 80px; right: 24px;
  width: min(410px, calc(100vw - 32px)); max-height: min(690px, calc(100dvh - 108px)); overflow-y: auto;
  border: 1px solid #818991; border-radius: 9px; background: var(--paper-hi); color: var(--ink);
  box-shadow: 0 15px 55px #0f141c35;
}
.tutor-panel textarea { width: 100%; resize: vertical; }
@media (max-width: 960px) {
  :root { --side: 235px; }
  .lesson-main { padding-right: 32px; padding-left: 32px; }
}
@media (max-width: 760px) {
  :root { --head: 56px; }
  .topbar { padding: 0 15px; gap: 10px; }
  .brand { font-size: 16px; gap: 8px; }
  .brand svg { width: 26px; height: 26px; }
  .app-shell { display: block; }
  .sidebar {
    z-index: 30; position: fixed; top: var(--head); left: 0; bottom: 0;
    width: min(320px, 87vw); transform: translateX(-105%); visibility: hidden;
  }
  body.drawer-open .sidebar { transform: none; visibility: visible; }
  .lesson-main { padding: 26px clamp(18px, 5vw, 32px) 94px; }
  .tutor-panel { right: 10px; bottom: 72px; width: min(420px, calc(100vw - 20px)); max-height: calc(100dvh - 92px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Permanent workspace chrome and curriculum navigation. */
.skip-link { position: fixed; z-index: 60; top: 5px; left: 12px; padding: 8px 14px; background: white; transform: translateY(-150%); }
.skip-link:focus { transform: none; }
.topbar { justify-content: flex-start; }
.brand picture, .brand img { display: block; }
.brand img { width: 137px; height: auto; }
.header-divider { margin: 0 2px 0 5px; height: 20px; border-left: 1px solid var(--graphite); }
.workspace-name { color: #b2bac1; font-size: 12.5px; font-weight: 500; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 23px; }
#header-progress { color: #bec7cd; font: 11px/1.3 var(--mono); }
.account-button { padding: 7px 13px; color: var(--ivory); border: 1px solid #454d56; border-radius: 4px; background: #1e2329; font-size: 12.5px; font-weight: 550; max-width: 185px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-button:hover { background: #313943; }
.drawer-toggle, .drawer-close { display: none; }
.sidebar { display: flex; flex-direction: column; }
.sidebar-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 22px; margin-bottom: 27px; border-bottom: 1px solid #353c43; }
.sidebar-heading .eyebrow { color: var(--ivory); font: 500 18px/1.25 -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; letter-spacing: -.015em; text-transform: none; margin: 0; }
.shelf-label, .sidebar-foot .eyebrow { color: #a2b0bc; font: 600 10px/1.5 var(--mono); letter-spacing: .15em; }
.shelf-label { margin: 0 7px 9px; }
.sidebar summary { list-style: none; position: relative; padding: 5px 18px 8px 7px; cursor: pointer; color: var(--ivory); font-size: 15.5px; line-height: 1.35; font-weight: 580; }
.sidebar summary::-webkit-details-marker { display: none; }
.sidebar summary::after { content: ''; position: absolute; right: 4px; top: 11px; width: 6px; height: 6px; border: solid #a2b0bc; border-width: 0 1px 1px 0; transform: rotate(-45deg); }
.sidebar details[open] > summary::after { transform: rotate(45deg); }
#lesson-nav { display: grid; gap: 4px; margin: 13px 0 26px; }
.nav-item { display: flex; align-items: center; gap: 10px; position: relative; min-height: 43px; padding: 8px 10px; color: #bec5cd; font-size: 13px; line-height: 1.4; border-radius: 3px; }
.nav-item:hover { color: white; background: #252b31; }
.nav-item.active { color: #f0f0e9; background: #2e3842; }
.nav-item.active::before { content: ''; width: 2px; position: absolute; top: 8px; bottom: 8px; left: 0; background: var(--steel); }
.nav-code { flex: none; color: #a0b1c0; font: 10px/1 var(--mono); }
.nav-name { flex: 1; }
.sidebar-foot { margin-top: auto; padding: 18px 8px 3px; border-top: 1px solid #353c43; }
.sidebar-foot p { margin: 6px 0 9px; color: #d6dadd; font-size: 12.5px; }
progress { accent-color: var(--steel); }
#progress-bar { display: block; appearance: none; width: 100%; height: 4px; border: 0; border-radius: 3px; background: #353e46; color: var(--steel); }
#progress-bar::-webkit-progress-bar { background: #353e46; border-radius: 3px; }
#progress-bar::-webkit-progress-value { background: var(--steel); border-radius: 3px; }
#progress-bar::-moz-progress-bar { background: var(--steel); border-radius: 3px; }
#scrim { position: fixed; z-index: 25; inset: var(--head) 0 0; border: 0; background: #11182070; }

/* Reading hierarchy. Each section shares a left-aligned folio number. */
.breadcrumb { font: 12px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: #59636b; margin-bottom: 34px; }
.breadcrumb a { text-decoration-color: #abafb1; text-underline-offset: 3px; }
.lesson-header > .eyebrow { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.lesson-header > .eyebrow::before { content: ''; width: 26px; height: 2px; background: #748899; }
.objective { max-width: 71ch; color: #4a555c; font-size: clamp(16px, 1.6vw, 19px); line-height: 1.55; margin: 0 0 16px; }
.lesson-meta { color: #58626a; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; font: 11px/1.6 var(--mono); }
.section-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 19px; padding: 6px 0; margin: 20px 0 4px; border-block: 1px solid #bcc1c0; }
.section-nav a { display: inline-flex; align-items: center; min-height: 32px; color: #425663; text-decoration: none; font-size: 12px; font-weight: 580; }
.section-nav a:hover { text-decoration: underline; text-underline-offset: 4px; }
.lesson-section { padding: 34px 0 27px; }
.lesson-section + .lesson-section { border-top: 1px solid var(--rule); }
.section-title { display: flex; align-items: baseline; gap: 12px; margin-bottom: 13px; }
.section-title h2 { margin: 0; }
.section-number { color: #647b8b; font: 500 12px/1 var(--mono); }
.lesson-copy { max-width: 78ch; font-size: 16px; color: #333b41; line-height: 1.77; }
.lesson-copy p:last-child, .lesson-copy ol:last-child, .lesson-copy ul:last-child { margin-bottom: 0; }
.lesson-copy :is(ol,ul) { padding-left: 1.5em; }
.lesson-copy li + li { margin-top: 7px; }
.lesson-copy strong { font-weight: 620; color: #222b31; }
.lesson-copy dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 3px 14px; }
.lesson-copy dd { margin: 0; }
.lesson-copy .display-equation { border-left: 2px solid #93a4ad; background: #eceee9; padding: 12px 17px; margin-block: 16px; overflow-x: auto; }
.lesson-copy > math[display=block] { padding: 14px 5px; background: #eceee9; }
.exercise { border: 1px solid var(--rule); border-radius: 5px; background: var(--paper-hi); padding: clamp(17px, 2.5vw, 27px); margin: 15px 0 0; }
.exercise .eyebrow { margin-bottom: 7px; }
.exercise h3 { margin: 0 0 13px; color: #273036; font-size: 17.5px; letter-spacing: -.018em; font-weight: 590; line-height: 1.5; text-wrap: pretty; overflow-wrap: anywhere; }
.exercise p { font-size: 14px; color: var(--dim); }
.exercise form { margin: 0; }
.exercise fieldset { margin: 0 0 12px; padding: 0; border: none; }
.exercise .choice { cursor: pointer; display: flex; align-items: flex-start; gap: 10px; font-size: 14px; line-height: 1.5; padding: 7px 0; }
.exercise input[type=radio] { flex: none; margin-top: 4px; }
.answer-row { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.answer-row .answer-label { display: grid; gap: 4px; font-size: 13px; color: #42515a; }
.answer-row input:not([type=radio]) { width: min(14em, 100%); }
.text-button { border: 0; background: transparent; color: #465f72; text-underline-offset: 3px; text-decoration: underline; font-size: 13px; padding: 6px 3px; }
.text-button:hover { color: var(--night); }
.feedback { margin: 12px 0 0; font-size: 14px; }
.feedback.correct, .feedback.incorrect { padding: 10px 13px; border-left: 3px solid; }
.feedback.correct { background: #e9f0e9; border-color: #55745f; color: #2a4834; }
.feedback.incorrect { background: #f6ece3; border-color: #9a6b44; color: #6c492d; }
.scorebox, .progress-summary { background: #e9edea; padding: 17px 20px; border-radius: 5px; color: #2e424a; }
.next-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; border-top: 1px solid #9fa8ab; padding-top: 22px; margin-top: 10px; }
.next-row a { font-size: 14px; font-weight: 570; color: #354c5c; text-underline-offset: 4px; }

.tutor-launch { position: fixed; z-index: 19; bottom: 23px; right: 24px; display: flex; gap: 9px; align-items: center; justify-content: center; border: 1px solid #59646c; border-radius: 30px; padding: 11px 18px; color: #f4f2ea; background: #202832; font-size: 13px; font-weight: 580; box-shadow: 0 4px 14px #10182025; }
.tutor-launch:hover { background: #344451; }
.tutor-launch span { font-size: 18px; line-height: 1; color: #b5c8d5; }
dialog.tutor-panel { inset: auto 24px 77px auto; margin: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.panel-head .eyebrow { display: block; margin-bottom: 4px; }
.panel-head h2 { margin: 0; font-size: 31px; }
.close-panel, .drawer-close, .drawer-toggle { background: transparent; border: 1px solid #b6baba; color: #4b5660; border-radius: 4px; padding: 0; width: 34px; height: 34px; line-height: 1; font-size: 22px; }
.panel-head .close-panel { flex: none; }
dialog :is(.muted,#tutor-context) { font-size: 13px; color: var(--dim); }
#tutor-context { padding: 9px 12px; border-left: 2px solid #8fa2b6; background: #e9ece8; }
#tutor-reply:not(:empty) { margin: 14px 0; padding: 13px; min-height: 28px; border: 1px solid var(--rule); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; border-radius: 4px; }
#tutor-form > label { margin: 12px 0 4px; }
#tutor-form button { margin-top: 9px; }
#notice { position: fixed; z-index: 42; bottom: 24px; left: 50%; transform: translateX(-50%); max-width: min(480px, calc(100vw - 30px)); padding: 10px 16px; border-radius: 5px; background: #25313a; color: white; box-shadow: 0 4px 18px #17202724; font-size: 14px; }
@media (max-width: 760px) {
  .drawer-toggle, .drawer-close { display: inline-grid; place-items: center; color: var(--ivory); border-color: #4a535c; background: transparent; }
  .drawer-toggle { width: 35px; height: 35px; font-size: 17px; }
  .brand img { width: 113px; }
  .header-divider, .workspace-name { display: none; }
  .header-actions { gap: 10px; }
  #header-progress { font-size: 10px; }
  .account-button { max-width: 112px; }
  .sidebar { padding-top: 24px; }
  .sidebar-heading { padding-bottom: 16px; margin-bottom: 20px; }
  .breadcrumb { font-size: 11px; margin-bottom: 24px; }
  .objective { font-size: 16px; }
  .section-nav { gap: 0 14px; }
  .lesson-section { padding: 26px 0 22px; }
  .lesson-copy { font-size: 15.5px; }
  .tutor-launch { bottom: 14px; right: 14px; }
  dialog.tutor-panel { inset: auto 10px 66px auto; max-height: calc(100dvh - 82px); padding: 20px; }
  #notice { bottom: 72px; width: max-content; }
}
@media (max-width: 390px) {
  #header-progress { display: none; }
  .section-title { gap: 8px; }
  .answer-row .answer-label { width: 100%; }
  .answer-row input:not([type=radio]) { width: 100%; }
}
.lesson-copy h3 { font-size: 18px; font-weight: 600; margin: 24px 0 7px; letter-spacing: -.012em; }
.lesson-copy h3:first-child { margin-top: 0; }
.display-equation { border-radius: 0 3px 3px 0; }
.display-equation math { font-size: 1.32em; }
.breadcrumb span { color: #899297; padding: 0 4px; }
.exercise-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.answer-row:has(.choice) { display: grid; gap: 5px; }
.answer-row .choice { width: 100%; border: 1px solid var(--rule); padding: 9px 12px; border-radius: 4px; }
.answer-row .choice:has(:checked) { background: #e8edf0; border-color: #8b9ba6; }
.answer-row .choice:hover { border-color: #82949f; }
.scorebox p, .next-row h3, #auth-status:empty { margin: 0; }
.scorebox h3 { font-family: var(--serif); font-weight: 500; font-size: 29px; margin: 3px 0 6px; }
#auth-status { margin: 12px 0 0; font-size: 14px; color: #744630; }
@media (max-width: 760px) {
  body.drawer-open { overflow: hidden; }
}

.browse-links { display: grid; gap: 8px; margin: 16px 7px 28px; }
.browse-links button, .browse-links a { width: fit-content; background: none; border: 0; padding: 3px 0; color: #c8d5df; font: inherit; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.browse-links a { color: #a9b6bf; }
#syllabus { width: min(760px, calc(100% - 24px)); }
#syllabus-tree details { border-top: 1px solid var(--rule); padding: 9px 0; }
#syllabus-tree details details { margin: 8px 0 0 12px; padding: 8px 0 2px; }
#syllabus-tree summary { cursor: pointer; font-weight: 600; font-size: 15px; }
#syllabus-tree p { font-size: 14px; margin: 8px 0; }
#syllabus-tree li { margin: 10px 0; }
#syllabus-tree small { display: block; color: var(--dim); }
#syllabus-tree a, .prereqs a { color: #405c70; text-underline-offset: 3px; }
.prereqs { color: var(--dim); font-size: 13px; margin: 12px 0 0; }
#hint-level-label[hidden] { display: none; }
#written-review textarea { display:block; width:100%; margin:8px 0 16px; padding:12px; resize:vertical; color:var(--ink); background:var(--paper-hi); border:1px solid #a6abb0; border-radius:4px; font:inherit; }
#written-status { margin:12px 0 0; }
#pilot-menu summary { font-size: 13px; padding-left: 0; }
#pilot-links { display: grid; gap: 7px; padding: 7px 0 12px; }
a.workspace-name { text-decoration:none }
a.workspace-name:hover { text-decoration:underline }
