/* ============================================================
 * 变速视频播放器 · 深色主题（GitHub Dark 风格，与网站统一）
 * ============================================================ */
:root {
  --bg-deep: #0d1117;
  --bg-surface: #161b22;
  --bg-elevated: #21262d;
  --bg-hover: #30363d;
  --border: #30363d;
  --border-subtle: #21262d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent-blue: #58a6ff;
  --accent-purple: #bc8cff;
  --accent-cyan: #39c5cf;
  --accent-green: #3fb950;
  --accent-orange: #f0883e;
  --accent-red: #f85149;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(0,0,0,.45);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', 'PingFang SC', 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, rgba(88,166,255,.08), transparent 60%), var(--bg-deep);
  color: var(--text-primary); min-height: 100vh; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
.app { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  background: var(--bg-surface); color: var(--text-primary);
  padding: 16px 28px; display: flex; align-items: center; gap: 16px;
  border-bottom: 1px solid var(--border); box-shadow: 0 2px 16px rgba(0,0,0,.35);
}
.topbar .logo { font-size: 30px; }
.topbar h1 { font-size: 1.5rem; letter-spacing: .5px; }
.topbar .en { font-size: 1rem; opacity: .75; font-weight: 400; }
.topbar .sub { color: var(--text-secondary); font-size: 13px; margin-top: 2px; }
.back-home {
  margin-left: auto; color: var(--accent-blue); text-decoration: none; font-size: 13.5px;
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; white-space: nowrap;
}
.back-home:hover { border-color: var(--accent-blue); background: rgba(88,166,255,.08); }

.layout { display: flex; gap: 18px; padding: 18px; max-width: 1480px; margin: 0 auto; width: 100%; align-items: flex-start; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.side { width: 360px; flex-shrink: 0; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 18px; }

.card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px;
}
.card h2 { color: var(--text-primary); font-size: 1.15rem; margin-bottom: 6px; }
.note { color: var(--text-secondary); font-size: 13px; line-height: 1.7; margin: 8px 0; }
.note strong { color: var(--text-primary); }
.note code {
  background: var(--bg-deep); border: 1px solid var(--border); border-radius: 5px;
  padding: 1px 6px; font-family: 'Consolas', monospace; font-size: 12px; color: var(--accent-cyan);
}
.note a { color: var(--accent-blue); text-decoration: none; }
.note a:hover { text-decoration: underline; }

/* 拖拽区 */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 36px 20px; text-align: center; cursor: pointer; transition: all .2s;
  background: var(--bg-surface);
}
.dropzone.drag { border-color: var(--accent-blue); background: rgba(88,166,255,.08); }
.dz-inner { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.dz-icon { font-size: 46px; }
.dz-title { font-size: 1.05rem; font-weight: 600; }
.dz-hint { color: var(--text-muted); font-size: 12.5px; margin-bottom: 8px; }

.video { width: 100%; border-radius: var(--radius); background: #000; display: block; margin-top: 4px; }

.player-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.mini-check { font-size: 12.5px; color: var(--text-secondary); display: flex; align-items: center; gap: 5px; cursor: pointer; }
.speed-badge {
  margin-left: auto; font-weight: 800; font-size: 15px; color: #0d1117;
  background: var(--accent-cyan); padding: 4px 14px; border-radius: 999px;
}

/* 时间轴 */
.timeline-card { margin-top: 14px; }
.timeline {
  position: relative; height: 46px; border-radius: 8px; overflow: hidden;
  background: var(--bg-elevated); border: 1px solid var(--border); cursor: pointer;
}
.timeline .seg {
  position: absolute; top: 0; bottom: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #0d1117;
  border-right: 1px solid rgba(13,17,23,.35);
  overflow: hidden; white-space: nowrap;
}
.playhead {
  position: absolute; top: -3px; bottom: -3px; width: 3px;
  background: #fff; box-shadow: 0 0 8px rgba(255,255,255,.8); left: 0; pointer-events: none;
}
.timeline-legend { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--text-muted); }
.legend-grad { width: 120px; height: 10px; border-radius: 6px; background: linear-gradient(90deg, hsl(210,70%,50%), hsl(20,80%,52%)); }
.tl-info { margin-left: auto; color: var(--text-secondary); }

/* 统计 */
.stats-row { display: flex; gap: 14px; margin: 6px 0 10px; }
.stat { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 10px; padding: 12px 18px; text-align: center; flex: 1; }
.stat span { display: block; font-size: 1.5rem; font-weight: 800; color: var(--accent-blue); }
.stat label { font-size: 12px; color: var(--text-muted); }

/* 预设 / 片段 */
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 14px; }
.chip {
  background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text-primary);
  padding: 7px 12px; border-radius: 999px; font-size: 12.5px; cursor: pointer; transition: all .15s;
}
.chip:hover { border-color: var(--accent-blue); color: var(--accent-blue); }

/* 二维样条曲线编辑器 */
.curve-editor { position: relative; margin: 6px 0 4px; }
.curve-svg {
  width: 100%; height: 220px; display: block;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 8px;
  touch-action: none; cursor: crosshair; user-select: none;
}
.curve-grid-line { stroke: var(--border); stroke-width: 1; }
.curve-axis-text { fill: var(--text-muted); font-size: 10px; font-family: 'Consolas', monospace; }
.curve-path { fill: none; stroke: var(--accent-blue); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.curve-play { stroke: #ffffff; stroke-width: 1.5; stroke-dasharray: 3 3; opacity: .85; pointer-events: none; }
.curve-pt { fill: var(--accent-cyan); stroke: #0d1117; stroke-width: 1.5; cursor: grab; }
.curve-pt:hover { fill: #7fe3e8; }
.curve-pt.endpoint { fill: var(--accent-purple); }
.curve-pt.sel { stroke: #fff; stroke-width: 2.5; }
.curve-hint { font-size: 12px; color: var(--text-muted); margin: 6px 0 10px; }

.seg-list { display: flex; flex-direction: column; gap: 8px; }
.seg-row {
  display: grid; grid-template-columns: 26px 1fr 1fr 30px; gap: 8px; align-items: center;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px;
}
.seg-row .idx { font-weight: 800; color: var(--text-muted); text-align: center; }
.seg-row input {
  width: 100%; background: var(--bg-surface); border: 1px solid var(--border);
  color: var(--text-primary); border-radius: 6px; padding: 6px 8px; font-size: 13px; font-family: 'Consolas', monospace;
}
.seg-row input:focus { outline: none; border-color: var(--accent-blue); }
.seg-row .seg-speed { display: flex; align-items: center; gap: 4px; }
.seg-row .seg-speed input { flex: 1; }
.seg-row .seg-speed span { color: var(--text-muted); font-size: 12px; }
.seg-row .del { background: transparent; border: none; color: var(--accent-red); cursor: pointer; font-size: 16px; }
.seg-row .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 4px; }

.btn {
  border: none; border-radius: 9px; padding: 9px 18px; font-size: 14px; font-weight: 700;
  cursor: pointer; transition: all .15s; font-family: inherit;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent-blue); color: #0d1117; }
.btn-primary:hover:not(:disabled) { background: #79c0ff; }
.btn-ghost { background: var(--bg-hover); color: var(--accent-blue); }
.btn-ghost:hover:not(:disabled) { background: var(--border); }
.btn-danger { background: rgba(248,81,73,.14); color: var(--accent-red); border: 1px solid var(--accent-red); }
.btn-danger:hover:not(:disabled) { background: rgba(248,81,73,.28); }
.btn.full { width: 100%; margin-top: 10px; }

/* 导出 */
.ff-cmd {
  width: 100%; background: var(--bg-deep); border: 1px solid var(--border); color: var(--accent-green);
  border-radius: 8px; padding: 12px; font-family: 'Consolas', 'Monaco', monospace; font-size: 12px;
  line-height: 1.5; resize: vertical; margin: 6px 0 10px; white-space: pre;
}
.export-actions { display: flex; gap: 10px; }

@media (max-width: 980px) {
  .layout { flex-direction: column; }
  .side { width: 100%; position: static; }
  .topbar { flex-wrap: wrap; }
}

/* 双来源切换 */
.source-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tab {
  flex: 1; background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text-secondary);
  padding: 9px 12px; border-radius: 9px; font-size: 13.5px; font-weight: 700; cursor: pointer; transition: all .15s;
}
.tab:hover { border-color: var(--accent-blue); color: var(--accent-blue); }
.tab.active { background: var(--accent-blue); color: #0d1117; border-color: var(--accent-blue); }

/* B 站导入表单 */
.bzhan-form { display: flex; flex-direction: column; gap: 10px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.bzhan-input {
  width: 100%; background: var(--bg-deep); border: 1px solid var(--border); color: var(--text-primary);
  border-radius: 8px; padding: 10px 12px; font-size: 13.5px; font-family: 'Consolas', monospace;
}
.bzhan-input:focus { outline: none; border-color: var(--accent-blue); }
.bzhan-hint { margin: 0; padding: 8px 10px; background: rgba(88,166,255,.07); border-left: 3px solid var(--accent-blue); border-radius: 6px; }
.page-info { margin: 0; padding: 8px 10px; background: rgba(63,185,80,.08); border-left: 3px solid var(--accent-green); border-radius: 6px; }
.quota-note { margin: 2px 0 0; font-size: 12px; color: var(--text-muted); }
.bzhan-cookie { font-size: 12.5px; color: var(--text-secondary); }
.bzhan-cookie summary { cursor: pointer; color: var(--accent-cyan); }
.bzhan-cookie textarea {
  width: 100%; margin-top: 8px; background: var(--bg-deep); border: 1px solid var(--border); color: var(--text-primary);
  border-radius: 8px; padding: 10px; font-size: 12px; font-family: 'Consolas', monospace; resize: vertical;
}
.bzhan-cookie textarea:focus { outline: none; border-color: var(--accent-blue); }
.bzhan-actions { display: flex; gap: 10px; }
.bzhan-status { font-size: 12.5px; color: var(--text-secondary); min-height: 18px; line-height: 1.6; }
.bzhan-status:empty { display: none; }
.bzhan-status.err { color: var(--accent-red); }
.bzhan-status.ok { color: var(--accent-green); }

/* 进度条 */
.progress-wrap { display: flex; align-items: center; gap: 10px; }
.progress { flex: 1; height: 8px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan)); transition: width .3s; }
.progress-pct { font-size: 12px; color: var(--text-secondary); font-family: 'Consolas', monospace; min-width: 38px; text-align: right; }

/* 缓存列表 */
.cache-list { display: flex; flex-direction: column; gap: 6px; background: var(--bg-deep); border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.cache-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 6px;
  cursor: pointer; font-size: 12.5px; border: 1px solid transparent;
}
.cache-item:hover { background: var(--bg-hover); border-color: var(--accent-blue); }
.cache-item .c-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cache-item .c-size { color: var(--text-muted); font-family: 'Consolas', monospace; }
.cache-item .c-del {
  flex-shrink: 0; background: transparent; border: 1px solid var(--border);
  color: var(--accent-red); border-radius: 6px; padding: 3px 8px; font-size: 12px; cursor: pointer;
}
.cache-item .c-del:hover { background: rgba(248,81,73,.2); border-color: var(--accent-red); }
.cache-sum { font-size: 12px; color: var(--text-muted); padding: 2px 6px; }

/* 自然语言搜索 */
.bzhan-search { display: flex; gap: 8px; }
.bzhan-search .bzhan-input { flex: 1; }
.search-results {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 320px; overflow-y: auto; padding: 4px; margin: 2px 0;
  background: var(--bg-deep); border: 1px solid var(--border); border-radius: 8px;
}
.search-head { font-size: 12px; color: var(--text-muted); padding: 2px 6px; }
.search-loading, .search-err { font-size: 12.5px; color: var(--text-muted); padding: 8px 6px; }
.search-err { color: var(--accent-red); }
.search-item {
  display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 8px;
  cursor: pointer; border: 1px solid transparent; transition: all .15s;
}
.search-item:hover { background: var(--bg-hover); }
.search-item.sel { border-color: var(--accent-blue); background: rgba(88,166,255,.08); }
.s-cover { width: 96px; height: 60px; object-fit: cover; border-radius: 6px; flex-shrink: 0; background: var(--bg-elevated); }
.s-main { min-width: 0; flex: 1; }
.s-title {
  font-size: 13px; font-weight: 600; color: var(--text-primary); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.s-meta { font-size: 11.5px; color: var(--text-secondary); margin-top: 3px; }
.s-bv { font-size: 11px; color: var(--text-muted); font-family: 'Consolas', monospace; margin-top: 2px; }
