/* =========================
   TRANG VIDEO CHI TIẾT
   ========================= */

/* Layout chính 2 cột trên desktop. */
.watch-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 24px;
    align-items: start;
}

.watch-main,
.watch-side {
    min-width: 0;
}

/* =========================
   KHUNG PLAYER
   ========================= */

/* Khung video chính. */
.player-shell,
.sv-player-shell {
    position: relative;
    width: 100%;
    background: #000;
    border: 1px solid var(--border);
    border-radius: 18px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
}

/* Lớp overlay cho custom controls. */
.player-shell--overlay {
    position: relative;
}

/* Video native nằm kín trong khung. */
.player-shell > video,
.sv-player-shell > video {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    max-height: none;
    background: #000;
    object-fit: contain;
}

/* Wrapper Plyr/HLS/DASH nếu dùng thư viện player. */
.player-shell .plyr,
.player-shell .plyr__video-wrapper,
.player-shell .plyr video {
    width: 100% !important;
    height: 100% !important;
    background: #000;
}

/* Video trong Plyr không bị crop. */
.player-shell .plyr video {
    object-fit: contain !important;
}

/* =========================
   OVERLAY PLAYER
   ========================= */

/* Gradient phủ dưới video để control dễ nhìn. */
.sv-player-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    opacity: 1;
    pointer-events: none;
    transition: opacity .2s ease;
    background: linear-gradient(to top, rgba(0, 0, 0, .82), rgba(0, 0, 0, .18) 42%, rgba(0, 0, 0, 0));
}

/* Ẩn control khi player idle. */
.sv-player-shell.is-idle .sv-player-overlay {
    opacity: 0;
}

/* Vùng chứa toàn bộ control custom. */
.sv-player-controls {
    width: 100%;
    padding: 0 8px 4px 8px;
    color: #fff;
    pointer-events: auto;
}

/* =========================
   PROGRESS BAR
   ========================= */

/* Vùng bắt sự kiện tua/kéo video. */
.sv-progress-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    width: 100%;
    height: 18px;
    cursor: pointer;
}

/* Track nền của progress bar. */
.sv-progress-track {
    position: relative;
    width: 100%;
    height: 5px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, .24);
}

/* Phần video đã buffer. */
.sv-progress-buffer {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, .34);
}

/* Phần video đã phát. */
.sv-progress-played {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    border-radius: 999px;
    background: #ff0033;
}

/* Nút kéo tua trên progress bar. */
.sv-progress-thumb {
    position: absolute;
    top: 50%;
    left: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ff0033;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 0 3px rgba(255, 0, 51, .18);
}

/* =========================
   CONTROL ROW
   ========================= */

/* Hàng chứa play, time, source, volume, loop, PiP, setting, fullscreen. */
.sv-controls-row {
    display: grid;
    grid-template-columns: auto auto auto minmax(120px, auto) minmax(0, 1fr) auto auto auto auto auto;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}

/* Style chung cho các nút control. */
.sv-control-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    color: #fff;
    background: transparent;
    cursor: pointer;
}

/* Hover cho nút control. */
.sv-control-btn:hover {
    background: rgba(255, 255, 255, .14);
}

/* Icon trong nút control. */
.sv-control-btn i {
    font-size: 22px;
    line-height: 1;
}

/* Icon fullscreen nhỏ hơn một chút để cân bằng với các nút control khác. */
#svFullscreenBtn i {
    font-size: 18px;
}

/* Text thời gian hiện tại / tổng thời lượng. */
.sv-time-text {
    color: rgba(255, 255, 255, .92);
    font-size: 13px;
    white-space: nowrap;
    user-select: none;
}

/* Label source đang phát. */
.sv-source-label {
    min-width: 0;
    color: rgba(255, 255, 255, .86);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: none;
}

/* Cụm âm lượng. */
.sv-volume-box {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Thanh chỉnh âm lượng. */
.sv-volume-range {
    width: 86px;
    accent-color: #fff;
}

/* Active state của loop/setting. */
.sv-loop-active,
.sv-hd-active,
.sv-settings-active {
    color: #ff0033;
}

/* =========================
   CENTER PLAY ANIMATION
   ========================= */

/* Icon play/pause hiện giữa video. */
.sv-play-center {
    position: absolute;
    top: 50%;
    left: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    color: #fff;
    background: rgba(0, 0, 0, .46);
    transform: translate(-50%, -50%);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
}

/* Hiện animation play/pause. */
.sv-play-center.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.04);
}

/* Icon trong animation. */
.sv-play-center i {
    font-size: 42px;
    line-height: 1;
}

/* =========================
   PLAYER MESSAGE
   ========================= */

/* Thông báo nhỏ trong player. */
.sv-player-message {
    position: absolute;
    left: 14px;
    top: 14px;
    max-width: calc(100% - 28px);
    padding: 7px 10px;
    border-radius: 999px;
    color: #fff;
    background: rgba(0, 0, 0, .55);
    font-size: 12px;
    line-height: 1.35;
    pointer-events: none;
}

/* =========================
   NÚT BẬT TIẾNG
   ========================= */

/* Overlay bật tiếng khi autoplay bị muted. */
.player-unmute-overlay {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 5;
    height: 42px;
    padding: 0 14px;
    border: 0;
    border-radius: 999px;
    background: rgba(15, 15, 15, 0.78);
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    backdrop-filter: blur(8px);
    cursor: pointer;
    transition: background-color 0.2s ease, opacity 0.2s ease;
    opacity: 0.96;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
}

/* Hover nút bật tiếng. */
.player-unmute-overlay:hover {
    background: rgba(15, 15, 15, 0.92);
}

/* Ẩn nút bật tiếng. */
.player-unmute-overlay.hidden {
    display: none;
}

/* Icon bật tiếng. */
.player-unmute-overlay__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

/* Text bật tiếng. */
.player-unmute-overlay__text {
    line-height: 1;
}

/* =========================
   SETTINGS PANEL
   ========================= */

/* Wrapper để neo panel vào nút bánh răng. */
.sv-settings-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Panel setting nằm phía trên nút setting. */
.sv-settings-panel {
    position: absolute;
    right: 0;
    bottom: 38px;
    width: 300px;
    max-width: calc(100vw - 22px);
    max-height: min(300px, calc(100vh - 150px));
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 14px;
    color: #fff;
    background: rgba(43, 43, 43, .96);
    box-shadow: 0 14px 38px rgba(0, 0, 0, .42);
    backdrop-filter: blur(12px);
    display: none;
    z-index: 40;
}

/* Hiện panel setting. */
.sv-settings-panel.show {
    display: block;
}

/* Màn hình con trong settings. */
.sv-settings-view {
    display: none;
    max-height: min(300px, calc(100vh - 150px));
    overflow: hidden;
}

/* View setting đang hiển thị. */
.sv-settings-view.show {
    display: flex;
    flex-direction: column;
}

/* View chính gồm tốc độ và chất lượng. */
.sv-settings-main {
    padding: 8px;
    overflow-y: auto;
}

/* Dòng menu setting chính. */
.sv-settings-row {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) auto 14px;
    align-items: center;
    gap: 2px;
    width: 100%;
    min-height: 48px;
    padding: 4px 5px;
    border: 0;
    border-radius: 8px;
    color: #fff;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

/* Hover menu setting. */
.sv-settings-row:hover,
.sv-settings-row.is-focus {
    background: rgba(255, 255, 255, .12);
}

/* Icon trong dòng setting. */
.sv-settings-row-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: rgba(255, 255, 255, .94);
}

/* Kích thước icon setting. */
.sv-settings-row-icon i {
    font-size: 18px;
    line-height: 1;
}

/* Tiêu đề dòng setting. */
.sv-settings-row-title {
    min-width: 0;
    color: rgba(255, 255, 255, .96);
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Giá trị hiện tại. */
.sv-settings-row-value {
    max-width: 116px;
    color: rgba(255, 255, 255, .74);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mũi tên sang view con. */
.sv-settings-row-arrow {
    color: rgba(255, 255, 255, .66);
    font-size: 20px;
    line-height: 1;
}

/* Header của view con. */
.sv-settings-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 9px;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
    background: rgba(43, 43, 43, .98);
}

/* Nút back trong view con. */
.sv-settings-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    color: #fff;
    background: transparent;
    cursor: pointer;
}

/* Hover nút back. */
.sv-settings-back:hover {
    background: rgba(255, 255, 255, .12);
}

/* Icon back. */
.sv-settings-back i {
    font-size: 20px;
    line-height: 1;
}

/* Tiêu đề view con. */
.sv-settings-title {
    min-width: 0;
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =========================
   SPEED SETTINGS
   ========================= */

/* Body chỉnh tốc độ. */
.sv-speed-box {
    overflow-y: auto;
    padding: 14px 14px 12px 14px;
}

/* Text tốc độ hiện tại. */
.sv-speed-value {
    margin-bottom: 14px;
    color: #fff;
    font-size: 22px;
    font-weight: 800;
    text-align: center;
    letter-spacing: .02em;
}

/* Hàng nút giảm, slider, nút tăng. */
.sv-speed-slider-row {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

/* Nút tăng/giảm tốc độ. */
.sv-speed-step-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    color: #fff;
    background: rgba(255, 255, 255, .12);
    cursor: pointer;
}

/* Hover nút tăng/giảm. */
.sv-speed-step-btn:hover {
    background: rgba(255, 255, 255, .2);
}

/* Icon tăng/giảm. */
.sv-speed-step-btn i {
    font-size: 18px;
    line-height: 1;
}

/* Slider tốc độ. */
.sv-speed-range {
    width: 100%;
    accent-color: #fff;
}

/* Dãy preset tốc độ. */
.sv-speed-preset-row {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 7px;
}

/* Nút preset tốc độ. */
.sv-speed-preset {
    min-height: 36px;
    padding: 0 5px;
    border: 0;
    border-radius: 999px;
    color: #fff;
    background: rgba(255, 255, 255, .12);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

/* Hover preset tốc độ. */
.sv-speed-preset:hover {
    background: rgba(255, 255, 255, .2);
}

/* Preset tốc độ đang chọn. */
.sv-speed-preset.is-active {
    color: #202020;
    background: #fff;
}

/* Text trạng thái tốc độ. */
.sv-speed-default-text {
    margin-top: 8px;
    color: rgba(255, 255, 255, .72);
    font-size: 12px;
}

/* =========================
   QUALITY SETTINGS
   ========================= */

/* Danh sách chất lượng có scroll riêng. */
.sv-quality-list {
    flex: 1 1 auto;
    max-height: calc(min(300px, calc(100vh - 150px)) - 44px);
    overflow-y: auto;
    padding: 8px;
    overscroll-behavior: contain;
}

/* Một dòng chất lượng/source. */
.sv-quality-option {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 50px;
    padding: 8px 10px;
    border: 0;
    border-radius: 10px;
    color: #fff;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

/* Hover/active dòng chất lượng. */
.sv-quality-option:hover,
.sv-quality-option.is-active {
    background: rgba(255, 255, 255, .12);
}

/* Label chính của chất lượng. */
.sv-quality-main {
    min-width: 0;
    color: rgba(255, 255, 255, .96);
    font-size: 13px;
    font-weight: 800;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Dòng phụ codec/protocol/container. */
.sv-quality-sub {
    margin-top: 3px;
    color: rgba(255, 255, 255, .62);
    font-size: 10px;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Badge HD/Premium. */
.sv-quality-badge {
    display: inline-flex;
    align-items: center;
    height: 16px;
    margin-left: 5px;
    padding: 0 5px;
    border-radius: 4px;
    color: #fff;
    background: #cc001f;
    font-size: 10px;
    font-weight: 800;
    vertical-align: middle;
}

/* Dấu tick source đang chọn. */
.sv-quality-check {
    color: #fff;
    font-size: 16px;
    line-height: 1;
}

/* =========================
   THÔNG TIN VIDEO
   ========================= */

/* Tiêu đề video. */
.watch-title {
    margin: 16px 0 12px;
    font-size: 1.22rem;
    line-height: 1.35;
    font-weight: 700;
    color: var(--text);
}

/* Khu vực channel và actions. */
.watch-meta-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

/* Channel info. */
.watch-channel {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

/* Avatar channel. */
.watch-channel-avatar {
    width: 44px;
    height: 44px;
    border-radius: 999px;
    object-fit: cover;
    flex-shrink: 0;
}

/* Tên channel. */
.watch-channel-name {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--text);
    line-height: 1.35;
}

/* Sub text channel. */
.watch-channel-sub {
    color: var(--text-soft);
    font-size: 0.82rem;
    line-height: 1.35;
}

/* Nhóm nút action. */
.watch-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* Nút like/share. */
.watch-btn {
    height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    border: 0;
    background: var(--btn-bg);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Hover action. */
.watch-btn:hover {
    background: var(--btn-bg-hover);
}

/* Trạng thái đã like. */
.watch-btn.is-liked {
    background: rgba(255, 45, 45, 0.12);
    color: #d93025;
}

/* =========================
   MÔ TẢ + NỘI DUNG
   ========================= */

/* Card mô tả và nội dung. */
.watch-desc,
.watch-content-box {
    margin-top: 12px;
    padding: 16px;
    border-radius: 16px;
    background: var(--card);
    border: 1px solid var(--border);
}

/* Meta mô tả và tiêu đề nội dung. */
.watch-desc-meta,
.watch-content-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text);
}

/* Body mô tả/nội dung. */
.watch-desc-body,
.watch-content-body {
    color: var(--text);
    font-size: 0.92rem;
    line-height: 1.6;
    word-break: break-word;
}

/* Media trong nội dung không tràn layout. */
.watch-desc-body img,
.watch-content-body img,
.watch-desc-body iframe,
.watch-content-body iframe,
.watch-desc-body table,
.watch-content-body table,
.watch-desc-body video,
.watch-content-body video {
    max-width: 100%;
}

/* =========================
   VIDEO LIÊN QUAN
   ========================= */

/* Danh sách video liên quan. */
.related-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Card video liên quan. */
.related-card {
    display: grid;
    grid-template-columns: 168px minmax(0, 1fr);
    gap: 10px;
}

/* Thumbnail video liên quan. */
.related-thumb {
    border-radius: 14px;
    overflow: hidden;
    background: var(--card-2);
    border: 1px solid var(--border);
}

/* Info video liên quan. */
.related-info {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

/* Tiêu đề video liên quan. */
.related-title {
    margin: 0 0 6px;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
    overflow: hidden;
}

/* Link trong tiêu đề không được kéo layout tràn ngang. */
.related-title a {
    display: -webkit-box;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    color: inherit;
    line-height: 1.35;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    overflow-wrap: anywhere;
    word-break: break-word;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Mô tả/meta video liên quan. */
.related-desc,
.related-meta {
    max-width: 100%;
    color: var(--text-soft);
    font-size: 0.82rem;
    line-height: 1.4;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Meta video liên quan. */
.related-meta {
    margin-top: 2px;
}

/* Loading video liên quan. */
.related-loading {
    display: none;
    justify-content: center;
    padding: 18px 0;
    color: var(--text-soft);
}

/* Hiện loading. */
.related-loading.show {
    display: flex;
}

/* Empty state video liên quan. */
.related-empty {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 28px 20px;
    border: 1px dashed var(--border);
    border-radius: 18px;
    background: var(--card);
    text-align: center;
}

/* Icon empty state. */
.related-empty__icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 14px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--btn-bg);
    color: var(--text-soft);
    font-size: 1.6rem;
}

/* Title empty state. */
.related-empty__title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

/* Text empty state. */
.related-empty__text {
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--text-soft);
    margin-bottom: 16px;
}

/* Button empty state. */
.related-empty__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 128px;
    height: 40px;
    padding: 0 16px;
    border-radius: 999px;
    background: var(--btn-bg);
    color: var(--text);
    font-weight: 600;
    transition: background-color 0.2s ease;
}

/* Hover button empty state. */
.related-empty__btn:hover {
    background: var(--btn-bg-hover);
}

/* =========================
   POPUP CHIA SẺ
   ========================= */

/* Khóa scroll khi mở modal. */
.modal-open-custom {
    overflow: hidden;
}

/* Modal chia sẻ. */
.share-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
}

/* Hiện modal chia sẻ. */
.share-modal.show {
    display: block;
}

/* Backdrop modal. */
.share-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

/* Dialog modal. */
.share-modal__dialog {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    width: min(560px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 18px;
}

/* Header modal. */
.share-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

/* Title modal. */
.share-modal__title {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--text);
}

/* Nút đóng modal. */
.share-modal__close {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 999px;
    background: var(--btn-bg);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Hover nút đóng modal. */
.share-modal__close:hover {
    background: var(--btn-bg-hover);
}

/* Grid nền tảng chia sẻ. */
.share-platforms {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

/* Item nền tảng chia sẻ. */
.share-platform {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    color: var(--text);
}

/* Icon nền tảng chia sẻ. */
.share-platform__icon {
    width: 56px;
    height: 56px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--btn-bg);
    border: 1px solid var(--border);
    font-size: 1.2rem;
    font-weight: 700;
}

/* Text nền tảng chia sẻ. */
.share-platform__text {
    font-size: 0.82rem;
    color: var(--text-soft);
}

/* Hover icon chia sẻ. */
.share-platform:hover .share-platform__icon {
    background: var(--btn-bg-hover);
}

/* Row copy link. */
.share-copy-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Input copy link. */
.share-copy-input {
    flex: 1;
    min-width: 0;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text);
    padding: 0 12px;
}

/* Nút copy link. */
.share-copy-btn-popup {
    height: 44px;
    padding: 0 16px;
    border-radius: 12px;
    border: 0;
    background: var(--brand);
    color: #fff;
    font-weight: 600;
    white-space: nowrap;
}

/* =========================
   PLYR CUSTOM
   ========================= */

/* Bo góc Plyr desktop. */
.plyr {
    border-radius: 18px;
}

/* Nền Plyr video. */
.plyr--video {
    background: #000;
}

/* Nút play lớn của Plyr. */
.plyr__control--overlaid {
    background: rgba(255, 45, 45, 0.9);
}

/* Menu Plyr. */
.plyr__menu__container {
    border-radius: 14px;
}

/* Thanh range Plyr. */
.plyr--full-ui input[type="range"] {
    color: var(--brand);
}

/* Nút loop custom trong Plyr. */
.plyr__control--loop-custom {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    min-width: auto;
}

/* Icon loop custom. */
.plyr__control--loop-custom .bi {
    font-size: 1rem;
    line-height: 1;
}

/* Text loop custom. */
.plyr__control--loop-custom .plyr__custom-text {
    font-size: 0.82rem;
    line-height: 1;
}

/* Loop custom đang active. */
.plyr__control--loop-custom.is-active {
    background: rgba(255, 45, 45, 0.18) !important;
    color: #ff4d4f !important;
}

/* =========================
   TABLET
   ========================= */

@media (max-width: 1199.98px) {
    /* Chuyển layout về 1 cột. */
    .watch-layout {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    /* Tạo khoảng cách cho cột liên quan. */
    .watch-side {
        margin-top: 4px;
    }
}

/* =========================
   MOBILE
   ========================= */

@media (max-width: 767.98px) {
    /* Chặn scroll ngang do player full-bleed. */
    html,
    body,
    .page-content,
    .watch-layout,
    .watch-main {
        overflow-x: hidden;
    }

    /* Layout mobile 1 cột. */
    .watch-layout {
        display: block;
    }

    .watch-main,
    .watch-side {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    /* Player full ngang viewport, bỏ padding cha .page-content. */
    .watch-main > .player-shell,
    .watch-main > .sv-player-shell,
    .watch-main > .player-shell.sv-player-shell {
        width: 100vw !important;
        max-width: 100vw !important;
        margin-left: calc(50% - 50vw) !important;
        margin-right: calc(50% - 50vw) !important;
        border-left: 0 !important;
        border-right: 0 !important;
        border-radius: 0 !important;
        box-sizing: border-box !important;
        aspect-ratio: 16 / 9;
    }

    /* Video nằm đúng trong player full ngang. */
    .watch-main > .player-shell > video,
    .watch-main > .sv-player-shell > video,
    .watch-main > .player-shell.sv-player-shell > video {
        position: absolute;
        inset: 0;
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: none !important;
        display: block;
        object-fit: contain;
        box-sizing: border-box;
        border-radius: 0 !important;
    }

    /* Overlay không bo góc trên mobile. */
    .watch-main > .player-shell .sv-player-overlay,
    .watch-main > .sv-player-shell .sv-player-overlay,
    .watch-main > .player-shell.sv-player-shell .sv-player-overlay {
        border-radius: 0 !important;
    }

    /* Plyr cũng bỏ bo góc trên mobile. */
    .player-shell .plyr,
    .player-shell .plyr__video-wrapper,
    .player-shell .plyr video,
    .plyr {
        border-radius: 0 !important;
    }

    /* Rút gọn control row mobile. */
    .sv-controls-row {
        grid-template-columns: auto auto minmax(90px, auto) minmax(0, 1fr) auto auto auto;
        gap: 8px;
    }

    /* Ẩn nút tua và thanh âm lượng để tiết kiệm chỗ. */
    .sv-backward-btn,
    .sv-forward-btn,
    .sv-volume-range {
        display: none;
    }

    /* Ẩn source label trên mobile. */
    .sv-source-label {
        display: none;
    }

    /* Thu nhỏ nút bật tiếng. */
    .player-unmute-overlay {
        top: 12px;
        right: 12px;
        height: 38px;
        padding: 0 12px;
        font-size: 0.84rem;
    }

    /* Thu gọn panel setting. */
    .sv-settings-panel {
        right: -44px;
        bottom: 38px;
        width: min(300px, calc(100vw - 18px));
        max-height: min(285px, calc(100vh - 130px));
    }

    /* Giới hạn chiều cao view setting. */
    .sv-settings-view {
        max-height: min(285px, calc(100vh - 130px));
    }

    /* Danh sách chất lượng scroll riêng. */
    .sv-quality-list {
        max-height: calc(min(285px, calc(100vh - 130px)) - 44px);
    }

    /* Preset tốc độ chia 3 cột trên mobile. */
    .sv-speed-preset-row {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    /* Tiêu đề video mobile. */
    .watch-title {
        font-size: 1.02rem;
        margin: 14px 0 10px;
    }

    /* Meta mobile xếp dọc. */
    .watch-meta-top {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    /* Channel mobile. */
    .watch-channel {
        align-items: center;
    }

    /* Action mobile scroll ngang. */
    .watch-actions {
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 8px;
        padding-bottom: 2px;
        scrollbar-width: none;
    }

    .watch-actions::-webkit-scrollbar {
        display: none;
    }

    /* Nút action mobile. */
    .watch-btn {
        flex: 0 0 auto;
        height: 38px;
        font-size: 0.86rem;
        padding: 0 12px;
    }

    /* Card nội dung mobile. */
    .watch-desc,
    .watch-content-box {
        padding: 14px;
        border-radius: 14px;
    }

    /* Danh sách video liên quan không được kéo tràn ngang mobile. */
    .related-list {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: hidden;
    }
    
    /* Card liên quan mobile. */
    .related-card {
        grid-template-columns: 140px minmax(0, 1fr);
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: hidden;
    }

    /* Thumbnail video liên quan giữ đúng kích thước mobile. */
    .related-thumb {
        width: 140px;
        max-width: 140px;
        min-width: 0;
    }
    
    /* Info video liên quan không được ép rộng làm tràn màn hình. */
    .related-info {
        min-width: 0;
        max-width: 100%;
        overflow: hidden;
    }

    /* Tiêu đề video liên quan mobile không được tràn ngang. */
    .related-title,
    .related-title a {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    
    /* Grid share mobile. */
    .share-platforms {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    /* Copy link mobile xếp dọc. */
    .share-copy-row {
        flex-direction: column;
        align-items: stretch;
    }

    /* Nút copy full width. */
    .share-copy-btn-popup {
        width: 100%;
    }

    /* Ẩn text loop custom nếu dùng Plyr. */
    .plyr__control--loop-custom .plyr__custom-text {
        display: none;
    }
}

@media (max-width: 767.98px) {
    /* Chỉ trang video detail: bỏ padding ngang của content wrapper nếu có. */
    body:has(#svPlayerShell) .page-content {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* Trả khoảng cách ngang cho nội dung dưới video, không làm element vượt quá viewport. */
    body:has(#svPlayerShell) .watch-title,
    body:has(#svPlayerShell) .watch-meta-top,
    body:has(#svPlayerShell) .watch-desc,
    body:has(#svPlayerShell) .watch-content-box,
    body:has(#svPlayerShell) .watch-side {
        width: calc(100% - 20px);
        max-width: calc(100% - 20px);
        margin-left: 10px;
        margin-right: 10px;
        box-sizing: border-box;
    }

    /* Player không cần full-bleed nữa vì page-content đã bỏ padding. */
    body:has(#svPlayerShell) #svPlayerShell {
        left: auto !important;
        right: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

@media (max-width: 420px) {
    /* Thu thumbnail lại để title có thêm không gian trên màn hình nhỏ. */
    .related-card {
        grid-template-columns: 124px minmax(0, 1fr);
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    /* Đồng bộ width thumbnail với grid column. */
    .related-thumb {
        width: 124px;
        max-width: 124px;
        min-width: 0;
        box-sizing: border-box;
    }
}