:root {
  --paper: #f3efe5;
  --paper-deep: #e8dfcf;
  --ink: #1f211c;
  --muted: #6c6b62;
  --line: rgba(31, 33, 28, 0.15);
  --accent: #b74931;
  --accent-dark: #8f3221;
  --panel: #252820;
  --white: #fffdf7;
  --shadow: 0 28px 80px rgba(47, 40, 25, 0.14);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(31, 33, 28, 0.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 33, 28, 0.018) 1px, transparent 1px),
    var(--paper);
  background-size: 24px 24px;
  font-family: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", Georgia, serif;
}

button, input { font: inherit; }
button { color: inherit; }

.site-shell { min-height: 100vh; overflow: hidden; }

.topbar {
  width: min(1200px, calc(100% - 48px));
  height: 92px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.14em;
}
.brand { justify-self: start; }

.bookshelf-entry {
  min-height: 34px;
  padding: 0 13px;
  border: 0;
  border-radius: 99px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-family: system-ui, sans-serif;
  font-size: 12px;
  transition: color 150ms ease, background 150ms ease;
}
.bookshelf-entry:hover, .bookshelf-entry.is-active { color: var(--ink); background: rgba(31,33,28,.07); }
.bookshelf-entry span {
  min-width: 17px;
  height: 17px;
  display: inline-grid;
  place-items: center;
  margin-left: 3px;
  border-radius: 50%;
  color: white;
  background: var(--accent);
  font-size: 9px;
}

.brand-mark {
  position: relative;
  width: 32px;
  height: 36px;
  display: inline-block;
  border: 2px solid var(--ink);
  border-radius: 2px 8px 8px 2px;
  transform: rotate(-2deg);
}

.brand-mark::before, .brand-mark::after, .brand-mark i {
  content: "";
  position: absolute;
  left: 7px;
  right: 5px;
  height: 1px;
  background: currentColor;
  opacity: 0.7;
}
.brand-mark::before { top: 10px; }
.brand-mark i { top: 16px; }
.brand-mark::after { top: 22px; }
.brand-mark.small { width: 24px; height: 28px; border-width: 1.5px; }
.brand-mark.small::before { top: 8px; left: 5px; }
.brand-mark.small i { top: 13px; left: 5px; }
.brand-mark.small::after { top: 18px; left: 5px; }

.topbar-actions { justify-self: end; display: flex; align-items: center; gap: 22px; }
.install-button {
  min-height: 36px;
  padding: 0 15px;
  border: 1px solid var(--ink);
  border-radius: 99px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  font-family: system-ui, sans-serif;
  font-size: 12px;
  font-weight: 650;
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}
.install-button:hover { color: var(--paper); background: var(--ink); transform: translateY(-1px); }
.install-button[hidden] { display: none; }

.privacy-pill {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-family: system-ui, sans-serif;
  font-size: 12px;
  letter-spacing: 0.04em;
}
.privacy-pill b { font-weight: 400; }
.privacy-pill span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #507c55;
  box-shadow: 0 0 0 4px rgba(80, 124, 85, 0.12);
}

.landing {
  width: min(1200px, calc(100% - 48px));
  min-height: calc(100vh - 154px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: clamp(48px, 8vw, 120px);
  align-items: center;
  padding: 64px 0 72px;
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
}

.hero h1 {
  margin: 0;
  font-size: clamp(48px, 6.2vw, 82px);
  line-height: 1.08;
  font-weight: 600;
  letter-spacing: -0.06em;
}
.hero h1 em { color: var(--accent); font-weight: 500; }

.hero-copy {
  width: min(570px, 100%);
  margin: 28px 0 40px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.9;
}

.drop-card {
  position: relative;
  width: min(620px, 100%);
  min-height: 202px;
  display: grid;
  grid-template-columns: 78px 1fr auto;
  grid-template-rows: 1fr auto;
  align-items: center;
  gap: 16px 22px;
  padding: 29px 30px 20px;
  background: rgba(255, 253, 247, 0.66);
  border: 1px solid rgba(31, 33, 28, 0.13);
  box-shadow: var(--shadow);
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}
.drop-card::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px dashed rgba(31, 33, 28, 0.2);
  pointer-events: none;
}
.drop-card.is-dragging {
  transform: translateY(-4px);
  border-color: var(--accent);
  background: var(--white);
}

.file-glyph {
  position: relative;
  width: 62px;
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  box-shadow: 7px 7px 0 var(--paper-deep);
}
.file-glyph::after {
  content: "";
  position: absolute;
  top: -1.5px;
  right: -1.5px;
  width: 18px;
  height: 18px;
  background: linear-gradient(225deg, transparent 48%, var(--ink) 49%, var(--ink) 53%, var(--paper) 54%);
}
.file-glyph span { color: var(--accent); font-size: 25px; font-weight: 800; }
.file-glyph i {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 13px;
  height: 1px;
  background: var(--ink);
  opacity: 0.3;
}
.file-glyph i:nth-of-type(2) { bottom: 18px; right: 21px; }
.file-glyph i:nth-of-type(3) { bottom: 23px; }

.drop-copy h2 { margin: 0 0 8px; font-size: 18px; }
.drop-copy p { margin: 0; color: var(--muted); font-family: system-ui, sans-serif; font-size: 13px; }

.primary-button {
  position: relative;
  z-index: 1;
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-family: system-ui, sans-serif;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.03em;
  transition: background 160ms ease, transform 160ms ease;
}
.primary-button:hover { background: var(--accent-dark); transform: translateY(-1px); }
.primary-button span { margin-left: 8px; }
.file-note {
  grid-column: 1 / -1;
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: system-ui, sans-serif;
  font-size: 11px;
  text-align: center;
}

.feature-panel { align-self: stretch; display: flex; flex-direction: column; justify-content: center; }
.editorial-card {
  position: relative;
  min-height: 435px;
  padding: 64px 54px;
  overflow: hidden;
  color: var(--white);
  background: var(--panel);
  box-shadow: 22px 25px 0 var(--paper-deep);
}
.editorial-card::before {
  content: "";
  position: absolute;
  width: 230px;
  height: 230px;
  right: -115px;
  bottom: -115px;
  border: 1px solid rgba(255, 253, 247, 0.2);
  border-radius: 50%;
  box-shadow: 0 0 0 34px rgba(255, 253, 247, 0.025), 0 0 0 72px rgba(255, 253, 247, 0.018);
}
.quote-mark { color: var(--accent); font-size: 72px; line-height: 0.7; }
.editorial-card blockquote { margin: 37px 0 20px; font-size: 28px; line-height: 1.65; letter-spacing: 0.04em; }
.editorial-card p { color: rgba(255,255,255,.55); font-size: 13px; letter-spacing: .12em; }
.page-lines { position: absolute; left: 54px; right: 54px; bottom: 52px; display: grid; gap: 7px; }
.page-lines span { height: 1px; background: rgba(255,255,255,.11); }
.page-lines span:nth-child(2) { width: 91%; }
.page-lines span:nth-child(4) { width: 76%; }
.page-lines span:nth-child(5) { width: 44%; }

.feature-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 34px; background: var(--line); }
.feature-list div { display: flex; gap: 12px; min-height: 78px; padding: 18px 12px; background: var(--paper); }
.feature-list strong { color: var(--accent); font-family: ui-monospace, monospace; font-size: 10px; }
.feature-list span { font-size: 12px; line-height: 1.65; }

.landing-footer {
  width: min(1200px, calc(100% - 48px));
  height: 62px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: ui-monospace, monospace;
  font-size: 9px;
  letter-spacing: 0.18em;
}

.bookshelf {
  width: min(1200px, calc(100% - 48px));
  min-height: calc(100vh - 154px);
  margin: 0 auto;
  padding: 58px 0 72px;
}
.bookshelf-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 30px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}
.bookshelf-heading h1 { margin: 0 0 10px; font-size: clamp(42px, 6vw, 72px); line-height: 1; letter-spacing: -.055em; }
.bookshelf-heading > div > p:last-child { margin: 0; color: var(--muted); font: 13px system-ui, sans-serif; }
.add-book-button { flex: 0 0 auto; min-width: 148px; }
.book-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 40px 28px;
  padding: 38px 0 48px;
}
.book-card { position: relative; min-width: 0; }
.book-open {
  width: 100%;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.shelf-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: rgba(255,255,255,.92);
  background: var(--cover-color, #5d6452);
  box-shadow: 12px 15px 0 var(--paper-deep), 0 18px 38px rgba(45,39,27,.12);
  transition: transform 180ms ease, box-shadow 180ms ease;
}
.book-open:hover .shelf-cover { transform: translateY(-5px); box-shadow: 12px 20px 0 var(--paper-deep), 0 22px 45px rgba(45,39,27,.18); }
.shelf-cover::before {
  content: "";
  position: absolute;
  inset: 13px;
  border: 1px solid rgba(255,255,255,.24);
  pointer-events: none;
}
.shelf-cover img { width: 100%; height: 100%; object-fit: cover; }
.shelf-monogram { font-size: clamp(38px, 5vw, 70px); font-weight: 500; }
.shelf-format { position: absolute; left: 22px; bottom: 20px; font: 9px ui-monospace, monospace; letter-spacing: .18em; opacity: .65; }
.book-meta { padding-top: 20px; }
.book-meta strong { display: block; min-height: 42px; overflow: hidden; font-size: 15px; line-height: 1.45; }
.book-meta > span { display: block; margin-top: 6px; overflow: hidden; color: var(--muted); font: 11px system-ui, sans-serif; text-overflow: ellipsis; white-space: nowrap; }
.book-progress { height: 2px; margin-top: 14px; overflow: hidden; background: rgba(31,33,28,.12); }
.book-progress i { display: block; height: 100%; width: var(--progress, 0%); background: var(--accent); }
.book-status { display: flex; justify-content: space-between; margin-top: 7px; color: var(--muted); font: 9px ui-monospace, monospace; }
.remove-book {
  position: absolute;
  z-index: 2;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  color: white;
  background: rgba(22,24,20,.72);
  opacity: 0;
  cursor: pointer;
  transition: opacity 150ms ease, background 150ms ease;
}
.book-card:hover .remove-book, .remove-book:focus-visible { opacity: 1; }
.remove-book:hover { background: var(--accent); }
.bookshelf-note { margin: 0; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font: 11px system-ui, sans-serif; text-align: center; }

.reader {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: 66px minmax(0, 1fr) 46px;
  background: #f7f2e8;
  color: #22231e;
}
.reader[hidden] { display: none; }
.reader[data-theme="light"] { background: #f8f7f3; }
.reader[data-theme="dark"] { background: #20221f; color: #dedbd2; }

.reader-header {
  position: relative;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid rgba(31,33,28,.12);
  background: color-mix(in srgb, currentColor 2%, transparent);
}
.reader[data-theme="dark"] .reader-header,
.reader[data-theme="dark"] .reader-footer { border-color: rgba(255,255,255,.1); }
.reader-header-left, .reader-actions, .reader-brand { display: flex; align-items: center; }
.reader-header-left { gap: 14px; min-width: 0; }
.reader-brand { gap: 12px; min-width: 0; }
.reader-brand > div { display: flex; flex-direction: column; min-width: 0; }
.reader-title { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 700; }
.reader-chapter { margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-family: system-ui, sans-serif; font-size: 10px; }
.reader[data-theme="dark"] .reader-chapter { color: #aaa79f; }
.reader-actions { gap: 4px; }
.toolbar-divider { width: 1px; height: 22px; margin: 0 6px; background: var(--line); }

.icon-button, .text-button {
  min-width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: background 150ms ease;
}
.icon-button:hover, .text-button:hover { background: rgba(31,33,28,.08); }
.reader[data-theme="dark"] .icon-button:hover,
.reader[data-theme="dark"] .text-button:hover { background: rgba(255,255,255,.08); }
.text-button { width: auto; padding: 0 12px; border-radius: 20px; font-family: system-ui, sans-serif; font-size: 12px; }
.type-button { font-family: Georgia, serif; font-size: 13px; }
.type-button.large { font-size: 15px; }

.reader-stage { position: relative; min-height: 0; overflow: hidden; }
.book-host, .book-host foliate-view { display: block; width: 100%; height: 100%; }
.reader[data-theme="dark"] foliate-view::part(filter) { filter: invert(.88) hue-rotate(180deg); }

.loading-state {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: inherit;
  transition: opacity 250ms ease;
}
.loading-state[hidden] { display: none; }
.loading-state strong { font-size: 16px; }
.loading-state small { color: var(--muted); font-family: system-ui, sans-serif; }
.loading-mark {
  width: 30px;
  height: 38px;
  margin-bottom: 10px;
  border: 2px solid currentColor;
  border-right-color: var(--accent);
  animation: page-turn 1s ease-in-out infinite alternate;
  transform-origin: left center;
}
@keyframes page-turn { to { transform: perspective(140px) rotateY(-35deg); } }

.page-zone {
  position: absolute;
  z-index: 3;
  top: 50%;
  width: 42px;
  height: 68px;
  transform: translateY(-50%);
  border: 0;
  background: rgba(31,33,28,.055);
  color: currentColor;
  opacity: .28;
  cursor: pointer;
  font: 34px/1 Georgia, serif;
  transition: opacity 160ms ease, background 160ms ease;
}
.page-zone:hover { opacity: .85; background: rgba(31,33,28,.11); }
.page-zone-left { left: 14px; }
.page-zone-right { right: 14px; }
.reader[data-flow="scrolled"] .page-zone { display: none; }

.reader-footer {
  position: relative;
  z-index: 8;
  display: grid;
  grid-template-columns: 58px 1fr 80px;
  gap: 12px;
  align-items: center;
  padding: 0 22px;
  border-top: 1px solid rgba(31,33,28,.12);
  font-family: ui-monospace, monospace;
  font-size: 10px;
}
.progress-text { color: var(--accent); font-weight: 700; }
.location-text { text-align: right; color: var(--muted); }
#progressSlider { width: 100%; height: 3px; accent-color: var(--accent); cursor: pointer; }

.toc-panel {
  position: fixed;
  z-index: 20;
  inset: 0 auto 0 0;
  width: min(380px, 88vw);
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 15px 0 55px rgba(0,0,0,.2);
  transform: translateX(-105%);
  visibility: hidden;
  transition: transform 240ms ease, visibility 240ms;
}
.toc-panel.is-open { transform: translateX(0); visibility: visible; }
.toc-backdrop { position: fixed; z-index: 19; inset: 0; border: 0; background: rgba(10,12,9,.38); cursor: default; }
.toc-header { display: flex; align-items: center; justify-content: space-between; padding: 28px 26px 20px; border-bottom: 1px solid var(--line); }
.toc-header p { margin: 0 0 5px; color: var(--accent); font: 9px ui-monospace, monospace; letter-spacing: .2em; }
.toc-header h2 { margin: 0; font-size: 26px; }
.toc-header .icon-button { font-size: 28px; }
.book-summary { display: flex; align-items: center; gap: 15px; padding: 20px 26px; background: rgba(255,255,255,.22); border-bottom: 1px solid var(--line); }
.cover-placeholder, #bookCover { width: 48px; height: 66px; flex: 0 0 auto; object-fit: cover; box-shadow: 3px 4px 0 var(--paper-deep); }
.cover-placeholder { display: flex; align-items: center; justify-content: center; color: var(--white); background: var(--accent); font-size: 20px; font-weight: 700; }
.book-summary > div:last-child { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.book-summary strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.book-summary span { color: var(--muted); font-family: system-ui, sans-serif; font-size: 11px; }
.toc-list { flex: 1; overflow: auto; padding: 16px 14px 36px; }
.toc-group { margin: 0; padding: 0; list-style: none; }
.toc-group .toc-group { padding-left: 15px; }
.toc-link, .toc-empty { display: block; width: 100%; padding: 10px 12px; border: 0; border-radius: 3px; color: inherit; background: transparent; text-align: left; cursor: pointer; font-size: 13px; line-height: 1.4; }
.toc-link:hover, .toc-link.is-current { color: var(--accent); background: rgba(183,73,49,.08); }
.toc-empty { color: var(--muted); cursor: default; }

.reader-tool-button { font: 12px/1 system-ui, sans-serif; }
.reader-tool-button.is-active { color: var(--accent); background: rgba(183,73,49,.1); }
.tools-panel {
  position: fixed;
  z-index: 20;
  inset: 0 0 0 auto;
  width: min(420px, 92vw);
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background: var(--paper);
  box-shadow: -15px 0 55px rgba(0,0,0,.2);
  transform: translateX(105%);
  visibility: hidden;
  transition: transform 240ms ease, visibility 240ms;
}
.tools-panel.is-open { transform: translateX(0); visibility: visible; }
.tools-backdrop { position: fixed; z-index: 19; inset: 0; border: 0; background: rgba(10,12,9,.38); cursor: default; }
.tools-header { display: flex; align-items: center; justify-content: space-between; padding: 28px 26px 20px; border-bottom: 1px solid var(--line); }
.tools-header p { margin: 0 0 5px; color: var(--accent); font: 9px ui-monospace, monospace; letter-spacing: .2em; }
.tools-header h2 { margin: 0; font-size: 26px; }
.tools-header .icon-button { font-size: 28px; }
.tools-tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); }
.tools-tab { height: 48px; border: 0; border-bottom: 2px solid transparent; color: var(--muted); background: transparent; cursor: pointer; font: 12px system-ui, sans-serif; }
.tools-tab:hover { color: var(--ink); background: rgba(31,33,28,.035); }
.tools-tab.is-active { border-bottom-color: var(--accent); color: var(--accent); font-weight: 700; }
.tools-tab span { display: inline-grid; min-width: 17px; height: 17px; place-items: center; margin-left: 3px; border-radius: 9px; color: var(--muted); background: var(--paper-deep); font-size: 9px; }
.tool-view { flex: 1; min-height: 0; overflow: auto; }
.tool-view[hidden] { display: none; }
.book-search { display: grid; grid-template-columns: 1fr 64px; gap: 8px; padding: 20px 20px 0; }
.book-search input { min-width: 0; height: 42px; padding: 0 13px; border: 1px solid var(--line); border-radius: 2px; color: var(--ink); background: rgba(255,255,255,.45); font: 13px system-ui, sans-serif; outline: none; }
.book-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(183,73,49,.1); }
.book-search button { border: 0; border-radius: 2px; color: white; background: var(--ink); cursor: pointer; font: 12px system-ui, sans-serif; }
.book-search button:hover { background: var(--accent); }
.tool-status, .tool-hint { margin: 0; padding: 14px 20px; color: var(--muted); font: 11px/1.6 system-ui, sans-serif; }
.tool-hint { border-bottom: 1px solid var(--line); background: rgba(255,255,255,.2); }
.tool-list { padding: 0 14px 30px; }
.tool-empty { margin: 32px 10px; color: var(--muted); text-align: center; font: 12px/1.7 system-ui, sans-serif; }
.tool-item { position: relative; display: block; width: 100%; padding: 15px 42px 15px 12px; border: 0; border-bottom: 1px solid var(--line); color: var(--ink); background: transparent; text-align: left; }
button.tool-item { cursor: pointer; }
button.tool-item:hover { background: rgba(183,73,49,.055); }
.tool-item-label { display: block; margin-bottom: 7px; color: var(--accent); font: 9px/1.3 ui-monospace, monospace; letter-spacing: .08em; text-transform: uppercase; }
.tool-item-copy { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 3; font: 13px/1.65 system-ui, sans-serif; }
.tool-item-note { display: block; margin-top: 8px; padding-left: 9px; border-left: 2px solid var(--accent); color: var(--muted); font: 12px/1.55 system-ui, sans-serif; }
.search-match { color: var(--accent); background: transparent; font-weight: 700; }
.tool-item-actions { position: absolute; top: 10px; right: 5px; display: flex; flex-direction: column; }
.tool-mini-button { width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%; color: var(--muted); background: transparent; cursor: pointer; }
.tool-mini-button:hover { color: var(--accent); background: rgba(183,73,49,.09); }

.selection-toolbar { position: fixed; z-index: 18; left: 50%; bottom: 62px; width: min(520px, calc(100vw - 28px)); display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 11px 12px 11px 16px; transform: translateX(-50%); color: #f5f2ea; background: rgba(31,33,28,.96); box-shadow: 0 12px 35px rgba(0,0,0,.26); }
.selection-toolbar[hidden] { display: none; }
.selection-toolbar > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #c9c5bb; font: 11px system-ui, sans-serif; }
.selection-toolbar > div { display: flex; flex: 0 0 auto; gap: 4px; }
.selection-toolbar button { height: 32px; padding: 0 11px; border: 0; color: white; background: transparent; cursor: pointer; font: 12px system-ui, sans-serif; }
.selection-toolbar button:hover { background: rgba(255,255,255,.12); }
#highlightSelectionButton { color: #f1c466; }
#cancelSelectionButton { width: 32px; padding: 0; border-radius: 50%; font-size: 18px; }

.note-modal { position: fixed; z-index: 55; inset: 0; display: grid; place-items: center; padding: 22px; background: rgba(20,20,16,.68); }
.note-modal[hidden] { display: none; }
.note-card { width: min(500px, 100%); padding: 30px; color: var(--ink); background: var(--paper); box-shadow: var(--shadow); }
.note-card > p { margin: 0 0 7px; color: var(--accent); font: 9px ui-monospace, monospace; letter-spacing: .2em; }
.note-card h2 { margin: 0 0 18px; font-size: 25px; }
.note-card blockquote { max-height: 105px; overflow: auto; margin: 0 0 16px; padding: 10px 13px; border-left: 2px solid #e0b94f; color: var(--muted); background: rgba(255,255,255,.3); font: 12px/1.65 system-ui, sans-serif; }
.note-card textarea { box-sizing: border-box; width: 100%; resize: vertical; padding: 12px; border: 1px solid var(--line); color: var(--ink); background: rgba(255,255,255,.45); font: 14px/1.6 system-ui, sans-serif; outline: none; }
.note-card textarea:focus { border-color: var(--accent); }
.note-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 16px; }
.note-actions .primary-button, .secondary-button { min-width: 92px; height: 40px; padding: 0 18px; border: 0; border-radius: 2px; cursor: pointer; font: 12px system-ui, sans-serif; }
.secondary-button { color: var(--ink); background: var(--paper-deep); }

.toast { position: fixed; z-index: 40; left: 50%; bottom: 72px; transform: translateX(-50%); padding: 10px 16px; border-radius: 99px; color: white; background: rgba(31,33,28,.88); font: 12px system-ui, sans-serif; box-shadow: 0 8px 28px rgba(0,0,0,.2); }
.error-modal { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(20,20,16,.65); }
.error-modal[hidden], .toast[hidden] { display: none; }
.error-card { width: min(410px, 100%); padding: 38px; text-align: center; background: var(--paper); box-shadow: var(--shadow); }
.error-symbol { width: 46px; height: 46px; display: inline-grid; place-items: center; border: 1px solid var(--accent); border-radius: 50%; color: var(--accent); font-size: 23px; }
.error-card h2 { margin: 20px 0 10px; }
.error-card p { margin: 0 0 25px; color: var(--muted); font: 14px/1.7 system-ui, sans-serif; }

@media (max-width: 900px) {
  .landing { grid-template-columns: 1fr; padding-top: 45px; }
  .feature-panel { display: none; }
  .hero { max-width: 680px; margin: 0 auto; }
  .drop-card { grid-template-columns: 64px 1fr; }
  .drop-card .primary-button { grid-column: 1 / -1; }
  .reader-title { max-width: 190px; }
  .book-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .topbar, .landing, .landing-footer, .bookshelf { width: min(100% - 30px, 1200px); }
  .topbar { height: 76px; }
  .brand { gap: 8px; font-size: 17px; }
  .brand-mark { width: 26px; height: 30px; }
  .privacy-pill { display: none; }
  .topbar-actions { gap: 0; }
  .landing { min-height: calc(100vh - 130px); padding: 40px 0 50px; }
  .bookshelf { min-height: calc(100vh - 130px); padding: 38px 0 50px; }
  .bookshelf-heading { align-items: start; }
  .bookshelf-heading h1 { font-size: 42px; }
  .add-book-button { min-width: auto; padding: 0 13px; }
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 34px 20px; padding-top: 30px; }
  .shelf-cover { box-shadow: 8px 10px 0 var(--paper-deep), 0 14px 28px rgba(45,39,27,.12); }
  .book-meta strong { font-size: 13px; }
  .remove-book { opacity: .82; }
  .hero h1 { font-size: clamp(42px, 13vw, 62px); }
  .hero-copy { margin: 22px 0 30px; font-size: 15px; }
  .drop-card { display: flex; flex-direction: column; align-items: stretch; padding: 28px 24px 20px; text-align: center; }
  .file-glyph { align-self: center; }
  .reader { grid-template-rows: 58px minmax(0, 1fr) 42px; }
  .reader-header { padding: 0 8px; }
  .reader-brand .brand-mark, .reader-chapter, .toolbar-divider, #fontDownButton, #flowButton, #libraryButton, #newBookButton { display: none; }
  .reader-title { max-width: calc(100vw - 235px); font-size: 12px; }
  .reader-actions { gap: 0; }
  .text-button { padding: 0 7px; font-size: 11px; }
  .icon-button { min-width: 34px; width: 34px; height: 34px; }
  .page-zone { width: 32px; height: 58px; background: transparent; }
  .page-zone-left { left: 0; }
  .page-zone-right { right: 0; }
  .reader-footer { grid-template-columns: 42px 1fr 55px; gap: 8px; padding: 0 10px; }
  .selection-toolbar { bottom: 51px; }
  .selection-toolbar > span { display: none; }
  .selection-toolbar { width: auto; }
  .note-card { padding: 24px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
