/* Immersive EPUB reader. One scroll container: #reader-scroll. */
.reader-page { padding-top: 28px; }

body.is-reading { overflow: hidden; }
body.is-reading > header.nav,
body.is-reading > footer,
body.is-reading .tool-hero,
body.is-reading #reader-drop,
body.is-reading .tool-section { display: none !important; }

#reader:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: #f6f1e8;
  color: var(--ink);
}
#reader[data-theme="night"] { background: #1c1916; color: #f3eadf; }
#reader[data-theme="night"] .reader-top,
#reader[data-theme="night"] .reader-drawer,
#reader[data-theme="night"] .reader-panel,
#reader[data-theme="night"] .reader-selbar { background: #26211c; color: #f3eadf; border-color: #3a332c; }
#reader[data-theme="night"] .reader-article { color: #f3eadf; }
#reader[data-size="16"] .reader-article { font-size: 16px; }
#reader[data-size="18"] .reader-article { font-size: 18px; }
#reader[data-size="20"] .reader-article { font-size: 20px; }

.reader-top {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: #f6f1e8;
  flex: none;
}
.reader-top-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reader-icon-btn {
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.reader-icon-btn:hover,
.reader-icon-btn[aria-expanded="true"] { background: rgba(101, 81, 38, .1); }

.reader-body { position: relative; flex: 1; min-height: 0; display: flex; }
.reader-scroll { flex: 1; min-width: 0; overflow: auto; }
.reader-column { max-width: 680px; margin: 0 auto; padding: 28px 22px 64px; }
.reader-article { outline: none; }
.reader-article h2 { margin: 0 0 18px; font-size: 26px; line-height: 1.35; }
.reader-article h3,
.reader-article h4,
.reader-article h5,
.reader-article h6 { margin: 1.2em 0 .4em; line-height: 1.35; }
.reader-article p,
.reader-article blockquote,
.reader-article li { font-size: 1em; line-height: 1.8; }
.reader-article p { margin: 0 0 .8em; }
.reader-article p.line { margin: 0; }
.reader-article blockquote { margin: 0 0 .8em; padding-left: 1em; border-left: 3px solid var(--line); }
.reader-article img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 80vh;
  height: auto;
  margin: 0 auto .8em;
}
.reader-article ul,
.reader-article ol { margin: 0 0 .8em; padding-left: 1.4em; }
.reader-hl { background: #f3e2a4; color: inherit; }
#reader[data-theme="night"] .reader-hl { background: #6d5820; color: #fff8e8; }

.reader-pager { display: flex; gap: 12px; margin-top: 28px; }
.reader-pager .button { flex: 1; }

.reader-drawer {
  width: 320px;
  flex: none;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 16px;
  border-left: 1px solid var(--line);
  background: #f6f1e8;
}
.reader-drawer h2 { margin: 0; font-size: 18px; }
.reader-sheet-handle { display: none; }
.reader-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.reader-empty { margin: 0; color: var(--muted); font-size: 14px; }
.reader-card { padding: 10px 0; border-top: 1px solid var(--line); cursor: pointer; }
.reader-card.is-new { background: #f4ecd2; }
#reader[data-theme="night"] .reader-card.is-new { background: #3a3320; }
.reader-card blockquote { margin: 0; font-size: 15px; line-height: 1.55; }
.reader-card-chapter { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.reader-card-actions { display: flex; gap: 12px; margin-top: 8px; }
.reader-text-btn,
.reader-selbar button,
.reader-type-row button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.reader-note, .reader-unsaved, .reader-hint { margin: 0; color: var(--muted); font-size: 13px; }
.reader-hint { color: var(--brown); font-weight: 650; }
.reader-qr { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; align-items: center; padding-top: 8px; border-top: 1px solid var(--line); }
.reader-qr img { width: 96px; height: 96px; }
.reader-qr p, .reader-qr ol { margin: 0; font-size: 13px; }
.reader-qr ol { padding-left: 1.2em; }
.reader-qr a { color: var(--brown); }
.reader-phone-only { display: none; }

.reader-progress {
  appearance: none;
  width: 100%;
  height: 3px;
  border: 0;
  flex: none;
  background: transparent;
  color: var(--brown);
}
.reader-progress::-webkit-progress-bar { background: transparent; }
.reader-progress::-webkit-progress-value { background: var(--brown); }
.reader-progress::-moz-progress-bar { background: var(--brown); }

.reader-panel {
  position: absolute;
  top: 56px;
  right: 12px;
  z-index: 7;
  width: min(360px, calc(100% - 24px));
  max-height: min(70vh, 520px);
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f6f1e8;
  box-shadow: 0 16px 40px rgba(40, 32, 24, .16);
}
.reader-toc { list-style: none; margin: 0; padding: 0; }
.reader-toc button {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.reader-toc button[aria-current="true"] { background: rgba(101, 81, 38, .12); font-weight: 700; }
.reader-toc .lvl-2 button { padding-left: 22px; }
.reader-toc .lvl-3 button { padding-left: 34px; }
.reader-type-row { display: flex; flex-wrap: wrap; gap: 8px; }
.reader-type p { margin: 0 0 8px; }

.reader-selbar {
  display: flex;
  gap: 4px;
  width: max-content;
  margin: 8px 0;
  padding: 4px;
  user-select: none;
  background: #fffdf8;
  border: 1px solid rgba(42, 37, 32, .16);
  border-radius: 12px;
  box-shadow: 0 8px 22px rgba(40, 32, 24, .28);
}
.reader-selbar button {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: #2a2520;
  color: #fffdf8;
  font-weight: 700;
}
.reader-selbar button:hover { background: #655126; }
#reader[data-theme="night"] .reader-selbar {
  background: #1c1916;
  border-color: #5c5348;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .5);
}
#reader[data-theme="night"] .reader-selbar button {
  background: #f3eadf;
  color: #1c1916;
}
.reader-selbar.is-placed { position: fixed; z-index: 45; margin: 0; }
.reader-modal { z-index: 70; }

@media (max-width: 800px) {
  .reader-desktop-only { display: none; }
  .reader-phone-only { display: block; }
  .reader-top { gap: 2px; padding: 0 6px; }
  .reader-drawer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: 60vh;
    z-index: 8;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -12px 40px rgba(40, 32, 24, .18);
  }
  .reader-sheet-handle { display: block; }
  .reader-qr { display: none; }
  .reader-column { padding: 20px 18px 48px; }
  .reader-article h2 { font-size: 24px; }
}
