/* ============================================================
 * style.css — 智能播放器样式
 * ============================================================ */
:root {
  --bg: #12121a;
  --bg2: #1a1a24;
  --panel: #1e1e2a;
  --panel2: #26263a;
  --text: #f0f0f5;
  --text2: #9a9ab0;
  --accent: #ff3b30;   /* 播放器外框颜色，可被设置覆盖 */
  --border: #2e2e42;
  --radius: 14px;
  --danger: #ff453a;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
}

.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }

/* ================= 顶部工具条 ================= */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: linear-gradient(180deg, #1b1b28, #15151f);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-dot {
  width: 16px; height: 16px; border-radius: 5px;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: .5px; }

.toolbar-actions { display: flex; gap: 8px; }
.tb-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 7px 12px; font-size: 13px; cursor: pointer;
  transition: .15s;
}
.tb-btn:hover { background: var(--panel2); border-color: var(--accent); }
.tb-btn svg { width: 16px; height: 16px; fill: currentColor; stroke: none; }

/* ================= 主体 ================= */
.main { flex: 1; min-height: 0; display: flex; }
.player-column { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 12px; gap: 10px; }

/* ================= 播放器外框 ================= */
.player-frame {
  flex: 1; min-height: 0;
  display: flex; gap: 10px;
  background: var(--bg2);
  border: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: 0 0 24px -6px var(--accent);
  overflow: hidden;
}

/* ================= 视频舞台 ================= */
.video-stage {
  flex: 1; min-width: 0; position: relative;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
}
#video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  background: #000;
}
/* 画面比例：16:9 / 9:16 / 4:3 / 原始 */
.video-stage.ratio-auto #video { inset: 0; width: 100%; height: 100%; transform: none; }
.video-stage.ratio-169 #video {
  inset: auto; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 100%; height: auto; aspect-ratio: 16 / 9;
}
.video-stage.ratio-916 #video {
  inset: auto; left: 50%; top: 50%; transform: translate(-50%, -50%);
  height: 100%; width: auto; aspect-ratio: 9 / 16;
}
.video-stage.ratio-43 #video {
  inset: auto; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 100%; height: auto; aspect-ratio: 4 / 3;
}
.video-stage.ratio-origin #video { inset: auto; left: 50%; top: 50%; transform: translate(-50%, -50%); }

/* 封面层 */
.poster-layer {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #101018, #0a0a12);
  z-index: 2;
}
.poster-layer img { width: 100%; height: 100%; object-fit: contain; }
.poster-empty { text-align: center; color: var(--text2); }
.pe-icon { font-size: 44px; margin-bottom: 12px; opacity: .6; }
.pe-text { font-size: 14px; line-height: 1.8; }

/* 顶部剧集名窄条（暂停时显示） */
.title-bar {
  position: absolute; top: 0; left: 0; right: 0;
  z-index: 6;
  background: linear-gradient(180deg, rgba(0,0,0,.82), rgba(0,0,0,0));
  padding: 8px 14px;
  pointer-events: none;
}
.title-bar-text {
  font-size: 12.5px; font-weight: 600; color: #fff;
  letter-spacing: .5px;
  display: inline-block;
  background: rgba(0,0,0,.45);
  border-radius: 6px;
  padding: 3px 10px;
  border-left: 3px solid var(--accent);
}

/* 中央播放按钮 */
.center-play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: 72px; height: 72px; border-radius: 50%;
  background: rgba(0,0,0,.5); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  color: #fff; z-index: 5; cursor: pointer;
  border: 2px solid rgba(255,255,255,.35);
}
.center-play svg { width: 34px; height: 34px; margin-left: 4px; }
.center-play:hover { background: rgba(0,0,0,.7); }

/* 加载 */
.loading {
  position: absolute; inset: 0; z-index: 4;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: rgba(0,0,0,.55); color: #fff; font-size: 13px;
}
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.2); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================= 控制栏 ================= */
.controls {
  position: absolute; left: 0; right: 158px; bottom: 0; z-index: 7;
  background: linear-gradient(0deg, rgba(0,0,0,.85), rgba(0,0,0,0));
  padding: 26px 12px 10px;
  opacity: 0; transition: opacity .25s;
}
.controls.show { opacity: 1; }
.controls-row { display: flex; align-items: center; gap: 6px; }

.c-btn {
  background: none; border: none; color: #fff;
  min-width: 34px; height: 34px; padding: 0 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; border-radius: 8px; cursor: pointer;
}
.c-btn:hover { background: rgba(255,255,255,.12); }
.c-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.c-btn svg path { stroke: currentColor; }
.c-btn.active { color: var(--accent); }

/* 进度条 */
.seek-wrap { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 60px; }
.time-info { font-size: 11px; color: rgba(255,255,255,.8); font-variant-numeric: tabular-nums; }
.time-info .sep { margin: 0 4px; opacity: .5; }
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  height: 4px; background: rgba(255,255,255,.25); border-radius: 4px; outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff;
  box-shadow: 0 0 6px rgba(0,0,0,.5);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff;
}
.vol { width: 64px; height: 4px; }

/* 倍速/比例下拉 */
.speed-wrap, .ratio-wrap { position: relative; }
.speed-menu, .ratio-menu {
  position: absolute; bottom: 42px; right: 0;
  background: rgba(20,20,30,.96); border: 1px solid var(--border); border-radius: 10px;
  padding: 6px; min-width: 140px; z-index: 20;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.sm-title { font-size: 11px; color: var(--text2); padding: 4px 10px 6px; }
.sm-item {
  padding: 7px 10px; font-size: 13px; border-radius: 6px; cursor: pointer;
  display: flex; justify-content: space-between;
}
.sm-item:hover { background: rgba(255,255,255,.1); }
.sm-item.active { color: var(--accent); background: rgba(255,69,58,.12); }

/* ================= 选集面板 ================= */
.episode-panel {
  width: 158px; min-width: 0; flex-shrink: 0;
  background: var(--panel);
  border-radius: 10px;
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: width .2s;
}
.episode-panel.collapsed { width: 0; border: none; }
.episode-panel.collapsed .ep-list,
.episode-panel.collapsed .ep-header,
.episode-panel.collapsed .ep-footer { display: none; }

.ep-header {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
.ep-set { margin-left: auto; background: none; border: none; color: var(--text2); font-size: 15px; cursor: pointer; }
.ep-set:hover { color: var(--accent); }
.ep-collapse { background: none; border: none; color: var(--text2); font-size: 15px; cursor: pointer; padding: 0 2px; }
.ep-collapse:hover { color: var(--accent); }

.ep-list {
  flex: 1; overflow-y: auto; padding: 8px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  align-content: start;
}
.ep-list::-webkit-scrollbar { width: 4px; }
.ep-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.ep-item {
  height: 38px; display: flex; align-items: center; justify-content: center;
  background: var(--panel2); border-radius: 8px;
  font-size: 12px; cursor: pointer;
  border: 1px solid transparent;
  position: relative; overflow: hidden;
  transition: .12s;
}
.ep-item:hover { border-color: var(--accent); }
.ep-item.active { background: var(--accent); color: #fff; font-weight: 700; box-shadow: 0 2px 8px -2px var(--accent); }
.ep-item.has-video::after {
  content: "●"; position: absolute; right: 5px; bottom: 2px;
  font-size: 8px; color: #4cd97b;
}
.ep-item.active.has-video::after { color: #fff; }

.ep-footer { padding: 8px; border-top: 1px solid var(--border); flex-shrink: 0; }
.ep-import {
  width: 100%; padding: 8px; font-size: 12px;
  background: transparent; color: var(--text2);
  border: 1px dashed var(--border); border-radius: 8px; cursor: pointer;
}
.ep-import:hover { color: var(--accent); border-color: var(--accent); }

/* 播放器说明条 */
.hint-bar {
  font-size: 12px; color: var(--text2);
  padding: 2px 6px; line-height: 1.6;
}

/* ================= 模态框 ================= */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.65); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal {
  width: 440px; max-width: 100%; max-height: 88vh; overflow-y: auto;
  background: var(--panel); border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.modal-sm { width: 320px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
  font-size: 15px; font-weight: 700;
}
.modal-close { background: none; border: none; color: var(--text2); font-size: 22px; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--accent); }
.modal-body { padding: 16px 18px; }
.modal-foot { padding: 12px 18px 18px; display: flex; gap: 10px; justify-content: flex-end; }

.form-item { margin-bottom: 16px; }
.form-item label { display: block; font-size: 12.5px; color: var(--text2); margin-bottom: 8px; }
.form-item input[type="text"],
.form-item input[type="url"],
.form-item input[type="number"],
.form-item select {
  width: 100%; padding: 10px 12px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-size: 14px; outline: none;
}
.form-item input:focus, .form-item select:focus { border-color: var(--accent); }
.color-row { display: flex; align-items: center; gap: 12px; }
.color-row input[type="color"] {
  width: 46px; height: 36px; border: none; border-radius: 8px; background: none; cursor: pointer; padding: 0;
}
.color-row span { font-size: 13px; color: var(--text2); font-variant-numeric: tabular-nums; }

.net-tip {
  background: rgba(255,180,60,.1); border: 1px solid rgba(255,180,60,.3);
  border-radius: 10px; padding: 10px 12px;
  font-size: 12px; color: #f5c76a; line-height: 1.7; margin-bottom: 16px;
}

.m-btn {
  padding: 10px 20px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--panel2); color: var(--text); font-size: 13px; cursor: pointer;
}
.m-btn:hover { border-color: var(--accent); }
.m-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.m-btn.primary:hover { filter: brightness(1.1); }

/* ================= 移动端适配 ================= */
@media (max-width: 760px) {
  .toolbar { padding: 8px 10px; }
  .tb-btn span { display: none; }
  .tb-btn { padding: 8px; }
  .tb-btn svg { width: 18px; height: 18px; }
  .player-column { padding: 8px; }
  .episode-panel { width: 96px; }
  .controls { right: 96px; }
  .ep-list { grid-template-columns: repeat(2, 1fr); }
  .ep-item { height: 34px; font-size: 11px; }
  .ep-footer { display: none; }
  .ep-collapse { display: none; }
  .hint-bar { font-size: 11px; }
  .vol { display: none; }
  .controls-row { gap: 2px; }
  .c-btn { min-width: 30px; padding: 0 4px; }
}

/* ================= 激活界面（月卡） ================= */
.activate-mask {
  position: fixed; inset: 0; z-index: 200;
  background: radial-gradient(circle at 50% 30%, #1c1c2c, #0b0b12 70%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.activate-box {
  width: 380px; max-width: 100%;
  background: var(--panel); border: 1px solid var(--border); border-radius: 20px;
  padding: 34px 30px; text-align: center;
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
}
.act-logo { font-size: 52px; margin-bottom: 12px; }
.act-title { font-size: 22px; font-weight: 800; letter-spacing: 1px; margin-bottom: 6px; }
.act-sub { font-size: 13px; color: var(--text2); margin-bottom: 24px; }
.activate-box input[type="text"] {
  width: 100%; padding: 13px 14px; text-align: center; letter-spacing: 2px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); font-size: 16px; outline: none; margin-bottom: 14px;
  text-transform: uppercase;
}
.activate-box input:focus { border-color: var(--accent); }
.act-btn { width: 100%; padding: 13px; font-size: 15px; border-radius: 12px; }
.act-msg { margin-top: 12px; font-size: 13px; min-height: 20px; }
.act-msg.ok { color: #4cd97b; }
.act-msg.err { color: #ff5f57; }
.act-exp { margin-top: 6px; font-size: 12px; color: var(--text2); }
.act-foot { margin-top: 20px; font-size: 11px; color: var(--text2); line-height: 1.6; border-top: 1px dashed var(--border); padding-top: 14px; }

/* ================= 兼容转码提示 ================= */
.convert-tip {
  position: absolute; left: 12px; right: 12px; bottom: 56px; z-index: 6;
  background: rgba(20,20,30,.92); border: 1px solid rgba(255,160,60,.5);
  border-radius: 12px; padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
  backdrop-filter: blur(4px);
}
.ct-text { flex: 1; font-size: 12.5px; color: #f5c76a; line-height: 1.5; }
.convert-tip .m-btn { white-space: nowrap; }

/* ================= 移动端选集单列（集数 + 名字） ================= */
@media (max-width: 760px) {
  .episode-panel { width: 118px; }
  .controls { right: 118px; }
  .ep-list { grid-template-columns: 1fr; gap: 5px; padding: 6px; }
  .ep-item {
    height: auto; min-height: 40px; flex-direction: column;
    padding: 5px 6px; text-align: left; align-items: flex-start;
    font-size: 12px; line-height: 1.35;
  }
  .ep-item .ep-num { font-weight: 700; font-size: 12px; }
  .ep-item .ep-name {
    font-weight: 400; font-size: 10px; color: var(--text2);
    width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .ep-item.active .ep-name { color: rgba(255,255,255,.85); }
  .ep-item .ep-edit {
    position: absolute; right: 4px; top: 4px;
    font-size: 10px; color: var(--text2); cursor: pointer;
    background: rgba(255,255,255,.08); border-radius: 4px; padding: 0 4px;
  }
}

/* ========== v3 弹幕 ========== */
.danmaku-layer {
  position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 5;
}
.danmaku-item {
  position: absolute; white-space: nowrap; color: #fff; font-size: 18px; font-weight: 600;
  text-shadow: 1px 1px 2px rgba(0,0,0,.8), 0 0 4px rgba(0,0,0,.6);
  will-change: transform; animation: danmaku-fly linear forwards;
}
@keyframes danmaku-fly {
  from { transform: translateX(0); }
  to { transform: translateX(calc(-100vw - 100%)); }
}
/* 固定弹幕：屏幕上不动，淡入后一直显示不消失 */
.danmaku-item.fixed {
  left: 50% !important;
  transform: translateX(-50%);
  animation: danmaku-fixed 1s ease-out forwards;
}
@keyframes danmaku-fixed {
  0% { opacity: 0; transform: translateX(-50%) scale(0.8); }
  100% { opacity: 1; transform: translateX(-50%) scale(1); }
}
/* 弹幕输入行 */
.danmaku-row {
  display: flex; align-items: center; gap: 8px; padding: 4px 8px 6px;
}
.danmaku-input {
  flex: 1; height: 32px; padding: 0 12px; border: 1px solid rgba(255,255,255,.2);
  border-radius: 16px; background: rgba(0,0,0,.5); color: #fff; font-size: 13px; outline: none;
}
.danmaku-input::placeholder { color: rgba(255,255,255,.5); }
.danmaku-input:focus { border-color: var(--accent); }
.danmaku-send {
  height: 32px; padding: 0 18px; border: none; border-radius: 16px;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 600; cursor: pointer;
}
.danmaku-send:hover { opacity: .9; }

/* ========== v3 标题栏按钮 ========== */
.title-bar { display: flex; align-items: center; gap: 6px; padding: 0 8px; }
.tb-back, .tb-fs {
  background: none; border: none; color: #fff; font-size: 20px; cursor: pointer;
  width: 28px; height: 24px; display: flex; align-items: center; justify-content: center;
  opacity: .85; border-radius: 4px;
}
.tb-back:hover, .tb-fs:hover { opacity: 1; background: rgba(255,255,255,.15); }
.tb-back { display: none; }  /* 非全屏隐藏返回按钮 */

/* ========== v3 全屏模式 ========== */
body.is-fullscreen .video-stage { background: #000; }
body.is-fullscreen .title-bar { padding: 8px 14px; height: auto; }
body.is-fullscreen .tb-back { display: flex; }
body.is-fullscreen .danmaku-input { height: 36px; font-size: 14px; }
body.is-fullscreen .danmaku-send { height: 36px; padding: 0 22px; }
/* 全屏时选集面板变为右侧 overlay */
body.is-fullscreen .episode-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: 220px; z-index: 10;
  background: rgba(15,15,22,.92); backdrop-filter: blur(8px);
  border-left: 1px solid rgba(255,255,255,.1); margin: 0;
  padding: 0;  /* 去掉内边距，让选集占满空间 */
}
/* 全屏选集列表：去掉底部大padding，让剧集显示到底 */
body.is-fullscreen .episode-panel .ep-list { padding-bottom: 8px; padding-top: 8px; }
/* 全屏时控制栏右侧留出选集面板宽度，弹幕发送按钮不被遮挡 */
body.is-fullscreen .controls { right: 220px; }
body.is-fullscreen .controls .danmaku-row { max-width: calc(100vw - 240px); }

/* ========== 手机端全屏选集优化：选集延伸到底部，紧靠右侧 ========== */
@media (max-width: 760px) {
  body.is-fullscreen .episode-panel {
    bottom: 0 !important;  /* 选集延伸到底部，不留间隙 */
    top: 0 !important;     /* 选集延伸到顶部，不留间隙 */
    right: 0 !important;   /* 选集紧靠右侧，不留间隙 */
    /* 注意：width 不用 !important，让 JavaScript 拖动时可以动态修改宽度 */
    width: 180px;  /* 增加到180px，给剧集名字更多显示空间 */
    padding: 0;    /* 去掉内边距 */
  }
  body.is-fullscreen .controls {
    /* 注意：right 不用 !important，让 JavaScript 可以动态修改 */
    right: 180px;
  }
  body.is-fullscreen .controls .danmaku-row {
    max-width: calc(100vw - 200px);
  }
  /* 手机端全屏时选集列表：去掉底部大padding，让剧集显示到底 */
  body.is-fullscreen .episode-panel .ep-list {
    padding-bottom: 8px;
    padding-top: 8px;
    padding-left: 6px;
    padding-right: 6px;
  }
}
body.is-fullscreen .episode-panel .ep-list {
  grid-template-columns: 1fr; gap: 6px; padding: 8px; max-height: none; overflow-y: auto;
}
body.is-fullscreen .episode-panel .ep-item {
  height: auto; min-height: 44px; padding: 8px 12px; font-size: 13px;
  display: flex; align-items: center; gap: 10px; text-align: left;
  border-radius: 8px;
}
body.is-fullscreen .episode-panel .ep-item .ep-num {
  min-width: 28px; font-weight: 700; color: var(--accent); font-size: 14px;
}
body.is-fullscreen .episode-panel .ep-item.active .ep-num { color: #fff; }
body.is-fullscreen .episode-panel .ep-item .ep-name {
  flex: 1; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-size: 12px; color: rgba(255,255,255,.85);
}
body.is-fullscreen .episode-panel .ep-item.active .ep-name { color: #fff; }
body.is-fullscreen .episode-panel .ep-item .ep-edit { opacity: .6; font-size: 12px; }
body.is-fullscreen .episode-panel .ep-footer { display: none; }
/* 全屏时隐藏非视频区域（由 JS 处理 body class） */

/* v3 修复：播放/下一集按钮用填充图标，覆盖 c-btn 的 fill:none */
#btnPlay svg, #btnNext svg { fill: currentColor; stroke: none; }
#btnPlay svg path, #btnNext svg path { fill: currentColor; stroke: none; }

/* ========== v4 全屏模式完善（安卓可用） ========== */
body.is-fullscreen .toolbar,
body.is-fullscreen .hint-bar { display: none !important; }
body.is-fullscreen, body.is-fullscreen .app, body.is-fullscreen .main {
  margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden;
}
body.is-fullscreen .player-column { width: 100%; max-width: 100%; padding: 0 !important; gap: 0 !important; }
body.is-fullscreen .player-frame {
  width: 100vw; height: 100vh; border: none !important; border-radius: 0 !important; margin: 0;
  padding: 0 !important; box-shadow: none !important; gap: 0 !important;
}
body.is-fullscreen .video-stage { width: 100%; height: 100%; border-radius: 0; }
body.is-fullscreen #video { width: 100%; height: 100%; object-fit: contain; }
/* 全屏时选集面板可滚动 */
body.is-fullscreen .episode-panel .ep-list { overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ========== v5 选集收起/展开 + 拖动调整大小 ========== */
.episode-panel { position: relative; transition: width .25s ease, margin .25s ease; overflow: hidden; }
.episode-panel.collapsed { width: 0 !important; min-width: 0; margin: 0; padding: 0; border: none; }
.episode-panel.collapsed > *:not(.ep-resize) { display: none; }
/* 拖动调整宽度手柄（选集框内部左侧中间位置的小三角） */
.ep-resize {
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 24px; height: 50px; cursor: col-resize; z-index: 30;
  background: #ff6b35;
  border-radius: 0 8px 8px 0;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 2px 0 6px rgba(0,0,0,.3);
  transition: width .2s, opacity .2s;
  opacity: .9;
}
.ep-resize::before {
  content: '';
  width: 0; height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 6px solid rgba(255,255,255,.95);
}
.ep-resize:hover, .ep-resize.active {
  opacity: 1;
  width: 22px;
}
/* 选集收起时隐藏拖动把手 */
.episode-panel.collapsed .ep-resize { display: none; }

/* 纯数字模式时数字居中 */
.ep-item.num-only {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.ep-item.num-only .ep-num {
  min-width: auto;
  text-align: center;
}
/* 选集收起后的展开按钮（贴播放器右边） */
.ep-expand {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  z-index: 15; writing-mode: vertical-rl; text-orientation: mixed;
  background: var(--accent, #ff3b30); color: #fff; border: none; border-radius: 8px 0 0 8px;
  padding: 16px 6px; font-size: 13px; cursor: pointer; letter-spacing: 2px;
  box-shadow: -2px 0 8px rgba(0,0,0,.3);
}
.ep-expand:hover { opacity: .9; }

/* ========== v5 视频缩放容器 ========== */
.video-zoom-wrap {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  touch-action: none; overflow: hidden;
}
.video-zoom-wrap #video { max-width: 100%; max-height: 100%; transform-origin: center center; will-change: transform; }

/* ========== v5 一键清除按钮 ========== */
.m-btn.danger { background: #ff3b30; color: #fff; }
.m-btn.danger:hover { background: #d32f2f; }

/* ========== v5 全屏返回按钮美化 ========== */
body.is-fullscreen .tb-back {
  display: flex !important; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%; background: rgba(0,0,0,.5);
  color: #fff; font-size: 22px; line-height: 1; border: 1px solid rgba(255,255,255,.2);
  cursor: pointer; flex-shrink: 0;
}
body.is-fullscreen .tb-back:hover { background: rgba(255,59,48,.8); }
body.is-fullscreen .tb-fs {
  display: flex !important; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%; background: rgba(0,0,0,.5);
  color: #fff; font-size: 18px; border: 1px solid rgba(255,255,255,.2); cursor: pointer;
}
body.is-fullscreen .tb-fs:hover { background: rgba(255,59,48,.8); }
body.is-fullscreen .title-bar { background: linear-gradient(180deg, rgba(0,0,0,.7), transparent); }

/* ========== v5 循环按钮激活态 ========== */
#btnLoop.active { background: var(--accent, #ff3b30); color: #fff; }

/* ========== v5 修复：全屏时模态框黑色假面 ========== */
.modal-mask { z-index: 10000 !important; }
.modal { z-index: 10001 !important; }

/* v5 拖动时禁用过渡，跟手调整 */
.episode-panel.resizing { transition: none !important; }

/* ========== v6 导入选择菜单 ========== */
.toolbar-actions { position: relative; }
.import-menu {
  position: absolute; top: 100%; right: 0; z-index: 100;
  background: var(--panel, #1e1e2e); border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.4);
  min-width: 160px; overflow: hidden;
}
.import-item {
  padding: 12px 16px; cursor: pointer; font-size: 14px; color: #eee;
  transition: background .15s;
}
.import-item:hover { background: var(--accent, #ff3b30); color: #fff; }

/* ============================================================

/* ========== 封面图缩放容器（V6+） ========== */
.poster-zoom-wrap {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  touch-action: none; overflow: hidden;
}
.poster-zoom-wrap #posterImg {
  max-width: 100%; max-height: 100%;
  transform-origin: center center;
  will-change: transform;
}

/* ========== 转码提示：移到外层，z-index 高于控制栏 ========== */
.convert-tip {
  z-index: 8;
  bottom: 70px;
}
/* 转码提示显示时，自动隐藏弹幕输入框，避免重叠 */
.convert-tip:not([hidden]) ~ .controls .danmaku-row { display: none !important; }
/* 转码中也隐藏弹幕输入框 */
body.is-converting .danmaku-row { display: none !important; }
/* 转码进度条 */
.convert-progress {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  margin-top: 8px;
  overflow: hidden;
}
.convert-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #ff9800, #ffc107);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
}
.convert-progress-text {
  font-size: 11px;
  color: #ffc107;
  margin-top: 4px;
}

/* ========== iOS 刘海屏 / 底部横条 安全区域适配 ========== */
@supports (padding-top: env(safe-area-inset-top)) {
  /* 顶部工具条：避开刘海 */
  .toolbar {
    padding-top: calc(10px + env(safe-area-inset-top)) !important;
  }
  /* 视频内顶部剧集名窄条：避开刘海 */
  .title-bar {
    padding-top: calc(8px + env(safe-area-inset-top)) !important;
  }
  /* 底部控制栏：避开底部横条 */
  .controls {
    padding-bottom: calc(10px + env(safe-area-inset-bottom)) !important;
  }
  /* 转码提示：避开底部横条 */
  .convert-tip {
    bottom: calc(70px + env(safe-area-inset-bottom)) !important;
  }
  /* 选集面板：右侧避开刘海/横条 */
  .episode-panel {
    padding-top: calc(8px + env(safe-area-inset-top)) !important;
    padding-bottom: calc(8px + env(safe-area-inset-bottom)) !important;
  }
  /* 全屏时选集面板顶部避开刘海 */
  body.is-fullscreen .episode-panel {
    padding-top: calc(8px + env(safe-area-inset-top)) !important;
  }
  /* 横屏时：左右两侧也需要避开 */
  @media (orientation: landscape) {
    .toolbar {
      padding-left: calc(16px + env(safe-area-inset-left)) !important;
      padding-right: calc(16px + env(safe-area-inset-right)) !important;
    }
    .title-bar {
      padding-left: calc(14px + env(safe-area-inset-left)) !important;
      padding-right: calc(14px + env(safe-area-inset-right)) !important;
    }
    .controls {
      padding-left: calc(12px + env(safe-area-inset-left)) !important;
      padding-right: calc(12px + env(safe-area-inset-right)) !important;
    }
    .episode-panel {
      padding-right: calc(12px + env(safe-area-inset-right)) !important;
    }
  }
  /* 全屏模式下的适配 */
  body.is-fullscreen .title-bar {
    padding-top: calc(8px + env(safe-area-inset-top)) !important;
  }
  body.is-fullscreen .controls {
    padding-bottom: calc(10px + env(safe-area-inset-bottom)) !important;
  }
}

/* ========== 激活页记住激活码复选框 ========== */
.act-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: rgba(255,255,255,.7);
  cursor: pointer;
  margin: 4px 0;
  user-select: none;
}
.act-remember input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #ff9800;
}
.act-remember:hover { color: rgba(255,255,255,.9); }

/* ========== 设置页激活状态 ========== */
.license-status { border-top: 1px solid rgba(255,255,255,.1); padding-top: 14px; margin-top: 6px; }
.license-info {
  font-size: 13px;
  color: #4caf50;
  background: rgba(76,175,80,.1);
  border: 1px solid rgba(76,175,80,.3);
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.6;
}
.license-info.inactive {
  color: #f44336;
  background: rgba(244,67,54,.1);
  border-color: rgba(244,67,54,.3);
}

/* ========== 设置页服务端验证配置 ========== */
.license-server-config { border-top: 1px solid rgba(255,255,255,.1); padding-top: 14px; margin-top: 6px; }
.server-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: rgba(255,255,255,.8);
  cursor: pointer;
  margin: 6px 0;
}
.server-switch input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #ff9800;
}
.server-hint {
  font-size: 11px;
  color: rgba(255,255,255,.45);
  margin-top: 6px;
  line-height: 1.5;
}

/* ========== iOS CSS 全屏模式（带选集和控制栏，不是视频原生全屏） ========== */
body.is-fullscreen.ios-fullscreen {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9999;
  background: #000;
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  overflow: hidden;
}
body.is-fullscreen.ios-fullscreen .app,
body.is-fullscreen.ios-fullscreen .main,
body.is-fullscreen.ios-fullscreen .player-column {
  width: 100%; height: 100%; max-width: 100%;
  padding: 0 !important; margin: 0 !important;
  background: #000;
}
body.is-fullscreen.ios-fullscreen .player-frame {
  width: 100%; height: 100%;
  border: none !important; border-radius: 0 !important;
  margin: 0; padding: 0 !important;
  background: #000; box-shadow: none !important;
  gap: 0 !important;
}
body.is-fullscreen.ios-fullscreen .video-stage {
  width: 100%; height: 100%;
  border-radius: 0; background: #000;
}
body.is-fullscreen.ios-fullscreen #video {
  background: #000;
}
/* iOS 全屏时选集面板占满高度 */
body.is-fullscreen.ios-fullscreen .episode-panel {
  top: 0 !important; bottom: 0 !important;
  border-radius: 0;
}

/* 隐藏 Netlify 免费版徽章 */
[class*="netlify"],
[id*="netlify"],
a[href*="netlify.com"],
div[style*="fixed"][style*="bottom"][style*="right"] {
  display: none !important;
}
