/* ============================================================
   随机小姐姐 - H5 自适应样式
   抖音风格沉浸式播放界面 / 移动端优先
   ============================================================ */
:root {
    --bg: #0e0f13;
    --bg2: #17181f;
    --card: #1d1f28;
    --line: #2a2d3a;
    --text: #f2f3f7;
    --text2: #9aa0b0;
    --accent: #ff5c8a;
    --accent2: #8a5cff;
    --like: #ff2d55;
    --ok: #35d07f;
    --warn: #ffb02e;
    --err: #ff5c5c;
    --radius: 14px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
    --grad: linear-gradient(135deg, #ff5c8a, #8a5cff);
}

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

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

.hidden { display: none !important; }

/* ---------- 顶栏（播放时自动淡出） ---------- */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 20;
    padding: calc(var(--safe-t) + 10px) 14px 10px;
    background: linear-gradient(180deg, rgba(0,0,0,.55), rgba(0,0,0,0));
    pointer-events: none;
    opacity: 1;
    transition: opacity .35s;
}
.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: auto;
}
.logo {
    font-size: 19px;
    font-weight: 700;
    letter-spacing: .5px;
    background: var(--grad);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text);
    background: rgba(0,0,0,.35);
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 999px;
    padding: 4px 10px;
    backdrop-filter: blur(8px);
}
.badge .dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--text2);
}
.badge.ok .dot { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.badge.err .dot { background: var(--err); box-shadow: 0 0 6px var(--err); }
.stage.playing .topbar { opacity: 0; pointer-events: none; }

/* ---------- 播放舞台 ---------- */
.stage {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 10;
}
#player {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    touch-action: none;
    -webkit-touch-callout: none; /* iOS 长按不弹原生菜单/存储视频 */
    -webkit-user-select: none;
    user-select: none;
}
/* ---------- 强制屏蔽各内核的原生播放器控制层 ---------- */
video::-webkit-media-controls,
video::-webkit-media-controls-enclosure,
video::-webkit-media-controls-panel,
video::-webkit-media-controls-overlay-play-button,
video::-webkit-media-controls-play-button,
video::-webkit-media-controls-start-playback-button,
video::-webkit-media-controls-current-time-display,
video::-webkit-media-controls-time-remaining-display,
video::-webkit-media-controls-timeline,
video::-webkit-media-controls-volume-slider,
video::-webkit-media-controls-mute-button,
video::-webkit-media-controls-fullscreen-button,
video::-webkit-media-controls-toggle-closed-captions-button,
video::-webkit-media-controls-return-to-realtime-button,
video::-webkit-media-controls-picture-in-picture-button,
video::-webkit-media-controls-rewind-button,
video::-webkit-media-controls-seek-back-button,
video::-webkit-media-controls-seek-forward-button {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}
/* 播放完毕后 Chrome 的"重播"覆盖层一并屏蔽 */
video::-webkit-media-controls-overlay-play-button {
    display: none !important;
}

/* ---------- 遮罩 ---------- */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: rgba(10,11,15,.72);
    backdrop-filter: blur(6px);
    z-index: 12;
}
.spinner {
    width: 44px; height: 44px;
    border: 3px solid rgba(255,255,255,.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 14px; color: var(--text2); }

.error-icon {
    width: 58px; height: 58px;
    border-radius: 50%;
    background: rgba(255,92,92,.15);
    color: var(--err);
    display: flex; align-items: center; justify-content: center;
    font-size: 30px; font-weight: 700;
    border: 1px solid rgba(255,92,92,.4);
}
.error-text { font-size: 14px; color: var(--text2); padding: 0 30px; text-align: center; }

.btn {
    border: 0;
    border-radius: 999px;
    padding: 10px 30px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: var(--grad);
    cursor: pointer;
}
.btn:active { opacity: .8; }

/* ---------- 中央播放键（暂停时显示） ---------- */
.center-play {
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    z-index: 11;
    color: rgba(255,255,255,.9);
    text-shadow: 0 2px 12px rgba(0,0,0,.5);
    pointer-events: none;
    animation: popIn .25s ease;
}
@keyframes popIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(.6); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ---------- 双击收藏爱心动画 ---------- */
.heart-burst {
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    z-index: 13;
    pointer-events: none;
}
.heart-burst.burst { animation: heartPop .75s ease forwards; }
@keyframes heartPop {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(.3); }
    20%  { opacity: 1; }
    60%  { opacity: 1; transform: translate(-50%, -50%) scale(1.18); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}

/* ---------- 左下角信息区 ---------- */
.video-info {
    position: absolute;
    left: 14px;
    right: 86px;
    bottom: calc(var(--safe-b) + 42px);
    z-index: 11;
    display: flex;
    flex-direction: column;
    gap: 7px;
    transition: opacity .35s;
    pointer-events: none;
}
.stage.playing .video-info { opacity: 0; }
.info-title {
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,.6);
}
.info-tags { display: flex; align-items: center; gap: 8px; }
.src-tag {
    font-size: 11px;
    color: #fff;
    background: rgba(0,0,0,.35);
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 999px;
    padding: 2px 9px;
    backdrop-filter: blur(6px);
}
.src-tag.api { color: #ffd7e4; border-color: rgba(255,92,138,.5); }
.info-line { font-size: 12px; color: var(--text2); text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.music-line {
    font-size: 12px;
    color: var(--text2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 3px rgba(0,0,0,.6);
}

/* ---------- 右侧竖排操作栏（抖音风格） ---------- */
.action-rail {
    position: absolute;
    right: 10px;
    bottom: calc(var(--safe-b) + 70px);
    z-index: 13;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    transition: opacity .35s;
}
.stage.playing .action-rail { opacity: .82; }
.rail-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: 0;
    color: #fff;
    cursor: pointer;
    padding: 0;
}
.rail-btn:active { transform: scale(.9); }
.rail-icon {
    width: 47px; height: 47px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(0,0,0,.35);
    border: 1px solid rgba(255,255,255,.12);
    backdrop-filter: blur(8px);
    transition: all .2s;
}
.rail-label {
    font-size: 11px;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,.7);
}
.rail-btn .fav-heart.active { fill: var(--like); }
.rail-btn.on .rail-icon {
    color: #fff;
    background: var(--grad);
    border-color: transparent;
    box-shadow: 0 2px 12px rgba(255,92,138,.45);
}
/* 电脑端专用：全屏按钮（触屏设备自动隐藏） */
@media (hover: none), (pointer: coarse) {
    .pc-only { display: none !important; }
}

/* ---------- 底部细进度条 ---------- */
.progress {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 3px;
    background: rgba(255,255,255,.16);
    z-index: 12;
}
.progress-bar {
    height: 100%;
    width: 0;
    background: #fff;
    border-radius: 0 2px 2px 0;
}

/* ---------- 抽屉 ---------- */
.drawer-mask {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 30;
}
.drawer {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 31;
    background: var(--bg2);
    border-radius: 18px 18px 0 0;
    padding: 14px 14px calc(var(--safe-b) + 14px);
    max-height: 62vh;
    display: flex;
    flex-direction: column;
    animation: slideUp .25s ease;
    box-shadow: 0 -8px 30px rgba(0,0,0,.5);
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}
.drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.tabs { display: flex; gap: 6px; }
.tab {
    border: 0;
    background: rgba(255,255,255,.06);
    color: var(--text2);
    font-size: 13px;
    padding: 7px 16px;
    border-radius: 999px;
    cursor: pointer;
}
.tab.active {
    color: #fff;
    background: var(--grad);
    font-weight: 600;
}
.drawer-close {
    background: none;
    border: 0;
    color: var(--text2);
    font-size: 24px;
    line-height: 1;
    padding: 0 6px;
    cursor: pointer;
}
.drawer-list {
    list-style: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
}
.drawer-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 8px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
}
.drawer-item:active { background: rgba(255,255,255,.05); }
.drawer-item .thumb {
    width: 44px; height: 30px;
    border-radius: 6px;
    background: linear-gradient(135deg, #2a2d3a, #1d1f28);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.drawer-item .thumb svg { width: 18px; height: 18px; color: var(--text2); }
.drawer-item .meta { flex: 1; min-width: 0; }
.drawer-item .url {
    font-size: 12px;
    color: var(--text2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.drawer-item .info { font-size: 11px; color: var(--text2); margin-top: 2px; }
.drawer-empty {
    text-align: center;
    color: var(--text2);
    font-size: 13px;
    padding: 40px 0;
}

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--safe-b) + 110px);
    transform: translateX(-50%);
    z-index: 40;
    background: rgba(20,21,28,.92);
    border: 1px solid var(--line);
    color: var(--text);
    font-size: 13px;
    padding: 9px 20px;
    border-radius: 999px;
    max-width: 80%;
    text-align: center;
    backdrop-filter: blur(10px);
    animation: fadeUp .25s ease;
    box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
@keyframes fadeUp {
    from { opacity: 0; transform: translate(-50%, 10px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

/* 横屏适配 */
@media (orientation: landscape) and (max-height: 500px) {
    .action-rail { right: 8px; bottom: 12px; gap: 10px; }
    .rail-icon { width: 38px; height: 38px; }
    .video-info { left: 12px; bottom: 18px; gap: 4px; }
    .info-title { font-size: 15px; }
    .logo { font-size: 16px; }
    .music-line, .info-line { font-size: 11px; }
}
