/* ==========================================================================
   Cinovel — main stylesheet (mobile-first, no framework)
   ========================================================================== */
:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --surface: #ffffff;
  --text: #16181d;
  --text-muted: #5b6472;
  --border: #e4e7ec;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --accent: #f59e0b;
  --success: #16a34a;
  --danger: #dc2626;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);
  --max: 1120px;
  --header-h: 60px;
  --tabbar-h: 0px;  /* height of the mobile bottom tab bar; 0 on desktop */
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg-soft);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding-bottom: var(--tabbar-h);
}

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

.container { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 16px; }
.main-content { min-height: 60vh; padding-top: 20px; padding-bottom: 48px; }

.muted { color: var(--text-muted); }
.small { font-size: .85rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 42px; padding: 0 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: .95rem; font-weight: 600; cursor: pointer; transition: .15s ease;
  text-decoration: none !important; white-space: nowrap; box-sizing: border-box;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-soft); }
.btn-sm { height: 34px; padding: 0 12px; font-size: .82rem; border-radius: 6px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 1rem; border-radius: 8px; }
.btn-block { width: 100%; }
.btn.disabled, .btn[disabled] { opacity: .5; pointer-events: none; }
.linklike { background: none; border: none; color: var(--primary); cursor: pointer; font: inherit; padding: 0; }
.linklike:hover { text-decoration: underline; }
.inline-form { display: inline-flex; align-items: center; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50; height: var(--header-h);
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 16px; height: var(--header-h); }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -.03em;
  text-decoration: none;
}
.brand:hover {
  text-decoration: none;
  opacity: 0.92;
}
.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  object-fit: contain;
  display: block;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}
.brand-text {
  display: inline-block;
  line-height: 1;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.brand-ci {
  color: #000000;
}
.brand-novel {
  color: #7c3aed;
}
:root[data-reader-theme="dark"] .brand-ci {
  color: #f8fafc;
}
.header-search { flex: 1; display: flex; max-width: 420px; }
.header-search input {
  flex: 1; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm); font-size: .9rem; outline: none;
}
.header-search input:focus { border-color: var(--primary); }
.header-search button {
  padding: 8px 14px; border: 1px solid var(--border); border-left: none;
  background: var(--bg-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  cursor: pointer; font-size: 1rem;
}
.site-nav { display: flex; align-items: center; gap: 14px; margin-left: auto; font-size: .9rem; }
.nav-user { color: var(--text-muted); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Primary nav (desktop tabs) ---------- */
.primary-nav { display: flex; align-items: center; gap: 4px; }
.nav-tab {
  padding: 6px 14px; border-radius: 999px; color: var(--text-muted);
  font-weight: 600; font-size: .92rem;
}
.nav-tab:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.nav-tab.active { color: var(--primary); background: #eef2ff; }
.account-nav { margin-left: auto; }

/* ---------- Hamburger + slide-out drawer (mobile) ---------- */
.hamburger {
  display: none; margin-left: auto; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer; color: var(--text);
  font-size: 24px; line-height: 1; padding: 6px 8px;
}
.nav-overlay {
  position: fixed; inset: 0; z-index: 200; background: rgba(16, 24, 40, .45);
  opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility .25s ease;
}
.nav-overlay.open { opacity: 1; visibility: visible; }
.nav-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 210;
  width: min(320px, 86vw); padding: 16px; overflow-y: auto;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .25s ease;
  display: flex; flex-direction: column; gap: 18px;
}
.nav-drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer-title { font-weight: 800; font-size: 1.05rem; }
.drawer-close {
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  font-size: 22px; line-height: 1; padding: 4px 8px;
}
.drawer-close:hover { color: var(--text); }
.drawer-search { display: flex; }
.drawer-search input {
  flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm); font-size: .95rem; outline: none;
}
.drawer-search input:focus { border-color: var(--primary); }
.drawer-search button {
  padding: 10px 14px; border: 1px solid var(--border); border-left: none;
  background: var(--bg-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  cursor: pointer; font-size: 1rem;
}
.drawer-account { display: flex; flex-direction: column; gap: 10px; }
.drawer-user { color: var(--text-muted); font-size: .9rem; word-break: break-all; }
body.drawer-open { overflow: hidden; }

/* ---------- Bottom tab bar (mobile) ---------- */
.tab-bar {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 150;
  height: var(--tabbar-h); padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(0, 0, 0, 0.07);
}
:root[data-theme="dark"] .tab-bar {
  background: rgba(20, 22, 26, 0.94);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding-top: 7px; color: var(--text-muted); font-size: .68rem; font-weight: 600;
}
.tab:hover { text-decoration: none; }
.tab.active { color: var(--primary); }
.tab-icon { display: block; width: 22px; height: 22px; }
.tab-icon svg { width: 100%; height: 100%; display: block; }
.tab-label { line-height: 1; }

/* ---------- Page title + Recent list ---------- */
.page-title { font-size: 1.5rem; margin: 8px 0 16px; letter-spacing: -.01em; }
.recent-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.recent-item {
  display: flex; align-items: center; gap: 12px; padding: 10px; color: inherit;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); transition: .18s ease;
}
.recent-item:hover { text-decoration: none; box-shadow: var(--shadow-lg); }
.recent-cover { flex: 0 0 auto; width: 48px; height: 64px; border-radius: 6px; overflow: hidden; background: var(--bg-soft); }
.recent-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.recent-cover .cover-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.1rem; color: #fff; background: linear-gradient(135deg, var(--primary), #7c3aed);
}
.recent-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.recent-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-meta { font-size: .82rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-cta { flex: 0 0 auto; color: var(--primary); font-weight: 700; font-size: .9rem; }

/* ---------- Me (account hub) ---------- */
.me-section {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.me-h { font-size: 1rem; margin: 0 0 10px; }
.me-acct-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.me-email { font-weight: 600; word-break: break-all; }
.me-note { margin: 0 0 10px; }
.me-version { color: var(--text-muted); font-size: .9rem; margin: 0 0 10px; }
.me-links { display: flex; flex-direction: column; gap: 8px; }
.txn-list { list-style: none; margin: 0; padding: 0; }
.txn { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--border); }
.txn:first-child { border-top: none; }
.txn-book { flex: 1; min-width: 140px; font-weight: 600; }
.txn-amount { font-variant-numeric: tabular-nums; }
.txn-status { font-size: .75rem; padding: 2px 9px; border-radius: 999px; background: var(--bg-soft); color: var(--text-muted); }
.txn-succeeded { background: #ecfdf3; color: #065f46; }
.txn-refunded { background: #fff8e6; color: #8a5a00; }
.txn-failed { background: #fef2f2; color: #991b1b; }
.txn-date { color: var(--text-muted); font-size: .82rem; }

/* ---------- Messages ---------- */
.messages { list-style: none; padding: 0; margin: 16px 0 0; }
.msg { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 8px; font-size: .9rem; }
.msg-success { background: #ecfdf3; color: #065f46; border: 1px solid #a7f3d0; }
.msg-error, .msg-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.msg-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ---------- Sleek Hero & Code Strip (Prominent Title) ---------- */
.hero-code-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 22px;
  margin: 14px 0 16px 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}
.strip-brand {
  min-width: 0;
  flex: 1;
}
.strip-title {
  font-size: clamp(1.25rem, 2.2vw, 1.55rem);
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
  margin: 0 0 3px 0;
  letter-spacing: -0.02em;
}
.strip-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 0;
  font-weight: 400;
}
.strip-code-action {
  flex-shrink: 0;
}
.strip-code-form {
  display: flex;
  align-items: center;
  margin: 0;
}
.strip-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-soft);
  border: 1.5px solid var(--border);
  border-radius: 9999px;
  padding: 4px 5px 4px 14px;
  height: 42px;
  box-sizing: border-box;
  transition: all 0.2s ease;
}
.strip-input-wrap:focus-within {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.strip-icon {
  font-size: 1.05rem;
  margin-right: 8px;
  opacity: 0.85;
  line-height: 1;
}
.strip-input-wrap input {
  border: none;
  background: transparent;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  outline: none;
  width: 190px;
  text-transform: uppercase;
}
.strip-input-wrap input::placeholder {
  text-transform: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 400;
}
.strip-submit-btn {
  border: none;
  background: var(--primary);
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 9999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}
.strip-submit-btn:hover {
  background: var(--primary-hover);
}

/* Fallback for legacy .hero & .code-search-bar if loaded on other sub-pages */
.hero { text-align: center; padding: 20px 0 16px; }
.hero h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); margin: 0 0 8px; letter-spacing: -.02em; }
.hero p { color: var(--text-muted); margin: 0; font-size: 0.95rem; }

.code-search-bar {
  max-width: 480px;
  margin: 10px auto 20px auto;
  padding: 0 12px;
}
.code-input-wrap {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 9999px;
  padding: 4px 6px 4px 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
}
.code-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}
.code-icon {
  font-size: 1.15rem;
  margin-right: 10px;
  display: flex;
  align-items: center;
}
.code-input-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.95rem;
  color: var(--text);
  text-transform: uppercase;
  min-width: 0;
}
.code-input-wrap input::placeholder {
  text-transform: none;
  color: var(--text-muted);
  font-size: 0.88rem;
}
.code-input-wrap button {
  border-radius: 9999px;
  white-space: nowrap;
  font-weight: 600;
  padding: 8px 18px;
  margin-left: 6px;
}
.code-error-alert {
  margin: 10px 0;
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 0.88rem;
  text-align: center;
}

/* ---------- Filter bar ---------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0 20px;
}
.filter-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.filter-search-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.filter-search-wrap input[type="search"] {
  width: 220px;
  height: 38px;
  padding: 8px 32px 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 8px);
  font-size: 0.88rem;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.filter-search-wrap input[type="search"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.filter-search-wrap button[type="submit"] {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 0.95rem;
  line-height: 1;
}
.filter-search-wrap button[type="submit"]:hover {
  color: var(--primary);
}
.filter-form select {
  height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 8px);
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.filter-form select:hover {
  border-color: var(--primary);
}
.filter-form select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.clear-filters { font-size: .85rem; color: var(--text-muted); }

/* ---------- Book grid & cards ---------- */
.book-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
.book-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); transition: transform .18s ease, box-shadow .18s ease;
  display: flex; flex-direction: column; color: inherit; position: relative;
}
.book-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); text-decoration: none; }
.book-card:active { transform: scale(0.99); }
.book-cover { position: relative; aspect-ratio: 3 / 4; background: var(--bg-soft); overflow: hidden; }
.book-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary), #7c3aed); color: #fff;
  font-size: 2.5rem; font-weight: 800;
}
.cover-placeholder.large { font-size: 4rem; }

/* Floating Status Badges on Cover (Top Layer - Compact & Refined) */
.badge-status-overlay {
  position: absolute;
  top: 5px;
  left: 5px;
  z-index: 3;
  padding: 1.5px 6px;
  border-radius: 9999px;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1.15;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  pointer-events: none;
}
.badge-status-overlay::before {
  content: "";
  display: inline-block;
  width: 3.5px;
  height: 3.5px;
  border-radius: 50%;
  background: currentColor;
}
/* Cover Floating Badges (Only for .badge-status-overlay) */
.badge-status-overlay.badge-completed {
  background: rgba(5, 150, 105, 0.92);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.42);
}
.badge-status-overlay.badge-completed::before {
  background: #a7f3d0;
}
.badge-status-overlay.badge-ongoing {
  background: rgba(217, 119, 6, 0.94);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.42);
}
.badge-status-overlay.badge-ongoing::before {
  background: #fde68a;
}

/* Card Bottom Metadata Status Badges (Refined, Subtle, Never Shouting) */
.stat-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.01em;
}
.stat-status .status-dot {
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: currentColor;
}
.stat-status.status-completed {
  background: rgba(5, 150, 105, 0.08) !important;
  color: #059669 !important;
  border: 1px solid rgba(5, 150, 105, 0.18) !important;
  box-shadow: none !important;
}
.stat-status.status-ongoing {
  background: rgba(217, 119, 6, 0.08) !important;
  color: #b45309 !important;
  border: 1px solid rgba(217, 119, 6, 0.18) !important;
  box-shadow: none !important;
}

.book-meta {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  justify-content: space-between;
}
.book-meta-top {
  display: block;
}
.book-title {
  font-size: 0.93rem;
  margin: 0 0 4px;
  line-height: 1.35;
  font-weight: 600;
  height: 2.7em; /* Fixed 2 lines for rock-solid baseline alignment */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text);
}
.book-author {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0 0 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.book-abstract {
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-muted);
  margin: 0 0 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex-grow: 1;
}
.book-meta-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 6px;
  border-top: 1px solid rgba(0, 0, 0, 0.04);
  font-size: 0.74rem;
  color: var(--text-muted);
}

.book-meta-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  white-space: nowrap;
}

.book-meta-stats {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.stat-dot-num {
  font-weight: 600;
  color: var(--text);
}
.stat-sep {
  color: var(--border);
  font-size: 0.7rem;
}
.book-category-pill {
  font-size: 0.68rem;
  line-height: 1.4;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 1.5px 7px;
  border-radius: 999px;
  color: var(--text-muted);
  white-space: nowrap;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* In Grid view, hide synopsis to keep vertical cards uniform */
html.view-grid .book-card .book-abstract,
html:not(.view-list) .book-card .book-abstract {
  display: none;
}

/* In List view, display the synopsis in the red-marked content row */
html.view-list .book-card .book-abstract {
  display: -webkit-box !important;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-muted);
  margin: 6px 0 10px;
  flex-grow: 1;
}

/* ---------- Layout toggle (grid / list) ---------- */
.view-toggle {
  display: inline-flex; margin-left: auto;
  height: 42px;
  border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.view-btn {
  border: none; background: transparent; cursor: pointer;
  width: 42px; height: 42px;
  padding: 0; font-size: 1rem; line-height: 1; color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
}
.view-btn + .view-btn { border-left: 1px solid var(--border); }
.view-btn.active { background: var(--primary); color: #fff; }

/* List view: horizontal card layout (Standard for Mobile & Readers) */
html.view-list .book-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
html.view-list .book-card {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  min-height: 132px;
  border-radius: var(--radius);
}
html.view-list .book-card:hover { transform: none; box-shadow: var(--shadow-lg); }
html.view-list .book-cover {
  flex: 0 0 96px;
  width: 96px;
  aspect-ratio: 3 / 4;
}
html.view-list .book-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px 14px 10px 14px;
}
html.view-list .book-title {
  font-size: 1.02rem;
  margin: 0 0 2px;
  -webkit-line-clamp: 1;
}
html.view-list .book-author {
  font-size: 0.80rem;
  margin: 0 0 6px;
}
html.view-list .book-abstract {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 0.83rem;
  line-height: 1.45;
  color: var(--text-muted);
  margin: 2px 0 6px;
  flex-grow: 1;
}
html.view-list .book-meta-bottom {
  margin-top: auto;
  padding-top: 4px;
  border-top: none;
}
/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .72rem;
  font-weight: 600; background: var(--bg-soft); color: var(--text-muted); border: 1px solid var(--border);
}
.badge-status { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.65); color: #fff; border: none; }
.badge-link { color: var(--primary); }
.badge-link:hover { background: #eef2ff; text-decoration: none; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 32px;
  margin-bottom: 24px;
}
.page-link {
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 8px);
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: all 0.15s ease;
  text-decoration: none !important;
  box-sizing: border-box;
}
.page-link:hover {
  background: var(--bg-soft);
  border-color: var(--primary);
  color: var(--primary);
}
.page-link.disabled {
  opacity: 0.45;
  pointer-events: none;
  box-shadow: none;
}
.page-current {
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  box-sizing: border-box;
}

/* ---------- Book detail ---------- */
.breadcrumb { font-size: .85rem; color: var(--text-muted); margin: 8px 0 20px; }
.detail-layout { display: flex; flex-direction: column; gap: 24px; }
.detail-cover img, .detail-cover .cover-placeholder {
  width: 100%; max-width: 260px; border-radius: var(--radius); box-shadow: var(--shadow-lg);
  aspect-ratio: 3 / 4; object-fit: cover;
}
.detail-info { flex: 1; }
.detail-title { font-size: clamp(1.5rem, 4vw, 2.2rem); margin: 0 0 4px; letter-spacing: -.02em; }
.detail-author { color: var(--text-muted); margin: 0 0 12px; }
.detail-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.detail-stats { list-style: none; display: flex; flex-wrap: wrap; gap: 20px; padding: 0; margin: 0 0 16px; color: var(--text-muted); font-size: .9rem; }
.detail-stats strong { color: var(--text); }
.detail-abstract { color: var(--text); margin-bottom: 20px; }

.purchase-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.price-line { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.price { font-size: 1.9rem; font-weight: 800; color: var(--text); }
.price.big { font-size: 2.4rem; }
.price-note { color: var(--text-muted); font-size: .85rem; }
.cta-row { display: flex; flex-wrap: wrap; gap: 10px; }
.owned-tag { display: inline-block; color: var(--success); font-weight: 700; margin-bottom: 10px; }

.chapter-list-section { margin-top: 36px; }
.chapter-list-section h2 { font-size: 1.3rem; margin-bottom: 12px; }
.chapter-list { list-style: none; padding: 0; margin: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.chapter-list li + li { border-top: 1px solid var(--border); }
.chapter-link { display: flex; align-items: center; gap: 12px; padding: 11px 14px; color: var(--text); }
.chapter-link:hover { background: var(--bg-soft); text-decoration: none; }
.chapter-link.locked { color: var(--text-muted); }
.ch-index { font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: .85rem; min-width: 32px; }
.ch-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-flag { font-size: .72rem; font-weight: 600; }
.ch-flag.free { color: var(--success); }

/* ---------- Reader ---------- */
/* Background themes: one data attribute on <html> drives --reader-bg /
   --reader-canvas / --reader-paper so the page, header, side docks and paper recolor together. */
:root {
  --reader-bg: #fffdf7;
  --reader-canvas: #ebe8e1;
  --reader-paper: #ffffff;
  --reader-text: #23262b;
  --reader-dock-bg: rgba(255, 255, 255, 0.94);
  --reader-dock-border: rgba(0, 0, 0, 0.08);
  --reader-sheet-border: rgba(0, 0, 0, 0.07);
  --reader-sheet-shadow: 0 6px 30px rgba(0, 0, 0, 0.06);
}
:root[data-reader-theme="white"] {
  --reader-bg: #ffffff;
  --reader-canvas: #f0f2f5;
  --reader-paper: #ffffff;
  --reader-text: #1a1a1a;
  --reader-dock-bg: rgba(255, 255, 255, 0.96);
  --reader-dock-border: rgba(0, 0, 0, 0.08);
  --reader-sheet-border: rgba(0, 0, 0, 0.08);
  --reader-sheet-shadow: 0 6px 30px rgba(0, 0, 0, 0.05);
}
:root[data-reader-theme="sepia"] {
  --reader-bg: #f1e5cb;
  --reader-canvas: #dfd2b5;
  --reader-paper: #f4ecda;
  --reader-text: #4a3c25;
  --reader-dock-bg: rgba(244, 236, 218, 0.96);
  --reader-dock-border: rgba(90, 65, 30, 0.12);
  --reader-sheet-border: rgba(90, 65, 30, 0.1);
  --reader-sheet-shadow: 0 6px 30px rgba(74, 60, 37, 0.08);
}
:root[data-reader-theme="green"] {
  --reader-bg: #cbe7ce;
  --reader-canvas: #b6d4ba;
  --reader-paper: #d5ecd8;
  --reader-text: #22382a;
  --reader-dock-bg: rgba(213, 236, 216, 0.96);
  --reader-dock-border: rgba(30, 60, 35, 0.12);
  --reader-sheet-border: rgba(30, 60, 35, 0.1);
  --reader-sheet-shadow: 0 6px 30px rgba(32, 53, 39, 0.07);
}
:root[data-reader-theme="dark"]  {
  --reader-bg: #14161a;
  --reader-canvas: #0c0e12;
  --reader-paper: #181b21;
  --reader-text: #c9d0d8;
  --reader-dock-bg: rgba(24, 27, 33, 0.94);
  --reader-dock-border: rgba(255, 255, 255, 0.1);
  --reader-sheet-border: rgba(255, 255, 255, 0.08);
  --reader-sheet-shadow: 0 8px 36px rgba(0, 0, 0, 0.45);
}

.reader-page {
  --tabbar-h: 0px;
  padding-bottom: 0;
  background: var(--reader-canvas, var(--reader-bg));
  color: var(--reader-text);
  min-height: 100vh;
}
.reader-main {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 0;
}
.reader-workspace {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
}
.reader {
  width: 100%;
  max-width: 860px;
  box-sizing: border-box;
}

/* Item 1: Centered Paper Sheet */
@media (min-width: 720px) {
  .reader-paper-sheet {
    margin: 28px auto 60px;
    padding: 44px 60px 52px;
    background: var(--reader-paper, var(--reader-bg));
    border: 1px solid var(--reader-sheet-border);
    border-radius: 8px;
    box-shadow: var(--reader-sheet-shadow);
    transition: background-color 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
  }
}
@media (max-width: 719px) {
  .reader-page {
    background: var(--reader-bg) !important;
  }
  .reader-main {
    padding: 0 12px;
  }
  .reader-paper-sheet {
    margin: 0 auto;
    padding: 16px 4px 44px;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }
}

/* ---------- Reader Header (Default: Desktop Sticky) ---------- */
.reader-header {
  position: sticky; top: 0; z-index: 60;
  background: var(--reader-paper, var(--reader-bg));
  border-bottom: 1px solid var(--reader-sheet-border, rgba(128,128,128,.18));
  transform: none; opacity: 1; pointer-events: auto;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.02);
}
.reader-header-inner {
  max-width: 860px; margin: 0 auto; height: 52px; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.reader-header-title {
  font-size: 0.92rem; font-weight: 600; max-width: 60%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--reader-text); opacity: .88;
}
.reader-header-actions { display: flex; align-items: center; gap: 4px; }
.reader-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 38px; height: 38px; padding: 0; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--reader-text); cursor: pointer; text-decoration: none;
  transition: background .15s ease;
}
.reader-icon-btn:hover { background: rgba(128,128,128,.14); color: var(--reader-text); text-decoration: none; }
.reader-icon-btn svg { width: 20px; height: 20px; }

/* Desktop: Bottom floating HUD is hidden */
.reader-hud-bottom {
  display: none;
}

/* ---------- Items 2 & 3: PC Floating Side Docks (>= 1080px) ---------- */
@media (min-width: 1080px) {
  .reader-dock {
    position: fixed;
    top: 130px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--reader-dock-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--reader-dock-border);
    border-radius: 12px;
    padding: 8px 6px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.06);
    transition: background 0.22s ease, border-color 0.22s ease;
  }
  .reader-dock-left {
    right: calc(50% + 430px + 18px);
  }
  .reader-dock-right {
    left: calc(50% + 430px + 18px);
  }
  .dock-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border: 0;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    color: var(--reader-text);
    opacity: 0.72;
    transition: all 0.16s ease;
    text-decoration: none !important;
    gap: 3px;
  }
  .dock-btn:hover {
    opacity: 1;
    background: rgba(128, 128, 128, 0.12);
    transform: translateY(-1px);
    color: var(--reader-text);
  }
  .dock-btn:active {
    transform: translateY(0);
  }
  .dock-text {
    font-size: 0.67rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    line-height: 1;
  }
  .dock-icon-text {
    font-weight: 700;
    line-height: 1;
  }
  .dock-icon-text.font-lg {
    font-size: 1.05rem;
  }
  .dock-icon-text.font-sm {
    font-size: 0.88rem;
  }
  .dock-separator {
    height: 1px;
    background: var(--reader-dock-border);
    margin: 4px 6px;
  }
}
@media (max-width: 1079px) {
  .reader-dock {
    display: none !important;
  }
}

/* ---------- Item 4: Editorial Breadcrumb & Metadata ---------- */
.reader-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--reader-text);
  opacity: 0.68;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(128, 128, 128, 0.12);
}
.bc-link {
  color: inherit;
  text-decoration: none;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.bc-link:hover {
  opacity: 1;
  color: var(--primary);
}
.bc-sep {
  opacity: 0.4;
  font-size: 0.78rem;
}
.bc-current {
  font-weight: 600;
  opacity: 0.9;
}

.chapter-meta-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 0.82rem;
}
.ch-badge {
  font-weight: 700;
  color: var(--primary);
  background: rgba(79, 70, 229, 0.09);
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.75rem;
}
.ch-meta-stat {
  color: var(--reader-text);
  opacity: 0.6;
}
.ch-meta-status {
  margin-left: auto;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}
.ch-meta-status.free {
  color: #059669;
  background: rgba(16, 185, 129, 0.1);
}
.ch-meta-status.paid {
  color: #4f46e5;
  background: rgba(79, 70, 229, 0.1);
}

/* ---------- Item 6: End-of-Chapter Card ---------- */
.reader-end-card {
  margin: 40px 0 28px;
}
.end-card-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.end-card-line {
  flex: 1;
  height: 1px;
  background: rgba(128, 128, 128, 0.18);
}
.end-card-tag {
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--reader-text);
  opacity: 0.55;
  white-space: nowrap;
}
.end-card-next {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  background: rgba(128, 128, 128, 0.05);
  border: 1px solid rgba(128, 128, 128, 0.14);
  border-radius: 10px;
  text-decoration: none !important;
  transition: all 0.2s ease;
  gap: 16px;
}
.end-card-next:hover {
  background: rgba(128, 128, 128, 0.09);
  border-color: rgba(79, 70, 229, 0.35);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}
.end-card-next-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.end-card-next-subtitle {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
}
.end-card-next-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--reader-text);
}
.end-card-btn {
  white-space: nowrap;
  font-size: 0.9rem;
  padding: 8px 18px;
}
.end-card-finished {
  text-align: center;
  padding: 24px;
  background: rgba(128, 128, 128, 0.05);
  border-radius: 10px;
}
.end-card-msg {
  font-size: 0.95rem;
  margin-bottom: 14px;
  color: var(--reader-text);
}

/* ---------- Item 5: Keyboard Shortcuts Hint ---------- */
.reader-keyboard-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px dashed rgba(128, 128, 128, 0.15);
  font-size: 0.78rem;
  color: var(--reader-text);
  opacity: 0.6;
}
.kbd-title {
  font-weight: 600;
}
.kbd-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.kbd-pill kbd {
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 6px;
  background: rgba(128, 128, 128, 0.12);
  border: 1px solid rgba(128, 128, 128, 0.22);
  border-radius: 4px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
}
@media (max-width: 719px) {
  .reader-keyboard-hint {
    display: none !important;
  }
}

/* ---------- Reader Drawers & Navigation ---------- */
.reader-menu-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.4); opacity: 0; visibility: hidden; transition: opacity .22s ease, visibility .22s ease; }
.reader-menu-overlay.open { opacity: 1; visibility: visible; }
.reader-menu {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 210; width: min(300px, 84vw);
  padding: 10px 16px 28px; overflow-y: auto; background: var(--reader-bg); color: var(--reader-text);
  border-left: 1px solid rgba(128,128,128,.25); box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .24s ease;
}
.reader-menu.open { transform: translateX(0); }
.reader-menu-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.reader-menu-title { font-weight: 700; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-menu-link { display: flex; align-items: center; gap: 10px; padding: 12px 8px; margin: 0 -8px; color: var(--reader-text); font-weight: 600; border-radius: var(--radius-sm); }
.reader-menu-link:hover { background: rgba(128,128,128,.14); color: var(--reader-text); text-decoration: none; }
.reader-menu-ico { font-size: 15px; opacity: .75; }
.reader-setting { padding: 16px 0; border-top: 1px solid rgba(128,128,128,.2); }
.reader-setting-label { display: block; font-size: .76rem; text-transform: uppercase; letter-spacing: .07em; opacity: .7; margin-bottom: 12px; }
.reader-controls { display: flex; gap: 10px; }
.reader-controls .ctrl { flex: 1; }
.ctrl { padding: 10px 12px; border: 1px solid rgba(128,128,128,.35); border-radius: var(--radius-sm); background: transparent; color: var(--reader-text); cursor: pointer; font-size: .92rem; }
.ctrl:hover { background: rgba(128,128,128,.14); }
.theme-swatches { display: flex; gap: 14px; }
.swatch { width: 42px; height: 42px; padding: 0; border-radius: 50%; cursor: pointer; border: 2px solid rgba(128,128,128,.35); }
.swatch[data-theme="white"] { background: #ffffff; }
.swatch[data-theme="light"] { background: #fffdf7; }
.swatch[data-theme="sepia"] { background: #f1e5cb; }
.swatch[data-theme="green"] { background: #cbe7ce; }
.swatch[data-theme="dark"]  { background: #14161a; }
.swatch.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
body.reader-menu-open { overflow: hidden; }

/* Table-of-contents drawer (目录) — same slide-in pattern as the menu */
.reader-toc-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.4); opacity: 0; visibility: hidden; transition: opacity .22s ease, visibility .22s ease; }
.reader-toc-overlay.open { opacity: 1; visibility: visible; }
.reader-toc {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 210; width: min(340px, 88vw);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--reader-bg); color: var(--reader-text);
  border-left: 1px solid rgba(128,128,128,.25); box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .24s ease;
}
.reader-toc.open { transform: translateX(0); }
.reader-toc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px 10px 16px; border-bottom: 1px solid rgba(128,128,128,.2); }
.reader-toc-title { font-weight: 700; font-size: 1rem; }
.toc-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.toc-item { display: flex; align-items: center; gap: 10px; padding: 11px 16px; color: var(--reader-text); }
.toc-item:hover { background: rgba(128,128,128,.12); color: var(--reader-text); text-decoration: none; }
.toc-item.current { color: var(--primary); font-weight: 700; }
.toc-item.locked { opacity: .55; }
.toc-idx { font-variant-numeric: tabular-nums; font-size: .8rem; opacity: .6; min-width: 26px; text-align: right; }
.toc-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc-lock { font-size: .78rem; }
.reader-toc-foot { padding: 12px 16px; border-top: 1px solid rgba(128,128,128,.2); }
.reader-toc-foot a { color: #000; font-size: .9rem; font-weight: 600; }
:root[data-reader-theme="dark"] .reader-toc-foot a { color: var(--reader-text); }
body.reader-toc-open { overflow: hidden; }

.chapter { padding: 24px 0; }
.chapter-head { margin-bottom: 20px; }
.chapter-order { color: var(--reader-text); opacity: .65; font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; }
.chapter-title { font-size: 1.7rem; margin: 4px 0 0; letter-spacing: -.01em; color: var(--reader-text); }
.chapter-content {
  font-size: var(--reader-font, 1.125rem); line-height: 1.85;
  color: var(--reader-text); font-family: Georgia, "Times New Roman", serif;
}
.chapter-content p { margin: 0 0 1.1em; }

.reader-nav {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 18px 0 28px; margin-top: 24px; border-top: 1px solid rgba(128,128,128,.15);
}
.btn-reader-nav {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 34px; padding: 0 14px; font-size: 0.82rem; font-weight: 600;
  border-radius: 999px; border: 1px solid rgba(128,128,128,.28);
  color: var(--reader-text) !important; background: transparent; transition: all .15s ease;
  text-decoration: none !important; white-space: nowrap;
}
.btn-reader-nav:hover { background: rgba(128,128,128,.12); }
.btn-reader-nav.disabled { opacity: 0.35; pointer-events: none; }
.btn-reader-toc {
  background: rgba(128,128,128,.06); border-color: rgba(128,128,128,.2); font-weight: 500;
}
.btn-reader-primary {
  background: var(--primary); border-color: var(--primary); color: #fff !important;
}
.btn-reader-primary:hover { background: var(--primary-hover); }
@media (max-width: 560px) {
  .reader-nav { gap: 6px; padding: 14px 0 22px; margin-top: 16px; }
  .btn-reader-nav { height: 32px; padding: 0 10px; font-size: 0.78rem; }
}

/* Content protection (basic anti-copy) */
.protect.noselect { -webkit-user-select: none; user-select: none; }

/* ---------- Ad slot ---------- */
.ad-slot { margin: 24px 0; text-align: center; min-height: 90px; }

/* ---------- Paywall ---------- */
.paywall { display: flex; justify-content: center; padding: 20px 0 60px; }
.paywall-card {
  display: flex; gap: 24px; max-width: 760px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow-lg);
  flex-wrap: wrap;
}
.paywall-cover img { width: 160px; border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.paywall-body { flex: 1; min-width: 260px; }
.lock-icon { font-size: 2rem; }
.paywall-body h1 { font-size: 1.5rem; margin: 8px 0; }
.paywall-sub { color: var(--text-muted); margin: 0 0 12px; }
.paywall-note { margin-bottom: 18px; }
.paywall-price { display: flex; align-items: baseline; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.paywall-cta { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.paywall-secondary { display: flex; gap: 16px; font-size: .85rem; margin-bottom: 16px; flex-wrap: wrap; }
.paywall-perks { list-style: none; padding: 0; margin: 0; color: var(--text-muted); font-size: .9rem; }
.paywall-perks li { margin-bottom: 4px; }

.paywall-main-btn {
  font-size: 1.05rem;
  font-weight: 700;
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--primary) 0%, #4338ca 100%);
  color: #fff !important;
  text-align: center;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
  transition: transform .15s ease, box-shadow .15s ease;
  display: block;
}
.paywall-main-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.45);
}
.guest-soft-note {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.guest-soft-note a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
}
.paywall-trust {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.trust-badges-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.trust-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 4px 8px;
  height: 28px;
  box-sizing: border-box;
}
.trust-pill .badge-svg {
  height: 18px;
  width: auto;
  display: block;
}
.trust-guarantee {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: #475569;
}
.trust-guarantee .shield-icon {
  font-size: 1rem;
}

/* ---------- Auth / forms ---------- */
.auth-card {
  max-width: 420px; margin: 40px auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 1.5rem; margin: 0 0 4px; }
.auth-sub { color: var(--text-muted); margin: 0 0 20px; font-size: .95rem; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card label { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; font-weight: 600; color: var(--text); }
.form-input, .auth-card input[type="email"], .auth-card input[type="password"], .auth-card input[type="text"] {
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 8px);
  font-size: .95rem;
  font-weight: 400;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-input:focus, .auth-card input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.auth-card button[type="submit"] {
  height: 42px;
  border-radius: var(--radius-sm, 8px);
}
.auth-alt { text-align: center; font-size: .9rem; margin: 16px 0 0; }
.auth-legal { text-align: center; font-size: .78rem; color: var(--text-muted); margin: 14px 0 0; }
.field-error, .form-errors { color: var(--danger); font-size: .8rem; font-weight: 400; }

/* ---------- Legal ---------- */
.legal-page { max-width: 720px; margin: 20px auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; }
.legal-page h1 { margin-top: 0; }
.legal-page h2 { font-size: 1.1rem; margin-top: 24px; }

/* ---------- Footer ---------- */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); margin-top: 40px; }
.footer-inner { display: flex; flex-direction: column; gap: 10px; align-items: center; padding: 24px 16px; text-align: center; }
.footer-brand { font-weight: 800; }
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; font-size: .9rem; }
.footer-copy { color: var(--text-muted); font-size: .8rem; margin: 0; }

/* ---------- Cookie banner ---------- */
.cookie-banner {
  position: fixed; bottom: var(--tabbar-h); left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 20px; background: #1f2430; color: #e6e8ec; box-shadow: 0 -2px 12px rgba(0,0,0,.2);
}
.cookie-banner p { margin: 0; font-size: .88rem; max-width: 720px; }
.cookie-banner a { color: #a5b4fc; }
/* The banner uses `display: flex`, which would override the UA `[hidden]`
   rule; re-assert it so setting `banner.hidden = true` actually hides it. */
.cookie-banner[hidden] { display: none; }

/* ---------- Continue-reading toast (home) ---------- */
.resume-toast {
  position: fixed; left: 50%; z-index: 120;
  bottom: calc(var(--tabbar-h) + 20px);
  transform: translate(-50%, 20px);
  width: min(440px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 12px;
  padding: 12px 40px 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); box-shadow: 0 8px 30px rgba(0,0,0,.18);
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.resume-toast.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.resume-close {
  position: absolute; top: 4px; right: 8px; border: 0; background: transparent;
  font-size: 22px; line-height: 1; color: var(--text-muted); cursor: pointer; padding: 2px 6px;
}
.resume-close:hover { color: var(--text); }
.resume-body {
  display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0;
  text-decoration: none; color: inherit;
}
.resume-cover { flex: 0 0 auto; width: 44px; height: 60px; border-radius: 6px; overflow: hidden; background: #eee; }
.resume-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.resume-cover .cover-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.2rem; background: #6c63ff; color: #fff;
}
.resume-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.resume-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.resume-title { font-weight: 700; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resume-chapter { font-size: .82rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resume-cta { flex: 0 0 auto; font-weight: 700; color: #6c63ff; font-size: .9rem; }

/* ---------- Responsive ---------- */
/* Mobile: bottom tab bar + hamburger drawer; hide the marketing hero and the
   inline Library search (search lives in the drawer, hidden by default). */
@media (max-width: 719px) {
  :root { --tabbar-h: calc(56px + env(safe-area-inset-bottom, 0px)); }
  .primary-nav, .header-search, .account-nav { display: none; }
  /* Mobile: the tab bar already navigates, so drop the footer on every page */
  .site-footer { display: none; }
  .hamburger { display: inline-flex; }
  .tab-bar { display: flex; }
  .hero { display: none; }
  /* The hero is gone on mobile, so don't leave its slot as a wide gap */
  .filter-bar { margin-top: 0; }
  .filter-search-wrap { width: 100%; margin-bottom: 4px; }
  .filter-search-wrap input[type="search"] { width: 100%; height: 34px; font-size: 0.82rem; }
}
@media (min-width: 720px) {
  .detail-layout { flex-direction: row; }
  .footer-inner { flex-direction: row; justify-content: space-between; text-align: left; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
@media (max-width: 560px) {
  .header-search { display: none; }
  .nav-user { display: none; }
  /* Continue-reading toast: roomier tap target, drop the redundant CTA text
     (the whole card is already a tappable link). */
  .resume-toast { gap: 10px; padding: 10px 48px 10px 12px; }
  .resume-cover { width: 40px; height: 54px; }
  .resume-cta { display: none; }
  .resume-close {
    top: 50%; right: 4px; transform: translateY(-50%);
    width: 44px; height: 44px; padding: 0; font-size: 26px;
  }
}

/* ---------- Social login buttons ---------- */
.social-buttons { display: flex; flex-direction: column; gap: 10px; margin-bottom: 4px; }
.btn-social {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 42px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 8px);
  background: var(--surface);
  color: var(--text);
  font-size: .92rem;
  font-weight: 600;
  text-decoration: none !important;
  cursor: pointer;
  box-sizing: border-box;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn-social:hover { background: #f7f7fb; border-color: #cfcfe0; }
.btn-social svg { flex: 0 0 auto; width: 18px; height: 18px; }
.social-divider { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: .8rem; margin: 6px 0 16px; }
.social-divider::before, .social-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.checkbox-row { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 400 !important; }
.btn-link { background: none; border: none; color: var(--primary); text-decoration: underline; cursor: pointer; padding: 8px; font-size: .9rem; }
.auth-alt .muted, .muted { color: var(--text-muted); }
.small { font-size: .82rem; }

/* ---------- Guest notices / warnings ---------- */
.guest-warning {
  margin: 12px 0 0; padding: 10px 12px; font-size: .82rem; line-height: 1.5;
  color: #8a5a00; background: #fff8e6; border: 1px solid #ffe2a8; border-radius: var(--radius-sm);
}
.guest-notice {
  margin: 12px 0; padding: 10px 14px; font-size: .85rem; line-height: 1.5;
  color: #8a5a00; background: #fff8e6; border: 1px solid #ffe2a8; border-radius: var(--radius-sm);
}


/* ---------- Continuous Scroll Mode (Webtoon / Infinite Scroll) ---------- */
.mode-btn {
  font-size: .85rem;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all .15s ease;
}
.mode-btn:hover {
  background: #f1f5f9;
}
.mode-btn.active {
  background: var(--primary) !important;
  color: #fff !important;
  border-color: var(--primary) !important;
  font-weight: 700;
}
.reader.scroll-mode .reader-nav {
  display: none;
}
.scroll-sentinel {
  height: 20px;
  width: 100%;
  pointer-events: none;
}
.scroll-loading {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px 0;
  font-size: 0.95rem;
  color: var(--text-muted);
  text-align: center;
}
.scroll-loading.visible {
  display: flex;
}
.chapter.scroll-appended {
  margin-top: 50px;
  padding-top: 40px;
  border-top: 1px dashed var(--border);
}
.instream-paywall {
  margin: 48px auto 60px;
  max-width: 680px;
}
.instream-paywall .paywall-card {
  margin: 0;
  border: 1px solid rgba(79, 70, 229, 0.25);
  background: linear-gradient(180deg, var(--surface) 0%, rgba(79, 70, 229, 0.03) 100%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}
.scroll-end-badge {
  text-align: center;
  padding: 40px 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  letter-spacing: 0.05em;
}


@media (max-width: 560px) {
  /* Mobile clean 2-column grid when in grid mode */
  .book-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }
  .book-card {
    border-radius: 10px;
  }
  .book-meta {
    padding: 8px 9px 9px;
  }
  .book-title {
    font-size: 0.86rem;
    line-height: 1.28;
  }
  .book-author {
    font-size: 0.72rem;
    margin-bottom: 3px;
  }
  .book-category-pill {
    display: none;
  }
  .badge-status-overlay {
    top: 4px;
    left: 4px;
    font-size: 0.54rem;
    padding: 1px 5px;
    gap: 2.5px;
  }
  .badge-status-overlay::before {
    width: 3px;
    height: 3px;
  }

  /* Mobile list view: generous room for abstract & bottom row stats */
  html.view-list .book-card {
    min-height: 126px;
  }
  html.view-list .book-cover {
    flex: 0 0 90px;
    width: 90px;
  }
  html.view-list .book-meta {
    padding: 9px 11px 9px 12px;
  }
  html.view-list .book-title {
    font-size: 0.94rem;
    -webkit-line-clamp: 1;
  }
  html.view-list .book-author {
    font-size: 0.74rem;
    margin: 1px 0 4px;
  }
  html.view-list .book-abstract {
    font-size: 0.80rem;
    line-height: 1.42;
    -webkit-line-clamp: 2;
    margin: 0 0 6px;
  }
  html.view-list .book-meta-bottom {
    font-size: 0.72rem;
  }
}

/* ---------- Mobile Immersive Reader (Tomato Novel Mode < 720px) ---------- */
@media (max-width: 719px) {
  .reader-header {
    position: sticky; top: 0; left: 0; right: 0; z-index: 100;
    height: 48px; box-shadow: 0 1px 6px rgba(0,0,0,.04);
    transform: none !important; opacity: 1 !important; pointer-events: auto !important;
  }
  .reader-page.reader-hud-visible .reader-header {
    transform: translateY(0); opacity: 1; pointer-events: auto;
  }
  .reader-header-inner {
    height: 48px; padding: 0 8px;
  }
  .reader-header-title {
    font-size: 0.85rem; max-width: 55%;
  }

  /* Mobile bottom floating HUD */
  .reader-hud-bottom {
    display: block;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    background: var(--reader-bg); border-top: 1px solid rgba(128,128,128,.15);
    box-shadow: 0 -4px 18px rgba(0,0,0,.06);
    transform: translateY(100%); opacity: 0; pointer-events: none;
    transition: transform .26s cubic-bezier(0.16, 1, 0.3, 1), opacity .2s ease;
    padding-bottom: max(6px, env(safe-area-inset-bottom, 0px));
  }
  .reader-page.reader-hud-visible .reader-hud-bottom {
    transform: translateY(0); opacity: 1; pointer-events: auto;
  }
  .reader-hud-inner {
    max-width: 680px; margin: 0 auto; padding: 8px 12px 10px;
    display: flex; flex-direction: column; gap: 8px;
  }
  .reader-hud-progress {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    font-size: 0.8rem; color: var(--reader-text);
  }
  .hud-chapter-info { font-weight: 600; opacity: .85; font-size: 0.78rem; }
  .hud-nav-btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 4px 12px; border-radius: 999px; font-size: 0.78rem; font-weight: 600;
    border: 1px solid rgba(128,128,128,.25); color: var(--reader-text);
    text-decoration: none !important; background: rgba(128,128,128,.06);
  }
  .hud-nav-next { background: var(--primary); border-color: var(--primary); color: #fff !important; }

  .reader-hud-actions {
    display: flex; align-items: center; justify-content: space-around;
    padding-top: 6px; border-top: 1px dashed rgba(128,128,128,.15);
  }
  .hud-action-btn {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    background: none; border: none; color: var(--reader-text);
    font-size: 0.72rem; font-weight: 500; padding: 4px 10px; border-radius: 8px;
    cursor: pointer;
  }

  .reader-nav {
    gap: 6px; padding: 14px 0 22px; margin-top: 16px;
  }
  .btn-reader-nav {
    height: 32px; padding: 0 10px; font-size: 0.78rem;
  }
}

/* ---------- Segmented Control Pill Bar (Solution A) ---------- */
.reader-nav-wrap {
  margin: 36px 0 48px;
  display: flex;
  justify-content: center;
  padding: 0 4px;
}
.reader-segmented-nav {
  display: flex;
  align-items: stretch;
  width: 100%;
  max-width: 480px;
  height: 44px;
  background: rgba(128, 128, 128, 0.08);
  border: 1px solid rgba(128, 128, 128, 0.22);
  border-radius: 9999px;
  padding: 3px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  user-select: none;
  -webkit-user-select: none;
}
.seg-item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--reader-text);
  text-decoration: none !important;
  border-radius: 9999px;
  transition: all 0.16s ease;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.seg-item:hover {
  background: rgba(128, 128, 128, 0.14);
  color: var(--reader-text);
}
.seg-item:active {
  transform: scale(0.98);
}
.seg-item.disabled {
  opacity: 0.32;
  pointer-events: none;
}
.seg-divider {
  width: 1px;
  height: 18px;
  align-self: center;
  background: rgba(128, 128, 128, 0.22);
  flex-shrink: 0;
}
.seg-highlight {
  background: var(--primary);
  color: #fff !important;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}
.seg-highlight:hover {
  background: var(--primary-hover);
  color: #fff !important;
}

@media (max-width: 560px) {
  .reader-nav-wrap {
    margin: 26px 0 34px;
  }
  .reader-segmented-nav {
    height: 40px;
    padding: 2.5px;
    max-width: 100%;
  }
  .seg-item {
    font-size: 0.80rem;
    padding: 0 6px;
  }
  .seg-divider {
    height: 15px;
  }
}


/* In Grid view, hide truncated category pill to keep stats row 100% clean */
html.view-grid .book-card .book-category-pill,
html:not(.view-list) .book-card .book-category-pill {
  display: none !important;
}

/* In List view, show full category pill with comfortable room */
html.view-list .book-card .book-category-pill {
  display: inline-block !important;
}

@media (min-width: 720px) {
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); gap: 20px; }
}


/* ---------- Mobile Landing Layout & Micro-Typography Optimizations ---------- */
@media (max-width: 719px) {
  /* 1. Mobile Hero & Code Box: Clean, unified card layout */
  .hero-code-strip {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    padding: 12px 14px !important;
    margin: 8px 0 10px 0 !important;
    border-radius: 12px !important;
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03) !important;
  }
  .strip-brand {
    text-align: left !important;
    width: 100% !important;
    min-width: 0 !important;
  }
  .strip-title {
    font-size: 1.15rem !important; /* 18px */
    font-weight: 700 !important;
    line-height: 1.3 !important;
    margin: 0 0 3px 0 !important;
    letter-spacing: -0.015em !important;
    color: var(--text) !important;
    white-space: normal !important;
  }
  .strip-subtitle {
    font-size: 0.76rem !important; /* 12px */
    line-height: 1.35 !important;
    color: var(--text-muted) !important;
    margin: 0 !important;
    white-space: normal !important;
  }
  .strip-code-action {
    width: 100% !important;
    margin-top: 2px !important;
  }
  .strip-code-form {
    width: 100% !important;
    margin: 0 !important;
  }
  .strip-input-wrap {
    width: 100% !important;
    height: 38px !important;
    padding: 2px 3px 2px 10px !important;
    box-sizing: border-box !important;
    display: flex !important;
    align-items: center !important;
    background: var(--bg-soft) !important;
    border: 1px solid var(--border) !important;
    border-radius: 9999px !important;
  }
  .strip-icon {
    font-size: 0.92rem !important;
    margin-right: 6px !important;
    opacity: 0.8 !important;
  }
  .strip-input-wrap input {
    flex: 1 !important;
    min-width: 0 !important;
    width: auto !important;
    font-size: 0.80rem !important;
    font-weight: 500 !important;
    border: none !important;
    background: transparent !important;
    outline: none !important;
    color: var(--text) !important;
    text-transform: uppercase !important;
  }
  .strip-input-wrap input::placeholder {
    text-transform: none !important;
    color: var(--text-muted) !important;
    font-size: 0.76rem !important;
    font-weight: 400 !important;
  }
  .strip-submit-btn {
    flex-shrink: 0 !important;
    padding: 6px 12px !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    border-radius: 9999px !important;
    background: var(--primary) !important;
    color: #ffffff !important;
    border: none !important;
    cursor: pointer !important;
    white-space: nowrap !important;
  }

  /* 2. Mobile Filter Bar: Clean single row with zero messy wrapping */
  .filter-bar {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    margin: 8px 0 12px 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }
  .filter-form {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex: 1 !important;
    min-width: 0 !important;
  }
  .filter-form select[name="category"] {
    flex: 1 !important;
    min-width: 0 !important;
    height: 34px !important;
    padding: 4px 8px !important;
    font-size: 0.78rem !important;
    font-weight: 500 !important;
    border-radius: 8px !important;
    border: 1px solid var(--border) !important;
    background: var(--surface) !important;
    color: var(--text) !important;
  }
  .filter-form select[name="sort"] {
    flex: 0 0 92px !important;
    width: 92px !important;
    height: 34px !important;
    padding: 4px 6px !important;
    font-size: 0.78rem !important;
    font-weight: 500 !important;
    border-radius: 8px !important;
    border: 1px solid var(--border) !important;
    background: var(--surface) !important;
    color: var(--text) !important;
  }
  .view-toggle {
    flex: 0 0 auto !important;
    height: 42px !important;
    margin-left: 0 !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    border: 1px solid var(--border) !important;
    background: var(--surface) !important;
    display: inline-flex !important;
    align-items: center !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
  }
  .view-btn {
    width: 38px !important;
    height: 42px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0.95rem !important;
  }
  .filter-search-wrap input[type="search"] {
    font-size: 0.86rem !important;
    padding: 8px 36px 8px 12px !important;
  }
  /* Omit reads on mobile to prevent status pill truncation */
  .book-card .stat-reads {
    display: none !important;
  }
  .book-meta-right {
    flex: 0 0 auto !important;
    margin-left: auto !important;
  }
  .stat-status {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }
}

/* 3. Mobile List View: Refined font sizes for Ongoing / Completed & metadata */
@media (max-width: 560px) {
  html.view-list .book-meta-bottom {
    font-size: 0.68rem !important;
    padding-top: 3px !important;
    margin-top: auto !important;
  }
  html.view-list .stat-item {
    font-size: 0.68rem !important;
    color: var(--text-muted) !important;
  }
  html.view-list .stat-dot-num {
    font-weight: 600 !important;
    color: var(--text) !important;
  }
  html.view-list .book-meta-right {
    gap: 6px !important;
  }
  html.view-list .stat-status {
    font-size: 0.62rem !important; /* ~10px */
    padding: 1px 5px !important;
    border-radius: 3px !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
  }
  html.view-list .stat-status .status-dot {
    width: 3.5px !important;
    height: 3.5px !important;
  }
  html.view-list .book-category-pill {
    font-size: 0.60rem !important;
    padding: 1px 5px !important;
    border-radius: 3px !important;
    max-width: 90px !important;
  }
}


/* ---------- Book detail (Clean, Fluid, No-Blowout) ---------- */
.breadcrumb { font-size: 0.85rem; color: var(--text-muted); margin: 8px 0 18px; }
.detail-layout { display: flex; flex-direction: column; gap: 24px; }
.detail-cover { display: flex; justify-content: center; }
.detail-cover img, .detail-cover .cover-placeholder {
  width: 100%; max-width: 180px; border-radius: 12px; box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
  aspect-ratio: 3 / 4; object-fit: cover;
}
.detail-info { flex: 1; min-width: 0; }
.detail-title { font-size: clamp(1.35rem, 3.8vw, 2.1rem); margin: 0 0 6px; letter-spacing: -0.02em; font-weight: 700; color: var(--text); text-wrap: balance; }
.detail-author { color: var(--text-muted); margin: 0 0 12px; font-size: 0.9rem; font-weight: 500; }
.detail-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.detail-stats { list-style: none; display: flex; flex-wrap: wrap; gap: 14px; padding: 0; margin: 0 0 16px; color: var(--text-muted); font-size: 0.82rem; }
.detail-stats strong { color: var(--text); }
.detail-abstract { color: #334155; font-size: 0.88rem; line-height: 1.65; margin-bottom: 18px; text-wrap: pretty; }

/* Action / Purchase card */
.purchase-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.cta-row { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.cta-btn-main {
  width: 100%; text-align: center; white-space: normal !important; line-height: 1.35;
  min-height: 44px; padding: 10px 18px; font-size: 0.95rem; font-weight: 600; border-radius: 8px;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25); display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box;
}
.cta-btn-sub {
  width: 100%; text-align: center; white-space: normal !important; line-height: 1.35;
  min-height: 44px; padding: 10px 16px; font-size: 0.88rem; font-weight: 600; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box;
}
.guest-warning { margin-top: 10px; text-align: center; color: var(--text-muted); font-size: 0.8rem; line-height: 1.4; }
.guest-warning a { color: var(--primary); font-weight: 600; text-decoration: underline; }

/* Volumes Section */
.volumes-section { margin-top: 32px; margin-bottom: 32px; }
.section-header-row { margin-bottom: 14px; }
.section-title { font-size: 1.25rem; font-weight: 700; color: var(--text); margin: 0 0 4px; }
.section-subtitle { font-size: 0.82rem; color: var(--text-muted); margin: 0; }

.volume-cards-grid {
  display: grid; grid-template-columns: 1fr; gap: 12px;
}
.volume-card {
  border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
  background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  display: flex; flex-direction: column; justify-content: space-between;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.volume-card.is-owned { border-color: #10b981; background: #f0fdf4; }
.vol-badge-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.vol-badge {
  font-size: 0.72rem; font-weight: 700; color: #4f46e5; background: #eef2ff;
  padding: 2px 8px; border-radius: 6px; text-transform: uppercase; letter-spacing: 0.04em;
}
.vol-unlocked-badge {
  background: #dcfce7; color: #15803d; font-size: 0.72rem; font-weight: 700;
  padding: 2px 8px; border-radius: 6px;
}
.vol-title { font-size: 1rem; font-weight: 700; color: var(--text); margin: 0 0 4px; line-height: 1.35; }
.vol-meta { font-size: 0.8rem; color: var(--text-muted); margin: 0 0 12px; }
.vol-footer {
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--border); padding-top: 10px; margin-top: 8px; gap: 8px;
}
.vol-price { font-size: 1.15rem; font-weight: 800; color: var(--text); line-height: 1; }
.vol-actions { display: inline-flex; gap: 8px; align-items: center; }
.vol-actions .btn { height: 34px; padding: 0 12px; font-size: 0.82rem; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; }
.vol-buy-btn { white-space: nowrap !important; font-weight: 600; }

@media (min-width: 720px) {
  .detail-layout { flex-direction: row; gap: 32px; }
  .detail-cover { display: block; }
  .detail-cover img, .detail-cover .cover-placeholder { max-width: 240px; }
  .cta-row { flex-direction: row; align-items: center; width: auto; gap: 12px; }
  .cta-btn-main { width: auto; height: 44px; padding: 0 20px; }
  .cta-btn-sub { width: auto; height: 44px; padding: 0 18px; font-size: 0.90rem; }
  .guest-warning { text-align: left; }
  .volume-cards-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
}

/* Paywall Button Overflow Fix */
.paywall-main-btn {
  white-space: normal !important; text-align: center; line-height: 1.35;
  padding: 12px 18px !important; max-width: 100%; word-break: break-word;
}

/* Mobile Reader HUD Solid Background Fix */

@media (max-width: 719px) {
  .reader-header {
    background: var(--reader-paper, #ffffff) !important;
    border-bottom: 1px solid var(--reader-sheet-border, rgba(128,128,128,.18)) !important;
    box-shadow: 0 2px 12px rgba(0,0,0,.08) !important;
  }
  .reader-hud-bottom {
    background: var(--reader-paper, #ffffff) !important;
    border-top: 1px solid var(--reader-sheet-border, rgba(128,128,128,.18)) !important;
    box-shadow: 0 -4px 20px rgba(0,0,0,.08) !important;
  }
  .reader-paper {
    padding-top: 14px;
  }
}

/* === VOLUME VALUE CARD & MULTI-VOLUME NAV === */
.volume-value-card {
  background: rgba(79, 70, 229, 0.05);
  border: 1px solid rgba(79, 70, 229, 0.2);
  border-radius: var(--radius-sm, 8px);
  padding: 14px 18px;
  margin: 14px 0 18px;
  text-align: left;
}
.volume-value-card .vvc-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary, #4f46e5);
  background: rgba(79, 70, 229, 0.12);
  padding: 3px 8px;
  border-radius: 4px;
  margin-bottom: 8px;
}
.volume-value-card .vvc-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text, #111827);
  margin: 0 0 4px;
}
.volume-value-card .vvc-desc {
  font-size: 0.88rem;
  color: var(--text-muted, #64748b);
  line-height: 1.5;
  margin: 0;
}
.volume-value-card .vvc-highlight {
  color: var(--primary, #4f46e5);
  font-weight: 700;
}
.seg-locked-vol {
  border-color: rgba(79, 70, 229, 0.4) !important;
  font-weight: 700 !important;
}
.hud-nav-locked {
  background: rgba(79, 70, 229, 0.15) !important;
  color: var(--primary, #4f46e5) !important;
  font-weight: 700 !important;
}

/* ==========================================================================
   TWO-LEVEL TOC ACCORDION & MOBILE IMMERSIVE ENHANCEMENTS
   ========================================================================== */
.toc-accordion {
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}
.toc-vol-group {
  border-bottom: 1px solid rgba(128, 128, 128, 0.16);
}
.toc-vol-group.is-current-group {
  background: rgba(79, 70, 229, 0.04);
}
.toc-vol-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  color: var(--reader-text);
  font-family: inherit;
  transition: background 0.15s ease;
}
.toc-vol-header:hover {
  background: rgba(128, 128, 128, 0.08);
}
.toc-vol-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  transform: rotate(-90deg); /* points right when collapsed */
  color: var(--text-muted, #71717a);
  flex-shrink: 0;
}
.toc-vol-header.active .toc-vol-caret {
  transform: rotate(0deg); /* points down when expanded */
  color: var(--primary, #4f46e5);
}
.toc-vol-meta-block {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.toc-vol-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--reader-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toc-vol-header.active .toc-vol-name {
  color: var(--primary, #4f46e5);
}
.toc-vol-range {
  font-size: 0.76rem;
  color: var(--text-muted, #71717a);
}
.toc-vol-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  flex-shrink: 0;
}
.toc-vol-badge.unlocked {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}
.toc-vol-badge.price {
  background: rgba(79, 70, 229, 0.12);
  color: var(--primary, #4f46e5);
}
.toc-vol-chapters {
  list-style: none;
  margin: 0;
  padding: 0 0 4px 12px;
  background: rgba(128, 128, 128, 0.03);
  border-top: 1px dashed rgba(128, 128, 128, 0.12);
}
.toc-vol-chapters.is-collapsed {
  display: none !important;
}

/* Paywall Header Desktop/Mobile Visibility */
.paywall-mobile-header {
  display: none;
}
.paywall-desktop-header {
  display: block;
}

/* Hide breadcrumb on mobile reader (no Library and Volume display) */
@media (max-width: 768px) {
  .reader-breadcrumb,
  .reader-breadcrumb.hide-mobile {
    display: none !important;
  }
}

/* Mobile Paywall: Above-the-fold Immediate CTA Button */
@media (max-width: 719px) {
  .paywall {
    padding: 10px 12px 30px !important;
  }
  .paywall-card {
    padding: 16px 14px !important;
    gap: 12px !important;
    max-width: 100% !important;
    border-radius: 12px !important;
  }
  .paywall-cover {
    display: none !important; /* Hide giant cover on mobile to bring CTA above the fold */
  }
  .paywall-desktop-header {
    display: none !important;
  }
  .paywall-mobile-header {
    display: flex !important;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
  }
  .paywall-mobile-thumb {
    width: 48px;
    height: 64px;
    object-fit: cover;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    flex-shrink: 0;
  }
  .paywall-mobile-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .paywall-lock-pill {
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--primary, #4f46e5);
    background: rgba(79, 70, 229, 0.1);
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 4px;
    width: fit-content;
  }
  .paywall-mobile-title {
    font-size: 1.02rem;
    font-weight: 700;
    margin: 2px 0 0;
    line-height: 1.25;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .paywall-mobile-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
  }
  .volume-value-card {
    padding: 10px 12px !important;
    margin: 8px 0 10px !important;
    border-radius: 8px !important;
  }
  .volume-value-card .vvc-badge {
    font-size: 0.72rem !important;
    padding: 2px 6px !important;
    margin-bottom: 4px !important;
  }
  .volume-value-card .vvc-title {
    font-size: 0.94rem !important;
    margin-bottom: 3px !important;
  }
  .volume-value-card .vvc-desc {
    font-size: 0.78rem !important;
    line-height: 1.35 !important;
  }
  .paywall-price {
    margin-bottom: 10px !important;
    gap: 6px !important;
  }
  .paywall-price .price.big {
    font-size: 1.4rem !important;
  }
  .paywall-price .price-note {
    font-size: 0.75rem !important;
    line-height: 1.3 !important;
  }
  .paywall-cta {
    margin-bottom: 12px !important;
  }
  .paywall-main-btn {
    font-size: 0.98rem !important;
    padding: 13px 14px !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.4) !important;
  }
  .paywall-secondary {
    margin-bottom: 8px !important;
    font-size: 0.8rem !important;
    gap: 12px !important;
  }
  .paywall-trust {
    margin-top: 8px !important;
    padding-top: 8px !important;
    gap: 6px !important;
  }
  .trust-guarantee {
    font-size: 0.74rem !important;
  }
}

/* TOC Drawer Width & Full Title Wrapping Enhancement */
.reader-toc {
  width: min(460px, 92vw) !important;
}
.toc-vol-name {
  white-space: normal !important;
  line-height: 1.35 !important;
  word-break: break-word !important;
  overflow: visible !important;
  text-overflow: clip !important;
}
.toc-name {
  flex: 1 !important;
  min-width: 0 !important;
  font-size: 0.88rem !important;
  line-height: 1.4 !important;
  white-space: normal !important;
  display: block !important;
  overflow: visible !important;
  text-overflow: clip !important;
  word-break: break-word !important;
}
.toc-item {
  align-items: flex-start !important;
  padding: 10px 16px !important;
}
.toc-idx {
  padding-top: 1px !important;
  flex-shrink: 0 !important;
}
.toc-lock {
  padding-top: 2px !important;
  flex-shrink: 0 !important;
}
.ch-title {
  white-space: normal !important;
  line-height: 1.35 !important;
  display: block !important;
  overflow: visible !important;
  text-overflow: clip !important;
  word-break: break-word !important;
}
.ch-flag.unlocked {
  color: #10b981 !important;
  font-size: 0.75rem !important;
  font-weight: 600 !important;
}

/* --- Novel Update Capsule Badge (First-Principles Landing / Library UI) --- */
.book-update-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3.5px;
  padding: 2px 7.5px;
  font-size: 11px;
  line-height: 14px;
  font-weight: 600;
  letter-spacing: 0.015em;
  color: #ffffff;
  background: #7c3aed;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 9999px;
  box-shadow: 0 2px 6px rgba(124, 58, 237, 0.38), 0 1px 2px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  white-space: nowrap;
  user-select: none;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.book-update-badge .badge-dot {
  width: 4px;
  height: 4px;
  background-color: #ffffff;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .book-update-badge {
    top: 5px;
    right: 5px;
    padding: 1.5px 6.5px;
    font-size: 10px;
    line-height: 13px;
  }
  .book-update-badge .badge-dot {
    width: 3.5px;
    height: 3.5px;
  }
}

html.view-list .book-update-badge {
  top: 4px;
  right: 4px;
  padding: 1px 5.5px;
  font-size: 9.5px;
  line-height: 12px;
}
html.view-list .book-update-badge .badge-dot {
  width: 3px;
  height: 3px;
}

/* Recent Tab Unread Pill */
.recent-unread-pill {
  display: inline-flex;
  align-items: center;
  gap: 3.5px;
  padding: 1.5px 7px;
  font-size: 10.5px;
  font-weight: 600;
  color: #ffffff;
  background: #7c3aed;
  border-radius: 9999px;
  line-height: 14px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(124, 58, 237, 0.25);
}
.recent-unread-pill .badge-dot {
  width: 3.5px;
  height: 3.5px;
  background: #ffffff;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* Explicitly hide deprecated reader floating dock and bottom HUD */
.reader-floating-dock,
.reader-hud-bottom {
  display: none !important;
}

/* ---------- Centered Reader Layout (Golden Ratio Reading Column) ---------- */
.reader-main {
  width: 100% !important;
  max-width: 720px !important;
  margin: 0 auto !important;
  padding: 0 16px !important;
  box-sizing: border-box !important;
}

.reader {
  width: 100% !important;
  max-width: 720px !important;
  margin: 0 auto !important;
  box-sizing: border-box !important;
}

.reader-header-inner {
  max-width: 720px !important;
  margin: 0 auto !important;
  padding: 0 16px !important;
  box-sizing: border-box !important;
}

.chapter {
  padding: 24px 0 36px !important;
}

.chapter-head {
  margin-bottom: 24px !important;
  text-align: left !important;
}

.chapter-order {
  display: block !important;
  color: var(--reader-text) !important;
  opacity: .65 !important;
  font-size: 0.85rem !important;
  text-transform: uppercase !important;
  letter-spacing: .06em !important;
  font-weight: 600 !important;
  margin-bottom: 4px !important;
}

.chapter-title {
  font-size: 1.85rem !important;
  line-height: 1.25 !important;
  letter-spacing: -.015em !important;
  color: var(--reader-text) !important;
  font-weight: 700 !important;
  margin: 4px 0 0 !important;
}

.chapter-content {
  font-size: var(--reader-font, 1.125rem) !important;
  line-height: 1.85 !important;
  color: var(--reader-text) !important;
  font-family: Georgia, "Times New Roman", serif !important;
  letter-spacing: 0.01em !important;
  word-break: break-word !important;
}

.chapter-content p {
  margin: 0 0 1.25em !important;
  text-align: left !important;
}

/* Home Clean Single Search Bar */
.filter-bar {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 16px !important;
  margin: 16px 0 24px !important;
}

.filter-form {
  flex: 1 !important;
  max-width: 580px !important;
}

.filter-search-wrap {
  width: 100% !important;
}

/* Refined Single Search Bar Styling (No categories/sorts) */
.filter-bar {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 16px !important;
  margin: 18px 0 24px !important;
}

.filter-form {
  flex: 1 !important;
  min-width: 0 !important;
  max-width: 540px !important;
  display: flex !important;
  align-items: center !important;
}

.filter-search-wrap {
  position: relative !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 540px !important;
  display: flex !important;
  align-items: center !important;
}

.filter-search-wrap input[type="search"] {
  width: 100% !important;
  min-width: 0 !important;
  height: 42px !important;
  padding: 8px 42px 8px 16px !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  font-size: 0.92rem !important;
  background: var(--surface) !important;
  color: var(--text) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
  outline: none !important;
  transition: border-color 0.15s ease, box-shadow 0.15s ease !important;
}

.filter-search-wrap input[type="search"]:focus {
  border-color: #7c3aed !important;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12) !important;
}

.filter-search-wrap button[type="submit"] {
  position: absolute !important;
  right: 12px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  background: transparent !important;
  border: none !important;
  color: #6b7280 !important;
  font-size: 1.15rem !important;
  cursor: pointer !important;
  padding: 4px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.filter-search-wrap button[type="submit"]:hover {
  color: #7c3aed !important;
}

/* Guarantee side-by-side 42px height for Search & View-Toggle on mobile */
@media (max-width: 719px) {
  .filter-bar {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    margin: 10px 0 16px 0 !important;
    width: 100% !important;
  }
  .filter-form {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    display: flex !important;
    align-items: center !important;
    margin: 0 !important;
  }
  .filter-search-wrap {
    width: 100% !important;
    min-width: 0 !important;
    display: flex !important;
    align-items: center !important;
  }
  .filter-search-wrap input[type="search"] {
    width: 100% !important;
    min-width: 0 !important;
    height: 42px !important;
    padding: 6px 36px 6px 12px !important;
    font-size: 0.84rem !important;
    border-radius: 8px !important;
  }
  .view-toggle {
    flex: 0 0 auto !important;
    height: 42px !important;
    margin: 0 !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    border: 1px solid var(--border) !important;
    background: var(--surface) !important;
    display: inline-flex !important;
    align-items: center !important;
  }
  .view-btn {
    width: 38px !important;
    height: 42px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0.95rem !important;
  }
  /* Position 2: Omit read count on mobile so status pill is never clipped */
  .book-card .stat-reads {
    display: none !important;
  }
  .stat-status {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }
}


/* Me page preference alignment rules */
.pref-row {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.mode-toggle-group, .view-toggle-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-pref-mode, .btn-pref-view {
  height: 32px;
  padding: 0 12px;
  font-size: 0.80rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-sizing: border-box;
  transition: all 0.15s ease;
}
.btn-pref-mode.active, .btn-pref-view.active {
  background: var(--primary) !important;
  color: #fff !important;
  border-color: var(--primary) !important;
}
.theme-swatches {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.theme-swatches .swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #e2e8f0;
  cursor: pointer;
  padding: 0;
  box-sizing: border-box;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.theme-swatches .swatch:hover {
  transform: scale(1.1);
}
.theme-swatches .swatch.active {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 2px var(--primary) !important;
}
.me-auth-actions {
  display: flex;
  gap: 10px;
  width: 100%;
}
.me-auth-actions .btn {
  height: 42px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}
