.reader {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow-y: auto;
  background: #000;
}

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

.reader.mode-page {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.reader-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 16px 32px;
  background: rgba(0, 0, 0, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.reader-heading {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  min-width: 0;
}

.title-link {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  color: inherit;
  text-decoration: none;
}

.title-link:hover h2 {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.reader-bar h2 {
  margin: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  width: 36px;
  padding: 0;
}

.icon-button .icon {
  transition: transform 0.2s ease;
}
.icon-button:hover .icon {
  transform: rotate(45deg);
}

.settings-panel {
  position: absolute;
  top: calc(100% + 1px);
  right: 32px;
  z-index: 3;
  width: 264px;
  padding: 16px;
  background: #000;
  border: 1px solid var(--line-strong);
}

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

.settings-title {
  margin: 0 0 14px;
  color: var(--dim);
  font: 10px var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font: 10px var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.segmented {
  display: flex;
}

.segmented button {
  padding: 6px 9px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line-strong);
  margin-left: -1px;
  font: 10px var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.segmented button:first-child {
  margin-left: 0;
}
.segmented button:hover {
  color: var(--fg);
  border-color: var(--fg);
}

.segmented button[aria-pressed="true"] {
  color: #000;
  background: var(--fg);
  border-color: var(--fg);
}

.segmented button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.reader[data-width="narrow"] .page img {
  width: min(680px, 100%);
}
.reader[data-width="wide"] .page img {
  width: 100%;
}

.reader[data-gap="on"] .reader-pages {
  gap: 12px;
}
.reader[data-gap="on"] .reader-foot {
  margin-top: 12px;
}

.reader-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px 20px;
}

.reader-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.reader-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--line);
}

#reader-progress-bar {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--fg);
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform 0.15s ease-out;
}

.reader-count {
  font: 10px var(--mono);
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
}

.chapter-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 210px;
  padding: 8px 10px;
  color: var(--fg);
  background: #000;
  border: 1px solid var(--line-strong);
  font: 10px var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.chapter-button::after {
  content: "";
  flex: none;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--muted);
}

.chapter-button:hover {
  border-color: var(--fg);
}
.chapter-button:hover::after {
  border-top-color: var(--fg);
}

#reader-sources {
  max-width: 170px;
  padding: 8px 10px;
  color: var(--fg);
  background: #000;
  border: 1px solid var(--line-strong);
  font: 10px var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}

#reader-sources[hidden] {
  display: none;
}

#reader-sources option {
  color: var(--fg);
  background: #000;
  letter-spacing: 0.04em;
}

.reader-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px 88px;
}

.page {
  display: flex;
  justify-content: center;
  width: 100%;
  margin: 0;
  line-height: 0;
  gap: 0;
}

.page img {
  display: block;
  width: min(860px, 100%);
  height: auto;
  margin: 0;
  vertical-align: top;
  background: var(--panel);
}

.reader.mode-page .reader-pages {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 0;
}

.reader.mode-page .page {
  display: none;
}

.reader.mode-page .page.is-current {
  display: flex;
  align-items: center;
  height: 100%;
}

.reader.mode-page .page img {
  width: auto;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  cursor: pointer;
}

.reader.mode-page .page.is-tall {
  align-items: flex-start;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.reader.mode-page .page.is-tall img {
  width: min(860px, 100%);
  max-width: 100%;
  max-height: none;
  height: auto;
}

.reader.mode-page .reader-foot {
  display: none;
}

.reader-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 40px;
  padding: 28px 16px 72px;
  border-top: 1px solid var(--line);
}

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

.reader-note .text-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.reader-note {
  margin: 40px 0;
  font: 10px var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
