:root {
  color-scheme: light;
  --bg: #f2f5f2;
  --paper: #fff;
  --ink: #172723;
  --muted: #52645d;
  --line: #d8e3dc;
  --green: #195849;
  --soft: #e7f2eb;
  --hero: #164838;
  font: 100% system-ui, -apple-system, sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121c19;
  --paper: #1c2925;
  --ink: #eaf2ed;
  --muted: #adc0b6;
  --line: #385047;
  --green: #98dcc0;
  --soft: #263e34;
  --hero: #164838;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--bg); }
h1, h2, p { margin: 0; }
a { color: var(--green); }
button, select, summary { font: inherit; color: inherit; }
button, select, summary, .modes a { cursor: pointer; }
button { background: var(--paper); }
button:focus-visible, a:focus-visible, summary:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid #448f77; outline-offset: 3px; }
.top { background: var(--paper); border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1180px; padding: 12px 24px; margin: auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-weight: 720; min-height: 44px; }
.brand-icon { display: grid; place-items: center; height: 32px; width: 32px; border-radius: 8px; background: var(--hero); color: white; }
.course, .metadata { color: var(--muted); font-size: .875rem; }
.shell { max-width: 1120px; padding: 32px 24px 80px; margin: auto; }
.hero { display: flex; justify-content: space-between; align-items: end; flex-wrap: wrap; gap: 24px; padding: clamp(22px, 5vw, 42px); border-radius: 18px; background: var(--hero); color: white; margin-bottom: 32px; }
.hero h1 { font-size: clamp(2rem, 5.5vw, 3.35rem); letter-spacing: -.045em; line-height: 1.05; margin: 8px 0 12px; }
.hero p, .hero .progress { color: #e1eee7; }
.eyebrow { font-weight: 700; font-size: .86rem; letter-spacing: .055em; color: var(--green); }
.progress { display: grid; gap: 8px; min-width: 185px; font-size: .875rem; }
progress { width: 100%; height: 8px; accent-color: #a7e2bd; }
h2 { font-size: 1.15rem; margin-bottom: 14px; }
.library { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.book-card { display: flex; gap: 13px; align-items: center; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); text-decoration: none; padding: 17px; color: var(--ink); min-height: 92px; }
.book-card:hover { border-color: var(--green); }
.book-id { min-width: 57px; border-radius: 8px; padding: 10px 5px; text-align: center; background: var(--soft); color: var(--green); font-size: .85rem; font-weight: 750; }
.book-copy { display: grid; gap: 4px; }
.book-copy span { font-size: .875rem; color: var(--muted); }
.breadcrumbs { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; font-size: .9rem; color: var(--muted); margin-bottom: 18px; }
.reading-grid { display: grid; grid-template-columns: minmax(0, 240px) minmax(0, 1fr); align-items: start; gap: 20px; }
.main-column { min-width: 0; }
.sidebar { background: var(--paper); border: 1px solid var(--line); padding: 14px; border-radius: 12px; display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; overflow: clip; gap: 8px; }
.sidebar select { width: 100%; min-width: 0; }
.sidebar label { font-size: .9rem; font-weight: 700; }
select { border: 1px solid var(--line); background: var(--paper); border-radius: 7px; min-height: 44px; padding: 6px; max-width: 100%; }
.sidebar summary { padding: 12px 0; font-weight: 700; }
#topics { display: grid; gap: 3px; }
#topics a { padding: 9px 8px; min-height: 44px; display: flex; align-items: center; border-radius: 7px; line-height: 1.35; text-decoration: none; font-size: .9rem; }
#topics a[aria-current], #topics a:hover { background: var(--soft); }
.modes { display: grid; grid-template-columns: repeat(4, 1fr); border-radius: 10px; background: var(--paper); border: 1px solid var(--line); padding: 3px; gap: 2px; margin-bottom: 10px; }
.modes a { font-size: .92rem; font-weight: 650; color: var(--muted); padding: 12px 3px; text-align: center; text-decoration: none; border-radius: 7px; min-height: 44px; }
.modes a[aria-current], .modes a:hover { background: var(--soft); color: var(--green); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.colors { display: flex; align-items: center; }
.colors button { height: 44px; min-width: 44px; border: 1px solid var(--line); border-right-width: 0; padding: 0 7px; font-size: .875rem; }
.colors button:first-child { border-radius: 8px 0 0 8px; }
.colors button:last-child { border-radius: 0 8px 8px 0; border-right-width: 1px; }
.swatch::before { content: ""; display: block; width: 15px; height: 15px; margin: auto; border-radius: 50%; border: 1px solid #0003; }
mark.yellow, .swatch.yellow::before { background: #ffe383; }
mark.green, .swatch.green::before { background: #a6e2b4; }
mark.pink, .swatch.pink::before { background: #ffc4d3; }
mark { color: #172723; }
.view { position: relative; }
.view summary, .pdf, .secondary, .primary { padding: 10px 12px; min-height: 44px; display: inline-flex; gap: 5px; align-items: center; border-radius: 8px; background: var(--paper); border: 1px solid var(--line); color: var(--green); text-decoration: none; font-size: .9rem; font-weight: 650; }
.view summary::after { content: "⌄"; }
.view-panel { display: grid; gap: 8px; padding: 10px 12px; position: absolute; right: 0; width: 220px; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; z-index: 2; box-shadow: 0 8px 24px #0002; font-size: .875rem; }
.view-panel > div, .view-panel > label { display: flex; justify-content: space-between; gap: 8px; align-items: center; min-height: 44px; }
.view-panel input { width: 1.2rem; height: 1.2rem; }
.notice { font-size: .875rem; color: var(--muted); min-height: .75rem; padding-top: 4px; }
.notice:not(:empty) { padding-bottom: 8px; }
.reading { background: var(--paper); border: 1px solid var(--line); border-radius: 15px; padding: clamp(18px, 4vw, 40px); font-size: calc(1rem * var(--text-scale, 1)); line-height: 1.65; overflow-wrap: anywhere; }
.reading h1 { font-size: clamp(1.45em, 3.3vw, 2em); line-height: 1.15; letter-spacing: -.028em; margin: 8px 0 12px; }
.prose { max-width: 69ch; margin-top: 24px; }
[data-width="full"] .prose { max-width: none; }
.prose p + p { margin-top: 1em; }
.reader-footer { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.primary { background: var(--hero); color: white; }
.flashcard { margin: 18px 0; padding: 12px 16px; background: var(--soft); border-radius: 10px; }
.flashcard summary { min-height: 44px; display: flex; align-items: center; font-weight: 700; color: var(--green); }
.question, .originals { border-top: 1px solid var(--line); padding-top: 18px; margin-top: 20px; }
.question h2 { font-size: 1em; }
.answers { display: grid; gap: 8px; }
.answers button { text-align: left; border-radius: 8px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); }
.answers button:not(:disabled):hover { background: var(--soft); }
.answers .correct { border-color: #248249; background: #daf0e1; color: #173621; }
.answers .incorrect { border-color: #b14e58; background: #fbe4e6; color: #4b1e25; }
.feedback { margin: 10px 0; }
.originals a { margin: 0 6px 6px 0; }
@media (max-width: 879px) {
  .reading-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .sidebar { padding: 10px 12px; }
}
@media (max-width: 550px) {
  .shell, .top-inner { padding-left: 12px; padding-right: 12px; }
  .shell { padding-top: 16px; }
  .library { grid-template-columns: 1fr; }
  .toolbar { position: relative; row-gap: 5px; }
  .view { position: static; }
  .view-panel { right: 0; width: min(232px, 100%); }
}
