:root {
  --bg: #f6f1e7;
  --surface: #fffdf7;
  --surface-2: #f1e9d8;
  --ink: #2b2620;
  --text-soft: #4a4237;
  --muted: #8a8071;
  --accent: #b0762c;
  --accent-strong: #8f5f22;
  --line: #e6ddc9;
  --topbar-bg: rgba(246, 241, 231, 0.92);
  --danger: #b3522c;
  --shadow: 0 10px 30px rgba(64, 49, 30, 0.12);
  --radius: 14px;
  color-scheme: light;
  --font-ui: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Noto Serif SC", "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", Georgia, "Times New Roman", serif;
}

html[data-theme="dark"] {
  --bg: #171512;
  --surface: #201d18;
  --surface-2: #2b2721;
  --ink: #e6dfd0;
  --text-soft: #c4bba8;
  --muted: #97907e;
  --accent: #d09a44;
  --accent-strong: #e8bc72;
  --line: #35302a;
  --topbar-bg: rgba(23, 21, 18, 0.92);
  --danger: #d4714a;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

/* ---------- Base ---------- */

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.reading { overflow: hidden; }
body.reading .topbar { display: none; }

a { color: inherit; text-decoration: none; }

button { font-family: inherit; }

.view { max-width: 1200px; margin: 0 auto; padding: 22px clamp(14px, 4vw, 32px) 60px; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px clamp(14px, 4vw, 32px);
  background: var(--topbar-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 1.18rem;
  letter-spacing: 0.2px;
  flex-shrink: 0;
}

.brand-name { color: var(--ink); }

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(176, 118, 44, 0.15);
}

.search-icon { color: var(--muted); flex-shrink: 0; }

#searchInput {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.93rem;
  color: var(--ink);
  min-width: 0;
}

#searchInput::-webkit-search-cancel-button { display: none; }

.search-clear {
  border: none;
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  line-height: 1;
  font-size: 11px;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-import {
  flex-shrink: 0;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent-strong);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-import:hover { background: var(--accent); color: #fff; }

html[data-theme="dark"] .btn-import:hover,
html[data-theme="dark"] .chip.active,
html[data-theme="dark"] .seg button.active,
html[data-theme="dark"] .btn-primary {
  color: #241d12;
}

.theme-toggle {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
}

.theme-toggle:hover { border-color: var(--accent); color: var(--accent-strong); }

.theme-toggle svg { width: 17px; height: 17px; }

/* Search dropdown */

.search-drop {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-height: 70vh;
  overflow-y: auto;
  padding: 6px;
}

.search-drop .sd-section {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 10px 12px 4px;
}

.sd-item {
  display: block;
  padding: 9px 12px;
  border-radius: 9px;
  cursor: pointer;
}

.sd-item:hover, .sd-item.active { background: var(--surface-2); }

.sd-item .sd-title { font-weight: 600; font-size: 0.93rem; }
.sd-item .sd-sub { font-size: 0.8rem; color: var(--muted); margin-top: 1px; }
.sd-item .sd-snip {
  font-size: 0.82rem;
  color: var(--ink);
  margin-top: 4px;
  font-family: var(--font-serif);
  line-height: 1.5;
}

.sd-item .sd-snip b { color: var(--accent-strong); }

.sd-empty { padding: 16px 12px; color: var(--muted); font-size: 0.88rem; text-align: center; }

/* ---------- Library ---------- */

.library-head { margin: 8px 0 18px; }

.library-head h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  margin: 0 0 2px;
}

.library-head .sub { color: var(--muted); font-size: 0.92rem; }

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 16px 0 20px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.chip:hover { border-color: var(--accent); }

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.chip .count { opacity: 0.65; font-size: 0.78rem; margin-left: 4px; }

.section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 26px 0 12px;
}

.continue-strip {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
}

.cont-card {
  flex: 0 0 auto;
  width: 210px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
}

.cont-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

.cont-card .cc-title { font-weight: 700; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cont-card .cc-meta { font-size: 0.78rem; color: var(--muted); margin: 3px 0 10px; }

.cc-bar { height: 4px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.cc-bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.cont-card .cc-pct { font-size: 0.75rem; color: var(--muted); margin-top: 6px; }

/* Book grid */

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 22px 18px;
}

.book-card { cursor: pointer; transition: transform 0.15s; }
.book-card:hover { transform: translateY(-3px); }
.book-card:hover .cover { box-shadow: 0 14px 30px rgba(64, 49, 30, 0.28); }

.cover {
  aspect-ratio: 3 / 4.2;
  border-radius: 10px 13px 13px 10px;
  padding: 16px 14px 12px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  color: #fff;
  box-shadow: 0 6px 16px rgba(64, 49, 30, 0.18);
  transition: box-shadow 0.15s;
}

.cover::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0) 34%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.22) 0 5px, rgba(0, 0, 0, 0) 9px);
  pointer-events: none;
}

.cover .c-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.06rem;
  line-height: 1.32;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
  word-break: break-word;
}

.cover .c-author {
  font-size: 0.74rem;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.cover .c-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 0.66rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.32);
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}

.book-card .b-title {
  margin: 10px 2px 0;
  font-weight: 600;
  font-size: 0.94rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-card .b-meta { margin: 3px 2px 0; font-size: 0.8rem; color: var(--muted); }

.link-author { cursor: pointer; }
.link-author:hover { color: var(--accent-strong); text-decoration: underline; }

.empty-state {
  text-align: center;
  padding: 70px 20px;
  color: var(--muted);
}

.empty-state .big { font-size: 2.6rem; margin-bottom: 10px; }
.empty-state h2 { font-family: var(--font-serif); margin: 0 0 6px; color: var(--ink); }
.empty-state p { margin: 0 auto 18px; max-width: 420px; font-size: 0.92rem; }

/* ---------- Book detail ---------- */

.book-hero {
  display: flex;
  gap: 26px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(18px, 3.5vw, 30px);
  box-shadow: var(--shadow);
}

.book-hero .cover { width: 170px; flex-shrink: 0; }

.bh-info { flex: 1; min-width: 0; }

.bh-info h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.4rem, 3vw, 2rem);
  margin: 2px 0 6px;
}

.bh-author { color: var(--muted); font-size: 0.95rem; margin-bottom: 10px; }

.bh-cat {
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--accent-strong);
  background: rgba(176, 118, 44, 0.12);
  padding: 3px 12px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.bh-desc {
  font-family: var(--font-serif);
  line-height: 1.85;
  color: var(--text-soft);
  margin: 0 0 18px;
}

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

.btn-primary {
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 11px 26px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(176, 118, 44, 0.35);
  transition: background 0.15s, transform 0.15s;
}

.btn-primary:hover { background: var(--accent-strong); transform: translateY(-1px); }

.btn-ghost {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.9rem;
  padding: 10px 20px;
  border-radius: 999px;
  cursor: pointer;
}

.btn-ghost:hover { border-color: var(--accent); color: var(--accent-strong); }

.bh-stats { display: flex; gap: 22px; font-size: 0.84rem; color: var(--muted); margin-top: 16px; flex-wrap: wrap; }
.bh-stats b { color: var(--ink); font-size: 0.95rem; }

.chapter-list {
  margin-top: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.chapter-list .cl-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  font-size: 0.95rem;
}

.chapter-list ol {
  list-style: none;
  margin: 0;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  max-height: 480px;
  overflow-y: auto;
}

.chapter-list li a {
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--ink);
}

.chapter-list li a:hover { background: var(--surface-2); }

.chapter-list .n {
  color: var(--muted);
  font-size: 0.78rem;
  min-width: 2.2em;
  text-align: right;
  flex-shrink: 0;
  padding-top: 2px;
}

.chapter-list .ct {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Search results page ---------- */

.result-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: box-shadow 0.15s;
}

.result-card:hover { box-shadow: var(--shadow); }

.result-card .rc-title { font-weight: 700; font-size: 1rem; }
.result-card .rc-sub { color: var(--muted); font-size: 0.8rem; margin: 2px 0 6px; }
.result-card .rc-snip {
  font-family: var(--font-serif);
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-soft);
}

.result-card mark {
  background: rgba(176, 118, 44, 0.22);
  color: var(--accent-strong);
  border-radius: 3px;
  padding: 0 1px;
}

/* ---------- Reader ---------- */

.reader {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--r-bg);
  color: var(--r-ink);
  transition: background 0.25s;
}

.reader[data-theme="light"] { --r-bg: #fbf7ee; --r-ink: #2b2620; --r-muted: #95896f; --r-line: #e9e0ca; --r-surface: #fffdf5; }
.reader[data-theme="sepia"] { --r-bg: #efe2c8; --r-ink: #4a3a26; --r-muted: #93815f; --r-line: #decfa9; --r-surface: #f6ecd5; }
.reader[data-theme="dark"] { --r-bg: #1c1a17; --r-ink: #d8d1c2; --r-muted: #8b8577; --r-line: #322e28; --r-surface: #24211d; }

.reader[data-theme="dark"] .r-flow mark { background: rgba(176, 118, 44, 0.4); color: #f0e4cf; }

.r-top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px clamp(10px, 3vw, 20px);
  padding-top: calc(8px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--r-line);
  background: var(--r-bg);
  z-index: 20;
  transition: transform 0.25s;
}

.r-titles {
  flex: 1;
  min-width: 0;
  text-align: center;
  line-height: 1.25;
}

.r-titles .r-book {
  font-size: 0.8rem;
  color: var(--r-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.r-titles .r-ch {
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.r-icon {
  border: none;
  background: transparent;
  color: var(--r-ink);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.05rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

.r-icon:hover { background: rgba(128, 100, 60, 0.14); }

.r-progress { height: 3px; background: var(--r-line); z-index: 20; }
.r-progress i { display: block; height: 100%; background: var(--accent); width: 0; transition: width 0.2s; }

.r-viewport {
  position: relative;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.r-flow {
  height: 100%;
  box-sizing: border-box;
  padding: clamp(14px, 3vw, 30px) clamp(16px, 4vw, 40px);
  column-fill: auto;
  font-family: var(--font-serif);
  user-select: text;
}

/* Standard measure: widen the side padding instead of shrinking the flow box —
   a narrower centered flow would leave neighbor columns visible beside the
   current page when paging by translateX. */
.reader[data-width="narrow"] .r-flow {
  padding-left: max(clamp(16px, 4vw, 40px), calc((100% - 680px) / 2));
  padding-right: max(clamp(16px, 4vw, 40px), calc((100% - 680px) / 2));
}

.r-flow p {
  margin: 0 0 1em;
  text-indent: 2em;
  line-height: var(--r-lh, 1.9);
  font-size: var(--r-fs, 20px);
  text-align: justify;
}

.r-flow mark {
  background: rgba(176, 118, 44, 0.22);
  color: inherit;
  border-radius: 3px;
}

.r-flow .r-chhead {
  text-align: center;
  font-weight: 700;
  text-indent: 0;
  margin: 0.1em 0 1.4em;
  font-size: 1.12em;
  line-height: var(--r-lh, 1.9);
}

.reader[data-family="sans"] .r-flow { font-family: var(--font-ui); }

.reader[data-mode="paged"] .r-flow { transition: transform 0.28s ease; }

.r-flow.no-anim { transition: none !important; }

.reader[data-mode="scroll"] .r-viewport { overflow-y: auto; }

.reader[data-mode="scroll"] .r-flow { height: auto; }

.r-end {
  margin: 1.5em 0;
  text-align: center;
  color: var(--r-muted);
  font-size: 0.85em;
  text-indent: 0 !important;
}

.r-tapzones { position: absolute; inset: 0; display: flex; z-index: 5; }
.r-tapzones .tz { flex: 1; }
.r-tapzones .tz-mid { flex: 1.2; }

.r-bottom {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px clamp(10px, 3vw, 20px);
  padding-bottom: calc(6px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--r-line);
  background: var(--r-bg);
  z-index: 20;
  font-size: 0.85rem;
  color: var(--r-muted);
  transition: transform 0.25s;
}

.r-bottom .r-pos { flex: 1; text-align: center; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.r-nav {
  border: 1px solid var(--r-line);
  background: transparent;
  color: var(--r-ink);
  font-size: 0.85rem;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.r-nav:hover { background: rgba(128, 100, 60, 0.12); }
.r-nav:disabled { opacity: 0.4; cursor: default; }

.reader.immersive .r-top { transform: translateY(-110%); }
.reader.immersive .r-bottom { transform: translateY(110%); }
.reader.immersive .r-progress { opacity: 0.25; }

/* Reader drawers */

.r-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  width: min(360px, 88vw);
  background: var(--r-surface);
  z-index: 60;
  display: flex;
  flex-direction: column;
  transition: transform 0.28s ease;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.25);
}

.r-drawer.right { right: 0; transform: translateX(105%); border-radius: 16px 0 0 16px; }
.r-drawer.left { left: 0; transform: translateX(-105%); border-radius: 0 16px 16px 0; }
.r-drawer.open { transform: translateX(0); }

.r-drawer .rd-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--r-line);
  font-weight: 700;
  flex-shrink: 0;
  padding-top: calc(14px + env(safe-area-inset-top));
}

.r-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(24, 18, 10, 0.4);
  z-index: 55;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.r-backdrop.show { opacity: 1; pointer-events: auto; }

/* TOC */

.r-toc-list {
  flex: 1;
  overflow-y: auto;
  margin: 0;
  padding: 8px;
  list-style: none;
}

.r-toc-list a {
  display: flex;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--r-ink);
}

.r-toc-list a:hover { background: rgba(128, 100, 60, 0.1); }
.r-toc-list a.current { background: rgba(176, 118, 44, 0.16); font-weight: 600; color: var(--accent-strong); }
.reader[data-theme="dark"] .r-toc-list a.current { color: #e2b26a; }
.r-toc-list .n { color: var(--r-muted); font-size: 0.76rem; min-width: 2em; text-align: right; padding-top: 3px; flex-shrink: 0; }
.r-toc-list .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Settings */

.r-set-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 20px; }

.set-group .set-label {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--r-muted);
  margin-bottom: 9px;
}

.seg {
  display: flex;
  border: 1px solid var(--r-line);
  border-radius: 10px;
  overflow: hidden;
}

.seg button {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--r-ink);
  padding: 8px 4px;
  font-size: 0.85rem;
  cursor: pointer;
  border-right: 1px solid var(--r-line);
}

.seg button:last-child { border-right: none; }
.seg button.active { background: var(--accent); color: #fff; font-weight: 600; }

.set-range {
  display: flex;
  align-items: center;
  gap: 12px;
}

.set-range input[type="range"] { flex: 1; accent-color: var(--accent); }
.set-range .val { min-width: 2.6em; text-align: center; font-size: 0.85rem; color: var(--r-ink); }

.set-range .r-aa { font-family: var(--font-serif); color: var(--r-ink); }

/* Loading */

.r-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--r-muted);
  font-size: 0.9rem;
  background: var(--r-bg);
  z-index: 10;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--r-line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Import modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(24, 18, 10, 0.45);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal {
  background: var(--surface);
  border-radius: 16px;
  width: min(620px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(20, 14, 6, 0.35);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  font-size: 1.05rem;
}

.modal-close {
  border: none;
  background: var(--surface-2);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.modal-body { padding: 20px; overflow-y: auto; }

.dropzone {
  border: 2px dashed var(--line);
  border-radius: 14px;
  padding: 34px 20px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone.drag, .dropzone:hover { border-color: var(--accent); background: rgba(176, 118, 44, 0.06); }

.dropzone .dz-icon { font-size: 2rem; margin-bottom: 8px; }
.dropzone .dz-hint { font-size: 0.9rem; }
.dropzone .dz-formats { font-size: 0.78rem; margin-top: 6px; opacity: 0.8; }

.import-form { display: flex; flex-direction: column; gap: 14px; }

.import-form label { font-size: 0.78rem; font-weight: 700; color: var(--muted); display: block; margin-bottom: 4px; }

.import-form input[type="text"], .import-form textarea, .import-form select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 0.92rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--bg);
  outline: none;
}

.import-form input:focus, .import-form textarea:focus, .import-form select:focus { border-color: var(--accent); }

.import-form textarea { resize: vertical; min-height: 64px; }

.if-row { display: flex; gap: 12px; }
.if-row > div { flex: 1; }

.if-preview {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--muted);
}

.if-preview b { color: var(--ink); }

.import-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }

.import-status { font-size: 0.85rem; color: var(--muted); text-align: center; padding: 12px; }

.import-status.error { color: var(--danger); }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: #2b2620;
  color: #f6f1e7;
  padding: 11px 22px;
  border-radius: 999px;
  font-size: 0.9rem;
  z-index: 200;
  box-shadow: 0 10px 30px rgba(20, 14, 6, 0.35);
  animation: toast-in 0.25s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
  .brand-name { display: none; }

  .btn-import { padding: 7px 12px; font-size: 0.84rem; }

  .book-grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 16px 12px; }

  .book-hero { flex-direction: column; align-items: center; text-align: center; }
  .book-hero .cover { width: 150px; }
  .bh-actions { justify-content: center; }
  .bh-stats { justify-content: center; }

  .chapter-list ol { grid-template-columns: 1fr; max-height: 380px; }

  .view { padding-bottom: 40px; }

  .r-flow p { text-align: left; }
}
