:root {
  --bg: #f4efe4;
  --bg-accent: #e6dcc4;
  --panel: rgba(255, 251, 243, 0.92);
  --panel-strong: #fffaf0;
  --line: rgba(65, 56, 38, 0.12);
  --line-strong: rgba(65, 56, 38, 0.22);
  --text: #231f18;
  --muted: #695f51;
  --accent: #0f766e;
  --accent-strong: #0b5e58;
  --shadow: 0 22px 60px rgba(56, 44, 22, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.09), transparent 30%),
    radial-gradient(circle at bottom right, rgba(180, 83, 9, 0.1), transparent 26%),
    linear-gradient(180deg, #f8f3e9 0%, #efe6d4 100%);
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  min-height: 100vh;
}

body.home-mode .app-shell,
body.reader-mode .app-shell {
  grid-template-columns: 1fr;
}

body.course-mode .app-shell {
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
}

body.home-mode .app-shell {
  grid-template-columns: 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: rgba(251, 246, 236, 0.84);
  backdrop-filter: blur(18px);
  overflow-y: auto;
}

body.home-mode .sidebar {
  display: none;
}

body.reader-mode .sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(88vw, 340px);
  transform: translateX(-100%);
  transition: transform 200ms ease;
  z-index: 40;
  box-shadow: var(--shadow);
}

body.reader-mode .sidebar.is-open {
  transform: translateX(0);
}

.sidebar__inner {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1.5rem;
  height: 100%;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 800;
  letter-spacing: 0.08em;
}

.brand-mark--button {
  padding: 0;
  cursor: pointer;
}

.brand-mark--button:hover,
.brand-mark--button:focus-visible {
  color: var(--accent-strong);
  outline: none;
}

.brand-mark i {
  color: var(--accent);
  font-size: 1.45rem;
}

.brand-mark--home {
  margin-right: auto;
  font-size: 1.1rem;
}

.brand-mark--home i {
  font-size: 1.65rem;
}

.sidebar__topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
}

.sidebar__topbar .brand-mark {
  margin-left: auto;
  text-align: right;
}

.sidebar__topbar .home-link {
  flex: 0 0 auto;
}

#back-link {
  border-color: transparent;
  background: transparent;
}

#back-link:hover,
#back-link:focus-visible {
  border-color: transparent;
}

.sidebar__courseWrap {
  display: grid;
  gap: 0.35rem;
}

.sidebar__courseTitle {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  color: inherit;
  font-size: 1.8rem;
  line-height: 1.05;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  text-align: left;
  cursor: pointer;
}

.sidebar__courseTitle:hover,
.sidebar__courseTitle:focus-visible {
  color: var(--accent-strong);
  outline: none;
}

.sidebar__courseMeta {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.panel__eyebrow,
.reader-meta__eyebrow {
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--muted);
}

.brand__title,
.hero__title,
.panel__title,
.reader-meta__title,
.course-hero__title {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  letter-spacing: -0.03em;
}

.brand__title {
  font-size: 2rem;
  line-height: 1;
}

.course-hero__copy,
.sidebar__summary,
.course-card__copy,
.chapter-card__meta,
.result-card__meta {
  color: var(--muted);
}

.home-link,
.ghost-button,
.topbar__menu,
.course-card__button,
.chapter-card__button,
.result-card__button {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.home-link:hover,
.ghost-button:hover,
.topbar__menu:hover,
.course-card__button:hover,
.chapter-card__button:hover,
.result-card__button:hover,
.page-link:hover {
  transform: translateY(-1px);
  border-color: rgba(15, 118, 110, 0.35);
  background: rgba(15, 118, 110, 0.08);
}

.home-link:disabled,
.ghost-button:disabled,
.topbar__menu:disabled,
.course-card__button:disabled,
.chapter-card__button:disabled,
.result-card__button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  background: transparent;
}

a[aria-disabled="true"] {
  pointer-events: none;
  opacity: 0.55;
}

.home-link,
.ghost-button,
.course-card__button,
.chapter-card__button,
.result-card__button {
  padding: 0.7rem 1rem;
}

.search {
  display: grid;
}

.search input {
  width: 100%;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  outline: none;
}

.search input:focus {
  border-color: rgba(15, 118, 110, 0.45);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.1);
}

.course-nav {
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
}

.course-nav__item {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.44);
  overflow: hidden;
}

.course-nav__item.is-active {
  border-color: rgba(15, 118, 110, 0.35);
  background: rgba(15, 118, 110, 0.08);
}

.page-list {
  display: grid;
  gap: 0.45rem;
  padding: 0 0 0.2rem;
}

.page-list--scrollable {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.45rem;
}

.page-list--scrollable::-webkit-scrollbar {
  width: 8px;
}

.page-list--scrollable::-webkit-scrollbar-thumb {
  background: rgba(35, 31, 24, 0.18);
  border-radius: 999px;
}

.page-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.6);
  padding: 0.75rem 0.85rem;
  text-align: left;
  cursor: pointer;
}

.page-link.is-active {
  border-color: rgba(15, 118, 110, 0.38);
  background: rgba(15, 118, 110, 0.12);
}

.page-link.is-read:not(.is-active) {
  background: rgba(255, 255, 255, 0.74);
}

.page-link__title {
  display: block;
  font-size: 0.93rem;
  font-weight: 600;
}

.page-link__status,
.chapter-card__status {
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 800;
}

.main {
  min-width: 0;
  padding: 1.4rem;
}

body.home-mode .main {
  display: flex;
  flex-direction: column;
  width: min(100%, 1360px);
  min-height: 100vh;
  margin: 0 auto;
  padding-left: 1.15rem;
  padding-right: 1.15rem;
  padding-bottom: 0;
}

body.course-mode .main {
  padding-left: 1rem;
  padding-right: 1.4rem;
}

body.reader-mode .main {
  padding-top: 0;
  padding-left: 0;
  padding-right: 0;
}

.topbar__menu {
  display: none;
  padding: 0.7rem 1rem;
}

.topbar__menu[hidden] {
  display: none !important;
}

.topbar__menuLabel {
  display: none;
}

.topbar__menu--standalone {
  margin-bottom: 1rem;
}

.reader-mode .topbar__menu {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-width: 2.8rem;
  height: 2.8rem;
  padding: 0 0.95rem;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  opacity: 0.82;
  transition: opacity 180ms ease, transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.reader-mode .topbar__menu i {
  font-size: 1rem;
}

.reader-mode .topbar__menuLabel {
  display: inline;
}

.reader-mode .topbar__menu--standalone {
  position: sticky;
  top: 1rem;
  margin-left: auto;
  z-index: 25;
  background: rgba(255, 251, 243, 0.9);
  backdrop-filter: blur(16px);
}

.reader-mode .topbar__menu:hover,
.reader-mode .topbar__menu:focus-visible {
  opacity: 1;
}

.home-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto 1rem;
}

.search--home {
  width: min(100%, 430px);
}

.course-toolbar {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 1rem;
}

.search--course {
  width: min(100%, 420px);
}

.view {
  display: none;
}

.view.view--active {
  display: block;
  animation: viewFade 180ms ease both;
}

body.home-mode #home-view.view--active {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

@keyframes viewFade {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .view.view--active {
    animation: none;
  }
}

.panel,
.course-hero,
.reader-meta {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 1.4rem;
  margin-bottom: 1.4rem;
}

body.home-mode #home-view .panel {
  width: 100%;
  max-width: 1280px;
  margin-left: auto;
  margin-right: auto;
  padding: 1.6rem 1.7rem;
}

body.home-mode #home-courses-panel {
  align-self: center;
}

body.home-mode #home-courses-panel:not([hidden]) {
  margin-top: auto;
  margin-bottom: auto;
}

body.home-mode #search-results-panel:not([hidden]) {
  margin-bottom: auto;
}

.recent-panel {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto 1rem;
}

.recent-panel--course {
  max-width: none;
  margin: 0 0 1rem;
}

.recent-panel__header {
  margin-bottom: 0.55rem;
}

.recent-panel__header h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.recent-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}

.recent-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 251, 243, 0.74);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.recent-card:hover,
.recent-card:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(15, 118, 110, 0.28);
  background: rgba(255, 251, 243, 0.94);
  outline: none;
}

.recent-card__icon,
.course-card__icon,
.course-hero__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 14px;
  background: rgba(15, 118, 110, 0.1);
  color: var(--accent-strong);
}

.recent-card__body {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
}

.recent-card__course {
  color: var(--muted);
  font-size: 0.75rem;
}

.recent-card__title {
  overflow: hidden;
  color: var(--text);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.9rem 1.4rem;
  width: 100%;
  max-width: 1280px;
  margin: 1.25rem auto 0;
  padding: 1.1rem 0 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.home-footer__brand {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
}

.home-footer__brand strong {
  color: var(--text);
  font-size: 1rem;
}

.home-footer__brand span,
.home-footer__note {
  font-size: 0.9rem;
  line-height: 1.45;
}

.home-footer__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
}

.home-footer__actions button {
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  padding: 0.2rem 0;
  font-weight: 700;
  cursor: pointer;
}

.home-footer__actions button:hover,
.home-footer__actions button:focus-visible {
  color: var(--text);
  outline: none;
}

.home-footer__actions button:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.55;
}

.home-footer__note {
  grid-column: 1 / -1;
  margin: 0;
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.course-grid,
.results-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1rem;
}

.course-card,
.result-card {
  position: relative;
  display: grid;
  gap: 1.1rem;
  padding: 1.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
}

.result-card {
  gap: 0.9rem;
}

.course-card--interactive,
.chapter-card--interactive,
.result-card--interactive {
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.course-card--interactive:hover,
.chapter-card--interactive:hover,
.result-card--interactive:hover,
.course-card--interactive:focus-visible,
.chapter-card--interactive:focus-visible,
.result-card--interactive:focus-visible {
  transform: translateY(-3px);
  border-color: rgba(15, 118, 110, 0.32);
  box-shadow: 0 18px 40px rgba(56, 44, 22, 0.14);
  outline: none;
}

.course-card::before,
.course-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.36), transparent 55%);
}

.course-card[data-theme="teal"],
.course-hero[data-theme="teal"] {
  background: linear-gradient(180deg, #f3fbfa 0%, #fffaf0 100%);
}

.course-card[data-theme="amber"],
.course-hero[data-theme="amber"] {
  background: linear-gradient(180deg, #fff6e6 0%, #fffaf0 100%);
}

.course-card[data-theme="sage"],
.course-hero[data-theme="sage"] {
  background: linear-gradient(180deg, #f2f8ee 0%, #fffaf0 100%);
}

.course-card[data-theme="coral"],
.course-hero[data-theme="coral"] {
  background: linear-gradient(180deg, #fff2ec 0%, #fffaf0 100%);
}

.course-card[data-theme="slate"],
.course-hero[data-theme="slate"] {
  background: linear-gradient(180deg, #f1f4f7 0%, #fffaf0 100%);
}

.course-card__header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 1rem;
  min-width: 0;
  padding-right: 0;
  padding-bottom: 0;
}

.course-card__title {
  max-width: none;
  font-size: clamp(1.35rem, 1.75vw, 1.9rem);
  line-height: 1.08;
  overflow-wrap: normal;
  word-break: normal;
  white-space: normal;
  hyphens: manual;
}

.course-card__copy {
  margin: 0.55rem 0 0;
  font-size: 0.92rem;
  line-height: 1.45;
}

.course-card__meta {
  grid-column: 1 / -1;
  display: grid;
  gap: 0.45rem;
  margin-top: 0.1rem;
}

.course-card__count {
  color: var(--muted);
  font-size: 0.86rem;
}

.course-card__progress {
  height: 0.45rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(35, 31, 24, 0.08);
}

.course-card__progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #b45309);
}

.course-card__continue {
  justify-self: start;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  padding: 0;
  font-weight: 800;
  cursor: pointer;
}

.course-card__continue:hover,
.course-card__continue:focus-visible {
  color: var(--text);
  outline: none;
}

.course-card__actions,
.result-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.course-card__actions {
  margin-top: 0.5rem;
}

.result-card__metaRow {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.result-card__badge {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(35, 31, 24, 0.06);
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.02em;
}

.result-card__badge--strong {
  background: rgba(15, 118, 110, 0.11);
  color: var(--accent-strong);
}

.result-card__title {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.25;
}

.result-card__snippet {
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.55;
}

mark {
  padding: 0.08rem 0.2rem;
  border-radius: 0.3rem;
  background: rgba(15, 118, 110, 0.16);
  color: inherit;
}

.course-hero {
  position: relative;
  padding: 1.5rem;
  margin-bottom: 1.4rem;
}

.course-hero__icon {
  margin-bottom: 0.9rem;
}

.course-hero__title {
  font-size: clamp(2.2rem, 4vw, 3.4rem);
}

.course-hero__copy {
  max-width: 62ch;
  margin: 0.85rem 0 0;
  font-size: 1.05rem;
}

.course-hero__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1rem;
}

.course-progress {
  display: grid;
  gap: 0.45rem;
  max-width: 520px;
  margin-top: 1.05rem;
}

.course-progress__meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.course-progress__bar {
  height: 0.55rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(35, 31, 24, 0.08);
}

.course-progress__bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #b45309);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.58);
  color: var(--muted);
  font-size: 0.86rem;
}

.chapter-groups {
  display: grid;
  gap: 1rem;
}

.chapter-group {
  padding: 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.chapter-group__header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.chapter-group__actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.chapter-continueButton {
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  padding: 0.35rem 0;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.chapter-continueButton:hover,
.chapter-continueButton:focus-visible {
  color: var(--text);
  outline: none;
}

.chapter-group__title {
  margin: 0;
  font-size: 1.5rem;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
}

.chapter-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.9rem;
}

.chapter-card {
  position: relative;
  padding: 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--panel-strong);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
}

.chapter-card.is-read {
  border-color: rgba(15, 118, 110, 0.24);
  background: rgba(243, 251, 250, 0.82);
}

.chapter-card__title {
  margin: 0;
  font-size: 1.05rem;
}

.reader-meta {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0;
  margin-bottom: 1rem;
  position: sticky;
  top: 0;
  z-index: 25;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: rgba(255, 251, 243, 0.88);
  backdrop-filter: blur(18px);
}

.reader-meta__center {
  grid-row: 1;
  grid-column: 2;
  align-self: center;
  min-width: 0;
  text-align: center;
}

.reader-footerNav {
  display: flex;
  justify-content: flex-end;
  gap: 0.35rem;
  margin-top: 1rem;
}

.ghost-button--wide {
  min-width: 168px;
}

.reader-meta__title {
  font-size: clamp(1.25rem, 2vw, 1.85rem);
  line-height: 1.12;
}

.reader-contentsButton {
  grid-row: 1;
  grid-column: 1;
  justify-self: start;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  white-space: nowrap;
}

.reader-contentsButton .topbar__menuLabel {
  display: none;
}

.reader-navButton {
  grid-row: 1;
  grid-column: 3;
  justify-self: start;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.reader-meta .ghost-button {
  min-width: 2.75rem;
  height: 2.75rem;
  border-color: transparent;
  background: transparent;
  padding: 0;
  line-height: 1;
}

.reader-meta .ghost-button:hover,
.reader-meta .ghost-button:focus-visible {
  border-color: transparent;
}

.reader-navButton__label {
  display: none;
}

.reader-navButton--right {
  grid-row: 1;
  grid-column: 5;
  justify-self: end;
  align-self: center;
}

.reader-readToggle {
  grid-row: 1;
  grid-column: 4;
  align-self: center;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  padding: 0;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.reader-readToggle:hover,
.reader-readToggle:focus-visible {
  color: var(--text);
  outline: none;
}

.reader-navButton,
.reader-footerNav .ghost-button {
  font-size: 1.15rem;
}

.reader-footerNav .ghost-button {
  min-width: auto;
  border-color: transparent;
  background: transparent;
}

.reader-footerNav .ghost-button:hover,
.reader-footerNav .ghost-button:focus-visible {
  border-color: transparent;
}

.reader-frame {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: rgba(255, 250, 240, 0.9);
  box-shadow: var(--shadow);
}

#content-frame {
  display: block;
  width: 100%;
  min-height: 0;
  border: 0;
  background: transparent;
}

.panel--error {
  border-color: rgba(185, 28, 28, 0.22);
  background: rgba(254, 242, 242, 0.94);
}

.empty-state {
  display: grid;
  gap: 0.3rem;
  padding: 1rem;
  border-radius: var(--radius-lg);
  border: 1px dashed var(--line-strong);
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--text);
}

.sidebar-overlay {
  display: none;
}

body.reader-mode .sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(25, 20, 12, 0.28);
  backdrop-filter: blur(2px);
  z-index: 30;
}

body.reader-mode .sidebar-overlay.is-open {
  display: block;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  body.course-mode .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(88vw, 340px);
    transform: translateX(-100%);
    transition: transform 200ms ease;
    z-index: 40;
    box-shadow: var(--shadow);
  }

  body.course-mode .sidebar.is-open {
    transform: translateX(0);
  }

  body.course-mode .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(25, 20, 12, 0.28);
    backdrop-filter: blur(2px);
    z-index: 30;
  }

  body.course-mode .sidebar-overlay.is-open {
    display: block;
  }

  body.course-mode .topbar__menu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.8rem;
    height: 2.8rem;
    padding: 0;
    border-radius: 999px;
    font-size: 1.2rem;
    line-height: 1;
    opacity: 0.3;
  }

  body.course-mode .topbar__menu--standalone {
    position: sticky;
    top: 1rem;
    left: 0;
    z-index: 25;
    background: rgba(255, 251, 243, 0.9);
    backdrop-filter: blur(16px);
  }

  .main {
    padding: 1rem;
  }

  body.reader-mode .main {
    padding-top: 0;
    padding-left: 0;
    padding-right: 0;
  }
}

@media (max-width: 860px) {
  .home-toolbar {
    justify-content: stretch;
  }

  .course-toolbar {
    justify-content: stretch;
  }

  .search--home {
    width: 100%;
  }

  .search--course {
    width: 100%;
  }

  .recent-list {
    grid-template-columns: 1fr;
  }

  .home-footer {
    grid-template-columns: 1fr;
  }

  .home-footer__actions {
    justify-content: flex-start;
  }

  .reader-meta {
    grid-template-columns: auto minmax(0, 1fr) auto auto auto;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 0;
  }

  .reader-navButton__label,
  .reader-contentsButton .topbar__menuLabel {
    display: none;
  }

  .reader-footerNav {
    flex-direction: row;
    justify-content: flex-end;
  }

  .course-grid,
  .results-list,
  .chapter-list {
    grid-template-columns: 1fr;
  }

  .course-card__title {
    max-width: none;
  }

}

@media (max-width: 640px) {
  .main,
  .sidebar__inner {
    padding: 0.9rem;
  }

  body.home-mode .main {
    padding-left: 0.8rem;
    padding-right: 0.8rem;
  }

  .panel,
  .course-hero {
    border-radius: 22px;
  }

  .reader-meta {
    border-radius: 0;
  }
}
