/* PMA Study Room
 * 01 Theme and editable colors  02 Base/buttons  03 Header/footer
 * 04 Library/search  05 Course cards  06 Reader/sidebar  07 Quiz
 * 08 Flashcards/matching  09 Markdown/tables  10 Responsive
 * 11 Preferences  12 Print
 *
 * Edit card fills in the --card-* variables below. In #RRGGBBAA,
 * the final AA pair is opacity: 00 = transparent, ff = opaque.
 * Screen and print are separate so web colors never leak into PDFs.
 */

@media screen {
  /* Theme and editable colors */

  :root {
    color-scheme: dark;
    --paper: #10131d;
    --ink: #eeeaf1;
    --muted: #b8b2c3;
    --line: #ffffff24;
    --accent: #d2b8ed;
    --soft: #bca3d41a;
    --card-background: linear-gradient(130deg,#6382c785,#4c64ac73);
    --card-complete-background: linear-gradient(135deg,#567cca8c,#4763b780);
    --card-practice-background: linear-gradient(135deg,#788bd880,#596ec480);
    --card-quick-background: linear-gradient(135deg,#8c9de084,#6b82cb73);
    --card-reference-background: linear-gradient(135deg,#648bc58c,#5671b580);
    --card-rehearse-background: linear-gradient(125deg,#6578c38c,#5266b384);
    --card-hover-background: linear-gradient(130deg,#83a0e59c,#6c83cd8c);
    --card-practice-hover-background: linear-gradient(135deg,#95a2e994,#7688d994);
    --card-reduced-transparency-background: #516fc970;
    --course-background: #33427724;
    --course-title-background: #44558780;
    --landscape-overlay: linear-gradient(180deg,#090c1bc9,#0c1021c9 45%,#10131eff 100%);
  }
}

/* Shared layout and typography: screen + print */

:root {
  --serif: Georgia,"Times New Roman",serif;
}

/* Base, buttons, and focus */

* {
  box-sizing: border-box;
}

html {
  scroll-padding-top: 90px;
}

body {
  margin: 0;
  font: 16px/1.65 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  outline-offset: 4px;
}

button {
  font: inherit;
  cursor: pointer;
  color: inherit;
  outline-offset: 4px;
}

input,
select {
  font: inherit;
  outline-offset: 4px;
}

[tabindex] {
  outline-offset: 4px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid #cd831c;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -80px;
  padding: 10px;
  z-index: 10;
}

.skip-link:focus {
  top: 10px;
}

.quiet-button {
  border: 0;
  background: transparent;
  padding: 7px 0;
  font-size: 14px;
  color: var(--accent);
}

.button {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 9px 14px;
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
}

[hidden] {
  display: none !important;
}

textarea {
  outline-offset: 4px;
}

/* Header and footer */

.site-header {
  height: 76px;
  border-bottom: 1px solid var(--line);
  align-items: center;
  justify-content: space-between;
  padding: 0 5%;
  position: sticky;
  top: 0;
  z-index: 5;
  gap: 15px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  font-weight: 750;
  text-decoration: none;
  color: var(--ink);
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  text-align: center;
  font: 700 23px/34px var(--serif);
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 14px;
}

.site-header nav a {
  text-decoration: none;
}

.eyebrow {
  font-weight: 750;
  letter-spacing: .13em;
  text-transform: uppercase;
  margin: 0 0 14px;
}

.page-footer {
  border-top: 1px solid var(--line);
  padding: 24px 0;
  margin-top: 45px;
  font-size: 12px;
  color: var(--muted);
}

/* Library hero and search */

.library-main {
  margin: auto;
  padding-right: 5%;
  padding-bottom: 32px;
  padding-left: 5%;
}

.library-intro h1 {
  font: 400 clamp(40px,6vw,66px)/1.08 var(--serif);
  margin-top: 15px;
  margin-right: 0;
  margin-left: 0;
}

.library-summary {
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}

.library-summary span {
  border-left: 2px solid #afd0bf;
  padding-left: 12px;
}

.library-intro>p:not(.eyebrow) {
  font-size: 18px;
}

/* Course panels and cards */

.course-group {
  margin-bottom: 46px;
  padding-top: 0;
  padding-right: 25px;
  padding-left: 25px;
  border: 1px solid #a9c6b580;
  border-radius: 0 20px 20px 20px;
  margin-top: 66px;
  position: relative;
}

.guide-grid {
  display: grid;
}

.guide-card {
  border: 1px solid var(--line);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 24px;
  border-radius: 14px;
}

.card-kind {
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px;
  text-transform: none;
  letter-spacing: 0;
}

.course-group>h2 {
  display: table;
  position: relative;
  margin-right: 0;
  margin-left: -26px;
  border: 1px solid #a9c6b580;
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  font: 600 clamp(17px,2vw,23px)/1.35 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  max-width: calc(100% + 27px);
  margin-bottom: 22px;
}

.guide-card h3 {
  font: 600 23px/1.25 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  margin-right: 0;
  margin-left: 0;
}

.guide-card--complete {
  grid-column: 1;
  justify-content: center;
  grid-row: 1/span 2;
}

.guide-card--complete h3 {
  font: 400 34px/1.2 var(--serif);
}

.course-with-practice .guide-card--practice {
  grid-column: 2;
  justify-content: center;
  grid-row: 1/span 2;
}

.course-with-practice .guide-grid {
  grid-template-columns: 1.2fr 1fr 1fr;
}

.course-with-practice .guide-card--quick,
.course-with-practice .guide-card--reference {
  grid-column: 3;
}

/* Reader and contents sidebar */

.reading-layout {
  grid-template-columns: 290px minmax(0,900px);
  padding-top: 0;
  padding-bottom: 0;
}

.sidebar {
  position: sticky;
  top: 76px;
  height: calc(100vh - 76px);
  overflow: auto;
  padding-top: 30px;
  padding-right: 22px;
  padding-bottom: 50px;
  border-right: 1px solid var(--line);
  font-size: 13px;
}

.back-link {
  display: inline-block;
  margin-bottom: 24px;
  font-size: 12px;
  text-decoration: none;
}

.sidebar label {
  display: block;
  font-weight: 700;
  font-size: 11px;
  margin: 12px 0 6px;
  color: var(--muted);
}

.sidebar select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  font-size: 12px;
  color: var(--ink);
  white-space: normal;
}

.sidebar input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  font-size: 12px;
  color: var(--ink);
}

.sidebar .eyebrow {
  margin: 28px 0 12px;
}

.sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}







.search-status {
  margin: 10px 0;
  font-size: 11px;
  min-height: 0;
}

.search-status:empty {
  display: none;
}

#search-results li {
  margin-bottom: 12px;
}

#search-results a {
  display: block;
  line-height: 1.4;
}

#search-results small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 4px;
}

.reading-main {
  min-width: 0;
  padding-bottom: 0;
}

.guide-heading {
  border-bottom: 1px solid var(--line);
}

.guide-heading h1 {
  font: 400 clamp(32px,4vw,45px)/1.15 var(--serif);
  letter-spacing: -.025em;
  margin: 12px 0 20px;
}

.reading-meta {
  font-size: 12px;
  color: var(--muted);
}

.guide-actions {
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.section-link {
  font-size: 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 4px 8px;
  vertical-align: middle;
  opacity: .45;
}

.section-link:focus-visible {
  opacity: 1;
}

.render-status {
  padding: 12px 16px;
  border: 1px solid #e3bd73;
  border-radius: 6px;
  font-size: 13px;
}

/* Markdown, tables, formulas, and diagrams */

.study-content h2 {
  font: 400 29px/1.3 var(--serif);
  margin-right: 0;
  margin-left: 0;
  border-top: 1px solid var(--line);
  scroll-margin-top: 92px;
}

.study-content h3 {
  line-height: 1.4;
  margin-right: 0;
  margin-left: 0;
  scroll-margin-top: 92px;
}

.study-content h4 {
  font-size: 16px;
}

.study-content p,
.study-content li {
  margin-right: 0;
  margin-left: 0;
}

.study-content blockquote {
  margin: 22px 0;
  padding: 5px 18px;
  border-left: 3px solid var(--accent);
}

.study-content hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin-right: 0;
  margin-left: 0;
}

.study-content pre {
  padding: 20px;
  border-radius: 7px;
  line-height: 1.6;
}

.study-content code {
  font-size: .85em;
  overflow-wrap: anywhere;
}

.table-scroll {
  overflow-x: auto;
  margin-right: 0;
  margin-left: 0;
}

.study-content table {
  width: 100%;
  border-collapse: collapse;
  line-height: 1.5;
}

.study-content th {
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.study-content td {
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.study-content th[align=right],
.study-content td[align=right] {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.study-content th[align=center],
.study-content td[align=center] {
  text-align: center;
}

.study-content tr:last-child td {
  border-bottom: 0;
}

.math-display {
  margin-right: 0;
  margin-left: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0;
}

.katex {
  font-size: 1.08em !important;
}

.math-inline {
  white-space: nowrap;
}

.mermaid {
  background: white !important;
  text-align: center;
}

.mermaid svg {
  max-width: 100%;
  height: auto;
}

.study-content h2:hover .section-link,
.study-content h3:hover .section-link {
  opacity: 1;
}

.study-content button,
.study-content input {
  font: inherit;
}

/* Practice questions */

.quiz-toolbar {
  border: 1px solid #ffffffb3;
  border-radius: 14px;
  padding: 20px;
  margin: 22px 0;
}

.study-content .quiz-toolbar>p {
  margin: 0 0 12px;
  font-size: 14px;
}

.quiz-score {
  font-weight: 750;
  color: var(--accent);
}

.quiz-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.quiz-bulk-status:empty {
  display: none;
}

.quiz-question {
  border: 1px solid #b9cec480;
  border-radius: 16px;
  padding: 22px;
  margin: 22px 0;
  scroll-margin-top: 95px;
}

.quiz-question fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

.quiz-question legend {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 0;
  width: 100%;
  font-weight: 650;
  line-height: 1.6;
}

.quiz-number-badge {
  flex: none;
  border-radius: 8px;
  color: var(--accent);
  padding: 3px 9px;
  min-width: 34px;
  text-align: center;
}

.quiz-prompt p {
  margin: 0;
}

.quiz-hint {
  font-size: 13px;
  color: var(--muted);
}

.quiz-fields {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.quiz-option {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid #b9cec47a;
  border-radius: 9px;
  padding: 12px 14px;
  cursor: pointer;
  line-height: 1.55;
  font-size: 14px;
}

.quiz-option input {
  flex: none;
  margin-top: 5px;
  accent-color: var(--accent);
  width: 17px;
  height: 17px;
}

.quiz-question[data-type=numeric] .quiz-fields {
  grid-template-columns: repeat(2,minmax(0,1fr));
}

.quiz-number label {
  display: block;
  font-size: 13px;
  font-weight: 650;
  margin-bottom: 5px;
}

.quiz-number input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #aec2b8;
  border-radius: 8px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.quiz-number small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 3px;
}

.quiz-number input[aria-invalid=true] {
  border: 2px solid #974533;
}

.quiz-feedback {
  margin-top: 18px;
  padding: 14px 18px;
  border-radius: 9px;
  border: 1px solid #b9cec4;
  font-size: 14px;
}

.study-content .quiz-feedback p {
  margin: 8px 0;
}

.quiz-result {
  font-weight: 750;
}

.quiz-correct-answer {
  font-weight: 650;
}

.quiz-explanation {
  border-top: 1px solid #7a938330;
  padding-top: 8px;
}

.quiz-key-toggle {
  white-space: normal;
}

.quiz-number input:focus-visible {
  outline: 3px solid #cd831c;
}

/* Screen appearance and layouts */

@media screen {
  /* Base, buttons, and focus */

  html {
    scroll-behavior: smooth;
  }

  body {
    color: var(--ink);
    min-height: 100vh;
    background-image: var(--landscape-overlay),url("study-background.svg"),url("study-colors.png");
    background-color: #10131e;
    background-blend-mode: normal,soft-light,normal;
    background-size: cover,cover,cover;
    background-position: center,center,center;
    background-attachment: fixed,fixed,fixed;
    background-repeat: repeat;
  }

  .skip-link {
    background: #232331;
    color: var(--ink);
  }

  .button {
    background: #c4a8dc;
    color: #18131f;
    border-color: #cfb5e2;
  }

  select option,
  select optgroup {
    background: #1a1b29;
    color: var(--ink);
  }

  .button:hover {
    background: #dbc3ee;
  }

  .button-secondary {
    color: #decaed;
    background: #15142436;
    border-color: #ffffff30;
  }

  .button-secondary:hover {
    background: #c4a8dc1c;
  }

  .button:disabled {
    opacity: .45;
    cursor: default;
  }

  .quiet-button:hover {
    color: #eee2f7;
  }

  /* Header and footer */

  .site-header {
    display: flex;
    background: #10121d73;
    border-color: #ffffff15;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }

  .brand-icon {
    background: #b89fcb2b;
    color: #e5d7ef;
    border: 1px solid #d3b8e33b;
    line-height: 32px;
  }

  .site-header nav a {
    color: var(--muted);
  }

  .eyebrow {
    color: #c5b2d6;
    font-size: 10px;
  }

  /* Library hero and search */

  .library-main {
    max-width: 1320px;
    padding-top: 58px;
  }

  .library-intro h1 {
    letter-spacing: -.045em;
    margin-bottom: 25px;
    text-shadow: 0 2px 25px #0a0c1930;
    font-size: clamp(44px,5.5vw,78px);
    line-height: 1.1;
  }

  .library-summary {
    margin-top: 23px;
    gap: 22px;
  }

  .library-summary span {
    border-color: #b7a0cb60;
  }

  .library-intro {
    margin-bottom: 28px;
    max-width: none;
  }

  .library-intro>p:not(.eyebrow) {
    color: #ded7e5;
    max-width: 700px;
  }

  .library-intro>p.provenance {
    font-size: 13px;
    line-height: 1.8;
    color: var(--muted);
    max-width: 660px;
  }

  .library-search {
    max-width: 100%;
    margin: 32px 0 74px;
  }

  .library-search label {
    display: block;
    color: #d4cadf;
    font-size: 13px;
    margin-bottom: 9px;
  }

  .library-search input {
    width: 100%;
    border: 1px solid #ede1ff33;
    border-radius: 13px;
    background: #13172470;
    color: var(--ink);
    padding: 17px 20px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    font-size: 15px;
  }

  .library-search input::placeholder {
    color: #a7a0b4;
  }

  .library-search input:focus {
    border-color: #c7afd280;
  }

  .library-search #library-search-status {
    font-size: 13px;
    color: var(--muted);
  }

  #library-search-status:empty {
    display: none;
  }

  #library-search-results {
    list-style: none;
    margin: 20px 0;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
  }

  #library-search-results li {
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #181b2973;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  #library-search-results a {
    font-size: 18px;
    font-family: var(--serif);
  }

  #library-search-results small {
    display: block;
    color: var(--muted);
    font-size: 11px;
    margin-top: 8px;
  }

  #library-search-results p {
    font-size: 13px;
    margin-bottom: 0;
    overflow-wrap: anywhere;
  }

  .library-intro .library-subhead {
    display: block;
    line-height: 1.6;
  }

  .library-subhead img.sparkle {
    display: inline-block;
    position: relative;
    font-size: inherit;
    line-height: 0;
    color: transparent;
    width: 1.05em;
    height: 1.05em;
    vertical-align: -.14em;
    top: auto;
    margin-left: .1em;
    background: none;
    object-fit: contain;
  }

  .hero-ending {
    white-space: nowrap;
  }

  /* Course panels and cards */

  .course-group {
    box-shadow: 0 16px 40px #03061330;
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
    padding-bottom: 20px;
    background: var(--course-background);
    border-color: #abbce954;
  }

  .guide-grid {
    grid-template-columns: 1.2fr 1fr 1fr;
    gap: 15px;
  }

  .guide-card {
    justify-content: center;
    min-height: 132px;
    transition: transform .22s ease,background .22s ease,border-color .22s ease,box-shadow .22s ease;
    transform-origin: center;
    will-change: transform;
    background: var(--card-background);
    border-color: #b7c9fa66;
    box-shadow: inset 0 1px 0 #e5ecff38,0 10px 26px #050b2224;
    color: #f4f3ff;
    backdrop-filter: blur(9px);
    -webkit-backdrop-filter: blur(9px);
  }

  .card-kind {
    background: #e6d8f314;
    color: #ddd0e9;
  }

  .course-group>h2 {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    font-size: clamp(25px,2.4vw,34px);
    font-weight: 650;
    line-height: 1.3;
    padding: 14px 25px;
    margin-top: -43px;
    background: var(--course-title-background);
    border-color: #bbc9f35e;
    color: #f2f1ff;
  }

  .guide-card h3 {
    margin-top: 15px;
    margin-bottom: 0;
  }

  .guide-card--complete {
    background: var(--card-complete-background);
  }

  .guide-card--complete h3 {
    font-size: 31px;
  }

  .course-with-practice .guide-card--practice {
    background: var(--card-practice-background) !important;
  }

  .guide-card--rehearse {
    grid-column: 1/-1;
    position: relative;
    min-height: 120px;
    justify-content: center;
    background: var(--card-rehearse-background);
    border-color: #b8c9ef66;
    border-left: 3px solid #e2aed280;
  }

  .guide-card--rehearse h3 {
    font: 400 26px/1.25 var(--serif);
    margin: 13px 0 0;
  }

  .guide-card:hover {
    transform: scale(1.018);
    z-index: 1;
    background: var(--card-hover-background);
    border-color: #c9d7ffb3;
    box-shadow: inset 0 1px 0 #f2f4ff4d,0 14px 30px #080d3138;
  }

  .course-with-practice .guide-grid {
    gap: 15px;
  }

  .course-with-practice .guide-card--complete {
    grid-row: 1/span 2;
  }

  .guide-card--quick {
    background: var(--card-quick-background);
  }

  .guide-card--reference {
    background: var(--card-reference-background);
  }

  .course-with-practice .guide-card--practice:hover {
    background: var(--card-practice-hover-background) !important;
  }

  .guide-card .card-kind {
    background: #cbd7ff26;
    color: #e6edff;
    border: 1px solid #dce4ff12;
  }

  .guide-card--rehearse .card-kind {
    background: #edb7d423;
    color: #dce4ff;
    border-color: #dce4ff26;
  }

  /* Reader and contents sidebar */

  .reading-layout {
    display: grid;
    max-width: 1400px;
    padding-right: 4%;
    padding-left: 4%;
    margin: auto;
    gap: 36px;
  }

  .sidebar {
    background: #14152235;
    padding-left: 12px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  .sidebar select,
  .sidebar input {
    background: #1517249c;
    border-color: var(--line);
  }

  .reading-main {
    background: #1117255c;
    padding-top: 38px;
    padding-right: 30px;
    padding-left: 30px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  .guide-heading {
    padding-bottom: 28px;
    margin-bottom: 28px;
  }

  .guide-actions {
    display: flex;
  }

  .render-status {
    background: #584724ad;
    border-color: #c2a770;
    color: #ffe6b3;
  }

  .contents-toggle {
    display: block;
  }

  .reading-layout:not(.contents-open) {
    grid-template-columns: minmax(0,900px);
    justify-content: center;
    max-width: 1100px;
  }

  /* Markdown, tables, formulas, and diagrams */

  .study-content {
    font-size: 16px;
    line-height: 1.8;
  }

  .study-content h2 {
    margin-top: 54px;
    margin-bottom: 18px;
    padding-top: 9px;
  }

  .study-content h3 {
    font-size: 18px;
    margin-top: 32px;
    margin-bottom: 12px;
  }

  .study-content p {
    margin-top: 14px;
    margin-bottom: 14px;
  }

  .study-content li {
    margin-top: 6px;
    margin-bottom: 6px;
  }

  .study-content blockquote {
    background: #b9a1d012;
  }

  .study-content hr {
    margin-top: 35px;
    margin-bottom: 35px;
  }

  .study-content pre {
    overflow: auto;
    font-size: 13px;
    background: #111824ad;
  }

  .table-scroll {
    margin-top: 24px;
    margin-bottom: 24px;
    border: 1px solid var(--line);
    border-radius: 7px;
  }

  .study-content table {
    font-size: 13px;
    background: #18202a80;
  }

  .study-content th {
    padding: 12px 13px;
    min-width: 60px;
    border-bottom: 1px solid var(--line);
    background: #b9a1d01c;
  }

  .study-content td {
    padding: 12px 13px;
    min-width: 60px;
    border-bottom: 1px solid var(--line);
  }

  .math-display {
    margin-top: 22px;
    margin-bottom: 22px;
  }

  .study-content em {
    color: #c1b6c9;
  }

  .study-content .mermaid {
    background: #f5f3f7 !important;
    border-radius: 8px;
    color: #172e2b;
  }

  /* Practice questions */

  .quiz-toolbar,
  .quiz-question {
    background: #171c2959;
    border-color: var(--line);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
  }

  .quiz-number-badge {
    background: #d1b2e51f;
  }

  .quiz-option {
    background: #15192640;
    border-color: #ffffff24;
  }

  .quiz-number input {
    background: #1217248c;
    border-color: #ffffff33;
  }

  .quiz-number input[aria-invalid=true] {
    border-color: #d8888f;
  }

  .quiz-feedback {
    background: #bba2da17;
    border-color: #ccb1e14a;
  }

  .quiz-explanation {
    border-color: #ffffff20;
  }

  .quiz-option:hover {
    background: #bba2da13;
  }

  .quiz-option:has(input:checked) {
    background: #bba2da1c;
    border-color: #d3b8e3a0;
  }

  .quiz-question[data-state=wrong] .quiz-feedback {
    background: #9b445328;
    border-color: #d8888f66;
  }

  .quiz-question[data-state=correct] .quiz-feedback {
    background: #367e7329;
    border-color: #89c9b566;
  }

  .save-note {
    font-size: 12px !important;
    color: #b9b2c5;
    line-height: 1.6;
  }

  /* Flashcards and matching */

  .activity-main {
    max-width: 980px;
    margin: auto;
    padding: 44px 5% 20px;
  }

  .activity-main h1 {
    font: 400 clamp(38px,6vw,60px)/1.1 var(--serif);
    letter-spacing: -.03em;
    margin: 14px 0;
  }

  .activity-main .back-link {
    margin-bottom: 30px;
  }

  .activity-lede {
    color: #d1c5db;
  }

  .activity-toolbar {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    border: 1px solid var(--line);
    background: #171a264d;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 15px;
    border-radius: 14px;
    margin: 30px 0 22px;
  }

  .activity-tabs {
    display: flex;
    border: 1px solid #ffffff24;
    border-radius: 9px;
    padding: 3px;
  }

  .activity-tabs button {
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: var(--muted);
    padding: 9px 12px;
    font-size: 13px;
  }

  .activity-tabs button[aria-pressed=true] {
    background: #c4a8dc2b;
    color: #f0e1fa;
  }

  .activity-toolbar label {
    font-size: 12px;
  }

  .activity-toolbar select {
    background: #13172480;
    color: var(--ink);
    border: 1px solid var(--line);
    padding: 8px;
    border-radius: 7px;
    max-width: 220px;
    font-size: 12px;
  }

  .activity-toolbar #deck-reset {
    margin-left: auto;
    font-size: 11px;
  }

  .activity-summary {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    color: var(--muted);
    font-size: 12px;
    margin: 24px 3px 12px;
  }

  .flash-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    text-align: center;
    width: 100%;
    min-height: 340px;
    padding: 38px;
    border: 1px solid #e4d5f136;
    border-radius: 22px;
    background: linear-gradient(130deg,#bca1cd13,#18202c4a);
    backdrop-filter: blur(9px);
    -webkit-backdrop-filter: blur(9px);
    box-shadow: 0 20px 65px #0409162b;
    color: var(--ink);
    transition: background .2s;
  }

  .flash-card[data-flipped=true] {
    background: linear-gradient(130deg,#cbb7de24,#192a3459);
  }

  #card-category {
    margin: 0;
    font-size: 10px;
  }

  #card-face {
    display: block;
    font: 400 clamp(23px,3vw,32px)/1.45 var(--serif);
    overflow-wrap: anywhere;
    width: 100%;
  }

  #card-face p {
    font: 400 16px/1.6 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
    margin: 20px 0 0;
    color: #c6bacf;
  }

  #card-face .math {
    white-space: normal;
  }

  #card-face .katex {
    font-size: 1em !important;
  }

  #card-face code {
    font-size: .8em;
  }

  #flip-hint {
    font-size: 11px;
    color: var(--muted);
  }

  .flash-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 23px 0;
  }

  .card-source {
    text-align: center;
    font-size: 12px;
    color: var(--muted);
  }

  #match-panel>h2 {
    font: 400 29px/1.3 var(--serif);
  }

  #match-panel>p {
    color: var(--muted);
    font-size: 14px;
  }

  .match-row {
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #151b2959;
    backdrop-filter: blur(9px);
    -webkit-backdrop-filter: blur(9px);
    margin: 15px 0;
  }

  .match-row label {
    display: block;
    font-size: 15px;
    line-height: 1.7;
    margin-bottom: 12px;
  }

  .match-row select {
    width: 100%;
    padding: 12px;
    color: var(--ink);
    background: #1217258c;
    border: 1px solid #ffffff30;
    border-radius: 8px;
    font-size: 13px;
  }

  .match-feedback {
    font-size: 13px;
    margin-bottom: 0;
  }

  .match-row[data-state=correct] {
    border-color: #80bbaa66;
  }

  .match-row[data-state=correct] .match-feedback {
    color: #afe0cf;
  }

  .match-row[data-state=wrong] {
    border-color: #d8888f66;
  }

  .match-row[data-state=wrong] .match-feedback {
    color: #efb6bf;
  }

  #match-score {
    text-align: center;
  }

  .match-row label .card-caveat {
    font-size: 12px;
    color: var(--muted);
    margin: 8px 0 0;
  }
}

/* 10. Responsive layouts */

@media screen and (max-width:1000px) {
  /* Reader and contents sidebar */

  .reading-layout {
    grid-template-columns: 240px minmax(0,1fr);
  }

  .guide-heading h1 {
    font-size: 36px;
  }

  .sidebar {
    padding-right: 16px;
  }

  /* Markdown, tables, formulas, and diagrams */

  .study-content {
    font-size: 15px;
  }
}

@media screen and (max-width:950px) {
  /* Course panels and cards */

  .guide-grid,
  .course-with-practice .guide-grid {
    grid-template-columns: 1fr 1fr;
  }

  .guide-card--complete,
  .course-with-practice .guide-card--complete,
  .course-with-practice .guide-card--practice,
  .course-with-practice .guide-card--quick,
  .course-with-practice .guide-card--reference {
    grid-column: auto;
    grid-row: auto;
  }

  .guide-card--rehearse {
    grid-column: 1/-1;
  }

  .guide-card--complete h3 {
    font-size: 26px;
  }

  /* Reader and contents sidebar */

  .reading-main {
    padding: 30px 20px 0;
  }
}

@media screen and (max-width:760px) {
  /* Header and footer */

  .site-header {
    height: 65px;
    padding: 0 5%;
  }

  .site-header nav {
    gap: 14px;
  }

  .brand {
    font-size: 15px;
    gap: 8px;
  }

  .brand-icon {
    width: 29px;
    height: 29px;
    font-size: 20px;
  }

  .site-header nav a {
    display: none;
  }

  /* Library hero and search */

  .library-main {
    padding-top: 40px;
  }

  #library-search-results {
    grid-template-columns: 1fr;
  }

  .library-search input {
    font-size: 14px;
  }

  .library-intro h1 {
    font-size: clamp(40px,8.5vw,56px);
    line-height: 1.12;
  }

  /* Course panels and cards */

  .course-with-practice .guide-card--rehearse {
    grid-column: 1/-1;
  }

  .course-group>h2 {
    font-size: 25px;
    padding: 13px 18px;
    margin-top: -42px;
  }

  .course-group {
    margin-top: 74px;
  }

  /* Reader and contents sidebar */

  .reading-layout {
    display: block;
    padding: 0 6%;
  }

  .sidebar {
    display: none;
    position: fixed;
    z-index: 6;
    top: 65px;
    left: 0;
    width: min(340px,90vw);
    height: calc(100dvh - 65px);
    padding-top: 22px;
    padding-right: 22px;
    padding-bottom: 22px;
    box-shadow: 10px 0 30px #152e2a26;
  }

  .sidebar.open {
    display: block;
    background: #121625ed;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }

  .guide-heading h1 {
    font-size: 34px;
  }

  .section-link {
    opacity: 1;
  }

  .reading-main {
    margin: 0 -3%;
    padding: 28px 3% 0;
  }

  .reading-layout:not(.contents-open),
  .reading-layout.contents-open {
    display: block;
  }

  /* Markdown, tables, formulas, and diagrams */

  .study-content h2 {
    font-size: 25px;
  }

  .study-content ul,
  .study-content ol {
    padding-left: 24px;
  }

  .study-content th,
  .study-content td {
    padding: 9px 10px;
    font-size: 12px;
  }

  /* Flashcards and matching */

  .activity-main {
    padding: 30px 5% 20px;
  }

  .activity-toolbar {
    gap: 10px;
  }

  .activity-toolbar #deck-reset {
    margin-left: 0;
  }

  .activity-toolbar select {
    max-width: 100%;
    flex: 1;
  }

  .activity-toolbar label {
    margin-left: 0;
  }

  .activity-tabs {
    width: 100%;
    justify-content: center;
  }

  .flash-card {
    padding: 28px 20px;
    min-height: 320px;
  }

  #card-face {
    font-size: 25px;
  }

  .flash-controls {
    gap: 8px;
  }
}

@media screen and (max-width:600px) {
  /* Library hero and search */

  .library-summary {
    font-size: 11px;
    gap: 14px;
  }

  .library-intro>p:not(.eyebrow) {
    font-size: 16px;
  }

  .library-intro>p.provenance {
    font-size: 12px;
  }

  .library-search {
    margin-bottom: 67px;
  }

  /* Course panels and cards */

  .course-group {
    padding-top: 0;
    padding-right: 14px;
    padding-left: 14px;
    margin-top: 78px;
  }

  .course-group>h2 {
    margin-left: -15px;
    max-width: calc(100% + 15px);
    font-size: clamp(22px,6vw,26px);
    padding: 12px 14px;
    margin-top: -42px;
  }

  .guide-card {
    padding: 18px;
    min-height: 116px;
  }

  .guide-grid,
  .course-with-practice .guide-grid {
    grid-template-columns: 1fr;
  }

  .guide-card--rehearse,
  .course-with-practice .guide-card--rehearse {
    grid-column: auto;
  }

  .guide-card:hover {
    transform: scale(1.012);
  }

  .guide-card--complete h3 {
    font-size: 26px;
  }

  /* Practice questions */

  .quiz-question {
    padding: 16px;
  }

  .quiz-question[data-type=numeric] .quiz-fields {
    grid-template-columns: 1fr;
  }

  .quiz-actions {
    flex-direction: column;
  }

  .quiz-actions button {
    justify-content: center;
  }

  .quiz-question legend {
    font-size: 15px;
    gap: 8px;
  }

  /* Flashcards and matching */

  .flash-controls .button {
    padding: 10px 12px;
  }

  .activity-toolbar #deck-reset {
    width: 100%;
    justify-content: center;
  }
}

@media screen and (min-width:900px) {
  /* Library hero and search */

  .library-intro h1 {
    white-space: nowrap;
  }
}

/* 11. Motion and transparency preferences */

@media screen and (prefers-reduced-motion:reduce) {
  /* Base, buttons, and focus */

  html {
    scroll-behavior: auto;
  }

  /* Course panels and cards */

  .guide-card {
    transition: none;
    will-change: auto;
  }

  .guide-card:hover {
    transform: none;
  }
}

@media screen and (prefers-reduced-transparency:reduce) {
  /* Base, buttons, and focus */

  body {
    background: #11131e;
  }

  /* Library hero and search */

  .library-search input,
  #library-search-results li {
    background: #1b1e2c;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  /* Course panels and cards */

  .course-group {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: #26355060;
  }

  .course-group>h2 {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: #3d528c60;
  }

  .guide-card,
  .guide-card--complete,
  .guide-card--quick,
  .guide-card--reference,
  .guide-card--rehearse,
  .course-with-practice .guide-card--practice {
    background: var(--card-reduced-transparency-background) !important;
  }

  /* Reader and contents sidebar */

  .sidebar.open {
    background: #f9fbf8;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .reading-main,
  .sidebar {
    background: #1b1e2c;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  /* Practice questions */

  .quiz-number input {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .quiz-question,
  .quiz-toolbar {
    background: #1b1e2c;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  /* Flashcards and matching */

  .flash-card,
  .match-row {
    background: #1b1e2c;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

/* 12. Print / PDF — light paper, worksheet, and answer key */

@media print {
  /* Theme and editable colors */

  :root {
    --paper: #faf9f5;
    --ink: #172e2b;
    --muted: #596b67;
    --line: #dce4de;
    --accent: #135c52;
    --soft: #e9f2ec;
    color-scheme: light;
  }

  /* Base, buttons, and focus */

  html {
    scroll-behavior: auto;
  }

  body {
    color: #182b26;
    font-size: 10pt;
    line-height: 1.5;
    background: white !important;
    background-attachment: initial;
  }

  .skip-link {
    background: white;
    display: none !important;
  }

  .button {
    background: var(--accent);
    color: white;
  }

  .button-secondary {
    background: transparent;
    color: var(--accent);
  }

  /* Header and footer */

  .site-header {
    display: none !important;
    background: #f8fbf3cc;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .brand-icon {
    background: var(--accent);
    color: white;
  }

  .eyebrow {
    color: var(--accent);
    font-size: 8pt;
  }

  .page-footer {
    display: none !important;
  }

  /* Library hero and search */

  .library-main {
    padding-top: 68px;
    max-width: 1280px;
  }

  .library-intro {
    max-width: 820px;
    margin-bottom: 42px;
  }

  .library-intro h1 {
    letter-spacing: -.035em;
    margin-bottom: 22px;
    font-size: clamp(38px,5vw,60px);
  }

  .library-intro>p:not(.eyebrow) {
    max-width: 600px;
    color: var(--muted);
  }

  .library-summary {
    gap: 24px;
    margin-top: 30px;
  }

  /* Course panels and cards */

  .course-group {
    padding-bottom: 25px;
    background: #ffffff45;
    box-shadow: 0 12px 40px #193c2b08;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  .guide-grid {
    grid-template-columns: 1.2fr 1fr;
    gap: 16px;
  }

  .guide-card {
    color: var(--ink);
    transition: transform .15s,box-shadow .15s;
    background: #ffffff7a;
    border-color: #ffffffb3;
    box-shadow: inset 0 1px 0 #ffffffe6;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    min-height: 140px;
  }

  .guide-card:hover {
    transform: translateY(-3px);
    border-color: #9bbbac;
    background: #ffffffa6;
    box-shadow: 0 10px 24px #193c2b0d;
  }

  .card-kind {
    color: var(--accent);
    background: #ffffff66;
  }

  .course-group>h2 {
    margin-top: -35px;
    padding: 12px 24px;
    background: #e0eee6b3;
  }

  .guide-card h3 {
    margin-top: 14px;
    margin-bottom: 10px;
  }

  .guide-card--complete {
    background: #c7e6d966;
  }

  .course-with-practice .guide-card--practice {
    background: #dddff966;
  }

  /* Reader and contents sidebar */

  .contents-toggle {
    display: none;
  }

  .reading-layout {
    gap: 54px;
    display: block;
    margin: 0;
    padding-right: 0;
    padding-left: 0;
    max-width: none;
  }

  .sidebar {
    padding-left: 0;
    display: none !important;
    background: #f5f9f140;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .sidebar select,
  .sidebar input {
    background: white;
  }

  .reading-main {
    padding-top: 0;
    padding-right: 0;
    padding-left: 0;
  }

  .guide-heading {
    padding-bottom: 16pt;
    margin-bottom: 16pt;
  }

  .guide-heading h1 {
    font-size: 27pt;
  }

  .reading-meta,
  .guide-actions,
  .section-link {
    display: none !important;
  }

  .render-status {
    background: #fff0d5;
    display: none !important;
  }

  /* Markdown, tables, formulas, and diagrams */

  .study-content h2 {
    font-size: 19pt;
    margin-top: 23pt;
    margin-bottom: 10pt;
    break-after: avoid;
    padding-top: 8pt;
    scroll-margin: 0;
  }

  .study-content h3 {
    font-size: 12pt;
    margin-top: 16pt;
    margin-bottom: 7pt;
    break-after: avoid;
  }

  .study-content blockquote {
    background: var(--soft);
    break-inside: avoid;
  }

  .study-content hr {
    margin-top: 18pt;
    margin-bottom: 18pt;
  }

  .study-content em {
    color: var(--muted);
  }

  .study-content pre {
    background: #edf1eb;
    white-space: pre-wrap;
    overflow: visible;
    font-size: 8pt;
    break-inside: avoid;
  }

  .table-scroll {
    overflow: visible;
    border: 0;
    margin-top: 12pt;
    margin-bottom: 12pt;
    border-radius: 0;
  }

  .study-content table {
    background: white;
    font-size: 8pt;
    table-layout: auto;
  }

  .study-content th {
    background: var(--soft);
    padding: 6pt;
    border: 1px solid #cdd9d2;
    min-width: 0;
  }

  .study-content td {
    padding: 6pt;
    border: 1px solid #cdd9d2;
    min-width: 0;
  }

  .math-display {
    overflow: visible;
    break-inside: avoid;
    margin-top: 10pt;
    margin-bottom: 10pt;
  }

  .mermaid {
    break-inside: avoid;
  }

  .study-content {
    font-size: 10pt;
    line-height: 1.5;
  }

  .study-content p {
    margin-top: 7pt;
    margin-bottom: 7pt;
    orphans: 3;
    widows: 3;
  }

  .study-content li {
    margin-top: 3pt;
    margin-bottom: 3pt;
  }

  .study-content thead {
    display: table-header-group;
  }

  .study-content tr {
    break-inside: avoid;
  }

  .study-content a {
    color: #14594f;
  }

  .math-display .katex-display {
    white-space: normal;
  }

  /* Practice questions */

  .quiz-toolbar {
    background: #ffffff7a;
  }

  .quiz-question {
    background: #ffffff70;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .quiz-number-badge {
    background: #135c5215;
  }

  .quiz-option {
    background: #ffffff40;
  }

  .quiz-option:hover {
    background: #ffffff90;
  }

  .quiz-option:has(input:checked) {
    border-color: var(--accent);
    background: #c7e6d970;
  }

  .quiz-number input {
    background: #ffffffb3;
  }

  .quiz-feedback {
    background: #e0eee680;
  }

  .quiz-question[data-state=wrong] .quiz-feedback {
    background: #f3dfd580;
    border-color: #ba795f80;
  }

  .quiz-question[data-state=correct] .quiz-feedback {
    background: #c7e6d980;
    border-color: #669c7b80;
  }

  .quiz-interface {
    display: none !important;
  }

  .quiz-worksheet[hidden],
  .quiz-answer-key[hidden] {
    display: block !important;
  }

  .save-note {
    display: none !important;
  }

  /* Flashcards and matching */

  .activity-toolbar,
  .flash-controls,
  .card-source,
  .activity-tabs {
    display: none !important;
  }

  .flash-card {
    color: #182b26;
    background: white;
    border: 1px solid #ccd4d1;
    min-height: 0;
    padding: 20pt;
    font-size: 18pt;
  }
}

@media print and (max-width:1000px) {
  /* Reader and contents sidebar */

  .reading-layout {
    grid-template-columns: 240px minmax(0,1fr);
    gap: 30px;
  }

  .sidebar {
    padding-right: 16px;
  }
}

@media print and (max-width:760px) {
  /* Header and footer */

  .site-header {
    height: 65px;
    padding: 0 5%;
  }

  .site-header nav {
    gap: 14px;
  }

  .brand {
    font-size: 15px;
    gap: 8px;
  }

  .brand-icon {
    width: 29px;
    height: 29px;
    line-height: 29px;
    font-size: 20px;
  }

  .site-header nav a {
    display: none;
  }

  /* Library hero and search */

  .library-main {
    padding-top: 40px;
  }

  .library-intro>p:not(.eyebrow) {
    font-size: 16px;
  }

  .library-summary {
    gap: 12px;
  }

  /* Reader and contents sidebar */

  .contents-toggle {
    display: block;
  }

  .sidebar {
    position: fixed;
    z-index: 6;
    top: 65px;
    left: 0;
    width: min(340px,90vw);
    height: calc(100dvh - 65px);
    padding: 22px;
    box-shadow: 10px 0 30px #152e2a26;
  }

  .sidebar.open {
    display: block;
  }

  .section-link {
    opacity: 1;
  }

  /* Markdown, tables, formulas, and diagrams */

  .study-content ul,
  .study-content ol {
    padding-left: 24px;
  }

  .study-content th,
  .study-content td {
    font-size: 12px;
  }
}

@media print and (max-width:950px) {
  /* Course panels and cards */

  .course-with-practice .guide-grid {
    grid-template-columns: 1fr 1fr;
  }

  .course-with-practice .guide-card--complete,
  .course-with-practice .guide-card--practice {
    grid-row: auto;
    grid-column: auto;
  }

  .course-with-practice .guide-card--quick,
  .course-with-practice .guide-card--reference {
    grid-column: auto;
  }
}

@media print and (max-width:600px) {
  /* Course panels and cards */

  .course-group {
    padding: 0 14px 14px;
    margin-top: 60px;
  }

  .course-group>h2 {
    margin-left: -15px;
    padding: 10px 14px;
    margin-top: -32px;
    max-width: calc(100% + 15px);
  }

  .guide-grid,
  .course-with-practice .guide-grid {
    grid-template-columns: 1fr;
  }

  .guide-card--complete {
    grid-column: auto;
    grid-row: auto;
  }

  .guide-card {
    min-height: 130px;
    padding: 18px;
  }

  .guide-card--complete h3 {
    font-size: 28px;
  }

  /* Reader and contents sidebar */

  .sidebar.open {
    background: #f4f8f1ed;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }

  /* Practice questions */

  .quiz-question {
    padding: 16px;
  }

  .quiz-question[data-type=numeric] .quiz-fields {
    grid-template-columns: 1fr;
  }

  .quiz-actions {
    flex-direction: column;
  }

  .quiz-actions button {
    justify-content: center;
  }

  .quiz-question legend {
    font-size: 15px;
    gap: 8px;
  }
}

@media print and (prefers-reduced-motion:reduce) {
  /* Course panels and cards */

  .guide-card {
    transition: none;
    will-change: auto;
  }

  .guide-card:hover {
    transform: none;
  }
}
