/* ============================================================
   飛象影片學習站 — 共用樣式
   設計語彙：暗色磨砂玻璃 / 電光藍 #2563EB / 等寬數字 / 大量留白
   ============================================================ */
:root {
  --bg: #0F0F0F;
  --bg-soft: #171717;
  --panel: rgba(23, 23, 23, 0.85);
  --border: rgba(255, 255, 255, 0.08);
  --border-soft: rgba(255, 255, 255, 0.05);
  --text: #EDEDED;
  --text-dim: #C4C4C4;
  --text-faint: #9C9C9C;
  --accent: #2563EB;
  --accent-soft: rgba(37, 99, 235, 0.15);
  --green: #34C759;
  --amber: #F59E0B;
  --red: #DC2626;
  --radius: 12px;
  --font: 'Microsoft JhengHei', 'PingFang TC', 'Noto Sans TC', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
}

.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

.mono { font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }

/* ---------- 首頁：頂欄 ---------- */
.site-header {
  padding: 28px 0 18px;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.06), transparent 60%);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo {
  width: 46px; height: 46px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; letter-spacing: 0.02em;
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.35);
}
.brand h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.brand-sub { margin: 2px 0 0; font-size: 13px; color: var(--text-dim); }

.home-header-inner,
.player-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.player-header-main { min-width: 0; }
.tool-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-soft);
  border: 1px solid rgba(37, 99, 235, 0.45);
  color: #BFDBFE;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 9999px;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}
.tool-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
}

/* ---------- 首頁：節目卡片 ---------- */
.program-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 22px;
  padding: 28px 0 40px;
}
.program-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.program-card:hover {
  transform: translateY(-3px);
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(37, 99, 235, 0.18);
}
.program-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}
.program-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.program-thumb::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgba(0, 0, 0, 0.55));
}
.program-lang {
  position: absolute;
  top: 10px; right: 10px;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid var(--border);
  color: #BFDBFE;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  backdrop-filter: blur(6px);
}
.program-body { padding: 14px 16px 16px; }
.program-body h3 { margin: 0 0 6px; font-size: 16px; font-weight: 600; }
.program-body p { margin: 0; font-size: 13px; color: var(--text-dim); }

.loading-hint { padding: 48px 0; text-align: center; color: var(--text-dim); font-size: 14px; }
.loading-hint.error { color: var(--amber); }

.site-footer {
  border-top: 1px solid var(--border-soft);
  padding: 18px 0 30px;
  color: var(--text-faint);
  font-size: 12.5px;
}
.site-footer code {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border-soft);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- 播放頁：頂欄 ---------- */
.player-header { padding: 18px 0 14px; }
.back-link {
  display: inline-block;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13.5px;
  margin-bottom: 10px;
  transition: color 0.15s;
}
.back-link:hover { color: #fff; }
.player-title-block h1 { margin: 0; font-size: 20px; font-weight: 600; }
.player-desc { margin: 4px 0 0; font-size: 13px; color: var(--text-dim); }

/* ---------- 播放頁：影片區 ---------- */
.player-shell { max-width: 1440px; padding-bottom: 48px; }
.player-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 20px;
}
.player-main { min-width: 0; }
.player-side { min-width: 0; }
.player-side .vocab-panel { position: sticky; top: 16px; }
.video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.video-wrap iframe {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border: 0;
}

.player-error {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.82);
  color: #FECACA;
  font-size: 14px;
  text-align: center;
  padding: 24px;
  z-index: 5;
}
.player-error[hidden] { display: none; }

/* ---------- 播放頁：控制面板 ---------- */
.control-panel {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 14px 18px 16px;
}

.ab-timeline {
  height: 22px;
  display: flex;
  align-items: center;
  cursor: pointer;
  position: relative;
}
.ab-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 9999px;
  position: relative;
  transition: height 0.12s ease;
}
.ab-timeline:hover .ab-track { height: 6px; }
.ab-range {
  position: absolute;
  height: 100%;
  background: var(--accent);
  border-radius: 9999px;
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.55);
}
.ab-handle {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 18px;
  background: #fff;
  border-radius: 9999px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  cursor: ew-resize;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.1s ease;
  z-index: 2;
}
.ab-playhead {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 12px;
  background: #fff;
  border-radius: 9999px;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
  pointer-events: none;
  z-index: 1;
  transition: height 0.12s ease;
}
.ab-timeline:hover .ab-playhead { height: 16px; }
.ab-handle:hover { transform: translate(-50%, -50%) scale(1.25); }
.ab-timeline:hover .ab-handle { opacity: 1; }
.ab-handle.dragging { opacity: 1; transform: translate(-50%, -50%) scale(1.25); }

.control-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.cb-left, .cb-center, .cb-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.loop-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.18s ease;
}
.loop-pill.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
}
.loop-dot {
  width: 8px; height: 8px;
  border-radius: 9999px;
  background: var(--text-faint);
  transition: background 0.18s ease;
}
.loop-pill.on .loop-dot { background: #fff; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.now-time { font-size: 13px; color: var(--text); }
.time-sep { color: var(--text-faint); font-size: 12px; }
.dur-time { font-size: 13px; color: var(--text-faint); }

.anchor {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid transparent;
  transition: all 0.15s;
}
.anchor.clickable { cursor: pointer; }
.anchor.clickable:hover { background: rgba(37, 99, 235, 0.25); border-color: rgba(37, 99, 235, 0.5); }
.anchor-sep { color: var(--text-faint); font-size: 13px; }

.divider { width: 1px; height: 18px; background: rgba(255, 255, 255, 0.12); }

.mini-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-soft);
  color: var(--text-dim);
  font-size: 12.5px;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s ease;
  white-space: nowrap;
}
.mini-btn:hover { color: #fff; border-color: rgba(255, 255, 255, 0.2); }
.mini-btn.strong { color: #BFDBFE; }
.mini-btn.strong:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.mini-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.speed-wrap { display: inline-flex; align-items: center; gap: 6px; }
.speed-label { font-size: 12px; color: var(--text-faint); }
.speed-select {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-soft);
  color: #BFDBFE;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  padding: 5px 8px;
  border-radius: 8px;
  cursor: pointer;
  outline: none;
}
.speed-select:focus { border-color: var(--accent); }

/* ---------- 詞匯面板 ---------- */
.vocab-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.vocab-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
  color: var(--text-dim);
}
.seg-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
}
.seg-label {
  flex: 1 1 auto;
  text-align: center;
  font-size: 13px;
  color: #BFDBFE;
  white-space: nowrap;
}
.sub-filter {
  flex: 1 1 auto;
  min-width: 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-soft);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s ease;
}
.sub-filter::placeholder { color: var(--text-faint); }
.sub-filter:focus { border-color: var(--accent); }

.offset-wrap {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
}
.offset-label { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.sub-offset {
  width: 66px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-soft);
  color: #BFDBFE;
  border-radius: 8px;
  padding: 7px 8px;
  font-size: 13px;
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
  outline: none;
  text-align: center;
}
.sub-offset:focus { border-color: var(--accent); }
.sub-offset::-webkit-outer-spin-button,
.sub-offset::-webkit-inner-spin-button { opacity: 0.5; }

.pinned-word {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--border-soft);
  border-left: 3px solid var(--accent);
}
.pinned-word[hidden] { display: none; }
.pinned-en { font-size: 26px; font-weight: 700; color: #fff; line-height: 1.2; }
.pinned-zh { font-size: 18px; color: #BFDBFE; }

.vocab-search-wrap {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
}
.vocab-search-wrap .sub-filter { width: 100%; }
.vocab-list {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  padding: 14px 16px 18px;
  max-height: calc(100vh - 320px);
  overflow-y: auto;
}
.vocab-chip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-soft);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 7px 13px;
  border-radius: 9999px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.vocab-chip:hover { color: #fff; border-color: rgba(37, 99, 235, 0.5); background: var(--accent-soft); }
.vocab-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}
.vocab-empty {
  padding: 30px 18px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13.5px;
  line-height: 1.7;
}

/* ---------- OSD 提示 ---------- */
.osd {
  position: fixed;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  padding: 12px 26px;
  border-radius: 9999px;
  font-size: 14.5px;
  font-weight: 500;
  pointer-events: none;
  opacity: 0;
  transition: all 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 1000;
  white-space: nowrap;
  max-width: 92vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.osd.active { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ---------- 響應式 ---------- */
@media (max-width: 1024px) {
  .player-layout { grid-template-columns: 1fr; }
  .player-side .vocab-panel { position: static; }
  .vocab-list { max-height: 380px; }
}
@media (max-width: 760px) {
  .container { padding: 0 14px; }
  .program-grid { grid-template-columns: 1fr; }
  .control-bar { flex-direction: column; align-items: stretch; }
  .cb-center, .cb-right { justify-content: flex-start; }
  .seg-nav { justify-content: flex-start; }
}
