/* ===== CSS Variables & Theme ===== */
:root {
  --bg: #f5f0e8;
  --bg-card: #faf7f2;
  --bg-nav: rgba(245,240,232,0.92);
  --text: #2c2416;
  --text-muted: #7a6e5f;
  --text-light: #a8997e;
  --accent: #8b5a2b;
  --accent-soft: #c4956a;
  --border: rgba(139,90,43,0.15);
  --border-solid: #d4c4a8;
  --shadow: rgba(44,36,22,0.08);
  --reading-bg: #fdf6e3;
  --reading-text: #3d2e1e;
  --tag-bg: rgba(139,90,43,0.08);
  --hover: rgba(139,90,43,0.06);
  --badge: #c4956a;
  --nav-item-active: #8b5a2b;
}

[data-theme="dark"] {
  --bg: #1a1612;
  --bg-card: #221e18;
  --bg-nav: rgba(26,22,18,0.95);
  --text: #e8dcc8;
  --text-muted: #a08870;
  --text-light: #6b5a45;
  --accent: #c4956a;
  --accent-soft: #a07850;
  --border: rgba(196,149,106,0.12);
  --border-solid: #3d3428;
  --shadow: rgba(0,0,0,0.3);
  --reading-bg: #1e1a14;
  --reading-text: #d4c4a4;
  --tag-bg: rgba(196,149,106,0.1);
  --hover: rgba(196,149,106,0.06);
  --badge: #a07850;
  --nav-item-active: #c4956a;
}
:root {
  --font-sans: "PingFang TC", "Microsoft JhengHei", "蘋方-繁",
               "微軟正黑體", "Noto Sans TC", sans-serif;
  --font-serif: "Georgia", "Songti TC", "宋體-繁", "SimSun",
                "Noto Serif TC", serif;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  transition: background 0.3s, color 0.3s;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
ul { list-style: none; }
img { max-width: 100%; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-solid); border-radius: 3px; }

/* ===== Top Nav ===== */
.topnav {
  position: fixed; top:0; left:0; right:0; z-index:100;
  background: var(--bg-nav);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  height: 56px;
  display: flex; align-items: center;
  padding: 0 20px;
  gap: 8px;
}
.site-logo {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.05em;
  margin-right: auto;
  cursor: pointer;
  white-space: nowrap;
}
.nav-links { display: flex; gap: 2px; }
.nav-link {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: color 0.2s, background 0.2s;
  cursor: pointer;
  white-space: nowrap;
}
.nav-link:hover, .nav-link.active { color: var(--nav-item-active); background: var(--hover); }
.nav-actions { display:flex; gap:6px; align-items:center; }
.btn-icon {
  width:36px; height:36px; border-radius:8px;
  display:flex; align-items:center; justify-content:center;
  color: var(--text-muted); font-size:1rem;
  transition: color 0.2s, background 0.2s;
  cursor: pointer;
}
.btn-icon:hover { color:var(--accent); background:var(--hover); }
/* ===== Search Bar ===== */
.search-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-solid);
  border-radius: 20px;
  padding: 5px 6px 5px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-width: 220px;
}
.search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 90, 43, 0.1);
}
.search-icon {
  font-size: 0.9rem;
  flex-shrink: 0;
  opacity: 0.6;
}
.search-bar input[type="search"] {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text);
  min-width: 0;
  /* 清除瀏覽器原生 × 按鈕 */
  -webkit-appearance: none;
  appearance: none;
}
.search-bar input[type="search"]::-webkit-search-cancel-button {
  display: none;
}
.search-bar input::placeholder {
  color: var(--text-light);
}
.search-submit {
  padding: 4px 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-size: 0.8rem;
  font-family: var(--font-sans);
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.2s;
}
.search-submit:hover { opacity: 0.88; }
.search-clear {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: var(--border-solid);
  color: var(--text-muted);
  font-size: 0.7rem;
  cursor: pointer;
  flex-shrink: 0;
  display: none; /* 預設隱藏，有內容才顯示 */
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.search-clear:hover { background: var(--accent-soft); color: #fff; }
.search-clear.visible { display: flex; }

/* 手機端收窄 */
@media (max-width: 640px) {
  .search-bar { min-width: 0; width: 160px; }
  .search-submit { display: none; } /* 手機按 Enter 提交即可 */
}
@media (max-width: 400px) {
  .search-bar { width: 150px; }
  .btn-icon { width:25px;}
}
.ham { display:none; }

/* ===== Main Wrapper ===== */
.main { padding-top: 72px; max-width: 1120px; margin: 0 auto; padding-left:16px; padding-right:16px; padding-bottom:48px; }

/* ===== Section Title ===== */
.section-title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  display:flex; align-items:center; gap:10px;
  margin-bottom: 16px;
}
.section-title::before {
  content:'';
  display:block; width:3px; height:18px;
  background: var(--accent); border-radius:2px;
}
.section-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:16px; }
.see-all { font-size:0.82rem; color:var(--accent-soft); cursor:pointer; }
.see-all:hover { color:var(--accent); }

/* ===== Banner / Hero ===== */
.hero {
  background: linear-gradient(135deg, var(--accent) 0%, #6b3d1a 100%);
  border-radius: 14px;
  padding: 32px 28px;
  color: #fff;
  margin-bottom: 32px;
  position:relative; overflow:hidden;
}
.hero::before {
  content:'書';
  position:absolute; right:-20px; top:-30px;
  font-family: var(--font-serif);
  font-size:160px; font-weight:700;
  opacity:0.07; line-height:1;
  pointer-events:none;
}
.hero-tag { font-size:0.75rem; letter-spacing:0.1em; opacity:0.7; margin-bottom:8px; text-transform:uppercase; }
.hero-title { font-family: var(--font-serif); font-size:1.6rem; font-weight:700; margin-bottom:8px; }
.hero-desc { font-size:0.88rem; opacity:0.82; margin-bottom:20px; line-height:1.6; max-width:400px; }
.hero-meta { display:flex; gap:16px; font-size:0.8rem; opacity:0.75; margin-bottom:20px; }
.btn-read {
  display:inline-flex; align-items:center; gap:6px;
  background:#fff; color:var(--accent);
  padding:8px 20px; border-radius:20px;
  font-size:0.88rem; font-weight:500;
  transition: opacity 0.2s, transform 0.2s;
  cursor:pointer;
}
.btn-read:hover { opacity:0.9; transform:translateX(2px); }

/* ===== Novel Grid ===== */
.novel-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:16px; }
.novel-card {
  background:var(--bg-card); border-radius:10px;
  border: 1px solid var(--border);
  overflow:hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}
.novel-card:hover { transform:translateY(-3px); box-shadow:0 8px 24px var(--shadow); }
.novel-cover {
  width:100%; aspect-ratio:3/4;
  display:flex; align-items:center; justify-content:center;
  font-family: var(--font-serif);
  font-size:1.4rem; font-weight:700;
  color:#fff; position:relative; overflow:hidden;
}
.novel-cover-text { position:relative; z-index:1; text-align:center; padding:8px; }
.novel-cover-sub { font-size:0.65rem; font-weight:400; opacity:0.8; margin-top:4px; font-family:var(--font-sans); }
.novel-info { padding:10px 12px 12px; }
.novel-title { font-size:0.88rem; font-weight:500; margin-bottom:4px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.novel-author { font-size:0.75rem; color:var(--text-muted); margin-bottom:6px; }
.novel-tags { display:flex; flex-wrap:wrap; gap:4px; }
.tag {
  font-size:0.68rem; padding:2px 7px; border-radius:10px;
  background:var(--tag-bg); color:var(--accent);
}

/* ===== Novel List (compact) ===== */
.novel-list { display:flex; flex-direction:column; gap:1px; }
.novel-list-item {
  display:flex; align-items:center; gap:14px;
  padding:6px 7px; border-radius:8px;
   transition:background 0.15s;
}
.novel-list-item:hover { background:var(--hover); }
.rank-num { width:24px; text-align:center; font-size:0.85rem; font-weight:700; color:var(--text-light); flex-shrink:0; }
.rank-num.top { color:var(--accent); }
.list-cover {
  width:38px; height:52px; border-radius:5px; flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
  font-family: var(--font-serif); font-size:0.85rem; color:#fff; font-weight:700;
}
.list-info { flex:1; min-width:0; }
.list-title { font-size:0.9rem; font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.list-author { font-size:0.76rem; color:var(--text-muted); }
.list-meta { font-size:0.75rem; color:var(--text-light); white-space:nowrap; }
.list-intro { font-size:0.76rem; color:var(--text-muted); }
.clamp-text {
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
      line-clamp: 2;
      overflow: hidden;
      word-break: break-all;
    }
.list-author span { margin:0px 6px; }

/* ===== Categories ===== */
.cat-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(100px,1fr)); gap:10px; }
.cat-item {
  background:var(--bg-card); border:1px solid var(--border);
  border-radius:10px; padding:8px 6px;
  text-align:center; cursor:pointer;
  transition: border-color 0.2s, background 0.2s;
}
.cat-item:hover { border-color:var(--accent-soft); background:var(--hover); }
.cat-icon { font-size:1.4rem; margin-bottom:6px; }
.cat-name { font-size:0.82rem; font-weight:500; }
.cat-count { font-size:0.72rem; color:var(--text-muted); margin-top:2px; }

/* ===== Section spacing ===== */
.section { margin-bottom:36px; }

/* ===== Chapter List ===== */
.chapter-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(200px,1fr)); gap:1px; background:var(--border); border-radius:10px; overflow:hidden; }
.chapter-item {
  background:var(--bg-card);
  padding:12px 16px;
  cursor:pointer;
  transition:background 0.15s;
  font-size:0.85rem;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.chapter-item:hover { background:var(--hover); }
.chapter-item.read { color:var(--text-muted); }

/* ===== Novel Detail ===== */
.detail-header { display:flex; gap:20px; margin-bottom:24px; align-items:flex-start; }
.detail-cover { width:110px; height:148px; border-radius:10px; flex-shrink:0; display:flex; align-items:center; justify-content:center; font-family: var(--font-serif); font-size:1.6rem; color:#fff; font-weight:700; }
.detail-info { flex:1; }
.detail-title { font-family: var(--font-serif); font-size:1.4rem; font-weight:700; margin-bottom:6px; }
.detail-author { font-size:0.88rem; color:var(--text-muted); margin-bottom:10px; display: flex; gap: 5px; align-items: center; }
.detail-tags { display:flex; flex-wrap:wrap; gap:6px; margin-bottom:12px;}
.detail-stats { display:flex; gap:20px; margin-bottom:16px; }
.stat-item { text-align:center; }
.stat-val { font-size:1rem; font-weight:600; color:var(--accent); }
.stat-label { font-size:0.72rem; color:var(--text-muted); }
.btn-start {
  display:inline-flex; align-items:center; gap:6px;
  background:var(--accent); color:#fff;
  padding:10px 24px; border-radius:20px;
  font-size:0.9rem; font-weight:500;
  cursor:pointer; transition:opacity 0.2s;
}
.btn-start:hover { opacity:0.88; }
.btn-outline {
  display:inline-flex; align-items:center; gap:6px;
  border:1px solid var(--border-solid); color:var(--text-muted);
  padding:9px 18px; border-radius:20px;
  font-size:0.9rem;
  cursor:pointer; transition:border-color 0.2s, color 0.2s;
}
.btn-outline:hover { border-color:var(--accent-soft); color:var(--accent); }
.btn-group { display:flex; gap:10px; flex-wrap:wrap; }
.novel-desc { font-size:0.88rem; color:var(--text-muted); line-height:1.8; margin-bottom:24px; border-left:3px solid var(--border-solid); padding-left:14px; }

/* ===== Reading Page ===== */
.reading-wrap {
  max-width: 720px; margin:0 auto;
  padding-top:80px; 
  padding-left:16px; padding-right:16px;
}
.reading-title { font-family: var(--font-serif); font-size:1.2rem; font-weight:700; margin-bottom:28px; color:var(--text); text-align:center; }
.reading-body {
  font-family: var(--font-serif);
  font-size: var(--reading-font-size, 1rem);
  line-height: 2.1;
  color: var(--reading-text);
  letter-spacing:0.02em;
}
.reading-body p { margin-bottom:0.7em; text-indent:2em; }
.reading-nav {
  display:flex; justify-content:space-between; align-items:center;
  padding:16px 0; margin-top:40px;
  border-top:1px solid var(--border);
  gap:12px;
}
.reading-ctrl {
  position:fixed; bottom:0; left:0; right:0;
  background:var(--bg-nav); backdrop-filter:blur(10px);
  border-top:1px solid var(--border);
  padding:12px 20px;
  display:flex; align-items:center; justify-content:center; gap:16px;
  z-index:50;
}
.font-btn { font-size:0.8rem; padding:6px 12px; border-radius:6px; background:var(--tag-bg); color:var(--text-muted); transition:background 0.2s; }
.font-btn:hover { background:var(--hover); color:var(--accent); }
.chapter-nav-btn {
  padding:8px 18px; border-radius:20px; font-size:0.85rem;
  border:1px solid var(--border-solid); color:var(--text-muted);
  cursor:pointer; transition:all 0.2s;
}
.chapter-nav-btn:hover { border-color:var(--accent); color:var(--accent); }
.chapter-nav-btn.primary { background:var(--accent); color:#fff; border-color:var(--accent); }
.chapter-nav-btn.primary:hover { opacity:0.88; }
.progress-text { font-size:0.78rem; color:var(--text-light); }

/* ===== History Page ===== */
.history-item {
  display:flex; gap:14px; align-items:center;
  padding:14px 16px; border-radius:10px;
  background:var(--bg-card); border:1px solid var(--border);
  margin-bottom:8px; cursor:pointer;
  transition:border-color 0.2s;
}
.history-item:hover { border-color:var(--accent-soft); }
.history-info { flex:1; min-width:0; }
.history-title { font-size:0.92rem; font-weight:500; margin-bottom:3px; }
.history-chapter { font-size:0.8rem; color:var(--text-muted); }
.history-time { font-size:0.75rem; color:var(--text-light); white-space:nowrap; }
.history-clear { font-size:0.82rem; color:var(--accent-soft); cursor:pointer; }
.history-clear:hover { color:var(--accent); }

/* ===== Rank Page ===== */
.rank-tabs { display:flex; gap:4px; margin-bottom:20px; background:var(--bg-card); border:1px solid var(--border); border-radius:10px; padding:4px; }
.rank-tab { flex:1; text-align:center; padding:8px 4px; border-radius:7px; font-size:0.85rem; color:var(--text-muted); cursor:pointer; transition:all 0.2s; }
.rank-tab.active { background:var(--accent); color:#fff; }

/* ===== Back Button ===== */
.back-btn {
  display:inline-flex; align-items:center; gap:6px;
  font-size:0.85rem; color:var(--text-muted);
  cursor:pointer; padding:6px 0; margin-bottom:16px;
  transition:color 0.2s;
}
.back-btn:hover { color:var(--accent); }

/* ===== Empty State ===== */
.empty-state { text-align:center; padding:60px 20px; color:var(--text-muted); }
.empty-icon { font-size:3rem; margin-bottom:12px; opacity:0.4; }
.empty-text { font-size:0.9rem; }

/* ===== Divider ===== */
.divider { height:1px; background:var(--border); margin:20px 0; }

/* ===== Filter Bar ===== */
.filter-bar { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:20px; }
.filter-btn { padding:6px 14px; border-radius:16px; font-size:0.82rem; border:1px solid var(--border-solid); color:var(--text-muted); cursor:pointer; transition:all 0.2s; }
.filter-btn.active, .filter-btn:hover { border-color:var(--accent); color:var(--accent); background:var(--tag-bg); }

/* ===== Cover Gradients ===== */
.cov-1 { background:linear-gradient(145deg,#8b5a2b,#c4956a); }
.cov-2 { background:linear-gradient(145deg,#2d5a3d,#4a9b6a); }
.cov-3 { background:linear-gradient(145deg,#3d3580,#6b63c4); }
.cov-4 { background:linear-gradient(145deg,#8b2d3d,#c46a7a); }
.cov-5 { background:linear-gradient(145deg,#5a3d8b,#956ac4); }
.cov-6 { background:linear-gradient(145deg,#2d5a7a,#4a9bbf); }
.cov-7 { background:linear-gradient(145deg,#7a5a2d,#c4a06a); }
.cov-8 { background:linear-gradient(145deg,#3d5a2d,#7ab04a); }

/* ===== Toast ===== */
.toast {
  position:fixed; bottom:80px; left:50%; transform:translateX(-50%) translateY(20px);
  background:var(--text); color:var(--bg);
  padding:10px 20px; border-radius:20px;
  font-size:0.85rem; z-index:200;
  opacity:0; transition:all 0.3s; pointer-events:none;
}
.toast.show { opacity:1; transform:translateX(-50%) translateY(0); }

/* ===== Responsive ===== */
@media (max-width:640px) {
  .nav-links { display:none; }
  .ham { display:flex; }
  .search-bar { min-width:120px; }
  .detail-cover { width:90px; height:120px; }
  .detail-title { font-size:1.15rem; }
  .novel-grid { grid-template-columns:repeat(auto-fill,minmax(130px,1fr)); gap:12px; }
  .cat-grid { grid-template-columns:repeat(4,1fr); }
  .hero-title { font-size:1.3rem; }
  .chapter-grid { grid-template-columns:1fr 1fr; }
  .reading-ctrl { padding:10px 14px; gap:10px; }
}
@media (max-width:415px) {
  .cat-grid { grid-template-columns:repeat(3,1fr); }
  .novel-grid { grid-template-columns:repeat(2,1fr); }

  /* 小屏 */
  .detail-header { flex-direction:column; align-items:center; gap:12px; }
  .detail-cover { width:100px; height:130px; }
  .detail-title { font-size:1.1rem; text-align:center; }
}

/* ===== Mobile Nav ===== */
.mobile-nav {
  display:none; position:fixed; top:56px; left:0; right:0;
  background:var(--bg-nav); backdrop-filter:blur(12px);
  border-bottom:1px solid var(--border);
  flex-direction:column; z-index:99; padding:8px 12px 12px;
}
.mobile-nav.open { display:flex; }
.mobile-nav .nav-link { padding:10px 12px; }

/* ===== Reading progress bar ===== */
.read-progress {
  position:fixed; top:56px; left:0; height:2px;
  background:var(--accent); z-index:101;
  transition:width 0.2s;
}

/* ===== Breadcrumb ===== */
.breadcrumb { display:flex; align-items:center; gap:6px; font-size:0.78rem; color:var(--text-light); margin-bottom:20px; flex-wrap:wrap; }
.breadcrumb a { cursor:pointer; transition:color 0.2s; }
.breadcrumb a:hover { color:var(--accent); }
.breadcrumb-sep { opacity:0.4; }

/* ===== Stars ===== */
.stars { color:#e8a040; font-size:0.85rem; }

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  padding: 12px 20px 12px;
}
.footer-inner {
  max-width: 1120px; margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 32px;
}
.footer-brand .site-logo { font-family: var(--font-serif); font-size: 1.2rem; font-weight: 700; color: var(--accent); margin-bottom: 10px; }
.footer-brand p { font-size: 0.82rem; color: var(--text-muted); line-height: 1.8; max-width: 300px; }
.footer-col h2 { font-size: 1.2rem; font-weight: 600; margin-bottom: 12px; color: var(--text); }
.footer-col a { display: block; font-size: 0.82rem; color: var(--text-muted); margin-bottom: 8px; cursor: pointer; transition: color 0.2s; }
.footer-col a:hover { color: var(--accent); }
.footer-bottom {
  max-width: 1120px; margin: 8px auto 0;
  padding-top: 16px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.78rem; color: var(--text-light); flex-wrap: wrap; gap: 8px;
}
@media (max-width: 640px) {
  .footer-inner { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
}

.chapterlist-nav {
  display:flex; justify-content:space-between; align-items:center;
  padding:16px 0; margin-top:10px;
  gap:12px;
}

/* ===== Select 美化 ===== */
.select-wrap {
  position: relative;
  display: inline-block;
}

.select-wrap::after {
  content: '›';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%) rotate(90deg);
  color: var(--accent-soft);
  font-size: 1rem;
  pointer-events: none;
  transition: transform 0.2s;
}

.select-wrap:focus-within::after {
  transform: translateY(-50%) rotate(-90deg);
  color: var(--accent);
}

select {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  padding: 8px 36px 8px 14px;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border-solid);
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.5;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

select:hover {
  border-color: var(--accent-soft);
}

select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 90, 43, 0.12);
}

select option {
  background: var(--bg-card);
  color: var(--text);
  padding: 6px 0;
}

/* 尺寸變體 */
select.select-sm {
  padding: 5px 32px 5px 10px;
  font-size: 0.8rem;
  border-radius: 6px;
}

select.select-lg {
  padding: 11px 40px 11px 16px;
  font-size: 0.95rem;
  border-radius: 10px;
}

/* 狀態：禁用 */
select:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  border-color: var(--border-solid);
}

select:disabled + .select-wrap::after {
  opacity: 0.4;
}

.notice {
  color: red;
}

.fav-action-btn {
    border-radius: 50%;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    float: right;
}
.fav-action-btn.active #heart-path {
    fill: #ff4d4f;
    stroke: #ff4d4f;
}
.fav-particle {
  position: fixed;
  font-size: 14px;
  pointer-events: none;
  animation: fly 700ms cubic-bezier(.22,.61,.36,1) forwards;
}
@keyframes fly {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--x), var(--y)) scale(.3);
    opacity: 0;
  }
}
/* ===== Scroll Float Button ===== */
.scroll-fab {
  position: fixed;
  right: 20px;
  bottom: 200px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 99;
  box-shadow: 0 4px 14px rgba(139, 90, 43, 0.35);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s, background 0.2s;
  user-select: none;
}
.scroll-fab.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.scroll-fab:hover {
  background: var(--accent-soft);
  box-shadow: 0 6px 18px rgba(139, 90, 43, 0.45);
}
.scroll-fab:active {
  transform: scale(0.92);
}

/* 閱讀頁底部控制欄已佔位，往上移一些 */
.page#page-reading ~ .scroll-fab,
body:has(#page-reading.active) .scroll-fab {
  bottom: 70px;
}

/* ===== 閱讀頁字體選單 ===== */
.reading-ctrl .select-wrap {
  position: relative;
}
.reading-ctrl .select-wrap::after {
  content: '›';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%) rotate(90deg);
  font-size: 0.85rem;
  color: var(--accent-soft);
  pointer-events: none;
}
.reading-ctrl select {
  appearance: none;
  -webkit-appearance: none;
  padding: 5px 26px 5px 10px;
  background: var(--tag-bg);
  color: var(--text-muted);
  border: 1px solid var(--border-solid);
  border-radius: 6px;
  font-size: 0.8rem;
  font-family: var(--font-sans);
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s, color 0.2s;
}
.reading-ctrl select:hover,
.reading-ctrl select:focus {
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== 詳情頁推薦 Tab ===== */
.rec-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.rec-tab {
  padding: 8px 20px;
  font-size: 0.88rem;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.2s, border-color 0.2s;
}
.rec-tab:hover { color: var(--accent); }
.rec-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 500;
}
.rec-list {
  display: flex;
  flex-direction: column;
  display: none;
}
.rec-list.active { display: block; }
.rec-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
}
.rec-item:last-child { border-bottom: none; }
.rec-item:hover { background: var(--hover); }
.rec-title {
  flex: 1;           /* 佔滿中間空間，把 badge 擠到最右 */
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rec-rank {
  width: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-light);
  text-align: center;
  flex-shrink: 0;
}
.rec-rank.top { color: var(--accent); }
.rec-meta { font-size: 0.75rem; color: var(--text-muted); }
.rec-badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--tag-bg);
  color: var(--accent);
  flex-shrink: 0;
  white-space: nowrap;
}
@media (min-width: 640px) {
  .detail-author {
    gap:20px;
  }
}