:root {
  --bg-primary: #0f172a;
  --bg-card: #1e293b;
  --bg-sidebar: #0f172a;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --accent-color: #38bdf8;
  --accent-glow: rgba(56, 189, 248, 0.25);
  --border-color: #334155;
  --highlight-bg: rgba(56, 189, 248, 0.15);
  --highlight-border: #38bdf8;
  --shadow-color: rgba(0, 0, 0, 0.3);
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --accent-color: #0284c7;
  --accent-glow: rgba(2, 132, 199, 0.15);
  --border-color: #e2e8f0;
  --highlight-bg: rgba(2, 132, 199, 0.1);
  --highlight-border: #0284c7;
  --shadow-color: rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.8;
  transition: background-color 0.3s, color 0.3s;
}

/* Reading Progress Bar */
#progress-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: transparent;
  z-index: 1000;
}

#progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  transition: width 0.1s ease;
}

/* Header Navbar */
.top-header {
  position: sticky;
  top: 0;
  z-index: 900;
  backdrop-filter: blur(12px);
  background: rgba(15, 23, 42, 0.85);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

[data-theme="light"] .top-header {
  background: rgba(248, 250, 252, 0.85);
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-badge {
  background: linear-gradient(135deg, #0284c7, #6366f1);
  color: #ffffff;
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #3b82f6);
  color: #ffffff;
  border: none;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0369a1, #2563eb);
  color: #ffffff;
  box-shadow: 0 4px 12px var(--accent-glow);
}

/* Layout Container */
.main-container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 40px 24px 140px 24px;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 40px;
}

@media (max-width: 900px) {
  .main-container {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
  }
}

/* Sidebar Toc */
.sidebar {
  position: sticky;
  top: 90px;
  height: calc(100vh - 120px);
  overflow-y: auto;
  padding-right: 16px;
}

.toc-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 4px 20px var(--shadow-color);
}

.toc-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toc-item a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.88rem;
  display: block;
  padding: 6px 10px;
  border-radius: 6px;
  transition: all 0.2s ease;
  line-height: 1.4;
}

.toc-item a:hover, .toc-item a.active {
  background: var(--highlight-bg);
  color: var(--accent-color);
  font-weight: 600;
}

/* Document Content */
.content-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 48px;
  box-shadow: 0 8px 30px var(--shadow-color);
}

.article-header {
  text-align: center;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 30px;
  margin-bottom: 40px;
}

.article-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 16px;
  line-height: 1.35;
}

.article-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.markdown-body h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 40px;
  margin-bottom: 20px;
  padding-left: 14px;
  border-left: 4px solid var(--accent-color);
  scroll-margin-top: 100px;
}

.markdown-body h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-top: 24px;
  margin-bottom: 12px;
}

.readable-para {
  margin-bottom: 18px;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background-color 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
  cursor: pointer;
  position: relative;
}

.readable-para:hover {
  background-color: var(--highlight-bg);
}

.readable-para.reading-active {
  background-color: var(--highlight-bg);
  border-left: 4px solid var(--highlight-border);
  box-shadow: 0 2px 12px var(--accent-glow);
}

.readable-para.reading-active::after {
  content: "🔊 正在朗读";
  position: absolute;
  right: 12px;
  top: 10px;
  font-size: 0.75rem;
  color: var(--accent-color);
  font-weight: 600;
}

blockquote {
  background: var(--bg-primary);
  border-left: 4px solid var(--border-color);
  padding: 16px 20px;
  border-radius: 0 8px 8px 0;
  color: var(--text-secondary);
  margin: 20px 0;
  font-size: 0.95rem;
}

/* Audio Sticky Control Bar */
.audio-player-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 800px;
  background: rgba(30, 41, 59, 0.92);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 16px 24px;
  z-index: 1000;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

[data-theme="light"] .audio-player-bar {
  background: rgba(255, 255, 255, 0.92);
}

.player-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.player-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.play-status-icon {
  font-size: 1.4rem;
}

.status-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.status-para {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 250px;
}

.control-btns {
  display: flex;
  align-items: center;
  gap: 10px;
}

.voice-select-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.select-input {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  outline: none;
}

/* Modal Drawer for Voice Preview */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: none;
  justify-content: center;
  align-items: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 90%;
  max-width: 560px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
}

.voice-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 6px;
}

.voice-item {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease;
}

.voice-item:hover {
  border-color: var(--accent-color);
}

.voice-item.selected {
  border-color: var(--accent-color);
  background: var(--highlight-bg);
}

.voice-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.voice-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.voice-tag {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.voice-actions {
  display: flex;
  gap: 8px;
}
