@font-face {
  font-family: ReaderSystem;
  src: local("Microsoft YaHei");
}
:root {
  font-family: ReaderSystem, "Segoe UI", sans-serif;
  color-scheme: light;
  --bg: #f6f4ef;
  --panel: #eeece5;
  --surface: #fffcf6;
  --text: #303c36;
  --muted: #80877e;
  --line: #dddfd5;
  --accent: #446a55;
  --accent-soft: #e2e9df;
  --shadow: 0 12px 32px #283b3010;
  --font-size: 21px;
  --line-height: 1.9;
  --reading-width: 740px;
  --reading-gutter: 19.918699%;
  --reader-font: "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}
body[data-theme="light"] {
  --bg: #fafbfc;
  --panel: #f0f2f4;
  --surface: #fff;
  --text: #27333b;
  --muted: #79848a;
  --line: #dde3e7;
  --accent: #446b80;
  --accent-soft: #e3edf2;
}
body[data-theme="green"] {
  --bg: #eaf0e7;
  --panel: #dde6da;
  --surface: #f0f6ed;
  --text: #304234;
  --muted: #70816e;
  --line: #cbd7c7;
  --accent: #436d4a;
  --accent-soft: #d1e1ce;
}
body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1d2422;
  --panel: #232d28;
  --surface: #29352f;
  --text: #d3ded4;
  --muted: #8e9f92;
  --line: #39473f;
  --accent: #acd0ad;
  --accent-soft: #354c3d;
  --shadow: 0 12px 32px #0002;
}
button,
input,
select {
  font: inherit;
}
button {
  cursor: pointer;
  color: inherit;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 14px;
  transition:
    background 0.15s,
    transform 0.15s;
}
button:hover {
  background: var(--accent-soft);
}
button:active {
  transform: translateY(1px);
}
button:disabled {
  opacity: 0.35;
  cursor: default;
}
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
input,
select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
input[type="range"] {
  padding: 0;
  accent-color: var(--accent);
}
[hidden] {
  display: none !important;
}
.primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  padding: 12px 23px;
  box-shadow: var(--shadow);
}
.primary:hover {
  background: var(--accent);
  filter: brightness(1.1);
}
.muted {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}
.eyebrow {
  letter-spacing: 3px;
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 14px;
}
.rail {
  width: 90px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 12px 18px;
  gap: 14px;
}
.brand {
  font-family: serif;
  background: var(--accent);
  color: var(--bg);
  font-size: 28px;
  width: 45px;
  height: 45px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  margin-bottom: 46px;
  position: relative;
}
.brand span {
  position: absolute;
  top: 55px;
  color: var(--text);
  font:
    12px ReaderSystem,
    sans-serif;
  letter-spacing: 5px;
  padding-left: 5px;
  white-space: nowrap;
}
.rail-button {
  border: none;
  font-size: 11px;
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 5px;
  width: 62px;
  padding: 12px 0;
  color: var(--muted);
}
.rail-button span {
  font-size: 24px;
  line-height: 1.2;
}
.rail-button.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.rail-spacer {
  flex: 1;
}
.offline-dot {
  font-size: 10px;
  color: var(--accent);
  white-space: nowrap;
}
main {
  flex: 1;
  min-width: 0;
}
#library-view {
  height: 100%;
  overflow: auto;
  padding: 52px 6% 25px;
  display: flex;
  flex-direction: column;
}
.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
}
.library-header h1 {
  font-size: 34px;
  font-weight: 500;
  margin: 0;
  letter-spacing: 2px;
}
.small-dot {
  color: var(--accent);
  margin-left: 4px;
}
.library-header .muted {
  margin: 15px 0;
}
.library-toolbar {
  margin-top: 36px;
  padding: 22px 0;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}
.count {
  margin-left: 12px;
  color: var(--muted);
  font-size: 12px;
}
.library-toolbar input {
  width: 240px;
  background: transparent;
  font-size: 12px;
}
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 30px 26px;
  padding: 15px 0 40px;
}
.book-card {
  min-width: 0;
  position: relative;
}
.book-open {
  padding: 0;
  border: 0;
  width: 100%;
  text-align: left;
  display: block;
}
.book-open:hover {
  background: none;
}
.book-cover {
  height: 225px;
  background: var(--cover, #546b5b);
  color: #f6f1dd;
  padding: 23px 22px;
  border-radius: 3px 9px 9px 3px;
  box-shadow: 4px 8px 15px #0002;
  position: relative;
  overflow: hidden;
  border-left: 5px solid #ffffff22;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.book-cover:after {
  content: "";
  position: absolute;
  border: 1px solid #ffffff35;
  inset: 10px;
  pointer-events: none;
}
.book-cover strong {
  font-family: serif;
  font-size: 23px;
  font-weight: 500;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.book-cover small {
  font-size: 9px;
  letter-spacing: 3px;
  opacity: 0.7;
}
.book-meta {
  padding: 15px 0 4px;
}
.book-meta b {
  font-size: 14px;
  font-weight: 500;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 23px;
}
.book-meta p {
  font-size: 11px;
  color: var(--muted);
  margin: 8px 0;
}
.book-remove {
  position: absolute;
  bottom: 34px;
  right: -5px;
  border: none;
  padding: 2px 6px;
  color: var(--muted);
  font-size: 18px;
}
.progress-track {
  height: 2px;
  background: var(--line);
  margin-top: 12px;
}
.progress-track div {
  height: 100%;
  background: var(--accent);
}
.empty-library {
  flex: 1;
  min-height: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding-bottom: 45px;
}
.empty-art {
  width: 130px;
  height: 170px;
  background: #dce4d7;
  border-radius: 4px 10px 10px 4px;
  transform: rotate(-7deg);
  border-left: 7px solid #b8c9b5;
  box-shadow:
    18px 9px 0 -3px var(--panel),
    20px 10px 0 -2px var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: #5e765c;
  font: 48px serif;
  margin: 10px 0 28px;
}
.empty-art span {
  font: 8px sans-serif;
  letter-spacing: 1px;
  margin-top: 24px;
}
.empty-library h2 {
  font-size: 21px;
  font-weight: 500;
  margin: 10px;
}
.empty-library p {
  font-size: 13px;
  color: var(--muted);
  line-height: 2;
  margin-bottom: 24px;
}
.empty-library small {
  font-size: 10px;
  color: var(--muted);
  margin-top: 18px;
}
.library-footer {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-top: 20px;
  font-size: 11px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}
#reader-view {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.reader-header {
  height: 74px;
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  gap: 20px;
}
.reader-title {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}
.reader-title small {
  font-size: 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 6px;
  color: var(--muted);
}
.reader-title b {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reader-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.reader-actions button {
  border: 0;
  font-size: 12px;
  padding: 8px 10px;
}
.reader-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}
#side-panel {
  width: 270px;
  flex-shrink: 0;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  padding: 22px 16px;
}
.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
}
.panel-heading h2 {
  font-size: 18px;
  font-weight: 500;
  margin: 0;
}
.panel-heading button {
  border: 0;
  font-size: 22px;
  padding: 0 8px;
}
.panel-heading .eyebrow {
  margin-bottom: 9px;
}
#panel-search {
  width: 100%;
  font-size: 12px;
  margin: 20px 0 12px;
}
#panel-items {
  overflow: auto;
  flex: 1;
  padding-top: 10px;
}
.panel-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  font-size: 12px;
  padding: 11px 9px;
  border-radius: 6px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.panel-item.active {
  color: var(--accent);
  background: var(--accent-soft);
}
.panel-item small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin-bottom: 3px;
}
.panel-empty {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.9;
  padding: 8px;
}
#reading-scroll {
  overflow: auto;
  flex: 1;
  min-width: 0;
  padding: 50px
    max(
      34px,
      min(calc((100% - var(--reading-width)) / 2), var(--reading-gutter))
    );
  scroll-behavior: auto;
  overflow-anchor: none;
}
.reading-section {
  display: flow-root;
}
.reading-section + .reading-section {
  border-top: 1px solid var(--line);
  margin-top: 42px;
  padding-top: 42px;
}
.reading-section:last-child {
  min-height: calc(100vh - 230px);
  padding-bottom: calc(100vh - 160px);
}
.chapter-kicker {
  text-align: center;
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--muted);
  margin-bottom: 30px;
}
#content {
  font-family: var(--reader-font);
  font-size: var(--font-size);
  line-height: var(--line-height);
  overflow-wrap: anywhere;
  min-height: 45vh;
}
#reading-scroll[data-mode="paged"] {
  overflow: hidden;
  padding-block: 28px;
}
#reading-scroll:focus {
  outline: none;
}
#reading-scroll:focus-visible {
  outline: 1px solid var(--line);
  outline-offset: -1px;
}
#reading-scroll[data-mode="paged"] #content {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
#reading-scroll[data-mode="paged"] .reading-section {
  display: block;
  height: 100%;
  min-height: 0;
  padding: 0;
  margin: 0;
  column-count: 1;
  column-gap: 0;
  column-fill: auto;
}
#reading-scroll[data-mode="paged"] .chapter-navigation {
  display: none;
}
#reading-scroll[data-mode="paged"] p {
  orphans: 2;
  widows: 2;
}
#reading-scroll[data-mode="paged"] img {
  max-height: var(--page-image-height, 50vh);
  object-fit: contain;
  break-inside: avoid;
}
#reading-scroll[data-mode="paged"] pre {
  white-space: pre-wrap;
}
#page-controls {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 8px 20px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}
#page-number {
  color: var(--muted);
  min-width: 110px;
  text-align: center;
}
#content p {
  margin: 0 0 0.9em;
  text-indent: 2em;
}
#content h1,
#content h2,
#content h3 {
  text-align: center;
  line-height: 1.6;
  margin: 1em 0 1.8em;
  font-weight: 600;
}
#content h1 {
  font-size: 1.5em;
}
#content h2 {
  font-size: 1.3em;
}
#content h3 {
  font-size: 1.15em;
}
#content a {
  color: var(--accent);
  text-decoration: underline;
}
#content img {
  max-width: 100%;
  max-height: 80vh;
  display: block;
  margin: 1em auto;
}
#content table {
  max-width: 100%;
  border-collapse: collapse;
  font-size: 0.85em;
}
#content td,
#content th {
  border: 1px solid var(--line);
  padding: 8px;
}
#content blockquote {
  margin: 1em 0;
  padding: 0 1em;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}
#content pre {
  white-space: pre-wrap;
}
.chapter-navigation {
  display: flex;
  justify-content: space-between;
  margin: 60px 0 20px;
  gap: 15px;
}
.chapter-navigation button {
  font-size: 12px;
}
.reader-footer {
  height: 38px;
  flex-shrink: 0;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line);
  font-size: 10px;
  color: var(--muted);
}
#chapter-name {
  max-width: 40%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
dialog {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  width: 420px;
  max-height: 90vh;
  box-shadow: 0 20px 80px #0003;
}
dialog::backdrop {
  background: #17271e66;
  backdrop-filter: blur(3px);
}
dialog label {
  display: block;
  font-size: 12px;
  margin: 22px 0 10px;
}
dialog label small {
  font-size: 10px;
  color: var(--muted);
  float: right;
}
dialog select,
dialog input[type="range"] {
  width: 100%;
}
.theme-options {
  display: flex;
  gap: 8px;
}
.theme-options button {
  flex: 1;
  font-size: 12px;
  padding: 15px 4px;
}
.theme-options [data-theme="light"] {
  background: #fff;
  color: #333;
}
.theme-options [data-theme="paper"] {
  background: #efe9d9;
  color: #594e38;
}
.theme-options [data-theme="green"] {
  background: #dce9d7;
  color: #47603e;
}
.theme-options [data-theme="dark"] {
  background: #24302a;
  color: #d5e1d5;
}
.theme-options button.selected {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
output {
  float: right;
  color: var(--muted);
}
.wide-button {
  width: 100%;
  margin-top: 24px;
  font-size: 12px;
}
.settings-note {
  font-size: 10px;
  text-align: center;
  color: var(--muted);
  margin: 15px 0 0;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 25px;
}
.danger {
  color: #bf5a4f;
}
#selection-toolbar {
  position: fixed;
  display: flex;
  gap: 6px;
  z-index: 12;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 13px;
}
#lookup-dialog {
  width: min(580px, calc(100vw - 40px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  overscroll-behavior: contain;
  font-size: 14px;
  line-height: 1.8;
}
#lookup-text {
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 12px 16px;
  max-height: 140px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 18px;
}
.lookup-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
}
.lookup-heading h3 {
  margin: 0;
  font-size: 15px;
}
.lookup-heading small {
  color: var(--muted);
  font-size: 11px;
  font-weight: normal;
}
.lookup-heading button {
  font-size: 12px;
}
#lookup-pinyin {
  font-size: 18px;
  color: var(--accent);
  overflow-wrap: anywhere;
}
.lookup-note,
.lookup-example {
  color: var(--muted);
  font-size: 12px;
}
#lookup-result {
  overflow-wrap: anywhere;
}
#lookup-result h3 {
  font-size: 15px;
}
#lookup-result ol {
  padding-left: 24px;
}
#lookup-result li {
  margin-bottom: 12px;
}
#lookup-result p {
  margin: 6px 0;
}
#confirm-dialog p {
  font-size: 14px;
  line-height: 1.8;
}
#toast {
  position: fixed;
  bottom: 55px;
  left: 50%;
  transform: translateX(-50%);
  padding: 13px 23px;
  border-radius: 9px;
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow);
  font-size: 13px;
  z-index: 10;
  max-width: 75vw;
  line-height: 1.6;
}
#drop-overlay {
  position: fixed;
  inset: 12px;
  z-index: 20;
  border: 2px dashed var(--accent);
  border-radius: 18px;
  background: var(--bg);
  opacity: 0.97;
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 26px;
}
#drop-overlay span {
  display: block;
  text-align: center;
  font-size: 13px;
  margin-top: 20px;
  letter-spacing: 3px;
}
.mark-row {
  display: flex;
  align-items: center;
}
.bookmark-snippet {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 7px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.7;
}
.mark-row .panel-item {
  flex: 1;
}
.mark-delete {
  padding: 5px;
  border: 0;
  color: var(--muted);
}
@media (max-width: 1000px) {
  .reader-footer span:last-child {
    display: none;
  }
  .rail {
    width: 74px;
    padding-inline: 6px;
  }
  #library-view {
    padding: 35px 5% 20px;
  }
  #side-panel {
    width: 235px;
  }
  .reader-header {
    padding: 0 16px;
  }
  .reader-actions button {
    padding: 8px 6px;
  }
  .book-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
  .book-cover {
    height: 215px;
  }
}
