/* 基础样式 */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.6;
  padding-bottom: 180px;
}

/* 顶部导航 */
.header {
  position: sticky;
  top: 0;
  background: #1a73e8;
  color: #fff;
  padding: 16px;
  z-index: 100;
}

.header h1 {
  font-size: 18px;
  font-weight: 600;
  text-align: center;
}

/* 搜索框 */
.search-box {
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
}

.search-box input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 16px;
  background: #f9f9f9;
}

/* 播放列表控制 */
.playlist-control {
  margin: 12px 16px;
  padding: 12px 16px;
  background: #fff7ed;
  border-radius: 12px;
  border: 1px solid #f97316;
}

.playlist-buttons {
  display: flex;
  gap: 10px;
}

.playlist-btn {
  flex: 1;
  padding: 12px;
  background: #f97316;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
}

#clearSelectedBtn {
  background: #6b7280;
}

.selected-count {
  display: block;
  text-align: center;
  margin-top: 10px;
  font-size: 13px;
  color: #f97316;
  font-weight: 500;
}

/* 朝代筛选 */
.filter-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  background: #fff;
  -webkit-overflow-scrolling: touch;
}

.filter-bar::-webkit-scrollbar { display: none; }

.filter-btn {
  padding: 8px 16px;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  background: #fff;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
}

.filter-btn.active {
  background: #1a73e8;
  color: #fff;
  border-color: #1a73e8;
}

/* 课文列表 */
.poem-list {
  padding: 12px 16px;
}

.poem-item {
  position: relative;
  background: #fff;
  margin-bottom: 12px;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  overflow: hidden;
}

.poem-item-inner {
  background: white;
}

.poem-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
}

.poem-num {
  width: 36px;
  height: 36px;
  background: #e8f0fe;
  color: #1a73e8;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

/* 选中状态的序号变为橙色 */
.poem-item.selected .poem-num {
  background: #fff7ed;
  color: #f97316;
}

.poem-info {
  flex: 1;
  margin-left: 12px;
  min-width: 0;
}

.poem-title {
  font-size: 16px;
  font-weight: 600;
  color: #222;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.poem-author {
  font-size: 13px;
  color: #666;
}

.poem-dynasty {
  font-size: 12px;
  background: #f0f0f0;
  padding: 2px 8px;
  border-radius: 4px;
  color: #666;
  margin-left: 8px;
}

/* 动画光点 */
.animation-dot {
  position: fixed;
  width: 6px;
  height: 6px;
  background: #f97316;
  border-radius: 50%;
  box-shadow: 0 0 8px 2px rgba(249, 115, 22, 0.6);
  z-index: 300;
  pointer-events: none;
  opacity: 0;
}

.animation-dot.active {
  opacity: 1;
}

/* 展开内容区域 */
.poem-content {
  padding: 0;
  max-height: 0;
  overflow: hidden;
}

.poem-content.expanded {
  padding: 16px;
  max-height: 10000px;
}

.content-section {
  margin-bottom: 20px;
}

.content-section:last-child {
  margin-bottom: 0;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: #1a73e8;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e0e0e0;
}

.original-text {
  font-size: 16px;
  line-height: 1.8;
  white-space: pre-line;
  font-family: "SimSun", "STSong", serif;
}

.translation-text {
  font-size: 15px;
  line-height: 1.6;
  color: #333;
  white-space: pre-line;
}

/* 逐行释义样式 */
.inline-translation-text {
  font-size: 14px;
}

.poem-line {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px dashed #e0e0e0;
}

.poem-line:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.line-original {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  line-height: 1.8;
  padding: 6px 0;
  font-family: "SimSun", "STSong", serif;
}

.line-translation {
  font-size: 13px;
  color: #666;
  line-height: 1.7;
  padding: 6px 12px;
  background: #f8f9fa;
  border-left: 3px solid #6b7280;
  border-radius: 4px;
  margin-top: 6px;
}

/* 底部固定播放器 */
.player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  z-index: 200;
}

.player-bar.hidden .playlist-horizontal-container {
  display: none;
}

/* 进度条作为顶部橙色线 */
.progress-bar {
  width: 100%;
  height: 2px;
  background: #f97316;
  cursor: pointer;
  position: relative;
}

/* 隐藏进度填充 */
.progress {
  display: none;
}

/* 进度小球 */
.progress-dot {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #f97316;
  border-radius: 50%;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%);
  z-index: 2;
  box-shadow: 0 0 6px rgba(249, 115, 22, 0.8);
  will-change: left;
}

/* 播放器主内容区 */
.player-main {
  padding: 8px 16px 6px 16px;
}

.player-info {
  flex: 1;
  min-width: 0;
}

.player-title {
  font-size: 15px;
  font-weight: 600;
  color: #222;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-author {
  font-size: 13px;
  color: #666;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.time-info {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #666;
  margin-top: 4px;
}

/* 播放控制区 */
.player-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.player-center {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  justify-content: center;
}

.speed-control {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  justify-content: flex-start;
}

.speed-select {
  display: none;
}

/* 自定义倍速下拉菜单 */
.custom-speed-select {
  position: relative;
}

.speed-toggle {
  padding: 6px 12px;
  border: none;
  border-radius: 8px;
  background: #f0f0f0;
  font-size: 12px;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 50px;
}

.speed-toggle:hover {
  background: #e5e7eb;
}

.speed-toggle::after {
  content: '▼';
  font-size: 8px;
  margin-left: 4px;
  opacity: 0.6;
}

.speed-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 4px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  display: none;
  min-width: 70px;
  z-index: 100;
  overflow: hidden;
}

.speed-dropdown.show {
  display: block;
}

.speed-option {
  padding: 8px 14px;
  font-size: 12px;
  color: #333;
  cursor: pointer;
  transition: background 0.15s ease;
}

.speed-option:hover {
  background: #f97316;
  color: #fff;
}

.speed-option.selected {
  background: #fff7ed;
  color: #f97316;
}

.time-display {
  font-size: 11px;
  color: #666;
  white-space: nowrap;
}

/* 播放按钮 - 橙色三角无外圈 */
.player-btn {
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  padding: 0;
}

/* 播放三角图标 */
.player-btn .play-icon {
  width: 0;
  height: 0;
  border-left: 12px solid #f97316;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  transition: all 0.2s ease;
}

/* 暂停状态：两条橙色竖线 */
.player-btn.playing .play-icon {
  width: 12px;
  height: 14px;
  border: none;
  background: transparent;
  position: relative;
}

.player-btn.playing .play-icon::before,
.player-btn.playing .play-icon::after {
  content: '';
  position: absolute;
  width: 4px;
  height: 14px;
  background: #f97316;
  border-radius: 1px;
}

.player-btn.playing .play-icon::before {
  left: 0;
}

.player-btn.playing .play-icon::after {
  right: 0;
}

.player-btn:hover {
  transform: scale(1.1);
}

.player-btn:active {
  transform: scale(0.95);
}

.loop-control-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  justify-content: flex-end;
}

/* 循环模式按钮 */
.loop-control {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #f0f0f0;
  border: none;
  border-radius: 12px;
  font-size: 12px;
  color: #666;
  cursor: pointer;
}

.loop-control.active {
  background: #f97316;
  color: #fff;
}

.loop-text {
  font-size: 12px;
}

.loop-btn {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  background: #f0f0f0;
  border: none;
  border-radius: 12px;
  font-size: 12px;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
}

.loop-btn:hover {
  background: #e5e7eb;
}

.loop-btn.active {
  background: #f97316;
  color: #fff;
}

.loop-btn.active:hover {
  background: #ea580c;
}

/* 复选框样式 */
.play-checkbox {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-right: 6px;
  border: 2px solid rgba(255,255,255,0.5);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.play-btn.selected .play-checkbox {
  background: #fff;
  border-color: #fff;
}

.play-btn.selected .play-checkbox::after {
  content: "✓";
  color: #34a853;
  font-size: 12px;
  font-weight: bold;
}

/* 播放按钮选中状态 */
.play-btn.selected {
  background: #34a853;
}

/* 空状态 */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: #666;
}

/* 加载状态 */
.loading {
  text-align: center;
  padding: 40px;
  color: #666;
}

.loading::after {
  content: "加载中...";
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { opacity: 0.5; }
  50% { opacity: 1; }
  100% { opacity: 0.5; }
}

/* 移动端安全区域适配 */
@supports (padding: max(0px)) {
  .player-bar {
    padding-bottom: max(6px, env(safe-area-inset-bottom));
  }

  body {
    padding-bottom: max(180px, calc(180px + env(safe-area-inset-bottom)));
  }
}

/* 响应式 */
@media (min-width: 768px) {
  .container {
    max-width: 800px;
    margin: 0 auto;
    background: #fff;
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
  }
  
  .header {
    border-radius: 0;
  }
  
  body {
    background: #e0e0e0;
  }
  
  .poem-list {
    padding: 20px;
  }
}
