:root {
  color-scheme: light;
  --ink: #172c32;
  --muted: #536970;
  --line: #cbd8d9;
  --teal: #125f62;
  --dark: #143f44;
  --wash: #edf4f3;
  font: 16px/1.55 Inter, system-ui, sans-serif;
  color: var(--ink);
  background: #f5f8f7;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, summary { font: inherit; cursor: pointer; color: inherit; }
button { border: 0; background: none; }
button:focus-visible, summary:focus-visible, a:focus-visible, [tabindex="0"]:focus-visible { outline: 3px solid #b2671b; outline-offset: 3px; }
button:disabled { opacity: .42; cursor: default; }
[hidden] { display: none !important; }
.skip { position: fixed; top: -5rem; z-index: 10; background: white; padding: .6rem 1rem; }
.skip:focus { top: .5rem; left: 1rem; }
.mast { background: var(--dark); color: white; }
.mast-inner { max-width: 1340px; margin: auto; padding: 0 clamp(1rem,4vw,3.5rem); height: 68px; display: flex; align-items: center; gap: .8rem; }
.brand-mark { width: 37px; height: 37px; border: 1px solid #86b8b2; border-radius: 9px; display: grid; place-items: center; font: italic 32px/1 Georgia,serif; padding: 0 3px 4px 0; color: #c9eece; }
.brand { font-size: 1.23rem; font-weight: 700; letter-spacing: .035em; }
.course { padding-left: 1rem; margin-left: .3rem; border-left: 1px solid #789294; color: #d7ebe8; font-size: .91rem; }
.course b { color: #fff; font-weight: 600; }
.directory-open { display:none; }
.mast-actions { margin-left:auto; display:flex; align-items:center; gap:.5rem; }
#book-open, #account-open, .mast .directory-open { border:1px solid #90aaa9; background:transparent; color:white; border-radius:5px; padding:.42rem .8rem; font-size:.9rem; font-weight:600; }
#account-open { max-width:13.5rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.library-switch { display:flex; gap:3px; padding:3px; border:1px solid var(--line); border-radius:6px; background:var(--wash); margin-bottom:1.1rem; }
.library-switch button { flex:1; padding:.35rem .2rem; border-radius:4px; font-size:.89rem; color:var(--muted); }
.library-switch button[aria-pressed="true"] { background:white; color:var(--dark); font-weight:650; box-shadow:0 1px 3px rgb(13 42 45 / 12%); }
.workspace { max-width: 1340px; margin: auto; padding: 32px clamp(1rem,4vw,3.5rem) 40px; display: grid; grid-template-columns: clamp(232px,23%,282px) minmax(0,1fr); gap: clamp(1.3rem,3.2vw,3.2rem); align-items:start; }
.directory-column { position: sticky; top: 16px; max-height: calc(100dvh - 32px); overflow: auto; scrollbar-width: thin; }
.directory { padding: 4px 4px 12px; }
.directory h2 { font-size: 1.24rem; margin: 0 0 1rem; }
.active-topic { display:flex; justify-content:space-between; align-items:center; background: var(--dark); color:white; border-radius: 6px; padding: .63rem .9rem; font-weight: 650; }
.active-topic:has(select:not([hidden])) { gap:.5rem; padding:.3rem .75rem .3rem .4rem; }
#topic-select { flex:1; min-width:0; cursor:pointer; font:inherit; color:inherit; background:var(--dark); border:0; border-radius:3px; padding:.4rem .2rem; }
#topic-select:focus-visible { outline:2px solid #d8efea; }
.count { font-size: .8rem; font-weight: 500; color: #d8efea; }
.section-list { display: grid; margin: .42rem 0 .3rem; }
.section-item { display: flex; justify-content: space-between; gap: .35rem; align-items: center; text-align: left; color: var(--muted); border-left: 3px solid transparent; padding: .49rem .7rem; font-size: .92rem; }
.section-item .tally { font: .78rem/1.4 Inter,system-ui,sans-serif; color: var(--muted); }
.section-item[aria-pressed="true"] { border-color: var(--teal); background: #dcece8; color: var(--dark); font-weight: 650; }
.section-item:hover, .picker button:hover { background: #e0ece9; }
.related { display:flex; align-items:center; gap:.38rem; color:var(--muted); font-size:.84rem; padding:.42rem .66rem; cursor:pointer; }
.related input { accent-color:var(--teal); margin:0; width:1rem; height:1rem; }
.other-topics { margin: .45rem 0 1.1rem; font-size: .87rem; color: var(--muted); }
.other-topics summary { padding: .6rem .35rem; }
.other-topics ol { margin: .2rem 0 .5rem; padding-left: 2.1rem; }
.other-topics li { margin-bottom: .3rem; }
.picker-head { border-top:1px solid var(--line); padding-top: 1rem; display: flex; align-items: baseline; justify-content: space-between; }
.picker-head h3 { margin:0; font-size: 1rem; }
.picker-head span,.panel-note { color: var(--muted); font-size: .86rem; }
.picker { display:grid; grid-template-columns:repeat(6,minmax(0,1fr)); gap:5px; margin-top:.65rem; }
.picker-topic { grid-column:1/-1; margin:.45rem 0 .15rem; color:var(--muted); font-size:.85rem; }
.picker button { min-height: 32px; background: #fff; border:1px solid var(--line); border-radius: 4px; font-size:.875rem; font-variant-numeric: tabular-nums; padding: .15rem; }
.picker button[aria-current="true"] { background: var(--teal); color:white; border-color:var(--teal); font-weight:650; }
main { min-width:0; }
#sheet { background: white; border:1px solid var(--line); border-top:4px solid var(--teal); padding:clamp(1.2rem,3.2vw,3.25rem); border-radius: 3px 3px 8px 8px; }
.empty-state { padding:clamp(1.2rem,3.2vw,3.25rem); border:1px solid var(--line); border-top:4px solid var(--teal); background:white; border-radius:3px 3px 8px 8px; }
.empty-state p { color:var(--muted); }
.question-head { padding-bottom: 1.05rem; border-bottom: 1px solid var(--line); }
.crumb { color:var(--teal); font-size:.88rem; font-weight:620; }
.headline { display:flex; align-items:center; gap: .8rem; margin:.34rem 0 .25rem; }
h1 { font-size: clamp(1.55rem,2.7vw,2.25rem); letter-spacing:-.025em; margin:0; line-height:1.35; }
h1:focus, main:focus { outline:none; }
#question-marks { color:var(--muted); font-size:.87rem; white-space:nowrap; }
.review-row { margin:0 0 1rem; }
#review-save, #return-practice, #logout, .retry { border:1px solid var(--line); border-radius:5px; padding:.4rem .78rem; background:white; color:var(--teal); font-weight:600; font-size:.9rem; }
#review-save[aria-pressed="true"] { background:var(--wash); border-color:#85aaa5; }
#account-status { color:var(--ink); background:var(--wash); border-left:3px solid var(--teal); padding:.55rem .8rem; margin:0 0 .8rem; }
#question-status .retry, #account-status .retry { margin-left:.3rem; }
#startup-state { margin:3rem auto; max-width:34rem; padding:0 1rem; color:var(--muted); }
#student-entry { max-width:30rem; margin:clamp(2rem,9vh,6rem) auto; padding:0 1rem; }
.entry-card { padding:clamp(1.4rem,5vw,2.3rem); background:white; border:1px solid var(--line); border-top:4px solid var(--teal); border-radius:5px; }
.entry-card h1, .entry-card h2 { font-size:1.65rem; letter-spacing:-.025em; line-height:1.35; margin:0 0 1.2rem; }
.entry-methods { display:flex; padding:3px; gap:3px; margin-bottom:1.1rem; background:var(--wash); border:1px solid var(--line); border-radius:5px; }
.entry-methods button { flex:1; min-height:44px; border-radius:3px; font-size:.92rem; font-weight:600; color:var(--muted); }
.entry-methods button[aria-pressed="true"] { color:var(--dark); background:white; box-shadow:0 1px 3px rgb(13 42 45 / 13%); }
.entry-card label { display:block; font-size:.9rem; font-weight:650; margin:.85rem 0 .28rem; }
.entry-card input { width:100%; min-height:44px; border:1px solid #9dadaf; padding:.5rem .7rem; font:inherit; color:var(--ink); border-radius:4px; }
.entry-card input:focus-visible { outline:2px solid var(--teal); outline-offset:1px; }
.student-number-field { position:relative; }
.student-number-field span { position:absolute; inset-inline-start:.7rem; top:50%; transform:translateY(-50%); color:var(--muted); pointer-events:none; }
.student-number-field input { padding-inline-start:1.65rem; }
.field-hint { margin:.3rem 0 0; font-size:.85rem; color:var(--muted); }
.primary-action { display:block; width:100%; min-height:44px; margin-top:1.2rem; padding:.55rem .9rem; border-radius:4px; color:white; font-weight:650; background:var(--teal); }
.id-line { display:flex; align-items:center; gap:.5rem; margin-bottom:1rem; }
.id-line input { min-width:0; font-family:ui-monospace,monospace; }
.id-line button { border:1px solid var(--line); border-radius:4px; padding:.45rem .65rem; color:var(--teal); font-weight:600; }
.math-content { font: 1.1rem/1.7 "STIX Two Text", Georgia, "Times New Roman", serif; color:#1b272b; min-width:0; overflow-wrap:break-word; }
#problem { margin:1.4rem 0 1.8rem; }
.prose { white-space:pre-line; margin: 0 0 .55rem; }
.prose:last-child { margin-bottom:0; }
.math-content .katex { font-size:1.05em; }
.display-math { display:block; overflow-x:auto; max-width:100%; padding:.15rem 0; }
.katex-display { margin:.32em 0; }
.part-list { list-style:none; padding:0; margin:.55rem 0 0; }
.part-list > li { display:grid; grid-template-columns:auto minmax(0,1fr); gap:.62rem; align-items:baseline; margin: .52rem 0; }
.part-list > li.no-label { display:block; }
.part-label { font-weight:650; white-space:nowrap; }
.part-body { min-width:0; }
.prose, .part-body { overflow-x:auto; }
.marks { margin-left:.48rem; white-space:nowrap; color:var(--muted); font: .81rem/1.3 Inter,system-ui,sans-serif; }
.figure-button { display:block; max-width:100%; padding:.45rem; margin:.65rem 0; border:1px solid var(--line); border-radius:5px; background:white; text-align:left; }
.figure-button img { display:block; object-fit:contain; width:auto; max-width:100%; max-height:290px; }
.zoom-label { display:block; font: .77rem/1.6 Inter,system-ui,sans-serif; color:var(--teal); text-align:right; margin:.2rem .2rem 0; }
.table-wrap { max-width:100%; overflow-x:auto; margin:.7rem 0; }
.table-wrap table { border-collapse:collapse; margin:0; font-size:.98em; }
th, td { border:1px solid #b6c6c7; padding:.45rem .63rem; text-align:left; vertical-align:top; }
th { background:var(--wash); }
td .figure-button { margin:0; }
td:has(.figure-button) { min-width:112px; }
td .figure-button img { min-width:70px; }
.answers { border-top:1px solid var(--line); }
.answers details { border-bottom:1px solid var(--line); }
.answers summary { display:flex; align-items:center; justify-content:space-between; padding:.88rem 0; font-weight:650; list-style:none; }
.answers summary::-webkit-details-marker { display:none; }
.answers summary::after { content:"+"; color:var(--teal); font:1.45rem/1 system-ui,sans-serif; margin-right:.2rem; }
.answers details[open] summary::after { content:"−"; }
.answers .panel { padding:.15rem 0 1rem; }
.panel-note { margin: 0 0 .6rem; font-family: Inter,system-ui,sans-serif; }
.answers .worked-answer { border:0; }
.answers .worked-answer summary { justify-content:flex-start; gap:.65rem; color:var(--teal); font:.9rem/1.5 Inter,system-ui,sans-serif; }
.pager { display:flex; justify-content:space-between; align-items:center; gap:.5rem; margin-top:1rem; }
.pager button,.directory-open,.close-dialog { border:1px solid var(--line); padding:.54rem .98rem; border-radius:5px; font-size:.92rem; font-weight:600; background:white; }
#next { background:var(--teal); color:white; border-color:var(--teal); }
#position { font-variant-numeric:tabular-nums; color:var(--muted); font-size:.88rem; }
dialog { padding:0; border:1px solid var(--line); color:var(--ink); border-radius:9px; max-width:calc(100vw - 1.4rem); max-height:90dvh; }
dialog::backdrop { background:rgb(12 32 37 / 56%); }
.dialog-head { position:sticky; top:0; background:white; z-index:1; display:flex; justify-content:space-between; align-items:center; padding:.7rem 1rem; border-bottom:1px solid var(--line); }
.close-dialog { padding:.32rem .77rem; }
#account-dialog { width:min(370px,95vw); }
.account-panel { padding:1rem 1.2rem 1.2rem; }
.account-panel label { display:block; margin:.72rem 0 .23rem; font-size:.9rem; font-weight:600; }
.account-panel label:first-child { margin-top:0; }
#invite-fields { margin-top:.72rem; }
.account-panel input { display:block; width:100%; border:1px solid #9dadaf; border-radius:4px; font:inherit; padding:.42rem .6rem; color:var(--ink); }
.account-panel input:focus-visible { outline:2px solid var(--teal); outline-offset:1px; }
.form-actions { display:flex; gap:.6rem; align-items:center; flex-wrap:wrap; margin-top:1rem; }
#account-submit { border-radius:5px; background:var(--teal); color:white; font-weight:650; padding:.48rem 1rem; }
#account-switch { color:var(--teal); font-size:.9rem; text-decoration:underline; text-underline-offset:.18em; }
.form-error { color:#942f26; font-size:.91rem; }
#account-name { overflow-wrap:anywhere; }
#drawer { width:min(390px, 95vw); }
#drawer .directory { padding:1rem; }
#drawer .directory h2 { display:none; }
.lightbox-scroll { overflow:auto; max-height:calc(90dvh - 4rem); padding:1rem; }
#large-figure { display:block; width:max(550px,66vw); max-width:1060px; object-fit:contain; }
@media(max-width:760px) {
  .mast-inner { height:56px; padding:0 .85rem; gap:.5rem; }
  .brand { font-size:1.04rem; }
  .brand-mark { width:28px; height:29px; border-radius:6px; font-size:24px; }
  .course { margin:0; padding-left:.6rem; font-size:.85rem; }
  .course span { display:none; }
  .directory-open { display:block; }
  #book-open, #account-open, .mast .directory-open { font-size:.81rem; padding:.4rem .52rem; }
  #account-open { max-width:6.7rem; }
  .mast-actions { gap:.35rem; }
  .workspace { display:block; padding:.8rem .7rem calc(5.5rem + env(safe-area-inset-bottom)); }
  .directory-column { display:none; }
  #sheet { padding:1.12rem .95rem; }
  .crumb { font-size:.81rem; }
  .math-content { font-size:1.045rem; }
  .pager { position:fixed; z-index:2; left:0; bottom:0; width:100%; background:white; margin:0; padding:.55rem .85rem calc(.55rem + env(safe-area-inset-bottom)); border-top:1px solid var(--line); }
  .pager button { min-height:42px; }
  .picker button { min-height:40px; }
  #large-figure { width:max(500px,96vw); }
}
@media(max-width:450px) {
  .course { display:none; }
}
@media(max-width:350px) {
  .brand { font-size:.95rem; }
  #account-open { max-width:5rem; }
  .mast-inner { padding:0 .55rem; gap:.4rem; }
}
#collection-label::after { content:" · "; }
.review-row:has(button[hidden]) { display:none; }

@media(max-width:760px) {
  .class-study .mast-inner { height:auto; min-height:56px; display:grid; grid-template-columns:auto 1fr auto; padding:.5rem .85rem; gap:.4rem .5rem; }
  .class-study .course { display:none; }
  .class-study .mast-actions { display:contents; }
  .class-study #account-open { grid-column:3; grid-row:1; max-width:28vw; }
  .class-study .directory-open { grid-column:1/3; grid-row:2; justify-self:start; }
  .class-study #book-open { grid-column:2/4; grid-row:2; justify-self:end; }
  .class-study .directory-open, .class-study #book-open { min-height:40px; }
}
