/* MindForge MVP Styles */

/* ============================================
   Base Styles
   ============================================ */
:root {
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --secondary: #6B7280;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --bg: #F9FAFB;
  --bg-card: #FFFFFF;
  --text: #1F2937;
  --text-secondary: #6B7280;
  --border: #E5E7EB;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --radius: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ============================================
   Utilities
   ============================================ */
.hidden {
  display: none !important;
}

/* ============================================
   Loading
   ============================================ */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 1rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

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

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-text {
  background: transparent;
  color: var(--text-secondary);
}

.btn-text:hover {
  color: var(--text);
}

.queue-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.queue-badge {
  display: inline-block;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  background: var(--primary);
  color: white;
  border-radius: 8px;
  padding: 0 4px;
  position: absolute;
  top: -4px;
  right: -8px;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #DC2626;
}

.btn-danger:disabled {
  background: #FCA5A5;
  cursor: not-allowed;
}

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

/* ============================================
   Header
   ============================================ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav-back-link {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-size: 13px;
  color: var(--text-secondary);
}

.nav-back-link:hover {
  color: var(--primary);
  background: rgba(79, 70, 229, 0.1);
}

.title {
  font-size: 1.125rem;
  font-weight: 600;
}

/* ============================================
   Main Content
   ============================================ */
.main {
  min-height: 100vh;
  padding-bottom: 60px;
  position: relative;
}

/* 右侧面板容器 - 移除旧样式，因为现在用 .sentence-panel */
/* .sidebar 已废弃 */

/* Reader container - 固定高度容器 */
.reader {
  display: flex;
  flex: 1;
  height: calc(100vh - 120px);
  overflow: hidden;
  position: relative;
}

/* ============================================
   左侧目录面板
   ============================================ */
.toc-panel {
  width: 25%;
  max-width: 33%;
  min-width: 180px;
  height: 100%;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: none;
  position: relative;
  z-index: 10;
}

.toc-panel.collapsed {
  width: 0;
  min-width: 0;
  border-right: none;
  overflow: hidden;
}

.toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--primary);
  color: white;
  flex-shrink: 0;
}

.toc-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.btn-toc-show {
  position: fixed;
  left: 0;
  top: 45%;
  transform: translateY(-50%);
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.5rem 0.35rem;
  cursor: pointer;
  font-size: 1rem;
  z-index: 100;
  box-shadow: 2px 0 8px rgba(0,0,0,0.15);
  transition: opacity 0.3s ease, left 0.3s ease;
}

.toc-panel:not(.collapsed) ~ .btn-toc-show {
  opacity: 0;
  pointer-events: none;
}

.toc-content {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}

/* 目录章节项 */
.toc-chapter {
  border-bottom: 1px solid var(--border);
}

.toc-chapter-header {
  display: flex;
  align-items: center;
  padding: 0.6rem 1rem;
  cursor: pointer;
  background: var(--bg);
  transition: background 0.15s;
}

.toc-chapter-header:hover {
  background: var(--bg-card);
}

.toc-chapter-header.active {
  background: rgba(79, 70, 229, 0.1);
  color: var(--primary);
}

.toc-chapter-title {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 500;
}

.toc-chapter-arrow {
  font-size: 0.7rem;
  color: var(--text-secondary);
  transition: transform 0.2s;
}

.toc-chapter.expanded .toc-chapter-arrow {
  transform: rotate(90deg);
}

/* 目录小节项 */
.toc-sections {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  background: var(--bg-card);
}

.toc-chapter.expanded .toc-sections {
  max-height: 500px;
}

.toc-section {
  padding: 0.4rem 1rem 0.4rem 2rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.toc-section:hover {
  background: rgba(79, 70, 229, 0.05);
  color: var(--primary);
}

.toc-section.active {
  background: var(--primary);
  color: white;
}

.toc-section-number {
  margin-right: 0.5rem;
  opacity: 0.6;
}

/* ============================================
   小节导航（替代章节导航）
   ============================================ */
.section-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.75rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.section-info {
  min-width: 160px;
  text-align: center;
}

#section-indicator {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

/* 左侧阅读区 - 可滚动 */
.reader-main {
  flex: 1;
  min-width: 300px;
  height: 100%;
  overflow-y: auto;
  padding: 0;
}

/* 右侧分析面板 - 固定不滚动 */
.sentence-panel {
  position: relative;
  width: 25%;
  max-width: 33%;
  min-width: 240px;
  height: 100%;
  background: #fff;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0; /* 防止被压缩 */
}

/* ============================================
   Resize Handles (拖拽调整面板宽度)
   ============================================ */
.resize-handle {
  position: absolute;
  top: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 20;
  transition: background 0.15s;
}

.resize-handle:hover,
.resize-handle.active {
  background: var(--primary);
  opacity: 0.6;
}

.resize-handle-right {
  right: -3px;
}

.resize-handle-left {
  left: -3px;
}

.sentence-panel.hidden {
  display: none;
}

/* Book Info */
.book-info {
  text-align: center;
  padding: 1.5rem 1rem;
  background: linear-gradient(135deg, var(--primary), #818CF8);
  color: white;
}

#book-title {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

#book-author {
  font-size: 0.875rem;
  opacity: 0.9;
}

/* Content */
.content {
  padding: 1rem;
  max-width: 100%;
  margin: 0 auto;
}

.segment {
  margin-bottom: 1.5rem;
  font-size: 1.125rem;
  line-height: 1.8;
}

.segment p {
  margin: 0 0 1rem 0;
  line-height: 1.8;
  text-indent: 2em;  /* 段首缩进2字符 */
}

/* Word highlighting */
.word {
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.2s;
}

.word:hover {
  background: #EEF2FF;
}

.word.over-level {
  background: #FEF3C7;
  color: #92400E;
}

/* 超纲词括号注释 */
.word-note {
  font-size: 0.75em;
  color: #6B7280;
  margin-left: 2px;
}

/* Load More */
.load-more {
  text-align: center;
  padding: 1rem;
}

/* ============================================
   Bottom Navigation
   ============================================ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  padding: 0.75rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
}

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

.nav-btn.active {
  color: var(--primary);
  font-weight: 600;
}

/* ============================================
   Popup
   ============================================ */
.popup,
.mf-popup {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn 0.2s;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.popup-content {
  background: var(--bg-card);
  width: 95%;
  max-width: 500px;
  max-height: 85vh;
  border-radius: var(--radius);
  padding: 1.5rem;
  overflow-y: auto;
  animation: scaleIn 0.2s;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

@keyframes scaleIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.word-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

#popup-word {
  font-size: 1.5rem;
  font-weight: 600;
}

#popup-phonetic {
  color: var(--text-secondary);
}

.level-badge {
  background: #EEF2FF;
  color: var(--primary);
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.word-body {
  margin-bottom: 1.5rem;
}

.meaning {
  margin-bottom: 1rem;
}

.meaning-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.part-of-speech {
  background: var(--bg);
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.origin {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.sense {
  margin-bottom: 0.75rem;
}

.definition {
  margin-bottom: 0.25rem;
}

.chinese-definition {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.examples {
  margin-top: 0.5rem;
  padding-left: 1rem;
  border-left: 2px solid var(--border);
}

.example {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.example-translation {
  font-size: 0.75rem;
  color: var(--text-secondary);
  opacity: 0.8;
}

/* Deep Dive Button */
.btn-deep-dive {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
}

/* Popup Buttons Group */
.popup-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.btn-favorite {
  flex: 1;
  padding: 0.75rem;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.btn-favorite.favorited {
  background: var(--warning);
  color: white;
  border-color: var(--warning);
}

.btn-favorite.loading {
  opacity: 0.7;
  pointer-events: none;
}

/* ============================================
   Relation Tree Canvas (Phase 5.2)
   ============================================ */
.relation-tree-wrapper {
  position: relative;
  width: 100%;
  height: 400px;
  background: #fafafa;
  border-radius: 8px;
  overflow: hidden;
}

.relation-tree-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.relation-tree-tooltip {
  position: fixed;
  background: white;
  padding: 8px 12px;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  font-size: 12px;
  z-index: 1000;
  pointer-events: none;
}

.tree-section {
  padding: 1rem 0;
}

.tree-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.tree-header h4 {
  margin: 0;
  font-size: 1rem;
}

.tree-container {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

/* ============================================
   Deep Dive Panel
   ============================================ */
.panel,
.mf-panel,
.mf-deep-dive-panel {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 200;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.panel-footer {
  padding: 1rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.breadcrumb-item {
  background: var(--bg);
  border: none;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  cursor: pointer;
  white-space: nowrap;
}

.breadcrumb-item:hover {
  background: var(--border);
}

.breadcrumb-item.current {
  background: var(--primary);
  color: white;
}

/* Relations */
.relations {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.relation-group h4 {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.word-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.word-chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

.word-chip:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ============================================
   Search Page
   ============================================ */
.page {
  padding: 1rem;
}

.page-overlay {
  padding: 1rem;
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  bottom: 60px;
  background: var(--bg);
  z-index: 100;
  overflow-y: auto;
}

/* ============================================
   Book Selection Page
   ============================================ */
.book-select-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.book-select-header h2 {
  font-size: 1.25rem;
  color: var(--text);
}

.book-list {
  display: grid;
  gap: 1rem;
}

.book-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.book-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.book-card.active {
  border-color: var(--success);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.05) 0%, rgba(16, 185, 129, 0.1) 100%);
}

.book-card-icon {
  font-size: 2.5rem;
  flex-shrink: 0;
}

.book-card-info {
  flex: 1;
  min-width: 0;
}

.book-card-info h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-card-info p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.book-card-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.book-card-current {
  padding: 0.25rem 0.75rem;
  background: var(--success);
  color: white;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 999px;
}

/* Chapter Navigation removed - replaced by section-nav + toc-panel */

.chapter-dropdown-item .ch-sections {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.search-header {
  margin-bottom: 1rem;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.search-result {
  padding: 0.75rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
}

.search-result:hover {
  background: var(--bg);
}

/* ============================================
   Profile Page
   ============================================ */
.profile-info {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}

.profile-hint {
  color: var(--text-secondary);
  font-size: 0.875rem;
  text-align: center;
  margin-top: 1rem;
}

/* 收藏列表 */
.favorites-section {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.favorites-section h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
  color: var(--text);
}

.favorites-list {
  max-height: 300px;
  overflow-y: auto;
}

.favorite-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: background 0.2s;
}

.favorite-item:hover {
  background: var(--bg-hover, #f0f4ff);
}

.fav-word {
  font-weight: 600;
  color: var(--text);
}

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

.fav-level {
  font-size: 0.75rem;
  padding: 0.1rem 0.4rem;
  background: var(--primary);
  color: white;
  border-radius: 4px;
}

.fav-remove {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.25rem;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.fav-remove:hover {
  opacity: 1;
  color: var(--danger);
}

.no-favorites {
  color: var(--text-secondary);
  text-align: center;
  padding: 2rem;
  font-size: 0.9rem;
}

/* 搜索历史 */
.search-history {
  padding: 0.5rem 1rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.history-title {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.history-item {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: var(--bg-secondary, #f0f4ff);
  border-radius: 16px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}

.history-item:hover {
  background: var(--primary);
  color: white;
}

/* 等级选择器 */
.level-selector {
  position: relative;
  margin-top: 1rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

.level-selector-title {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  text-align: center;
}

.level-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.level-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem;
  background: var(--bg);
  border: 2px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.level-option:hover {
  background: var(--bg-hover, #f0f4ff);
  border-color: var(--primary);
}

.level-option.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.level-name {
  font-size: 1.25rem;
  font-weight: 700;
}

.level-desc {
  font-size: 0.7rem;
  opacity: 0.7;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.stat-card {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: var(--radius);
  text-align: center;
}

.stat-card.clickable {
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card.clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* 版本号徽章 */
.version-badge {
  font-size: 0.5em;
  font-weight: 400;
  color: var(--text-secondary);
  margin-left: 0.5rem;
}

.version-hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

.stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* ============================================
   Word Media (Audio & Image)
   ============================================ */
.word-media {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.media-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.audio-btn {
  background: var(--primary);
  color: white;
}

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

.audio-btn.playing {
  background: var(--success);
}

.media-card {
  display: flex;
  justify-content: center;
  padding: 0.5rem;
  background: var(--bg);
  border-radius: var(--radius);
}

.word-card-image {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--radius);
  object-fit: contain;
}

/* ============================================
   Section Cover Image Styles
   ============================================ */
.section-cover {
  width: 100%;
  margin-bottom: 1.5rem;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-secondary);
}

.section-cover-image {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  display: block;
}

/* 图片 Loading 占位符 */
.section-cover-loading {
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f0f4ff 0%, #e8eaf6 100%);
}

.image-loading-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.spinner-small {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* 图片错误占位符 */
.image-error-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 9;
  color: var(--text-secondary);
  font-size: 0.85rem;
  background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
}

/* 章节加载状态 */
.chapter-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  gap: 1rem;
  color: var(--text-secondary);
}

/* 按钮禁用状态 */
.btn:disabled,
.btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* 错误信息 */
.error-message {
  color: var(--danger);
  margin-bottom: 1rem;
}

/* 响应式调整 */
@media (max-width: 768px) {
  /* 手机端：图片更宽一些 */
  .section-cover {
    margin-left: -1rem;
    margin-right: -1rem;
    width: calc(100% + 2rem);
    border-radius: 0;
  }
}

/* ============================================
   Expanded Popup Styles
   ============================================ */
.status-section {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.status-item {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  background: var(--bg);
  border-radius: var(--radius);
  color: var(--text-secondary);
}

.instances-section {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.instances-section h4,
.examples-section h4,
.relations-section h4,
.meanings-section h4,
.definition-section h4 {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.book-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.book-tag {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  background: var(--primary);
  color: white;
  border-radius: var(--radius);
}

.theme-info {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  background: var(--bg);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  display: inline-block;
}

.definition-section {
  margin-bottom: 1rem;
}

.definition-section .definition {
  font-size: 1rem;
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.definition-section .translation {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.examples-section {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.example-item {
  margin-bottom: 0.75rem;
}

.example-item .example {
  font-style: italic;
  color: var(--text);
}

.example-item .example-translation {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.example-item .example-source {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.relations-section {
  margin-bottom: 1rem;
}

.relation-group {
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.relation-type {
  font-weight: 500;
  color: var(--text-secondary);
  margin-right: 0.5rem;
}

.relation-word {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  background: var(--bg);
  border-radius: var(--radius);
  margin-right: 0.25rem;
  cursor: pointer;
}

.relation-word:hover {
  background: var(--primary);
  color: white;
}

.loading-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
}

.media-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.not-found {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
}

/* ============================================
   Popup Content Sections
   ============================================ */
.no-content {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
}

.no-content .hint {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.definition-section {
  margin-bottom: 1rem;
}

.definition-section h4 {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
}

.definition-section .definition {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
}

.definitions-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.definition-item {
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.definition-item .pos {
  font-weight: 600;
  color: var(--primary);
  margin-right: 0.5rem;
  text-transform: lowercase;
}

.definition-item .meaning {
  color: var(--text);
}

.examples-section {
  margin-bottom: 1rem;
}

.examples-section h4 {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.75rem;
}

.examples-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.example-item {
  padding: 0.75rem;
  background: var(--bg);
  border-radius: var(--radius);
}

.example-sentence {
  font-style: italic;
  color: var(--text);
  line-height: 1.5;
  flex: 1;
}

.example-content {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.example-audio-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 0.25rem;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.example-audio-btn:hover {
  opacity: 1;
}

.example-translation {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.example-source {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.audio-section {
  margin-bottom: 1rem;
}

.audio-section .audio-btn {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}

.audio-btn.play-btn {
  background: var(--primary);
  color: white;
}

.audio-btn.play-btn:hover {
  background: var(--primary-hover);
}

.audio-btn.generate-btn {
  background: var(--success);
  color: white;
}

.audio-btn.generate-btn:hover {
  opacity: 0.9;
}

/* ============================================
   Audio Icon Buttons (Small with tooltip)
   ============================================ */
.audio-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 14px;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.audio-icon-btn:hover {
  background: var(--hover-bg);
  transform: scale(1.1);
}

.audio-icon-btn.play {
  color: var(--primary);
}

.audio-icon-btn.generate {
  color: var(--warning, #f59e0b);
}

.audio-icon-btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

/* 浮动tag提示 */
.audio-icon-btn::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  font-size: 12px;
  white-space: nowrap;
  color: white;
  background: rgba(0, 0, 0, 0.85);
  border-radius: 4px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
  z-index: 10;
  pointer-events: none;
}

.audio-icon-btn:hover::after {
  opacity: 1;
  visibility: visible;
}

/* 头部单词发音按钮 */
.word-header .audio-icon-btn {
  width: 24px;
  height: 24px;
  font-size: 12px;
}

/* 例句操作按钮容器 */
.example-actions {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.example-item:hover .example-actions {
  opacity: 1;
}

.image-section {
  margin-bottom: 1rem;
  text-align: center;
}

.word-image {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.word-image.clickable {
  cursor: zoom-in;
  transition: transform 0.2s;
}

.word-image.clickable:hover {
  transform: scale(1.02);
}

/* ============================================
   Image Viewer (Lightbox)
   ============================================ */
.image-viewer,
.mf-image-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1rem;
}

.image-viewer.hidden {
  display: none;
}

.image-viewer-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
}

.image-viewer-content img {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius);
}

.image-viewer-close {
  position: absolute;
  top: -1rem;
  right: -1rem;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: white;
  color: black;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.image-viewer-close:hover {
  background: #eee;
}

/* ============================================
   Word Stats Panel
   ============================================ */
.word-stats-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 500;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px;
  overflow-y: auto;
}

.panel-overlay {
  background: rgba(0, 0, 0, 0.5);
}

.panel-container {
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 1100px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 10;
}

.panel-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.btn-close:hover {
  background: var(--bg);
  color: var(--text);
}

/* Stats Overview */
.stats-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  padding: 1.5rem;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.stat-icon {
  font-size: 2rem;
}

.stat-content {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Task Controls */
.task-controls {
    padding: 1rem 1.5rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.task-controls h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text);
}

.task-section {
    padding: 1rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

.task-section h4 {
    font-size: 0.875rem;
    color: var(--text);
    margin-bottom: 0.75rem;
}

.task-info {
    margin-bottom: 0.75rem;
}

.task-status {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.task-status.idle {
    background: var(--bg);
    color: var(--text-secondary);
}

.task-status.running {
    background: #FEF3C7;
    color: #92400E;
}

.task-status.completed {
    background: #D1FAE5;
    color: #065F46;
}

.task-status.cancelled {
    background: #FEE2E2;
    color: #991B1B;
}

.task-progress {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    min-width: 80px;
    text-align: right;
}

.task-buttons {
    display: flex;
    gap: 0.5rem;
}

.batch-size-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.batch-size-input label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.batch-size-input input {
    width: 60px;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.875rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1500;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    width: 100%;
    max-width: 450px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.form-group select,
.form-group input[type="number"] {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: var(--bg-card);
    color: var(--text);
}

.form-divider {
    height: 1px;
    background: var(--border);
    margin: 1.5rem 0;
}

.checkbox-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--bg);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
}

.checkbox-label:hover {
    background: var(--border);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* CEFR Distribution */
.cefr-distribution {
  padding: 0 1.5rem 1.5rem;
}

.cefr-distribution h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.cefr-bars {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cefr-bar-item {
  display: grid;
  grid-template-columns: 30px 1fr 100px;
  align-items: center;
  gap: 0.75rem;
}

.cefr-label {
  font-weight: 600;
  font-size: 0.875rem;
}

.cefr-label.A1 { color: #4CAF50; }
.cefr-label.A2 { color: #8BC34A; }
.cefr-label.B1 { color: #FFC107; }
.cefr-label.B2 { color: #FF9800; }
.cefr-label.C1 { color: #F44336; }

.cefr-bar-bg {
  height: 20px;
  background: var(--bg);
  border-radius: 10px;
  overflow: hidden;
}

.cefr-bar-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 0.3s ease;
}

.cefr-count {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: right;
}

/* Filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--bg);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-group label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.filter-group select {
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  background: white;
}

/* Words Section */
.words-section {
  padding: 1.5rem;
}

.words-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.words-header h3 {
  font-size: 1rem;
}

#words-count {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.words-table-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.words-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.words-table th,
.words-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.words-table th {
  background: var(--bg);
  font-weight: 600;
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.words-table tbody tr:hover {
  background: var(--bg);
}

.words-table tbody tr:last-child td {
  border-bottom: none;
}

.word-cell strong {
  color: var(--primary);
}

.word-cell.clickable {
  cursor: pointer;
}

.word-cell.clickable:hover strong {
  text-decoration: underline;
}

.phonetic-cell {
  color: var(--text-secondary);
  font-family: monospace;
}

.difficulty-cell {
  color: var(--warning);
}

.status-cell {
  text-align: center;
}

.status-cell.done {
  color: var(--success);
}

.status-cell.pending {
  color: var(--text-secondary);
}

.level-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.level-badge.A1 { background: #E8F5E9; color: #4CAF50; }
.level-badge.A2 { background: #F1F8E9; color: #8BC34A; }
.level-badge.B1 { background: #FFF8E1; color: #FFC107; }
.level-badge.B2 { background: #FFF3E0; color: #FF9800; }
.level-badge.C1 { background: #FFEBEE; color: #F44336; }

.loading, .no-data, .error {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
}

.error {
  color: var(--danger);
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#page-info {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Theme Management Panel */
.theme-panel .theme-content {
  padding: 1.5rem;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

.theme-panel .section {
  margin-bottom: 1.5rem;
}

.theme-panel .section h3 {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.series-list, .books-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 200px;
  overflow-y: auto;
}

.series-item, .book-item {
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.series-item:hover, .book-item:hover {
  border-color: var(--primary);
  background: rgba(79, 70, 229, 0.05);
}

.series-item.selected, .book-item.selected {
  border-color: var(--primary);
  background: rgba(79, 70, 229, 0.1);
}

.series-item.notable {
  border-left: 3px solid var(--success);
}

.series-name, .book-title {
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.series-meta, .book-meta {
  display: flex;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.badge {
  background: var(--success);
  color: white;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.625rem;
  font-weight: 600;
}

.current-theme-info {
  margin-bottom: 1rem;
}

.theme-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.theme-name {
  font-weight: 600;
  color: var(--primary);
}

.theme-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.theme-actions {
  display: flex;
  gap: 0.5rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}

.stat-item .stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.stat-item .stat-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.generate-config {
  margin-bottom: 1rem;
}

.config-row {
  margin-bottom: 0.75rem;
}

.config-row label {
  display: block;
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
}

.config-row select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.config-row .checkbox-group {
  display: flex;
  gap: 1rem;
}

.config-row .checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
}

.estimate-info {
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.estimate-detail {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.25rem;
}

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

/* ============================================
   句子悬浮按钮组
   ============================================ */
.sentence-hover-buttons {
  position: fixed;
  z-index: 1000;
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transform: translateY(5px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.sentence-hover-buttons:not(.hidden) {
  opacity: 1;
  transform: translateY(0);
}

.sentence-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.sentence-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.sentence-btn[style*="display: none"] {
  display: none !important;
}

/* ============================================
   句子悬浮效果
   ============================================ */
.sentence-span {
  background: transparent;
  border-radius: 4px;
  padding: 2px 0;
  transition: all 0.2s ease;
  position: relative;
}

.sentence-span.sentence-active {
  background: rgba(79, 70, 229, 0.12);
  color: var(--primary);
  font-weight: 600;
  border-radius: 6px;
  padding: 2px 4px;
  margin: -2px -4px;
  border: 1px solid rgba(79, 70, 229, 0.4);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.2);
}

/* ============================================
   句子悬浮结果卡片
   ============================================ */
.sentence-result-card {
  position: fixed;
  z-index: 1001;
  width: 320px;
  max-width: calc(100vw - 40px);
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.draggable-header {
  cursor: grab;
  user-select: none;
}

.draggable-header:active {
  cursor: grabbing;
}

.result-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.result-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.result-close:hover {
  color: var(--text);
}

.result-content {
  padding: 16px;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  max-height: 300px;
  overflow-y: auto;
}

.result-content .main-clause {
  display: block;
  color: #059669;
  font-weight: 600;
  margin-bottom: 8px;
  padding-left: 12px;
  border-left: 3px solid #059669;
}

.result-content .sub-clause {
  display: block;
  color: #7c3aed;
  font-weight: 500;
  margin-bottom: 8px;
  padding-left: 12px;
  border-left: 3px solid #7c3aed;
}

.result-content .relation {
  display: block;
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 6px;
}

/* ============================================
   单词悬浮提示框
   ============================================ */
.word-hover-tooltip {
  position: fixed;
  z-index: 1002;
  width: 280px;
  max-width: calc(100vw - 20px);
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  pointer-events: auto;
}

.word-hover-tooltip.hidden {
  display: block;
  pointer-events: none;
}

.tooltip-word {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  margin-bottom: 2px;
}

.tooltip-phonetic {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.tooltip-meaning {
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 6px;
}

.tooltip-pos {
  display: inline-block;
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ============================================
   错误提示
   ============================================ */
.sentence-error {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  padding: 10px 20px;
  background: var(--danger);
  color: white;
  border-radius: 8px;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* ============================================
   句子解析面板（新版内嵌布局）
   ============================================ */

/* 面板头部 */
.sentence-panel .panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary, #f5f5f5);
  flex-shrink: 0;
}

.sentence-panel .panel-title {
  font-weight: 600;
  font-size: 1rem;
}

/* 控制开关 */
.panel-controls {
  display: flex;
  gap: 16px;
}

.control-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.control-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* 面板内容区 */
.sentence-panel .panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.sentence-panel .panel-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.sentence-panel .panel-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--primary);
}

/* 分析内容样式 */
.sentence-panel .analysis-original {
  margin-bottom: 16px;
}

.sentence-panel .analysis-section {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.sentence-panel .analysis-section:last-child {
  border-bottom: none;
}

.sentence-panel .analysis-section label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
}

.sentence-panel .original-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  padding: 12px;
  border-radius: 8px;
}

.sentence-panel .main-structure {
  font-size: 14px;
  color: var(--primary);
  font-weight: 500;
}

.sentence-panel .breakdown-parts {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sentence-panel .breakdown-part {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  line-height: 1.5;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 6px;
}

.sentence-panel .part-num {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 600;
}

.sentence-panel .part-content {
  color: var(--text);
  flex: 1 1 auto;
  min-width: 0;
  word-wrap: break-word;
  word-break: break-word;
}

.sentence-panel .part-role {
  color: var(--text-secondary);
  font-size: 11px;
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  white-space: nowrap;
}

.sentence-panel .note-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* 设置行 */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.setting-label {
  display: flex;
  flex-direction: column;
}

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

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.3s;
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background-color: var(--primary);
}

input:checked + .toggle-slider:before {
  transform: translateX(24px);
}

/* 区块标题 */
.section-title {
  padding: 12px 16px 8px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* 句子列表 */
.sentence-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 16px;
}

.sentence-item {
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 8px;
}

.sentence-text {
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 4px;
}

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

.loading-placeholder,
.empty-placeholder,
.error-placeholder {
  text-align: center;
  padding: 24px;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.error-placeholder {
  color: var(--danger);
}

.sentence-analysis-panel .panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary, #f5f5f5);
}

.sentence-analysis-panel .panel-title {
  font-weight: 600;
  color: var(--text);
}

.sentence-analysis-panel .panel-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0 8px;
  line-height: 1;
}

.sentence-analysis-panel .panel-close:hover {
  color: var(--text);
}

.sentence-analysis-panel .panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.sentence-analysis-panel .panel-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-secondary);
}

.sentence-analysis-panel .panel-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--primary);
}

/* 分析内容样式 */
.sentence-analysis-panel .analysis-original {
  margin-bottom: 16px;
}

.sentence-analysis-panel .analysis-section {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.sentence-analysis-panel .analysis-section:last-child {
  border-bottom: none;
}

.sentence-analysis-panel .analysis-section label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
}

.sentence-analysis-panel .original-text {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg, #f9f9f9);
  padding: 12px;
  border-radius: 8px;
}

.sentence-analysis-panel .main-structure {
  font-size: 14px;
  color: var(--primary);
  font-weight: 500;
}

/* ============================================
   复杂度标记
   ============================================ */
.complexity-marker {
  display: inline-block;
  margin-left: 4px;
  font-size: 12px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.complexity-marker:hover {
  opacity: 1;
}

.complexity-marker-wrapper {
  display: inline-flex;
  align-items: center;
}

/* 句子悬浮高亮 */
.sentence-span.sentence-active {
  background: rgba(79, 70, 229, 0.1);
  border-radius: 4px;
}

