/* ============================================================
   书斋 · TXT 小说阅读器 — Apple 风格样式
   设计语言：毛玻璃材质、系统字体、柔和阴影、克制动效
   ============================================================ */

:root {
  /* 主题变量 — 浅色 */
  --bg: #f5f5f7;
  --bg-deep: #ececef;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --text: #1d1d1f;
  --text-secondary: rgba(60, 60, 67, 0.6);
  --text-tertiary: rgba(60, 60, 67, 0.34);
  --accent: #0071e3;
  --accent-press: #005bb8;
  --border: rgba(0, 0, 0, 0.06);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.05), 0 12px 32px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.06), 0 24px 64px rgba(0, 0, 0, 0.16);

  /* 阅读器变量 */
  --reader-font-size: 18px;
  --reader-line-height: 1.9;
  --reader-text: #1d1d1f;
  --reader-bg: #fbfbfd;
  --reader-muted: rgba(60, 60, 67, 0.5);

  /* 几何 */
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --navbar-h: 56px;

  /* 动效 */
  --spring: cubic-bezier(0.22, 1, 0.36, 1);
  --ease: cubic-bezier(0.33, 1, 0.68, 1);

  color-scheme: light;
}

/* ---------------- 主题：羊皮纸 ---------------- */
[data-theme='sepia'] {
  --bg: #f3ead8;
  --bg-deep: #e9ddc6;
  --surface: rgba(249, 244, 232, 0.8);
  --surface-solid: #f9f4e8;
  --text: #433422;
  --text-secondary: rgba(67, 52, 34, 0.62);
  --text-tertiary: rgba(67, 52, 34, 0.36);
  --accent: #a9713c;
  --accent-press: #8a5a2e;
  --border: rgba(67, 52, 34, 0.1);
  --reader-text: #3f3223;
  --reader-bg: #f7efdf;
  --reader-muted: rgba(63, 50, 35, 0.55);
  color-scheme: light;
}

/* ---------------- 主题：深色 ---------------- */
[data-theme='dark'] {
  --bg: #000000;
  --bg-deep: #0a0a0c;
  --surface: rgba(28, 28, 30, 0.72);
  --surface-solid: #1c1c1e;
  --text: #f5f5f7;
  --text-secondary: rgba(235, 235, 245, 0.6);
  --text-tertiary: rgba(235, 235, 245, 0.34);
  --accent: #0a84ff;
  --accent-press: #3395ff;
  --border: rgba(255, 255, 255, 0.09);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5), 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.5), 0 12px 32px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.55), 0 24px 64px rgba(0, 0, 0, 0.7);
  --reader-text: rgba(235, 235, 245, 0.9);
  --reader-bg: #111113;
  --reader-muted: rgba(235, 235, 245, 0.45);
  color-scheme: dark;
}

/* ---------------- 基础 ---------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro SC', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.35s var(--ease), color 0.35s var(--ease);
}

button {
  font-family: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
.drop-zone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::selection {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text-tertiary) 55%, transparent);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background-color: color-mix(in srgb, var(--text-secondary) 60%, transparent);
}

/* ---------------- 视图切换 ---------------- */
.view {
  min-height: 100vh;
  min-height: 100dvh;
}

.view--reader {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--reader-bg);
}

/* ============================================================
   书库页
   ============================================================ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--navbar-h);
  padding: 0 max(20px, env(safe-area-inset-left)) 0 max(24px, env(safe-area-inset-left));
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
}

.navbar__title {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 980px;
  padding: 7px 18px;
  font-size: 15px;
  font-weight: 600;
  transition: transform 0.15s var(--ease), background-color 0.2s var(--ease),
    box-shadow 0.2s var(--ease), opacity 0.2s var(--ease);
}

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

.btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent);
}

.btn--primary:hover {
  background: var(--accent-press);
}

.library {
  max-width: 1060px;
  margin: 0 auto;
  padding: 48px 24px 96px;
}

/* ---------------- Hero ---------------- */
.hero {
  text-align: center;
  margin-bottom: 36px;
}

.hero__eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}

.hero__title {
  font-size: clamp(30px, 4.5vw, 46px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 12px;
}

.hero__subtitle {
  font-size: 17px;
  color: var(--text-secondary);
  max-width: 460px;
  margin: 0 auto;
}

/* ---------------- 上传区 ---------------- */
.drop-zone {
  position: relative;
  border: 1.5px dashed color-mix(in srgb, var(--text-tertiary) 55%, transparent);
  border-radius: var(--radius-xl);
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  padding: 44px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.25s var(--ease), transform 0.2s var(--ease),
    background-color 0.25s var(--ease), box-shadow 0.3s var(--ease);
}

.drop-zone:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.drop-zone.is-dragover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface-solid));
  transform: scale(1.005);
}

.drop-zone__icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  transition: transform 0.3s var(--spring);
}

.drop-zone:hover .drop-zone__icon {
  transform: translateY(-3px);
}

.drop-zone__main {
  font-size: 17px;
  font-weight: 600;
}

.drop-zone__link {
  color: var(--accent);
}

.drop-zone__hint {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-tertiary);
}

/* 上传进度 */
.upload-progress {
  max-width: 340px;
  margin: 20px auto 0;
}

.upload-progress__track {
  height: 6px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--text-tertiary) 20%, transparent);
  overflow: hidden;
}

.upload-progress__bar {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.3s var(--ease);
}

.upload-progress__label {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ---------------- 书架 ---------------- */
.shelf-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 44px 0 18px;
}

.shelf-head__title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.shelf-head__count {
  font-size: 13px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 22px;
}

/* 书卡 */
.book-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: card-in 0.5s var(--spring) both;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.book-card__cover {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  transition: transform 0.35s var(--spring), box-shadow 0.35s var(--ease);
  cursor: pointer;
}

.book-card:hover .book-card__cover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: var(--shadow-lg);
}

.book-card__cover::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.16), transparent 40%);
  pointer-events: none;
}

.book-card__cover-title {
  position: relative;
  z-index: 1;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.96);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.18);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-align: center;
  word-break: break-all;
}

.book-card__meta {
  padding: 0 2px;
}

.book-card__name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-card__info {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.book-card__progress {
  margin-top: 6px;
  height: 3px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--text-tertiary) 18%, transparent);
  overflow: hidden;
}

.book-card__progress i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.4s var(--ease);
}

.book-card__remove {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.2s var(--ease), transform 0.25s var(--spring);
}

.book-card:hover .book-card__remove,
.book-card:focus-within .book-card__remove {
  opacity: 1;
  transform: none;
}

.book-card__remove:hover {
  background: rgba(255, 59, 48, 0.9);
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 48px 0 20px;
}

.empty-state__art {
  font-size: 52px;
  margin-bottom: 14px;
  filter: grayscale(0.2);
}

.empty-state__title {
  font-size: 18px;
  font-weight: 600;
}

.empty-state__sub {
  margin-top: 6px;
  font-size: 14px;
  color: var(--text-tertiary);
}

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(12px);
  z-index: 100;
  max-width: min(90vw, 380px);
  padding: 11px 18px;
  border-radius: 980px;
  background: var(--surface-solid);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  opacity: 0;
  transition: opacity 0.3s var(--ease), transform 0.35s var(--spring);
  pointer-events: none;
}

.toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   阅读器
   ============================================================ */
.reader-bar {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--navbar-h);
  padding: 0 max(14px, env(safe-area-inset-left)) 0 max(16px, env(safe-area-inset-left));
  background: var(--reader-bg);
}

.reader-bar__title {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-bar__actions {
  display: flex;
  gap: 4px;
}

/* 通用图标按钮 */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: var(--reader-muted);
  transition: background-color 0.18s var(--ease), color 0.18s var(--ease),
    transform 0.12s var(--ease);
}

.icon-btn:hover {
  background: color-mix(in srgb, var(--reader-muted) 12%, transparent);
  color: var(--reader-text);
}

.icon-btn:active {
  transform: scale(0.92);
}

.icon-btn--lg {
  width: 46px;
  height: 46px;
  border-radius: 14px;
}

/* 阅读进度条 */
.reader-progress {
  position: relative;
  z-index: 30;
  height: 2px;
  background: color-mix(in srgb, var(--reader-muted) 18%, transparent);
}

.reader-progress__bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.2s linear;
}

/* 正文滚动区 */
.reader-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.reader-content {
  max-width: 680px;
  margin: 0 auto;
  padding: 28px clamp(20px, 5vw, 44px) 120px;
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  color: var(--reader-text);
  letter-spacing: 0.005em;
  overflow-wrap: break-word;
}

.reader-content.is-justified {
  text-align: justify;
}

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

.reader-content p.chapter-title {
  text-indent: 0;
  font-size: 1.28em;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-align: center;
  margin: 1.4em 0 1.1em;
  line-height: 1.5;
}

.reader-content p.is-muted {
  text-indent: 0;
  text-align: center;
  color: var(--reader-muted);
  font-size: 0.85em;
}

.reader-loading,
.reader-end {
  text-align: center;
  padding: 24px 0;
  font-size: 13px;
  color: var(--reader-muted);
  letter-spacing: 0.06em;
}

.reader-loading::before {
  content: '';
  display: inline-block;
  width: 18px;
  height: 18px;
  margin-right: 8px;
  vertical-align: -4px;
  border: 2px solid var(--reader-muted);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* 章节导航条 */
.reader-nav {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px max(16px, env(safe-area-inset-left)) calc(12px + env(safe-area-inset-bottom));
  background: var(--reader-bg);
  border-top: 1px solid color-mix(in srgb, var(--reader-muted) 14%, transparent);
}

.reader-nav__label {
  font-size: 13px;
  color: var(--reader-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.reader-nav button:disabled {
  opacity: 0.28;
  pointer-events: none;
}

/* ---------------- 抽屉（目录 / 设置） ---------------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}

.sheet-backdrop.is-show {
  opacity: 1;
}

.sheet {
  position: fixed;
  top: 0;
  bottom: 0;
  z-index: 60;
  width: min(340px, 88vw);
  display: flex;
  flex-direction: column;
  background: var(--reader-bg);
  box-shadow: var(--shadow-lg);
  transition: transform 0.45s var(--spring);
}

.sheet--left {
  left: 0;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  transform: translateX(-105%);
}

.sheet--left.is-open {
  transform: translateX(0);
}

.sheet--right {
  right: 0;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  transform: translateX(105%);
}

.sheet--right.is-open {
  transform: translateX(0);
}

.sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 12px;
}

.sheet__title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* 目录列表 */
.toc {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px 24px;
}

.toc__item {
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text-secondary);
  transition: background-color 0.16s var(--ease), color 0.16s var(--ease);
}

.toc__item:hover {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  color: var(--text);
}

.toc__item.is-current {
  color: var(--accent);
  font-weight: 600;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

/* 设置面板 */
.settings {
  flex: 1;
  overflow-y: auto;
  padding: 4px 20px 32px;
}

.setting-group {
  padding: 18px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--reader-muted) 14%, transparent);
}

.setting-group:last-child {
  border-bottom: none;
}

.setting-group__label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--reader-muted);
  margin-bottom: 14px;
  text-transform: uppercase;
}

/* 字号步进器 */
.stepper {
  display: flex;
  align-items: center;
  gap: 14px;
}

.stepper .icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}

.stepper__value {
  min-width: 46px;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* 滑杆 */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--reader-muted) 26%, transparent);
  outline: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
  cursor: pointer;
  transition: transform 0.15s var(--ease);
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.08);
}

.slider::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
  cursor: pointer;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  color: var(--reader-muted);
}

/* 主题色板 */
.theme-row {
  display: flex;
  gap: 16px;
}

.theme-swatch {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: transform 0.2s var(--spring);
}

.theme-swatch:hover {
  transform: scale(1.08);
}

.theme-swatch__dot {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 1px solid var(--border);
  box-shadow: inset 0 0 0 3px var(--reader-bg), 0 1px 4px rgba(0, 0, 0, 0.14);
  transition: box-shadow 0.25s var(--ease);
}

.theme-swatch.is-active .theme-swatch__dot {
  box-shadow: inset 0 0 0 3px var(--reader-bg), 0 0 0 2px var(--accent),
    0 1px 4px rgba(0, 0, 0, 0.18);
}

.theme-swatch__dot--light {
  background: #fbfbfd;
}
.theme-swatch__dot--sepia {
  background: #f2e7cf;
}
.theme-swatch__dot--dark {
  background: #161618;
}

/* 开关 */
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle__track {
  width: 52px;
  height: 32px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--reader-muted) 30%, transparent);
  position: relative;
  transition: background-color 0.25s var(--ease);
  flex-shrink: 0;
}

.toggle__track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s var(--spring);
}

.toggle input:checked + .toggle__track {
  background: var(--accent);
}

.toggle input:checked + .toggle__track::after {
  transform: translateX(20px);
}

.toggle__text {
  font-size: 15px;
  color: var(--text);
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 640px) {
  .library {
    padding: 32px 16px 80px;
  }
  .book-grid {
    grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
    gap: 16px;
  }
  .book-card__cover-title {
    font-size: 15px;
  }
}

/* ---------------- 动效偏好 ---------------- */
@media (prefers-reduced-motion: reduce) {
  .book-card,
  .reader-content,
  .sheet,
  .sheet-backdrop,
  .toast {
    transition: opacity 0.2s ease !important;
    transform: none !important;
    animation: none !important;
  }
  html {
    scroll-behavior: auto;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .navbar,
  .drop-zone,
  .tabbar {
    background: var(--surface-solid);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

/* ============================================================
   登录视图
   ============================================================ */
.view--login {
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--accent) 10%, var(--bg)), var(--bg) 55%);
}

.login-card {
  width: min(400px, 100%);
  padding: 40px 34px 34px;
  border-radius: 24px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  animation: card-in 0.5s var(--spring) both;
}

.login-logo {
  font-size: 44px;
  text-align: center;
}

.login-title {
  margin-top: 8px;
  text-align: center;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-sub {
  margin: 8px 0 26px;
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-error {
  font-size: 13px;
  color: #ff3b30;
  text-align: center;
}

.login-switch {
  text-align: center;
  font-size: 14px;
  color: var(--text-tertiary);
}

.login-switch__btn {
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
}

/* 表单字段 */
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.field__input {
  font-family: inherit;
  font-size: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), background-color 0.2s var(--ease);
}

.field__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
  background: var(--surface-solid);
}

.field__input::placeholder {
  color: var(--text-tertiary);
}

.field__textarea {
  resize: none;
  min-height: 120px;
  line-height: 1.6;
}

.btn--block {
  width: 100%;
  justify-content: center;
  padding: 13px 18px;
  font-size: 16px;
}

.btn--danger {
  background: color-mix(in srgb, #ff3b30 10%, transparent);
  color: #ff3b30;
  font-weight: 600;
}

.btn--danger:hover {
  background: color-mix(in srgb, #ff3b30 16%, transparent);
}

/* ============================================================
   底部导航
   ============================================================ */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  display: flex;
  background: var(--surface);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-top: 1px solid var(--border);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}

.tabbar__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  transition: color 0.2s var(--ease);
}

.tabbar__item svg {
  transition: transform 0.25s var(--spring);
}

.tabbar__item.is-active {
  color: var(--accent);
}

.tabbar__item.is-active svg {
  transform: translateY(-1px);
}

/* ============================================================
   通用页面视图
   ============================================================ */
.view--page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

.page-main {
  flex: 1;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 20px 40px;
}

.page-desc {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 18px;
}

.navbar__title--flex {
  flex: 1;
  text-align: left;
}

/* 搜索栏 */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  margin-bottom: 18px;
  color: var(--text-tertiary);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.search-bar input {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
}

.search-bar input::placeholder {
  color: var(--text-tertiary);
}

/* 头像 */
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  flex-shrink: 0;
  user-select: none;
}

.avatar--sm {
  width: 30px;
  height: 30px;
  font-size: 13px;
}

/* ============================================================
   推荐页
   ============================================================ */
.recommend-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.recommend-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s var(--spring), box-shadow 0.3s var(--ease);
  cursor: pointer;
}

.recommend-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.recommend-card__cover {
  width: 54px;
  height: 72px;
  border-radius: 9px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  padding: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  overflow: hidden;
}

.recommend-card__body {
  flex: 1;
  min-width: 0;
}

.recommend-card__title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recommend-card__meta {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--text-tertiary);
}

.recommend-card__actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.heart-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--text-tertiary);
  transition: color 0.2s var(--ease), transform 0.25s var(--spring), background-color 0.2s var(--ease);
}

.heart-btn:hover {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.heart-btn.is-liked {
  color: #ff3b30;
}

.heart-btn.is-liked svg {
  fill: currentColor;
}

.heart-btn:active {
  transform: scale(0.82);
}

.heart-count {
  font-size: 11px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   书友页
   ============================================================ */
.friend-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.friend-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.2s var(--spring), box-shadow 0.25s var(--ease);
}

.friend-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.friend-card__body {
  flex: 1;
  min-width: 0;
}

.friend-card__name {
  font-size: 15px;
  font-weight: 600;
}

.friend-card__name span {
  color: var(--text-tertiary);
  font-weight: 400;
  font-size: 13px;
  margin-left: 6px;
}

.friend-card__meta {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--text-tertiary);
}

.follow-btn {
  padding: 7px 18px;
  border-radius: 980px;
  font-size: 13px;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  transition: background-color 0.2s var(--ease), transform 0.15s var(--ease), opacity 0.2s var(--ease);
}

.follow-btn:active {
  transform: scale(0.95);
}

.follow-btn.is-following {
  background: color-mix(in srgb, var(--text-secondary) 12%, transparent);
  color: var(--text-secondary);
}

/* 用户主页（弹层） */
.profile-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: var(--reader-bg);
  overflow-y: auto;
  padding: 0 0 48px;
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}

.profile-backdrop.is-show {
  opacity: 1;
}

.profile-head {
  padding: 48px 24px 24px;
  text-align: center;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 8%, transparent), transparent);
}

.profile-head .avatar {
  width: 72px;
  height: 72px;
  font-size: 28px;
  margin: 0 auto;
}

.profile-head__name {
  margin-top: 12px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.profile-head__user {
  margin-top: 3px;
  font-size: 13px;
  color: var(--text-tertiary);
}

.profile-head__stats {
  margin-top: 14px;
  display: flex;
  justify-content: center;
  gap: 28px;
}

.profile-head__stat {
  text-align: center;
}

.profile-head__stat b {
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.profile-head__stat span {
  display: block;
  font-size: 11px;
  color: var(--text-tertiary);
}

.profile-head__follow {
  margin-top: 16px;
}

.profile-section {
  max-width: 720px;
  margin: 24px auto 0;
  padding: 0 20px;
}

.profile-section__title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 14px;
}

/* ============================================================
   论坛页
   ============================================================ */
.board-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 12px;
  cursor: pointer;
  transition: transform 0.2s var(--spring), box-shadow 0.25s var(--ease);
}

.board-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.board-card__icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  flex-shrink: 0;
}

.board-card__body {
  flex: 1;
  min-width: 0;
}

.board-card__title {
  font-size: 16px;
  font-weight: 600;
}

.board-card__meta {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--text-tertiary);
}

.board-card__arrow {
  color: var(--text-tertiary);
}

/* 帖子列表 */
.post-card {
  padding: 16px 4px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background-color 0.15s var(--ease);
}

.post-card:hover {
  background: color-mix(in srgb, var(--accent) 4%, transparent);
}

.post-card:first-child {
  border-top: 1px solid var(--border);
}

.post-card__title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.4;
}

.post-card__excerpt {
  margin-top: 5px;
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card__meta {
  margin-top: 9px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-tertiary);
}

.post-card__author {
  display: flex;
  align-items: center;
  gap: 7px;
}

/* 帖子详情 */
.post-detail {
  padding: 4px 0;
}

.post-detail__title {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.4;
}

.post-detail__head {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.post-detail__author-name {
  font-size: 14px;
  font-weight: 600;
}

.post-detail__time {
  font-size: 12px;
  color: var(--text-tertiary);
}

.post-detail__content {
  margin-top: 18px;
  font-size: 15.5px;
  line-height: 1.9;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.comment-list {
  margin-top: 24px;
}

.comment-list__title {
  font-size: 15px;
  font-weight: 700;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.comment-item {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.comment-item__body {
  flex: 1;
  min-width: 0;
}

.comment-item__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.comment-item__name {
  font-weight: 600;
}

.comment-item__time {
  color: var(--text-tertiary);
  font-size: 12px;
}

.comment-item__content {
  margin-top: 6px;
  font-size: 14.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.comment-form {
  margin-top: 18px;
}

/* 发帖抽屉 */
.compose {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 20px 28px;
  overflow-y: auto;
}

.compose__board {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 8px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

/* ============================================================
   我的
   ============================================================ */
.me-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 22px;
}

.me-card__body {
  flex: 1;
}

.me-card__name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.me-card__user {
  margin-top: 3px;
  font-size: 13px;
  color: var(--text-tertiary);
}

.me-card__stats {
  display: flex;
  gap: 18px;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.me-card__stats b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.me-card__hint {
  margin-top: 8px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-tertiary);
}

.me-section {
  margin-bottom: 26px;
}

.me-section__title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
}

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

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

.session-item__body {
  flex: 1;
  min-width: 0;
}

.session-item__time {
  font-size: 12px;
  color: var(--text-tertiary);
}

.session-item__current {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  padding: 2px 8px;
  border-radius: 99px;
}

.me-following {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.me-following__empty {
  font-size: 13px;
  color: var(--text-tertiary);
  padding: 8px 0;
}

/* 阅读器推荐按钮激活态 */
#btn-recommend.is-liked {
  color: #ff3b30;
}

#btn-recommend.is-liked svg {
  fill: currentColor;
}

/* ---------------- 动效偏好（追加） ---------------- */
@media (prefers-reduced-motion: reduce) {
  .login-card,
  .profile-backdrop,
  .recommend-card,
  .friend-card,
  .board-card,
  .post-card,
  .tabbar__item svg {
    transition: opacity 0.2s ease !important;
    transform: none !important;
    animation: none !important;
  }
}
