﻿:root {
  --bg: #0d1724;
  --panel: rgba(244, 249, 255, 0.9);
  --panel-strong: #fbfeff;
  --ink: #102032;
  --muted: #5c7088;
  --line: rgba(56, 114, 165, 0.14);
  --accent: #1d9bf0;
  --accent-2: #19c6d6;
  --shadow: 0 24px 54px rgba(4, 14, 28, 0.22);
  --radius: 24px;
  --nav-bg: rgba(7, 18, 31, 0.92);
  --nav-line: rgba(95, 224, 255, 0.16);
  --nav-ink: #e5f7ff;
  --font-ui:
    "Microsoft JhengHei",
    "PingFang TC",
    "Noto Sans TC",
    "Source Han Sans TC",
    sans-serif;
  --font-reader:
    "Noto Serif TC",
    "Source Han Serif TC",
    "PMingLiU",
    "Songti TC",
    serif;
}

html[lang="zh-Hans"] {
  --font-ui:
    "Microsoft YaHei",
    "PingFang SC",
    "Noto Sans SC",
    "Source Han Sans SC",
    sans-serif;
  --font-reader:
    "Noto Serif SC",
    "Source Han Serif SC",
    "SimSun",
    "Songti SC",
    serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(95, 224, 255, 0.18), transparent 24%),
    radial-gradient(circle at bottom right, rgba(25, 198, 214, 0.14), transparent 28%),
    linear-gradient(180deg, #09131f 0%, #101b29 100%);
  color: var(--ink);
  font-family: var(--font-ui);
}

body {
  padding: 28px;
}

a {
  color: inherit;
}

.site-bar {
  margin: 0 0 20px;
}

.shell {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.site-bar-inner {
  display: block;
}

.site-bar-search {
  margin-top: 8px;
  display: flex;
  justify-content: flex-start;
}

.site-bar-search .library-search {
  width: min(760px, 100%);
}

.site-nav-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 4px;
}

.site-nav-start {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.site-nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.site-brand {
  color: var(--nav-ink);
  text-decoration: none;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.lang-switcher {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--nav-line);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(95, 224, 255, 0.08);
}

.lang-link {
  padding: 7px 12px;
  border-radius: 999px;
  color: rgba(229, 247, 255, 0.74);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  transition:
    background-color 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
  border: 1px solid transparent;
}

.lang-link.active {
  background: linear-gradient(135deg, #37d7ff 0%, #15a8ff 100%);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.46);
  box-shadow:
    0 8px 18px rgba(21, 168, 255, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.lang-link:hover,
.lang-link:focus-visible {
  color: #fff;
  background: rgba(95, 224, 255, 0.16);
  border-color: rgba(95, 224, 255, 0.26);
  outline: none;
}

.hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  align-items: stretch;
  margin-bottom: 12px;
}

.hero.hero-import-open {
  grid-template-columns: 1.1fr 0.9fr;
}

.hero-card,
.upload-panel,
.book-card,
.reader-shell,
.empty-state,
.detail-card {
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 34px;
}

.hero-actions {
  margin-top: 22px;
}

.import-toggle-button {
  min-width: 172px;
}

.import-toggle-button-nav {
  min-width: 0;
  padding-inline: 18px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(29, 155, 240, 0.12);
  color: #0d77c4;
  font-size: 0.88rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 16px 0 10px;
  font-size: clamp(1.9rem, 3.9vw, 3.35rem);
  line-height: 0.98;
  letter-spacing: -0.03em;
}

.hero p,
.muted {
  color: var(--muted);
  line-height: 1.7;
}

.upload-panel {
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.upload-panel[hidden] {
  display: none;
}

.upload-panel h2,
.section-head h2 {
  margin: 0;
  font-size: 1.25rem;
}

.upload-panel form {
  display: grid;
  gap: 14px;
}

.panel-divider {
  height: 1px;
  background: var(--line);
}

.file-field {
  display: grid;
  gap: 8px;
}

.file-field input {
  width: 100%;
  padding: 14px;
  border-radius: 16px;
  border: 1px dashed rgba(31, 42, 44, 0.22);
  background: rgba(255, 255, 255, 0.55);
}

.field-note {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.scan-direct-tools {
  display: grid;
  gap: 12px;
}

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

.button.ghost {
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink);
  border: 1px solid var(--line);
}

.drop-zone {
  display: grid;
  gap: 6px;
  padding: 18px;
  border-radius: 20px;
  border: 1px dashed rgba(25, 198, 214, 0.4);
  background:
    linear-gradient(135deg, rgba(25, 198, 214, 0.08), rgba(255, 255, 255, 0.5)),
    rgba(255, 255, 255, 0.42);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 140ms ease, transform 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.drop-zone strong {
  font-size: 1rem;
}

.drop-zone span {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.is-dragover {
  outline: none;
  transform: translateY(-1px);
  border-color: rgba(25, 198, 214, 0.72);
  background:
    linear-gradient(135deg, rgba(25, 198, 214, 0.16), rgba(255, 255, 255, 0.58)),
    rgba(255, 255, 255, 0.58);
  box-shadow: 0 14px 32px rgba(4, 14, 28, 0.12);
}

.scan-results {
  display: grid;
  gap: 12px;
}

.scan-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.checkbox-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  color: var(--ink);
}

.scan-list {
  display: grid;
  gap: 10px;
  max-height: 280px;
  overflow: auto;
  padding-right: 4px;
}

.scan-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
}

.scan-item.is-disabled {
  opacity: 0.72;
}

.scan-item input {
  margin-top: 4px;
}

.scan-item-body {
  display: grid;
  gap: 6px;
}

.scan-item-path,
.scan-item-state {
  font-size: 0.88rem;
  color: var(--muted);
  word-break: break-all;
}

button,
.button {
  border: none;
  border-radius: 16px;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--accent) 0%, #c26a42 100%);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.button.secondary {
  background: linear-gradient(135deg, var(--accent-2) 0%, #1789b8 100%);
}

.status {
  min-height: 24px;
  font-size: 0.95rem;
}

.status[data-state="error"] {
  color: #9e2a2a;
}

.status[data-state="success"] {
  color: #1f6f43;
}

.section-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}

.section-head-copy {
  display: grid;
  gap: 4px;
  width: 100%;
}

.library-search {
  display: flex;
  align-items: center;
  width: min(680px, 100%);
  position: relative;
  align-self: flex-start;
  margin: 0;
}

.library-search input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
  font: inherit;
}

.library-search input::placeholder {
  color: var(--muted);
}

.library-search input:focus {
  outline: none;
  border-color: rgba(25, 198, 214, 0.42);
  box-shadow: 0 0 0 4px rgba(25, 198, 214, 0.1);
}

.library-search-suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  display: grid;
  gap: 6px;
  padding: 8px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(251, 254, 255, 0.96);
  box-shadow: 0 18px 42px rgba(4, 14, 28, 0.18);
  z-index: 20;
}

.library-suggestion {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.library-suggestion:hover,
.library-suggestion.active {
  background: rgba(25, 198, 214, 0.12);
  border-color: rgba(25, 198, 214, 0.28);
}

.library-search-empty {
  margin: 0 0 14px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.book-card {
  overflow: hidden;
  content-visibility: auto;
  contain-intrinsic-size: 360px;
}

.book-card-link {
  display: block;
  color: inherit;
  text-decoration: none;
  height: 100%;
  transition: transform 160ms ease, box-shadow 160ms ease;
  will-change: transform;
}

.book-card-link:hover {
  transform: translateY(-4px);
}

.book-card-link:focus-visible {
  outline: 2px solid rgba(25, 198, 214, 0.72);
  outline-offset: -2px;
}

.book-cover {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5.2;
  object-fit: cover;
  background:
    linear-gradient(135deg, rgba(166, 83, 47, 0.2), rgba(45, 106, 106, 0.18)),
    linear-gradient(180deg, #f9ecda, #e9d4b7);
}

.book-card .book-body {
  padding: 14px 14px 16px;
  display: grid;
  gap: 8px;
}

.book-card .book-title {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-card .meta-line {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-card .tag-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(45, 106, 106, 0.1);
  color: var(--accent-2);
  font-size: 0.76rem;
}

.variant-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.variant-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(45, 106, 106, 0.2);
  background: rgba(255, 255, 255, 0.72);
  color: var(--accent-2);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
}

.variant-links a.active {
  background: rgba(25, 198, 214, 0.12);
  border-color: rgba(25, 198, 214, 0.42);
  color: var(--ink);
}

.nav-variants {
  gap: 6px;
}

.nav-variants a {
  min-height: 34px;
  padding: 7px 12px;
  border-color: var(--nav-line);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(229, 247, 255, 0.78);
  font-size: 0.88rem;
}

.nav-variants a.active {
  background: linear-gradient(135deg, rgba(95, 224, 255, 0.22), rgba(137, 255, 202, 0.16));
  color: #fff;
  border-color: rgba(95, 224, 255, 0.24);
}

.empty-state {
  padding: 28px;
  text-align: center;
}

.reader-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  height: calc(100vh - 56px);
  min-height: 0;
  overflow: hidden;
  align-items: stretch;
  isolation: isolate;
}

.reader-side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 20px;
  border-right: 1px solid var(--line);
  background: #eef4fb;
  overflow: hidden;
  position: relative;
  z-index: 2;
}

.reader-head {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.reader-head h1 {
  margin: 0;
  font-size: clamp(1.55rem, 2vw, 2.35rem);
  line-height: 1.04;
  max-height: min(20vh, 11rem);
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-family: var(--font-reader);
  font-weight: 700;
}

.reader-nav-controls {
  display: grid;
  gap: 8px;
}

.reader-nav-main-line {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: nowrap;
  min-width: 0;
}

.reader-nav-main-line > * {
  min-width: 0;
}

.reader-nav-quick-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.reader-nav-main-line .inline-lang-switcher {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 3px;
  flex: 0 1 auto;
}

.reader-nav-main-line .inline-lang-switcher .lang-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  min-width: 52px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.reader-nav-main-line .nav-home-link,
.reader-nav-main-line .nav-tts-toggle {
  min-height: 36px;
  min-width: 56px;
  padding: 0 12px;
  font-size: 0.82rem;
}

.reader-nav-variant-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.reader-font-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid rgba(56, 114, 165, 0.14);
  background: rgba(255, 255, 255, 0.5);
}

.reader-font-label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.reader-font-buttons {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

.reader-font-button {
  min-width: 42px;
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(56, 114, 165, 0.18);
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.reader-font-button.is-active {
  border-color: rgba(25, 198, 214, 0.4);
  background: rgba(25, 198, 214, 0.12);
}

.reader-tts-controls {
  display: none !important;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid rgba(56, 114, 165, 0.14);
  background: rgba(255, 255, 255, 0.5);
}

.reader-tts-controls[hidden] {
  display: none !important;
}

.reader-tts-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.reader-tts-label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.reader-tts-buttons {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

.reader-tts-button {
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(56, 114, 165, 0.18);
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
}

.reader-tts-config {
  align-items: flex-end;
}

.reader-tts-field {
  display: grid;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--muted);
}

.reader-tts-field select {
  min-height: 32px;
  min-width: 92px;
  padding: 4px 8px;
  border-radius: 10px;
  border: 1px solid rgba(56, 114, 165, 0.2);
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
  font: inherit;
}

.reader-tts-voice select {
  min-width: 210px;
}

.reader-tts-engine select {
  min-width: 160px;
}

.reader-tts-status {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.nav-home-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(56, 114, 165, 0.16);
  background: rgba(255, 255, 255, 0.62);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 700;
  white-space: nowrap;
}

.nav-tts-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(56, 114, 165, 0.16);
  background: rgba(127, 144, 161, 0.32);
  color: rgba(16, 32, 50, 0.72);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  opacity: 0.8;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease,
    opacity 160ms ease;
}

.nav-home-link:hover {
  background: rgba(25, 198, 214, 0.12);
  border-color: rgba(25, 198, 214, 0.32);
}

.nav-tts-toggle:hover {
  background: rgba(25, 198, 214, 0.12);
  border-color: rgba(25, 198, 214, 0.32);
}

.nav-tts-toggle.is-active {
  background: linear-gradient(135deg, #dffbff 0%, #8de9ff 100%);
  border-color: rgba(22, 180, 255, 0.58);
  color: #06263d;
  box-shadow:
    0 8px 18px rgba(22, 180, 255, 0.24),
    0 0 0 2px rgba(95, 224, 255, 0.22);
  opacity: 1;
}

.inline-lang-switcher {
  gap: 4px;
  padding: 3px;
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(56, 114, 165, 0.24);
  box-shadow:
    0 10px 24px rgba(16, 32, 50, 0.08),
    inset 0 0 0 1px rgba(95, 224, 255, 0.08);
}

.inline-lang-switcher .lang-link {
  padding: 6px 10px;
  color: #30475f;
  font-size: 0.84rem;
  font-weight: 700;
  border-color: rgba(56, 114, 165, 0.08);
}

.inline-lang-switcher .lang-link.active {
  color: #06263d;
  background: linear-gradient(135deg, #dffbff 0%, #8de9ff 100%);
  border-color: rgba(22, 180, 255, 0.52);
  box-shadow:
    0 8px 18px rgba(22, 180, 255, 0.2),
    0 0 0 2px rgba(95, 224, 255, 0.22),
    inset 0 0 0 1px rgba(255, 255, 255, 0.44);
}

.inline-lang-switcher .lang-link:hover,
.inline-lang-switcher .lang-link:focus-visible {
  color: #18324e;
  background: rgba(95, 224, 255, 0.18);
  border-color: rgba(95, 224, 255, 0.24);
}

.reader-side-head {
  margin-bottom: 10px;
}

.reader-side-head h2 {
  margin: 0;
  font-size: 1rem;
}

.toc {
  display: grid;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(38, 83, 126, 0.62) rgba(255, 255, 255, 0.16);
  padding: 8px 6px 0 0;
  border-top: 1px solid rgba(56, 114, 165, 0.12);
}

.toc::-webkit-scrollbar {
  width: 12px;
}

.toc::-webkit-scrollbar-track {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.26);
}

.toc::-webkit-scrollbar-thumb {
  border: 2px solid rgba(250, 252, 255, 0.9);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(70, 124, 175, 0.9), rgba(38, 83, 126, 0.82));
}

.toc::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(85, 145, 201, 0.96), rgba(47, 99, 150, 0.9));
}

.toc a {
  display: block;
  padding: 10px 12px;
  border-radius: 12px;
  text-decoration: none;
  color: #1d3150;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid transparent;
  line-height: 1.4;
  font-weight: 600;
}

.toc a.active {
  border-color: rgba(25, 198, 214, 0.35);
  background: rgba(25, 198, 214, 0.1);
}

.reader-main {
  min-height: 0;
  height: 100%;
  background: rgba(255, 253, 249, 0.96);
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  z-index: 1;
  scroll-padding-top: 24px;
}

.reader-scroll {
  --reader-font-scale: 1;
  width: 100%;
  min-height: 100%;
  padding: 38px 28px 40px;
  font-size: calc(1rem * var(--reader-font-scale));
}

.reader-scroll .reader-section + .reader-section {
  margin-top: 26px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

.reader-section-title {
  margin: 0 0 18px;
  color: var(--ink);
  font-size: 1.55em;
  line-height: 1.2;
  font-family: var(--font-reader);
  font-weight: 700;
}

.reader-section {
  content-visibility: auto;
  contain-intrinsic-size: 960px;
  scroll-margin-top: 24px;
}

.reader-prose {
  color: var(--ink);
  font-size: 1em;
  line-height: 1.82;
  overflow-wrap: anywhere;
  font-family: var(--font-reader);
  font-weight: 400;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

.reader-prose :where(
  h1,
  h2,
  h3,
  h4,
  h5,
  h6,
  p,
  span,
  a,
  li,
  div,
  blockquote,
  strong,
  em,
  b,
  i
) {
  font-family: inherit !important;
}

.reader-prose > :first-child {
  margin-top: 0;
}

.reader-prose :where(img, svg, video, audio, canvas, iframe) {
  max-width: 100%;
  height: auto;
}

.reader-prose :where(svg, canvas) {
  height: auto;
}

.reader-prose :where(table) {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}

.reader-prose :where(p, ul, ol, blockquote) {
  max-width: 100%;
  margin-top: 0;
  margin-bottom: 0.95em;
}

.reader-prose :where(a) {
  color: inherit;
  text-decoration: none;
}

.reader-prose :where(p:last-child, ul:last-child, ol:last-child, blockquote:last-child) {
  margin-bottom: 0;
}

.reader-toolbar {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: rgba(255, 255, 255, 0.72);
}

.toolbar-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 920px) {
  body {
    padding: 18px;
  }

  .site-bar-inner,
  .site-nav-panel,
  .hero,
  .reader-shell {
    grid-template-columns: 1fr;
  }

  .site-bar-inner {
    display: grid;
  }

  .site-nav-panel {
    display: grid;
  }

  .site-nav-start {
    width: 100%;
  }

  .site-nav-actions {
    justify-content: flex-start;
  }

  .reader-side {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .reader-shell {
    height: auto;
  }

  .reader-side,
  .reader-main {
    overflow: visible;
  }

  .reader-side {
    padding: 16px;
  }

  .reader-nav-controls {
    gap: 10px;
  }

  .reader-nav-main-line {
    gap: 6px;
  }

  .reader-nav-main-line .inline-lang-switcher .lang-link {
    min-height: 28px;
    min-width: 48px;
    padding: 0 8px;
    font-size: 0.8rem;
  }

  .reader-nav-main-line .nav-home-link,
  .reader-nav-main-line .nav-tts-toggle {
    min-height: 34px;
    min-width: 52px;
    padding: 0 10px;
    font-size: 0.8rem;
  }

  .reader-font-controls {
    display: grid !important;
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 12px;
    width: 100%;
    padding: 12px;
  }

  .reader-font-controls > * {
    min-width: 0;
  }

  .reader-font-label {
    font-size: 0.92rem;
    line-height: 1.2;
  }

  .reader-font-buttons {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    width: 100% !important;
    gap: 8px;
    min-width: 0;
  }

  .reader-font-button {
    width: 100% !important;
    min-width: 0 !important;
    padding: 8px 0;
  }

  .reader-tts-row {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .reader-tts-buttons {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .reader-tts-button {
    width: 100%;
    min-width: 0;
    text-align: center;
  }

  .reader-tts-voice select {
    min-width: 0;
    width: 100%;
  }

  .reader-tts-engine select {
    min-width: 0;
    width: 100%;
  }

  .toc {
    max-height: 48vh;
  }

  .reader-main {
    background: transparent;
  }

  .reader-scroll {
    padding: 16px 16px 28px;
    font-size: calc(0.98rem * var(--reader-font-scale));
  }

  .reader-scroll .reader-section + .reader-section {
    margin-top: 20px;
    padding-top: 20px;
  }

  .reader-section-title {
    margin-bottom: 14px;
    font-size: 1.22em;
    line-height: 1.3;
  }

  .reader-prose {
    font-size: 1em;
    line-height: 1.74;
    overflow-wrap: break-word;
  }

  .reader-prose :where(p, ul, ol, blockquote) {
    margin-top: 0.85em;
    margin-bottom: 0.85em;
  }

  .reader-prose :where(table) {
    font-size: 0.94em;
  }

  .section-head {
    align-items: stretch;
  }

  .library-search {
    width: 100%;
  }

}

@media (max-width: 1320px) {
  .catalog-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 1120px) {
  .catalog-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 920px) {
  .catalog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

