/* ==========================================================================
   泰语小说阅读平台 - 前台样式
   视觉参考 hinovel.com：白底、青绿主色、扁平卡片、无重阴影
   ========================================================================== */

/* Noto Sans Thai 自托管子集（可变字重 100-900），按 unicode-range 分段加载，
   泰语正文只命中 thai 子集，约 27KB。中文字形回退系统字体，不再拉取 SC webfont。 */
@font-face {
  font-family: "Noto Sans Thai";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/noto-sans-thai-thai.woff2") format("woff2");
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: "Noto Sans Thai";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/noto-sans-thai-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Noto Sans Thai";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/noto-sans-thai-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #ffffff;
  --bg-soft: #f7f8f9;
  --surface: #ffffff;
  --surface-2: #f4f6f7;
  --text: #15161a;
  --muted: #65676e;
  --border: #efefef;
  --border-strong: #e2e4e7;
  --accent: #00c3a9;
  --accent-ink: #ffffff;
  --accent-soft: #e6f9f6;
  --gold: #d98e12;
  --gold-soft: #fff5e2;
  --danger: #d64545;
  --shadow: 0 1px 2px rgba(21, 22, 26, 0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --font-ui: "Noto Sans Thai", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --reader-size: 17px;
}

html[data-theme="dark"] {
  --bg: #0f1115;
  --bg-soft: #14171c;
  --surface: #171a1e;
  --surface-2: #1e2227;
  --text: #e7e9ec;
  --muted: #9aa0a8;
  --border: #262a2f;
  --border-strong: #343940;
  --accent: #2ed3bc;
  --accent-ink: #06231f;
  --accent-soft: #173430;
  --gold: #e9b055;
  --gold-soft: #352c1c;
  --danger: #ef7d7d;
  --shadow: none;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

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

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

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

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.page-shell {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px 96px;
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 10px max(16px, calc((100vw - 720px) / 2));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 15px;
  font-weight: 700;
}

.brand-th {
  font-style: normal;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted, #8a8a94);
  margin-left: 6px;
  letter-spacing: 0;
}

.topbar-spacer {
  flex: 1;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 6px;
}

.topnav a {
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.topnav a:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

@media (max-width: 640px) {
  .topnav {
    display: none;
  }
}

.coin-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold);
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}

.coin-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
}

.user-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.user-link strong {
  color: var(--text);
  font-weight: 600;
}

/* ---------- 首页 ---------- */

.hero {
  padding: 28px 0 4px;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.hero-title {
  margin: 10px 0 8px;
  font-size: 26px;
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.hero-sub {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.search {
  position: relative;
  margin: 20px 0 14px;
}

.search input {
  width: 100%;
  height: 46px;
  padding: 0 16px 0 44px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--surface-2);
  outline: none;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.search input::placeholder {
  color: var(--muted);
}

.search input:focus {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.search svg {
  position: absolute;
  top: 50%;
  left: 16px;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  color: var(--muted);
}

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 14px;
  scrollbar-width: none;
}

.chip-row::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: none;
  height: 34px;
  padding: 0 15px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

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

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 26px 0 12px;
}

.section-head h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.section-head span {
  color: var(--muted);
  font-size: 12px;
}

/* ---------- 小说卡片 ---------- */

.novel-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rank-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rank-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

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

.rank-no {
  display: grid;
  place-items: center;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.rank-no.top {
  background: var(--accent-soft);
  color: var(--accent);
}

.rank-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.rank-main strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-main small {
  color: var(--muted);
  font-size: 12px;
}

#categories,
#ranking {
  scroll-margin-top: 76px;
}

.novel-card {
  display: flex;
  gap: 14px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.novel-card:hover {
  border-color: var(--border-strong);
}

.novel-card:active {
  transform: scale(0.995);
  border-color: var(--accent);
}

.cover {
  position: relative;
  flex: none;
  width: 82px;
  height: 123px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: linear-gradient(160deg, var(--accent-soft), var(--surface-2));
  color: var(--muted);
  font-size: 12px;
}

/* 封面统一 2:3（生成与上传均为 600×900），contain 保证任何比例都不会被裁切 */
.cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--surface-2);
}

.cover-fallback {
  display: grid;
  place-items: center;
  height: 100%;
  padding: 8px;
  text-align: center;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.35;
  word-break: break-word;
}

.novel-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  gap: 5px;
  padding: 2px 0;
}

.novel-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.novel-title-cn {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.novel-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  flex-wrap: wrap;
}

/* 列表卡片简介：两行截断，避免长简介撑高卡片 */
.novel-desc {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.tag {
  display: inline-flex;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
}

.novel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.status-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.status-dot.ongoing::before {
  background: var(--gold);
}

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 42px;
  padding: 0 18px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-gold {
  border-color: var(--gold);
  background: var(--gold);
  color: #ffffff;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
}

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

.btn-block {
  width: 100%;
}

.btn-sm {
  height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

/* ---------- 详情页 ---------- */

.detail-hero {
  display: flex;
  gap: 16px;
  padding: 24px 0 14px;
}

.detail-hero .cover {
  width: 112px;
  height: 168px;
  border-radius: 12px;
}

.detail-title {
  margin: 4px 0 2px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.detail-sub {
  color: var(--muted);
  font-size: 13px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 0;
}

.meta-cell {
  padding: 12px 8px;
  border-radius: var(--radius);
  background: var(--surface-2);
  text-align: center;
}

.meta-cell strong {
  display: block;
  font-size: 17px;
  font-weight: 700;
}

.meta-cell span {
  color: var(--muted);
  font-size: 11px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
  margin: 14px 0;
}

.panel h3 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
}

.panel p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.85;
  white-space: pre-wrap;
}

.detail-actions {
  display: flex;
  gap: 10px;
  margin: 18px 0 4px;
}

.detail-actions .btn {
  flex: 1;
}

.chapter-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 24px 0 10px;
}

.chapter-toolbar h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
}

.chapter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.chapter-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.chapter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  transition: background 0.15s ease;
}

.chapter-row:hover {
  background: var(--surface-2);
}

.chapter-row:last-child {
  border-bottom: none;
}

.chapter-row.locked {
  color: var(--muted);
}

.chapter-no {
  flex: none;
  width: 62px;
  color: var(--muted);
  font-size: 12px;
}

.chapter-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-badge {
  flex: none;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
}

.chapter-badge.free {
  background: var(--accent-soft);
  color: var(--accent);
}

.chapter-badge.price {
  background: var(--gold-soft);
  color: var(--gold);
}

/* ---------- 阅读器 ---------- */

.reader-page {
  background: var(--bg);
}

.reader-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 8px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

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

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.reader-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}

.reader-title small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.reader-shell {
  max-width: 680px;
  margin: 0 auto;
  padding: 28px 20px 120px;
}

.reader-heading {
  margin: 4px 0 4px;
  font-size: 22px;
  line-height: 1.5;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.reader-heading-cn {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 20px;
}

.reader-content {
  font-size: var(--reader-size);
  line-height: 1.95;
  color: var(--text);
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.reader-content p {
  margin: 0 0 1.05em;
  text-indent: 0;
}

.reader-tip {
  margin: 28px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.reader-locked {
  position: relative;
  margin-top: -90px;
  padding: 110px 18px 22px;
  border-radius: var(--radius);
  background: linear-gradient(to bottom, transparent, var(--bg) 46%);
  text-align: center;
}

.lock-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.reader-locked h3 {
  margin: 14px 0 6px;
  font-size: 18px;
}

.reader-locked p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.reader-nav {
  display: flex;
  gap: 10px;
  margin-top: 30px;
}

.reader-nav .btn {
  flex: 1;
}

.reader-settings {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin: 0 0 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.reader-settings .label {
  color: var(--muted);
  font-size: 12px;
  margin-right: 2px;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-2);
}

.seg button {
  min-width: 38px;
  height: 30px;
  padding: 0 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.seg button.active {
  background: var(--accent);
  color: var(--accent-ink);
}

/* ---------- 底部导航 ---------- */

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 45;
  display: flex;
  width: 100%;
  max-width: 720px;
  transform: translateX(-50%);
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}

.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  border-radius: 10px;
  color: var(--muted);
  font-size: 11px;
}

.bottom-nav a svg {
  width: 21px;
  height: 21px;
}

.bottom-nav a.active {
  color: var(--accent);
  font-weight: 600;
}

/* ---------- 书架 ---------- */

.shelf-item {
  display: flex;
  gap: 14px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.shelf-item .cover {
  width: 72px;
  height: 108px;
}

.progress-track {
  height: 4px;
  margin-top: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.shelf-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

/* ---------- 空状态 / 加载 ---------- */

.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.empty strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 16px;
}

.skeleton {
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.2s infinite linear;
}

@keyframes shimmer {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ---------- 弹窗 ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 17, 21, 0.5);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 460px;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0;
  background: var(--surface);
  box-shadow: 0 -10px 40px rgba(15, 17, 21, 0.18);
  animation: sheet-up 0.24s ease;
}

@media (min-width: 560px) {
  .modal {
    align-items: center;
    padding: 20px;
  }

  .modal-card {
    border-radius: 20px;
  }
}

@keyframes sheet-up {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-card h3 {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 700;
}

.modal-card p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.modal-actions .btn {
  flex: 1;
}

/* ---------- 表单 ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.7;
}

.form-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  font-size: 13px;
}

/* ---------- 登录页 ---------- */

.auth-wrap {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 28px 22px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 2px 16px rgba(21, 22, 26, 0.05);
}

.auth-card .brand {
  justify-content: center;
  margin-bottom: 6px;
}

.auth-card .hero-sub {
  text-align: center;
  margin-bottom: 20px;
}

.tabs {
  display: flex;
  padding: 4px;
  margin-bottom: 18px;
  border-radius: 999px;
  background: var(--surface-2);
}

.tabs button {
  flex: 1;
  height: 36px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.tabs button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(21, 22, 26, 0.08);
}

.auth-foot {
  margin-top: 14px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.auth-foot a {
  color: var(--accent);
  font-weight: 600;
}

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

#toast-host {
  position: fixed;
  top: 14px;
  left: 50%;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(92vw, 420px);
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  padding: 11px 14px;
  border-radius: 10px;
  background: #15161a;
  color: #ffffff;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 10px 28px rgba(15, 17, 21, 0.18);
  animation: toast-in 0.2s ease;
}

.toast.error {
  background: #b93a3a;
}

.toast.success {
  background: #00a08b;
}

@keyframes toast-in {
  from {
    transform: translateY(-8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ---------- 工具类 ---------- */

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

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

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

.mt-8 {
  margin-top: 8px;
}

.mt-16 {
  margin-top: 16px;
}

.hidden {
  display: none !important;
}

@media (min-width: 900px) {
  .page-shell {
    max-width: 880px;
  }

  .novel-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

/* ==========================================================================
   社区互动 / 发现 / 通知 / PWA 补充样式
   ========================================================================== */

:root {
  --reader-line-height: 1.9;
  --reader-font: "Noto Sans Thai", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC", system-ui, sans-serif;
}

.reader-content {
  font-family: var(--reader-font);
  line-height: var(--reader-line-height);
}

.reader-content p {
  margin: 0 0 0.9em;
  padding: 2px 4px;
  border-radius: 6px;
  transition: background 0.15s ease;
}

.reader-content p:hover {
  background: var(--surface-2);
}

.reader-content p.para-active {
  background: var(--accent-soft);
}

.reader-watermark {
  position: fixed;
  right: 10px;
  bottom: 12px;
  z-index: 5;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.02em;
  pointer-events: none;
  opacity: 0.7;
}

html[data-theme="dark"] .reader-watermark {
  background: rgba(255, 255, 255, 0.06);
}

/* 榜单切换 */
.rank-tabs,
.seg-tabs {
  display: flex;
  gap: 6px;
  margin: 0 0 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.rank-tabs::-webkit-scrollbar,
.seg-tabs::-webkit-scrollbar {
  display: none;
}

.rank-tabs button,
.seg-tabs button {
  flex: none;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.rank-tabs button.active,
.seg-tabs button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* 搜索联想 */
.search-suggest {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(21, 22, 26, 0.12);
}

.suggest-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
}

.suggest-item:hover {
  background: var(--surface-2);
}

.suggest-item .s-type {
  flex: none;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
}

/* 标签云 */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

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

.tag-link i {
  font-style: normal;
  color: var(--muted);
  font-size: 10px;
}

/* 关注按钮 */
.follow-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* 评分 */
.star-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.stars {
  display: inline-flex;
  gap: 1px;
  color: var(--gold);
  font-size: 15px;
  line-height: 1;
}

.star-row {
  display: inline-flex;
  gap: 4px;
  font-size: 28px;
  line-height: 1;
  color: var(--border-strong);
  cursor: pointer;
  user-select: none;
}

.star-row span.on {
  color: var(--gold);
}

.review-item {
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.review-item:first-child {
  border-top: 0;
}

.review-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.review-head strong {
  color: var(--text);
  font-size: 13px;
}

.review-body {
  margin: 6px 0 0;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.review-form textarea,
.comment-form textarea {
  width: 100%;
  min-height: 84px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  outline: none;
}

.review-form textarea:focus,
.comment-form textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* 评论 */
.comment-block {
  margin-top: 26px;
}

.comment-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.comment-form .hint {
  color: var(--muted);
  font-size: 12px;
}

.comment-item {
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.comment-head {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.comment-head strong {
  color: var(--text);
  font-size: 13px;
}

.comment-para {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  font-size: 10px;
}

.comment-body {
  margin: 6px 0;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.comment-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
}

.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}

.like-btn.liked {
  color: var(--accent);
  font-weight: 600;
}

.comment-replies {
  margin: 8px 0 0 18px;
  padding-left: 10px;
  border-left: 2px solid var(--border);
}

/* 通知 */
.notif-item {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.notif-item.unread {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.notif-item h4 {
  margin: 0 0 2px;
  font-size: 14px;
}

.notif-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.notif-dot {
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.badge-count {
  display: inline-grid;
  place-items: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

.icon-btn .badge-count {
  position: absolute;
  top: 2px;
  right: 2px;
}

/* 相关推荐 */
.related-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: none;
}

.related-scroll::-webkit-scrollbar {
  display: none;
}

.related-card {
  flex: none;
  width: 120px;
}

.related-card .cover {
  width: 120px;
  height: 180px;
}

.related-card strong {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 分享与页脚 */
.share-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.share-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: #06c755;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.site-footer {
  margin-top: 36px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.site-footer a:hover {
  color: var(--accent);
}

/* 后台看板 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.stat-cell {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.stat-cell strong {
  display: block;
  font-size: 20px;
}

.stat-cell span {
  color: var(--muted);
  font-size: 12px;
}

/* 空态与提示 */
.mt-8 {
  margin-top: 8px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.reader-content p[data-count]::after {
  content: attr(data-count);
  display: inline-grid;
  place-items: center;
  min-width: 15px;
  height: 15px;
  margin-left: 6px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 9px;
  font-weight: 700;
  vertical-align: super;
}

.reader-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin: 0 0 4px;
}

.icon-btn.active {
  color: var(--accent);
  background: var(--accent-soft);
}

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

.author-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 24px 0 6px;
}

.author-avatar {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 24px;
  font-weight: 700;
}

.author-hero h1 {
  margin: 0;
  font-size: 22px;
}

.chapter-date {
  color: var(--muted);
  font-size: 11px;
}

.tag-link.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.reader-settings .seg button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* 首页继续阅读卡片 */
.continue-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
  text-decoration: none;
  color: inherit;
}

.continue-cover {
  width: 44px;
  height: 66px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--accent-soft);
  flex-shrink: 0;
}

.continue-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.continue-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
}

.continue-info strong {
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.continue-meta {
  font-size: 12px;
  color: var(--muted);
}

.continue-go {
  color: var(--accent);
  font-size: 20px;
  flex-shrink: 0;
}

/* 阅读历史列表复用书架样式，按钮允许换行 */
.shelf-item .shelf-actions {
  flex-wrap: wrap;
}

.reader-mode-label {
  margin-left: auto;
}

.reader-offline {
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--text);
  font-size: 13px;
  line-height: 1.7;
}

@media (max-width: 640px) {
  .reader-topbar {
    padding: calc(8px + env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left));
  }

  .reader-topbar .icon-btn,
  .reader-actions .icon-btn {
    width: 44px;
    min-width: 44px;
    height: 44px;
  }

  .reader-shell {
    padding: 20px 16px calc(156px + env(safe-area-inset-bottom));
  }

  .reader-heading,
  .reader-content {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .reader-actions {
    min-height: 44px;
  }

  .reader-actions .icon-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  .reader-settings {
    display: block;
    max-height: calc(100vh - 96px);
    max-height: calc(100dvh - 96px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 14px;
  }

  .reader-settings .label {
    display: block;
    margin: 14px 0 6px;
    font-size: 13px;
  }

  .reader-settings .label:first-child {
    margin-top: 0;
  }

  .reader-settings .reader-mode-label {
    margin-left: 0;
  }

  .reader-settings .seg {
    display: flex;
    width: 100%;
    min-height: 46px;
    border-radius: 12px;
  }

  .reader-settings .seg button {
    flex: 1;
    min-width: 0;
    height: 44px;
    font-size: 16px;
  }

  .reader-settings #font-size-label {
    display: block;
    margin-top: 6px;
  }

  .reader-nav {
    position: fixed;
    left: 50%;
    right: auto;
    bottom: 0;
    z-index: 50;
    width: 100%;
    max-width: 680px;
    margin: 0;
    padding: 8px max(12px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    transform: translateX(-50%);
    background: var(--surface);
    border-top: 1px solid var(--border);
  }

  .reader-nav .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 48px;
    padding: 10px 8px;
    white-space: nowrap;
    touch-action: manipulation;
  }

  .comment-form textarea {
    font-size: 16px;
  }
}

/* ---------- 首页榜单三栏（参考目标站：简单、留白、无大图） ---------- */

.rank-board {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.rank-col {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.rank-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 700;
}

.rank-col-head em {
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  opacity: 0.65;
}

.rank-col.mint .rank-col-head {
  background: linear-gradient(90deg, #e7faf6, #f7fdfc);
  color: #0a8f7c;
}

.rank-col.blue .rank-col-head {
  background: linear-gradient(90deg, #eaf1ff, #f8faff);
  color: #3f63c8;
}

.rank-col.amber .rank-col-head {
  background: linear-gradient(90deg, #fff4e4, #fffbf5);
  color: #b4740c;
}

html[data-theme="dark"] .rank-col.mint .rank-col-head {
  background: #12302c;
  color: #5fe0cb;
}

html[data-theme="dark"] .rank-col.blue .rank-col-head {
  background: #1b2438;
  color: #9db4ea;
}

html[data-theme="dark"] .rank-col.amber .rank-col-head {
  background: #33281a;
  color: #e6b76b;
}

.rank-col-body {
  padding: 6px 6px 8px;
}

.rank-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
}

.rank-row:hover {
  background: var(--surface-2);
}

.rank-badge {
  flex: none;
  width: 18px;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  font-style: normal;
  color: var(--muted);
}

.rank-badge.top-1 {
  color: #e2453a;
}

.rank-badge.top-2 {
  color: #f0871f;
}

.rank-badge.top-3 {
  color: #d9a400;
}

.rank-thumb {
  position: relative;
  flex: none;
  width: 44px;
  height: 66px;
  overflow: hidden;
  border-radius: 6px;
  background: linear-gradient(160deg, var(--accent-soft), var(--surface-2));
}

.rank-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--surface-2);
}

.rank-thumb-fallback {
  display: grid;
  place-items: center;
  height: 100%;
  padding: 3px;
  overflow: hidden;
  color: var(--accent);
  font-size: 9px;
  line-height: 1.25;
  text-align: center;
  word-break: break-word;
}

.rank-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}

.rank-info strong {
  display: -webkit-box;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.rank-desc {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.rank-info small {
  color: var(--muted);
  font-size: 11px;
}

.rank-empty {
  padding: 18px 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

@media (min-width: 900px) {
  .page-shell {
    max-width: 1080px;
  }

  .topbar {
    padding-left: max(16px, calc((100vw - 1080px) / 2));
    padding-right: max(16px, calc((100vw - 1080px) / 2));
  }

  .rank-board {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }
}

@media (min-width: 1000px) {
  .novel-list {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* 桌面端与目标站一致：顶栏导航足够，隐藏底部悬浮导航，避免遮挡内容 */
@media (min-width: 900px) {
  .bottom-nav {
    display: none;
  }

  .page-shell {
    padding-bottom: 48px;
  }
}

/* ---------- 首页排行区 / 排行榜页 / 分类页 ---------- */

.home-rank-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

@media (min-width: 900px) {
  .home-rank-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px 16px;
  }
}

.rank-list-page {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rank-list-page .rank-row {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.rank-list-page .rank-row:hover {
  background: var(--surface);
  border-color: var(--accent);
}

.rank-list-page .rank-thumb {
  width: 56px;
  height: 74px;
}

.rank-list-page .rank-info strong {
  font-size: 14px;
}

.category-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 2px 0 4px;
}

/* ---------- 充值页 ---------- */

.topup-balance {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 4px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 14px;
}

.topup-balance strong {
  font-size: 18px;
  color: var(--gold);
}

.topup-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 12px 0 4px;
}

@media (min-width: 900px) {
  .topup-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.topup-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.topup-card strong {
  font-size: 22px;
  line-height: 1.2;
}

.topup-card > span {
  color: var(--muted);
  font-size: 12px;
}

.topup-card .btn {
  margin-top: 8px;
}

.topup-card > .pack-tag {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.pack-price {
  font-style: normal;
  font-size: 15px;
  font-weight: 700;
}

.topup-card > .pack-sub {
  text-align: center;
  font-size: 11px;
  line-height: 1.5;
}

.topup-steps {
  margin: 8px 0 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.9;
}

.contact-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 10px;
}

@media (min-width: 700px) {
  .contact-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.contact-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.qr-slot {
  display: grid;
  place-items: center;
  min-height: 120px;
  padding: 8px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  background: var(--surface-2);
}

.qr-slot img {
  width: 150px;
  height: 150px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
}


