:root {
  --ink: #24180f;
  --muted: #776a5c;
  --paper: #f4ead8;
  --paper-deep: #e6d1b6;
  --panel: rgba(255, 249, 237, 0.78);
  --line: rgba(64, 43, 26, 0.16);
  --accent: #b34c2f;
  --accent-2: #1f6f63;
  --charcoal: #18201c;
  --shadow: 0 24px 70px rgba(55, 34, 18, 0.22);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Georgia, 'Songti SC', 'Noto Serif CJK SC', serif;
  background:
    radial-gradient(circle at 8% 12%, rgba(179, 76, 47, 0.18), transparent 28rem),
    radial-gradient(circle at 86% 4%, rgba(31, 111, 99, 0.2), transparent 24rem),
    linear-gradient(135deg, #ead6b9, #f8efd9 42%, #d9c1a2);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  background-image:
    linear-gradient(90deg, rgba(36, 24, 15, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(36, 24, 15, 0.06) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: linear-gradient(to bottom, black, transparent 82%);
}

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

button {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

button:hover { transform: translateY(-1px); }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid rgba(31, 111, 99, 0.35);
  outline-offset: 2px;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0.84rem 0.95rem;
  color: var(--ink);
  background: rgba(255, 252, 245, 0.82);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.58);
}

input[type='checkbox'] {
  width: auto;
  accent-color: var(--accent-2);
  box-shadow: none;
}

textarea { resize: vertical; }
label {
  display: grid;
  gap: 0.42rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.app-shell {
  width: min(1460px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 34px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: 1fr minmax(280px, 420px);
  gap: 28px;
  overflow: hidden;
  padding: 34px;
}

.hero::after {
  content: '✦';
  position: absolute;
  right: 46%;
  top: 22px;
  color: rgba(179, 76, 47, 0.3);
  font-size: 5rem;
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--accent-2);
  font-family: 'Avenir Next', 'Gill Sans', sans-serif;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1, h2 { margin: 0; line-height: 0.95; }
h1 { max-width: 8ch; font-size: clamp(3.4rem, 9vw, 8rem); letter-spacing: -0.07em; }
h2 { font-size: clamp(1.6rem, 3vw, 2.6rem); letter-spacing: -0.045em; }

.hero-copy {
  max-width: 55ch;
  color: var(--muted);
  font-size: 1.18rem;
  line-height: 1.8;
}

.sync-card {
  display: grid;
  gap: 12px;
  align-self: end;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(36, 24, 15, 0.06);
}

.primary-btn, .ghost-btn, .danger-btn {
  min-height: 46px;
  padding: 0.82rem 1.2rem;
  font-family: 'Avenir Next', 'Gill Sans', sans-serif;
  font-weight: 800;
}

.primary-btn { color: #fff8eb; background: var(--charcoal); box-shadow: 0 12px 28px rgba(24, 32, 28, 0.24); }
.ghost-btn { color: var(--charcoal); background: rgba(255, 252, 245, 0.76); border: 1px solid var(--line); }
.danger-btn { color: #fff8eb; background: var(--accent); }

.status-line { min-height: 1.3em; margin: 0; color: var(--accent-2); line-height: 1.4; }

.calibre-card {
  display: grid;
  gap: 12px;
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 390px) 1fr;
  gap: 24px;
  margin-top: 24px;
}

.sidebar, .detail { padding: 22px; }
.toolbar { display: grid; gap: 12px; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 18px 0;
}
.stat {
  padding: 14px;
  border-radius: 20px;
  background: rgba(255, 252, 245, 0.66);
  border: 1px solid var(--line);
}
.stat strong { display: block; font-size: 1.7rem; }
.stat span { color: var(--muted); font-size: 0.82rem; }

.book-list { display: grid; gap: 12px; max-height: 62vh; overflow: auto; padding-right: 4px; }
.book-card {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 14px;
  width: 100%;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 24px;
  text-align: left;
  color: var(--ink);
  background: rgba(255, 252, 245, 0.5);
}
.book-card.active { border-color: rgba(179, 76, 47, 0.45); background: rgba(255, 252, 245, 0.9); }
.book-spine { min-height: 72px; border-radius: 14px 8px 8px 14px; box-shadow: inset -8px 0 0 rgba(0, 0, 0, 0.12); }
.book-card h3 { margin: 0 0 6px; font-size: 1.05rem; }
.book-card p { margin: 0; color: var(--muted); line-height: 1.45; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { padding: 0.18rem 0.55rem; border-radius: 999px; background: rgba(31, 111, 99, 0.12); color: var(--accent-2); font-size: 0.76rem; }

.detail-grid { display: grid; grid-template-columns: minmax(300px, 0.95fr) minmax(340px, 1.05fr); gap: 24px; }
.book-form, .note-form { display: grid; gap: 14px; }
.form-row { display: grid; gap: 12px; }
.form-row.two { grid-template-columns: repeat(2, 1fr); }
.form-row.three { grid-template-columns: 1fr 0.75fr auto; align-items: end; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.notes-column { display: grid; align-content: start; gap: 16px; }
.notes-header { display: flex; justify-content: space-between; align-items: end; gap: 14px; }
.note-list { display: grid; gap: 12px; max-height: 58vh; overflow: auto; padding-right: 4px; }
.note-card {
  position: relative;
  padding: 18px 48px 18px 18px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 252, 245, 0.78);
}
.note-card::before {
  content: '';
  position: absolute;
  left: 18px;
  right: 18px;
  top: 46px;
  height: 1px;
  background: rgba(179, 76, 47, 0.12);
}
.note-meta { margin-bottom: 18px; color: var(--accent); font-family: 'Avenir Next', 'Gill Sans', sans-serif; font-size: 0.78rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; }
.note-card p { margin: 0; color: #3b2a1d; line-height: 1.7; white-space: pre-wrap; }
.icon-btn {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 30px;
  height: 30px;
  color: var(--muted);
  background: transparent;
}
.empty-state { padding: 30px; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 24px; }

.reveal { animation: rise 560ms ease both; }
.delay-1 { animation-delay: 90ms; }
.delay-2 { animation-delay: 180ms; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 980px) {
  .hero, .workspace, .detail-grid { grid-template-columns: 1fr; }
  .book-list, .note-list { max-height: none; }
}

.login-shell {
  width: min(1120px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: 28px 0;
}

.login-panel {
  width: 100%;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 24px;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 34px;
  background: rgba(255, 249, 237, 0.8);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.login-art {
  position: relative;
  overflow: hidden;
  min-height: 420px;
  padding: 30px;
  border-radius: 28px;
  color: #fff8eb;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.16), transparent 22rem),
    radial-gradient(circle at 82% 28%, rgba(255, 255, 255, 0.1), transparent 16rem),
    linear-gradient(145deg, #1f2a24, #284c43 52%, #7d402f);
}

.login-art::after {
  content: '书 · 注 · 同步';
  position: absolute;
  right: 18px;
  bottom: 18px;
  color: rgba(255, 248, 235, 0.72);
  font-family: 'Avenir Next', 'Gill Sans', sans-serif;
  font-size: 0.8rem;
  letter-spacing: 0.18em;
}

.login-art .eyebrow {
  color: rgba(255, 248, 235, 0.72);
}

.login-art h1 {
  max-width: 10ch;
  margin-top: 18px;
  color: #fff8eb;
}

.login-art p {
  max-width: 34ch;
  color: rgba(255, 248, 235, 0.8);
  font-size: 1.08rem;
  line-height: 1.8;
}

.login-orbit {
  display: grid;
  gap: 14px;
  margin-top: 36px;
}

.login-pill {
  width: fit-content;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  background: rgba(255, 248, 235, 0.14);
  border: 1px solid rgba(255, 248, 235, 0.18);
  font-family: 'Avenir Next', 'Gill Sans', sans-serif;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.login-form-shell {
  display: grid;
  align-content: center;
  gap: 18px;
  padding: 18px 6px 18px 0;
}

.login-form-shell h2 {
  margin-bottom: 6px;
}

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

.login-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.login-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.login-error {
  min-height: 1.3em;
  margin: 0;
  color: var(--accent);
  font-weight: 700;
}

@media (max-width: 980px) {
  .login-panel { grid-template-columns: 1fr; }
  .login-art { min-height: 320px; }
}

@media (max-width: 640px) {
  .app-shell { width: min(100% - 18px, 1460px); padding-top: 9px; }
  .hero, .sidebar, .detail { padding: 16px; border-radius: 24px; }
  h1 { font-size: 3.5rem; }
  .form-row.two, .form-row.three { grid-template-columns: 1fr; }
  .primary-btn, .ghost-btn, .danger-btn { width: 100%; }
}

.reader-body {
  overflow: hidden;
}

.mobile-reader-nav,
.mobile-notes-head,
.notes-backdrop {
  display: none;
}

.reader-body.is-night {
  --ink: #e9e2d5;
  --muted: #aaa397;
  --line: rgba(235, 226, 210, 0.15);
  --panel: rgba(29, 30, 28, 0.96);
  color: var(--ink);
  background: #151715;
}

.reader-body.is-night .panel,
.reader-body.is-night .document-toolbar {
  background: rgba(29, 30, 28, 0.96);
}

.reader-body.is-night .reader-tool-btn {
  color: #eee7da;
  background: rgba(255, 255, 255, 0.1);
}

.reader-body.is-night .reader-text,
.reader-body.is-night .epub-viewer,
.reader-body.is-night .epub-viewer iframe,
.reader-body.is-night .reader-frame {
  color: #ded8cc;
  background: #1b1d1b;
}

.reader-body.is-night .pdf-page-stage {
  background: #0f1110;
}

.reader-body.is-night .pdf-page canvas {
  filter: invert(0.88) hue-rotate(180deg) brightness(0.88) contrast(0.92);
}

.reader-shell {
  width: min(1680px, calc(100% - 24px));
  height: 100vh;
  margin: 0 auto;
  padding: 16px 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
}

.reader-top {
  display: grid;
  grid-template-columns: 1fr minmax(260px, 420px);
  gap: 18px;
  padding: 18px 22px;
}

.reader-top h1 {
  max-width: none;
  font-size: clamp(2rem, 4vw, 4rem);
}

.back-link {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--accent);
  font-family: 'Avenir Next', 'Gill Sans', sans-serif;
  font-weight: 800;
  text-decoration: none;
}

.reader-actions {
  display: grid;
  align-content: end;
  gap: 10px;
}

.reading-workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 430px);
  gap: 14px;
}

.book-reader,
.reader-notes {
  min-height: 0;
  padding: 14px;
}

.book-reader {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
}

.document-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 252, 245, 0.88);
  font-family: 'Avenir Next', 'Gill Sans', sans-serif;
}

.document-toolbar [hidden] {
  display: none !important;
}

.reader-tool-btn {
  width: 34px;
  height: 34px;
  color: var(--ink);
  background: rgba(36, 24, 15, 0.08);
  font-weight: 800;
}

.page-control {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.page-control input {
  width: 58px;
  padding: 0.4rem 0.5rem;
  border-radius: 10px;
  text-align: center;
}

.zoom-label {
  min-width: 46px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.live-location {
  margin-left: auto;
  color: var(--accent-2);
  font-size: 0.82rem;
  font-weight: 800;
}

.book-source {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.pdf-page-stage {
  height: 100%;
  overflow: auto;
  padding: 24px;
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255,255,255,.55), transparent 36rem),
    #cfc7b9;
}

.pdf-page {
  position: relative;
  margin: 0 auto;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 20px 50px rgba(24, 20, 16, 0.28);
}

.pdf-page canvas,
.pdf-page .textLayer,
.pdf-highlight-layer {
  position: absolute;
  inset: 0;
}

.pdf-page canvas {
  position: relative;
  display: block;
}

.pdf-page .textLayer {
  z-index: 2;
}

.pdf-highlight-layer {
  z-index: 1;
  pointer-events: none;
}

.saved-highlight {
  position: absolute;
  border-radius: 2px;
  mix-blend-mode: multiply;
}

.saved-highlight.yellow,
.inline-highlight.yellow { background: rgba(245, 205, 67, 0.52); }
.saved-highlight.green,
.inline-highlight.green { background: rgba(98, 189, 139, 0.45); }
.saved-highlight.coral,
.inline-highlight.coral { background: rgba(235, 116, 92, 0.45); }
.saved-highlight.quote,
.inline-highlight.quote {
  background: rgba(66, 139, 202, 0.2);
  border-bottom: 2px solid rgba(66, 139, 202, 0.72);
}

.selection-toolbar {
  position: fixed;
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  color: #fff8eb;
  background: #18201c;
  box-shadow: 0 14px 38px rgba(18, 24, 21, 0.36);
  animation: selection-pop 160ms ease both;
}

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

.selection-toolbar > button:first-child {
  padding: 0.35rem 0.65rem;
  color: #fff8eb;
  background: transparent;
  font-family: 'Avenir Next', 'Gill Sans', sans-serif;
  font-weight: 800;
}

.selection-divider {
  width: 1px;
  height: 22px;
  background: rgba(255,255,255,.24);
}

.highlight-dot {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(255,255,255,.7);
  border-radius: 50%;
}

.highlight-dot.yellow { background: #f2ca3a; }
.highlight-dot.green { background: #64b98b; }
.highlight-dot.coral { background: #e8775f; }

@keyframes selection-pop {
  from { opacity: 0; transform: translateY(5px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.reader-frame {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 22px;
  background: #fffdf5;
}

  .epub-viewer {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  border-radius: 18px;
  background: #fffdf7;
}

.epub-viewer iframe {
  border: 0;
  background: #fffdf7;
}

.reader-text {
  height: 100%;
  margin: 0;
  overflow: auto;
  padding: 28px;
  border-radius: 22px;
  color: #2d2016;
  background: #fffdf5;
  font-family: Georgia, 'Songti SC', 'Noto Serif CJK SC', serif;
  font-size: 1.05rem;
  line-height: 1.85;
  white-space: pre-wrap;
}

.inline-highlight {
  border-radius: 3px;
  color: inherit;
}

.reader-notes {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
}

.note-source-draft {
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--draft-color) 55%, var(--line));
  border-left: 5px solid var(--draft-color);
  border-radius: 18px;
  background: color-mix(in srgb, var(--draft-color) 12%, #fffdf7);
  animation: selection-pop 180ms ease both;
}

.note-source-draft[hidden] { display: none; }

.draft-source-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  color: var(--muted);
  font-family: 'Avenir Next', 'Gill Sans', sans-serif;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.draft-clear {
  padding: 0.2rem 0.5rem;
  color: var(--muted);
  background: transparent;
  font-size: 0.75rem;
}

.note-source-draft blockquote,
.saved-source {
  position: relative;
  margin: 0;
  padding: 4px 14px 14px 32px;
  color: #49382b;
  font-family: Georgia, 'Songti SC', 'Noto Serif CJK SC', serif;
  line-height: 1.65;
  white-space: pre-wrap;
}

.note-source-draft blockquote > span:first-child,
.saved-source > span:first-child {
  position: absolute;
  left: 11px;
  top: -3px;
  color: var(--draft-color, var(--note-color));
  font-size: 1.7rem;
  font-weight: 800;
}

.saved-source {
  margin: 0 0 12px;
  padding: 10px 12px 10px 28px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--note-color) 12%, transparent);
}

.reader-notes .note-list {
  max-height: none;
  min-height: 0;
}

.reader-notes .note-card {
  border-left: 5px solid var(--note-color, var(--line));
}

.reader-notes .note-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.note-location {
  padding: 0.28rem 0.58rem;
  color: var(--accent-2);
  background: rgba(31, 111, 99, 0.1);
  font-size: 0.74rem;
  font-weight: 800;
}

.highlight-note p { padding-top: 2px; }

@media (max-width: 980px) {
  .reader-body {
    overflow: auto;
  }

  .reader-shell {
    height: auto;
  }

  .reader-top,
  .reading-workspace {
    grid-template-columns: 1fr;
  }

  .book-reader {
    height: 72vh;
  }

  .document-toolbar {
    flex-wrap: wrap;
  }

  .live-location {
    width: 100%;
    margin-left: 0;
  }
}

@media (max-width: 640px), (hover: none) and (pointer: coarse) {
  .reader-body {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
    background: #f4efe5;
  }

  .reader-shell {
    width: 100%;
    height: 100dvh;
    margin: 0;
    padding: 0;
    display: block;
  }

  .reader-top {
    display: none;
  }

  .reading-workspace {
    display: block;
    height: 100dvh;
  }

  .book-reader {
    width: 100%;
    height: 100dvh;
    padding: 0;
    display: block;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #fffdf7;
  }

  .epub-viewer > div {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }

  .mobile-reader-nav {
    position: fixed;
    z-index: 9000;
    top: max(8px, env(safe-area-inset-top));
    left: 8px;
    right: 8px;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 42px 42px 42px;
    align-items: center;
    gap: 7px;
    min-height: 50px;
    padding: 4px;
    border: 1px solid rgba(61, 52, 43, 0.12);
    border-radius: 18px;
    background: rgba(255, 252, 245, 0.88);
    box-shadow: 0 8px 28px rgba(35, 27, 20, 0.14);
    backdrop-filter: blur(18px) saturate(1.2);
    -webkit-backdrop-filter: blur(18px) saturate(1.2);
    transition: transform 220ms cubic-bezier(.22,.75,.2,1), opacity 180ms ease;
  }

  .reader-body.controls-hidden .mobile-reader-nav {
    opacity: 0;
    pointer-events: none;
    transform: translateY(calc(-100% - 24px));
  }

  .reader-body.is-night .mobile-reader-nav {
    border-color: rgba(255,255,255,.1);
    background: rgba(27, 29, 27, 0.88);
  }

  .mobile-nav-btn {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    padding: 0;
    border-radius: 14px;
    color: #2f443d;
    background: rgba(59, 107, 91, 0.1);
    font-family: 'Avenir Next', 'Gill Sans', sans-serif;
    font-size: 0.92rem;
    font-weight: 900;
    text-decoration: none;
  }

  .reader-body.is-night .mobile-nav-btn {
    color: #e5ded2;
    background: rgba(255,255,255,.1);
  }

  .mobile-book-title {
    min-width: 0;
    display: grid;
    line-height: 1.15;
  }

  .mobile-book-title strong,
  .mobile-book-title span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-book-title strong {
    font-family: Georgia, 'Songti SC', serif;
    font-size: 0.86rem;
  }

  .mobile-book-title span {
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.68rem;
  }

  .document-toolbar {
    display: none !important;
  }

  .book-source {
    position: relative;
    width: 100%;
    height: 100dvh;
    border-radius: 0;
    touch-action: pan-y pinch-zoom;
  }

  .epub-gesture-zones {
    position: absolute;
    z-index: 7000;
    inset: calc(68px + env(safe-area-inset-top)) 0 calc(68px + env(safe-area-inset-bottom));
    pointer-events: none;
  }

  .epub-gesture-zone {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 30%;
    pointer-events: auto;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
  }

  .epub-gesture-zone.left { left: 0; }
  .epub-gesture-zone.right { right: 0; }

  .book-source.selection-active .epub-gesture-zone {
    pointer-events: none;
  }

  .reader-text,
  .pdf-page .textLayer {
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
  }

  .pdf-page .textLayer {
    touch-action: auto;
  }

  .epub-viewer,
  .reader-frame,
  .reader-text,
  .pdf-page-stage {
    width: 100%;
    height: 100dvh;
    border-radius: 0;
  }

  .reader-text {
    padding: calc(76px + env(safe-area-inset-top)) 22px calc(76px + env(safe-area-inset-bottom));
    font-size: 1.08rem;
    line-height: 1.9;
  }

  .pdf-page-stage {
    padding: calc(70px + env(safe-area-inset-top)) 4px calc(68px + env(safe-area-inset-bottom));
  }

  .pdf-page {
    box-shadow: 0 10px 30px rgba(24, 20, 16, 0.18);
  }

  .selection-toolbar {
    z-index: 10020;
    left: 50% !important;
    top: auto !important;
    bottom: max(16px, env(safe-area-inset-bottom));
    gap: 9px;
    max-width: calc(100% - 16px);
    padding: 9px 11px;
    box-shadow: 0 12px 34px rgba(13, 17, 15, .42);
    transform: translateX(-50%);
  }

  .selection-toolbar > button:first-child {
    min-height: 34px;
    padding: 0.4rem 0.6rem;
  }

  .highlight-dot {
    width: 29px;
    height: 29px;
  }

  .reader-notes {
    position: fixed;
    z-index: 10010;
    left: 0;
    right: 0;
    bottom: 0;
    height: min(84dvh, 760px);
    padding: 14px 14px calc(16px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-rows: auto auto 1fr;
    gap: 12px;
    border: 0;
    border-radius: 26px 26px 0 0;
    box-shadow: 0 -20px 60px rgba(25, 20, 16, 0.26);
    transform: translateY(105%);
    transition: transform 240ms cubic-bezier(.22,.75,.2,1);
  }

  .reader-body.notes-open .reader-notes {
    transform: translateY(0);
  }

  .mobile-notes-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: Georgia, 'Songti SC', serif;
    font-size: 1.15rem;
  }

  .mobile-notes-head::before {
    content: '';
    position: absolute;
    top: 7px;
    left: 50%;
    width: 38px;
    height: 4px;
    border-radius: 999px;
    background: var(--line);
    transform: translateX(-50%);
  }

  .reader-notes .note-form {
    max-height: 48dvh;
    overflow: auto;
  }

  .reader-notes .form-row.two {
    grid-template-columns: 1fr 1fr;
  }

  .reader-notes .note-list {
    overflow: auto;
  }

  .notes-backdrop {
    position: fixed;
    z-index: 10000;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    background: rgba(17, 18, 16, 0.42);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }

  .notes-backdrop:not([hidden]) {
    display: block;
  }
}
