/* NovelTTS 播放器样式 —— PC 悬浮音乐播放器卡片 / 移动端融入阅读页工具栏 */

/* ============ PC：悬浮音乐播放器卡片 ============ */
.noveltts-player {
    position: fixed;
    z-index: 9999;
    top: auto;
    left: auto;
    right: 16px;
    bottom: 16px;
    margin: 0;
    width: 320px;
    max-width: calc(100vw - 24px);
    padding: 0;
    background: linear-gradient(135deg, #ffffff 0%, #f5f7fa 100%);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: #2c3e50;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: width .22s ease, height .22s ease, border-radius .22s ease,
                transform .22s ease, opacity .18s ease, left .22s ease, top .22s ease;
    touch-action: none;
    overflow: hidden;
}

/* 拖拽手柄 */
.noveltts-drag-handle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 12px;
    cursor: move;
    cursor: grab;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    font-size: 12px;
    color: #95a5a6;
    background: rgba(0, 0, 0, 0.02);
}
.noveltts-drag-handle:active { cursor: grabbing; }
.noveltts-drag-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    pointer-events: none;
}
.noveltts-drag-grip {
    display: inline-block;
    width: 14px;
    height: 14px;
    background-image: radial-gradient(circle, #b0bdc6 1px, transparent 1.4px);
    background-size: 5px 5px;
    opacity: .8;
}
.noveltts-collapse-btn {
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.08);
    color: #5a6c7d;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    transition: background .15s;
}
.noveltts-collapse-btn:hover { background: rgba(0, 0, 0, 0.18); }

/* 卡片：封面 + 元信息 */
.noveltts-card {
    display: flex;
    gap: 12px;
    padding: 12px 14px 10px;
    align-items: center;
}
.noveltts-cover {
    flex: 0 0 60px;
    width: 60px;
    height: 60px;
    border-radius: 10px;
    overflow: hidden;
    background: #e9eef5 center/cover no-repeat;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}
.noveltts-cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.noveltts-meta {
    flex: 1 1 auto;
    min-width: 0;
}
.noveltts-title {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.noveltts-progress {
    font-size: 12px;
    color: #95a5a6;
    margin-top: 3px;
}
.noveltts-state { color: #e67e22; margin-left: 6px; }
.noveltts-bar {
    margin-top: 7px;
    height: 4px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 2px;
    overflow: hidden;
}
.noveltts-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #27ae60, #2ecc71);
    border-radius: 2px;
    transition: width .3s ease;
}

/* 控制区 */
.noveltts-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 4px 14px 12px;
}
.noveltts-btn {
    min-width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #ecf0f3;
    color: #5a6c7d;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .2s, transform .1s, color .2s;
    line-height: 1;
}
.noveltts-btn:hover { background: #e0e6ed; color: #2c3e50; }
.noveltts-btn:active { transform: scale(.94); }
.noveltts-btn:disabled { background: #f0f3f6; color: #b0bdc6; cursor: not-allowed; }
.noveltts-play {
    width: 44px;
    height: 44px;
    font-size: 15px;
    background: #27ae60;
    color: #fff;
    box-shadow: 0 3px 10px rgba(39, 174, 96, 0.4);
}
.noveltts-play:hover { background: #1e8449; color: #fff; }
.noveltts-play.loading { background: #7f8c8d; box-shadow: none; }
.noveltts-player.playing .noveltts-play {
    background: #e74c3c;
    box-shadow: 0 3px 10px rgba(231, 76, 60, 0.4);
}
.noveltts-player.playing .noveltts-play:hover { background: #c0392b; }

.noveltts-spacer { flex: 1 1 auto; }
.noveltts-voice-label,
.noveltts-volume-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #5a6c7d;
}
.noveltts-voice {
    height: 28px;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    background: #fff;
    padding: 0 6px;
    font-size: 12px;
    cursor: pointer;
    max-width: 110px;
}
.noveltts-volume {
    width: 84px;
    cursor: pointer;
    vertical-align: middle;
}
.noveltts-err {
    margin: 0 14px 10px;
    padding: 6px 10px;
    font-size: 12px;
    color: #c0392b;
    background: #fdecea;
    border-radius: 6px;
    display: none;
}
.noveltts-err.show { display: block; }

/* 收缩态：封面圆球 + 遮罩图标 */
.noveltts-collapsed-icon {
    display: none;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    cursor: pointer;
    position: relative;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}
.noveltts-collapsed-mask {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 22px;
    line-height: 1;
}
.noveltts-collapsed-mask .noveltts-icon-pause { display: none; }
.noveltts-player.playing .noveltts-collapsed-mask .noveltts-icon-play { display: none; }
.noveltts-player.playing .noveltts-collapsed-mask .noveltts-icon-pause { display: inline; }

/* 收缩球封面旋转：播放中封面图持续顺时针旋转，遮罩图标反向旋转保持正向；
   停止时 playing class 移除 → animation 移除 → transform 回 none，封面与遮罩自动回正 */
@keyframes noveltts-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
@keyframes noveltts-spin-reverse {
    from { transform: rotate(0deg); }
    to { transform: rotate(-360deg); }
}
.noveltts-player.collapsed.playing .noveltts-collapsed-icon {
    animation: noveltts-spin 8s linear infinite;
}
.noveltts-player.collapsed.playing .noveltts-collapsed-mask {
    animation: noveltts-spin-reverse 8s linear infinite;
}

.noveltts-player.collapsed {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    padding: 0;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}
.noveltts-player.collapsed .noveltts-drag-handle,
.noveltts-player.collapsed .noveltts-card,
.noveltts-player.collapsed .noveltts-controls,
.noveltts-player.collapsed .noveltts-err { display: none; }
.noveltts-player.collapsed .noveltts-collapsed-icon { display: block; }

/* 拖拽中 / 靠边吸附 */
.noveltts-player.dragging {
    transition: none !important;
    opacity: 0.95;
    cursor: grabbing;
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.28);
}
.noveltts-player.edge-left { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.noveltts-player.edge-right { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.noveltts-player.collapsed.edge-left,
.noveltts-player.collapsed.edge-right { border-radius: 50%; }

/* 暗色模式 */
@media (prefers-color-scheme: dark) {
    .noveltts-player {
        background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
        border-color: #4a5c6d;
        color: #ecf0f1;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    }
    .noveltts-drag-handle {
        background: rgba(0, 0, 0, 0.2);
        border-bottom-color: rgba(255, 255, 255, 0.08);
        color: #bdc3c7;
    }
    .noveltts-drag-grip {
        background-image: radial-gradient(circle, #7f8c8d 1px, transparent 1.4px);
    }
    .noveltts-collapse-btn {
        background: rgba(255, 255, 255, 0.12);
        color: #ecf0f1;
    }
    .noveltts-collapse-btn:hover { background: rgba(255, 255, 255, 0.22); }
    .noveltts-cover { background-color: #2c3e50; }
    .noveltts-title { color: #ecf0f1; }
    .noveltts-progress { color: #bdc3c7; }
    .noveltts-bar { background: rgba(255, 255, 255, 0.12); }
    .noveltts-btn { background: #3a4a5c; color: #bdc3c7; }
    .noveltts-btn:hover { background: #4a5c6d; color: #ecf0f1; }
    .noveltts-voice-label, .noveltts-volume-label { color: #bdc3c7; }
    .noveltts-voice {
        background: #2c3e50;
        color: #ecf0f1;
        border-color: #4a5c6d;
    }
    .noveltts-err { color: #f5b7b1; background: #4a2c2c; }
}

/* ============ 移动端：融入阅读页底部工具栏的朗读面板 ============ */
/* footer 朗读按钮图标容器（替代 iconfont） */
.read-tts-footer-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    line-height: 1;
}
.read-tts-footer-ico svg { display: block; }

/* 朗读面板（复用阅读页 .read-opt-bot 定位/动画，黑底白字） */
.read-opt-tts {
    padding: 14px 16px calc(env(safe-area-inset-bottom, 0px) + 14px);
    color: #fff;
}
.read-opt-tts .read-tts-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.read-opt-tts .read-tts-main { padding: 4px 0; }
.read-opt-tts .read-tts-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: rgba(255, 255, 255, .85);
    font-size: 11px;
    padding: 4px 10px;
    -webkit-tap-highlight-color: transparent;
}
.read-opt-tts .read-tts-side i {
    font-style: normal;
    font-size: 20px;
    line-height: 1;
}
.read-opt-tts .read-tts-play {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #27ae60;
    color: #fff;
    font-size: 11px;
    -webkit-tap-highlight-color: transparent;
}
.read-opt-tts .read-tts-play i {
    font-style: normal;
    font-size: 22px;
    line-height: 1;
}
.read-opt-tts .read-tts-play .read-tts-icon-pause { display: none; }
.read-opt-tts.playing .read-tts-play { background: #e74c3c; }
.read-opt-tts .read-tts-play-text { font-size: 10px; opacity: .9; }

.read-opt-tts .read-tts-progress {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: rgba(255, 255, 255, .7);
    margin: 10px 2px 6px;
}
.read-opt-tts .read-tts-state { color: #f0a500; }

.read-opt-tts .read-tts-opt {
    justify-content: space-around;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, .1);
    margin-top: 4px;
}
.read-opt-tts .read-tts-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: rgba(255, 255, 255, .85);
}
.read-opt-tts .read-tts-voice {
    height: 28px;
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: 4px;
    background: rgba(255, 255, 255, .1);
    color: #fff;
    padding: 0 4px;
    font-size: 12px;
    max-width: 110px;
}
.read-opt-tts .read-tts-volume {
    width: 92px;
    vertical-align: middle;
}
.read-opt-tts .read-tts-err {
    margin-top: 8px;
    padding: 6px 8px;
    font-size: 12px;
    color: #f5b7b1;
    background: rgba(192, 57, 43, .35);
    border-radius: 4px;
    display: none;
}
.read-opt-tts .read-tts-err.show { display: block; }

/* 朗读按钮 active 高亮（与设置/进度按钮一致） */
#readBtnTts.active .read-tts-footer-ico {
    text-shadow: 0 0 2px rgba(255, 255, 255, .5);
}
