/* ============================================
   英语对话剧本库 - 全局样式
   美学方向：精炼文具感 · 温暖中性 + 深青点缀
   设计原则：留白、层次、克制、可读
   ============================================ */

:root {
  /* 主色 - 深青 */
  --primary: #0D9488;
  --primary-dark: #0F766E;
  --primary-darker: #115E54;
  --primary-light: #CCFBF1;
  --primary-lighter: #F0FDFA;
  --primary-glow: rgba(13, 148, 136, 0.10);

  /* 辅助色 */
  --accent: #F59E0B;
  --rose: #E11D48;
  --rose-light: #FFF1F2;
  --success: #059669;
  --success-light: #ECFDF5;

  /* 阅读高亮 - 柔和浅紫罗兰 */
  --reading-bg: #F4F1FB;
  --reading-bg-strong: #E9E2F7;
  --reading-border: #DDD3F0;
  --reading-text: #6B5BA8;

  /* 中性色 - 暖灰系 */
  --text: #1C1917;
  --text-secondary: #57534E;
  --text-tertiary: #A8A29E;
  --text-quaternary: #D6D3D1;

  --bg: #FAFAF7;
  --bg-soft: #F5F4F0;
  --surface: #FFFFFF;
  --surface-elevated: #FEFEFD;

  --border: #E7E5E4;
  --border-light: #F0EEEC;
  --border-strong: #D6D3D1;

  /* 阴影 - 柔和、有温度 */
  --shadow-xs: 0 1px 2px rgba(28, 25, 23, 0.04);
  --shadow-sm: 0 1px 3px rgba(28, 25, 23, 0.05), 0 1px 2px rgba(28, 25, 23, 0.03);
  --shadow-md: 0 4px 12px rgba(28, 25, 23, 0.06), 0 2px 4px rgba(28, 25, 23, 0.04);
  --shadow-lg: 0 12px 32px rgba(28, 25, 23, 0.08), 0 4px 12px rgba(28, 25, 23, 0.05);
  --shadow-xl: 0 20px 48px rgba(28, 25, 23, 0.10), 0 8px 16px rgba(28, 25, 23, 0.06);

  /* 圆角 */
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;

  /* 字体 */
  --font: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Noto Sans CJK SC', 'Helvetica Neue', 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'JetBrains Mono', 'Menlo', monospace;

  /* 缓动 */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  letter-spacing: -0.005em;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; }
input, select { font-family: inherit; }

/* ============================================
   顶部导航 - 极简磨砂
   ============================================ */
.navbar {
  background: rgba(250, 250, 247, 0.78);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(231, 229, 228, 0.6);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-inner {
  max-width: 1080px;
  margin: 0 auto;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.025em;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.28), inset 0 1px 0 rgba(255,255,255,0.15);
}

.logo-icon svg { width: 18px; height: 18px; }

.nav-links { display: flex; gap: 2px; }

.nav-link {
  padding: 8px 14px;
  border-radius: var(--radius-xs);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s var(--ease-out);
  position: relative;
}

.nav-link:hover {
  color: var(--text);
  background: rgba(13, 148, 136, 0.06);
}

.nav-link.active {
  color: var(--primary-dark);
  background: var(--primary-lighter);
  font-weight: 600;
}

/* ============================================
   容器
   ============================================ */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 24px;
}

/* ============================================
   首页标题 - 克制的层次
   ============================================ */
.page-header {
  text-align: center;
  padding: 40px 0 32px;
}

.page-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.035em;
  line-height: 1.2;
}

.page-subtitle {
  color: var(--text-tertiary);
  font-size: 0.9rem;
  font-weight: 400;
  letter-spacing: 0.005em;
}

/* ============================================
   搜索栏 - 极简优雅
   ============================================ */
.search-bar {
  max-width: 520px;
  margin: 0 auto 28px;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 13px 48px 13px 44px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  font-size: 0.92rem;
  background: var(--surface);
  color: var(--text);
  transition: all 0.25s var(--ease-out);
  outline: none;
  box-shadow: var(--shadow-xs);
}

.search-input::placeholder { color: var(--text-tertiary); }

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow), var(--shadow-sm);
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-btn {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-xs);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--ease-out);
  box-shadow: 0 2px 6px rgba(13, 148, 136, 0.25);
}

.search-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-50%) scale(1.04);
}

.search-btn:active { transform: translateY(-50%) scale(0.96); }

.search-btn svg { width: 16px; height: 16px; }

/* ============================================
   分类标签 - 横向滚动友好
   ============================================ */
.category-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 28px;
}

.category-tab {
  padding: 7px 14px;
  border-radius: 50px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  color: var(--text-secondary);
  box-shadow: var(--shadow-xs);
}

.category-tab svg { width: 14px; height: 14px; }
.category-tab .cat-emoji { font-size: 0.85rem; line-height: 1; }

.category-tab:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
  transform: translateY(-1px);
}

.category-tab.active {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
  box-shadow: 0 4px 12px rgba(28, 25, 23, 0.18);
  font-weight: 600;
}

/* ============================================
   剧本卡片网格 - 自适应三档
   ============================================ */
.script-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.script-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  padding: 22px;
  cursor: pointer;
  transition: all 0.35s var(--ease-out);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.script-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  opacity: 0;
  transition: opacity 0.3s var(--ease-out);
}

.script-card:active {
  transform: scale(0.985);
}

@media (hover: hover) {
  .script-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border);
  }
  .script-card:hover::before { opacity: 1; }
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  gap: 8px;
}

.card-category {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 11px;
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--primary-lighter);
  color: var(--primary-dark);
  letter-spacing: 0.005em;
}

.card-category .cat-emoji { font-size: 0.82rem; line-height: 1; }
.detail-meta .cat-emoji { font-size: 0.9rem; line-height: 1; }

.card-fav {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-quaternary);
}

.card-fav:hover {
  background: var(--rose-light);
  color: var(--rose);
  transform: scale(1.1);
}

.card-fav.active { color: var(--rose); }

.card-fav svg { width: 18px; height: 18px; }

.card-title {
  font-size: 1.08rem;
  font-weight: 700;
  margin-bottom: 5px;
  color: var(--text);
  letter-spacing: -0.015em;
  line-height: 1.35;
}

.card-scene {
  font-size: 0.82rem;
  color: var(--text-tertiary);
  margin-bottom: 16px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  gap: 14px;
  font-size: 0.76rem;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.card-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-meta svg { width: 13px; height: 13px; opacity: 0.7; }

.card-roles {
  margin-top: 12px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.role-tag {
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 0.71rem;
  background: var(--bg-soft);
  color: var(--text-secondary);
  font-weight: 500;
  border: 1px solid var(--border-light);
}

/* 卡片进度条 */
.card-progress {
  margin-top: 14px;
  height: 3px;
  background: var(--border-light);
  border-radius: 2px;
  overflow: hidden;
}

.card-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  border-radius: 2px;
  transition: width 0.5s var(--ease-out);
}

.card-badges {
  position: absolute;
  top: 14px;
  right: 48px;
  display: flex;
  gap: 4px;
}

.badge-completed {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 9px;
  border-radius: 50px;
  font-size: 0.66rem;
  font-weight: 600;
  background: var(--success-light);
  color: var(--success);
  border: 1px solid rgba(5, 150, 105, 0.2);
}

.badge-completed svg { width: 11px; height: 11px; }

/* ============================================
   空状态
   ============================================ */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-tertiary);
}

.empty-state .icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-quaternary);
}

.empty-state .icon svg { width: 28px; height: 28px; }

.empty-state p {
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.empty-state a {
  display: inline-block;
  margin-top: 12px;
  color: var(--primary-dark);
  font-weight: 600;
  font-size: 0.88rem;
}

/* ============================================
   剧本详情页
   ============================================ */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  margin-bottom: 18px;
  transition: all 0.2s var(--ease-out);
  cursor: pointer;
}

.back-btn:hover {
  color: var(--primary-dark);
  background: var(--primary-lighter);
}

.back-btn svg { width: 15px; height: 15px; }

.script-detail-header {
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-light);
  padding: 28px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.script-detail-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
}

.detail-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.detail-header-info {
  flex: 1;
  min-width: 0;
}

.detail-header-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  white-space: nowrap;
  color: var(--text-secondary);
}

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

.action-btn:active { transform: translateY(0); }

.action-btn .action-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.action-btn .action-icon svg { width: 16px; height: 16px; }

.action-btn.active-fav {
  border-color: var(--rose);
  background: var(--rose-light);
  color: var(--rose);
}

.action-btn.active-done {
  border-color: var(--success);
  background: var(--success-light);
  color: var(--success);
}

.script-detail-header h1 {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 7px;
  letter-spacing: -0.025em;
  line-height: 1.3;
}

.script-detail-header .scene {
  color: var(--text-tertiary);
  margin-bottom: 14px;
  font-size: 0.86rem;
  line-height: 1.5;
}

.detail-meta {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.detail-meta span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.detail-meta svg { width: 14px; height: 14px; opacity: 0.7; }

/* ============================================
   控制面板
   ============================================ */
.control-panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  padding: 16px 22px;
  margin-bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-xs);
}

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

.control-label {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

.btn {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.22);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.3);
}

.btn-primary:active { transform: translateY(0); }

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

.btn-toggle:hover {
  background: var(--border-light);
  color: var(--text);
}

.btn-toggle.active {
  background: var(--accent);
  color: var(--text);
  border-color: var(--accent);
}

.role-select {
  padding: 8px 32px 8px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  color: var(--text);
  transition: all 0.2s var(--ease-out);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23A8A29E' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
}

.role-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* ============================================
   对话区域
   ============================================ */
.dialogue-container {
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-light);
  padding: 22px;
  min-height: 320px;
  box-shadow: var(--shadow-xs);
}

.dialogue-line {
  display: flex;
  gap: 13px;
  margin-bottom: 10px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  transition: all 0.25s var(--ease-out);
  cursor: pointer;
  position: relative;
  border: 1px solid transparent;
}

@media (hover: hover) {
  .dialogue-line:hover {
    background: var(--bg-soft);
  }
}

.dialogue-line.active {
  background: var(--reading-bg);
  border-color: var(--reading-border);
}

.dialogue-line.playing {
  animation: linePulse 1.8s ease-in-out infinite;
}

@keyframes linePulse {
  0%, 100% { background: var(--reading-bg); }
  50% { background: var(--reading-bg-strong); }
}

/* 加载中状态 - 弱网等待音频下载 */
.dialogue-line.loading {
  background: var(--reading-bg);
  border-color: var(--reading-border);
}

.dialogue-line.loading .line-avatar {
  animation: avatarPulse 1.2s ease-in-out infinite;
}

@keyframes avatarPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.92); }
}

/* 加载旋转指示器 */
.line-loading-indicator {
  position: absolute;
  top: 14px;
  right: 12px;
  width: 20px;
  height: 20px;
  border: 2px solid var(--reading-border);
  border-top-color: var(--reading-text);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  z-index: 5;
}

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

/* 加载时隐藏行操作按钮 */
.dialogue-line.loading .line-actions { display: none; }

/* 加载失败提示 */
.dialogue-line.load-error {
  border-color: rgba(225, 29, 72, 0.25);
  background: var(--rose-light);
}

.line-error-tip {
  position: absolute;
  top: 14px;
  right: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--rose);
  background: rgba(225, 29, 72, 0.08);
  padding: 3px 10px;
  border-radius: 50px;
  z-index: 5;
  animation: errorFadeIn 0.3s var(--ease-out);
}

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

.line-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
  font-weight: 700;
  color: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1), inset 0 1px 0 rgba(255,255,255,0.2);
  letter-spacing: 0;
}

.line-content {
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
  padding-right: 70px;
}

.line-role {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-tertiary);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.line-role .my-role {
  color: var(--primary-dark);
  background: var(--primary-lighter);
  padding: 1px 7px;
  border-radius: 50px;
  margin-left: 4px;
  font-size: 0.65rem;
  letter-spacing: 0.02em;
  text-transform: none;
}

.line-en {
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.55;
  font-weight: 500;
  letter-spacing: -0.005em;
}

.line-zh {
  font-size: 0.83rem;
  color: var(--text-tertiary);
  line-height: 1.5;
}

.line-zh.hidden { display: none; }

.line-actions {
  display: flex;
  gap: 5px;
  align-items: center;
  position: absolute;
  top: 14px;
  right: 12px;
  opacity: 0;
  transition: opacity 0.2s var(--ease-out);
}

.dialogue-line:hover .line-actions { opacity: 1; }
.dialogue-line.active .line-actions { opacity: 1; }

.line-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: var(--surface);
  color: var(--text-secondary);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--ease-out);
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--border-light);
}

.line-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: scale(1.08);
}

.line-btn svg { width: 14px; height: 14px; }

.line-btn.active-repeat {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
}

/* ============================================
   进度条
   ============================================ */
.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--border-light);
  border-radius: 2px;
  margin-top: 18px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  border-radius: 2px;
  transition: width 0.5s var(--ease-out);
}

/* ============================================
   播放控制浮层 - 精致胶囊
   ============================================ */
.playback-bar {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border: 1px solid rgba(231, 229, 228, 0.6);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 90;
  border-radius: 50px;
  box-shadow: var(--shadow-xl);
  max-width: calc(100vw - 32px);
}

.pb-btn {
  width: 42px;
  height: 42px;
  border: none;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--ease-out);
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.3);
}

.pb-btn:active { transform: scale(0.92); }

.pb-btn svg { width: 18px; height: 18px; }

.pb-btn.secondary {
  background: var(--surface);
  color: var(--text-secondary);
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--border);
  width: 38px;
  height: 38px;
}

.pb-btn.secondary:hover {
  background: var(--bg-soft);
  color: var(--primary-dark);
  border-color: var(--primary-light);
}

.pb-btn.secondary svg { width: 16px; height: 16px; }

.pb-btn.repeat-active {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

.pb-info {
  font-size: 0.8rem;
  color: var(--text-secondary);
  min-width: 64px;
  text-align: center;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

/* ============================================
   角色标识色 - 柔和高级
   ============================================ */
.role-A { background: linear-gradient(135deg, #F87171, #DC2626); }
.role-B { background: linear-gradient(135deg, #2DD4BF, #0D9488); }
.role-C { background: linear-gradient(135deg, #FBBF24, #D97706); }
.role-D { background: linear-gradient(135deg, #C4B5FD, #8B5CF6); }

/* ============================================
   页脚
   ============================================ */
.footer {
  text-align: center;
  padding: 48px 20px 32px;
  color: var(--text-tertiary);
  font-size: 0.78rem;
  letter-spacing: 0.01em;
}

/* ============================================
   响应式：平板 (768px - 1024px)
   ============================================ */
@media (min-width: 769px) and (max-width: 1024px) {
  .script-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
  .container { padding: 20px 24px; }
}

@media (min-width: 1025px) {
  .script-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
  }
}

/* ============================================
   响应式：手机 (<=768px)
   ============================================ */
@media (max-width: 768px) {
  html { -webkit-tap-highlight-color: transparent; }

  .navbar { padding: 0 16px; }
  .nav-inner { height: 52px; }
  .logo { font-size: 0.98rem; gap: 9px; }
  .logo-icon { width: 28px; height: 28px; border-radius: 7px; }
  .logo-icon svg { width: 15px; height: 15px; }
  .nav-links { gap: 1px; }
  .nav-link { padding: 7px 11px; font-size: 0.78rem; }

  .container { padding: 16px 16px; }
  .page-header { padding: 24px 0 20px; }
  .page-title { font-size: 1.45rem; }
  .page-subtitle { font-size: 0.82rem; }

  .search-bar { margin-bottom: 20px; }
  .search-input { padding: 12px 44px 12px 42px; font-size: 0.88rem; border-radius: 12px; }
  .search-icon { left: 14px; width: 16px; height: 16px; }
  .search-btn { width: 32px; height: 32px; right: 5px; }
  .search-btn svg { width: 14px; height: 14px; }

  .category-tabs {
    gap: 6px;
    margin-bottom: 20px;
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
    scrollbar-width: none;
    margin-left: -16px;
    margin-right: -16px;
    padding-left: 16px;
    padding-right: 16px;
  }
  .category-tabs::-webkit-scrollbar { display: none; }
  .category-tab { padding: 7px 12px; font-size: 0.76rem; flex-shrink: 0; }

  .script-grid { grid-template-columns: 1fr; gap: 12px; }
  .script-card { padding: 18px; border-radius: var(--radius-md); }
  .card-title { font-size: 1rem; }
  .card-scene { font-size: 0.78rem; margin-bottom: 12px; }
  .card-meta { gap: 12px; font-size: 0.73rem; }
  .card-fav { width: 34px; height: 34px; }
  .card-badges { position: static; margin-bottom: 8px; }

  .back-btn { margin-bottom: 12px; padding: 7px 12px; font-size: 0.78rem; }

  .script-detail-header { padding: 20px 18px; border-radius: var(--radius-lg); }
  .script-detail-header h1 { font-size: 1.2rem; }
  .detail-header-top { flex-direction: column; gap: 14px; }
  .detail-header-actions { flex-direction: row; width: 100%; gap: 8px; }
  .detail-header-info { min-width: 0; overflow: hidden; }
  .detail-meta { flex-wrap: wrap; gap: 12px; font-size: 0.78rem; }

  .action-btn {
    flex: 1; justify-content: center;
    padding: 9px 10px; font-size: 0.78rem;
    border-radius: var(--radius-sm);
  }

  .control-panel {
    flex-direction: column; align-items: stretch;
    padding: 14px 16px; gap: 12px;
    border-radius: var(--radius-md);
  }
  .control-group { justify-content: space-between; flex-wrap: nowrap; }
  .control-label { font-size: 0.78rem; }
  .btn { padding: 9px 14px; font-size: 0.8rem; flex: 1; justify-content: center; }
  .role-select { padding: 8px 30px 8px 11px; font-size: 0.82rem; max-width: 160px; }

  .dialogue-container { padding: 14px; border-radius: var(--radius-md); min-height: 220px; }
  .dialogue-line {
    padding: 12px 10px; gap: 11px;
    margin-bottom: 8px; border-radius: var(--radius-sm);
  }
  .line-avatar { width: 34px; height: 34px; font-size: 0.88rem; }
  .line-content { padding-right: 66px; }
  .line-en { font-size: 0.9rem; }
  .line-zh { font-size: 0.79rem; }
  .line-role { font-size: 0.7rem; }
  .line-actions { opacity: 1; top: 11px; right: 8px; }
  .line-btn { width: 30px; height: 30px; }
  .line-btn svg { width: 13px; height: 13px; }

  .progress-bar { margin-top: 14px; }

  .playback-bar {
    padding: 8px 10px; gap: 6px;
    bottom: 12px;
    padding-bottom: 8px;
  }
  .pb-btn { width: 40px; height: 40px; }
  .pb-btn svg { width: 16px; height: 16px; }
  .pb-btn.secondary { width: 36px; height: 36px; }
  .pb-btn.secondary svg { width: 14px; height: 14px; }
  .pb-info { font-size: 0.74rem; min-width: 56px; }

  .footer { padding: 32px 16px 100px; font-size: 0.75rem; }
  .empty-state { padding: 56px 16px; }
  .empty-state .icon { width: 56px; height: 56px; }
  .empty-state .icon svg { width: 24px; height: 24px; }
}

/* === 手机小屏 === */
@media (max-width: 380px) {
  .logo span { display: none; }
  .nav-link { padding: 6px 9px; font-size: 0.72rem; }
  .page-title { font-size: 1.28rem; }
  .search-input { padding: 11px 40px 11px 38px; font-size: 0.84rem; }
  .search-icon { left: 12px; width: 15px; height: 15px; }
  .script-card { padding: 16px; }
  .card-title { font-size: 0.95rem; }
  .dialogue-line { padding: 10px 8px; gap: 9px; }
  .line-avatar { width: 30px; height: 30px; font-size: 0.82rem; }
  .line-en { font-size: 0.86rem; }
  .line-zh { font-size: 0.76rem; }
  .script-detail-header h1 { font-size: 1.08rem; }
  .pb-btn { width: 38px; height: 38px; }
  .pb-btn.secondary { width: 34px; height: 34px; }
  .action-btn { font-size: 0.74rem; padding: 8px 8px; }
  .role-select { max-width: 130px; }
}

/* === 大屏桌面优化 === */
@media (min-width: 1280px) {
  .script-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 22px;
  }
}

/* ============================================
   动画
   ============================================ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.script-card {
  opacity: 0;
  animation: fadeInUp 0.45s var(--ease-out) forwards;
}
.script-card:nth-child(1) { animation-delay: 0.02s; }
.script-card:nth-child(2) { animation-delay: 0.05s; }
.script-card:nth-child(3) { animation-delay: 0.08s; }
.script-card:nth-child(4) { animation-delay: 0.11s; }
.script-card:nth-child(5) { animation-delay: 0.14s; }
.script-card:nth-child(6) { animation-delay: 0.17s; }
.script-card:nth-child(n+7) { animation-delay: 0.2s; }

@media (prefers-reduced-motion: reduce) {
  .script-card { animation: none; opacity: 1; }
  * { transition-duration: 0.01ms !important; }
}

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }
