/* 温润纸感书卷风：低饱和、单焦点、去套娃边框 */
:root {
  --bg: #FAF7F2;
  --surface: #F3EDE3;
  --surface-elevated: #FFFFFF;
  --text: #1E1B18;
  --text-secondary: #686058;
  --text-muted: #9A9086;
  --accent: #B45309;
  --accent-soft: #F3E5D0;
  --accent-ink: #8C3D06;
  --divider: rgba(30, 27, 24, 0.08);
  --dock-bg: rgba(250, 247, 242, 0.92);
  --shadow-soft: 0 8px 28px rgba(30, 27, 24, 0.08);

  --cue-size: 18px;
  --cue-line: 1.75;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --font-serif: "Songti SC", "Noto Serif SC", "STSong", Georgia, serif;
}

[data-theme="dark"] {
  --bg: #141210;
  --surface: #1F1C19;
  --surface-elevated: #272320;
  --text: #E9E2D8;
  --text-secondary: #A69D93;
  --text-muted: #706860;
  --accent: #D97736;
  --accent-soft: rgba(217, 119, 54, 0.16);
  --accent-ink: #F19B60;
  --divider: rgba(233, 226, 216, 0.08);
  --dock-bg: rgba(20, 18, 16, 0.92);
  --shadow-soft: 0 10px 32px rgba(0, 0, 0, 0.45);
}

[data-font="sm"] {
  --cue-size: 16px;
  --cue-line: 1.7;
}

[data-font="md"] {
  --cue-size: 18px;
  --cue-line: 1.78;
}

[data-font="lg"] {
  --cue-size: 21px;
  --cue-line: 1.82;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* ========== 口令门禁 ========== */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.auth-mark {
  width: 52px;
  height: 52px;
  margin: 0 auto 18px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
}

.auth-title {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.auth-sub {
  margin: 0 0 28px;
  font-size: 14px;
  color: var(--text-secondary);
}

.auth-form {
  display: flex;
  gap: 10px;
}

.auth-form input {
  flex: 1;
  height: 48px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--divider);
  background: var(--surface-elevated);
  color: var(--text);
  font-size: 18px;
  letter-spacing: 0.2em;
  text-align: center;
  outline: none;
}

.auth-form input:focus {
  border-color: var(--accent);
}

.auth-submit {
  height: 48px;
  padding: 0 22px;
  border-radius: 12px;
  background: var(--accent);
  color: #FFF;
  font-size: 15px;
  font-weight: 600;
}

.auth-error {
  min-height: 20px;
  margin: 12px 0 0;
  font-size: 13px;
  color: #C2410C;
}

/* ========== 主应用布局 ========== */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
}

/* 顶栏 */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  height: calc(54px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0;
  background: var(--dock-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--divider);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.icon-btn:active {
  background: var(--surface);
}

.top-title-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.ep-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-secondary);
}

.ep-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.sleep-pill {
  height: 36px;
  padding: 0 10px;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-secondary);
}

.sleep-pill.active {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.sleep-label {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.sleep-label:empty {
  display: none;
}

/* ========== 阅读正文区 ========== */
.reader-viewport {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.reader-container {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 18px 160px;
}

.ep-hero {
  padding: 4px 12px 24px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--divider);
}

.hero-meta {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 8px;
}

.hero-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 24px;
  line-height: 1.38;
  font-weight: 700;
  color: var(--text);
}

.cue-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cue-item {
  position: relative;
  padding: 10px 14px 10px 16px;
  border-radius: 12px;
  font-size: var(--cue-size);
  line-height: var(--cue-line);
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.22s ease, color 0.22s ease;
  border-left: 3px solid transparent;
  user-select: text;
}

.cue-item:hover {
  background: rgba(180, 83, 9, 0.04);
}

.cue-item:active {
  background: var(--surface);
}

/* 唯一第一焦点：当前朗读句 */
.cue-item.is-active {
  background: var(--accent-soft);
  border-left-color: var(--accent);
  color: var(--text);
  font-weight: 500;
}

.cue-item.is-past {
  color: var(--text-secondary);
}

.cue-ts {
  display: inline-block;
  margin-right: 8px;
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  vertical-align: 1px;
  user-select: none;
}

.cue-item.is-active .cue-ts {
  color: var(--accent-ink);
  font-weight: 600;
}

.loading-state {
  padding: 64px 0;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
}

.ep-footer-nav {
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid var(--divider);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.ep-nav-btn {
  flex: 1;
  height: 44px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}

.ep-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* 回到当前句轻胶囊 */
.return-pill {
  position: fixed;
  left: 50%;
  bottom: calc(136px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 25;
  height: 36px;
  padding: 0 14px;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-soft);
}

/* ========== 底部紧凑播放控台 ========== */
.player-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 10px 18px calc(12px + env(safe-area-inset-bottom));
  background: var(--dock-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--divider);
}

.progress-row,
.controls-row {
  max-width: 680px;
  margin: 0 auto;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.time-text {
  width: 46px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.time-text:last-child {
  text-align: right;
}

.seek-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--divider);
  outline: none;
  accent-color: var(--accent);
}

.seek-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

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

.ctrl-btn {
  width: 44px;
  height: 44px;
  border-radius: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}

.ctrl-btn:active {
  background: var(--surface);
}

.play-btn {
  width: 52px;
  height: 52px;
  border-radius: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #FFF;
  box-shadow: 0 4px 14px rgba(180, 83, 9, 0.28);
}

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

.ctrl-chip {
  min-width: 64px;
  height: 34px;
  padding: 0 11px;
  border-radius: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface);
}

.ctrl-chip.sync-on {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

/* ========== 遮罩与选集抽屉 ========== */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(15, 12, 10, 0.42);
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
  width: min(86vw, 380px);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding-top: env(safe-area-inset-top);
  box-shadow: var(--shadow-soft);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 12px 18px;
}

.drawer-title {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 700;
}

.drawer-sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
}

.drawer-search-wrap {
  padding: 0 16px 12px;
}

.drawer-search {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--divider);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.episode-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px calc(24px + env(safe-area-inset-bottom));
}

.section-heading {
  padding: 14px 8px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.ep-row {
  width: 100%;
  text-align: left;
  padding: 11px 10px;
  border-radius: 10px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.ep-row.current {
  background: var(--accent-soft);
}

.ep-row-num {
  width: 24px;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  padding-top: 2px;
}

.ep-row.current .ep-row-num {
  color: var(--accent-ink);
}

.ep-row-body {
  flex: 1;
  min-width: 0;
}

.ep-row-title {
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
}

.ep-row-meta {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.ep-row-bar {
  width: 48px;
  height: 3px;
  border-radius: 2px;
  background: var(--divider);
  overflow: hidden;
}

.ep-row-bar-fill {
  height: 100%;
  background: var(--accent);
}

/* ========== 底部弹出面板（定时 / 显示） ========== */
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  max-width: 520px;
  margin: 0 auto;
  padding: 18px 18px calc(24px + env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0;
  background: var(--surface-elevated);
  box-shadow: var(--shadow-soft);
}

.sheet-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

.sheet-title {
  font-size: 16px;
  font-weight: 700;
}

.sheet-sub {
  font-size: 13px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.sheet-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.sheet-opt {
  height: 44px;
  border-radius: 12px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.sheet-opt.selected {
  background: var(--accent);
  color: #FFF;
}

.sheet-opt-cancel {
  color: var(--text-secondary);
}

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

.display-label {
  font-size: 14px;
  color: var(--text-secondary);
}

.seg-group {
  display: inline-flex;
  gap: 6px;
  background: var(--surface);
  padding: 4px;
  border-radius: 12px;
}

.seg-btn {
  min-width: 64px;
  height: 34px;
  padding: 0 12px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.seg-btn.active {
  background: var(--surface-elevated);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* Toast */
.toast {
  position: fixed;
  top: calc(68px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  padding: 8px 16px;
  border-radius: 20px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-soft);
  white-space: nowrap;
}
