/* ==========================================================================
   JIEQI 現代版 · 樣式表
   設計取向：暖色紙感、閱讀優先、移動端友好
   ========================================================================== */

:root {
  --c-bg: #faf8f4;
  --c-surface: #ffffff;
  --c-surface-2: #f4f1ea;
  --c-border: #e6e0d4;
  --c-text: #2c2a26;
  --c-text-2: #6b6559;
  --c-text-3: #9a9384;
  --c-primary: #a04a2e;
  --c-primary-dark: #863c23;
  --c-primary-soft: #f6ece7;
  --c-ok: #2f6b4f;
  --c-ok-soft: #e9f3ee;
  --c-danger: #b03a2e;
  --c-warn: #93631b;
  --c-radius: 10px;
  --c-radius-sm: 6px;
  --c-shadow: 0 1px 2px rgba(44, 42, 38, .06), 0 4px 14px rgba(44, 42, 38, .05);
  --wrap: 1180px;
  --font: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --font-read: Georgia, "Songti SC", "SimSun", "Microsoft YaHei", serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  color: var(--c-text);
  background: var(--c-bg);
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--c-primary); }

img { max-width: 100%; height: auto; display: block; }

h1, h2, h3 { margin: 0; font-weight: 700; line-height: 1.35; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }
.wrap-narrow { max-width: 460px; }

.muted { color: var(--c-text-3); font-size: 13px; }
.empty { color: var(--c-text-3); text-align: center; padding: 36px 12px; margin: 0; }

/* ---------- 頂欄 ---------- */
.site-header {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 62px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }

.brand-mark {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: var(--c-primary);
  color: #fff;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
}

.brand-logo { height: 30px; width: auto; display: block; }

.brand-name { font-size: 18px; font-weight: 700; letter-spacing: .3px; }

.header-search {
  display: flex;
  flex: 1 1 220px;
  max-width: 420px;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--c-bg);
}

.header-search input {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 7px 14px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  min-width: 0;
}

.header-search button {
  border: 0;
  background: var(--c-primary);
  color: #fff;
  padding: 0 18px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}
.header-search button:hover { background: var(--c-primary-dark); }

.nav-toggle {
  display: none;
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  border-radius: var(--c-radius-sm);
  width: 38px; height: 34px;
  font-size: 16px;
  cursor: pointer;
  margin-left: auto;
}

.site-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }

.site-nav > a {
  padding: 6px 12px;
  border-radius: var(--c-radius-sm);
  font-size: 14px;
  color: var(--c-text-2);
  white-space: nowrap;
}
.site-nav > a:hover { background: var(--c-surface-2); color: var(--c-primary); }
.site-nav > a.active { color: var(--c-primary); font-weight: 600; background: var(--c-primary-soft); }

.nav-user { padding: 0 8px; font-size: 13px; color: var(--c-text-2); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-admin { color: var(--c-primary) !important; }
.nav-login { border: 1px solid var(--c-border); }

.site-main { padding: 22px 0 48px; min-height: 60vh; }

/* ---------- 麵包屑 ---------- */
.breadcrumb {
  display: flex; flex-wrap: wrap; gap: 6px;
  font-size: 13px; color: var(--c-text-3);
  margin-bottom: 14px;
}
.breadcrumb a { color: var(--c-text-2); }
.breadcrumb a:hover { color: var(--c-primary); }

/* ---------- 面板 ---------- */
.panel {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius);
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: var(--c-shadow);
}

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--c-border);
}

.panel-title { font-size: 16px; position: relative; padding-left: 11px; }
.panel-title::before {
  content: ""; position: absolute; left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 15px;
  background: var(--c-primary);
  border-radius: 2px;
}
.panel-more { font-size: 13px; color: var(--c-text-3); }
.panel-more:hover { color: var(--c-primary); }
.panel-desc { color: var(--c-text-2); font-size: 13px; margin: 0 0 14px; }

/* ---------- 按鈕 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text);
  border-radius: var(--c-radius-sm);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  line-height: 1.4;
  white-space: nowrap;
}
.btn:hover { border-color: var(--c-primary); color: var(--c-primary); }

.btn-primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-dark); border-color: var(--c-primary-dark); color: #fff; }

.btn-ok { background: var(--c-ok); border-color: var(--c-ok); color: #fff; }
.btn-ok:hover { background: #245640; border-color: #245640; color: #fff; }

.btn-danger { color: var(--c-danger); border-color: #e8cecb; background: #fdf6f5; }
.btn-danger:hover { background: var(--c-danger); border-color: var(--c-danger); color: #fff; }

.btn-soft { background: var(--c-surface-2); border-color: transparent; color: var(--c-text-2); }
.btn-soft:hover { background: var(--c-primary-soft); color: var(--c-primary); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-xs { padding: 3px 9px; font-size: 12px; }
.btn-block { width: 100%; }
.btn.disabled, .btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

.inline-form { display: inline; margin: 0; }

/* ---------- 標籤 ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  font-size: 12px;
  border-radius: 999px;
  background: var(--c-surface-2);
  color: var(--c-text-2);
  border: 1px solid transparent;
}
a.chip:hover, .chip.active { background: var(--c-primary); color: #fff; }
.chip-lg { padding: 7px 15px; font-size: 14px; }
.chip-count { font-style: normal; font-size: 12px; opacity: .65; }
.chip-full { background: var(--c-ok-soft); color: var(--c-ok); }
.chip-sort { background: var(--c-primary-soft); color: var(--c-primary); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips-scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; margin-bottom: 16px; -webkit-overflow-scrolling: touch; }
.chips-scroll .chip { flex-shrink: 0; }

/* ---------- 提示條 ---------- */
.alert { padding: 11px 15px; border-radius: var(--c-radius-sm); font-size: 14px; margin-bottom: 16px; }
.alert-error { background: #fdeceb; color: var(--c-danger); }
.alert-warn { background: #fdf5e6; color: var(--c-warn); }

/* ---------- 首頁 hero ---------- */
.hero {
  background: linear-gradient(135deg, #f6ece7, #f4f1ea);
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius);
  padding: 30px 24px;
  margin-bottom: 18px;
  text-align: center;
}
.hero-title { font-size: 26px; letter-spacing: 1px; margin-bottom: 6px; }
.hero-sub { margin: 0 0 18px; color: var(--c-text-2); font-size: 14px; }

.hero-search, .search-form {
  display: flex; gap: 8px;
  max-width: 620px; margin: 0 auto;
}
.hero-search input, .search-form input {
  flex: 1; min-width: 0;
  padding: 10px 15px;
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius-sm);
  font-size: 14px; font-family: inherit;
  background: var(--c-surface);
  outline: none;
}
.hero-search input:focus, .search-form input:focus { border-color: var(--c-primary); }
.search-form select {
  padding: 10px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius-sm);
  font-size: 14px; font-family: inherit;
  background: var(--c-surface);
}

/* ---------- 封面網格 ---------- */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }

.book-card { display: block; border-radius: var(--c-radius-sm); overflow: hidden; }
.book-card:hover { color: inherit; }

.bc-cover { position: relative; display: block; aspect-ratio: 3 / 4; background: var(--c-surface-2); border-radius: var(--c-radius-sm); overflow: hidden; }
.bc-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.book-card:hover .bc-cover img { transform: scale(1.04); }

.bc-badge {
  position: absolute; left: 6px; top: 6px;
  padding: 2px 8px; font-size: 11px; border-radius: 4px;
  background: rgba(160, 74, 46, .9); color: #fff;
}
.bc-badge.is-full { background: rgba(47, 107, 79, .9); }

.bc-body { padding: 9px 2px 0; }
.bc-title { display: block; font-size: 14px; font-weight: 600; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bc-author { display: block; font-size: 12px; color: var(--c-text-3); margin-bottom: 4px; }
.bc-intro {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; font-size: 12px; color: var(--c-text-3); line-height: 1.55;
}

/* ---------- 兩欄 ---------- */
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.col-side { display: flex; flex-direction: column; }

/* ---------- 作品列表 ---------- */
.book-list { list-style: none; margin: 0; padding: 0; }

.book-row {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 0;
  border-bottom: 1px dashed var(--c-border);
}
.book-row:last-child { border-bottom: 0; }
.book-row.compact { padding: 9px 0; gap: 0; }

.br-cover { flex-shrink: 0; width: 62px; border-radius: var(--c-radius-sm); overflow: hidden; background: var(--c-surface-2); }
.book-row.compact .br-cover { display: none; }
.br-cover img { width: 100%; aspect-ratio: 3/4; object-fit: cover; }

.br-main { flex: 1; min-width: 0; }
.br-title { font-size: 15px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 5px; }
.br-title > a { font-weight: 600; }
.br-meta { margin: 0 0 5px; font-size: 12.5px; color: var(--c-text-3); display: flex; flex-wrap: wrap; gap: 4px 14px; }
.br-intro { margin: 0 0 5px; font-size: 13px; color: var(--c-text-2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.br-latest { margin: 0; font-size: 13px; color: var(--c-text-3); }
.br-latest a { color: var(--c-text-2); }
.br-latest a:hover { color: var(--c-primary); }

.br-go {
  align-self: center; flex-shrink: 0;
  font-size: 13px; padding: 6px 14px;
  border: 1px solid var(--c-border); border-radius: var(--c-radius-sm);
  color: var(--c-text-2);
}
.br-go:hover { border-color: var(--c-primary); color: var(--c-primary); }

.book-list-rank .book-row { align-items: center; }

/* ---------- 排行 ---------- */
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-list li { display: flex; align-items: center; gap: 9px; padding: 7px 0; font-size: 14px; border-bottom: 1px dashed var(--c-border); }
.rank-list li:last-child { border-bottom: 0; }
.rank-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-val { font-size: 12px; color: var(--c-text-3); flex-shrink: 0; }

.rank-no {
  flex-shrink: 0; width: 20px; height: 20px;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  border-radius: 5px;
  background: var(--c-surface-2); color: var(--c-text-3);
}
.rank-no-1 { background: #d94f3d; color: #fff; }
.rank-no-2 { background: #e08a2e; color: #fff; }
.rank-no-3 { background: #c9a227; color: #fff; }

/* ---------- 分類 ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 13px; }
.filter { padding: 4px 11px; border-radius: 999px; color: var(--c-text-2); }
.filter:hover { background: var(--c-surface-2); color: var(--c-primary); }
.filter.active { background: var(--c-primary); color: #fff; }
.filter-sep { width: 1px; height: 14px; background: var(--c-border); margin: 0 6px; }

.sort-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.sort-card {
  border: 1px solid var(--c-border); border-radius: var(--c-radius-sm);
  padding: 16px; display: flex; flex-direction: column; gap: 5px;
  transition: border-color .15s, background .15s;
}
.sort-card:hover { border-color: var(--c-primary); background: var(--c-primary-soft); color: inherit; }
.sort-name { font-size: 16px; font-weight: 600; }
.sort-short { font-size: 12px; color: var(--c-text-3); }
.sort-count { font-size: 12px; color: var(--c-text-3); margin-top: 4px; }

/* ---------- 作品詳情 ---------- */
.book-hero {
  display: flex; gap: 22px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: var(--c-shadow);
}
.bh-cover { flex-shrink: 0; width: 150px; border-radius: var(--c-radius-sm); overflow: hidden; background: var(--c-surface-2); box-shadow: 0 4px 14px rgba(44,42,38,.14); }
.bh-cover img { width: 100%; aspect-ratio: 3/4; object-fit: cover; }

.bh-info { flex: 1; min-width: 0; }
.bh-title { font-size: 23px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.bh-status { font-size: 12px; font-weight: 400; padding: 2px 9px; border-radius: 4px; background: var(--c-primary-soft); color: var(--c-primary); }
.bh-status.is-full { background: var(--c-ok-soft); color: var(--c-ok); }

.bh-meta { margin: 0 0 10px; font-size: 13.5px; color: var(--c-text-2); display: flex; flex-wrap: wrap; gap: 5px 18px; }
.bh-meta a { color: var(--c-primary); }

.bh-stats { margin: 0 0 16px; font-size: 13px; color: var(--c-text-3); display: flex; flex-wrap: wrap; gap: 5px 18px; }
.bh-stats em { font-style: normal; color: var(--c-text); font-weight: 600; }

.bh-actions { display: flex; flex-wrap: wrap; gap: 9px; }

.rich-text { line-height: 1.9; color: var(--c-text-2); font-size: 14.5px; }
.rich-text p { margin: 0 0 12px; }
.rich-text img { margin: 10px auto; border-radius: var(--c-radius-sm); }

.chapter-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 16px; }
.chapter-grid li a { display: flex; align-items: center; gap: 6px; padding: 6px 0; font-size: 14px; color: var(--c-text-2); border-bottom: 1px dashed transparent; }
.chapter-grid li a:hover { color: var(--c-primary); border-bottom-color: var(--c-border); }
.cv-name { font-size: 12px; color: var(--c-text-3); flex-shrink: 0; }
.cc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tag-vip { font-size: 10px; padding: 1px 5px; border-radius: 3px; background: #f3e2c7; color: #8a6414; flex-shrink: 0; }

/* ---------- 目錄 ---------- */
.catalog-tools { display: flex; align-items: center; gap: 10px; }
.catalog-volume { margin-bottom: 6px; }

.cv-head {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  background: var(--c-surface-2);
  border-radius: var(--c-radius-sm);
  cursor: pointer;
  user-select: none;
}
.cv-head:hover { background: var(--c-primary-soft); }
.cv-title { font-weight: 600; font-size: 14.5px; flex: 1; }
.cv-count { font-size: 12px; color: var(--c-text-3); }
.cv-arrow { font-size: 12px; color: var(--c-text-3); transition: transform .2s; }
.catalog-volume.collapsed .cv-arrow { transform: rotate(-90deg); }
.catalog-volume.collapsed .catalog-list { display: none; }

.catalog-list { list-style: none; margin: 0; padding: 4px 0 10px; }
.cl-item { display: flex; align-items: center; gap: 10px; padding: 6px 12px; font-size: 14px; border-bottom: 1px dashed var(--c-border); }
.cl-item a { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; overflow: hidden; }
.cl-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl-date { font-size: 12px; color: var(--c-text-3); flex-shrink: 0; }

/* ---------- 分頁 ---------- */
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--c-border); }
.pager > a, .pager > span {
  min-width: 34px; height: 34px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--c-border); border-radius: var(--c-radius-sm);
  font-size: 13.5px; color: var(--c-text-2);
}
.pager > a:hover { border-color: var(--c-primary); color: var(--c-primary); }
.pager .current { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.pager .disabled { opacity: .4; }
.pager .pg-gap { border: 0; }
.pg-info { border: 0 !important; color: var(--c-text-3) !important; font-size: 12.5px !important; margin-left: 6px; }

/* ---------- 閱讀器 ---------- */
.reader-wrap { --reader-bg: #f6f1e7; }

.reader-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.rt-left, .rt-right { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.rt-setter { position: relative; }

.setter-panel {
  position: absolute; right: 0; top: calc(100% + 7px);
  z-index: 30;
  width: 250px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius);
  box-shadow: 0 8px 28px rgba(44,42,38,.16);
  padding: 13px;
}
.setter-row { display: flex; align-items: center; gap: 7px; margin-bottom: 10px; }
.setter-label { font-size: 13px; color: var(--c-text-2); width: 36px; flex-shrink: 0; }
.setter-val { font-size: 12px; color: var(--c-text-3); }
.setter-note { margin: 4px 0 0; font-size: 11.5px; color: var(--c-text-3); }

.bg-options { display: flex; gap: 7px; }
.bg-dot {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--c-border);
  cursor: pointer; padding: 0;
}
.bg-dot:hover { transform: scale(1.12); }
.bg-dot.active { border-color: var(--c-primary); }

.reader-panel {
  background: var(--reader-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius);
  padding: 32px 40px 26px;
  transition: background .2s;
}
.reader-wrap[data-width="narrow"] .reader-panel { padding: 32px 14%; }
.reader-wrap[data-width="wide"] .reader-panel { padding: 32px 24px; }

.reader-head { text-align: center; margin-bottom: 26px; padding-bottom: 16px; border-bottom: 1px solid rgba(0,0,0,.07); }
.reader-title { font-size: 21px; margin-bottom: 7px; }
.reader-sub { margin: 0; font-size: 13px; color: var(--c-text-3); display: flex; align-items: center; justify-content: center; gap: 9px; flex-wrap: wrap; }

.reader-content {
  font-family: var(--font-read);
  font-size: 18px;
  line-height: 2.1;
  color: var(--c-text);
  word-wrap: break-word;
}
.reader-content p { margin: 0 0 1.1em; text-indent: 2em; }
.reader-content .divimage { text-indent: 0; text-align: center; margin: 18px 0; }
.reader-content img { margin: 0 auto; border-radius: var(--c-radius-sm); }

/* 夜間模式 */
.reader-wrap.reader-dark .reader-panel { color: #c8c5bf; }
.reader-wrap.reader-dark .reader-content { color: #c8c5bf; }
.reader-wrap.reader-dark .reader-title { color: #e8e5df; }
.reader-wrap.reader-dark .reader-sub { color: #8d8a84; }
.reader-wrap.reader-dark .reader-head { border-bottom-color: rgba(255,255,255,.1); }

.reader-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 30px; padding-top: 20px; border-top: 1px solid rgba(0,0,0,.07); }
.reader-nav .btn { flex: 1; flex-direction: column; align-items: flex-start; padding: 10px 16px; max-width: 44%; }
.reader-nav .btn-catalog { flex: 0 0 auto; align-items: center; max-width: none; }
.rn-label { font-size: 12px; color: var(--c-text-3); }
.rn-name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.btn-next { align-items: flex-end; text-align: right; }

.pager-pages { border-top: 0; margin-top: 22px; padding-top: 0; justify-content: center; }

/* ---------- 書架 ---------- */
.shelf-list { list-style: none; margin: 0; padding: 0; }
.shelf-item { display: flex; gap: 15px; padding: 16px 0; border-bottom: 1px dashed var(--c-border); }
.shelf-item:last-child { border-bottom: 0; }
.sh-cover { flex-shrink: 0; width: 82px; border-radius: var(--c-radius-sm); overflow: hidden; background: var(--c-surface-2); }
.sh-cover img { width: 100%; aspect-ratio: 3/4; object-fit: cover; }
.sh-main { flex: 1; min-width: 0; }
.sh-title { font-size: 16px; margin-bottom: 7px; }
.sh-progress { margin: 0 0 6px; font-size: 13.5px; color: var(--c-text-2); }
.hl { color: var(--c-primary); font-weight: 600; }
.sh-meta { margin: 0; font-size: 12.5px; color: var(--c-text-3); display: flex; gap: 16px; flex-wrap: wrap; }
.sh-actions { display: flex; flex-direction: column; gap: 7px; flex-shrink: 0; }

/* ---------- 登錄 ---------- */
.auth-box {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius);
  padding: 30px 26px;
  box-shadow: var(--c-shadow);
  margin-top: 30px;
}
.auth-title { font-size: 21px; text-align: center; margin-bottom: 6px; }
.auth-sub { text-align: center; color: var(--c-text-3); font-size: 13px; margin: 0 0 22px; }
.auth-form { display: block; }
.field { display: block; margin-bottom: 15px; }
.field-label { display: block; font-size: 13px; color: var(--c-text-2); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 10px 13px;
  border: 1px solid var(--c-border); border-radius: var(--c-radius-sm);
  font-size: 14px; font-family: inherit; background: var(--c-bg); outline: none;
}
.field input:focus { border-color: var(--c-primary); background: var(--c-surface); }
.auth-note { text-align: center; font-size: 12px; color: var(--c-text-3); margin: 18px 0 0; line-height: 1.6; }

/* ---------- 提示框 ---------- */
.note-box {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius);
  padding: 44px 24px;
  text-align: center;
  box-shadow: var(--c-shadow);
}
.note-title { font-size: 20px; margin-bottom: 10px; }
.note-text { color: var(--c-text-2); margin: 0 0 20px; }
.note-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 0; }

/* ---------- 頁腳 ---------- */
.site-footer {
  border-top: 1px solid var(--c-border);
  background: var(--c-surface);
  padding: 26px 0;
  margin-top: 20px;
}
.footer-inner { text-align: center; }
.footer-links { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin: 0 0 12px; font-size: 13.5px; }
.footer-links a { color: var(--c-text-2); }
.footer-links a:hover { color: var(--c-primary); }
.footer-copy { margin: 0; font-size: 13px; color: var(--c-text-3); }

/* ---------- 語言切換 ---------- */
.lang-switch { position: relative; display: inline-block; }

.lang-btn {
  padding: 6px 12px;
  border-radius: var(--c-radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--c-text-2);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}
.lang-btn:hover { background: var(--c-surface-2); color: var(--c-primary); }

.lang-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  min-width: 150px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius);
  box-shadow: 0 8px 28px rgba(44, 42, 38, .16);
  padding: 6px;
}
[dir="rtl"] .lang-menu { right: auto; left: 0; }
.lang-menu.open { display: block; }

.lang-menu a {
  display: block;
  padding: 7px 12px;
  border-radius: var(--c-radius-sm);
  font-size: 13.5px;
  color: var(--c-text-2);
}
.lang-menu a:hover { background: var(--c-surface-2); color: var(--c-primary); }
.lang-menu a.active { background: var(--c-primary-soft); color: var(--c-primary); font-weight: 600; }

/* ---------- 從右到左（阿拉伯語） ---------- */
[dir="rtl"] { text-align: right; }

[dir="rtl"] .breadcrumb,
[dir="rtl"] .br-meta,
[dir="rtl"] .bh-meta,
[dir="rtl"] .bh-stats,
[dir="rtl"] .bh-actions,
[dir="rtl"] .panel-head,
[dir="rtl"] .book-row,
[dir="rtl"] .shelf-item,
[dir="rtl"] .sh-meta,
[dir="rtl"] .rank-list li,
[dir="rtl"] .chapter-grid li a,
[dir="rtl"] .cl-item,
[dir="rtl"] .cv-head,
[dir="rtl"] .reader-nav,
[dir="rtl"] .reader-toolbar,
[dir="rtl"] .rt-left,
[dir="rtl"] .rt-right,
[dir="rtl"] .footer-links,
[dir="rtl"] .note-actions { direction: rtl; }

[dir="rtl"] .panel-title { padding-left: 0; padding-right: 11px; }
[dir="rtl"] .panel-title::before { left: auto; right: 0; }

/* 列表項的「開始閱讀」按鈕換到另一側 */
[dir="rtl"] .br-go { order: -1; }

/* 閱讀器：上一章靠右、下一章靠左，符合 RTL 閱讀方向 */
[dir="rtl"] .btn-next { align-items: flex-start; text-align: left; }
[dir="rtl"] .btn-prev { align-items: flex-end; text-align: right; }

/* 數字與代碼保持 LTR，避免阿拉伯語環境下數字順序錯亂 */
[dir="rtl"] code,
[dir="rtl"] .rank-val { direction: ltr; unicode-bidi: embed; display: inline-block; }

/* ---------- 響應式 ---------- */
@media (max-width: 980px) {
  .cols { grid-template-columns: 1fr; }
  .col-side { flex-direction: row; flex-wrap: wrap; }
  .col-side .panel { flex: 1 1 260px; }
}

@media (max-width: 760px) {
  .header-inner { min-height: 56px; gap: 10px; }
  .header-search { order: 3; flex: 1 1 100%; max-width: none; margin-bottom: 10px; }
  .nav-toggle { display: block; }

  .site-nav {
    display: none;
    order: 4;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding-bottom: 10px;
    margin-left: 0;
  }
  .site-nav.open { display: flex; }
  .site-nav > a, .nav-user { padding: 9px 12px; }
  .nav-user { max-width: none; }

  .book-hero { flex-direction: column; padding: 16px; }
  .bh-cover { width: 110px; }
  .bh-title { font-size: 19px; }

  .reader-panel { padding: 20px 16px; }
  .reader-wrap[data-width="narrow"] .reader-panel,
  .reader-wrap[data-width="wide"] .reader-panel { padding: 20px 16px; }
  .reader-content { font-size: 17px; line-height: 2; }
  .reader-nav .btn { max-width: none; }

  .br-go { display: none; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
  .shelf-item { flex-wrap: wrap; }
  .sh-actions { flex-direction: row; width: 100%; }
  .chapter-grid { grid-template-columns: 1fr 1fr; }
  .sort-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .hero { padding: 22px 16px; }
  .hero-title { font-size: 21px; }
}

@media (max-width: 460px) {
  .book-row { gap: 10px; }
  .br-cover { width: 52px; }
  .chapter-grid { grid-template-columns: 1fr; }
  .cl-date { display: none; }
}

/* ---------- 註冊 / 圖形驗證碼 ---------- */
.nav-register {
  color: #b45f06;
  font-weight: 600;
}

.field-hint {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.5;
  color: #8a8378;
}

.captcha-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.captcha-row input[type="text"] {
  flex: 1 1 auto;
  min-width: 0;
  letter-spacing: 4px;
}

.captcha-img {
  flex: 0 0 auto;
  width: 130px;
  height: 44px;
  border: 1px solid #e3ddd1;
  border-radius: 4px;
  background: #f6f1e7;
  cursor: pointer;
}

.captcha-refresh {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid #e3ddd1;
  border-radius: 4px;
  background: #fff;
  color: #5c564d;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

.captcha-refresh:hover {
  background: #f2ece1;
}

@media (max-width: 480px) {
  .captcha-row { flex-wrap: wrap; }
  .captcha-row input[type="text"] { flex: 1 1 100%; }
}
/* ---------- 可達性：跳到主內容 ---------- */
/* 平時移出視口，鍵盤聚焦時滑入，供讀屏與純鍵盤用戶跳過導航 */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  padding: 10px 16px;
  background: #26241f;
  color: #fff;
  font-size: 14px;
  border-radius: 0 0 6px 0;
  text-decoration: none;
}

.skip-link:focus {
  left: 0;
}

/* ---------- 聚合發現站：來源徽章 / 外鏈提示 / 外部評分 ---------- */
/* 來源類型與授權狀態：默認弱化，即將到期 / 已到期 / 已下架用警示色 */
.badge-source {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 1px 8px;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  background: var(--c-surface-2);
  color: var(--c-text-2);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.6;
  white-space: nowrap;
  vertical-align: middle;
}

.badge-source.is-warn {
  border-color: var(--c-warn);
  background: #fdf5e6;
  color: var(--c-warn);
}

/* 標題（h1）裡的徽章不要繼承標題字重 */
.bh-title .badge-source,
.bh-title .badge-external,
.bc-title .badge-source {
  font-weight: 400;
}

/* 外鏈作品短標籤 */
.badge-external {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 1px 8px;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  background: var(--c-surface-2);
  color: var(--c-primary);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.6;
  white-space: nowrap;
  vertical-align: middle;
}

/* 書目提示面板：說明本站不託管正文，並給出正版平臺入口 */
.external-panel {
  margin: 0 0 16px;
  padding: 12px 15px;
  border: 1px solid var(--c-border);
  border-left: 3px solid var(--c-primary);
  border-radius: var(--c-radius-sm);
  background: var(--c-surface-2);
}

.panel.external-panel {
  padding: 14px 16px;
  border-radius: var(--c-radius);
}

.external-panel-text {
  margin: 0;
  color: var(--c-text-2);
  font-size: 13.5px;
  line-height: 1.75;
}

.external-panel-link {
  margin: 8px 0 0;
}

.external-link {
  color: var(--c-primary);
  font-size: 13.5px;
  word-break: break-word;
}

.external-link:hover {
  color: var(--c-primary-dark);
  text-decoration: underline;
}

/* 詳情頁出站按鈕旁 / 目錄頂部的平臺名 */
.bh-platform {
  color: var(--c-text-3);
  font-size: 13px;
  word-break: break-word;
}

/* 授權到期日（詳情頁 meta 行內的灰字） */
.bh-expire {
  color: var(--c-text-3);
  font-size: 13px;
}

/* 外部評分 */
.rating-stars {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--c-warn);
  font-weight: 600;
}

.rating-stars::before {
  content: "★";
  font-size: 12px;
  line-height: 1;
}

/* 目錄頂部的出站按鈕行 */
.catalog-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
}

/* 目錄裡書目章節行的外鏈標記 */
.tag-ext {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 3px;
  background: var(--c-surface-2);
  color: var(--c-text-3);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.7;
  white-space: nowrap;
}

/* 手機端（wap）復用上面這套類名，避免小屏溢出 */
.wap-sec-body .external-panel {
  margin: 0;
  border-color: var(--w-border, var(--c-border));
}

.wap-sec-body .external-panel-text,
.wap-sec-body .external-panel-link {
  word-break: break-word;
}

.wap-tag.badge-source {
  border: 0;
  padding: 1px 7px;
  background: var(--w-bg, var(--c-surface-2));
  color: var(--w-text2, var(--c-text-2));
  font-size: 10.5px;
  line-height: 1.5;
}

.wap-tag.badge-source.is-warn {
  background: #fdf5e6;
  color: var(--c-warn);
}

.wap-bookhead-stat .rating-stars {
  color: var(--c-warn);
  font-weight: 400;
}

.wap-chlist li .wap-chitem .wap-tag {
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .bh-stats {
    gap: 4px 12px;
  }

  .bh-title .badge-source,
  .bh-title .badge-external {
    white-space: normal;
  }

  .external-panel,
  .panel.external-panel {
    padding: 12px 13px;
  }
}

@media (max-width: 360px) {
  .badge-source,
  .badge-external {
    font-size: 11px;
    padding: 1px 6px;
  }
}