﻿:root {
  --bg: #0e1014;
  --card: #1a1e25;
  --line: #2a303b;
  --text: #f2f4f8;
  --muted: #9aa3b2;
  --accent: #19c37d;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%; overflow-x: hidden;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

#app {
  padding: 18px 18px calc(24px + env(safe-area-inset-bottom));
  max-width: 1400px; margin: 0 auto;
}

.topbar { display: flex; align-items: center; justify-content: space-between; padding-top: calc(6px + env(safe-area-inset-top)); }
.brand { font-size: 22px; font-weight: 700; color: var(--accent); letter-spacing: .5px; }
.brand .tag {
  margin-left: 8px; font-size: 11px; font-weight: 500; color: var(--muted);
  border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; vertical-align: 2px;
}
.top-actions { display: flex; gap: 2px; }
.linkbtn { background: none; border: none; color: var(--muted); font-size: 14px; padding: 8px; }
.linkbtn:active { color: var(--text); }

.searchbar {
  display: flex; align-items: center; gap: 8px; margin-top: 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 6px 6px 6px 16px;
}
.searchbar input { flex: 1; min-width: 0; height: 38px; border: none; outline: none; background: transparent; color: var(--text); font-size: 15px; }
.searchbar input::placeholder { color: var(--muted); }
.searchbar button { height: 38px; padding: 0 18px; border: none; border-radius: 19px; background: var(--accent); color: #fff; font-size: 14px; font-weight: 600; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 2px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; padding: 7px 14px; border-radius: 16px; font-size: 13px; background: var(--card); border: 1px solid var(--line); color: var(--text); }
.chip:active { border-color: var(--accent); }

.section-head { display: flex; align-items: center; justify-content: space-between; }
.section-head h2 { margin: 0; font-size: 15px; font-weight: 700; }

.history { margin-top: 14px; }
.hrow { display: flex; gap: 10px; overflow-x: auto; padding: 10px 0 4px; -webkit-overflow-scrolling: touch; }
.hcard { flex: 0 0 auto; width: 118px; }
.hcover { position: relative; width: 118px; height: 158px; border-radius: 10px; overflow: hidden; background: var(--card); }
.hcover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hpercent { position: absolute; left: 6px; bottom: 6px; font-size: 10px; color: #fff; background: rgba(25,195,125,.8); border-radius: 5px; padding: 2px 5px; }
.hbar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.25); }
.hbar i { display: block; height: 100%; background: var(--accent); }
.hname { font-size: 12px; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hsub { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.status { margin: 14px 2px 8px; font-size: 13px; color: var(--muted); min-height: 18px; }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.cover { position: relative; width: 100%; padding-top: 140%; border-radius: 10px; overflow: hidden; background: var(--card); }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.badge { position: absolute; left: 6px; bottom: 6px; font-size: 10px; color: #fff; background: rgba(25,195,125,.72); border-radius: 5px; padding: 2px 5px; }
.cname { font-size: 13px; margin-top: 6px; line-height: 1.35; max-height: 2.7em; overflow: hidden; }
.cremarks { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 全屏面板 */
.sheet {
  position: fixed; inset: 0; background: var(--bg); z-index: 20;
  display: flex; flex-direction: column;
  padding: calc(10px + env(safe-area-inset-top)) 18px calc(16px + env(safe-area-inset-bottom));
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.sheet.hidden { display: none; }
.sheet.scrim { background: rgba(0,0,0,.55); justify-content: flex-end; padding: 0; z-index: 30; }
.sheet-head { display: flex; align-items: center; gap: 10px; }
.roundbtn { background: rgba(255,255,255,.14); border: none; color: #fff; border-radius: 18px; height: 36px; padding: 0 14px; font-size: 14px; flex: 0 0 auto; }
.roundbtn.small { height: 32px; padding: 0 12px; font-size: 13px; }
.sheet-title { flex: 1; font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.detail-body { display: flex; gap: 14px; margin-top: 16px; }
.detail-poster { width: 104px; height: 148px; border-radius: 10px; object-fit: cover; background: var(--card); }
.detail-info { flex: 1; min-width: 0; }
.meta { font-size: 12px; color: var(--muted); line-height: 1.7; }
.desc { font-size: 12px; color: var(--muted); line-height: 1.6; margin-top: 8px; max-height: 7.5em; overflow: hidden; }

.ep-head { margin: 18px 0 8px; font-size: 15px; font-weight: 700; }
.eps { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); padding-bottom: 10px; }
.ep { height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ep.on { border-color: var(--accent); color: var(--accent); }
.ep:active { border-color: var(--accent); }

/* 面板 */
.panel { background: #12151b; border-radius: 18px 18px 0 0; padding: 14px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 76vh; display: flex; flex-direction: column; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel-title { font-size: 15px; font-weight: 700; }
#epSheetList, .srclist { overflow-y: auto; -webkit-overflow-scrolling: touch; }

.srclist { display: flex; flex-direction: column; gap: 10px; }
.srcitem { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; color: var(--text); text-align: left; }
.srcitem.on { border-color: var(--accent); }
.srcitem img { width: 44px; height: 62px; border-radius: 8px; object-fit: cover; background: #0f1216; flex: 0 0 auto; }
.src-main { flex: 1; min-width: 0; }
.src-name { font-size: 14px; }
.src-sub { font-size: 11px; color: var(--muted); margin-top: 3px; }
.src-go { font-size: 13px; color: var(--accent); flex: 0 0 auto; }

/* 播放器 */
.player { padding: 0; background: #000; overflow: hidden; }
#stage { position: absolute; inset: 0; background: #000; overflow: hidden; }
#video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
#dim { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .1s linear; }
#gestureArea { position: absolute; inset: 0; z-index: 3; }

#hud {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  background: rgba(0,0,0,.72); color: #fff; font-size: 14px; padding: 12px 18px;
  border-radius: 12px; z-index: 8; min-width: 120px; text-align: center;
}
#hud.hidden { display: none; }

.player.force-land #stage {
  width: 100vh; height: 100vw;
  left: 50%; top: 50%; right: auto; bottom: auto;
  transform: translate(-50%, -50%) rotate(90deg);
}

.player-top {
  position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 16px; z-index: 6;
  background: linear-gradient(180deg, rgba(0,0,0,.75), rgba(0,0,0,0));
  transition: opacity .2s;
}
.ptitle { flex: 1; font-size: 15px; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.7); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.player-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6;
  padding: 26px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(0,0,0,.8), rgba(0,0,0,0));
  transition: opacity .2s;
}
.seekrow { display: flex; align-items: center; gap: 10px; }
.seekrow span { font-size: 12px; color: #fff; font-variant-numeric: tabular-nums; min-width: 42px; text-align: center; }

#seek { flex: 1; -webkit-appearance: none; appearance: none; height: 24px; background: transparent; }
#seek::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: rgba(255,255,255,.35); }
#seek::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #fff; margin-top: -6px; box-shadow: 0 0 4px rgba(0,0,0,.5); }
#seek::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(255,255,255,.35); }
#seek::-moz-range-thumb { width: 16px; height: 16px; border: none; border-radius: 50%; background: #fff; }

.pbtns { display: flex; justify-content: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.pbtn { height: 38px; min-width: 52px; padding: 0 12px; border-radius: 19px; border: none; background: rgba(255,255,255,.18); color: #fff; font-size: 13px; }
.pbtn.main { min-width: 76px; background: var(--accent); font-weight: 600; }

.unlock { position: absolute; left: 14px; top: 40%; z-index: 9; height: 40px; padding: 0 14px; border-radius: 20px; border: none; background: rgba(0,0,0,.6); color: #fff; font-size: 13px; }
.unlock.hidden { display: none; }

/* 我的 */
.me-block { margin-top: 18px; }
.me-block h2 { margin: 0 0 8px; font-size: 15px; }
.setting { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; }
.s-title { font-size: 14px; }
.s-desc { font-size: 12px; color: var(--muted); margin-top: 3px; }
.setting > div:first-child { flex: 1; }
.switch { width: 44px; height: 26px; border-radius: 13px; background: #333a45; position: relative; flex: 0 0 auto; transition: background .15s; }
.switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch.on { background: var(--accent); }
.switch.on::after { left: 21px; }

.widebtn { display: block; width: 100%; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: 14px; margin-bottom: 8px; }
.widebtn:active { border-color: var(--accent); }
.about .s-desc { line-height: 1.7; }

.histgrid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-top: 14px; }
.histcard { background: var(--card); border-radius: 12px; overflow: hidden; position: relative; }
.histcard img { width: 100%; height: 96px; object-fit: cover; display: block; background: #0f1216; }
.histcard .hc-body { padding: 8px 10px 10px; }
.histcard .hc-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.histcard .hc-sub { font-size: 11px; color: var(--muted); margin-top: 3px; }
.histcard .hc-bar { height: 3px; background: rgba(255,255,255,.15); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.histcard .hc-bar i { display: block; height: 100%; background: var(--accent); }
.histcard .hc-del { position: absolute; right: 6px; top: 6px; width: 26px; height: 26px; border-radius: 13px; border: none; background: rgba(0,0,0,.6); color: #fff; font-size: 13px; }

.toast {
  position: fixed; left: 50%; bottom: 12%; transform: translateX(-50%);
  background: rgba(0,0,0,.82); color: #fff; font-size: 13px; padding: 9px 16px;
  border-radius: 18px; z-index: 50; max-width: 80vw; text-align: center;
}
.toast.hidden { display: none; }

@media (min-width: 900px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .hcard, .hcover { width: 140px; }
  .hcover { height: 188px; }
}

@media (min-width: 1600px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
}
