/* Trình nghe/xem sách (Plyr), đi cùng media-player.js */
.mp-wrap {
    --mp-accent: #3789d9;
    --mp-border: #e1e1e1;
    --mp-muted: #6b7280;
    --mp-hover: #f3f6fa;
    --plyr-color-main: var(--mp-accent);
    max-width: 900px;
    margin: 15px auto;
    padding: 16px;
    border: 1px solid var(--mp-border);
    border-radius: 8px;
    background: #fff;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    color: #1f2937;
}
.mp-video { max-width: 1100px; }
.mp-head { display: flex; gap: 16px; align-items: center; margin-bottom: 12px; }
.mp-cover { width: 96px; height: 96px; object-fit: cover; border-radius: 6px; flex: none; background: var(--mp-hover); }
.mp-info { min-width: 0; }
.mp-book { margin: 0 0 4px; font-size: 18px; font-weight: 600; line-height: 1.3; }
.mp-author { margin: 0 0 6px; color: var(--mp-muted); font-size: 14px; }
.mp-current { margin: 0; font-size: 14px; color: var(--mp-accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-try { margin: 0 0 12px; padding: 8px 12px; border-radius: 6px; background: #fff7e6; color: #92400e; font-size: 14px; }
/* Audio: thanh tua một hàng riêng, nút (kể cả chương trước/sau do JS chèn vào) một hàng dưới, dồn trái */
.mp-player .plyr--audio .plyr__controls { flex-wrap: wrap; justify-content: flex-start; padding: 6px 4px; background: transparent; }
.mp-player .plyr--audio .plyr__progress__container { order: -1; flex: 1 1 100%; margin: 0; padding: 0; }
.mp-player .plyr--audio .plyr__controls__item:first-child { margin-right: 0; }
/* Chặn CSS chung của site (button) làm lệch trục nút Plyr; không đụng margin của input range (Plyr dùng margin âm để khớp thanh buffer) */
.mp-wrap .plyr__control { margin: 0; line-height: 1; }
.mp-video .mp-player .plyr { border-radius: 6px; overflow: hidden; }
.mp-prev:disabled, .mp-next:disabled { opacity: .35; cursor: default; }
/* Chương audio phát trong thẻ <video> (sách có cả audio và video): giữ giao diện video nhưng khung thấp, hiện ảnh bìa,
   thanh điều khiển luôn hiện (không tự ẩn); bỏ nút play lớn và nút chỉ dành cho video */
.mp-is-audio .plyr__video-wrapper { height: 180px; padding-bottom: 0 !important; aspect-ratio: auto !important; }
.mp-is-audio .plyr__poster { opacity: 1; background-size: contain; }
.mp-is-audio .plyr--video.plyr--hide-controls .plyr__controls { opacity: 1; transform: none; pointer-events: auto; }
.mp-is-audio .plyr--video.plyr--hide-controls { cursor: auto; }
.mp-is-audio .plyr--video .plyr__control--overlaid, .mp-is-audio [data-plyr="pip"], .mp-is-audio [data-plyr="fullscreen"], .mp-is-audio [data-plyr="captions"] { display: none; }
/* Lọc Tất cả / Audio / Video (chỉ hiện khi sách có cả 2 loại) */
.mp-filter { display: flex; gap: 6px; margin-top: 12px; }
.mp-filter button { height: 30px; padding: 0 12px; border: 1px solid var(--mp-border); border-radius: 999px; background: #f8fafc; color: #374151; font-size: 13px; cursor: pointer; }
.mp-filter button.on { border-color: var(--mp-accent); background: #eef5fc; color: var(--mp-accent); font-weight: 600; }
/* Thanh cài đặt: chip bo tròn trên một dòng, thiếu chỗ thì chip co lại, chữ dài thành "…" */
.mp-tools { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; line-height: 1.2; }
.mp-field {
    position: relative; display: inline-flex; align-items: center; gap: 6px; height: 34px; margin: 0; padding-left: 12px; min-width: 0;
    border: 1px solid var(--mp-border); border-radius: 999px; background: #f8fafc; color: #374151; font-weight: normal; cursor: pointer;
    transition: border-color .15s, background-color .15s, box-shadow .15s;
}
.mp-field[hidden] { display: none; }
.mp-field:hover { border-color: #c7d2e0; background: var(--mp-hover); }
.mp-field:focus-within { border-color: var(--mp-accent); box-shadow: 0 0 0 3px rgba(55, 137, 217, .15); }
.mp-field.is-on { border-color: var(--mp-accent); background: #eef5fc; color: var(--mp-accent); }
.mp-field svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }
.mp-field-label { flex: none; color: var(--mp-muted); white-space: nowrap; }
.mp-field-label::after { content: ":"; }
/* Select hiện trực tiếp, bỏ khung mặc định; chừa bên phải cho mũi tên (::after không nhận click nên bấm mũi tên vẫn mở select) */
.mp-field select { min-width: 0; height: 100%; margin: 0; padding: 0 30px 0 0; border: 0; background: transparent; color: inherit; font: inherit; font-weight: 600; text-overflow: ellipsis; cursor: pointer; outline: 0; -webkit-appearance: none; appearance: none; }
/* Màn cảm ứng: 16px để iOS không phóng to khi chọn */
@media (pointer: coarse) { .mp-field select { font-size: 16px; } }
.mp-field::after {
    content: ""; position: absolute; right: 13px; top: 50%; width: 6px; height: 6px; margin-top: -5px;
    border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); opacity: .5; pointer-events: none;
}
.mp-sleep {
    flex: none; display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px;
    background: var(--mp-accent); color: #fff; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.mp-sleep::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: mp-pulse 1.4s ease-in-out infinite; }
.mp-sleep:empty { display: none; }
@keyframes mp-pulse { 50% { opacity: .3; } }
.mp-list { list-style: none; margin: 12px 0 0; padding: 0; max-height: 420px; overflow-y: auto; border-top: 1px solid var(--mp-border); }
.mp-item { position: relative; display: flex; align-items: center; gap: 10px; padding: 10px 8px; border-bottom: 1px solid var(--mp-border); cursor: pointer; font-size: 14px; }
.mp-item:hover { background: var(--mp-hover); }
.mp-item.active { color: var(--mp-accent); font-weight: 600; }
.mp-no { width: 28px; flex: none; display: flex; justify-content: flex-end; align-items: center; color: var(--mp-muted); }
.mp-item.active .mp-no { color: var(--mp-accent); }
.mp-item.active .mp-no::before { content: ""; width: 12px; height: 12px; margin-right: 8px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 12 12%27%3E%3Crect x=%270%27 y=%274%27 width=%273%27 height=%278%27 rx=%271%27/%3E%3Crect x=%274.5%27 width=%273%27 height=%2712%27 rx=%271%27/%3E%3Crect x=%279%27 y=%277%27 width=%273%27 height=%275%27 rx=%271%27/%3E%3C/svg%3E") no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 12 12%27%3E%3Crect x=%270%27 y=%274%27 width=%273%27 height=%278%27 rx=%271%27/%3E%3Crect x=%274.5%27 width=%273%27 height=%2712%27 rx=%271%27/%3E%3Crect x=%279%27 y=%277%27 width=%273%27 height=%275%27 rx=%271%27/%3E%3C/svg%3E") no-repeat; }
/* Icon loại chương (tai nghe / máy quay), chỉ khi sách có cả 2 loại */
.mp-kind { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; color: var(--mp-muted); }
.mp-item.active .mp-kind { color: var(--mp-accent); }
.mp-item[hidden] { display: none; }
.mp-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-time { flex: none; color: var(--mp-muted); font-variant-numeric: tabular-nums; }
/* Tiến độ chương: thanh mảnh ở đáy dòng (nghe dở), ✓ trước thời lượng (đã xong) */
.mp-bar { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--mp-accent); }
.mp-item.done .mp-time::before { content: "✓ "; color: #16a34a; }
.mp-empty { padding: 16px 8px; color: var(--mp-muted); font-size: 14px; }
.mp-error { color: #dc2626; }
@media (max-width: 576px) {
    .mp-wrap { margin: 0; border-radius: 0; border-left: 0; border-right: 0; padding: 12px; }
    .mp-cover { width: 64px; height: 64px; }
    .mp-book { font-size: 16px; }
    /* Màn nhỏ: bỏ nút ít dùng để hàng nút vừa một dòng (âm lượng dùng phím của máy; video còn tua bằng chạm thanh tua) */
    .mp-wrap .plyr__volume, .mp-video [data-plyr="rewind"], .mp-video [data-plyr="fast-forward"], .mp-video [data-plyr="pip"] { display: none; }
    .mp-field-label { display: none; } /* màn nhỏ: chỉ icon + giá trị, nhãn ở title */
}
