/* ============================================================
   墨淵小說館｜黑金暗夜書城 + 起點／讀墨五主題沉浸閱讀器
   ============================================================ */

:root {
  /* 書城黑金視覺系統 */
  --site-bg: #0D1016;
  --site-surface: #131822;
  --site-card: #161C27;
  --site-card-hover: #1C2331;
  --site-border: rgba(255, 255, 255, 0.08);
  --site-border-hover: rgba(212, 176, 106, 0.36);
  --site-text: #EAEFF7;
  --site-muted: #8E99AD;
  --site-dim: #647084;

  --gold: #D4B06A;
  --gold-hover: #E2C17E;
  --gold-dark: #1A150B;
  --gold-soft: rgba(212, 176, 106, 0.14);
  --gold-border: rgba(212, 176, 106, 0.35);

  --emerald: #34D399;
  --emerald-bg: rgba(16, 185, 129, 0.22);
  --emerald-text: #A7F3D0;

  /* 閱讀器排版動態變數 */
  --r-bg: #11141B;
  --r-surface: rgba(20, 25, 35, 0.9);
  --r-elevated: #181E2B;
  --r-text: #D5DCE8;
  --r-muted: #838FA4;
  --r-border: rgba(255, 255, 255, 0.09);
  --r-accent: #D4B06A;

  --reader-font: 'Noto Serif TC', serif;
  --reader-size: 19px;
  --reader-line-height: 1.9;
  --reader-para-gap: 1em;
  --reader-max-width: 760px;
  --reader-indent: 2em;
}

/* 閱讀器五款主題變數（僅影響閱讀器視圖） */
[data-reader-theme="dark"] {
  --r-bg: #11141B;
  --r-surface: rgba(20, 25, 35, 0.9);
  --r-elevated: #181E2B;
  --r-text: #D5DCE8;
  --r-muted: #838FA4;
  --r-border: rgba(255, 255, 255, 0.09);
  --r-accent: #D4B06A;
}

[data-reader-theme="amoled"] {
  --r-bg: #000000;
  --r-surface: rgba(14, 14, 18, 0.92);
  --r-elevated: #121216;
  --r-text: #BFC5D0;
  --r-muted: #6F7685;
  --r-border: rgba(255, 255, 255, 0.11);
  --r-accent: #D4B06A;
}

[data-reader-theme="sepia"] {
  --r-bg: #F5EFE2;
  --r-surface: rgba(240, 232, 214, 0.92);
  --r-elevated: #FAF5EA;
  --r-text: #2C241B;
  --r-muted: #7A6C5B;
  --r-border: rgba(44, 36, 27, 0.12);
  --r-accent: #9E3B33;
}

[data-reader-theme="green"] {
  --r-bg: #D2E8D4;
  --r-surface: rgba(196, 224, 199, 0.92);
  --r-elevated: #DFF0E1;
  --r-text: #1B3020;
  --r-muted: #4C6B53;
  --r-border: rgba(27, 48, 32, 0.12);
  --r-accent: #1E7145;
}

[data-reader-theme="light"] {
  --r-bg: #FFFFFF;
  --r-surface: rgba(248, 249, 251, 0.92);
  --r-elevated: #FFFFFF;
  --r-text: #1D2129;
  --r-muted: #6B7280;
  --r-border: rgba(0, 0, 0, 0.09);
  --r-accent: #B8332A;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--site-bg);
  color: var(--site-text);
  font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.hidden { display: none !important; }

button {
  font-family: inherit;
  cursor: pointer;
  transition: all 0.18s ease;
}

.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 24px 24px 72px;
}

/* ==================== 頂部導覽列 ==================== */
.site-navbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(13, 16, 22, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--site-border);
}

.navbar-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.brand-badge {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(145deg, #252015, #14171F);
  border: 1px solid var(--gold-border);
  color: var(--gold);
  font-family: 'Noto Serif TC', serif;
  font-size: 20px;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.brand-title {
  font-family: 'Noto Serif TC', serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--site-text);
}

.brand-sub {
  font-size: 11.5px;
  color: var(--site-muted);
  margin-top: 2px;
}

.nav-pills {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-pill {
  background: transparent;
  border: 1px solid transparent;
  color: var(--site-muted);
  padding: 7px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
}

.nav-pill:hover {
  color: var(--site-text);
  background: rgba(255, 255, 255, 0.04);
}

.nav-pill.active {
  color: var(--gold);
  background: var(--gold-soft);
  border-color: var(--gold-border);
}

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

/* 按鈕系統 */
.btn-gold {
  background: linear-gradient(135deg, #D9B672, #C49B50);
  color: var(--gold-dark);
  border: none;
  padding: 8px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(212, 176, 106, 0.22);
}

.btn-gold:hover {
  background: linear-gradient(135deg, #E5C584, #D1A95E);
  transform: translateY(-1px);
}

.btn-outline-gold {
  background: rgba(212, 176, 106, 0.08);
  color: var(--gold);
  border: 1px solid var(--gold-border);
  padding: 7px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
}

.btn-outline-gold:hover {
  background: rgba(212, 176, 106, 0.16);
}

.btn-outline-gold.off {
  background: transparent;
  color: var(--site-muted);
  border-color: var(--site-border);
}

.btn-dark-outline {
  background: rgba(255, 255, 255, 0.04);
  color: var(--site-text);
  border: 1px solid rgba(255, 255, 255, 0.13);
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
}

.btn-dark-outline:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.24);
}

.btn-lg { padding: 11px 22px; font-size: 14.5px; border-radius: 11px; }
.btn-sm { padding: 6px 13px; font-size: 13px; }
.btn-xs { padding: 4px 10px; font-size: 12px; border-radius: 8px; }

/* ==================== 主打推薦大橫幅 Hero ==================== */
.hero-banner {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--site-border);
  background: var(--site-surface);
  min-height: 250px;
  display: flex;
  align-items: flex-end;
  margin-bottom: 22px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.42);
}

.hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center 22%;
  opacity: 0.34;
  filter: blur(1px);
  transform: scale(1.03);
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(95deg, rgba(13, 16, 22, 0.96) 0%, rgba(13, 16, 22, 0.82) 55%, rgba(13, 16, 22, 0.45) 100%);
}

.hero-content {
  position: relative;
  z-index: 2;
  padding: 30px 32px;
  max-width: 760px;
}

.hero-badges {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.status-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}

.status-pill.live {
  background: var(--emerald-bg);
  color: var(--emerald-text);
  border: 1px solid rgba(52, 211, 153, 0.35);
}

.cat-outline-pill {
  font-size: 12px;
  color: var(--gold);
  background: var(--gold-soft);
  border: 1px solid var(--gold-border);
  padding: 3px 10px;
  border-radius: 8px;
}

.hero-author {
  font-size: 13px;
  color: var(--site-muted);
}

.hero-title {
  margin: 0 0 10px;
  font-family: 'Noto Serif TC', serif;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.hero-synopsis {
  margin: 0 0 22px;
  font-size: 14.5px;
  line-height: 1.75;
  color: #C7D1E0;
}

.hero-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* ==================== 橫幅廣告預覽區 ==================== */
.ad-slot-banner {
  border: 1px dashed rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 30px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.ad-slot-tag {
  background: rgba(212, 176, 106, 0.12);
  border: 1px solid var(--gold-border);
  color: var(--gold);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
}

.ad-slot-desc {
  flex: 1;
  font-size: 13px;
  color: var(--site-muted);
  line-height: 1.5;
}

.ad-slot-desc strong { color: var(--site-text); }

.ad-slot-hint {
  font-size: 12px;
  color: var(--site-dim);
  white-space: nowrap;
}

/* ==================== 書架區 ==================== */
.shelf-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.section-title {
  margin: 0 0 4px;
  font-family: 'Noto Serif TC', serif;
  font-size: 22px;
  font-weight: 700;
}

.section-sub {
  margin: 0;
  font-size: 13px;
  color: var(--site-muted);
}

.search-box input {
  width: 280px;
  max-width: 100%;
  background: var(--site-surface);
  border: 1px solid var(--site-border);
  color: var(--site-text);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.2s;
}

.search-box input::placeholder { color: var(--site-dim); }
.search-box input:focus { border-color: var(--gold-border); }

.category-filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.cat-filter-btn {
  background: var(--site-surface);
  border: 1px solid var(--site-border);
  color: var(--site-muted);
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
}

.cat-filter-btn:hover {
  color: var(--site-text);
  border-color: rgba(255, 255, 255, 0.2);
}

.cat-filter-btn.active {
  background: var(--gold);
  color: var(--gold-dark);
  border-color: var(--gold);
  font-weight: 700;
}

/* 三欄卡片式書架（對標墨淵小說館） */
.book-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.book-card {
  background: var(--site-card);
  border: 1px solid var(--site-border);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}

.book-card:hover {
  transform: translateY(-4px);
  border-color: var(--site-border-hover);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45);
}

.card-cover-wrap {
  position: relative;
  height: 196px;
  background: linear-gradient(145deg, #1A2436, #0E131D);
  overflow: hidden;
  cursor: pointer;
}

.card-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 22%;
  transition: transform 0.35s ease;
}

.book-card:hover .card-cover-img {
  transform: scale(1.04);
}

.card-cover-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  background: linear-gradient(150deg, #1E293B 0%, #111622 100%);
}

.card-cover-fallback .fb-cat {
  font-size: 12px;
  color: var(--gold);
  margin-bottom: 6px;
}

.card-cover-fallback .fb-title {
  font-family: 'Noto Serif TC', serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--site-text);
}

.card-status-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(16, 185, 129, 0.85);
  backdrop-filter: blur(6px);
  color: #052E1F;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}

.card-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.card-title {
  margin: 0;
  font-family: 'Noto Serif TC', serif;
  font-size: 19px;
  font-weight: 700;
  color: var(--site-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.card-title:hover { color: var(--gold); }

.card-cat-tag {
  font-size: 11.5px;
  color: var(--gold);
  background: rgba(212, 176, 106, 0.1);
  border: 1px solid rgba(212, 176, 106, 0.25);
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.card-synopsis {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--site-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-stats {
  margin-top: auto;
  font-size: 12px;
  color: var(--site-dim);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.card-actions button {
  width: 100%;
  padding: 9px 10px;
  font-size: 13px;
}

/* 預留書位樣式（當書少於 3 本時可選擇呈現或保持整齊） */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 56px 20px;
  color: var(--site-muted);
  background: var(--site-surface);
  border: 1px dashed var(--site-border);
  border-radius: 16px;
  line-height: 1.8;
}

/* ==================== 2. 目錄詳情頁 ==================== */
.breadcrumb-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.book-switcher {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.catalog-hero {
  display: flex;
  gap: 26px;
  background: var(--site-card);
  border: 1px solid var(--site-border);
  border-radius: 18px;
  padding: 26px;
  margin-bottom: 26px;
}

.catalog-cover {
  width: 150px;
  height: 200px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--site-border);
}

.catalog-meta { flex: 1; min-width: 0; }
.catalog-meta h1 {
  margin: 0 0 8px;
  font-family: 'Noto Serif TC', serif;
  font-size: 26px;
}
.catalog-sub {
  font-size: 13.5px;
  color: var(--site-muted);
  margin-bottom: 12px;
}
.catalog-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.catalog-tag {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--site-muted);
}
.catalog-synopsis {
  font-size: 14px;
  line-height: 1.8;
  color: #C7D1E0;
  margin: 0 0 20px;
}

.toc-panel {
  background: var(--site-card);
  border: 1px solid var(--site-border);
  border-radius: 18px;
  padding: 22px;
}

.toc-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.toc-panel-header h2 {
  margin: 0;
  font-family: 'Noto Serif TC', serif;
  font-size: 18px;
}

.catalog-chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

.ch-btn {
  background: var(--site-surface);
  border: 1px solid var(--site-border);
  color: var(--site-text);
  border-radius: 10px;
  padding: 13px 15px;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.ch-btn:hover {
  border-color: var(--gold-border);
  background: var(--site-card-hover);
}

.ch-btn.active {
  border-color: var(--gold);
  background: var(--gold-soft);
  color: var(--gold);
  font-weight: 600;
}

.ch-btn-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.ch-btn-words {
  font-size: 12px;
  color: var(--site-dim);
  white-space: nowrap;
}

/* ==================== 3. 沉浸式電子閱讀器 ==================== */
.reader-view {
  min-height: 100vh;
  background-color: var(--r-bg);
  color: var(--r-text);
  transition: background-color 0.25s ease, color 0.25s ease;
}

.reader-topbar, .reader-bottombar {
  position: fixed;
  left: 0;
  right: 0;
  background: var(--r-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 40;
  transition: transform 0.24s ease;
}

.reader-topbar {
  top: 0;
  height: 56px;
  border-bottom: 1px solid var(--r-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
}

.reader-topbar.bars-hidden { transform: translateY(-100%); }

.r-bar-center {
  flex: 1;
  min-width: 0;
  text-align: center;
  padding: 0 10px;
}

.r-book-name {
  font-family: 'Noto Serif TC', serif;
  font-size: 14.5px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.r-ch-sub {
  font-size: 11.5px;
  color: var(--r-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.r-bar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.reader-bottombar {
  bottom: 0;
  height: 60px;
  border-top: 1px solid var(--r-border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.reader-bottombar.bars-hidden { transform: translateY(100%); }

.r-bar-btn {
  background: none;
  border: none;
  color: var(--r-text);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 8px;
}

.r-bar-btn:hover:not(:disabled) { color: var(--r-accent); }
.r-bar-btn:disabled { opacity: 0.3; cursor: default; }

.reader-stage {
  min-height: 100vh;
  padding: 82px 24px 104px;
}

.reader-article {
  max-width: var(--reader-max-width);
  margin: 0 auto;
}

.chapter-heading {
  font-family: var(--reader-font);
  font-size: calc(var(--reader-size) + 8px);
  font-weight: 700;
  line-height: 1.45;
  margin: 8px 0 10px;
}

.chapter-meta-bar {
  font-size: 12.5px;
  color: var(--r-muted);
  margin-bottom: 32px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--r-border);
}

.chapter-body {
  font-family: var(--reader-font);
  font-size: var(--reader-size);
  line-height: var(--reader-line-height);
  letter-spacing: 0.04em;
  word-break: break-word;
  text-align: justify;
}

.chapter-body p {
  margin: 0 0 var(--reader-para-gap);
  text-indent: var(--reader-indent);
}

.reader-ad-slot {
  margin-top: 40px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px dashed var(--r-border);
  text-align: center;
  font-size: 12px;
  color: var(--r-muted);
}

.chapter-end-nav {
  display: flex;
  gap: 12px;
  margin-top: 44px;
  padding-top: 24px;
  border-top: 1px solid var(--r-border);
}

.r-nav-card {
  flex: 1;
  padding: 13px 10px;
  border-radius: 12px;
  border: 1px solid var(--r-border);
  background: var(--r-elevated);
  color: var(--r-text);
  font-size: 14px;
  font-weight: 600;
}

.r-nav-card:hover:not(:disabled) { border-color: var(--r-accent); color: var(--r-accent); }
.r-nav-card.primary {
  background: var(--r-accent);
  color: #16120A;
  border-color: var(--r-accent);
}
[data-reader-theme="sepia"] .r-nav-card.primary,
[data-reader-theme="green"] .r-nav-card.primary,
[data-reader-theme="light"] .r-nav-card.primary {
  color: #FFFFFF;
}
.r-nav-card:disabled { opacity: 0.35; cursor: default; }

/* 讀墨直排模式 */
body.vertical-mode {
  overflow-y: hidden;
  overflow-x: auto;
}

body.vertical-mode .reader-stage {
  height: 100vh;
  width: 100vw;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 72px 40px 76px;
  direction: ltr;
}

body.vertical-mode .reader-article {
  writing-mode: vertical-rl;
  -webkit-writing-mode: vertical-rl;
  max-width: none;
  height: 100%;
  margin: 0 0 0 auto;
  padding-left: 56px;
}

body.vertical-mode .chapter-heading { margin: 0 0 0 28px; }
body.vertical-mode .chapter-meta-bar {
  border-bottom: none;
  border-left: 1px solid var(--r-border);
  margin: 0 0 0 32px;
  padding: 0 0 0 16px;
}
body.vertical-mode .chapter-body p {
  margin: 0 0 0 var(--reader-para-gap);
  text-indent: var(--reader-indent);
}
body.vertical-mode .reader-ad-slot { display: none; }
body.vertical-mode .chapter-end-nav {
  writing-mode: horizontal-tb;
  flex-direction: column;
  width: 170px;
  margin: 0 44px 0 0;
  padding-top: 0;
  border-top: none;
  justify-content: center;
}

/* ==================== 抽屜與設定面板 ==================== */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(3px);
  z-index: 45;
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(360px, 86vw);
  background: var(--r-elevated);
  color: var(--r-text);
  z-index: 55;
  display: flex;
  flex-direction: column;
  box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
}

.drawer-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--r-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.drawer-header h3 {
  margin: 0;
  font-family: 'Noto Serif TC', serif;
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-actions { display: flex; gap: 6px; }

.drawer-chapter-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.drawer-ch-item {
  background: transparent;
  border: 1px solid var(--r-border);
  color: var(--r-text);
  padding: 11px 13px;
  border-radius: 9px;
  text-align: left;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-ch-item.active {
  border-color: var(--r-accent);
  color: var(--r-accent);
  font-weight: 700;
}

.settings-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 600px;
  margin: 0 auto;
  background: var(--r-elevated);
  color: var(--r-text);
  border-top: 1px solid var(--r-border);
  border-radius: 22px 22px 0 0;
  padding: 20px 24px calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 55;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.38);
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 15.5px;
  margin-bottom: 16px;
}

.sheet-reset-btn {
  background: none;
  border: none;
  color: var(--r-accent);
  font-size: 13px;
}

.setting-row { margin-bottom: 15px; }
.setting-row label {
  display: block;
  font-size: 12.5px;
  color: var(--r-muted);
  margin-bottom: 7px;
}
.setting-row label strong { color: var(--r-text); }
.setting-row.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.setting-row.inline-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
}
.setting-row.inline-toggle label { margin-bottom: 0; }

.theme-swatches {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.swatch {
  height: 36px;
  border-radius: 10px;
  border: 2px solid var(--r-border);
  font-size: 12.5px;
  font-weight: 600;
}
.swatch[data-rtheme="dark"]   { background: #141822; color: #D4B06A; }
.swatch[data-rtheme="amoled"] { background: #000000; color: #C0C6D0; }
.swatch[data-rtheme="sepia"]  { background: #F5EFE2; color: #2C241B; }
.swatch[data-rtheme="green"]  { background: #D2E8D4; color: #1B3020; }
.swatch[data-rtheme="light"]  { background: #FFFFFF; color: #1D2129; }
.swatch.active { border-color: var(--r-accent); transform: scale(1.03); }

.segmented {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 8px;
}

.seg-btn {
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid var(--r-border);
  background: transparent;
  color: var(--r-text);
  font-size: 12.5px;
}

.seg-btn.active {
  background: var(--r-accent);
  color: #16120A;
  border-color: var(--r-accent);
  font-weight: 700;
}

[data-reader-theme="sepia"] .seg-btn.active,
[data-reader-theme="green"] .seg-btn.active,
[data-reader-theme="light"] .seg-btn.active {
  color: #FFFFFF;
}

.stepper-control {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-btn {
  padding: 6px 13px;
  border-radius: 8px;
  border: 1px solid var(--r-border);
  background: transparent;
  color: var(--r-text);
  font-weight: 600;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--r-accent);
}

/* ==================== 響應式調整 ==================== */
@media (max-width: 960px) {
  .book-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
  .navbar-inner { flex-wrap: wrap; padding: 12px 16px; }
  .nav-pills { order: 3; width: 100%; justify-content: center; padding-top: 6px; border-top: 1px solid var(--site-border); }
  .container { padding: 18px 16px 64px; }
  .hero-content { padding: 22px 20px; }
  .hero-title { font-size: 22px; }
  .ad-slot-banner { flex-direction: column; align-items: flex-start; gap: 8px; }
  .book-grid { grid-template-columns: 1fr; }
  .search-box, .search-box input { width: 100%; }
  .catalog-hero { flex-direction: column; align-items: center; text-align: center; padding: 20px; }
  .catalog-tags { justify-content: center; }
  .reader-stage { padding: 74px 18px 92px; }
}
