/* ── CSS Custom Properties ── */
:root {
  --color-bg: #faf8f5;
  --color-surface: #ffffff;
  --color-text: #2d2a26;
  --color-text-secondary: #6b6560;
  --color-text-muted: #999390;
  --color-primary: #c4734f;
  --color-primary-light: #e8c4a8;
  --color-primary-dark: #a05a3a;
  --color-accent: #d4956a;
  --color-border: #e8e3dd;
  --color-ring: #f0ebe4;
  --color-danger: #d94a4a;
  --color-success: #5a9e6f;
  --font-serif: "Noto Serif SC", "Source Han Serif SC", Georgia, "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.10);
  --radius: 10px;
  --radius-sm: 6px;
  --max-width: 720px;
  --topbar-height: 56px;
  --player-height: 80px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.65;
  min-height: 100vh;
  padding-top: var(--topbar-height);
  padding-bottom: 0;
  -webkit-font-smoothing: antialiased;
}

body.player-visible { padding-bottom: var(--player-height); }

a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-dark); }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, select { font-family: inherit; }

.hidden { display: none !important; }

/* ── Top Bar ── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  height: var(--topbar-height);
}
.topbar-inner {
  max-width: var(--max-width); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  height: 100%; padding: 0 20px;
}
.nav-brand {
  font-family: var(--font-serif);
  font-weight: 700; font-size: 1.05rem;
  color: var(--color-primary-dark);
  white-space: nowrap;
}
.nav-links { display: flex; gap: 4px; }
.nav-link {
  padding: 6px 14px; border-radius: 20px;
  font-size: 0.875rem; color: var(--color-text-secondary);
  transition: background 0.15s, color 0.15s; cursor: pointer;
}
.nav-link:hover, .nav-link.active {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}
.nav-actions { display: flex; align-items: center; gap: 8px; }

.lang-toggle {
  background: none; border: 1px solid var(--color-border);
  padding: 4px 10px; border-radius: 14px;
  font-size: 0.75rem; font-weight: 600;
  color: var(--color-text-secondary);
  transition: border-color 0.15s;
}
.lang-toggle:hover { border-color: var(--color-primary); }

.btn-login, .btn-logout {
  padding: 6px 14px; border-radius: 20px; border: none;
  font-size: 0.8rem; font-weight: 600;
  background: var(--color-primary); color: #fff;
  transition: background 0.15s;
}
.btn-login:hover { background: var(--color-primary-dark); }
.btn-logout { background: transparent; color: var(--color-text-muted); font-weight: 500; }
.btn-logout:hover { color: var(--color-danger); background: none; }

.user-menu { display: flex; align-items: center; gap: 6px; }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.user-name { font-size: 0.8rem; color: var(--color-text-secondary); max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Sections ── */
.section { max-width: var(--max-width); margin: 0 auto; padding: 40px 20px 60px; }
.section-header { margin-bottom: 32px; }
.section-header h2 {
  font-family: var(--font-serif);
  font-size: 1.8rem; font-weight: 700;
  color: var(--color-text);
}

/* ── Hero ── */
.hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 48px 0 32px; }
.hero-cover { margin-bottom: 28px; }
.hero-cover-placeholder {
  width: 160px; height: 160px; border-radius: 24px;
  background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary));
  display: flex; align-items: center; justify-content: center;
  font-size: 4rem; box-shadow: var(--shadow-lg);
}
.hero-title {
  font-family: var(--font-serif);
  font-size: 2.2rem; font-weight: 800;
  color: var(--color-text); margin-bottom: 8px;
  line-height: 1.3;
}
.hero-divider { color: var(--color-primary); margin: 0 4px; }
.hero-subtitle { font-size: 1.05rem; color: var(--color-primary); font-weight: 500; margin-bottom: 12px; }
.hero-desc { font-size: 0.9rem; color: var(--color-text-secondary); max-width: 440px; line-height: 1.7; margin-bottom: 28px; }

.hero-actions { margin-bottom: 28px; }
.btn-cta {
  display: inline-block; padding: 14px 40px;
  background: var(--color-primary); color: #fff;
  border: none; border-radius: 28px;
  font-size: 1rem; font-weight: 600;
  box-shadow: var(--shadow-md);
  transition: background 0.15s, transform 0.1s;
}
.btn-cta:hover { background: var(--color-primary-dark); transform: translateY(-1px); }

.hero-latest {
  padding: 14px 24px; background: var(--color-surface);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  display: flex; gap: 10px; align-items: center;
}
.latest-label { font-size: 0.75rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.latest-title { font-size: 0.9rem; color: var(--color-text-secondary); font-weight: 500; }

/* ── Episodes Grid ── */
.episodes-grid { display: flex; flex-direction: column; gap: 16px; }
.episodes-empty { text-align: center; color: var(--color-text-muted); padding: 48px 0; }

.episode-card {
  display: flex; gap: 16px; padding: 16px;
  background: var(--color-surface); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
  align-items: center;
}
.episode-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.episode-card-image {
  width: 72px; height: 72px; border-radius: var(--radius-sm);
  object-fit: cover; flex-shrink: 0;
  background: var(--color-ring);
}
.episode-card-info { flex: 1; min-width: 0; }
.episode-card-title {
  font-weight: 600; font-size: 0.95rem;
  margin-bottom: 4px; color: var(--color-text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.episode-card-meta {
  font-size: 0.78rem; color: var(--color-text-muted);
}
.episode-card-play {
  width: 36px; height: 36px; border-radius: 50%;
  border: none; background: var(--color-primary);
  color: #fff; font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background 0.15s;
}
.episode-card-play:hover { background: var(--color-primary-dark); }
.episode-card-play.playing { background: var(--color-danger); }

/* ── About ── */
.about-content { max-width: 600px; }
.about-content h2 {
  font-family: var(--font-serif);
  font-size: 1.8rem; margin-bottom: 32px;
}
.about-block { margin-bottom: 28px; }
.about-block h3 {
  font-size: 1.05rem; font-weight: 700;
  color: var(--color-primary-dark); margin-bottom: 8px;
}
.about-block p { font-size: 0.9rem; color: var(--color-text-secondary); line-height: 1.75; }
.contact-links { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.contact-link { font-size: 0.9rem; color: var(--color-primary); }

/* ── Audio Player ── */
.audio-player {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  background: var(--color-surface); border-top: 1px solid var(--color-border);
  box-shadow: 0 -2px 16px rgba(0,0,0,0.06);
  padding: 10px 20px; transition: transform 0.3s ease;
}
.audio-player.collapsed { transform: translateY(100%); }
.player-close {
  position: absolute; top: 4px; right: 12px;
  background: none; border: none; font-size: 0.85rem;
  color: var(--color-text-muted); padding: 4px;
}
.player-inner {
  max-width: var(--max-width); margin: 0 auto;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.player-artwork { flex-shrink: 0; }
.player-artwork img {
  width: 48px; height: 48px; border-radius: 8px; object-fit: cover;
}
.player-artwork-fallback {
  width: 48px; height: 48px; border-radius: 8px;
  background: var(--color-primary-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
}
.player-info { flex: 1; min-width: 0; }
.player-title {
  font-size: 0.85rem; font-weight: 600; color: var(--color-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block;
}
.player-meta { font-size: 0.7rem; color: var(--color-text-muted); }

.player-controls { display: flex; align-items: center; gap: 4px; }
.player-btn {
  background: none; border: none; font-size: 1rem; padding: 6px;
  color: var(--color-text-secondary); transition: color 0.15s;
}
.player-btn:hover { color: var(--color-primary); }
.player-btn-play {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--color-primary); color: #fff !important;
  font-size: 0.85rem; display: flex; align-items: center; justify-content: center;
}
.player-btn-play:hover { background: var(--color-primary-dark); }

.player-progress-container {
  width: 100%; display: flex; align-items: center; gap: 10px;
}
.player-time { font-size: 0.7rem; color: var(--color-text-muted); font-variant-numeric: tabular-nums; min-width: 36px; }
.progress-bar-wrapper { flex: 1; position: relative; height: 20px; display: flex; align-items: center; }
.progress-bar-bg {
  width: 100%; height: 5px; background: var(--color-ring);
  border-radius: 3px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; background: var(--color-primary);
  border-radius: 3px; width: 0%; transition: width 0.1s linear;
}
.progress-seek {
  position: absolute; inset: 0; width: 100%;
  opacity: 0; cursor: pointer; margin: 0;
}
.progress-seek::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--color-primary); cursor: pointer; }
.progress-seek::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--color-primary); cursor: pointer; border: none; }

.player-extras { display: flex; align-items: center; gap: 12px; }
.player-speed {
  padding: 3px 6px; border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); font-size: 0.75rem;
  background: var(--color-surface); color: var(--color-text-secondary);
}
.player-volume-wrap { display: flex; align-items: center; gap: 4px; }
.player-volume { width: 60px; accent-color: var(--color-primary); }
.player-btn-volume { font-size: 0.9rem; padding: 4px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.4); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--color-surface); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 400px;
  padding: 32px 28px; position: relative;
}
.modal-close {
  position: absolute; top: 12px; right: 16px;
  background: none; border: none; font-size: 1.1rem;
  color: var(--color-text-muted);
}
.modal-title {
  font-family: var(--font-serif); font-size: 1.3rem;
  text-align: center; margin-bottom: 24px;
}

.auth-tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--color-border); }
.auth-tab {
  flex: 1; padding: 10px 8px; border: none; background: none;
  font-size: 0.8rem; font-weight: 600; color: var(--color-text-muted);
  border-bottom: 2px solid transparent; transition: color 0.15s, border-color 0.15s;
}
.auth-tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

.auth-panel { display: none; text-align: center; }
.auth-panel.active { display: block; }
.auth-hint { font-size: 0.85rem; color: var(--color-text-secondary); margin-bottom: 16px; }
.auth-note { font-size: 0.72rem; color: var(--color-text-muted); margin-top: 12px; }

.auth-wechat-btn, .auth-google-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 28px; border-radius: 24px; font-weight: 600;
  font-size: 0.9rem; transition: background 0.15s;
}
.auth-wechat-btn {
  background: #07c160; color: #fff;
}
.auth-wechat-btn:hover { background: #06a050; color: #fff; }
.auth-google-btn {
  background: #fff; color: var(--color-text);
  border: 1px solid var(--color-border); box-shadow: var(--shadow-sm);
}
.auth-google-btn:hover { background: #f8f8f8; color: var(--color-text); }

.auth-form { text-align: left; }
.form-subtabs { display: flex; gap: 0; margin-bottom: 16px; border-bottom: 1px solid var(--color-border); }
.form-subtab {
  flex: 1; padding: 8px; border: none; background: none;
  font-size: 0.8rem; font-weight: 600; color: var(--color-text-muted);
  border-bottom: 2px solid transparent; text-align: center;
}
.form-subtab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

.form-field { margin-bottom: 14px; }
.form-field label {
  display: block; font-size: 0.78rem; color: var(--color-text-secondary);
  margin-bottom: 4px; font-weight: 500;
}
.form-field input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); font-size: 0.9rem;
  color: var(--color-text); background: var(--color-bg);
  outline: none; transition: border-color 0.15s;
}
.form-field input:focus { border-color: var(--color-primary); }
.form-error { color: var(--color-danger); font-size: 0.78rem; margin-bottom: 12px; }

.auth-submit {
  width: 100%; padding: 12px; border: none; border-radius: 24px;
  background: var(--color-primary); color: #fff;
  font-size: 0.9rem; font-weight: 600;
  transition: background 0.15s;
}
.auth-submit:hover { background: var(--color-primary-dark); }

/* ── Episode Detail ── */
.back-link {
  display: inline-block; padding: 6px 0; margin-bottom: 20px;
  background: none; border: none; color: var(--color-primary);
  font-size: 0.9rem; cursor: pointer; font-weight: 500;
}
.back-link:hover { color: var(--color-primary-dark); }

.episode-detail { max-width: 680px; }
.episode-detail-loading { text-align: center; padding: 60px 0; color: var(--color-text-muted); }

.detail-header { display: flex; gap: 24px; margin-bottom: 32px; align-items: flex-start; }
.detail-cover {
  width: 180px; height: 180px; border-radius: var(--radius); object-fit: cover;
  flex-shrink: 0; background: var(--color-ring);
}
.detail-header-info { flex: 1; min-width: 0; }
.detail-title {
  font-family: var(--font-serif); font-size: 1.5rem; font-weight: 700;
  line-height: 1.35; margin-bottom: 8px; color: var(--color-text);
}
.detail-meta { font-size: 0.82rem; color: var(--color-text-muted); margin-bottom: 12px; display: flex; gap: 4px; flex-wrap: wrap; }
.detail-desc { font-size: 0.9rem; color: var(--color-text-secondary); line-height: 1.7; margin-bottom: 16px; }
.detail-play-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 24px; background: var(--color-primary); color: #fff;
  border: none; border-radius: 24px; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; transition: background 0.15s;
}
.detail-play-btn:hover { background: var(--color-primary-dark); }

/* Show Notes */
.detail-shownotes { margin-bottom: 40px; padding-top: 24px; border-top: 1px solid var(--color-border); }
.detail-shownotes h3 {
  font-family: var(--font-serif); font-size: 1.2rem; font-weight: 700;
  margin-bottom: 16px; color: var(--color-text);
}
.shownotes-content { font-size: 0.9rem; line-height: 1.85; color: var(--color-text-secondary); }
.shownotes-content p { margin-bottom: 12px; }
.shownotes-content ul, .shownotes-content ol { margin: 8px 0 16px 20px; }
.shownotes-content li { margin-bottom: 6px; }
.shownotes-content strong { color: var(--color-text); }
.shownotes-content a { color: var(--color-primary); word-break: break-all; }

/* ── Comments ── */
.detail-comments { margin-bottom: 48px; }
.detail-comments h3 {
  font-family: var(--font-serif); font-size: 1.2rem; font-weight: 700;
  margin-bottom: 16px; color: var(--color-text);
}

.comments-list { display: flex; flex-direction: column; gap: 16px; margin-bottom: 24px; }
.comments-empty { color: var(--color-text-muted); font-size: 0.85rem; text-align: center; padding: 24px 0; }

.comment-item { display: flex; gap: 12px; align-items: flex-start; }
.comment-avatar { flex-shrink: 0; margin-top: 2px; }
.comment-body { flex: 1; min-width: 0; }
.comment-header { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.comment-author { font-size: 0.85rem; font-weight: 600; color: var(--color-text); }
.comment-date { font-size: 0.72rem; color: var(--color-text-muted); }
.comment-text { font-size: 0.88rem; color: var(--color-text-secondary); line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.comment-delete {
  background: none; border: none; font-size: 0.72rem; color: var(--color-text-muted);
  cursor: pointer; padding: 0; margin-top: 4px;
}
.comment-delete:hover { color: var(--color-danger); }

.comment-login-hint { text-align: center; font-size: 0.85rem; color: var(--color-text-muted); padding: 16px 0; }
.comment-login-hint a { color: var(--color-primary); font-weight: 500; }

.comment-form { display: flex; flex-direction: column; gap: 10px; }
.comment-form textarea {
  width: 100%; padding: 12px; border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); font-size: 0.9rem; font-family: inherit;
  color: var(--color-text); background: var(--color-bg);
  resize: vertical; outline: none; transition: border-color 0.15s;
}
.comment-form textarea:focus { border-color: var(--color-primary); }
.comment-submit {
  align-self: flex-end; padding: 8px 20px;
  background: var(--color-primary); color: #fff;
  border: none; border-radius: 20px; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; transition: background 0.15s;
}
.comment-submit:hover { background: var(--color-primary-dark); }

/* ── Footer ── */
.site-footer {
  border-top: 1px solid var(--color-border);
  background: var(--color-surface); padding: 40px 20px 24px;
  margin-top: 60px;
}
.footer-inner {
  max-width: var(--max-width); margin: 0 auto;
  display: flex; gap: 40px; flex-wrap: wrap; justify-content: space-between;
}
.footer-col { min-width: 140px; }
.footer-col h4 { font-size: 0.9rem; font-weight: 700; color: var(--color-text); margin-bottom: 10px; }
.footer-col p { font-size: 0.8rem; color: var(--color-text-secondary); }
.footer-link {
  display: block; font-size: 0.8rem; color: var(--color-text-secondary);
  margin-bottom: 6px; text-decoration: none;
}
.footer-link:hover { color: var(--color-primary); }
.footer-bottom {
  max-width: var(--max-width); margin: 24px auto 0;
  padding-top: 16px; border-top: 1px solid var(--color-border);
  text-align: center; font-size: 0.75rem; color: var(--color-text-muted);
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .detail-header { flex-direction: column; align-items: center; text-align: center; }
  .detail-cover { width: 140px; height: 140px; }
  .detail-title { font-size: 1.25rem; }
  .detail-meta { justify-content: center; }
  .footer-inner { flex-direction: column; gap: 20px; }
  .footer-col { text-align: center; }

  .topbar-inner { padding: 0 12px; }
  .nav-link { padding: 4px 10px; font-size: 0.8rem; }
  .nav-brand { font-size: 0.9rem; }
  .hero-title { font-size: 1.6rem; }
  .hero-cover-placeholder { width: 120px; height: 120px; font-size: 3rem; }
  .hero { padding: 28px 0 20px; }
  .section { padding: 24px 16px 48px; }
  .episode-card { padding: 12px; gap: 10px; }
  .episode-card-image { width: 56px; height: 56px; }
  .episode-card-title { font-size: 0.85rem; }
  .player-inner { gap: 8px; }
  .player-progress-container { order: 10; }
  .player-extras { width: 100%; justify-content: center; }
  .player-info { flex: 0 0 auto; width: calc(100% - 140px); }
}

@media (max-width: 380px) {
  .nav-links { gap: 0; }
  .nav-link { padding: 4px 7px; font-size: 0.75rem; }
  .nav-brand { font-size: 0.8rem; }
  .hero-title { font-size: 1.4rem; }
}
