/* ===== 子夜談 · 設計系統（配色與尺度源自建站策劃書 §5） ===== */

:root {
  --bg-page: #F8F7F2;
  --bg-card: #FFFFFF;
  --bg-elevated: #FFFFFF;
  --text-primary: #2C2C2A;
  --text-secondary: #5F5E5A;
  --text-tertiary: #888780;
  --border: #E6E3D9;
  --accent: #6D28D9;
  --accent-hover: #5B21B6;
  --accent-soft: rgba(109, 40, 217, 0.12);
  --reading-font-size: 18px;
  --reading-width: 700px;
  --font-ui: -apple-system, "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans SC", sans-serif;
  --font-reading: "Source Han Serif SC", "Noto Serif SC", Georgia, "Songti SC", "SimSun", serif;
}

[data-theme="dark"] {
  --bg-page: #1A1A18;
  --bg-card: #242422;
  --bg-elevated: #2C2C2A;
  --text-primary: #E8E6DF;
  --text-secondary: #B4B2A9;
  --text-tertiary: #888780;
  --border: #3A3A37;
  --accent: #A78BFA;
  --accent-hover: #C4B5FD;
  --accent-soft: rgba(167, 139, 250, 0.14);
}

[data-fontsize="small"] { --reading-font-size: 15px; }
[data-fontsize="large"] { --reading-font-size: 22px; }

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-ui);
  line-height: 1.7;
  transition: background 0.25s ease, color 0.25s ease;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
/* 鍵盤焦點可見框（無障礙：WCAG 2.4.7） */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

main { display: block; }

/* ===== 顶栏 ===== */
.site-header {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-inner {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text-primary); }
.brand:hover { color: var(--text-primary); }
.brand-mark {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg-elevated);
  font-size: 14px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.brand-name { font-size: 19px; font-weight: 700; }
.site-nav { display: flex; align-items: center; gap: 22px; }
.site-nav a { color: var(--text-secondary); font-size: 15px; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--accent); }
.nav-search { display: inline-flex; }
.theme-toggle {
  border: 1px solid var(--border);
  background: var(--bg-page);
  color: var(--accent);
  width: 34px; height: 28px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}
[data-theme="dark"] .theme-toggle::after { content: ""; }

/* ===== 首頁 ===== */
.hero, .featured, .latest, .page-head {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px;
}
.hero { padding-top: 50px; padding-bottom: 8px; text-align: center; }
.hero h1 { font-size: 34px; font-weight: 700; letter-spacing: 0.04em; }
.hero-en { color: var(--text-tertiary); font-size: 14px; letter-spacing: 0.22em; margin-top: 8px; }
.hero-sub { color: var(--text-tertiary); font-size: 15px; margin-top: 8px; }
.hero-tagline {

  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.7;
  margin-top: 40px;
  margin-bottom: 20px;
}
.hero-rule {
  width: 140px; height: 3px;
  background: var(--accent);
  margin-top: 8px;
  margin-left: auto;
  margin-right: auto;
}

.section-label {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.35em;
  margin: 30px 0 18px;
}

.featured-card {
  position: relative;
  background: var(--bg-card);
  border: 2px solid var(--accent);
  border-radius: 12px;
  padding: 34px 32px 30px;
  margin-top: 10px;
  margin-bottom: 10px;
}
.badge {
  position: absolute;
  top: -13px; left: 24px;
  background: var(--accent);
  color: #FFFFFF;
  font-size: 12.5px; font-weight: 700;
  padding: 4px 14px;
  border-radius: 6px;
}
.featured-title { font-size: 24px; margin-bottom: 6px; }
.featured-title a { color: var(--text-primary); }
.featured-title a:hover { color: var(--accent); }

.card-meta { color: var(--text-secondary); font-size: 13px; margin: 6px 0 10px; }
.card-summary { color: var(--text-secondary); font-size: 14.5px; }
.card-links { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.card-links .btn { margin-top: 0; }

.work-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px 26px;
  margin-bottom: 14px;
}
.work-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 5px;
  border-radius: 10px 0 0 10px;
  background: var(--accent);
}
.work-title { font-size: 19px; }
.work-title a { color: var(--text-primary); }
.work-title a:hover { color: var(--accent); }
.read-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 14px;
  font-weight: 700;
}

.all-works { margin: 26px 0 60px; }

/* ===== 按钮 ===== */
.btn {
  display: inline-block;
  border-radius: 12px;
  padding: 6px 24px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: #FFFFFF; }
.btn-primary:hover { background: var(--accent-hover); color: #FFFFFF; }
.btn-outline { background: var(--bg-card); border-color: var(--accent); color: var(--accent); }
.btn-outline:hover { color: var(--accent-hover); border-color: var(--accent-hover); }
.btn-block { display: block; text-align: center; background: var(--accent); color: #FFFFFF; padding: 13px; border-radius: 23px; }
.btn-block:hover { background: var(--accent-hover); color: #FFFFFF; }

/* ===== 頁腳 ===== */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 40px;
}
.footer-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 20px 36px;
  color: var(--text-tertiary);
  font-size: 13px;
  text-align: center;
}
.footer-sub { margin-top: 6px; }

/* ===== 作品詳情頁 ===== */
.breadcrumb {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 20px 0;
  font-size: 13px;
  color: var(--text-tertiary);
}
.work-detail { max-width: 720px; margin: 0 auto; padding: 10px 20px 0; }
.work-header h1 { font-size: 28px; margin: 14px 0 4px; text-align: center;}
.work-summary { color: var(--text-secondary); font-size: 15px; margin: 12px 0 18px; }
.work-tags { margin: 8px 0; }
.tag {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 5px;
  padding: 2px 10px;
  font-size: 12.5px;
  margin-right: 8px;
}
.tag.cw {
  background: rgba(234, 88, 12, 0.12);
  color: #C2410C;
  border: 1px solid rgba(234, 88, 12, 0.35);
  font-weight: 600;
}
[data-theme="dark"] .tag.cw {
  color: #FB923C;
  background: rgba(234, 88, 12, 0.18);
  border-color: rgba(251, 146, 60, 0.4);
}
.chapter-list { padding-bottom: 30px; }
.chapter-list ol { list-style: none; }
.chapter-list li a {
  display: flex;
  align-items: baseline;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 13px 18px;
  margin-bottom: 8px;
  color: var(--text-primary);
}
.chapter-list li a:hover { border-color: var(--accent); }
.ch-num { color: var(--accent); font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.ch-title { font-size: 15.5px; }

/* ===== 閱讀頁 ===== */
.progress-track {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--border);
  z-index: 40;
}
.progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.1s linear;
}

.reading-bar {
  position: sticky;
  top: 4px;
  z-index: 30;
  margin-top: 0;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 56px;
}
/* 阅读页只保留阅读栏，隐藏与其重叠的全局顶栏（避免双栏遮挡、双主题按钮） */
.site-header:has(~ .reading-bar) { display: none; }
.rb-back { font-size: 15px; color: var(--text-primary); }
.rb-back:hover { color: var(--accent); }
.rb-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 50%;
}
.rb-actions { display: inline-flex; gap: 8px; }
.rb-btn {
  border: 1px solid var(--border);
  background: var(--bg-page);
  color: var(--accent);
  min-width: 42px;
  height: 28px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 8px;
}
.fs-seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  height: 28px;
}
.fs-opt {
  border: 0;
  background: var(--bg-page);
  color: var(--text-secondary);
  min-width: 34px;
  height: 100%;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 8px;
}
.fs-opt + .fs-opt { border-left: 1px solid var(--border); }
.fs-opt.is-active {
  background: var(--accent);
  color: #fff;
}
.lang-switch {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  background: var(--bg-page);
  color: var(--accent);
  height: 28px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  padding: 0 10px;
  text-decoration: none;
}
.lang-switch:hover { color: var(--text-primary); }

.chapter {
  max-width: var(--reading-width);
  margin: 0 auto;
  padding: 40px 20px 60px;
}
.chapter-header { text-align: center; margin-bottom: 34px; }
.chapter-header h1 { font-size: 25px; font-weight: 700; }
.chapter-meta { color: var(--text-tertiary); font-size: 13px; margin-top: 12px; }
.chapter-header .hero-rule { margin: 18px auto 0; width: 120px; height: 2px; }

.chapter-body {
  font-family: var(--font-reading);
  font-size: var(--reading-font-size);
  line-height: 1.85;
  color: var(--text-primary);
}
.chapter-body p {
  text-indent: 2em;
  margin: 0 0 0.4em;
  overflow-wrap: break-word;
}

.chapter-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  margin-top: 48px;
  padding-top: 26px;
}
.chapter-nav .btn { max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapter-toc { font-size: 14px; color: var(--text-tertiary); }
.chapter-toc:hover { color: var(--accent); }

.chapter-copyright {
  margin-top: 36px;
  color: var(--text-tertiary);
  font-size: 12.5px;
  text-align: center;
}

/* ===== 通用頁面（關於/標籤/404/搜尋） ===== */
.page-body {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}
.page-body h1 { font-size: 26px; margin-bottom: 18px; }
.page-body h2 { font-size: 20px; margin: 60px 0 10px; }
.page-body p { color: var(--text-secondary); margin-bottom: 12px; font-size: 15px; }
.contact-email-img { display: block; max-width: 260px; height: auto; margin: 4px 0 16px; }
.page-head h1 { font-size: 26px; padding-top: 36px; }
.not-found { text-align: center; padding-top: 90px; }
.not-found .btn { margin-top: 18px; }

/* ===== 搜尋頁 ===== */
.search-input {
  width: 100%;
  font-size: 16px;
  padding: 12px 18px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--bg-card);
  color: var(--text-primary);
  outline: none;
}
.search-input:focus { border-color: var(--accent); }
.search-hint { color: var(--text-tertiary); font-size: 13px; margin: 12px 2px; }
.search-results { list-style: none; margin-top: 10px; }
.search-results li {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 10px;
}
.search-results .sr-work { font-size: 12.5px; color: var(--accent); }
.search-results .sr-title { font-size: 16.5px; font-weight: 700; }
.search-results .sr-title a { color: var(--text-primary); }
.search-results .sr-title a:hover { color: var(--accent); }
.search-results .sr-snippet { font-size: 13.5px; color: var(--text-secondary); margin-top: 4px; }
.search-results mark { background: var(--accent-soft); color: var(--accent); padding: 0 1px; border-radius: 2px; }

/* ===== 響應式 ===== */
@media (max-width: 640px) {
  .hero h1 { font-size: 27px; }
  .site-nav { gap: 16px; }
  .site-nav a { font-size: 14px; }
  .featured-card { padding: 26px 20px 24px; }
  .rb-title { max-width: 38%; }
  .chapter { padding-top: 30px; }
}

/* 超窄屏（≤360px）：收緊頂欄，避免導航溢出 */
@media (max-width: 360px) {
  .header-inner { padding: 0 14px; }
  .brand-name { font-size: 17px; }
  .site-nav { gap: 11px; }
  .site-nav a { font-size: 13px; }
  .theme-toggle { width: 30px; }
}

/* ===== 首頁數據條 / 分類導航 / 卡片補充字段（2026-09-16 首頁改造） ===== */
.hero-stats {
  color: var(--text-tertiary);
  font-size: 13.5px;
  line-height: 1.8;
  margin-top: 14px;
}
/* 中式悬疑定位句（2026-09-19 品牌化） */
.hero-tagline { margin-bottom: 8px; }
.hero-style {
  color: var(--text-tertiary);
  font-size: 14px;
  line-height: 1.8;
  margin-bottom: 20px;
}
.page-style {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.8;
  margin: -4px 0 22px !important;
}
@media (max-width: 640px) {
  .hero-style { font-size: 13px; }
}
.card-genre {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 5px;
  padding: 1px 9px;
  font-size: 12px;
  margin-right: 9px;
  vertical-align: 1px;
}
.card-time { white-space: nowrap; }
.genres, .latest-more {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px;
}
.latest { padding-bottom: 6px; }
.latest-more { padding-top: 6px; padding-bottom: 60px; }
.genre-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 4px 0 6px;
}
.genre-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 14px;
  color: var(--text-primary);
}
.genre-chip:hover { border-color: var(--accent); color: var(--accent); }
.genre-count {
  color: var(--text-tertiary);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.genre-chip:hover .genre-count { color: var(--accent); }
.page-intro {
  color: var(--text-tertiary);
  font-size: 13.5px;
  margin: 0 0 18px !important;
}
.page-body .genre-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 19px;
  margin: 46px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 84px;
}
.page-body .genre-heading:first-of-type { margin-top: 30px; }
.work-card { scroll-margin-top: 84px; }
@media (max-width: 640px) {
  .hero-stats { font-size: 12.5px; }
  .genre-chip { padding: 6px 13px; font-size: 13.5px; }
}

/* ===== 登录 / 书架 / 阅读进度（2026-09-23） ===== */
.auth-area { display: inline-flex; align-items: center; gap: 10px; position: relative; }
.auth-link {
  border: none; background: none; padding: 0;
  color: var(--text-secondary); font-size: 15px; font-family: inherit; cursor: pointer;
}
.auth-link:hover { color: var(--accent); }
.auth-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--accent-soft); color: var(--accent);
  font-size: 13px; font-weight: 700; cursor: pointer; line-height: 1;
}
.auth-menu {
  display: none; position: absolute; right: 0; top: 38px; z-index: 90;
  min-width: 190px; padding: 8px;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
.auth-menu.open { display: block; }
.auth-menu-email {
  padding: 6px 10px 8px; font-size: 12px; color: var(--text-tertiary);
  border-bottom: 1px solid var(--border); margin-bottom: 4px; word-break: break-all;
}
.auth-menu-item {
  display: block; width: 100%; text-align: left;
  border: none; background: none; padding: 8px 10px; border-radius: 7px;
  font-size: 14px; font-family: inherit; color: var(--text-primary); cursor: pointer;
}
.auth-menu-item:hover { background: var(--accent-soft); color: var(--accent); }
.auth-menu-danger { color: var(--text-tertiary); }

/* 收藏按钮：做成醒目的实心主按钮（2026-09-30 阿赖要求「♡ 太不明显」） */
.shelf-btn {
  display: inline-block;
  margin-top: 16px; padding: 10px 22px;
  border: 1px solid var(--accent); border-radius: 999px;
  background: var(--accent); color: #FFFFFF;
  font-size: 14px; font-weight: 700; font-family: inherit; cursor: pointer;
  box-shadow: 0 2px 10px rgba(109, 40, 217, .18);
}
.shelf-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #FFFFFF; }
/* 已收藏：降为空心，避免和「未收藏」混淆 */
.shelf-btn.is-on {
  background: var(--accent-soft); color: var(--accent);
  border-color: var(--accent); box-shadow: none;
}
/* 深色模式主色偏浅，白字看不清 → 改用深字 */
[data-theme="dark"] .shelf-btn { color: #1A1A18; }
[data-theme="dark"] .shelf-btn:hover { color: #1A1A18; }
[data-theme="dark"] .shelf-btn.is-on { color: var(--accent); }

.mt-resume {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 95;
  display: flex; align-items: center; gap: 12px;
  max-width: calc(100vw - 32px); padding: 10px 14px;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.14); font-size: 13.5px; color: var(--text-primary);
}
.mt-resume-btn {
  border: none; background: var(--accent); color: #fff;
  padding: 6px 14px; border-radius: 7px; font-size: 13px; font-family: inherit; cursor: pointer;
}
.mt-resume-x {
  border: none; background: none; color: var(--text-tertiary);
  font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px;
}

.mt-cookie {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); z-index: 96;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  width: min(680px, calc(100vw - 24px)); margin-bottom: 12px;
  padding: 10px 14px; border-radius: 10px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  font-size: 12.5px; color: var(--text-secondary);
}
.mt-cookie a { color: var(--accent); }
.mt-cookie-btn {
  margin-left: auto; border: none; background: var(--accent); color: #fff;
  padding: 5px 14px; border-radius: 7px; font-size: 12.5px; font-family: inherit; cursor: pointer;
}

.mt-modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(0,0,0,.45);
}
.mt-modal-card {
  position: relative; width: min(380px, 100%);
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 14px;
  padding: 26px 24px; box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.mt-modal-card h3 { margin: 0 0 4px; font-size: 19px; }
.mt-modal-tip { margin: 0 0 16px; font-size: 13px; color: var(--text-tertiary); }
.mt-modal-x {
  position: absolute; right: 12px; top: 8px;
  border: none; background: none; font-size: 24px; line-height: 1;
  color: var(--text-tertiary); cursor: pointer;
}
.mt-input {
  display: block; width: 100%; margin-bottom: 10px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-card); color: var(--text-primary);
  font-size: 14px; font-family: inherit;
}
.mt-input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.mt-modal-err { margin: 0 0 10px; font-size: 13px; color: #C0392B; }
.mt-btn {
  display: block; width: 100%; margin-bottom: 8px; padding: 10px;
  border-radius: 8px; font-size: 14px; font-family: inherit; cursor: pointer;
}
.mt-btn-primary { border: none; background: var(--accent); color: #fff; }
.mt-btn-ghost { border: 1px solid var(--border); background: none; color: var(--text-secondary); }
.mt-link-btn {
  display: block; margin: 4px auto 0; border: none; background: none;
  color: var(--accent); font-size: 12.5px; font-family: inherit; cursor: pointer;
}
.mt-modal-note { margin: 14px 0 0; font-size: 12px; color: var(--text-tertiary); text-align: center; }

.mt-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(12px);
  z-index: 110; opacity: 0; pointer-events: none; transition: opacity .22s, transform .22s;
  padding: 10px 16px; border-radius: 9px; max-width: calc(100vw - 32px);
  background: var(--text-primary); color: var(--bg-page);
  font-size: 13.5px; text-align: center;
}
.mt-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.shelf-list { display: grid; gap: 18px; }
.shelf-row { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.shelf-cont { color: var(--accent); font-size: 13.5px; }
.shelf-remove {
  margin-left: auto; border: 1px solid var(--border); background: none;
  color: var(--text-tertiary); border-radius: 999px; padding: 5px 12px;
  font-size: 12.5px; font-family: inherit; cursor: pointer;
}
.shelf-remove:hover { border-color: var(--accent); color: var(--accent); }
.shelf-empty { padding: 26px 0; color: var(--text-tertiary); font-size: 14px; }
@media (max-width: 640px) {
  .auth-menu { right: -4px; }
  .mt-cookie { font-size: 12px; }
}
