/* Course content extends the existing reader without changing saved anchors. */
.translation-hint {
  margin: 0 0 1.4rem;
  max-width: 68ch;
  color: var(--muted);
  font-family: var(--interface-font);
  font-size: 0.8125rem;
  line-height: 1.6;
}
.reader-page #conteudo .translation-term {
  cursor: help;
  text-decoration: underline dotted var(--example-rule);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
.reader-page #conteudo .translation-term:focus-visible,
.reader-page #conteudo [data-translation-open] {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
}
.translation-tooltip {
  position: fixed;
  z-index: 90;
  width: max-content;
  max-width: min(22rem, calc(100vw - 24px));
  padding: 0.75rem 0.95rem;
  border: 1px solid var(--example-rule);
  border-radius: 0.8rem;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 8px 30px #091f2433;
  font-family: var(--interface-font);
  font-size: 0.9375rem;
  line-height: 1.5;
  text-align: left;
  overflow-wrap: break-word;
}
.translation-tooltip::after {
  position: absolute;
  left: var(--tip-arrow, 50%);
  bottom: -5px;
  width: 8px;
  height: 8px;
  border-right: 1px solid var(--example-rule);
  border-bottom: 1px solid var(--example-rule);
  background: var(--surface);
  content: '';
  transform: translateX(-50%) rotate(45deg);
}
.translation-tooltip[data-side='below']::after {
  top: -5px;
  bottom: auto;
  transform: translateX(-50%) rotate(225deg);
}
.translation-tooltip-caption {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--muted);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}
.translation-tooltip-meaning {
  display: block;
  max-height: min(35vh, 14rem);
  overflow: auto;
  font-weight: 600;
}
@media print {
  .translation-hint,
  .translation-tooltip {
    display: none !important;
  }
}
.opening-section-label {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0 0 1.2rem;
  color: var(--teal-dark);
  font-family: var(--interface-font);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.4;
}
.opening-section-label .section-number {
  display: inline-grid;
  place-items: center;
  min-width: 2rem;
  min-height: 2rem;
  padding: 0.2rem;
  border: 1px solid var(--rule);
  border-radius: 0.5rem;
  color: var(--teal-dark);
  background: var(--surface);
  font-size: 0.8125rem;
  font-weight: 700;
}
.study-guide-intro {
  padding: clamp(1.15rem, 3vw, 1.8rem);
  border: 1px solid var(--rule);
  border-radius: 1rem;
  background: var(--teal-wash);
}
.study-guide-intro > h3 {
  margin: 0.65rem 0 0.85rem;
  font-size: 1.65em;
  font-weight: 450;
  line-height: 1.2;
}
.study-guide-intro > div {
  max-width: 58ch;
}
.study-label,
.study-check-note,
.study-reference-link,
.study-back {
  font-family: var(--interface-font);
  font-size: 0.78em;
  line-height: 1.55;
}
.study-label {
  display: block;
  color: var(--teal-dark);
  font-weight: 700;
  letter-spacing: 0.045em;
}
.study-topic-nav {
  display: grid;
  gap: 0.6rem;
  margin: 1.4rem 0 1rem;
  font-family: var(--interface-font);
  font-size: 0.9em;
}
.study-topic-nav a {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  min-height: 44px;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--rule);
  border-radius: 0.6rem;
  background: var(--surface);
  text-decoration: none;
  line-height: 1.5;
}
.study-topic-nav a > span:first-child {
  flex: 0 0 auto;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.reader-page .study-topic {
  min-width: 0;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
  scroll-margin-top: 6rem;
}
.study-topic-heading {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  margin-bottom: 1.6rem;
}
.study-step {
  display: grid;
  place-items: center;
  flex: 0 0 2.5rem;
  min-height: 2.5rem;
  border: 1px solid var(--rule);
  border-radius: 0.65rem;
  color: var(--teal-dark);
  background: var(--teal-wash);
  font-family: var(--interface-font);
  font-size: 0.85em;
  font-variant-numeric: tabular-nums;
}
.reader-page .study-topic h3 {
  margin: 0;
  padding: 0;
  font-size: 1.5em;
  font-weight: 500;
  line-height: 1.3;
}
.reader-page .study-topic h4 {
  margin: 1.8rem 0 1rem;
  font-family: var(--interface-font);
  font-size: 0.95em;
  line-height: 1.5;
}
.reader-page .study-topic p {
  margin: 0 0 1.2em;
  line-height: max(1.7, var(--text-spacing));
  text-align: start;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: none;
}
.study-examples {
  display: grid;
  gap: 1.6rem;
}
.study-example {
  min-width: 0;
  padding: clamp(1rem, 3vw, 1.5rem);
  border: 1px solid var(--rule);
  border-radius: 0.9rem;
  background: var(--field);
}
.reader-page .study-example .study-sentence {
  margin: 0.75rem 0 1.25rem;
  padding-left: 0.85rem;
  border-left: 3px solid var(--teal);
  font-size: 1.17em;
  font-weight: 500;
  line-height: 1.55;
}
.study-topic details {
  margin-top: 1rem;
  border-top: 1px solid var(--rule);
}
.study-topic summary,
.lesson-reference > summary {
  min-height: 44px;
  padding: 0.8rem 0;
  color: var(--teal-dark);
  font-family: var(--interface-font);
  font-weight: 650;
  font-size: 0.9em;
  line-height: 1.6;
  cursor: pointer;
}
.study-topic summary:focus-visible,
.lesson-reference > summary:focus-visible,
.study-topic-nav a:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 4px;
  border-radius: 0.3rem;
}
.study-translation > p:first-of-type {
  font-weight: 650;
}
.study-parts {
  display: grid;
  gap: 0.85rem;
  margin: 0.35rem 0 0;
  padding-left: 1.4em;
}
.study-parts > li {
  min-width: 0;
  padding: 0.5rem 0 0.5rem 0.35rem;
}
.study-parts > li::marker {
  color: var(--teal-dark);
  font-family: var(--interface-font);
  font-weight: 650;
}
.reader-page .study-parts .study-part-label {
  margin-bottom: 0.5rem;
}
.study-part-label strong {
  display: block;
  margin-top: 0.5rem;
  color: var(--muted);
  font-family: var(--interface-font);
  font-size: 0.8em;
}
.reader-page .study-parts li > p:last-child {
  margin-bottom: 0;
}
.study-pitfall,
.study-check {
  margin-top: 1.6rem;
  padding: clamp(1rem, 3vw, 1.5rem);
  border: 1px solid var(--rule);
  border-radius: 0.9rem;
}
.study-check {
  background: var(--teal-wash);
}
.reader-page :is(.study-pitfall, .study-check) > h4 {
  margin-top: 0;
}
.study-comparison {
  display: grid;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.study-comparison > div {
  min-width: 0;
  padding: 0.8rem 1rem;
  border-left: 2px solid var(--rule);
  background: var(--field);
}
.reader-page .study-comparison p {
  margin: 0.6rem 0 0;
}
.study-check-note {
  margin-top: 0.85rem;
  color: var(--muted);
}
.study-back {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 0.7rem;
}
.lesson-reference {
  margin-top: 3rem;
  padding: 0.4rem clamp(0.8rem, 2vw, 1.4rem);
  border: 1px solid var(--rule);
  border-radius: 0.8rem;
  scroll-margin-top: 6rem;
}
.reader-page .lesson-reference > h3 {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}
.reader-page .lesson-reference > p {
  margin-bottom: 1.5rem;
}
@media screen and (max-width: 650px) {
  .reader-page .study-topic {
    margin-top: 2.2rem;
    padding-top: 1.5rem;
  }
  .study-topic-heading {
    gap: 0.65rem;
  }
  .reader-page .study-topic h3 {
    font-size: 1.3em;
  }
  .study-step {
    flex-basis: 2rem;
    min-height: 2rem;
  }
  .study-example,
  .study-pitfall,
  .study-check {
    padding: 1rem 0.8rem;
  }
}
@media print {
  .study-topic-nav,
  .study-back,
  .study-reference-link {
    display: none;
  }
  .study-topic-heading,
  .study-sentence {
    break-after: avoid;
  }
  .study-example,
  .study-pitfall,
  .study-check {
    box-shadow: none;
  }
}
.course-hero {
  position: relative;
  overflow: hidden;
  padding: clamp(1.5rem, 5vw, 3.5rem);
  border: 1px solid var(--rule);
  border-radius: 1.5rem;
  background: var(--teal-wash);
}
.course-hero h1 {
  max-width: 17ch;
  margin: 0.75rem 0 1.25rem;
  font-family: var(--reading-font);
  font-size: clamp(2.3rem, 4.2vw, 4.5rem);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -0.045em;
}
.course-hero .lead {
  max-width: 53ch;
  font-size: 1.05rem;
}
.course-hero .hero-meta,
.course-hero .hero-actions {
  position: relative;
  flex-wrap: wrap;
}
.course-hero::after {
  content: '';
  position: absolute;
  inset: -7rem -7rem auto auto;
  width: 15rem;
  height: 15rem;
  border: 1px solid var(--rule);
  border-radius: 50%;
  box-shadow: 0 0 0 2rem var(--paper);
  opacity: 0.35;
  pointer-events: none;
}
.course-habit {
  margin-top: 1.5rem;
  padding: 1.1rem 1.3rem;
  border: 1px solid var(--rule);
  border-radius: 0.8rem;
  background: var(--field);
}
.course-habit p:last-child {
  margin-bottom: 0;
}
.course-reading [lang='pt-BR'] {
  line-height: 1.9;
}
.course-reading > div[lang='pt-BR'] {
  padding: 1.3rem 1.5rem;
  border-left: 3px solid var(--teal);
  border-radius: 0 0.75rem 0.75rem 0;
  background: var(--field);
}
.course-writing-model {
  padding: 1.1rem 1.4rem;
  border: 1px solid var(--rule);
  border-radius: 0.8rem;
  background: var(--field);
  white-space: normal;
}
.course-writing-model p:last-child {
  margin-bottom: 0;
}
.study-guide {
  max-width: 58rem;
  margin: 0 auto;
  padding: 3rem clamp(1rem, 4vw, 3rem) 5rem;
  font-family: var(--reading-font);
  font-size: 1.125rem;
  line-height: 1.85;
}
.study-guide h1 {
  font-size: clamp(2.7rem, 6vw, 4.2rem);
  font-weight: 400;
  line-height: 1.12;
  letter-spacing: -0.045em;
}
.study-guide h2 {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-size: 1.6rem;
}
.study-guide nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
  font-family: var(--interface-font);
  font-size: 0.875rem;
}
.study-guide nav a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
}

/* Phone layout: one reading column, clear hierarchy, no changes to text anchors. */
.mobile-reading-label,
.mobile-reading-rail,
.reader-page:not([data-progress-ready]) .reading-progress > label,
.reader-page:not([data-progress-ready]) .reading-progress > progress {
  display: none;
}
@media screen and (max-width: 650px) {
  .reader-page .reader-header {
    gap: 0.5rem;
    min-height: 4rem;
    padding: 0.5rem max(0.75rem, env(safe-area-inset-right, 0px)) 0.5rem
      max(0.75rem, env(safe-area-inset-left, 0px));
  }
  .reader-page .brand-subtitle {
    display: none;
  }
  /* Use the existing sticky header: no new row, fixed panel, or height budget. */
  .reader-page .mobile-reading-label {
    display: block;
    margin-top: 0.2rem;
    color: var(--header-ink);
    font-family: var(--interface-font);
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }
  .reader-page .mobile-reading-rail {
    position: absolute;
    inset: auto 0 -1px;
    display: block;
    width: 100%;
    height: 3px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    appearance: none;
    background: #ffffff24;
    color: #c7dcbc;
    accent-color: #c7dcbc;
    pointer-events: none;
  }
  .reader-page .mobile-reading-rail::-webkit-progress-bar {
    background: #ffffff24;
  }
  .reader-page .mobile-reading-rail::-webkit-progress-value {
    border-radius: 0;
    background: #c7dcbc;
  }
  .reader-page .mobile-reading-rail::-moz-progress-bar {
    border-radius: 0;
    background: #c7dcbc;
  }
  .reader-page .reader-actions {
    gap: 0.2rem;
  }
  .reader-page .reader-actions .icon-button,
  .reader-page .reader-actions .notebook-link {
    min-width: 44px;
    min-height: 44px;
    padding: 0.5rem;
  }
  .reader-page .reader-actions .icon-button {
    border-color: #ffffff24;
    background: #ffffff08;
  }
  .reader-page .book-layout {
    padding-top: 1rem;
    padding-right: max(0.75rem, env(safe-area-inset-right, 0px));
    padding-left: max(0.75rem, env(safe-area-inset-left, 0px));
  }
  .reader-page .reading-topline {
    display: block;
    margin-bottom: 0.85rem;
  }
  .reader-page .reading-topline .reading-breadcrumb {
    display: block;
    color: var(--ink);
    font-size: 0.8125rem;
    line-height: 1.5;
  }
  .reader-page .reading-topline .reading-book-name,
  .reader-page .reading-topline .reading-divider,
  .reader-page .reading-topline .unit-context {
    display: none;
  }
  .reader-page .reading-progress {
    gap: 0;
    margin-bottom: 0;
  }
  .reader-page .reading-progress > label,
  .reader-page .reading-progress > progress {
    display: none;
  }
  .reader-page .reading-progress #resume-reading {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    min-height: 44px;
    margin: 0 0 1rem;
    padding: 0.65rem 0.85rem;
    color: var(--teal-dark);
    font-size: 0.8125rem;
  }
  @media (forced-colors: active) {
    .reader-page .mobile-reading-rail {
      appearance: auto;
      color: Highlight;
      accent-color: Highlight;
    }
    .reader-page .mobile-reading-rail::-webkit-progress-bar {
      background: Canvas;
    }
    .reader-page .mobile-reading-rail::-webkit-progress-value {
      background: Highlight;
    }
    .reader-page .mobile-reading-rail::-moz-progress-bar {
      background: Highlight;
    }
  }
  .reader-page .course-hero,
  .reader-page .unit-hero {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
    padding: clamp(1.1rem, 4.5vw, 1.6rem);
    border-radius: 1rem;
  }
  .reader-page .course-hero::after,
  .reader-page .hero-kicker,
  .reader-page .hero-meta > span:first-child {
    display: none;
  }
  .reader-page .course-hero h1,
  .reader-page .unit-hero h1 {
    margin: 0 0 1rem;
    max-width: 18ch;
    font-size: clamp(2.25rem, 8vw, 3rem);
    letter-spacing: -0.035em;
    line-height: 1.1;
    text-wrap: balance;
  }
  .reader-page .course-hero .lead,
  .reader-page .unit-hero .lead {
    margin-bottom: 1.15rem;
    color: var(--ink);
    font-size: max(1rem, var(--text-size));
    line-height: 1.65;
  }
  .reader-page .hero-meta {
    gap: 0.5rem;
    margin: 1rem 0;
    font-size: 0.8125rem;
  }
  .reader-page .hero-meta > span {
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--rule);
    border-radius: 0.5rem;
    color: var(--ink);
    background: var(--surface);
  }
  .reader-page .hero-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.5rem;
    margin-top: 1.25rem;
  }
  .reader-page .hero-actions > a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.75rem;
    font-size: 0.9375rem;
  }
  .reader-page .hero-actions > a:not(.button) {
    border: 1px solid var(--rule);
    border-radius: 0.7rem;
    background: var(--surface);
    text-decoration: none;
  }
  .reader-page .hero-art img {
    height: 14rem;
    border-radius: 0.75rem;
  }
  .reader-page .lesson-section {
    padding: 1.25rem 1rem;
    border-radius: 0.9rem;
  }
  .reader-page .section-heading {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.65rem;
    align-items: center;
    margin-bottom: 1.25rem;
  }
  .reader-page .section-number {
    color: var(--teal-dark);
    font-size: 0.8125rem;
    font-weight: 700;
  }
  .reader-page .section-heading .activity-icon {
    width: 1.8rem;
    height: 1.8rem;
    padding: 0.3rem;
  }
  .reader-page .section-heading h2 {
    grid-column: 1 / -1;
    font-size: clamp(1.5rem, 5vw, 1.8rem);
    line-height: 1.25;
    text-wrap: pretty;
  }
  .reader-page .block-action {
    color: var(--teal-dark);
    opacity: 1;
  }
  .reader-page .course-habit,
  .reader-page .course-reading > div[lang='pt-BR'],
  .reader-page .course-writing-model {
    padding: 1rem 0.75rem;
  }
  .reader-page fieldset.exercise {
    min-width: 0;
    padding: 1rem 0.75rem;
  }
  .reader-page .options label {
    min-height: 44px;
    padding: 0.75rem;
    font-size: 1rem;
    line-height: 1.55;
  }
  .reader-page input[type='text'],
  .reader-page input[type='search'],
  .reader-page textarea,
  .reader-page select {
    font-size: 1rem;
    scroll-margin-bottom: calc(5rem + env(safe-area-inset-bottom, 0px));
  }
}
@media screen and (max-width: 360px) {
  .reader-page .reader-header .brand-icon {
    display: none;
  }
}
@media print {
  .course-hero,
  .course-habit,
  .course-reading > div[lang='pt-BR'],
  .course-writing-model {
    break-inside: auto;
    background: transparent;
  }
  .study-guide {
    padding: 0;
    max-width: none;
    font-size: 11pt;
  }
  .study-guide nav,
  .course-hero::after {
    display: none;
  }
}

.reader-page #conteudo pre,
.study-guide pre {
  --code-bg: #2d2a2e;
  --code-fg: #fcfcfa;
  --code-comment: #aaa5ad;
  --code-pink: #ff6188;
  --code-orange: #fc9867;
  --code-yellow: #ffd866;
  --code-green: #a9dc76;
  --code-cyan: #78dce8;
  --code-purple: #ab9df2;
  max-inline-size: 100%;
  margin: 1.35rem 0;
  padding: clamp(1rem, 2.5vw, 1.45rem);
  overflow: auto;
  border: 1px solid color-mix(in srgb, var(--code-purple) 24%, #565158);
  border-radius: 0.9rem;
  background: var(--code-bg);
  color: var(--code-fg);
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.045),
    0 1rem 2.8rem rgba(22, 19, 23, 0.2);
  scrollbar-color: #5c5760 var(--code-bg);
  tab-size: 2;
}

.reader-page #conteudo pre code,
.study-guide pre code {
  padding: 0;
  color: inherit;
  background: transparent;
  box-shadow: none;
  font-family:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono',
    monospace;
  font-size: 0.82em;
  font-style: normal;
  font-weight: 500;
  line-height: 1.7;
  white-space: pre;
  overflow-wrap: normal;
}

.reader-page #conteudo pre code::selection,
.reader-page #conteudo pre code *::selection,
.study-guide pre code::selection,
.study-guide pre code *::selection {
  color: var(--code-fg);
  background: color-mix(in srgb, var(--code-purple) 44%, transparent);
}

.reader-page #conteudo [data-code-theme='monokai-pro'] .tok-comment,
.study-guide [data-code-theme='monokai-pro'] .tok-comment {
  color: var(--code-comment);
  font-style: italic;
}

.reader-page #conteudo [data-code-theme='monokai-pro'] .tok-keyword,
.reader-page #conteudo [data-code-theme='monokai-pro'] .tok-tag,
.study-guide [data-code-theme='monokai-pro'] .tok-keyword,
.study-guide [data-code-theme='monokai-pro'] .tok-tag {
  color: var(--code-pink);
}

.reader-page #conteudo [data-code-theme='monokai-pro'] .tok-string,
.study-guide [data-code-theme='monokai-pro'] .tok-string {
  color: var(--code-yellow);
}

.reader-page #conteudo [data-code-theme='monokai-pro'] .tok-number,
.reader-page #conteudo [data-code-theme='monokai-pro'] .tok-literal,
.reader-page #conteudo [data-code-theme='monokai-pro'] .tok-regexp,
.study-guide [data-code-theme='monokai-pro'] .tok-number,
.study-guide [data-code-theme='monokai-pro'] .tok-literal,
.study-guide [data-code-theme='monokai-pro'] .tok-regexp {
  color: var(--code-purple);
}

.reader-page #conteudo [data-code-theme='monokai-pro'] .tok-function,
.reader-page #conteudo [data-code-theme='monokai-pro'] .tok-attribute,
.reader-page #conteudo [data-code-theme='monokai-pro'] .tok-selector,
.study-guide [data-code-theme='monokai-pro'] .tok-function,
.study-guide [data-code-theme='monokai-pro'] .tok-attribute,
.study-guide [data-code-theme='monokai-pro'] .tok-selector {
  color: var(--code-green);
}

.reader-page #conteudo [data-code-theme='monokai-pro'] .tok-type,
.reader-page #conteudo [data-code-theme='monokai-pro'] .tok-builtin,
.reader-page #conteudo [data-code-theme='monokai-pro'] .tok-namespace,
.reader-page #conteudo [data-code-theme='monokai-pro'] .tok-property,
.study-guide [data-code-theme='monokai-pro'] .tok-type,
.study-guide [data-code-theme='monokai-pro'] .tok-builtin,
.study-guide [data-code-theme='monokai-pro'] .tok-namespace,
.study-guide [data-code-theme='monokai-pro'] .tok-property {
  color: var(--code-cyan);
}

.reader-page #conteudo [data-code-theme='monokai-pro'] .tok-operator,
.study-guide [data-code-theme='monokai-pro'] .tok-operator {
  color: var(--code-pink);
}

.reader-page #conteudo [data-code-theme='monokai-pro'] .tok-punctuation,
.study-guide [data-code-theme='monokai-pro'] .tok-punctuation {
  color: color-mix(in srgb, var(--code-fg) 78%, var(--code-purple));
}

.reader-page #conteudo :not(pre) > code,
.study-guide :not(pre) > code {
  font-family:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono',
    monospace;
  font-size: 0.88em;
  font-style: normal;
}

.reader-page .translation-hint {
  border-color: color-mix(in srgb, var(--teal) 24%, var(--rule));
}

@media (prefers-contrast: more) {
  .reader-page #conteudo pre,
  .study-guide pre {
    border-width: 2px;
  }
}
