:root {
  --surface: #f7f7f3;
  --surface-top: #fafaf7;
  --surface-bottom: #f3f5f7;
  --surface-soft: #f1f4f7;
  --ink: #1f2328;
  --muted: #667085;
  --paper: #fff;
  --line: #d7dce2;
  --line-strong: #b9c1cc;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-border: rgba(215, 220, 226, 0.9);
  --accent: #2f6fed;
  --accent-soft: #eaf2ff;
  --accent-2: #c4513e;
  --warm-soft: #fcedea;
  --control-bg: rgba(255, 255, 255, 0.92);
  --control-muted-bg: rgba(31, 35, 40, 0.04);
  --control-hover-bg: rgba(47, 111, 237, 0.1);
  --shadow-chrome: 0 8px 24px rgba(31, 35, 40, 0.08);
  --shadow-soft: 0 2px 8px rgba(31, 35, 40, 0.06);
  --shadow-page: 0 12px 30px rgba(31, 35, 40, 0.12);
  --focus-ring: 0 0 0 3px rgba(47, 111, 237, 0.14);
  --setup-label-gap: 5px;
  --blend-position: 0%;
  --blend-pointer-x: 0px;
  --language-count: 2;
  --select-chevron-color: var(--muted);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  color: var(--ink);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  letter-spacing: 0;
  background: var(--surface);
}

body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background: linear-gradient(180deg, var(--surface-top) 0%, var(--surface-bottom) 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

.reader-chrome {
  position: fixed;
  top: 10px;
  left: 50%;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: min(760px, calc(100vw - 20px));
  min-height: 48px;
  padding: 6px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: var(--shadow-chrome);
  backdrop-filter: blur(12px);
  transform: translateX(-50%);
  transition:
    width 160ms ease,
    max-width 160ms ease,
    gap 160ms ease;
}

.reader-chrome.is-language-rail-hidden .language-switcher,
.reader-chrome.is-language-rail-hidden .autoplay-toggle {
  width: 0;
  min-width: 0;
  max-width: 0;
  padding-right: 0;
  padding-left: 0;
  overflow: hidden;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 190ms ease-out,
    width 0s linear 190ms,
    min-width 0s linear 190ms,
    max-width 0s linear 190ms,
    padding 0s linear 190ms,
    border-color 0s linear 190ms,
    background-color 0s linear 190ms,
    visibility 0s linear 190ms;
}

.reader-chrome.is-language-rail-hidden .autoplay-toggle {
  border-color: transparent;
}

.reader-brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
  padding: 0 10px;
  font-size: 0.9rem;
  font-weight: 650;
  white-space: nowrap;
  transition:
    gap 150ms ease,
    padding 150ms ease;
}

.reader-brand span:last-child {
  display: inline-block;
  max-width: 84px;
  overflow: hidden;
  opacity: 1;
  transform: translateX(0);
  transition:
    opacity 150ms ease,
    max-width 150ms ease,
    transform 150ms ease;
}

.reader-logo {
  display: block;
  width: 30px;
  height: 30px;
  object-fit: contain;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
}

.language-switcher {
  --rail-pointer-width: 36px;

  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--language-count), minmax(0, 1fr));
  width: 100%;
  min-width: 0;
  max-width: min(460px, 100%);
  justify-self: end;
  gap: 3px;
  padding: 3px;
  background: var(--surface-soft);
  border-radius: 8px;
  visibility: visible;
  opacity: 1;
  transition:
    opacity 150ms ease-out 120ms,
    visibility 0s linear 0s;
}

.language-switcher::after {
  position: absolute;
  z-index: 2;
  bottom: 4px;
  left: 0;
  width: var(--rail-pointer-width);
  height: 3px;
  content: "";
  pointer-events: none;
  background: var(--accent);
  border-radius: 999px;
  transform: translate3d(var(--blend-pointer-x), 0, 0);
  transition:
    opacity 120ms ease;
  will-change: transform;
}

.reader-chrome.is-language-rail-hidden .language-switcher::after {
  opacity: 0;
}

.blend-button {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  background: transparent;
  border: 0;
  border-radius: 6px;
}

.blend-button-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  gap: 4px;
  overflow: hidden;
}

.blend-button-marker,
.blend-button-code {
  min-width: 0;
}

.blend-button-code {
  overflow: hidden;
  text-overflow: ellipsis;
}

.language-switcher,
.blend-button,
.blend-button-label,
.reader-brand,
.reader-logo,
.autoplay-toggle,
.page-list,
.reader-page,
.image-stack,
.page-layer,
.missing-layer,
.page-meta,
.reader-hint {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.blend-button:hover,
.blend-button:focus-visible,
.blend-button.is-active {
  color: var(--ink);
  background: var(--accent-soft);
}

.blend-button:focus-visible {
  outline: 0;
  box-shadow: var(--focus-ring);
  outline-offset: -2px;
}

.autoplay-toggle {
  width: 58px;
  max-width: 58px;
  height: 34px;
  padding: 0 10px;
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  cursor: pointer;
  background: var(--control-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  visibility: visible;
  opacity: 1;
  transition:
    opacity 150ms ease-out 120ms,
    border-color 150ms ease,
    background-color 150ms ease,
    visibility 0s linear 0s;
}

.autoplay-toggle:hover,
.autoplay-toggle:focus-visible,
.autoplay-toggle.is-active {
  background: var(--accent-soft);
}

.autoplay-toggle:focus-visible {
  border-color: var(--accent);
  outline: 0;
  box-shadow: var(--focus-ring);
}

.autoplay-toggle:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.56;
  background: var(--control-muted-bg);
}

.app-toast {
  position: fixed;
  right: auto;
  bottom: 68px;
  left: 50%;
  z-index: 25;
  max-width: min(300px, calc(100vw - 24px));
  padding: 8px 12px;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
  pointer-events: none;
  background: rgba(31, 35, 40, 0.92);
  border-radius: 8px;
  box-shadow: var(--shadow-chrome);
  opacity: 0;
  transform: translate(-50%, 6px);
  transition:
    opacity 150ms ease,
    transform 150ms ease;
}

.app-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.reader-shell {
  width: min(1040px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 82px clamp(10px, 3vw, 28px) 120px;
}

.chapter-meta {
  position: relative;
  width: min(760px, 100%);
  min-width: 0;
  margin: 0 auto 18px;
  scroll-margin-top: 82px;
  overflow-wrap: anywhere;
}

.work-picker,
.language-picker label {
  display: grid;
  gap: var(--setup-label-gap);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
}

.work-picker {
  position: relative;
  width: min(420px, 100%);
  min-width: 0;
  margin-top: 12px;
}

.select-shell {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
}

.select-chevron {
  position: absolute;
  right: 10px;
  top: 50%;
  z-index: 2;
  display: block;
  width: 10px;
  height: 6px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--select-chevron-color) 50%),
    linear-gradient(135deg, var(--select-chevron-color) 50%, transparent 50%);
  background-repeat: no-repeat;
  background-position:
    left center,
    right center;
  background-size:
    5px 5px,
    5px 5px;
  opacity: 0.72;
  pointer-events: none;
  transform: translateY(-50%);
}

.select-shell--compact {
  width: auto;
  min-width: 56px;
}

.select-shell--compact .select-chevron {
  right: 8px;
}

.language-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  width: min(760px, 100%);
  column-gap: 10px;
  row-gap: var(--setup-label-gap);
  margin-top: 10px;
  padding: 0;
  border: 0;
  min-inline-size: 0;
}

.language-picker legend {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 5px;
  grid-column: 1 / -1;
  width: 100%;
  max-width: 100%;
  margin-bottom: 3px;
  padding: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
}

.language-legend-title {
  white-space: nowrap;
}

.chosen-language-slot {
  position: relative;
  min-width: 0;
}

.chosen-slot-number {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.chosen-slot-display {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  height: 36px;
  gap: 7px;
  padding: 0 28px 0 10px;
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1;
  overflow: hidden;
  background: var(--control-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.chosen-slot-display::after {
  position: absolute;
  top: 50%;
  right: 10px;
  width: 10px;
  height: 6px;
  content: "";
  background-image:
    linear-gradient(45deg, transparent 50%, var(--select-chevron-color) 50%),
    linear-gradient(135deg, var(--select-chevron-color) 50%, transparent 50%);
  background-repeat: no-repeat;
  background-position:
    left center,
    right center;
  background-size:
    5px 5px,
    5px 5px;
  opacity: 0.72;
  pointer-events: none;
  transform: translateY(-50%);
}

.chosen-slot-display-language {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.work-picker select,
.interest-panel input,
.interest-panel select,
.interest-panel textarea {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  background: var(--control-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.work-picker select,
.interest-panel select {
  position: relative;
  z-index: 1;
  height: 36px;
  padding: 0 30px 0 10px;
  font-weight: 600;
}

.chosen-language-slot select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.chosen-language-slot:focus-within .chosen-slot-display {
  border-color: var(--accent);
  outline: 0;
  box-shadow: var(--focus-ring);
}

.work-picker select:focus-visible,
.language-picker select:focus-visible,
.explanation-language-toggle:focus-visible,
.explanation-language-option:focus-visible,
.reader-intro-help-toggle:focus-visible,
.reader-intro-dismiss:focus-visible,
.interest-panel input:focus-visible,
.interest-panel select:focus-visible,
.interest-panel textarea:focus-visible {
  border-color: var(--accent);
  outline: 0;
  box-shadow: var(--focus-ring);
}

.reader-intro {
  position: relative;
  display: flex;
  align-items: center;
  width: min(760px, 100%);
  min-width: 0;
  gap: 6px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.25;
}

.reader-intro-copy {
  min-width: 0;
}

.reader-intro-help-toggle,
.reader-intro-dismiss {
  display: grid;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  place-items: center;
  padding: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
}

.reader-intro-help-toggle:hover,
.reader-intro-help-toggle[aria-expanded="true"],
.reader-intro-dismiss:hover {
  color: var(--ink);
  background: var(--control-hover-bg);
}

.reader-intro-help {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 18;
  width: max-content;
  max-width: min(320px, 100%);
  padding: 8px 10px;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 650;
  line-height: 1.35;
  background: rgba(31, 35, 40, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  box-shadow: var(--shadow-chrome);
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition:
    opacity 140ms ease,
    transform 140ms ease,
    visibility 0s linear 140ms;
}

.reader-intro-help.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition:
    opacity 140ms ease,
    transform 140ms ease,
    visibility 0s linear 0s;
}

.reader-intro.is-collapsed {
  position: absolute;
  top: 9px;
  right: 0;
  z-index: 6;
  width: auto;
  margin-top: 0;
}

.reader-intro.is-collapsed .reader-intro-help {
  right: 0;
  left: auto;
  max-width: min(320px, calc(100vw - 32px));
}

.reader-intro.is-collapsed .reader-intro-copy,
.reader-intro.is-collapsed .reader-intro-dismiss {
  display: none;
}

.page-list {
  display: grid;
  min-width: 0;
  gap: clamp(18px, 4vw, 36px);
  touch-action: pan-y;
}

.reader-status {
  width: min(380px, calc(100vw - 32px));
  margin: 16vh auto 0;
  padding: 16px;
  color: var(--muted);
  text-align: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.missing-route {
  display: grid;
  width: min(540px, calc(100vw - 32px));
  gap: 12px;
  text-align: left;
}

.missing-route h2,
.missing-route p {
  margin: 0;
}

.missing-route h2 {
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.missing-route p {
  line-height: 1.45;
}

.missing-route-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.missing-route-actions button {
  min-height: 36px;
  padding: 0 12px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--control-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.missing-route-actions .secondary-action {
  color: var(--muted);
  background: var(--control-muted-bg);
}

.missing-route-actions button:hover,
.missing-route-actions button:focus-visible {
  background: var(--control-hover-bg);
}

.missing-route-actions button:focus-visible,
.continuation-request button:focus-visible,
.close-button:focus-visible,
.contact-link:focus-visible,
.interest-actions button:focus-visible {
  border-color: var(--accent);
  outline: 0;
  box-shadow: var(--focus-ring);
}

.reader-page {
  display: grid;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.image-stack {
  position: relative;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  overflow: hidden;
  touch-action: pan-y;
  cursor: ew-resize;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  aspect-ratio: var(--page-ratio, 900 / 1320);
  box-shadow: var(--shadow-page);
}

.reader-page.is-wide-page .image-stack {
  max-width: min(var(--page-natural-width, 980px), 100%);
}

.image-stack:focus-visible {
  outline: 0;
  box-shadow:
    var(--shadow-page),
    var(--focus-ring);
  outline-offset: 3px;
}

.page-layer {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  transition: none;
  opacity: 0;
  will-change: opacity;
  -webkit-user-drag: none;
}

.reader-hint {
  position: absolute;
  top: 32%;
  left: 50%;
  z-index: 12;
  display: grid;
  width: max-content;
  max-width: min(320px, calc(100% - 32px));
  gap: 4px;
  padding: 8px 10px;
  color: #fff;
  text-align: center;
  pointer-events: none;
  background: rgba(31, 35, 40, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  box-shadow: var(--shadow-chrome);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -50%);
  transition:
    opacity 160ms ease,
    visibility 0s linear 160ms;
}

.reader-hint.is-visible {
  opacity: 1;
  visibility: visible;
  transition:
    opacity 160ms ease,
    visibility 0s linear 0s;
}

.reader-hint-copy {
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1.2;
}

.reader-hint-visual {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  color: rgba(255, 255, 255, 0.9);
}

.reader-hint-visual[hidden] {
  display: none;
}

.reader-hint-visual-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 3px 6px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.66rem;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
}

.reader-hint-visual-chip.is-current {
  color: #1f2328;
  background: rgba(255, 255, 255, 0.92);
}

.reader-hint-visual-marker,
.reader-hint-visual-label {
  min-width: 0;
}

.reader-hint-visual-arrow {
  position: relative;
  flex: 0 0 22px;
  width: 22px;
  height: 1px;
  color: rgba(255, 255, 255, 0.74);
  background: currentcolor;
}

.reader-hint-visual-arrow::after {
  position: absolute;
  top: 50%;
  width: 6px;
  height: 6px;
  border-top: 1px solid currentcolor;
  border-right: 1px solid currentcolor;
  content: "";
}

.reader-hint-visual-arrow.is-forward::after {
  right: 0;
  transform: translateY(-50%) rotate(45deg);
}

.reader-hint-visual-arrow.is-back::after {
  left: 0;
  transform: translateY(-50%) rotate(225deg);
}

.reader-hint-path {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.2;
}

.missing-layer {
  display: grid;
  place-items: center;
  padding: 20px;
  color: var(--muted);
  font-size: clamp(1rem, 3vw, 1.4rem);
  font-weight: 650;
  text-align: center;
  background:
    repeating-linear-gradient(
      -45deg,
      rgba(47, 111, 237, 0.08),
      rgba(47, 111, 237, 0.08) 12px,
      rgba(196, 81, 62, 0.08) 12px,
      rgba(196, 81, 62, 0.08) 24px
    ),
    var(--warm-soft);
}

.missing-layer span {
  padding: 10px 12px;
  background: var(--control-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.page-meta {
  position: relative;
  display: block;
  width: min(760px, 100%);
  min-height: 26px;
  padding-right: 58px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.reader-page.is-wide-page .page-meta {
  width: min(var(--page-natural-width, 980px), 100%);
}

.page-meta > span {
  display: block;
  min-width: 0;
  overflow: hidden;
  line-height: 26px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-explanation-button {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: max-content;
  min-width: 0;
  min-height: 26px;
  padding: 0 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 520;
  line-height: 1;
  text-align: right;
  cursor: pointer;
  background: transparent;
  border: 0;
  border-radius: 4px;
}

.page-explanation-action {
  flex: 0 0 auto;
  min-width: 0;
}

.page-explanation-action {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-explanation-button:hover,
.page-explanation-button:focus-visible {
  color: var(--ink);
  background: transparent;
}

.page-explanation-button:focus-visible {
  outline: 0;
  box-shadow: var(--focus-ring);
}

.continuation-request {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  width: min(760px, 100%);
  gap: 8px;
  margin: 20px auto 0;
}

.continuation-request button {
  min-height: 36px;
  padding: 0 12px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--control-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.continuation-request button:hover,
.continuation-request button:focus-visible {
  background: var(--control-hover-bg);
}

#request-next-chapter {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
}

#request-next-chapter:hover,
#request-next-chapter:focus-visible {
  background: #343a42;
  border-color: #343a42;
}

.continuation-request .secondary-action {
  color: var(--muted);
  background: transparent;
}

.source-license {
  width: min(760px, 100%);
  margin: 22px auto 0;
  padding-top: 14px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.4;
  border-top: 1px solid var(--line);
}

.source-license h2 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 650;
  letter-spacing: 0;
}

.source-license h3 {
  margin: 12px 0 5px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0;
}

.source-license h2 + h3 {
  margin-top: 0;
}

.source-license .source-license-primary-subheading {
  margin-top: 12px;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 650;
}

.source-license p {
  margin: 0;
  overflow-wrap: anywhere;
}

.source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px !important;
}

.source-links a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.source-links a:hover,
.source-links a:focus-visible {
  text-decoration: underline;
}

.explanation-reference {
  margin-top: 8px !important;
  color: var(--muted);
  font-size: 0.74rem;
}

.explanation-reference a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.explanation-reference a:hover,
.explanation-reference a:focus-visible {
  text-decoration: underline;
}

.about-yomuread a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.about-yomuread a:hover,
.about-yomuread a:focus-visible {
  text-decoration: underline;
}

.privacy-note {
  margin-top: 10px !important;
}

.reader-footer {
  position: fixed;
  right: 10px;
  bottom: 10px;
  left: 10px;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  width: min(720px, calc(100vw - 20px));
  gap: 8px;
  margin: 0 auto;
  padding: 6px 8px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.2;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: var(--shadow-chrome);
  backdrop-filter: blur(12px);
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 150ms ease,
    transform 150ms ease,
    visibility 0s linear 0s;
}

.reader-footer.is-after-reader {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition:
    opacity 150ms ease,
    transform 150ms ease,
    visibility 0s linear 150ms;
}

.blend-control {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  min-width: 0;
  gap: 8px;
}

.blend-label {
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 600;
}

#blend-range {
  width: 100%;
  min-width: 0;
  accent-color: var(--accent);
}

.autoplay-control {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  gap: 6px;
}

.autoplay-control-label {
  font-weight: 600;
}

.autoplay-speed-help {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 24;
  width: max-content;
  max-width: min(260px, calc(100vw - 24px));
  padding: 7px 9px;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 650;
  line-height: 1.25;
  text-align: center;
  pointer-events: none;
  background: rgba(31, 35, 40, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  box-shadow: var(--shadow-chrome);
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition:
    opacity 140ms ease,
    transform 140ms ease,
    visibility 0s linear 140ms;
}

.autoplay-speed-help.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition:
    opacity 140ms ease,
    transform 140ms ease,
    visibility 0s linear 0s;
}

.autoplay-control select {
  position: relative;
  z-index: 1;
  height: 28px;
  min-width: 56px;
  padding: 0 26px 0 8px;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--control-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.work-picker select,
.interest-panel select,
.autoplay-control select {
  -webkit-appearance: none;
  appearance: none;
  inline-size: 100%;
  max-width: 100%;
  max-inline-size: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.interest-panel select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--select-chevron-color) 50%),
    linear-gradient(135deg, var(--select-chevron-color) 50%, transparent 50%);
  background-repeat: no-repeat;
  background-position:
    calc(100% - 15px) calc(50% + 1px),
    calc(100% - 10px) calc(50% + 1px);
  background-size:
    5px 5px,
    5px 5px;
}

.autoplay-control select:focus-visible {
  border-color: var(--accent);
  outline: 0;
  box-shadow: var(--focus-ring);
}

.autoplay-control select:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.6;
}

.interest-dialog {
  width: min(540px, calc(100vw - 24px));
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
}

.interest-dialog::backdrop {
  background: rgba(31, 35, 40, 0.36);
}

.interest-panel {
  display: grid;
  gap: 12px;
  padding: 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 44px rgba(31, 35, 40, 0.16);
}

.interest-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.interest-copy,
.interest-context,
.interest-status {
  margin: 0;
  color: var(--muted);
}

.interest-header h2 {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.15;
  letter-spacing: 0;
}

.close-button {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  color: var(--muted);
  font-weight: 600;
  line-height: 1;
  text-align: center;
  cursor: pointer;
  background: var(--control-muted-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.close-button:hover,
.close-button:focus-visible {
  color: var(--ink);
  background: var(--control-hover-bg);
}

.interest-copy,
.interest-context,
.interest-status {
  font-size: 0.82rem;
  line-height: 1.4;
}

.interest-panel label,
.interest-panel fieldset {
  display: grid;
  gap: 6px;
  min-width: 0;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.interest-panel input {
  height: 36px;
  padding: 0 10px;
}

.interest-panel select {
  height: 36px;
  padding: 0 30px 0 10px;
}

.interest-panel textarea {
  min-height: 74px;
  resize: vertical;
  padding: 8px 10px;
}

.language-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.interest-panel fieldset {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.interest-panel legend {
  padding: 0 4px;
}

.interest-panel fieldset label,
.consent-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.interest-panel input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.interest-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.interest-actions button,
.contact-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  background: var(--control-muted-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.contact-link.is-primary {
  color: #fff;
  background: var(--accent);
  border-color: transparent;
}

.interest-actions button:hover,
.interest-actions button:focus-visible,
.contact-link:hover,
.contact-link:focus-visible {
  filter: brightness(0.97);
}

.explanation-dialog {
  width: 100vw;
  max-width: none;
  height: 100vh;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  color: var(--ink);
  background: transparent;
  border: 0;
}

.explanation-dialog::backdrop {
  background: rgba(31, 35, 40, 0.38);
}

.explanation-panel {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  max-width: 100%;
  max-height: min(78vh, 680px);
  overflow: hidden;
  padding: 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  box-shadow: 0 -18px 44px rgba(31, 35, 40, 0.16);
}

.explanation-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.explanation-heading,
.explanation-content,
.explanation-section,
.explanation-section p,
.explanation-disclosure,
.explanation-summary-toggle {
  min-width: 0;
  max-width: 100%;
}

.explanation-heading {
  flex: 1 1 auto;
}

.explanation-header-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.explanation-language-control {
  position: relative;
  flex: 0 0 auto;
}

.explanation-language-toggle {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  padding: 0;
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
}

.explanation-language-toggle:hover,
.explanation-language-toggle:focus-visible {
  background: var(--control-muted-bg);
  border-color: var(--line);
}

.explanation-language-toggle[hidden] {
  display: none;
}

.explanation-language-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 4;
  display: grid;
  min-width: 180px;
  max-width: min(240px, calc(100vw - 32px));
  gap: 2px;
  padding: 4px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-chrome);
}

.explanation-language-menu[hidden] {
  display: none;
}

.explanation-language-option {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 36px;
  gap: 8px;
  padding: 0 8px;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 520;
  text-align: left;
  cursor: pointer;
  background: transparent;
  border: 0;
  border-radius: 6px;
}

.explanation-language-option:hover,
.explanation-language-option:focus-visible,
.explanation-language-option[aria-selected="true"] {
  background: var(--accent-soft);
}

.explanation-language-option-marker {
  flex: 0 0 auto;
  line-height: 1;
}

.explanation-language-option-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.explanation-kicker,
.explanation-header h2,
.explanation-section h3,
.explanation-section p,
.explanation-disclosure summary,
.explanation-summary-toggle {
  margin: 0;
}

.explanation-kicker {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
}

.explanation-header h2 {
  margin-top: 3px;
  font-size: 1.05rem;
  line-height: 1.18;
  letter-spacing: 0;
}

.explanation-content {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 0;
  padding: 14px 0;
  overflow: auto;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.explanation-language-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.25;
}

.explanation-section {
  display: grid;
  gap: 5px;
}

.explanation-section h3 {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0;
}

.explanation-section p {
  color: var(--ink);
  font-size: 0.84rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.explanation-section-primary p {
  display: -webkit-box;
  overflow: hidden;
  font-size: 0.9rem;
  line-height: 1.5;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
}

.explanation-section-primary p.is-expanded {
  display: block;
  overflow: visible;
  -webkit-line-clamp: unset;
}

.explanation-section-primary.is-fallback p {
  color: var(--muted);
}

.explanation-summary-toggle {
  justify-self: start;
  padding: 2px 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  background: transparent;
  border: 0;
}

.explanation-summary-toggle:hover,
.explanation-summary-toggle:focus-visible {
  color: var(--ink);
}

.explanation-summary-toggle:focus-visible {
  outline: 0;
  box-shadow: var(--focus-ring);
}

.explanation-disclosure {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.explanation-disclosure summary {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
}

.explanation-disclosure p {
  margin-top: 7px;
}

@media (min-width: 760px) {
  .explanation-panel {
    right: 16px;
    bottom: 16px;
    left: auto;
    width: min(460px, calc(100vw - 32px));
    max-height: min(720px, calc(100vh - 32px));
    border-bottom: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 44px rgba(31, 35, 40, 0.18);
  }
}

@media (max-width: 620px) {
  html,
  body {
    width: 100%;
    max-width: 100vw;
  }

  .reader-chrome {
    top: 8px;
    left: 8px;
    width: min(374px, calc(100vw - 16px));
    transform: none;
  }

  .reader-chrome.is-language-rail-hidden {
    grid-template-columns: auto 0 0;
    gap: 0;
    width: max-content;
    max-width: calc(100vw - 16px);
  }

  .reader-brand {
    max-width: 32vw;
    padding: 0 6px;
    font-size: 0.82rem;
  }

  .reader-chrome:not(.is-language-rail-hidden) .reader-brand {
    gap: 0;
    padding-right: 2px;
  }

  .reader-chrome:not(.is-language-rail-hidden) .reader-brand span:last-child {
    max-width: 0;
    opacity: 0;
    transform: translateX(-3px);
  }

  .reader-logo {
    width: 28px;
    height: 28px;
  }

  .language-switcher {
    max-width: none;
  }

  .language-switcher::after {
    transition: opacity 120ms ease;
  }

  .blend-button {
    padding: 0 5px;
    font-size: 0.86rem;
  }

  .reader-chrome:not(.is-language-rail-hidden) .blend-button-label {
    gap: 0;
  }

  .reader-chrome:not(.is-language-rail-hidden) .blend-button-code {
    display: none;
  }

  .reader-chrome:not(.is-language-rail-hidden) .blend-button-marker {
    line-height: 1;
  }

  .autoplay-toggle {
    width: 54px;
    padding: 0 8px;
    font-size: 0.7rem;
  }

  .reader-shell {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 72px 16px 120px;
    overflow-x: hidden;
  }

  .chapter-meta,
  .work-picker,
  .language-picker,
  .reader-intro,
  .page-list,
  .continuation-request,
  .reader-page,
  .image-stack,
  .page-meta {
    width: 100%;
    max-width: 100%;
  }

  .page-meta {
    width: min(358px, calc(100vw - 32px));
    max-width: min(358px, calc(100vw - 32px));
    margin-right: 0;
    margin-left: 0;
    padding-right: 58px;
  }

  .reader-page.is-wide-page .page-meta {
    width: min(358px, calc(100vw - 32px));
    max-width: min(358px, calc(100vw - 32px));
  }

  .page-explanation-button {
    min-height: 26px;
    max-width: 100%;
  }

  .explanation-panel {
    width: 100vw;
    min-width: 0;
    max-width: 100vw;
  }

  .explanation-header,
  .explanation-content {
    width: min(358px, calc(100vw - 32px));
    max-width: min(358px, calc(100vw - 32px));
  }

  .reader-page .image-stack {
    width: 100vw;
    max-width: 100vw;
    margin-right: 0;
    margin-left: -16px;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .reader-page.is-wide-page .image-stack {
    max-width: 100vw;
  }

  .chapter-meta,
  .work-picker,
  .language-picker,
  .reader-intro {
    width: min(100%, 358px);
    max-width: min(100%, 358px);
    margin-right: 0;
    margin-left: 0;
  }

  .chapter-meta.is-intro-collapsed {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    column-gap: 8px;
  }

  .chapter-meta.is-intro-collapsed .reader-intro.is-collapsed {
    position: relative;
    top: auto;
    right: auto;
    grid-row: 1;
    grid-column: 2;
    justify-self: end;
    width: auto;
    max-width: none;
    margin-top: 0;
  }

  .chapter-meta.is-intro-collapsed .work-picker {
    grid-row: 2;
    grid-column: 1 / -1;
    margin-top: 3px;
  }

  .chapter-meta.is-intro-collapsed .language-picker {
    grid-row: 3;
    grid-column: 1 / -1;
  }

  .page-meta span:last-child {
    text-align: left;
  }

  .continuation-request {
    flex-direction: column;
    align-items: stretch;
  }

  .missing-route-actions {
    flex-direction: column;
  }

  .language-fields,
  .interest-panel fieldset {
    grid-template-columns: 1fr;
  }

  .language-picker {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-inline-size: 0;
    max-inline-size: 100%;
    column-gap: 4px;
    row-gap: var(--setup-label-gap);
  }

  .language-picker legend {
    display: inline-flex;
    flex: 0 0 100%;
    width: 100%;
    max-width: 100%;
    white-space: nowrap;
  }

  .reader-intro {
    display: none;
  }

  .reader-intro-help-toggle {
    width: 20px;
    height: 20px;
    margin-top: -2px;
    font-size: 0.68rem;
  }

  .reader-intro-dismiss {
    width: 20px;
    height: 20px;
    margin-top: -2px;
    font-size: 0.68rem;
  }

  .reader-intro-help {
    max-width: min(318px, calc(100vw - 32px));
    padding: 7px 9px;
    font-size: 0.68rem;
  }

  .language-picker .chosen-language-slot {
    display: block;
    flex: 1 1 0;
    min-width: 0;
    min-height: 38px;
    overflow: hidden;
  }

  .chosen-slot-display {
    justify-content: center;
    min-width: 0;
    max-width: 100%;
    min-height: 38px;
    height: 38px;
    gap: 1px;
    padding: 0 9px 0 2px;
    font-size: 0.6rem;
    font-weight: 650;
    text-overflow: clip;
  }

  .chosen-slot-display::after {
    right: 3px;
    width: 8px;
    height: 5px;
    background-size:
      4px 4px,
      4px 4px;
  }

  .work-picker .select-chevron {
    right: 10px;
    left: auto;
  }

  .chosen-slot-display-language {
    text-overflow: clip;
  }

  .reader-footer {
    right: auto;
    left: 8px;
    width: min(374px, calc(100vw - 16px));
    gap: 6px;
    padding: 6px 7px;
  }

  .blend-control {
    gap: 6px;
  }

  .autoplay-control-label {
    font-size: 0;
    white-space: nowrap;
  }

  .autoplay-control-label::after {
    content: attr(data-short-label);
    font-size: 0.7rem;
  }

  .autoplay-speed-help {
    right: -4px;
    max-width: min(224px, calc(100vw - 20px));
    padding: 6px 8px;
    font-size: 0.68rem;
  }

  .reader-hint {
    top: 30%;
    max-width: min(300px, calc(100% - 24px));
    gap: 6px;
    padding: 8px 9px;
  }

  .reader-hint-copy {
    font-size: 0.74rem;
  }

  .reader-hint-path {
    font-size: 0.64rem;
  }
}

@media (max-width: 420px) {
  .reader-chrome {
    gap: 6px;
    padding: 5px;
  }

  .reader-brand {
    max-width: none;
    padding: 0 4px;
  }

  .autoplay-toggle {
    width: 50px;
    max-width: 50px;
    padding: 0 6px;
  }

  .reader-footer {
    bottom: 8px;
    font-size: 0.7rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reader-chrome,
  .language-switcher,
  .language-switcher::after,
  .autoplay-toggle,
  .reader-chrome.is-language-rail-hidden .language-switcher,
  .reader-chrome.is-language-rail-hidden .autoplay-toggle,
  .reader-brand,
  .reader-brand span:last-child,
  .app-toast,
  .autoplay-speed-help,
  .reader-intro-help,
  .reader-hint,
  .reader-footer,
  .page-layer {
    transition: none;
  }
}
