:root {
  color-scheme: light dark;
  --bg: #ece7dc;
  --panel: #24282b;
  --panel-soft: #30363a;
  --ink: #272522;
  --muted: #77716a;
  --paper: #fffaf0;
  --rule: rgba(39, 37, 34, 0.14);
  --accent: #2d6cdf;
  --accent-2: #b24f32;
  --radius: 8px;
  --ui-font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --reader-font: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  font-family: var(--ui-font);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.32), transparent 36%),
    var(--bg);
  color: var(--ink);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

body.drawer-open {
  overflow: hidden;
}

a {
  color: inherit;
}

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

.library-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 24px 22px;
  color: #f4f2eb;
  background:
    linear-gradient(160deg, rgba(45, 108, 223, 0.22), transparent 38%),
    linear-gradient(25deg, rgba(178, 79, 50, 0.24), transparent 42%),
    var(--panel);
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  box-shadow: 18px 0 48px rgba(17, 19, 21, 0.16);
}

.drawer-backdrop,
.drawer-close,
.mobile-menu-button {
  display: none;
}

.brand-stack {
  display: grid;
  gap: 12px;
}

.brand-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-title {
  margin: 0;
  color: rgba(244, 242, 235, 0.96);
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.025em;
  white-space: nowrap;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mark {
  width: 48px;
  aspect-ratio: 1;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: white;
  background: #111315;
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark-img {
  object-fit: contain;
  padding: 0;
  background: rgba(17, 19, 21, 0.68);
}

.eyebrow,
.label {
  margin: 0 0 4px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.eyebrow:empty {
  display: none;
}

.library-panel .eyebrow,
.library-panel .label,
.library-panel .muted {
  color: rgba(244, 242, 235, 0.68);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.3rem;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.2rem, 2vw, 1.8rem);
}

.book-list {
  display: grid;
  gap: 12px;
}

.universe-nav-button {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  padding: 0 14px;
  color: rgba(244, 242, 235, 0.88);
  background: rgba(255, 255, 255, 0.08);
  text-align: left;
  font-weight: 700;
}

.universe-nav-button.active,
.universe-nav-button:hover,
.universe-nav-button:focus-visible {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.48);
  background: rgba(255, 255, 255, 0.14);
}

.library-status {
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  color: rgba(244, 242, 235, 0.78);
  background: rgba(255, 255, 255, 0.06);
}

.book-card {
  width: 100%;
  min-height: 144px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  padding: 16px;
  color: inherit;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.045));
  text-align: left;
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 16px;
  align-items: center;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.book-card.active {
  border-color: rgba(255, 255, 255, 0.7);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.17), rgba(255, 255, 255, 0.07));
}

.book-card.planned {
  opacity: 0.72;
}

.book-card:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.44);
}

.book-cover {
  width: 76px;
  aspect-ratio: 2 / 3;
  display: block;
  border-radius: 4px;
  background: linear-gradient(155deg, #0c0f12, #2d6cdf 55%, #b24f32);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.book-card:nth-child(2) .book-cover {
  background: linear-gradient(155deg, #17130f, #7b8f67 52%, #c68f3c);
}

.book-cover.has-image {
  background: #111315;
}

.book-cover-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.book-card h3 {
  margin: 0 0 4px;
  font-size: 1.04rem;
}

.book-subtitle {
  margin-bottom: 6px;
}

.book-card p {
  margin: 0;
  font-size: 0.86rem;
  color: rgba(244, 242, 235, 0.72);
}

.sync-panel {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.16);
}

.annotations-panel {
  display: grid;
  gap: 10px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.count-badge {
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: rgba(244, 242, 235, 0.88);
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.78rem;
}

.annotations-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 2px;
}

.annotations-empty {
  margin: 0;
  color: rgba(244, 242, 235, 0.62);
  font-size: 0.88rem;
}

.annotation-item {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
}

.annotation-title,
.annotation-ref,
.annotation-note {
  margin: 0;
}

.annotation-title {
  color: #ffffff;
  font-size: 0.88rem;
  font-weight: 700;
}

.annotation-ref {
  color: rgba(244, 242, 235, 0.66);
  font-size: 0.76rem;
}

.annotation-note {
  margin-top: 6px;
  color: rgba(244, 242, 235, 0.86);
  font-size: 0.84rem;
  line-height: 1.38;
}

.annotation-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.annotation-delete,
.annotation-email {
  width: fit-content;
  min-height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  padding: 0 10px;
  color: rgba(244, 242, 235, 0.82);
  background: rgba(0, 0, 0, 0.16);
  font-size: 0.8rem;
}

.annotation-email {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.annotation-email:hover,
.annotation-email:focus-visible {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.32);
}

.reader-area {
  --content-width: 980px;
  --reader-copy-width: 68ch;
  min-width: 0;
  min-height: 100vh;
  padding: 28px clamp(20px, 4vw, 64px);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 14px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.42), transparent 38%),
    transparent;
}

.reader-area[data-view="overview"] {
  --content-width: 980px;
  --reader-copy-width: 68ch;
}

.reader-area[data-view="reading"] {
  --content-width: 980px;
  --reader-copy-width: 68ch;
}

.reader-area[data-view="universe"] {
  --content-width: 980px;
  --reader-copy-width: 68ch;
}

.reader-area[data-view="translations"] {
  --content-width: 980px;
  --reader-copy-width: 68ch;
}

.reader-area[data-view="notes"] {
  --content-width: 980px;
  --reader-copy-width: 68ch;
}

.reader-toolbar,
.settings-panel,
.progress-footer {
  width: min(100%, var(--content-width));
  justify-self: center;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.toolbar-actions,
.segmented {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar-actions[hidden] {
  display: none;
}

.reader-heading {
  min-width: 0;
  flex: 1 1 auto;
}

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

#currentBook {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.2rem, 2vw, 1.8rem);
  font-weight: 800;
  letter-spacing: 0.015em;
  line-height: 1.08;
}

.header-controls {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
  margin-left: auto;
  flex-wrap: wrap;
}

.reader-title-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.reader-title-row h2 {
  min-width: 0;
}

.tool-button,
.icon-button,
.icon-text-button,
.segmented button {
  min-height: 40px;
  border: 1px solid rgba(40, 38, 34, 0.16);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
  color: rgba(40, 38, 34, 0.92);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.62) inset, 0 8px 18px rgba(44, 37, 26, 0.06);
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.tool-button,
.icon-text-button,
.segmented button {
  padding: 0 14px;
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 1.35rem;
}

.mobile-menu-button {
  min-height: 40px;
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  color: rgba(96, 90, 80, 0.98);
  background: transparent;
  box-shadow: none;
  opacity: 1;
  appearance: none;
  line-height: 1;
  transition: opacity 150ms ease;
  -webkit-tap-highlight-color: transparent;
}

.mobile-menu-button:hover {
  color: rgba(40, 38, 34, 0.96);
  background: transparent;
  box-shadow: none;
  opacity: 1;
  transform: none;
}

.mobile-menu-button:active,
.mobile-menu-button:focus {
  color: rgba(40, 38, 34, 0.96);
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  transform: none;
}

.mobile-menu-button:focus-visible {
  outline: 2px solid rgba(45, 108, 223, 0.42);
  outline-offset: 3px;
}

.tool-button:hover,
.icon-button:hover,
.icon-text-button:hover,
.segmented button:hover {
  transform: translateY(-1px);
  border-color: rgba(45, 108, 223, 0.34);
}

.tool-button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
  transform: none;
}

.primary,
.segmented button.active {
  color: white;
  background: var(--accent);
  border-color: var(--accent);
}

.subtle {
  background: transparent;
}

.settings-panel {
  display: grid;
  gap: 8px;
}

.settings-icon-button {
  width: 42px;
  min-height: 42px;
  display: inline-grid;
  align-items: center;
  place-items: center;
  border: 0;
  padding: 0;
  font-size: 1rem;
  font-weight: 800;
  background: transparent;
  box-shadow: none;
  flex: 0 0 auto;
  line-height: 1;
  color: rgba(40, 38, 34, 0.9);
  opacity: 1;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.settings-icon {
  display: block;
  opacity: 1;
  transition: opacity 150ms ease, filter 150ms ease;
}

.settings-icon svg {
  width: 1.9rem;
  height: 1.9rem;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 150ms ease, stroke 150ms ease;
}

.settings-icon-button svg,
.settings-icon-button svg * {
  fill: none;
  stroke: currentColor;
  opacity: 1;
}

.settings-icon-button[aria-expanded="true"] {
  color: rgba(40, 38, 34, 0.9);
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.settings-icon-button[aria-expanded="true"] .settings-icon {
  opacity: 1;
}

.settings-icon-button[aria-expanded="true"] .settings-icon svg {
  transform: rotate(18deg);
}

.settings-icon-button:hover {
  color: rgba(40, 38, 34, 0.9);
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  transform: none;
}

.settings-icon-button:hover .settings-icon {
  opacity: 1;
}

.settings-icon-button:active {
  color: rgba(40, 38, 34, 0.9);
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  transform: none;
}

.settings-icon-button:focus,
.settings-icon-button:focus-visible {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  transform: none;
}

.settings-icon-button:focus-visible {
  outline: 2px solid rgba(45, 108, 223, 0.42);
  outline-offset: 3px;
}

.controls-strip {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 10px 12px 12px;
  border: 1px solid rgba(40, 38, 34, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.42);
  flex-wrap: wrap;
}

.controls-strip[hidden] {
  display: none;
}

.controls-strip label {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 0.9rem;
  color: rgba(40, 38, 34, 0.76);
}

.controls-strip input[type="range"] {
  width: 130px;
  accent-color: var(--accent);
}

.reader-page {
  width: min(100%, var(--content-width));
  min-height: clamp(430px, 66vh, 760px);
  justify-self: center;
  padding: clamp(22px, 3.2vw, 42px) clamp(28px, 6vw, 78px) clamp(34px, 6vw, 74px);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 24px 80px rgba(44, 37, 26, 0.17);
  font-family: var(--reader-font);
  font-size: var(--reader-font-size, 19px);
  line-height: var(--reader-line-height, 1.65);
  overflow-wrap: anywhere;
}

.reader-page[data-view="universe"] {
  padding-top: clamp(16px, 1.8vw, 24px);
}

.reader-page h3 {
  max-width: 15ch;
  font-size: clamp(2rem, 4vw, 2.8rem);
  line-height: 1.14;
  margin-bottom: 0.8em;
  letter-spacing: 0;
}

.reader-page p {
  max-width: var(--reader-copy-width);
}

.book-fragment {
  max-width: var(--reader-copy-width);
}

.book-fragment > :first-child {
  margin-top: 0;
}

.book-fragment > :last-child {
  margin-bottom: 0;
}

.book-fragment section {
  margin: 0 0 1.4em;
}

.book-fragment h2,
.book-fragment h3 {
  max-width: var(--reader-copy-width);
}

.book-fragment h2 {
  margin: 1.25em 0 0.55em;
  color: var(--ink);
  font-size: clamp(1.35rem, 2.2vw, 1.8rem);
  font-weight: 700;
  line-height: 1.18;
}

.book-fragment h3 {
  margin: 1.1em 0 0.5em;
  color: var(--ink);
  font-size: clamp(1.12rem, 1.8vw, 1.35rem);
  font-weight: 650;
  line-height: 1.22;
}

.book-fragment > h2:first-child,
.book-fragment > h3:first-child,
.book-fragment section:first-child > h2:first-child,
.book-fragment section:first-child > h3:first-child {
  margin-top: 0.2em;
}

.book-fragment blockquote,
.book-fragment .memo,
.book-fragment .letter,
.book-fragment .song {
  max-width: var(--reader-copy-width);
  margin: 1.2em 0;
  padding: 0.9em 1.05em;
  border-left: 3px solid color-mix(in srgb, var(--accent-2), transparent 18%);
  background: color-mix(in srgb, var(--paper), var(--ink) 5%);
}

.book-fragment blockquote p,
.book-fragment .memo p,
.book-fragment .letter p,
.book-fragment .song p {
  margin: 0.45em 0;
}

.book-fragment .fade-in {
  opacity: 0.78;
  font-style: italic;
}

.book-fragment .centered {
  text-align: center;
}

.book-fragment .song {
  font-style: italic;
}

.book-landing-subtitle {
  font-weight: 650;
}

.book-map-panel {
  max-width: var(--reader-copy-width);
  margin-top: 1.55rem;
}

.book-map-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.78rem 0;
  border: 0;
  border-top: 1px solid color-mix(in srgb, var(--ink), transparent 84%);
  border-bottom: 1px solid color-mix(in srgb, var(--ink), transparent 84%);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--ui-font);
  font-size: 0.82rem;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: none;
  cursor: pointer;
}

.book-map-toggle:hover {
  color: color-mix(in srgb, var(--accent-2), var(--ink) 26%);
}

.book-map-toggle:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent), transparent 18%);
  outline-offset: 4px;
}

.book-map-container {
  margin-top: 1.1rem;
}

.book-map {
  max-width: var(--reader-copy-width);
  font-family: var(--ui-font);
}

.book-map-list {
  display: grid;
  gap: 0.32rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.book-map-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  column-gap: 0.75rem;
  row-gap: 0.2rem;
  color: color-mix(in srgb, var(--ink), transparent 8%);
  font-size: 0.86rem;
  line-height: 1.35;
}

.book-map-entry.level-1 {
  margin-top: 0.5rem;
  color: var(--ink);
  font-weight: 780;
}

.book-map-entry.level-2 {
  padding-left: 1.15rem;
  font-weight: 620;
}

.book-map-entry.level-3 {
  padding-left: 2.15rem;
  color: color-mix(in srgb, var(--ink), transparent 20%);
}

.book-map-title {
  position: relative;
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.book-map-page {
  color: color-mix(in srgb, var(--ink), transparent 34%);
  font-variant-numeric: tabular-nums;
}

.book-map-entry.is-available .book-map-title {
  color: color-mix(in srgb, #1f8f55, var(--ink) 18%);
}

.book-map-entry.is-available {
  cursor: pointer;
}

.book-map-entry.is-available:hover .book-map-title,
.book-map-entry.is-available:focus-visible .book-map-title {
  text-decoration: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

.book-map-entry.is-available:focus-visible {
  outline: 2px solid color-mix(in srgb, #1f8f55, transparent 30%);
  outline-offset: 4px;
  border-radius: 4px;
}

.book-map-back {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: var(--reader-copy-width);
  margin: 0 0 1.05rem;
  padding: 0.2rem 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: color-mix(in srgb, var(--accent-2), var(--ink) 18%);
  font-family: var(--ui-font);
  font-size: 0.78rem;
  font-weight: 780;
  letter-spacing: 0.075em;
  line-height: 1.2;
  text-transform: uppercase;
  cursor: pointer;
}

.book-map-back:hover {
  color: color-mix(in srgb, var(--accent-2), var(--ink) 4%);
  text-decoration: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.22em;
  transform: none;
}

.book-map-back:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent), transparent 18%);
  outline-offset: 4px;
  border-radius: 4px;
}

.book-map-back:active {
  transform: none;
}

.reader-kicker {
  font-family: var(--ui-font);
  font-size: 0.72em;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.reader-page[data-view="reading"] > .reader-kicker {
  max-width: var(--reader-copy-width);
  margin-bottom: 1.45em;
  color: color-mix(in srgb, var(--accent-2), var(--ink) 18%);
  font-size: clamp(1.02rem, 2vw, 1.42rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.2;
}

.reader-location {
  max-width: var(--reader-copy-width);
  margin-bottom: 1.55em;
  font-family: var(--ui-font);
}

.reader-location .reader-location-chapter,
.reader-location .reader-location-section,
.reader-location .reader-location-episode {
  max-width: var(--reader-copy-width);
}

.reader-location .reader-location-chapter {
  margin: 0 0 0.42em;
  color: color-mix(in srgb, var(--accent-2), var(--ink) 18%);
  font-size: clamp(1.16rem, 2.25vw, 1.55rem);
  font-weight: 850;
  letter-spacing: 0.055em;
  line-height: 1.16;
  text-transform: uppercase;
}

.reader-location .reader-location-section {
  margin: 0 0 0.24em;
  color: var(--ink);
  font-size: clamp(1.02rem, 1.65vw, 1.2rem);
  font-weight: 720;
  letter-spacing: 0;
  line-height: 1.22;
}

.reader-location .reader-location-episode {
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.95rem, 1.35vw, 1.08rem);
  font-weight: 650;
  line-height: 1.28;
}

.universe-brand-hero {
  max-width: var(--reader-copy-width);
  display: grid;
  gap: 12px;
  justify-items: center;
  margin-bottom: 0.9rem;
  text-align: center;
}

.universe-brand-hero img {
  width: min(100%, 340px);
  max-height: 88px;
  object-fit: contain;
  object-position: center;
  opacity: 0.88;
}

.universe-brand-hero img:not([src]),
.universe-brand-hero img[src=""] {
  display: none;
}

[data-theme="night"] .universe-hero-hat {
  filter: invert(1) brightness(1.24) contrast(0.9);
  opacity: 0.84;
}

.universe-brand-hero h3 {
  max-width: 18ch;
  margin-bottom: 0.2em;
}

.translation-panel {
  max-width: var(--reader-copy-width);
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-family: var(--ui-font);
}

.translation-toggle {
  min-height: 34px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.58);
  font-size: 0.86rem;
}

.translation-content {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.34);
}

.translation-entry p {
  margin-bottom: 0.65rem;
}

.translation-language {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.language-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-style: italic;
}

.sample-cta {
  max-width: var(--reader-copy-width);
  margin-top: 1.6rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-family: var(--ui-font);
}

.sample-cta a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(178, 79, 50, 0.28);
  border-radius: var(--radius);
  padding: 0 14px;
  color: var(--accent-2);
  background: rgba(178, 79, 50, 0.08);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 700;
}

.sample-cta a:hover,
.sample-cta a:focus-visible {
  border-color: rgba(178, 79, 50, 0.42);
  background: rgba(178, 79, 50, 0.12);
}

.translation-filters {
  max-width: var(--reader-copy-width);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 1.5rem 0;
  font-family: var(--ui-font);
}

.translation-filters label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

.translation-filters select,
.translation-filters input {
  min-height: 40px;
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.56);
}

.translation-search {
  grid-column: 1 / -1;
}

.translation-entry-list,
.embedded-translations-content {
  max-width: var(--reader-copy-width);
  display: grid;
  gap: 12px;
  font-family: var(--ui-font);
}

.translation-entry-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.34);
}

.translation-entry-meta,
.translation-source-text,
.translation-target-text,
.translation-entry-note,
.translation-empty {
  margin: 0;
}

.translation-entry-meta {
  color: var(--accent-2);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.translation-source-text {
  color: var(--ink);
  font-family: var(--reader-font);
  font-size: 1.1rem;
  line-height: 1.45;
}

.translation-target-text {
  color: var(--ink);
  font-size: 0.96rem;
  line-height: 1.45;
}

.translation-entry-note,
.translation-empty {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.embedded-translations-panel {
  max-width: var(--reader-copy-width);
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-family: var(--ui-font);
}

.embedded-translations-content {
  margin-top: 12px;
}

.universe-grid {
  max-width: var(--reader-copy-width);
  display: grid;
  gap: 12px;
  margin-top: 1.4rem;
  font-family: var(--ui-font);
}

.universe-tabs {
  max-width: var(--reader-copy-width);
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 1.35rem;
  padding: 5px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.28);
  font-family: var(--ui-font);
}

.universe-tab {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 2px);
  padding: 0 13px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}

.universe-tab.active {
  color: white;
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(45, 108, 223, 0.18);
}

.universe-tab:hover,
.universe-tab:focus-visible {
  color: var(--ink);
  border-color: rgba(45, 108, 223, 0.34);
}

.universe-tab.active:hover,
.universe-tab.active:focus-visible {
  color: white;
}

.universe-tab-panel {
  max-width: var(--reader-copy-width);
}

.art-section {
  max-width: var(--reader-copy-width);
  margin-top: 1.4rem;
  font-family: var(--ui-font);
}

.art-section h4 {
  margin: 0.2rem 0 0.35rem;
  font-family: var(--ui-font);
  font-size: clamp(1.2rem, 3vw, 1.65rem);
}

.art-section > p {
  color: var(--muted);
}

.art-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 1.1rem;
}

.art-card {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.36);
}

.art-card.is-placeholder {
  background: rgba(255, 255, 255, 0.24);
}

.art-media,
.art-audio,
.art-placeholder {
  min-height: 150px;
  margin: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(21, 22, 23, 0.08), rgba(178, 79, 50, 0.12));
}

.art-media img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}

.art-media figcaption {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.art-media.is-missing img {
  display: none;
}

.art-media.is-missing::after,
.art-placeholder {
  content: "Coming later";
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.art-audio {
  padding: 18px;
}

.art-audio audio {
  width: 100%;
}

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

.art-card-body h5,
.art-card-body p {
  margin: 0;
}

.art-card-body h5 {
  font-size: 1rem;
  line-height: 1.2;
}

.art-card-body p,
.art-note {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.art-card-meta {
  color: var(--accent-2);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.art-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.art-tags span,
.art-download {
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.45);
  font-size: 0.74rem;
  font-weight: 700;
  text-decoration: none;
}

.universe-card {
  display: grid;
  gap: 5px;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  color: inherit;
  background: rgba(255, 255, 255, 0.36);
  text-decoration: none;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.universe-card:hover,
.universe-card:focus-visible {
  border-color: rgba(45, 108, 223, 0.36);
  background: rgba(255, 255, 255, 0.5);
  transform: translateY(-1px);
}

.universe-card-main {
  color: inherit;
  text-decoration: none;
}

.universe-card-main:hover,
.universe-card-main:focus-visible {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.universe-card-title {
  font-weight: 800;
}

.universe-card-description,
.universe-card-url {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.universe-card-url {
  color: var(--accent-2);
}

.universe-platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.universe-platform-link {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.5);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 700;
}

.universe-platform-link:hover,
.universe-platform-link:focus-visible {
  border-color: rgba(45, 108, 223, 0.38);
  background: rgba(255, 255, 255, 0.72);
}

.progress-footer {
  color: var(--muted);
  font-size: 0.9rem;
  padding-bottom: 2px;
}

.progress-footer > div {
  flex: 1;
}

.progress-track {
  height: 6px;
  margin-top: 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent-2);
}

dialog {
  width: min(92vw, 520px);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--paper);
  color: var(--ink);
}

.note-context {
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.42);
}

.note-reference {
  margin: 0;
  font-weight: 700;
}

.field-label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.field-label input,
.field-label textarea {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.66);
  color: var(--ink);
}

textarea {
  width: 100%;
  resize: vertical;
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0;
  margin-bottom: 0;
}

[data-theme="sepia"] {
  --bg: #dfd0b7;
  --paper: #f6ead3;
  --ink: #352b1d;
  --muted: #7b6650;
}

[data-theme="night"] {
  --bg: #111315;
  --paper: #1d2023;
  --ink: #e8e2d5;
  --muted: #c1b7a9;
  --rule: rgba(232, 226, 213, 0.16);
  --accent-2: #da8b69;
}

[data-theme="night"] .reader-page {
  color: var(--ink);
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.32);
}

[data-theme="night"] .reader-page h3,
[data-theme="night"] .art-section h4,
[data-theme="night"] .art-card-body h5,
[data-theme="night"] .universe-card-title,
[data-theme="night"] .translation-source-text,
[data-theme="night"] .translation-target-text {
  color: #f1eadf;
}

[data-theme="night"] .reader-page[data-view="translations"] > p:not(.reader-kicker),
[data-theme="night"] .universe-brand-hero p,
[data-theme="night"] .art-section > p,
[data-theme="night"] .art-card-body p,
[data-theme="night"] .art-note,
[data-theme="night"] .universe-card-description,
[data-theme="night"] .translation-filters label,
[data-theme="night"] .translation-entry-note,
[data-theme="night"] .translation-empty {
  color: var(--muted);
}

@media (max-width: 900px) {
  .app-shell {
    display: block;
  }

  .library-panel {
    position: fixed;
    z-index: 30;
    inset: 0 auto 0 0;
    width: min(86vw, 340px);
    height: 100dvh;
    padding: 20px 20px 22px;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: 18px 0 48px rgba(17, 19, 21, 0.26);
  }

  .app-shell.menu-open .library-panel {
    transform: translateX(0);
  }

  .drawer-backdrop {
    position: fixed;
    z-index: 20;
    inset: 0;
    display: block;
    background: rgba(17, 19, 21, 0.42);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  .drawer-backdrop[hidden] {
    display: none;
  }

  .app-shell.menu-open .drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .drawer-close {
    width: 36px;
    height: 36px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.04);
    font-size: 1.25rem;
    line-height: 1;
    outline: none;
    box-shadow: none;
  }

  .drawer-close:hover {
    border-color: rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.08);
  }

  .drawer-close:focus-visible {
    border-color: rgba(244, 242, 235, 0.36);
    box-shadow: 0 0 0 2px rgba(244, 242, 235, 0.16);
  }

  .brand-title {
    min-width: 0;
    font-size: 1.06rem;
    letter-spacing: 0.015em;
  }

  .mobile-menu-button {
    width: 44px;
    min-height: 44px;
    padding: 0;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    font-size: 1.28rem;
    align-self: start;
    transform: translateY(-2px);
  }

  .mobile-menu-button:hover,
  .mobile-menu-button:active,
  .mobile-menu-button:focus {
    transform: translateY(-2px);
  }

  .reader-area {
    min-height: auto;
    width: 100%;
    padding-inline: 16px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }

  .reader-toolbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
  }

  .reader-title-row {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .settings-icon-button {
    width: 44px;
    min-height: 44px;
  }

  .reader-toolbar,
  .settings-panel,
  .progress-footer {
    width: 100%;
  }

  .reader-page {
    width: 100%;
    min-height: 420px;
    padding: 18px 20px 24px;
  }

  .reader-page[data-view="universe"] {
    padding-top: 9px;
  }

  .reader-page h3 {
    max-width: 100%;
  }

  .translation-filters {
    grid-template-columns: 1fr;
  }

  .universe-tabs {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .universe-tab {
    padding-inline: 8px;
  }

  .art-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .reader-toolbar {
    gap: 8px;
    align-items: center;
  }

  #currentBook {
    font-size: clamp(1rem, 5.4vw, 1.32rem);
    letter-spacing: 0.01em;
    line-height: 1.05;
  }

  .reader-eyebrow-row {
    gap: 8px;
  }

  .header-controls,
  .toolbar-actions {
    gap: 5px;
  }

  .tool-button,
  .icon-text-button,
  .segmented button {
    min-height: 40px;
    padding-inline: 9px;
    font-size: 0.86rem;
  }

  .icon-button {
    width: 40px;
    min-height: 40px;
    font-size: 1.12rem;
  }

  .settings-icon-button {
    width: 40px;
    min-height: 40px;
  }

  .settings-icon svg {
    width: 1.62rem;
    height: 1.62rem;
  }

  .reader-kicker {
    font-size: 0.62em;
    letter-spacing: 0.055em;
    line-height: 1.35;
  }

  .reader-page[data-view="reading"] > .reader-kicker {
    margin-bottom: 1.05em;
    font-size: clamp(0.95rem, 4.6vw, 1.16rem);
    letter-spacing: 0.045em;
    line-height: 1.18;
  }

  .reader-location {
    margin-bottom: 1.15em;
  }

  .reader-location .reader-location-chapter {
    font-size: clamp(1rem, 4.8vw, 1.18rem);
    letter-spacing: 0.035em;
  }

  .reader-location .reader-location-section {
    font-size: clamp(0.94rem, 4.4vw, 1.06rem);
  }

  .reader-location .reader-location-episode {
    font-size: clamp(0.9rem, 4.1vw, 1rem);
  }

  .book-fragment h2 {
    font-size: clamp(1.16rem, 5.2vw, 1.36rem);
  }

  .book-fragment h3 {
    font-size: clamp(1.02rem, 4.6vw, 1.16rem);
  }

  .book-map-panel {
    margin-top: 1.25rem;
  }

  .book-map-entry {
    font-size: 0.8rem;
    column-gap: 0.55rem;
  }

  .book-map-entry.level-2 {
    padding-left: 0.75rem;
  }

  .book-map-entry.level-3 {
    padding-left: 1.35rem;
  }

}

@media (max-width: 420px) {
  .book-card {
    min-height: 112px;
    grid-template-columns: 60px 1fr;
    gap: 12px;
    padding: 14px;
  }

  .book-cover {
    width: 60px;
  }
}
