/* 在播放器CSS中添加 */
.mmp {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    display: none;
    flex-direction: column;
    z-index: 9999;
    background: var(--bg);
    border: 1px solid var(--text);
    border-radius: 0.4em;
    padding: 0.2em;
    box-sizing: border-box;
    backdrop-filter: blur(30px);
    box-shadow: 0px 0px 4px 4px #0000006b;
    --mmp-button-height: var(--mmp-custom-height, 4vw);
    gap: 0.5em;
    
    /* 添加过渡效果 */
    transition: bottom 0.3s ease;
}

/* 如果有分页控件存在，播放器向上移动 */
body:has(#paging) .mmp {
    bottom: 25.6px; /* 根据分页控件高度调整 */
}

.mmp-media {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.mmp-header {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 0;
}

.mmp-time {
    font-size: 0.8em;
    min-width: 5em;
    text-align: center;
    color: var(--text);
    flex-shrink: 0;
    padding-top: 0;
    padding-bottom: 0;
    padding-left: 3px;
    padding-right: 3px;
    margin-right: 0.3em;
    line-height: 1.2;
    border: 1px solid var(--good-contrast);
    border-radius: 0.4em;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 1.6em;
}

/* 比特率显示样式 */
.mmp-bitrate {
    font-size: 0.8em;
    min-width: 4.5em;
    text-align: center;
    flex-shrink: 0;
    padding: 0 3px;
    margin-right: 0.3em;
    line-height: 1.2;
    border: 1px solid var(--good-contrast);
    color: var(--text);
    border-radius: 0.4em;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 1.6em;
}

.mmp-title-container {
    flex-grow: 1;
    min-width: 0;
    height: 1.5em;
    display: flex;
    align-items: center;
    overflow: hidden;
    margin: 0;
    line-height: 1.2;
    justify-content: center;
}

.mmp-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9em;
    padding: 0;
    line-height: inherit;
    max-width: 90%;
}

.mmp-header-controls {
    display: flex;
    align-items: center;
    gap: 0.8em;
}

.mmp-volume-control {
    display: flex;
    align-items: center;
    gap: 0.1em;
    padding: 0.1em;
}

.mmp-vol-down,
.mmp-vol-up {
    width: 1.5em;
    height: 1.5em;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text);
    cursor: pointer;
    font-size: 1em;
}

.mmp-volume-value {
    min-width: 3em;
    text-align: center;
    font-size: 1em;
}

.mmp-close {
    width: 1.5em;
    height: 1.5em;
    display: flex;
    align-items: center;
    justify-content: center;
    /*background: var(--bg);*/
    border: 1px solid var(--text);
    border-radius: 0.3em;
    color: var(--text);
    cursor: pointer;
    font-size: 1em;
}

.mmp-progress-container {
    position: relative;
    border: 1px solid var(--text);
    border-radius: 0.25em;
    padding: 0.5em;
    margin-bottom: 0em;/*進度條下邊間距*/
    background: 
    radial-gradient(circle at 1px 1px, rgba(150, 150, 150, 0.15) 1px, transparent 1px);
    background-size: 6px 6px;
}

.mmp-progress-container.transcoding {
    background-color: rgba(0,0,0,0.05);
}

.mmp-progress-container.transcoding::after {
    content: 'Transcoding...';
    position: absolute;
    right: 0.5em;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8em;
    color: var(--text);
    opacity: 0.7;
}

.mmp-progress-bar {
    position: relative;
    flex-grow: 1;
    height: 0.6em;
    cursor: pointer;
    background: var(--faint-contrast);
    border-radius: 0.25em;
    appearance: none;
    width: 100%;
    --thumb-color: var(--text);
}

.mmp-progress-bar:disabled {
    opacity: 0.7;
    --thumb-color: var(--faint-contrast);
    cursor: not-allowed;
}

/*進度跳針寬度*/
.mmp-progress-bar::-webkit-slider-thumb {
    appearance: none;
    width: 0.3em;
    height: 1.9em;
    background: var(--thumb-color);
    cursor: pointer;
    border-radius: 0;
    border: none;
}

.mmp-progress-bar::-moz-range-thumb {
    width: 0.3em;
    height: 1.9em;
    background: var(--thumb-color);
    cursor: pointer;
    border-radius: 0;
    border: none;
}

.mmp-progress-bar:hover::-webkit-slider-thumb {
    width: 0.3em;
    height: 1.9em;
    background: var(--text);
}

.mmp-progress-bar:hover::-moz-range-thumb {
    width: 0.3em;
    height: 1.9em;
    background: var(--text);
}

.mmp-loading-indicator {
    position: absolute;
    top: 50%;
    left: 0;
    height: 1px;
    width: 0;
    background-color: var(--good-contrast);
    transform: translateY(-50%);
    z-index: 2;
    pointer-events: none;
    transition: width 0.1s linear;
}

.mmp-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.3em;
}

.mmp-buttons {
    display: flex;
    flex-grow: 1;
    align-items: center;
    justify-content: space-between;
    gap: 0.3em;
}

.mmp-playback-buttons {
    display: flex;
    flex-grow: 1;
    justify-content: space-between;
    min-width: 0;
    gap: 0.3em;
    height: var(--mmp-button-height);
    min-height: 30px;
}

.mmp-play-pause,
.mmp-prev, 
.mmp-next {
    flex: 1;
    min-width: 0;
    text-align: center;
    color: inherit;
    border: 1px solid var(--text);
    border-radius: 0.4em;
    height: var(--mmp-button-height);
    min-height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: clamp(1em, calc(var(--mmp-button-height) * 0.5), 1.8em);
    position: relative;
    overflow: hidden;
    background: 
        radial-gradient(circle at 1px 1px, rgba(150, 150, 150, 0.15) 1px, transparent 1px);
    background-size: 8px 8px;
}

.mmp-play-pause.playing {
    color: var(--bg);
background-color: var(--text);
}

.mmp-play-pause.playing::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--text);
    z-index: -1;
}

.mmp-custom-button {
    width: 10%;
    min-width: 40px;
    height: var(--mmp-button-height);
    min-height: 30px;
    color: inherit;
    border: 1px solid var(--text);
    border-radius: 0.4em;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: clamp(1em, calc(var(--mmp-button-height) * 1.2), 1.2em);
    background: var(--bg);
    background: 
    radial-gradient(circle at 1px 1px, rgba(150, 150, 150, 0.15) 1px, transparent 1px);
    background-size: 8px 8px;
}

button.mmp-play {
    background: none;
    cursor: pointer;
    padding: 0 0.5em;
    font-size: 0.9em;
    color: inherit;
}

.mmp button {
    transition: none;
    border: 1px solid var(--text);
}

.mmp button:hover {
    background-color: var(--button-bg);
    color: var(--text); 
    outline: none;
}

.mmp-audio-icon {
    cursor: pointer !important;
}

.mmp-audio-icon:hover {
    opacity: 0.8;
}

@media (orientation: portrait) {
    .mmp-header {
        justify-content: flex-start;
        gap: 0;
    }
    .mmp-time {
        margin-right: 0.1em;
        min-width: 4.5em;
        min-height: 1.6em;
    }
    .mmp-bitrate {
        display: none; 
    }
    .mmp-title {
        text-align: left;
    }
    .mmp-volume-control {
        display: none;
    }
}

@media (orientation: landscape) {
    .mmp-header {
        justify-content: center;
        padding: 0.2em 0;
    }
    .mmp-time {
        position: absolute;
        left: 0.5em;
        margin-right: 0;
        min-height: 1.6em;
        min-width: 7em;
    }
    .mmp-bitrate {
        position: absolute;
        left: 8.5em; /* 在时间显示右侧 */
        margin-right: 0;
        min-height: 1.6em;
    }
    .mmp-title-container {
        max-width: 60%;
    }
    .mmp-header-controls {
        position: absolute;
        right: 0.5em;
    }
}

@media (max-width: 600px) {
    .mmp-bitrate {
        display: none; /* 小屏幕时隐藏比特率显示 */
    }
}

@media (max-width: 200px) {
    .mmp {
        padding: 0.3em;
    }
    
    .mmp-header {
        padding: 0.1em 0;
    }
    
    .mmp-time {
        font-size: 0.7em;
        min-width: 4em;
min-height: 1.6em;
    }
    
    .mmp-title {
        font-size: 0.8em;
    }
    
    .mmp-playback-buttons {
        height: 40px;
    }
    
    .mmp-custom-button {
        min-width: 35px;
    }
}

@media (orientation: portrait) {
    .mmp-custom-button.hide-portrait {
        display: none !important;
    }
    
    .mmp-playback-buttons {
        justify-content: center !important;
    }
}

    @media (forced-colors: active) {

        .mmp-progress-bar::-webkit-slider-thumb {
            background: Highlight !important;
            border: 1px solid ButtonText !important;
        }
        .mmp-progress-bar::-moz-range-thumb {
            background: Highlight !important;
            border: 1px solid ButtonText !important;
        }
        .mmp-progress-bar::-ms-thumb {
            background: Highlight !important;
            border: 1px solid ButtonText !important;
        }
    }