:root {
  --bg: #000;
  --panel: #121214;
  --card: #1c1c20;
  --line: rgba(255, 255, 255, .08);
  --text: #fff;
  --muted: rgba(255, 255, 255, .62);
  --accent: #fe2c55;
  --accent2: #25f4ee;
  --gold: #ffc53d;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #0b0b0d; color: var(--text); overflow: hidden; }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--accent2); text-decoration: none; }
img { -webkit-user-drag: none; user-select: none; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
svg.fill { fill: currentColor; stroke: none; }
.slide { touch-action: pan-y; }
.rail .act.bm.on svg { fill: var(--gold); animation: pop .35s; }
.btn.on svg.fill { fill: var(--accent); }
.row .mini img.full { width: 100%; object-fit: cover; }
a.btn { color: #fff; }

#app {
  position: relative;
  height: 100vh;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
  box-shadow: 0 0 60px rgba(0, 0, 0, .6);
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: absolute; z-index: 20; inset: 0 0 auto 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-t) + 8px) 10px 8px;
  background: linear-gradient(rgba(0, 0, 0, .55), transparent);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.icon-btn:active { background: rgba(255, 255, 255, .12); }
.tabs { display: flex; gap: 22px; }
.tabs button {
  position: relative; font-size: 17px; font-weight: 600; color: rgba(255, 255, 255, .62);
  padding: 6px 0; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); transition: color .2s;
}
.tabs button.on { color: #fff; }
.tabs button.on::after {
  content: ""; position: absolute; left: 50%; bottom: 0; width: 22px; height: 3px; margin-left: -11px;
  border-radius: 2px; background: #fff;
}
body.on-fav .topbar { background: var(--bg); }
body.on-fav #btnShuffle { visibility: hidden; }

/* ---------- 刷屏流 ---------- */
.feed {
  height: 100%;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.feed::-webkit-scrollbar { display: none; }

.slide {
  position: relative;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  overflow: hidden;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  user-select: none;
}
.slide .bg {
  position: absolute; inset: -40px; width: calc(100% + 80px); height: calc(100% + 80px);
  object-fit: cover; object-position: right center;
  filter: blur(28px) brightness(.45) saturate(1.2);
  transform: scale(1.1);
  opacity: 0; transition: opacity .4s;
}
.slide .bg.ok { opacity: 1; }

/* 主海报：DMM 的 pl 大图右半边是正面封面，裁出来竖屏展示 */
.poster {
  position: relative;
  width: min(100%, calc((100dvh - 230px) * .705));
  aspect-ratio: .705;
  margin-top: -40px;
  overflow: hidden;
  border-radius: 6px;
  background: #111;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.poster img { position: absolute; top: 0; right: 0; height: 100%; width: auto; opacity: 0; transition: opacity .35s; }
.poster img.ok { opacity: 1; }
.poster img.full { width: 100%; object-fit: cover; }
.poster .ph, .thumb .ph {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 64px; font-weight: 800; color: rgba(255, 255, 255, .18);
  background: linear-gradient(135deg, #2a1d2b, #12151f);
}
.thumb .ph { font-size: 26px; }

.slide .shade {
  position: absolute; inset: auto 0 0 0; height: 55%;
  background: linear-gradient(transparent, rgba(0, 0, 0, .85));
  pointer-events: none;
}

/* 右侧操作栏 */
.rail {
  position: absolute; right: 8px; bottom: calc(var(--safe-b) + 120px); z-index: 3;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.rail .act { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; font-weight: 600; text-shadow: 0 1px 2px rgba(0,0,0,.7); }
.rail .act svg { width: 34px; height: 34px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.rail .act.heart svg { fill: rgba(255,255,255,.95); stroke: none; transition: transform .2s; }
.rail .act.heart.on svg { fill: var(--accent); animation: pop .35s; }
.rail .avatar-wrap { position: relative; margin-bottom: 8px; }
.rail .avatar-wrap .plus {
  position: absolute; left: 50%; bottom: -9px; width: 20px; height: 20px; margin-left: -10px;
  border-radius: 50%; background: var(--accent); display: grid; place-items: center;
  font-size: 16px; line-height: 1; font-weight: 700; transition: transform .25s, background .25s;
}
.rail .avatar-wrap.on .plus { background: #fff; color: var(--accent); transform: rotate(360deg); }
.rail .avatar-wrap .plus::before { content: "+"; }
.rail .avatar-wrap.on .plus::before { content: "✓"; font-size: 12px; }

.avatar {
  width: 48px; height: 48px; border-radius: 50%; overflow: hidden; flex: none;
  border: 2px solid #fff; background: linear-gradient(135deg, #fe2c55, #7b3fe4);
  display: grid; place-items: center; font-weight: 800; font-size: 20px; position: relative;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.avatar.lg { width: 92px; height: 92px; font-size: 36px; border-width: 3px; }
.avatar.md { width: 64px; height: 64px; font-size: 26px; border-width: 2px; }
.avatar.sm { width: 40px; height: 40px; font-size: 16px; border-width: 0; }

/* 左下角信息 */
.meta {
  position: absolute; left: 14px; right: 80px; bottom: calc(var(--safe-b) + 18px); z-index: 3;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .7);
}
.meta .name { margin: 0 0 2px; font-size: 19px; font-weight: 700; }
.meta .sub { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
.meta .facts { margin: 0 0 6px; font-size: 14px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.meta .tags { margin: 0 0 10px; font-size: 14px; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta .tags span { margin-right: 8px; }
.music {
  display: flex; align-items: center; gap: 6px; max-width: 100%;
  font-size: 13px; padding: 5px 10px 5px 8px; border-radius: 16px;
  background: rgba(255, 255, 255, .14); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.music svg { width: 15px; height: 15px; flex: none; }
.music .marquee { overflow: hidden; white-space: nowrap; mask-image: linear-gradient(90deg, #000 85%, transparent); -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); }
.music .marquee span { display: inline-block; padding-right: 40px; }
.slide.active .music .marquee span { animation: marquee 14s linear infinite; }

.badge { display: inline-flex; align-items: center; padding: 0 7px; border-radius: 4px; font-size: 12px; font-weight: 600; line-height: 20px; }
.badge.active { background: rgba(46, 204, 113, .9); }
.badge.retired { background: rgba(140, 140, 150, .85); }
.badge.hiatus { background: rgba(255, 150, 40, .9); }

.disc {
  position: absolute; right: 12px; bottom: calc(var(--safe-b) + 20px); z-index: 3;
  width: 44px; height: 44px; border-radius: 50%; overflow: hidden;
  background: radial-gradient(#333 30%, #111 31%, #222 60%, #111 61%);
  border: 8px solid #1d1d1d; animation: spin 6s linear infinite paused;
}
.slide.active .disc { animation-play-state: running; }
.disc img { width: 100%; height: 100%; object-fit: cover; object-position: right center; }

.burst {
  position: absolute; z-index: 30; width: 90px; height: 90px; margin: -45px 0 0 -45px; pointer-events: none;
  animation: burst .8s ease-out forwards;
}
.burst svg { width: 100%; height: 100%; fill: var(--accent); stroke: none; filter: drop-shadow(0 4px 10px rgba(254, 44, 85, .5)); }

.feed-end { height: 100%; display: grid; place-items: center; color: var(--muted); scroll-snap-align: start; }

.swipe-hint {
  position: absolute; z-index: 25; left: 50%; bottom: 22%; transform: translateX(-50%);
  padding: 10px 16px; border-radius: 22px; background: rgba(0,0,0,.6); font-size: 14px;
  display: flex; align-items: center; gap: 6px; pointer-events: none; animation: hint 2.4s ease-in-out 2;
}

/* ---------- 收藏页 ---------- */
.fav-page {
  position: absolute; inset: 0; z-index: 10; overflow-y: auto; background: var(--bg);
  padding: calc(var(--safe-t) + 64px) 0 calc(var(--safe-b) + 24px);
}
.seg { display: flex; margin: 0 14px 14px; padding: 3px; background: var(--card); border-radius: 10px; }
.seg button { flex: 1; padding: 7px 0; border-radius: 8px; font-size: 14px; color: var(--muted); }
.seg button.on { background: #2e2e34; color: #fff; font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 60px 24px; font-size: 14px; }
.empty .big { font-size: 46px; margin-bottom: 8px; }

.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 18px 8px; padding: 0 14px; }
.person { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.person .avatar { width: 72px; height: 72px; font-size: 28px; border-width: 2px; }
.person .pn { font-size: 13px; line-height: 1.3; max-width: 100%; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.person .pc { font-size: 11px; color: var(--muted); }

/* ---------- 作品网格 ---------- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.thumb { position: relative; aspect-ratio: .71; overflow: hidden; background: #1a1a1e; display: block; width: 100%; }
.thumb img { position: absolute; top: 0; right: 0; height: 100%; width: auto; opacity: 0; transition: opacity .3s; }
.thumb img.full { width: 100%; object-fit: cover; }
.thumb img.ok { opacity: 1; }
.thumb .cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 5px 4px; text-align: left;
  font-size: 11px; font-weight: 600; line-height: 1.3; background: linear-gradient(transparent, rgba(0,0,0,.85));
}
.thumb .cap small { display: block; font-weight: 400; color: var(--muted); }
.thumb .fav-dot { position: absolute; top: 5px; right: 5px; width: 18px; height: 18px; }
.thumb .fav-dot svg { width: 18px; height: 18px; fill: var(--accent); stroke: none; filter: drop-shadow(0 1px 2px rgba(0,0,0,.7)); }

/* ---------- 弹层 ---------- */
.layer {
  position: absolute; inset: 0; z-index: 40; background: var(--panel);
  overflow-y: auto; overscroll-behavior: contain;
  animation: slideIn .28s cubic-bezier(.2, .8, .2, 1);
}
.layer.closing { animation: slideOut .22s ease-in forwards; }
.layer.sheet { background: rgba(0, 0, 0, .5); animation: fadeIn .2s; overflow: hidden; display: flex; align-items: flex-end; }
.layer.sheet.closing { animation: fadeOut .2s forwards; }
.layer.sheet .sheet-body {
  width: 100%; max-height: 92%; overflow-y: auto; overscroll-behavior: contain;
  background: var(--panel); border-radius: 14px 14px 0 0; animation: sheetUp .3s cubic-bezier(.2, .8, .2, 1);
  padding-bottom: calc(var(--safe-b) + 16px);
}
.layer.sheet.closing .sheet-body { animation: sheetDown .2s ease-in forwards; }
.grabber { width: 40px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.25); margin: 8px auto 4px; }

.lbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 6px;
  padding: calc(var(--safe-t) + 6px) 6px 6px; transition: background .2s;
}
.lbar.solid { background: rgba(18, 18, 20, .92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.lbar .ttl { flex: 1; font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; transition: opacity .2s; }
.lbar.solid .ttl { opacity: 1; }
.lbar .icon-btn { background: rgba(0, 0, 0, .35); }

/* 女优主页 */
.hero { position: relative; height: 190px; margin-top: calc(-52px - var(--safe-t)); overflow: hidden; }
.hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: right 30%; filter: brightness(.6); }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 40%, var(--panel)); }
.prof { position: relative; padding: 0 16px; margin-top: -52px; }
.prof-head { display: flex; align-items: flex-end; gap: 14px; }
.prof h1 { margin: 12px 0 0; font-size: 22px; line-height: 1.25; }
.prof .alt { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.stats { display: flex; gap: 22px; margin: 14px 0; }
.stats div { display: flex; flex-direction: column; }
.stats b { font-size: 17px; }
.stats span { font-size: 12px; color: var(--muted); }
.btn-row { display: flex; gap: 8px; margin-bottom: 14px; }
.btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; border-radius: 6px; font-weight: 600; font-size: 15px; background: var(--accent);
}
.btn.ghost { background: #2c2c32; }
.btn.on { background: #2c2c32; color: var(--muted); }
.btn svg { width: 18px; height: 18px; }
.btn.narrow { flex: none; width: 44px; }

.info { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; margin: 0 0 14px; }
.info dt { color: var(--muted); white-space: nowrap; }
.info dd { margin: 0; word-break: break-word; }
.bio { font-size: 14px; color: rgba(255,255,255,.85); margin: 0 0 14px; }
.links { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 11px; border-radius: 14px;
  font-size: 13px; background: #26262b; color: #fff;
}
a.chip { color: var(--accent2); }
.chip.tag { color: #ffd0da; background: rgba(254, 44, 85, .14); }
.more-toggle { color: var(--muted); font-size: 13px; margin: -6px 0 14px; }

.works-head {
  position: sticky; top: calc(var(--safe-t) + 52px); z-index: 4;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.works-head h3 { margin: 0; font-size: 16px; }
.sorts { display: flex; gap: 4px; }
.sorts button { font-size: 13px; padding: 3px 9px; border-radius: 12px; color: var(--muted); }
.sorts button.on { color: #fff; background: #2c2c32; }

/* 作品详情 */
.wcover { position: relative; width: 100%; aspect-ratio: 1.49; background: #000; overflow: hidden; }
.wcover img { width: 100%; height: 100%; object-fit: contain; }
.wbody { padding: 14px 16px 0; }
.wcode { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.wcode b { font-size: 18px; color: var(--accent2); letter-spacing: .5px; }
.wtitle { margin: 6px 0 12px; font-size: 16px; line-height: 1.5; font-weight: 600; }
.stars { color: var(--gold); letter-spacing: 1px; }
.cast { display: flex; gap: 14px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.cast .person { width: 64px; flex: none; }
.cast .person .avatar { width: 52px; height: 52px; font-size: 20px; }
.sec-title { font-size: 14px; font-weight: 600; margin: 4px 0 8px; color: rgba(255,255,255,.9); }
.syn { font-size: 14px; color: rgba(255,255,255,.82); margin: 0 0 14px; white-space: pre-wrap; }

/* 搜索 */
.search-bar { position: sticky; top: 0; z-index: 5; display: flex; gap: 8px; align-items: center; padding: calc(var(--safe-t) + 8px) 10px 8px; background: var(--panel); }
.search-bar input {
  flex: 1; height: 38px; border-radius: 8px; border: 0; outline: 0; padding: 0 12px;
  background: #26262b; color: #fff; font-size: 15px;
}
.search-bar .cancel { padding: 0 6px; color: #fff; font-size: 15px; }
.rows { padding: 0 6px; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; text-align: left; border-radius: 8px; }
.row:active { background: #1f1f24; }
.row .rt { flex: 1; min-width: 0; }
.row .rt b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .rt small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .mini { width: 44px; aspect-ratio: .71; position: relative; overflow: hidden; border-radius: 4px; flex: none; background: #222; }
.row .mini img { position: absolute; top: 0; right: 0; height: 100%; }
.group-title { padding: 12px 16px 4px; font-size: 13px; color: var(--muted); }
.hot-words { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 16px; }

/* toast */
.toast {
  position: absolute; z-index: 99; left: 50%; top: 45%; transform: translate(-50%, -50%) scale(.9);
  padding: 10px 18px; border-radius: 8px; background: rgba(30, 30, 34, .92); font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ---------- 动画 ---------- */
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-100%); } }
@keyframes burst {
  0% { transform: scale(.3) rotate(var(--r, 0deg)); opacity: 0; }
  15% { transform: scale(1.2) rotate(var(--r, 0deg)); opacity: 1; }
  30% { transform: scale(.95) rotate(var(--r, 0deg)); }
  70% { transform: scale(1) rotate(var(--r, 0deg)); opacity: 1; }
  100% { transform: scale(1.6) translateY(-60px) rotate(var(--r, 0deg)); opacity: 0; }
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: none; } }
@keyframes slideOut { to { transform: translateX(100%); } }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheetDown { to { transform: translateY(100%); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes hint { 0%, 100% { transform: translate(-50%, 0); opacity: .9; } 50% { transform: translate(-50%, -24px); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
@media (min-width: 481px) {
  #app { border-left: 1px solid #1d1d22; border-right: 1px solid #1d1d22; }
}
