/* ==================== 墨读 — 高端色彩暗色风格 ==================== */
:root {
  --bg-base: #0C0C14;
  --bg-elevated: #151525;
  --bg-surface: #1C1C30;
  --bg-hover: #222240;
  --border-subtle: #252538;
  --border-default: #333350;
  --text-primary: #F0F0FA;
  --text-secondary: #9999B8;
  --text-tertiary: #666680;
  --accent-purple: #A78BFA;
  --accent-blue: #60A5FA;
  --accent-pink: #F472B6;
  --accent-cyan: #22D3EE;
  --accent-amber: #FBBF24;
  --accent-emerald: #34D399;
  --accent-rose: #FB7185;
  --accent-indigo: #818CF8;
  --grad-hero: linear-gradient(135deg, #A78BFA 0%, #F472B6 50%, #FB923C 100%);
  --grad-card1: linear-gradient(145deg, #6366F1 0%, #8B5CF6 50%, #A78BFA 100%);
  --grad-card2: linear-gradient(145deg, #0EA5E9 0%, #06B6D4 50%, #22D3EE 100%);
  --grad-card3: linear-gradient(145deg, #F43F5E 0%, #E11D48 50%, #FB7185 100%);
  --grad-card4: linear-gradient(145deg, #10B981 0%, #059669 50%, #34D399 100%);
  --grad-card5: linear-gradient(145deg, #F59E0B 0%, #D97706 50%, #FBBF24 100%);
  --grad-card6: linear-gradient(145deg, #7C3AED 0%, #6D28D9 50%, #8B5CF6 100%);
  --grad-card7: linear-gradient(145deg, #EC4899 0%, #DB2777 50%, #F472B6 100%);
  --grad-card8: linear-gradient(145deg, #14B8A6 0%, #0D9488 50%, #2DD4BF 100%);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 30px rgba(167,139,250,0.15);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --transition: 0.25s cubic-bezier(0.4,0,0.2,1);
  --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-serif: 'Georgia', 'Noto Serif SC', 'STSong', serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  min-height: 100dvh;
}

#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; position: relative; }

/* ==================== 登录/注册 ==================== */
.page-auth {
  display: none; min-height: 100dvh; position: relative;
  align-items: center; justify-content: center; padding: 24px;
  background: var(--bg-base);
}
.page-auth.active { display: flex; }

.auth-ambient {
  position: absolute; inset: 0; overflow: hidden; pointer-events: none;
}
.auth-orb {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.3;
}
.auth-orb.o1 {
  width: 280px; height: 280px; background: var(--accent-purple);
  top: 15%; left: -20%; animation: float1 8s ease-in-out infinite;
}
.auth-orb.o2 {
  width: 220px; height: 220px; background: var(--accent-pink);
  bottom: 10%; right: -15%; animation: float2 10s ease-in-out infinite;
}
.auth-orb.o3 {
  width: 160px; height: 160px; background: var(--accent-blue);
  top: 50%; left: 50%; transform: translate(-50%,-50%);
  animation: float3 12s ease-in-out infinite;
}
@keyframes float1 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(30px,-20px) scale(1.1); } }
@keyframes float2 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-20px,30px) scale(1.15); } }
@keyframes float3 { 0%,100% { transform: translate(-50%,-50%) scale(1); } 50% { transform: translate(-40%,-60%) scale(1.2); } }

.auth-card {
  position: relative; z-index: 1; width: 100%; max-width: 340px;
  background: rgba(21,21,37,0.8); backdrop-filter: blur(30px);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-xl);
  padding: 40px 28px 32px; box-shadow: var(--shadow-md);
}

.auth-brand { text-align: center; margin-bottom: 36px; }
.auth-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 60px; height: 60px; border-radius: 18px;
  background: var(--grad-hero); color: #FFF;
  font-size: 28px; font-weight: 800; margin-bottom: 16px;
  box-shadow: 0 8px 30px rgba(167,139,250,0.4);
}
.auth-brand h1 {
  font-size: 30px; font-weight: 800; letter-spacing: -1px;
  background: var(--grad-hero);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.auth-brand p { font-size: 13px; color: var(--text-tertiary); margin-top: 4px; }

.input-group { margin-bottom: 14px; position: relative; }
.input-group .input-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-tertiary); pointer-events: none;
}
.input-group input {
  width: 100%; padding: 14px 16px 14px 42px;
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm); font-size: 15px; color: var(--text-primary);
  outline: none; transition: all var(--transition); font-family: var(--font-sans);
}
.input-group input::placeholder { color: var(--text-tertiary); }
.input-group input:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 4px rgba(167,139,250,0.12);
  background: var(--bg-hover);
}

.btn-primary {
  width: 100%; padding: 14px; margin-top: 8px;
  background: var(--grad-hero); color: #FFF; border: none;
  border-radius: var(--radius-sm); font-size: 16px; font-weight: 700;
  cursor: pointer; letter-spacing: 1px; transition: all var(--transition);
  box-shadow: 0 4px 24px rgba(167,139,250,0.35);
  font-family: var(--font-sans);
}
.btn-primary:active { transform: scale(0.97); opacity: 0.9; }

.auth-link { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-tertiary); }
.auth-link a { color: var(--accent-purple); cursor: pointer; font-weight: 600; text-decoration: none; }

/* ==================== 顶栏 ==================== */
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  height: 52px; padding: 0 16px;
  background: rgba(12,12,20,0.85); backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
}
.topbar-title {
  font-size: 18px; font-weight: 800; letter-spacing: -0.5px;
  background: var(--grad-hero);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.topbar-btn {
  width: 38px; height: 38px; border: none; background: transparent;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); cursor: pointer; transition: all var(--transition);
}
.topbar-btn:active { background: rgba(255,255,255,0.05); }

/* ==================== 搜索栏 ==================== */
.search-bar { padding: 0 16px 12px; }
.search-wrap {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-elevated); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm); padding: 10px 14px;
  transition: all var(--transition);
}
.search-wrap:focus-within { border-color: var(--accent-purple); box-shadow: 0 0 0 3px rgba(167,139,250,0.1); }
.search-wrap svg { flex-shrink: 0; }
.search-wrap input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 14px; color: var(--text-primary); font-family: var(--font-sans);
}
.search-wrap input::placeholder { color: var(--text-tertiary); }
.search-wrap button { background: none; border: none; cursor: pointer; display: flex; padding: 2px; }

/* ==================== 书架 ==================== */
.shelf-hero {
  padding: 28px 20px 24px; position: relative; overflow: hidden;
}
.shelf-hero::after {
  content: ''; position: absolute; top: -60px; right: -40px;
  width: 200px; height: 200px; border-radius: 50%;
  background: rgba(167,139,250,0.08); filter: blur(60px); pointer-events: none;
}
.shelf-greeting { position: relative; z-index: 1; }
.shelf-greeting span {
  font-size: 13px; color: var(--text-tertiary); font-weight: 500; text-transform: uppercase; letter-spacing: 2px;
}
.shelf-greeting h2 {
  font-size: 28px; font-weight: 800; letter-spacing: -1px; margin-top: 4px;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-purple) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.shelf-stats { margin-top: 16px; display: flex; gap: 20px; }
.stat-item { text-align: center; }
.stat-num { font-size: 22px; font-weight: 800; color: var(--accent-purple); display: block; }
.stat-label { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }

.shelf-section { padding: 0 16px; }
.shelf-section-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}
.shelf-section-header h3 { font-size: 16px; font-weight: 700; }
.shelf-section-header span { font-size: 12px; color: var(--text-tertiary); background: var(--bg-elevated); padding: 4px 12px; border-radius: 20px; }

.novel-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }

.novel-card {
  background: var(--bg-elevated); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); overflow: hidden; cursor: pointer;
  transition: all var(--transition); position: relative;
}
.novel-card:hover { border-color: var(--border-default); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.novel-card:active { transform: scale(0.97); }

.novel-card-cover {
  height: 150px; display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}
.novel-card-cover::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 30%, rgba(0,0,0,0.55) 100%);
  z-index: 1;
}
.novel-card-cover .cover-shine {
  position: absolute; top: -30%; left: -30%; width: 80%; height: 120%;
  background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 60%);
  transform: rotate(25deg); z-index: 0;
}
.novel-card-cover span {
  font-size: 20px; font-weight: 800; color: rgba(255,255,255,0.92);
  z-index: 2; text-align: center; padding: 0 10px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.novel-card-body { padding: 14px; }
.novel-card-name { font-size: 14px; font-weight: 600; margin-bottom: 6px;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.novel-card-info { font-size: 11px; color: var(--text-tertiary); display: flex; align-items: center; gap: 6px; }
.novel-card-info .dot { width: 3px; height: 3px; background: var(--text-tertiary); border-radius: 50%; }

/* 阅读进度标签 */
.novel-progress-tag {
  position: absolute; top: 10px; right: 10px; z-index: 3;
  padding: 3px 10px; border-radius: 20px; font-size: 10px; font-weight: 600;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(10px);
  color: var(--accent-emerald); border: 1px solid rgba(52,211,153,0.3);
}

/* ==================== 空状态 ==================== */
.empty-state { text-align: center; padding: 64px 32px; }
.empty-state .empty-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 72px; height: 72px; border-radius: 24px;
  background: var(--bg-elevated); border: 1px solid var(--border-subtle);
  font-size: 32px; margin-bottom: 20px;
}
.empty-state h3 { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.empty-state p { font-size: 13px; color: var(--text-tertiary); }

/* ==================== 按钮 ==================== */
.btn-outline {
  padding: 10px 28px; background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border-default); border-radius: 50px;
  font-size: 13px; cursor: pointer; transition: all var(--transition); font-family: var(--font-sans);
}
.btn-outline:active { border-color: var(--accent-purple); color: var(--accent-purple); }
.load-more { text-align: center; padding: 28px 0; }

/* ==================== 阅读器 ==================== */
#pageReader { height: calc(100dvh - 52px); }

.reader-container { display: flex; flex-direction: column; height: 100%; }

.reader-header-bar {
  display: flex; align-items: center; padding: 6px 10px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
}
.reader-back, .reader-settings-btn {
  width: 36px; height: 36px; border: none; background: transparent;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); cursor: pointer; flex-shrink: 0;
}
.reader-back:active, .reader-settings-btn:active { background: rgba(255,255,255,0.05); }
.reader-title {
  flex: 1; text-align: center; font-size: 14px; color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 8px;
}

.reader-content {
  flex: 1; padding: 24px 18px 40px; overflow-y: auto;
  -webkit-overflow-scrolling: touch; font-size: 18px;
  line-height: 1.9; letter-spacing: 0.3px; font-family: var(--font-serif);
}
.reader-content .ch-title {
  font-size: 22px; font-weight: 700; text-align: center;
  margin-bottom: 32px; padding-bottom: 22px;
  border-bottom: 1px solid var(--border-subtle);
  letter-spacing: 1px;
}
.reader-content .ch-text { text-align: justify; }
.reader-content .ch-text p { text-indent: 2em; margin-bottom: 1em; }

/* 阅读器主题 */
body.theme-dark .reader-content { background: #0F0F1A; color: #C8C8D8; }
body.theme-dark .reader-header-bar { background: #0F0F1A; }

body.theme-warm .reader-content { background: #1C1814; color: #D4C5B0; }
body.theme-warm .reader-header-bar { background: #1C1814; }
body.theme-warm .reader-content .ch-title { border-color: rgba(212,197,176,0.1); }

body.theme-light .reader-content { background: #F8F6F0; color: #3D3628; }
body.theme-light .reader-header-bar { background: #F8F6F0; border-color: #E5E0D8; }
body.theme-light .reader-content .ch-title { border-color: #E5E0D8; }

.reader-bottom {
  background: var(--bg-elevated); border-top: 1px solid var(--border-subtle);
  padding: 10px 16px 20px;
}
.reader-progress { height: 2px; background: var(--border-subtle); border-radius: 1px; margin-bottom: 12px; }
.reader-progress-fill { height: 100%; border-radius: 1px; transition: width 0.3s; }
.reader-progress-fill.grad { background: var(--grad-hero); }
.reader-controls { display: flex; align-items: center; justify-content: space-between; }
.reader-nav-btn {
  padding: 8px 20px; background: transparent; border: 1px solid var(--border-default);
  border-radius: 8px; font-size: 13px; color: var(--text-secondary); cursor: pointer;
  transition: all var(--transition); font-family: var(--font-sans);
}
.reader-nav-btn:disabled { opacity: 0.25; }
.reader-nav-btn:not(:disabled):active { border-color: var(--accent-purple); color: var(--accent-purple); }
.reader-page { font-size: 12px; color: var(--text-tertiary); font-weight: 500; }

/* ==================== 设置面板 ==================== */
.settings-overlay { position: fixed; inset: 0; z-index: 300; display: flex; align-items: flex-end; }
.settings-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.settings-panel {
  position: relative; width: 100%; max-width: 480px; margin: 0 auto;
  background: var(--bg-elevated); border: 1px solid var(--border-subtle);
  border-radius: 20px 20px 0 0; padding: 24px 20px 36px;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.settings-panel h3 { font-size: 16px; font-weight: 700; margin-bottom: 22px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.settings-row > span { font-size: 14px; color: var(--text-secondary); }
.font-ctrl { display: flex; align-items: center; gap: 14px; }
.font-ctrl button {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border-default);
  background: transparent; color: var(--text-primary); font-size: 15px; font-weight: 600; cursor: pointer;
  transition: all var(--transition); font-family: var(--font-sans);
}
.font-ctrl button:active { border-color: var(--accent-purple); background: rgba(167,139,250,0.1); }
.font-ctrl span { font-size: 18px; font-weight: 700; color: var(--accent-purple); min-width: 36px; text-align: center; }
.theme-options { display: flex; gap: 8px; }
.theme-btn {
  padding: 8px 18px; border: 1px solid var(--border-default); border-radius: 8px;
  background: transparent; color: var(--text-tertiary); font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all var(--transition); font-family: var(--font-sans);
}
.theme-btn.active { border-color: var(--accent-purple); color: var(--accent-purple); background: rgba(167,139,250,0.08); }

/* ==================== 个人中心 ==================== */
.profile-hero {
  text-align: center; padding: 40px 20px 32px;
  position: relative; overflow: hidden;
}
.profile-hero::after {
  content: ''; position: absolute; top: -50%; left: 50%; transform: translateX(-50%);
  width: 250px; height: 250px; border-radius: 50%;
  background: rgba(167,139,250,0.06); filter: blur(60px); pointer-events: none;
}
.profile-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 72px; height: 72px; border-radius: 22px;
  background: var(--grad-hero); color: #FFF;
  font-size: 30px; font-weight: 800; margin-bottom: 16px;
  box-shadow: 0 8px 32px rgba(167,139,250,0.35);
  position: relative; z-index: 1;
}
.profile-hero h2 { font-size: 22px; font-weight: 700; position: relative; z-index: 1; }
.profile-badge {
  display: inline-block; margin-top: 6px; padding: 3px 14px;
  border: 1px solid var(--border-default); border-radius: 20px;
  font-size: 11px; color: var(--text-tertiary); position: relative; z-index: 1;
}

.profile-menu { padding: 4px 16px 24px; }
.menu-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; margin-bottom: 6px;
  background: var(--bg-elevated); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm); cursor: pointer;
  transition: all var(--transition);
}
.menu-item:active { border-color: var(--accent-purple); background: var(--bg-hover); }
.menu-item .menu-icon { font-size: 18px; margin-right: 12px; }
.menu-item .menu-label { flex: 1; font-size: 14px; font-weight: 500; }
.menu-item .menu-arrow { color: var(--text-tertiary); }

/* ==================== Toast ==================== */
.toast {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%) translateY(-120px);
  z-index: 999; padding: 12px 24px; border-radius: 12px; font-size: 13px; font-weight: 500;
  background: var(--bg-elevated); color: var(--text-primary);
  border: 1px solid var(--border-default); box-shadow: var(--shadow-md);
  transition: transform 0.35s cubic-bezier(0.175,0.885,0.32,1.275);
  pointer-events: none; white-space: nowrap; font-family: var(--font-sans);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--accent-rose); color: var(--accent-rose); }
.toast.success { border-color: var(--accent-emerald); color: var(--accent-emerald); }

/* ==================== 通用 ==================== */
.page { display: none; animation: fadeIn 0.3s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

::-webkit-scrollbar { width: 0; }

@media (min-width: 481px) {
  #app { border-left: 1px solid var(--border-subtle); border-right: 1px solid var(--border-subtle); }
  .novel-grid { grid-template-columns: repeat(3, 1fr); }
}
