/* ============================================
   赛博圆桌派 · 赛博朋克霓虹风格
   ============================================ */

:root {
  --bg: #0A0A0F;
  --card: #111118;
  --text: #E0E0F0;
  --text-secondary: #707088;
  --border: #1E1E30;
  --header-bg: #06060A;
  --header-text: #00E5FF;
  --accent: #00E5FF;
  --accent2: #FF00FF;
  --player-bg: #06060A;

  /* Neon character colors */
  --c-f: #00E676;
  --c-d: #FFAB40;
  --c-r: #FF5252;
  --c-m: #FFD740;
  --c-z: #00E5FF;

  --c-f-bg: rgba(0,230,118,0.08);
  --c-d-bg: rgba(255,171,64,0.08);
  --c-r-bg: rgba(255,82,82,0.08);
  --c-m-bg: rgba(255,215,64,0.08);
  --c-z-bg: rgba(0,229,255,0.08);

  --glow: 0 0 6px rgba(0,229,255,0.3);
  --glow-strong: 0 0 12px rgba(0,229,255,0.4);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  background-image:
    linear-gradient(rgba(0,229,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,229,255,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* 背景装饰 - 静态光晕 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    /* 左上角青色光晕 */
    radial-gradient(ellipse 300px 200px at 15% 20%, rgba(0,229,255,0.06) 0%, transparent 70%),
    /* 右下角品红光晕 */
    radial-gradient(ellipse 250px 250px at 85% 80%, rgba(255,0,255,0.05) 0%, transparent 70%),
    /* 中间偏上淡淡的光柱 */
    radial-gradient(ellipse 400px 2px at 50% 30%, rgba(0,229,255,0.04) 0%, transparent 100%),
    /* 左侧竖线光晕 */
    radial-gradient(ellipse 1px 300px at 10% 50%, rgba(0,229,255,0.05) 0%, transparent 100%),
    /* 右侧竖线光晕 */
    radial-gradient(ellipse 1px 200px at 90% 60%, rgba(255,0,255,0.04) 0%, transparent 100%),
    /* 底部品红雾 */
    radial-gradient(ellipse 400px 150px at 50% 100%, rgba(255,0,255,0.04) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
  animation: bgPulse 8s ease-in-out infinite alternate;
}

@keyframes bgPulse {
  0%   { opacity: 0.6; }
  100% { opacity: 1; }
}

/* 背景装饰 - 漂浮光点（静态位置） */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle 4px at 25% 40%, rgba(0,229,255,0.08) 0%, transparent 100%),
    radial-gradient(circle 3px at 70% 25%, rgba(255,0,255,0.06) 0%, transparent 100%),
    radial-gradient(circle 5px at 60% 70%, rgba(0,229,255,0.06) 0%, transparent 100%),
    radial-gradient(circle 2px at 35% 85%, rgba(255,0,255,0.05) 0%, transparent 100%),
    radial-gradient(circle 3px at 80% 45%, rgba(0,229,255,0.05) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

/* ═══ 扫描光条 - 从上到下循环扫过 ═══ */
/* ═══ 几何装饰 - 漂移的菱形 ═══ */
.geo-shape {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  border: 3px solid;
  opacity: 0.7;
  box-shadow:
    0 0 15px currentColor,
    0 0 40px currentColor,
    inset 0 0 10px currentColor;
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

.geo-shape.diamond1 {
  width: 110px; height: 110px;
  top: 15%; left: 8%;
  border-color: rgba(0,229,255,0.6);
  color: rgba(0,229,255,0.3);
  animation: shapeFloat1 20s ease-in-out infinite, shapeSpin 25s linear infinite;
}

.geo-shape.diamond2 {
  width: 70px; height: 70px;
  top: 65%; left: 80%;
  border-color: rgba(255,0,255,0.55);
  color: rgba(255,0,255,0.25);
  animation: shapeFloat2 25s ease-in-out infinite, shapeSpin 35s linear infinite reverse;
}

.geo-shape.diamond3 {
  width: 90px; height: 90px;
  top: 38%; left: 72%;
  border-color: rgba(0,230,118,0.55);
  color: rgba(0,230,118,0.25);
  animation: shapeFloat3 22s ease-in-out infinite, shapeSpin 30s linear infinite;
}

@keyframes shapeSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes shapeFloat1 {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33%      { transform: translate(18px, -22px) rotate(120deg); }
  66%      { transform: translate(-8px, 10px) rotate(240deg); }
}

@keyframes shapeFloat2 {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33%      { transform: translate(-12px, 18px) rotate(-120deg); }
  66%      { transform: translate(10px, -5px) rotate(-240deg); }
}

@keyframes shapeFloat3 {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33%      { transform: translate(14px, 12px) rotate(120deg); }
  66%      { transform: translate(-6px, -15px) rotate(240deg); }
}

#app {
  max-width: 720px;
  margin: 0 auto;
  padding-bottom: 80px;
  position: relative;
  z-index: 1;
}

/* === Header === */
#header {
  z-index: 100;
  background: var(--header-bg);
  color: var(--header-text);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#headerLogo {
  height: 32px;
  width: auto;
  flex: 1;
  object-fit: contain;
  object-position: center;
}

/* 列表页：header 放大到 400px，logo 同比例放大 */
#header.header-list {
  height: 400px;
  padding: 16px;
}

#header.header-list #headerLogo {
  height: 360px;
}

#headerTitle {
  flex: 1;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  text-shadow: 0 0 10px rgba(0,229,255,0.5);
  color: var(--header-text);
}

.icon-btn {
  background: none;
  border: none;
  color: var(--header-text);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  min-width: 36px;
  text-align: center;
  opacity: 0.8;
}

.icon-btn:hover { opacity: 1; }

.header-spacer { width: 36px; }

/* === Loading === */
#loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  color: var(--text-secondary);
}

.loader {
  width: 32px;
  height: 32px;
  border: 2px solid rgba(0,229,255,0.15);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
  box-shadow: var(--glow);
}

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

/* === Episode List === */
#episodeList { padding: 16px; }

.episode-card {
  background: var(--card);
  padding: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid rgba(0,229,255,0.2);
  box-shadow: 0 0 8px rgba(0,229,255,0.08);
}

.episode-card:hover {
  border-color: rgba(0,229,255,0.5);
  box-shadow: 0 0 15px rgba(0,229,255,0.15);
}

.episode-card:active { transform: scale(0.98); }

.episode-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.episode-number {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(0,229,255,0.08);
  padding: 2px 8px;
}

.episode-date {
  font-size: 12px;
  color: var(--text-secondary);
}

.episode-title {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.4;
  margin-bottom: 4px;
}

.episode-summary {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}

.episode-summary:not(.collapsed) {
  display: block;
  -webkit-line-clamp: unset;
}

.episode-summary .expand-hint {
  color: var(--accent);
  font-size: 12px;
  margin-left: 4px;
}

.hint-expand { display: inline; }
.hint-collapse { display: none; }
.episode-summary:not(.collapsed) .hint-expand { display: none; }
.episode-summary:not(.collapsed) .hint-collapse { display: inline; }

/* === Episode Detail === */
#episodeDetail { padding: 0; }

.detail-header {
  padding: 24px 16px 16px;
  border-bottom: 1px solid var(--border);
}

.detail-header .episode-date {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.detail-header h2 {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.4;
  text-shadow: 0 0 8px rgba(0,229,255,0.15);
}

/* === Character Filter Bar === */
.char-filter {
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  background: transparent;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
}

.char-filter::-webkit-scrollbar { display: none; }

.char-filter-btn {
  flex-shrink: 0;
  padding: 4px 12px;
  border: 1px solid var(--border);
  background: transparent;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-secondary);
}

.char-filter-btn:hover {
  border-color: var(--c, var(--accent));
  color: var(--c, var(--accent));
}

.char-filter-btn.active {
  background: transparent;
  border-color: var(--c, var(--accent));
  color: var(--c, var(--accent));
  box-shadow: 0 0 8px var(--c, var(--accent));
}

.char-filter-btn.all-btn { --c: var(--accent); }

/* === Dialogue Segments === */
.dialogue-container { padding: 12px 16px 24px; }

.segment {
  margin-bottom: 8px;
  padding-left: 12px;
  border-left: 3px solid var(--border);
  transition: all 0.3s;
}

.segment.hidden-seg { display: none; }

.segment[data-speaker="F"] { border-left-color: var(--c-f); }
.segment[data-speaker="D"] { border-left-color: var(--c-d); }
.segment[data-speaker="R"] { border-left-color: var(--c-r); }
.segment[data-speaker="M"] { border-left-color: var(--c-m); }
.segment[data-speaker="Z"] { border-left-color: var(--c-z); }

.segment-label {
  display: inline-block;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.segment[data-speaker="F"] .segment-label { color: var(--c-f); background: var(--c-f-bg); }
.segment[data-speaker="D"] .segment-label { color: var(--c-d); background: var(--c-d-bg); }
.segment[data-speaker="R"] .segment-label { color: var(--c-r); background: var(--c-r-bg); }
.segment[data-speaker="M"] .segment-label { color: var(--c-m); background: var(--c-m-bg); }
.segment[data-speaker="Z"] .segment-label { color: var(--c-z); background: var(--c-z-bg); }

.segment-label:hover {
  opacity: 0.8;
  text-shadow: 0 0 8px currentColor;
}

.seg-seek-btn {
  margin-left: 8px;
  font-size: 10px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s;
  padding: 0 4px;
}

.seg-seek-btn:hover { opacity: 1; }

.segment.active-speaker .seg-seek-btn { display: none; }

.segment.active-speaker {
  background: var(--active-bg, rgba(0,229,255,0.04));
  padding-left: 15px;
  margin-left: -15px;
  padding-right: 15px;
  margin-right: -15px;
  padding-top: 4px;
  padding-bottom: 4px;
  border-left-width: 4px;
  box-shadow: 0 0 20px rgba(0,0,0,0.3);
}

.segment.active-speaker[data-speaker="F"] { --active-bg: rgba(0,230,118,0.06); }
.segment.active-speaker[data-speaker="D"] { --active-bg: rgba(255,171,64,0.06); }
.segment.active-speaker[data-speaker="R"] { --active-bg: rgba(255,82,82,0.06); }
.segment.active-speaker[data-speaker="M"] { --active-bg: rgba(255,215,64,0.06); }
.segment.active-speaker[data-speaker="Z"] { --active-bg: rgba(0,229,255,0.06); }

.segment.active-speaker .segment-text { font-weight: 500; }

/* Waveform */
.seg-wave {
  display: none;
  margin-left: 8px;
  align-items: center;
  gap: 1.5px;
  height: 12px;
}

.segment.active-speaker .seg-wave { display: inline-flex; }

.seg-wave span {
  display: block;
  width: 2px;
  background: currentColor;
  border-radius: 1px;
  animation: wave 0.6s ease-in-out infinite alternate;
}

.seg-wave span:nth-child(1) { height: 6px;  animation-delay: 0s; }
.seg-wave span:nth-child(2) { height: 10px; animation-delay: 0.15s; }
.seg-wave span:nth-child(3) { height: 8px;  animation-delay: 0.3s; }
.seg-wave span:nth-child(4) { height: 12px; animation-delay: 0.1s; }
.seg-wave span:nth-child(5) { height: 7px;  animation-delay: 0.2s; }

@keyframes wave {
  0%   { transform: scaleY(0.4); }
  100% { transform: scaleY(1); }
}

/* Section markers */
.section-marker {
  text-align: center;
  padding: 16px 0;
  margin: 12px 0;
  position: relative;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
  letter-spacing: 3px;
}

.section-marker::before,
.section-marker::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 30%;
  height: 1px;
  background: var(--border);
}

.section-marker::before { left: 0; }
.section-marker::after { right: 0; }

.segment-text {
  font-size: 16px;
  line-height: 1.8;
  padding: 0;
  color: var(--text);
}

.segment-text p { margin-bottom: 8px; }
.segment-text p:last-child { margin-bottom: 0; }

/* === Audio Player === */
.player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 150;
  background: var(--player-bg);
  color: var(--text);
  transition: transform 0.3s;
  border-top: 1px solid rgba(0,229,255,0.2);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.5),
              0 -1px 0 rgba(0,229,255,0.1);
}

.player.hidden { transform: translateY(100%); }

.player-progress {
  width: 100%;
  height: 8px;
  background: #111118;
  cursor: pointer;
  position: relative;
  touch-action: none;
}

.player-progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  box-shadow: 0 0 12px rgba(0,229,255,0.6),
              0 0 24px rgba(0,229,255,0.3);
}

.player-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  min-height: 72px;
}

.player-info {
  flex: 1;
  min-width: 0;
  cursor: pointer;
  padding: 2px 0;
}

.player-title {
  display: block;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #00E5FF;
}

.player-char {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 2px;
}

.player-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.player-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.player-play {
  background: none !important;
  border: none !important;
  cursor: pointer;
  padding: 0;
  line-height: 48px;
  height: 48px;
  display: flex;
  align-items: center;
}

.player-btn-icon {
  width: 48px;
  height: 48px;
  display: block;
}

/* === Desktop === */
@media (min-width: 768px) {
  #app { max-width: 800px; }

  #episodeList {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 16px;
  }

  .episode-card { margin-bottom: 0; }

  .segment-text { font-size: 16px; }
}
