:root {
  --bg: #f7f1e5;
  --bg-elevated: rgba(255, 251, 244, 0.88);
  --bg-panel: rgba(255, 250, 242, 0.94);
  --bg-soft: rgba(255, 248, 239, 0.8);
  --text-primary: #2e261d;
  --text-secondary: #72624d;
  --text-muted: #978771;
  --border: rgba(86, 69, 48, 0.12);
  --shadow: 0 24px 60px rgba(51, 38, 21, 0.12);
  --reader-max-width: 860px;
  --reader-padding-inline: clamp(16px, 3.5vw, 36px);
  --reader-padding-block: clamp(96px, 11vh, 132px);
  --font-family-reading: "Songti SC", "STSong", "Noto Serif SC", "Georgia", serif;
  --font-family-ui: "Avenir Next", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  --font-size-reading: 20px;
  --line-height-reading: 2.00;
  --theme-accent: #b49062;
  --theme-accent-strong: #8d6a3a;
  --highlight-yellow: #f1e7b8;
  --highlight-green: #dceacf;
  --highlight-blue: #d7e5f0;
  --danger: #b25545;
  --reader-keyboard-inset: 0px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  overscroll-behavior-y: none;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.55), transparent 28%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.3), transparent 30%),
    var(--bg);
  color: var(--text-primary);
  font-family: var(--font-family-ui);
  transition:
    background 180ms ease,
    color 180ms ease;
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 24px 24px;
  content: "";
  opacity: 0.35;
}

body.theme-paper {
  --bg: #f8f4ea;
  --bg-elevated: rgba(255, 251, 243, 0.9);
  --bg-panel: rgba(255, 252, 246, 0.95);
  --bg-soft: rgba(255, 248, 239, 0.86);
  --text-primary: #30261a;
  --text-secondary: #6f5d45;
  --text-muted: #9d8c73;
  --border: rgba(97, 75, 49, 0.12);
  --theme-accent: #b88a57;
  --theme-accent-strong: #936531;
}

body.theme-mist {
  --bg: #edf1e5;
  --bg-elevated: rgba(245, 248, 238, 0.9);
  --bg-panel: rgba(248, 250, 244, 0.96);
  --bg-soft: rgba(241, 245, 235, 0.88);
  --text-primary: #243025;
  --text-secondary: #5a6a5d;
  --text-muted: #879386;
  --border: rgba(61, 82, 65, 0.12);
  --theme-accent: #7f9d73;
  --theme-accent-strong: #617953;
}

body.theme-dark {
  --bg: #16191c;
  --bg-elevated: rgba(23, 27, 30, 0.92);
  --bg-panel: rgba(28, 33, 37, 0.95);
  --bg-soft: rgba(34, 39, 43, 0.88);
  --text-primary: #dde4e9;
  --text-secondary: #a8b3ba;
  --text-muted: #7b868f;
  --border: rgba(201, 214, 222, 0.1);
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.34);
  --theme-accent: #9bb49a;
  --theme-accent-strong: #c9d7c4;
  --highlight-yellow: rgba(165, 141, 64, 0.42);
  --highlight-green: rgba(92, 129, 101, 0.42);
  --highlight-blue: rgba(92, 122, 152, 0.42);
  color-scheme: dark;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--text-primary);
  padding: 14px 16px;
  outline: none;
  transition:
    border-color 140ms ease,
    background 140ms ease;
}

body.theme-dark input,
body.theme-dark textarea {
  background: rgba(255, 255, 255, 0.03);
}

input:focus,
textarea:focus {
  border-color: rgba(96, 129, 82, 0.4);
  background: rgba(255, 255, 255, 0.7);
}

textarea {
  min-height: 136px;
  resize: vertical;
  line-height: 1.7;
}

#app {
  position: relative;
  min-height: 100vh;
}

.screen {
  position: relative;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.login-screen {
  display: grid;
  place-items: center;
  padding: 32px;
}

.login-card {
  width: min(460px, 100%);
  border: 1px solid var(--border);
  border-radius: 32px;
  background: linear-gradient(
      145deg,
      rgba(255, 255, 255, 0.72),
      rgba(255, 251, 245, 0.52)
    ),
    var(--bg-elevated);
  box-shadow: var(--shadow);
  padding: 32px 30px 28px;
  backdrop-filter: blur(14px);
}

.eyebrow {
  color: var(--theme-accent-strong);
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.login-title,
.shelf-title,
.notes-title {
  margin: 14px 0 10px;
  font-family: var(--font-family-reading);
  font-size: clamp(30px, 5vw, 42px);
  font-weight: 600;
  line-height: 1.15;
}

.muted {
  color: var(--text-secondary);
}

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

.hint-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 13px;
}

.primary-button,
.secondary-button,
.danger-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  border-radius: 999px;
  padding: 0 18px;
  transition:
    transform 120ms ease,
    opacity 120ms ease,
    background 120ms ease;
}

.primary-button:hover,
.secondary-button:hover,
.danger-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.primary-button {
  background: var(--theme-accent);
  color: #fffdf7;
}

.secondary-button {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--border);
}

.danger-button {
  background: rgba(178, 85, 69, 0.12);
  color: var(--danger);
}

.ghost-button {
  color: var(--text-secondary);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.46);
  border: 1px solid var(--border);
  padding: 8px 12px;
  color: var(--text-secondary);
  font-size: 13px;
}

.top-shell {
  max-width: 1220px;
  margin: 0 auto;
  padding: 28px clamp(20px, 4vw, 38px) 60px;
}

.shelf-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 28px;
}

.shelf-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.search-bar {
  position: relative;
  width: min(460px, 100%);
}

.search-bar input {
  padding-left: 44px;
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.shelf-subtitle {
  max-width: 560px;
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.7;
}

.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 168px));
  gap: 26px 22px;
  justify-content: flex-start;
}

.book-card {
  position: relative;
  display: grid;
  gap: 12px;
  width: 100%;
  max-width: 168px;
}

.book-card.selection-mode .book-card-button {
  cursor: pointer;
}

.book-card.selected .book-cover {
  box-shadow:
    inset 0 0 0 2px rgba(96, 129, 82, 0.52),
    0 24px 44px rgba(28, 20, 11, 0.18);
}

.book-card-button {
  display: grid;
  gap: 12px;
  text-align: left;
}

.book-cover {
  position: relative;
  aspect-ratio: 0.72;
  width: 100%;
  border-radius: 22px;
  overflow: hidden;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.12),
    0 22px 40px rgba(28, 20, 11, 0.16);
}

.book-cover::before {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 65%);
  content: "";
}

.book-cover::after {
  position: absolute;
  inset: 0 auto 0 0;
  width: 14px;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.12),
    rgba(255, 255, 255, 0.08)
  );
  content: "";
}

.cover-image,
.cover-fallback {
  position: absolute;
  inset: 0;
}

.cover-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
}

.cover-image.loaded + .cover-fallback {
  opacity: 0;
}

.cover-fallback {
  z-index: 1;
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.16), transparent 36%),
    linear-gradient(160deg, #916f51, #5c4737 58%, #261f19);
  color: rgba(255, 248, 239, 0.95);
}

.cover-fallback .cover-inner {
  inset: 18px 20px 22px 22px;
}

.cover-inner {
  position: absolute;
  inset: 18px 20px 22px 26px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: rgba(255, 255, 255, 0.94);
}

.cover-kicker {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.78;
}

.cover-name {
  font-family: var(--font-family-reading);
  font-size: 30px;
  line-height: 1.15;
}

.cover-author {
  font-size: 13px;
  opacity: 0.82;
}

.book-meta {
  display: grid;
  gap: 5px;
}

.book-name {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.45;
}

.book-sub {
  color: var(--text-secondary);
  font-size: 14px;
}

.book-bottom {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  color: var(--text-muted);
  font-size: 13px;
}

.book-menu-trigger {
  position: absolute;
  right: 8px;
  top: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(18, 18, 18, 0.2);
  color: #fff;
  backdrop-filter: blur(10px);
}

.book-select-badge {
  position: absolute;
  right: 10px;
  top: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: rgba(18, 18, 18, 0.16);
  color: transparent;
  font-size: 15px;
  font-weight: 700;
  z-index: 3;
  backdrop-filter: blur(10px);
}

.book-select-badge.selected {
  background: rgba(96, 129, 82, 0.92);
  border-color: rgba(255, 255, 255, 0.88);
  color: #fff;
}

.selected-books-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.trash-sheet {
  width: min(860px, calc(100vw - 24px));
}

.trash-list {
  display: grid;
  gap: 14px;
}

.trash-item {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.44);
}

body.theme-dark .trash-item {
  background: rgba(255, 255, 255, 0.03);
}

.trash-item.is-unrecoverable {
  opacity: 0.72;
}

.trash-cover {
  position: relative;
  aspect-ratio: 0.72;
  width: 84px;
  border-radius: 18px;
  overflow: hidden;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.12),
    0 18px 32px rgba(28, 20, 11, 0.14);
}

.trash-cover::before {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 65%);
  content: "";
}

.trash-cover::after {
  position: absolute;
  inset: 0 auto 0 0;
  width: 10px;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.12),
    rgba(255, 255, 255, 0.08)
  );
  content: "";
}

.trash-cover .cover-inner {
  inset: 12px 12px 14px 16px;
}

.trash-cover .cover-name {
  font-size: 18px;
}

.trash-cover .cover-author {
  font-size: 11px;
}

.trash-meta {
  min-width: 0;
}

.trash-title {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.45;
}

.trash-subtitle {
  margin-top: 4px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.trash-hint {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}

.trash-actions {
  display: flex;
  justify-content: flex-end;
}

.empty-state {
  margin-top: 64px;
  padding: 52px 24px;
  border: 1px dashed var(--border);
  border-radius: 28px;
  text-align: center;
  color: var(--text-secondary);
}

.reader-screen {
  background: transparent;
}

.reader-shell {
  position: relative;
  min-height: 100vh;
  overflow-anchor: none;
}

.reader-toolbar,
.reader-bottom-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: min(calc(100vw - 22px), 1180px);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  backdrop-filter: blur(16px);
  z-index: 20;
  transition:
    opacity 150ms ease,
    transform 160ms ease,
    visibility 160ms ease;
  box-shadow: var(--shadow);
}

.reader-toolbar {
  top: max(12px, env(safe-area-inset-top));
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  border-radius: 22px;
  padding: 14px 18px;
}

.reader-toolbar.hidden-ui {
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -8px);
}

.reader-bottom-bar {
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  border-radius: 22px;
  padding: 14px 18px;
}

.reader-bottom-bar.hidden-ui {
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 10px);
}

.toolbar-section {
  display: flex;
  gap: 12px;
  align-items: center;
}

.reader-nav-group {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar-title {
  min-width: 0;
}

.toolbar-title strong {
  display: block;
  font-size: 15px;
}

.toolbar-title span {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 13px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.42);
}

body.theme-dark .icon-button {
  background: rgba(255, 255, 255, 0.04);
}

.reader-surface {
  position: relative;
  min-height: 100vh;
  padding:
    calc(var(--reader-padding-block) + 20px)
    var(--reader-padding-inline)
    calc(var(--reader-padding-block) + 40px);
  touch-action: pan-y;
  overscroll-behavior-y: contain;
  overflow-anchor: none;
}

.reader-content-shell {
  width: min(100%, var(--reader-max-width));
  min-height: 70vh;
  margin: 0 auto;
  overflow-anchor: none;
}

#reader-overlay-layer {
  position: relative;
  pointer-events: none;
}

.reader-content {
  width: min(100%, var(--reader-max-width));
  margin: 0 auto;
  font-family: var(--font-family-reading);
  font-size: var(--font-size-reading);
  line-height: var(--line-height-reading);
  letter-spacing: 0.01em;
}

.reader-title {
  margin: 0 0 34px;
  font-family: var(--font-family-reading);
  font-size: clamp(36px, 7vw, 54px);
  font-weight: 600;
  line-height: 1.1;
}

.reader-paragraph {
  margin: 0 0 28px;
  text-wrap: pretty;
}

.reader-paragraph:last-child {
  margin-bottom: 0;
}

.reader-highlight {
  position: relative;
  border-radius: 8px;
  padding: 0 2px;
  cursor: pointer;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.highlight-yellow {
  background: linear-gradient(180deg, transparent 34%, var(--highlight-yellow) 34%);
}

.highlight-green {
  background: linear-gradient(180deg, transparent 34%, var(--highlight-green) 34%);
}

.highlight-blue {
  background: linear-gradient(180deg, transparent 34%, var(--highlight-blue) 34%);
}

.reader-highlight::after {
  position: absolute;
  inset: auto 0 -3px;
  height: 2px;
  border-radius: 999px;
  background: rgba(125, 98, 62, 0.34);
  content: "";
}

body.theme-dark .reader-highlight::after {
  background: rgba(214, 221, 225, 0.25);
}

.selection-bubble,
.annotation-sheet,
.reader-menu,
.toc-sheet,
.settings-sheet,
.book-menu,
.dialog-backdrop,
.export-sheet {
  z-index: 30;
}

.selection-bubble,
.annotation-sheet,
.reader-menu,
.toc-sheet,
.book-menu {
  position: fixed;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--bg-panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.selection-bubble {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
}

.annotation-sheet-backdrop {
  z-index: 31;
}

.annotation-sheet {
  --annotation-sheet-offset: 0px;
  left: 50%;
  right: auto;
  top: auto;
  bottom: 0;
  width: min(720px, calc(100vw - 12px));
  max-height: min(78vh, 760px);
  padding: 0;
  border-radius: 28px 28px 0 0;
  transform: translate(-50%, var(--annotation-sheet-offset));
  overflow: hidden;
  z-index: 32;
  transition: transform 180ms ease;
}

.annotation-sheet-handle-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 34px;
  cursor: grab;
  touch-action: none;
}

.annotation-sheet-handle {
  display: block;
  width: 46px;
  height: 5px;
  border-radius: 999px;
  background: rgba(117, 103, 85, 0.24);
}

.annotation-sheet-scroll {
  max-height: calc(min(78vh, 760px) - 34px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 18px 22px;
}

.annotation-sheet-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.annotation-sheet-subtitle {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 13px;
}

.annotation-title {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.annotation-excerpt {
  margin: 0 0 14px;
  padding-left: 14px;
  border-left: 3px solid var(--border);
  color: var(--text-secondary);
  line-height: 1.8;
}

.annotation-note {
  margin: 0;
  line-height: 1.9;
}

.annotation-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  color: var(--text-muted);
  font-size: 13px;
}

.popover-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.action-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  border-radius: 999px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.action-chip.is-disabled {
  opacity: 0.42;
  pointer-events: none;
}

.color-dots {
  display: flex;
  gap: 8px;
  align-items: center;
}

.color-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
}

.color-dot.active {
  border-color: rgba(29, 26, 22, 0.72);
}

body.theme-dark .color-dot.active {
  border-color: rgba(255, 255, 255, 0.85);
}

body.theme-dark .annotation-sheet-handle {
  background: rgba(255, 255, 255, 0.18);
}

.color-dot[data-color="yellow"] {
  background: var(--highlight-yellow);
}

.color-dot[data-color="green"] {
  background: var(--highlight-green);
}

.color-dot[data-color="blue"] {
  background: var(--highlight-blue);
}

.sheet {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(560px, calc(100vw - 24px));
  max-height: min(78vh, 720px);
  overflow: auto;
  transform: translate(-50%, -50%);
  border: 1px solid var(--border);
  border-radius: 28px;
  background: var(--bg-panel);
  box-shadow: var(--shadow);
  padding: 22px;
  backdrop-filter: blur(20px);
  z-index: 40;
  -webkit-overflow-scrolling: touch;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 13, 0.22);
  backdrop-filter: blur(3px);
}

.sheet-header,
.notes-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.sheet-title {
  font-size: 18px;
  font-weight: 600;
}

.sheet-subtitle {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 14px;
}

.composer-excerpt {
  margin: 12px 0 18px;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--bg-soft);
  color: var(--text-secondary);
  line-height: 1.8;
}

.sheet-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.menu-list,
.toc-list {
  display: grid;
  gap: 8px;
}

.menu-item,
.toc-item,
.setting-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  border-radius: 18px;
  padding: 0 14px;
  text-align: left;
  background: rgba(255, 255, 255, 0.46);
  border: 1px solid transparent;
}

body.theme-dark .menu-item,
body.theme-dark .toc-item,
body.theme-dark .setting-option {
  background: rgba(255, 255, 255, 0.03);
}

.menu-item:hover,
.toc-item:hover,
.setting-option:hover {
  border-color: var(--border);
}

.setting-group {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.setting-label {
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

.theme-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid transparent;
  text-align: left;
}

.theme-card.active {
  border-color: var(--theme-accent);
}

body.theme-dark .theme-card {
  background: rgba(255, 255, 255, 0.03);
}

.theme-preview {
  height: 80px;
  border-radius: 14px;
  overflow: hidden;
}

.theme-preview.paper {
  background:
    linear-gradient(180deg, #f9f4e8 0%, #fcfaf4 100%);
}

.theme-preview.mist {
  background:
    linear-gradient(180deg, #e9efe1 0%, #f6f8f1 100%);
}

.theme-preview.dark {
  background:
    linear-gradient(180deg, #151a1c 0%, #22282c 100%);
}

.theme-preview::before,
.theme-preview::after {
  display: block;
  width: 72%;
  height: 8px;
  margin: 16px auto 0;
  border-radius: 999px;
  background: rgba(110, 110, 110, 0.14);
  content: "";
}

.theme-preview.dark::before,
.theme-preview.dark::after {
  background: rgba(255, 255, 255, 0.12);
}

.notes-screen {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px clamp(20px, 4vw, 34px) 80px;
}

.notes-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
}

.notes-search {
  margin-top: 18px;
}

.notes-group {
  margin-top: 28px;
}

.notes-group-title {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.note-card {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--bg-elevated);
  box-shadow: 0 18px 42px rgba(38, 32, 24, 0.08);
}

.note-card-top,
.inline-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.note-excerpt {
  margin: 0;
  padding-left: 12px;
  border-left: 3px solid var(--border);
  color: var(--text-secondary);
  line-height: 1.8;
}

.note-text {
  margin: 0;
  line-height: 1.8;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.48);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
}

.badge-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.badge-dot.yellow {
  background: #d3bb6d;
}

.badge-dot.green {
  background: #89a27f;
}

.badge-dot.blue {
  background: #7fa1c3;
}

.pdf-stage {
  width: min(100%, 780px);
  margin: 0 auto;
}

.pdf-view {
  width: min(100%, 820px);
  margin: 0 auto;
}

.pdf-page-shell {
  display: flex;
  justify-content: center;
  margin-bottom: 28px;
  padding: 18px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.28);
  border: 1px solid var(--border);
}

body.theme-dark .pdf-page-shell {
  background: rgba(255, 255, 255, 0.03);
}

.pdf-canvas {
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 16px;
  box-shadow: 0 22px 40px rgba(0, 0, 0, 0.14);
}

.epub-stage {
  width: min(100%, var(--reader-max-width));
  margin: 0 auto;
}

.epub-view {
  min-height: 72vh;
  overflow: visible;
  touch-action: pan-y;
  overscroll-behavior-y: contain;
  overflow-anchor: none;
}

.epub-view .epub-container {
  overflow: visible !important;
  overscroll-behavior-y: contain !important;
  overflow-anchor: none;
}

.epub-view iframe {
  display: block;
  width: 100% !important;
  min-height: 72vh !important;
  border: 0;
  background: transparent;
  touch-action: pan-y;
  overscroll-behavior-y: contain;
  overflow-anchor: none;
}

.pdf-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
}

.pdf-page {
  aspect-ratio: 0.74;
  width: 100%;
  margin-bottom: 22px;
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(246, 242, 235, 0.92)),
    #fff;
  box-shadow: 0 28px 54px rgba(25, 21, 15, 0.12);
  padding: 40px;
}

.pdf-page:last-child {
  margin-bottom: 0;
}

.pdf-line {
  display: block;
  height: 10px;
  margin-bottom: 14px;
  border-radius: 999px;
  background: rgba(58, 46, 34, 0.09);
}

.pdf-line.short {
  width: 46%;
}

.pdf-line.medium {
  width: 68%;
}

.pdf-line.long {
  width: 100%;
}

.menu-anchor {
  position: absolute;
}

.upload-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.offline-pill {
  background: rgba(124, 96, 62, 0.1);
  color: var(--text-secondary);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  min-width: 220px;
  max-width: calc(100vw - 24px);
  padding: 14px 18px;
  border-radius: 18px;
  background: rgba(18, 21, 24, 0.8);
  color: rgba(255, 255, 255, 0.92);
  text-align: center;
  z-index: 60;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.3);
}

.helper-copy {
  margin-top: 14px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  line-height: 1.7;
  font-size: 14px;
}

@media (max-width: 760px) {
  .shelf-header,
  .notes-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .shelf-actions,
  .notes-toolbar {
    width: 100%;
    flex-wrap: wrap;
  }

  .search-bar {
    width: 100%;
  }

  .books-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px 16px;
  }

  .book-card {
    max-width: none;
  }

  .book-name {
    font-size: 14px;
  }

  .reader-toolbar,
  .reader-bottom-bar {
    width: calc(100vw - 16px);
    border-radius: 18px;
    padding: 12px;
  }

  .reader-nav-group {
    width: 100%;
    justify-content: space-between;
  }

  .toolbar-title span {
    display: none;
  }

  .reader-surface {
    padding:
      calc(var(--reader-padding-block) + 4px)
      6px
      calc(var(--reader-padding-block) + 24px);
  }

  .pdf-page-shell {
    padding: 10px;
    border-radius: 20px;
  }

  .sheet {
    left: 0;
    right: 0;
    top: auto;
    bottom: var(--reader-keyboard-inset);
    width: 100vw;
    max-height: min(84dvh, calc(100dvh - var(--reader-keyboard-inset) - 12px));
    transform: none;
    border-radius: 24px 24px 0 0;
    padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  }

  .sheet textarea {
    min-height: 112px;
  }

  .annotation-sheet {
    width: calc(100vw - 8px);
    bottom: var(--reader-keyboard-inset);
    max-height: min(84dvh, calc(100dvh - var(--reader-keyboard-inset) - 8px));
  }

  .annotation-sheet-scroll {
    max-height: calc(min(84dvh, calc(100dvh - var(--reader-keyboard-inset) - 8px)) - 34px);
  }

  .trash-item {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .trash-cover {
    width: 72px;
  }

  .trash-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

@media (max-width: 540px) {
  .books-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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