/* Lume reader — local, dependency-free editorial interface. */
:root {
  --paper: #f2f1eb;
  --surface: #fffefb;
  --ink: #233a32;
  --muted: #62736b;
  --teal: #24614b;
  --teal-dark: #1b513e;
  --teal-wash: #eaf0e8;
  --rule: #dde3d9;
  --warm-wash: #f8efd9;
  --warm-ink: #79551c;
  --forest: #143b2c;
  --header-ink: #f8f7ee;
  --field: #f7f8f3;
  --radius: 1rem;
  --text-size: 18px;
  --text-spacing: 1.85;
  --shadow: 0 16px 48px #183d2810;
  --yellow: #f4dea1;
  --green: #cee6c6;
  --blue: #cde3f4;
  --pink: #f2d3dd;
  --example-ink: #245368;
  --example-wash: #eef5f6;
  --example-rule: #bdd1d9;
}

body[data-theme='sepia'] {
  --paper: #ede3cf;
  --surface: #fbf1df;
  --ink: #443b2d;
  --muted: #75664f;
  --rule: #daceb9;
  --teal-wash: #e8e5d3;
  --field: #f3e9d7;
  --example-ink: #604c24;
  --example-wash: #f3ead5;
  --example-rule: #d1bc8f;
}
body[data-theme='night'] {
  color-scheme: dark;
  --paper: #141d19;
  --surface: #1d2923;
  --ink: #e8ece3;
  --muted: #acbcb0;
  --teal: #a1cfb2;
  --teal-dark: #b2dcc1;
  --teal-wash: #2a3c30;
  --rule: #3b4b40;
  --warm-wash: #3b3424;
  --warm-ink: #efce8d;
  --field: #253229;
  --forest: #101b15;
  --shadow: 0 16px 48px #0002;
  --example-ink: #bfdfeb;
  --example-wash: #253a42;
  --example-rule: #587785;
}
body[data-font='sans'] {
  --reading-font: var(--interface-font);
}
body[data-size='16'] {
  --text-size: 16px;
}
body[data-size='18'] {
  --text-size: 18px;
}
body[data-size='20'] {
  --text-size: 20px;
}
body[data-size='22'] {
  --text-size: 22px;
}
body[data-size='24'] {
  --text-size: 24px;
}
body[data-spacing='relaxed'] {
  --text-spacing: 2.2;
}
html {
  scroll-behavior: smooth;
  scroll-padding-top: 7rem;
}
body.reader-page,
body.notebook-page {
  font-family: var(--interface-font);
  font-size: 1rem;
  line-height: 1.6;
}
body {
  -webkit-font-smoothing: antialiased;
}
[hidden] {
  display: none !important;
}
button,
input,
textarea,
select {
  font: inherit;
}
button,
.button {
  min-height: 2.75rem;
  border-radius: 0.7rem;
  font-size: 0.875rem;
  font-weight: 600;
  transition:
    background-color 0.16s,
    border-color 0.16s,
    box-shadow 0.16s;
}
button:hover:not(:disabled),
.button:hover {
  border-color: var(--teal);
  background: var(--teal-wash);
}
button:disabled {
  color: var(--muted);
  border-color: var(--rule);
  background: var(--field);
  opacity: 0.65;
}
button.primary,
.button.primary {
  background: var(--forest);
  border-color: var(--forest);
  color: #fff;
}
button.primary:hover:not(:disabled),
.button.primary:hover {
  background: #245940;
  border-color: #245940;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.1rem;
  text-decoration: none;
}
button.secondary {
  border-color: var(--rule);
}
a {
  text-underline-offset: 0.22em;
}
:where(a, button, input, textarea, select, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 3px;
}
::selection {
  color: #213c2e;
  background: #dae5b7;
}
.icon {
  display: inline-block;
  flex: 0 0 auto;
  width: 1.2rem;
  height: 1.2rem;
  vertical-align: -0.22em;
  stroke-width: 1.7;
}
.sr-only,
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.5rem;
  left: 1rem;
  transform: translateY(-180%);
  padding: 0.7rem 1rem;
  border: 2px solid var(--teal);
  border-radius: 0.5rem;
  background: var(--surface);
}
.skip-link:focus {
  transform: translateY(0);
}

/* A calm, compact application frame. */
.reader-header {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  min-height: 4.75rem;
  padding: 0.7rem clamp(1rem, 3vw, 3rem);
  border-bottom: 1px solid #ffffff15;
  color: var(--header-ink);
  background: var(--forest);
}
.reader-header .brand {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 0.7rem;
  color: var(--header-ink);
  line-height: 1.1;
  text-decoration: none;
}
.brand-navigation {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 1rem;
}
.portfolio-home {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 2.75rem;
  padding: 0.3rem 0.2rem;
  color: inherit;
  font-family: var(--interface-font);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  text-underline-offset: 0.2rem;
}
.portfolio-home:hover {
  text-decoration: underline;
}
.brand-icon {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid #e5e9b440;
  border-radius: 0.8rem;
  color: #e5dfb5;
  background: #ffffff08;
}
.brand-icon .icon {
  width: 1.4rem;
  height: 1.4rem;
}
.brand-text {
  display: block;
  font-family: Georgia, serif;
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.06em;
}
.brand-subtitle {
  display: block;
  margin-top: 0.3rem;
  color: #b8cec1;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.21em;
  text-transform: uppercase;
}
.header-center {
  margin-left: clamp(0.5rem, 3vw, 3rem);
  color: #cad8ce;
  font-size: 0.78rem;
}
.header-center strong {
  display: block;
  color: #f5f7ec;
  font-size: 0.875rem;
  font-weight: 500;
}
.reader-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}
.reader-actions .icon-button,
.reader-actions .notebook-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-width: 2.75rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid transparent;
  border-radius: 0.65rem;
  color: #e6eee6;
  background: transparent;
  font-size: 0.8rem;
  text-decoration: none;
  white-space: nowrap;
}
.reader-actions .icon-button:hover,
.reader-actions .notebook-link:hover {
  border-color: #fff3;
  background: #ffffff0c;
}
.reader-actions .notebook-link {
  background: #ffffff0e;
}
.reader-header :focus-visible {
  outline-color: #e3cb80;
}
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.3rem;
  height: 1.3rem;
  padding: 0 0.3rem;
  border-radius: 0.4rem;
  color: #143b2c;
  background: #e8d6a6;
  font-size: 0.75rem;
  font-weight: 700;
}
.book-layout {
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr);
  gap: clamp(1.5rem, 3.5vw, 3.5rem);
  max-width: 82rem;
  margin: 0 auto;
  padding: 2rem clamp(1rem, 3vw, 2.5rem) 6rem;
}
body[data-width='wide'] .book-layout {
  max-width: 96rem;
}
.contents {
  position: sticky;
  top: 6.75rem;
  max-height: calc(100dvh - 8.5rem);
  padding: 1rem 0 1.5rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 0.78rem;
  line-height: 1.5;
  scrollbar-color: var(--rule) transparent;
}
.contents h2,
.contents h3,
.contents > strong {
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.16em;
}
.contents nav,
.contents nav > ol,
.contents nav > ul {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.25rem;
}
.contents nav a {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.65rem 0.75rem;
  border: 0;
  border-radius: 0.6rem;
  color: var(--muted);
}
.contents nav a::before {
  content: '';
  flex: 0 0 auto;
  width: 0.3rem;
  height: 0.3rem;
  border-radius: 50%;
  background: var(--rule);
  align-self: center;
}
.contents nav a:hover,
.contents nav a[aria-current='true'],
.contents nav a[aria-current='location'],
.contents nav a.active {
  color: var(--teal-dark);
  background: var(--teal-wash);
}
.contents nav a[aria-current='true']::before,
.contents nav a[aria-current='location']::before {
  background: var(--teal);
}
.contents p,
.contents small {
  font-size: 0.75rem;
  line-height: 1.65;
}
.contents p:last-child {
  padding: 1rem 0.75rem;
  border-top: 1px solid var(--rule);
}
.reading-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.75rem;
}
.reading-topline a {
  text-decoration: none;
}
.reading-topline > span,
.reading-progress {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
progress {
  display: block;
  width: 100%;
  height: 0.3rem;
  overflow: hidden;
  border: 0;
  border-radius: 1rem;
  color: var(--teal);
  background: var(--rule);
  accent-color: var(--teal);
}
progress::-webkit-progress-bar {
  background: var(--rule);
}
progress::-webkit-progress-value {
  border-radius: 1rem;
  background: var(--teal);
}
progress::-moz-progress-bar {
  border-radius: 1rem;
  background: var(--teal);
}
.reading-topline progress {
  width: 6rem;
}
#progress-label {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
#resume-reading {
  margin-bottom: 1rem;
  font-size: 0.78rem;
}
.reader-tip {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin: 1.1rem 0 1.5rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 0.75rem;
  color: var(--muted);
  background: transparent;
  font-size: 0.75rem;
  line-height: 1.6;
}
.reader-tip p {
  margin: 0;
}
.reader-tip .icon {
  margin-top: 0.1rem;
  color: var(--teal);
}

/* Editorial content keeps a quiet measure, even with larger type. */
.reader-page
  #conteudo
  :is(p, li, td, h1, h2, h3, legend)
  :is(span, strong, em)[lang='pt-BR'],
.reader-page #conteudo code {
  padding: 0.03em 0.17em;
  border-radius: 0.2em;
  color: var(--example-ink);
  background: var(--example-wash);
  box-shadow: inset 0 -1px var(--example-rule);
  font-style: italic;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.reader-page #conteudo code {
  font-family: inherit;
  font-weight: 650;
  font-style: normal;
  white-space: normal;
  overflow-wrap: break-word;
}
.reader-page
  #conteudo
  :is(span, strong, em)[lang='pt-BR']
  :is(span, strong, em)[lang='pt-BR'] {
  padding: 0;
  background: transparent;
  box-shadow: none;
}
.learning-phrase,
.learning-gloss,
.learning-term-compact,
.reader-page:not([data-typography-ready])
  #conteudo
  :is(span, strong, em)[lang='pt-BR'] {
  display: inline-block;
  max-inline-size: 100%;
  vertical-align: baseline;
  white-space: normal;
  word-break: normal;
  hyphens: none;
  /* Only a token wider than the entire column may need an emergency break. */
  overflow-wrap: break-word;
  text-indent: 0;
}
.unit-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(11rem, 0.8fr);
  gap: 1.5rem;
  align-items: center;
  padding: clamp(1.5rem, 3vw, 3rem);
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 1.4rem;
  background: var(--teal-wash);
}
.hero-kicker,
.unit-hero .eyebrow {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 1.4rem;
  color: var(--teal-dark);
  font-family: var(--interface-font);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.hero-kicker::before {
  content: '';
  display: block;
  width: 1.6rem;
  height: 1px;
  background: currentColor;
}
.unit-hero h1 {
  max-width: 13ch;
  margin: 0 0 1.2rem;
  color: var(--ink);
  font-family: var(--reading-font);
  font-size: clamp(2.5rem, 4.4vw, 4.3rem);
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: -0.06em;
}
.unit-hero h1 em {
  color: var(--teal-dark);
}
.unit-hero .lead {
  max-width: 36ch;
  margin-bottom: 1.3rem;
  color: var(--muted);
  font-family: var(--interface-font);
  font-size: 0.9rem;
  line-height: 1.8;
}
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin: 1rem 0;
  color: var(--muted);
  font-size: 0.75rem;
}
.hero-meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.hero-meta .icon {
  width: 0.9rem;
  height: 0.9rem;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1.5rem;
}
.unit-hero .hero-art {
  width: 100%;
  max-width: 19rem;
  margin: 0;
  justify-self: end;
}
.hero-art img {
  width: 100%;
  height: 23rem;
  max-height: 34vw;
  object-fit: cover;
  object-position: 50% 72%;
  border: 0;
  border-radius: 8rem 8rem 1.2rem 1.2rem;
  background: #eaece2;
  box-shadow: none;
}
.hero-art figcaption {
  margin-top: 0.6rem;
  font-size: 0.75rem;
  line-height: 1.5;
  text-align: center;
}
.lesson-section {
  margin-top: 1.5rem;
  padding: clamp(1.4rem, 3.5vw, 3rem);
  border: 1px solid var(--rule);
  border-radius: 1.2rem;
  background: var(--surface);
  font-family: var(--reading-font);
  font-size: var(--text-size);
  line-height: var(--text-spacing);
}
.lesson-section[id],
.unit-hero[id],
.lesson-footer[id],
main#conteudo > section[id],
.reading-block {
  scroll-margin-top: 6.5rem;
}
.section-heading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.section-heading h2 {
  flex: 1;
  margin: 0;
  color: var(--ink);
  font-family: var(--reading-font);
  font-size: clamp(1.5rem, 2.4vw, 2rem);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.025em;
}
.section-number {
  flex: 0 0 auto;
  color: var(--muted);
  font-family: var(--interface-font);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}
.section-heading .activity-icon,
.section-heading > img.activity-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 2.3rem;
  height: 2.3rem;
  margin: 0;
  padding: 0.45rem;
  border-radius: 0.7rem;
  color: var(--teal-dark);
  background: var(--teal-wash);
}
.activity-icon img {
  width: 1.4rem;
  height: 1.4rem;
}
.lesson-section > p,
.lesson-section > ul,
.lesson-section > ol,
.reading-block {
  max-width: 72ch;
}
.lesson-section p {
  margin-bottom: 1.1em;
}
.lesson-section > h3 {
  margin-top: 1.8em;
  font-size: 1.2em;
}
.lesson-section li::marker {
  color: var(--teal);
}
.lesson-section blockquote {
  border-color: var(--teal);
  color: var(--ink);
  background: var(--teal-wash);
  font-size: inherit;
  line-height: inherit;
}
.lesson-section table {
  display: table;
  width: 100%;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: var(--surface);
  font-size: 0.875rem;
}
.table-scroll {
  margin: 1.5rem 0;
  overflow: auto;
  border: 1px solid var(--rule);
  border-radius: 0.8rem;
}
.lesson-section th,
.lesson-section td {
  min-width: 9rem;
  padding: 0.9rem 1rem;
  border-color: var(--rule);
}
.lesson-section th {
  color: var(--teal-dark);
  background: var(--teal-wash);
  font-size: 0.76rem;
}
.lesson-section tbody tr:nth-child(even) {
  background: var(--field);
}
figcaption {
  color: var(--muted);
  font-size: 0.75rem;
}
.scene img {
  border-color: var(--rule);
  border-radius: 0.9rem;
}
.objectives,
.callout,
.callout.note,
.dialogue,
.review-checklist {
  border-color: var(--rule);
  color: var(--ink);
  background: var(--field);
}
.callout.warning {
  border-color: var(--rule);
  border-left-color: #be9440;
  color: var(--warm-ink);
  background: var(--warm-wash);
}
.dialogue {
  padding: 0.5rem 1.5rem;
}
.dialogue > .reading-block + .reading-block,
.dialogue > p + p {
  border-top: 1px solid var(--rule);
}
.dialogue > .reading-block {
  margin: 0;
  padding-top: 1rem;
}
.dialogue p > strong {
  color: var(--ink);
  font-size: 1rem;
}
.dialogue p > small {
  color: var(--muted);
  font-size: 0.9rem;
}
fieldset.exercise {
  margin: 1.5rem 0;
  border-color: var(--rule);
  border-radius: 0.9rem;
  background: var(--surface);
}
.exercise legend {
  font-size: 0.9rem;
}
.options label {
  border-color: var(--rule);
  border-radius: 0.6rem;
  color: var(--ink);
  background: var(--field);
  font-size: 0.9rem;
}
.options label:has(input:checked) {
  border-color: var(--teal);
  color: var(--ink);
  background: var(--teal-wash);
  box-shadow: 0 0 0 1px var(--teal);
}
.exercise .explanation,
output#quiz-summary {
  color: var(--ink);
  border-color: var(--rule);
  background: var(--teal-wash);
}
.exercise[data-result='review'] .explanation {
  border-left-color: #b78b35;
  background: var(--warm-wash);
}
input[type='text'],
input[type='search'],
textarea,
select {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: 0.6rem;
  color: var(--ink);
  background: var(--field);
  font-family: var(--interface-font);
  font-size: 0.875rem;
  line-height: 1.6;
}
input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.85;
}
textarea {
  min-height: 7rem;
}
.writing-area label,
.plan-grid label {
  color: var(--ink);
  font-size: 0.875rem;
}
.writing-area small,
.plan-grid small {
  color: var(--muted);
  font-size: 0.75rem;
}
details.answer-key {
  border-color: var(--rule);
  background: var(--surface);
}
.answer-key summary {
  color: var(--teal-dark);
  font-size: 0.875rem;
}
.lesson-footer {
  margin: 2rem 0 0;
  padding: 1.5rem 0.5rem 0;
  font-size: 0.76rem;
}
.lesson-footer p {
  max-width: 75ch;
}

/* Annotations remain anchored to the exact selected text. */
.reading-block {
  position: relative;
  margin: 0 0 1.1em;
  padding-right: 3rem;
  border-radius: 0.35rem;
}
.reading-block > .block-text {
  margin-bottom: 0;
}
.block-action {
  position: absolute;
  top: 0.05rem;
  right: -0.3rem;
  display: grid;
  place-items: center;
  width: 2.75rem;
  min-width: 2.75rem;
  height: 2.75rem;
  min-height: 2.75rem;
  padding: 0.3rem;
  border: 1px solid transparent;
  border-radius: 0.4rem;
  color: var(--muted);
  background: transparent;
  opacity: 0.45;
}
.block-action .icon {
  width: 1rem;
  height: 1rem;
}
.reading-block:hover > .block-action,
.reading-block:focus-within > .block-action,
.block-action[aria-pressed='true'] {
  opacity: 1;
}
.block-action[aria-pressed='true'] {
  color: var(--teal-dark);
  background: var(--teal-wash);
}
.reading-block.is-target {
  outline: 2px solid var(--teal);
  outline-offset: 0.4rem;
}
mark.reader-highlight {
  color: #273128;
  background: var(--yellow);
  border-radius: 0.15em;
  padding: 0.04em 0;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
mark.reader-highlight[data-color='green'] {
  background: var(--green);
}
mark.reader-highlight[data-color='blue'] {
  background: var(--blue);
}
mark.reader-highlight[data-color='pink'] {
  background: var(--pink);
}
mark.reader-highlight.has-note {
  text-decoration: underline dotted;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.19em;
  cursor: pointer;
}
.annotation-pin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.45rem;
  min-width: 1.45rem;
  height: 1.45rem;
  min-height: 1.45rem;
  margin: 0 0.15rem;
  padding: 0.18rem;
  border: 1px solid var(--rule);
  border-radius: 0.35rem;
  color: var(--teal-dark);
  background: var(--teal-wash);
  vertical-align: baseline;
}
.annotation-pin .icon {
  width: 0.85rem;
  height: 0.85rem;
}
.selection-toolbar {
  position: fixed;
  z-index: 45;
  bottom: 1.5rem;
  left: 50%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: max-content;
  max-width: calc(100% - 2rem);
  padding: 0.55rem;
  transform: translateX(-50%);
  border: 1px solid var(--rule);
  border-radius: 0.9rem;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 8px 40px #0003;
}
.selection-toolbar > p,
.selection-toolbar > span {
  max-width: 12rem;
  margin: 0 0.5rem;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.selection-toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
}
.reader-bottom-bar {
  display: none;
}
#reader-status {
  position: fixed;
  pointer-events: none;
  z-index: 70;
  right: 1.5rem;
  bottom: 1.5rem;
  max-width: min(25rem, calc(100vw - 2rem));
  padding: 0.85rem 1.1rem;
  border: 1px solid var(--rule);
  border-radius: 0.8rem;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 0.8rem;
}
#selection-toolbar:not([hidden]) + #reader-status {
  bottom: calc(var(--course-mobile-bar-height, 6.5rem) + 4.5rem);
}
#storage-warning {
  margin: 1rem auto;
  padding: 0.8rem 1rem;
  border: 1px solid #b48637;
  border-radius: 0.6rem;
  color: var(--warm-ink);
  background: var(--warm-wash);
  font-size: 0.8rem;
}
body[data-focus='true'] .contents,
body[data-focus='true'] .reader-tip,
body[data-focus='true'] .header-center {
  display: none;
}
body[data-focus='true'] .book-layout {
  grid-template-columns: minmax(0, 1fr);
  max-width: 60rem;
}
body[data-focus='true'][data-width='wide'] .book-layout {
  max-width: 76rem;
}

/* Native dialogs retain keyboard focus and a real backdrop. */
.reader-dialog {
  width: min(35rem, calc(100vw - 2rem));
  max-height: min(85dvh, 52rem);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--rule);
  border-radius: 1.1rem;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 24px 100px #0004;
}
.reader-dialog::backdrop {
  background: #0b1e17a8;
  backdrop-filter: blur(4px);
}
.dialog-header {
  position: sticky;
  z-index: 1;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.5rem;
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
}
.dialog-header h2 {
  margin: 0;
  font-family: var(--reading-font);
  font-size: 1.5rem;
  letter-spacing: -0.03em;
}
.dialog-header > button {
  display: grid;
  place-items: center;
  width: 2.5rem;
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: 0.5rem;
  border-color: transparent;
  background: transparent;
}
.dialog-body {
  padding: 1.4rem 1.5rem;
}
.dialog-body > p {
  color: var(--muted);
  font-size: 0.8rem;
}
.settings-group,
.dialog-body fieldset {
  min-width: 0;
  margin: 0 0 1.3rem;
  padding: 0;
  border: 0;
}
.settings-group legend,
.settings-group > label,
.dialog-body fieldset legend,
.dialog-body > label {
  display: block;
  margin-bottom: 0.6rem;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 600;
}
.choice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.choice-grid label,
.choice-grid button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 4rem;
  gap: 0.4rem;
  min-height: 2.8rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 0.6rem;
  color: var(--muted);
  background: var(--field);
  font-size: 0.8rem;
  cursor: pointer;
}
.choice-grid label:has(input:checked),
.choice-grid button[aria-pressed='true'] {
  border-color: var(--teal);
  color: var(--teal-dark);
  background: var(--teal-wash);
  box-shadow: inset 0 0 0 1px var(--teal);
}
.choice-grid input {
  margin: 0;
  accent-color: var(--teal);
}
.color-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}
.color-options label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.8rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: 0.6rem;
  font-size: 0.8rem;
  cursor: pointer;
}
.color-options label:has(input:checked) {
  border-color: var(--teal);
  box-shadow: inset 0 0 0 1px var(--teal);
}
.color-options input {
  accent-color: var(--teal);
}
.color-dot,
.swatch {
  display: inline-block;
  flex: 0 0 auto;
  width: 0.7rem;
  height: 0.7rem;
  border: 1px solid #0001;
  border-radius: 50%;
  background: var(--yellow);
}
[data-color='yellow'] .color-dot,
.color-dot[data-color='yellow'],
.swatch[data-color='yellow'] {
  background: var(--yellow);
}
[data-color='green'] .color-dot,
.color-dot[data-color='green'],
.swatch[data-color='green'] {
  background: var(--green);
}
[data-color='blue'] .color-dot,
.color-dot[data-color='blue'],
.swatch[data-color='blue'] {
  background: var(--blue);
}
[data-color='pink'] .color-dot,
.color-dot[data-color='pink'],
.swatch[data-color='pink'] {
  background: var(--pink);
}
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--rule);
  background: var(--field);
}
.dialog-actions button {
  font-size: 0.8rem;
}
.selection-preview {
  max-height: 12rem;
  margin: 0 0 1.2rem;
  padding: 1rem 1.1rem;
  overflow: auto;
  border-left: 3px solid #c6a35f;
  border-radius: 0 0.6rem 0.6rem 0;
  color: var(--ink);
  background: var(--warm-wash);
  font-family: var(--reading-font);
  font-size: 1rem;
  line-height: 1.8;
}
#contents-dialog .contents {
  position: static;
  display: block;
  max-height: none;
  padding: 0;
}
#contents-dialog nav ol,
#contents-dialog nav ul {
  display: grid;
  gap: 0.2rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
#contents-dialog nav a {
  display: block;
  padding: 0.8rem 0.65rem;
  border-radius: 0.5rem;
  color: var(--ink);
  font-size: 0.875rem;
  text-decoration: none;
}
#contents-dialog nav a:hover {
  background: var(--teal-wash);
}

/* The notebook is a separate, searchable reading workspace. */
.notebook-shell {
  max-width: 78rem;
  margin: 0 auto;
  padding: 3rem clamp(1rem, 4vw, 3rem) 5rem;
}
.notebook-heading {
  position: relative;
  margin-bottom: 2rem;
}
.notebook-heading .eyebrow {
  margin-bottom: 0.6rem;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
}
.notebook-heading h1 {
  margin: 0 0 0.7rem;
  font-family: var(--reading-font);
  font-size: clamp(2.2rem, 4vw, 3.5rem);
  letter-spacing: -0.05em;
}
.notebook-heading > p {
  max-width: 58ch;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.notebook-local-notice {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin: 1rem 0 1.5rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 0.7rem;
  color: var(--muted);
  background: var(--teal-wash);
  font-size: 0.75rem;
  line-height: 1.65;
}
.notebook-local-notice p {
  margin: 0;
}
#notebook-message {
  max-width: none;
  margin: 1rem 0;
  font-size: 0.8rem;
}
.notebook-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 1.8rem 0 2.3rem;
}
.stat-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--rule);
  border-radius: 0.9rem;
  background: var(--surface);
}
.stat-card > .icon {
  width: 1.2rem;
  height: 1.2rem;
  color: var(--teal);
}
.stat-card strong {
  display: block;
  font-family: var(--reading-font);
  font-size: 1.8rem;
  font-weight: 400;
  line-height: 1.2;
}
.stat-card span,
.stat-card small {
  color: var(--muted);
  font-size: 0.75rem;
}
.notebook-layout {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
}
.notebook-filters {
  position: sticky;
  top: 6.5rem;
  padding: 1.2rem;
  border: 1px solid var(--rule);
  border-radius: 0.9rem;
  background: var(--surface);
}
.notebook-filters h2,
.notebook-filters h3 {
  margin: 0 0 1rem;
  font-family: var(--interface-font);
  font-size: 0.75rem;
  font-weight: 600;
}
.filter-group {
  margin: 0 0 1.1rem;
}
.filter-group > label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-size: 0.75rem;
}
.filter-group input,
.filter-group select {
  margin: 0;
  font-size: 0.78rem;
}
.filter-check {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.75rem;
  line-height: 1.65;
}
.filter-check input {
  flex: 0 0 auto;
  margin-top: 0.22rem;
  accent-color: var(--teal);
}
.filter-reset {
  width: 100%;
  padding: 0.55rem 0.7rem;
  font-size: 0.75rem;
}
.notebook-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 1rem;
}
.notebook-toolbar button {
  padding: 0.55rem 0.75rem;
  font-size: 0.75rem;
}
.results-count {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}
.legend-grid {
  display: grid;
  gap: 0.6rem;
  margin-top: 1rem;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  font-size: 0.75rem;
}
.legend-item > :last-child {
  margin-left: auto;
  color: var(--muted);
}
.notebook-results {
  min-width: 0;
}
.results-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.results-heading h2 {
  margin: 0;
  font-family: var(--interface-font);
  font-size: 0.875rem;
  font-weight: 500;
}
.results-heading p,
#results-count {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}
#notes-list {
  display: grid;
  gap: 1rem;
}
.note-card-list {
  display: grid;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.note-card-list > li {
  min-width: 0;
  margin: 0;
}
.note-card {
  position: relative;
  padding: 1.3rem 1.5rem;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 0.9rem;
  background: var(--surface);
}
.note-card::before {
  position: absolute;
  content: '';
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--yellow);
}
.note-card[data-color='green']::before {
  background: var(--green);
}
.note-card[data-color='blue']::before {
  background: var(--blue);
}
.note-card[data-color='pink']::before {
  background: var(--pink);
}
.note-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.color-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.55rem;
  border-radius: 0.35rem;
  color: var(--ink);
  background: var(--field);
  font-size: 0.75rem;
}
.note-color-dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 0.65rem;
  height: 0.65rem;
  border: 1px solid #0001;
  border-radius: 50%;
  background: var(--yellow);
}
[data-color='green'] .note-color-dot,
.note-color-dot[data-color='green'] {
  background: var(--green);
}
[data-color='blue'] .note-color-dot,
.note-color-dot[data-color='blue'] {
  background: var(--blue);
}
[data-color='pink'] .note-color-dot,
.note-color-dot[data-color='pink'] {
  background: var(--pink);
}
.note-meta {
  color: var(--muted);
  font-size: 0.75rem;
}
.note-quote {
  margin: 0 0 1rem;
  padding: 0;
  color: var(--ink);
  font-family: var(--reading-font);
  font-size: 1.12rem;
  line-height: 1.85;
}
.note-comment {
  margin: 0 0 1rem;
  padding: 0.8rem 1rem;
  border-radius: 0.55rem;
  color: var(--muted);
  background: var(--field);
  font-size: 0.82rem;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.note-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.7rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--rule);
}
.note-card-actions a,
.note-card-actions button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.3rem;
  padding: 0.4rem 0.55rem;
  border: 0;
  color: var(--teal-dark);
  background: transparent;
  font-size: 0.75rem;
  text-decoration: none;
}
.note-card-actions a:hover,
.note-card-actions button:hover {
  background: var(--teal-wash);
}
.note-card-actions a:first-child {
  margin-right: auto;
}
.note-actions-tail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  margin-left: auto;
}
.note-card-actions .icon {
  width: 0.9rem;
  height: 0.9rem;
}
.note-card.reviewed {
  background: var(--field);
}
.note-card.reviewed .note-meta {
  color: var(--teal-dark);
}
.empty-state {
  display: grid;
  justify-items: center;
  gap: 0.75rem;
  padding: 4rem 1.5rem;
  border: 1px dashed var(--rule);
  border-radius: 1rem;
  background: var(--surface);
  text-align: center;
}
.empty-state > .icon {
  box-sizing: content-box;
  width: 1.6rem;
  height: 1.6rem;
  padding: 1rem;
  border-radius: 1rem;
  color: var(--teal-dark);
  background: var(--teal-wash);
}
.empty-state h2,
.empty-state h3 {
  margin: 0.5rem 0 0;
  font-family: var(--reading-font);
  font-size: 1.6rem;
}
.empty-state p {
  max-width: 40ch;
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.note-empty-copy {
  color: var(--muted);
  font-size: 0.8rem;
}
.clipboard-fallback {
  position: fixed;
  top: 0;
  left: -9999px;
  width: 1px;
  height: 1px;
  min-height: 1px;
  margin: 0;
  padding: 0;
  opacity: 0;
}
.meaning-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.8rem;
}
.meaning-row label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 5rem;
  color: var(--muted);
  font-size: 0.75rem;
}
.meaning-row input {
  flex: 1;
  margin: 0;
}
.meaning-row[data-color='green'] .swatch {
  background: var(--green);
}
.meaning-row[data-color='blue'] .swatch {
  background: var(--blue);
}
.meaning-row[data-color='pink'] .swatch {
  background: var(--pink);
}

/* Final shell integration: semantic paragraphs, list items, and table cells. */
.contents .eyebrow {
  margin: 0 0 0.8rem;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.16em;
}
.contents .contents-title {
  margin: 0 0 1.3rem;
  padding: 0;
  border: 0;
  color: var(--ink);
  font-family: var(--reading-font);
  font-size: 1.4rem;
  line-height: 1.3;
  letter-spacing: -0.025em;
}
.contents nav a:has(.toc-number)::before {
  display: none;
}
.toc-number {
  flex: 0 0 1.1rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}
.sidebar-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 1.5rem 0.5rem 0;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.75rem;
}
.sidebar-footer a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 0.4rem;
  font-size: 0.75rem;
  text-decoration: none;
}
.sidebar-footer button {
  width: 100%;
  margin-top: 0.65rem;
  padding: 0.5rem;
  font-size: 0.75rem;
}
.sidebar-footer .icon {
  width: 0.9rem;
  height: 0.9rem;
}
.local-dot {
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 50%;
  background: var(--teal);
}
.reading-progress {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem 1rem;
  margin: 0 0 1.25rem;
}
.reading-progress > label {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.75rem;
}
.reading-progress progress {
  grid-column: 1 / -1;
}
.reading-progress #resume-reading {
  grid-column: 1 / -1;
  justify-self: start;
  min-height: 2.3rem;
  margin: 0.3rem 0 0;
  padding: 0.45rem 0.7rem;
  font-size: 0.75rem;
}
.hero-actions {
  align-items: center;
}
.hero-actions > a:not(.button) {
  padding: 0.5rem 0.2rem;
  color: var(--teal-dark);
  font-family: var(--interface-font);
  font-size: 0.75rem;
}
.local-notice,
.field-help {
  margin: 0.75rem 0.2rem;
  color: var(--muted);
  font-family: var(--interface-font);
  font-size: 0.75rem;
  line-height: 1.75;
}
.field-help:empty {
  display: none;
}
.intro-body {
  margin: 1.5rem 0;
  padding: 1.5rem clamp(1.15rem, 3.5vw, 3rem);
  border-left: 2px solid var(--rule);
  font-family: var(--reading-font);
  font-size: var(--text-size);
  line-height: var(--text-spacing);
}
.reading-block > .block-text {
  font-family: var(--reading-font);
  font-size: var(--text-size);
  line-height: var(--text-spacing);
}
.lesson-section td.reading-block {
  padding-right: 3.5rem;
}
.lesson-section td.reading-block > .block-action {
  top: 0.75rem;
  right: 0.3rem;
}
.lesson-section li.reading-block {
  padding-right: 3rem;
}
.dialogue > p.reading-block {
  padding-right: 3rem;
}
.dialogue > p.reading-block > .block-action {
  top: 1.1rem;
}
.lesson-section.objectives {
  max-width: none;
}
.dialog-body .filter-check {
  display: flex;
  margin-top: 1rem;
  font-weight: 400;
}
#annotation-note + .filter-check {
  margin-top: 0.85rem;
}
.reader-bottom-bar > span {
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}
#contents-dialog .dialog-contents a {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
}
#contents-dialog .dialog-contents + button {
  width: 100%;
  margin-top: 1rem;
}
.notebook-page .reader-header > nav {
  margin-left: auto;
}
.reader-book-label {
  margin-left: 1rem;
  color: #cad8ce;
  font-size: 0.75rem;
}
.header-action {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.65rem;
  color: var(--header-ink);
  background: #ffffff0e;
  font-size: 0.75rem;
  text-decoration: none;
}
.header-action:hover {
  background: #ffffff1a;
}
.notebook-page .reader-header .brand {
  font-size: 0.875rem;
  letter-spacing: 0.035em;
}
.brand-light {
  color: #b8cec1;
  font-weight: 400;
}
.stat-card:has(.stat-label) {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
}
.note-section {
  margin: 0 0 0.6rem;
  color: var(--muted);
  font-family: var(--interface-font);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.5;
}
.note-review-state {
  color: var(--muted);
  font-size: 0.75rem;
}
.reviewed .note-review-state {
  color: var(--teal-dark);
}
.note-card .color-tag {
  color: #273128;
  background: var(--yellow);
}
.note-card[data-color='green'] .color-tag {
  background: var(--green);
}
.note-card[data-color='blue'] .color-tag {
  background: var(--blue);
}
.note-card[data-color='pink'] .color-tag {
  background: var(--pink);
}
.danger-text {
  color: #a54035;
}
body[data-theme='night'] .danger-text {
  color: #f1a498;
}

@media (max-width: 80rem) {
  .reader-header .header-center {
    display: none;
  }
}
@media (max-width: 68rem) {
  .header-center {
    display: none;
  }
  .book-layout {
    grid-template-columns: 11.5rem minmax(0, 1fr);
    gap: 1.5rem;
  }
  .unit-hero {
    grid-template-columns: minmax(0, 1fr) minmax(9rem, 0.7fr);
    padding: 1.6rem;
    gap: 1rem;
  }
  .unit-hero h1 {
    font-size: 2.8rem;
  }
  .hero-art img {
    height: 19rem;
    max-height: none;
  }
  .contents {
    font-size: 0.75rem;
  }
  .contents nav a {
    padding: 0.6rem;
  }
  .notebook-layout {
    grid-template-columns: 12rem minmax(0, 1fr);
    gap: 1.3rem;
  }
}
@media (max-width: 54rem) {
  .brand-navigation {
    display: grid;
    justify-items: start;
    gap: 0;
  }
  .brand-navigation .portfolio-home {
    min-height: 1.6rem;
    padding: 0.15rem 0;
    font-size: 0.75rem;
  }
  .reader-header {
    min-height: 4.1rem;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
  }
  .brand-icon {
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 0.65rem;
  }
  .brand-text {
    font-size: 1.3rem;
  }
  .brand-subtitle {
    font-size: 0.75rem;
  }
  .reader-actions {
    gap: 0.2rem;
  }
  .reader-actions .icon-button,
  .reader-actions .notebook-link {
    padding: 0.6rem;
  }
  .reader-actions .button-label,
  .reader-actions .action-label {
    display: none;
  }
  .reader-actions .notebook-link > span:not(.count-badge) {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .reader-book-label {
    display: none;
  }
  .book-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    max-width: 48rem;
    padding: 1.5rem 1.25rem 7rem;
  }
  .book-layout > .contents {
    display: none;
  }
  .unit-hero {
    grid-template-columns: minmax(0, 1.2fr) minmax(11rem, 0.8fr);
    padding: 2rem;
    gap: 1.5rem;
  }
  .unit-hero h1 {
    font-size: 3.2rem;
  }
  .hero-art img {
    height: 21rem;
  }
  .lesson-section {
    padding: 2rem;
  }
  .reader-bottom-bar {
    position: fixed;
    z-index: 25;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: space-around;
    gap: 0.5rem;
    padding: 0.55rem 1rem max(0.55rem, env(safe-area-inset-bottom));
    border-top: 1px solid var(--rule);
    color: var(--ink);
    background: var(--surface);
    box-shadow: 0 -4px 20px #183d2808;
  }
  .reader-bottom-bar a,
  .reader-bottom-bar button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 2.6rem;
    padding: 0.5rem 0.7rem;
    border: 0;
    color: var(--muted);
    background: transparent;
    font-size: 0.75rem;
    text-decoration: none;
  }
  .reader-bottom-bar progress {
    width: 4rem;
  }
  .selection-toolbar {
    bottom: 5rem;
  }
  #reader-status {
    right: 1rem;
    bottom: 5.5rem;
  }
  .notebook-shell {
    padding-top: 2rem;
  }
  .notebook-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .notebook-filters {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.8rem 1rem;
    padding: 1rem;
  }
  .notebook-filters > h2,
  .notebook-filters > h3,
  .notebook-filters .legend-grid {
    grid-column: 1 / -1;
  }
  .notebook-filters .filter-group,
  .notebook-filters > h2 {
    margin: 0;
  }
  .legend-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 38rem) {
  html {
    scroll-padding-top: 5.5rem;
  }
  .reader-header {
    padding: 0.55rem 0.8rem;
  }
  .reader-header .brand {
    gap: 0.5rem;
  }
  .brand-icon {
    width: 2rem;
    height: 2rem;
  }
  .brand-text {
    font-size: 1.2rem;
  }
  .brand-subtitle {
    display: none;
  }
  .reader-actions .icon-button,
  .reader-actions .notebook-link {
    min-width: 2.5rem;
    min-height: 2.75rem;
    padding: 0.45rem;
  }
  .reader-actions .notebook-link {
    gap: 0.3rem;
  }
  .book-layout {
    padding: 1.1rem 0.85rem 6rem;
  }
  .reading-topline {
    gap: 0.7rem;
    margin-bottom: 1rem;
    font-size: 0.75rem;
  }
  .reading-topline progress {
    width: 3rem;
  }
  .unit-hero {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
    padding: 1.5rem;
    border-radius: 1rem;
  }
  .hero-kicker,
  .unit-hero .eyebrow {
    margin-bottom: 1.1rem;
    font-size: 0.75rem;
  }
  .unit-hero h1 {
    max-width: 13ch;
    font-size: clamp(2.65rem, 11vw, 3.6rem);
  }
  .unit-hero .lead {
    max-width: 40ch;
    font-size: 0.84rem;
  }
  .hero-meta {
    gap: 0.5rem 0.75rem;
    font-size: 0.75rem;
  }
  .hero-actions {
    margin-top: 1.2rem;
  }
  .unit-hero .hero-art {
    max-width: none;
  }
  .hero-art img {
    height: 13rem;
    border-radius: 0.8rem;
    object-position: 50% 68%;
  }
  .hero-art figcaption {
    font-size: 0.75rem;
  }
  .lesson-section {
    margin-top: 1rem;
    padding: 1.4rem 1.15rem;
    border-radius: 0.9rem;
  }
  .section-heading {
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1.3rem;
  }
  .section-heading h2 {
    padding: 0;
    font-size: 1.55rem;
  }
  .section-heading .activity-icon,
  .section-heading > img.activity-icon {
    width: 2rem;
    height: 2rem;
    padding: 0.35rem;
  }
  .section-number {
    font-size: 0.75rem;
  }
  .reader-tip {
    margin: 0.85rem 0 1rem;
    padding: 0.65rem 0.75rem;
    font-size: 0.75rem;
  }
  .reading-block {
    padding-right: 3rem;
  }
  .block-action {
    opacity: 0.7;
    right: -0.3rem;
    width: 2.75rem;
    min-width: 2.75rem;
  }
  .lesson-section blockquote,
  .dialogue,
  .objectives,
  .callout,
  .review-checklist {
    padding: 1rem;
  }
  .lesson-section th,
  .lesson-section td {
    padding: 0.75rem;
    min-width: 8rem;
  }
  .plan-grid {
    grid-template-columns: 1fr;
  }
  .quiz-actions {
    gap: 0.6rem;
  }
  .quiz-actions button {
    flex: 1 1 11rem;
  }
  .reader-bottom-bar {
    gap: 0.2rem;
    padding-right: 0.5rem;
    padding-left: 0.5rem;
  }
  .reader-bottom-bar a,
  .reader-bottom-bar button {
    padding: 0.5rem;
    font-size: 0.75rem;
  }
  .selection-toolbar {
    max-width: calc(100% - 1rem);
    gap: 0.3rem;
    padding: 0.4rem;
    border-radius: 0.8rem;
  }
  .selection-toolbar > p,
  .selection-toolbar > span {
    flex: 1 1 100%;
    max-width: 16rem;
    padding: 0.2rem 0.3rem;
    text-align: center;
  }
  .selection-toolbar button {
    gap: 0.3rem;
    padding: 0.5rem 0.55rem;
    font-size: 0.75rem;
  }
  .reader-dialog {
    width: calc(100vw - 1.2rem);
    max-height: 88dvh;
    border-radius: 1rem;
  }
  .dialog-header {
    padding: 1rem 1.1rem;
  }
  .dialog-body {
    padding: 1.2rem 1.1rem;
  }
  .dialog-actions {
    padding: 0.9rem 1.1rem;
  }
  .dialog-header h2 {
    font-size: 1.4rem;
  }
  .notebook-shell {
    padding: 1.8rem 1rem 4rem;
  }
  .notebook-heading {
    margin-bottom: 1.5rem;
  }
  .notebook-heading h1 {
    font-size: 2.5rem;
  }
  .notebook-heading > p {
    font-size: 0.8rem;
  }
  .notebook-stats {
    gap: 0.5rem;
    margin: 1.5rem 0;
  }
  .stat-card {
    display: block;
    padding: 0.9rem 0.7rem;
    border-radius: 0.7rem;
  }
  .stat-card > .icon {
    display: none;
  }
  .stat-card strong {
    margin-bottom: 0.2rem;
    font-size: 1.6rem;
  }
  .stat-card span,
  .stat-card small {
    font-size: 0.75rem;
  }
  .notebook-filters {
    gap: 0.8rem;
  }
  .notebook-filters .filter-group:has(input[type='search']) {
    grid-column: 1 / -1;
  }
  .note-card {
    padding: 1.1rem;
  }
  .note-quote {
    font-size: 1.05rem;
  }
  .note-card-actions {
    gap: 0.3rem;
  }
  .note-card-actions a:first-child {
    width: 100%;
    margin-bottom: 0.2rem;
  }
  .meaning-row label {
    min-width: 4.4rem;
    font-size: 0.75rem;
  }
}
@media (hover: none) {
  .block-action {
    opacity: 0.8;
  }
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}
@media print {
  body,
  body[data-theme] {
    --paper: #fff;
    --surface: #fff;
    --ink: #111;
    --muted: #444;
    --rule: #bbb;
    --teal-wash: #f3f3f3;
    --field: #fff;
    color: #111;
    background: #fff;
    font-size: 11pt;
  }
  .reader-header,
  .contents,
  .skip-link,
  .reader-tip,
  .reading-topline,
  .reading-progress,
  .local-notice,
  .reader-bottom-bar,
  .selection-toolbar,
  .reader-dialog,
  .block-action,
  .annotation-pin,
  #reader-status,
  #storage-warning,
  #resume-reading,
  .hero-actions,
  .notebook-filters,
  .note-card-actions,
  .quiz-actions {
    display: none !important;
  }
  .book-layout,
  body[data-focus='true'] .book-layout,
  .notebook-shell {
    display: block;
    max-width: none;
    padding: 0;
  }
  .unit-hero {
    grid-template-columns: 1fr 5cm;
    gap: 1cm;
    padding: 0.5cm;
    border: 0;
    background: #fff;
  }
  .unit-hero h1 {
    font-size: 28pt;
  }
  .hero-art img {
    height: 6cm;
    max-height: none;
  }
  .lesson-section {
    margin-top: 1cm;
    padding: 0;
    border: 0;
    border-radius: 0;
    font-size: 11pt;
    line-height: 1.65;
  }
  .section-heading {
    break-after: avoid;
  }
  .section-heading h2 {
    font-size: 19pt;
  }
  .reading-block {
    padding-right: 0;
  }
  .reading-block > .block-text {
    font-size: 11pt;
    line-height: 1.65;
  }
  .intro-body {
    padding: 0;
    border: 0;
  }
  .reading-block.is-target {
    outline: 0;
  }
  .note-card {
    break-inside: avoid;
    border-color: #bbb;
  }
  .notebook-layout {
    display: block;
  }
  .notebook-stats {
    margin: 0.5cm 0;
  }
  mark.reader-highlight {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  .note-card::before {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}
