/* Mini Series v4 — focused layout, site yellow accent */

body.ms-mode {
    --ms-yellow: #f2eb16;
    --ms-red: #dc3545;
    --ms-bg: #0b0b0b;
    --ms-card: #161616;
    --ms-line: #2a2a2a;
    --ms-text: #f5f5f5;
    --ms-muted: #a3a3a3;
}

body.ms-mode > main > h1 {
    display: none !important;
}

/* ---------- page shell ---------- */
.ms-page {
    color: #f5f5f5;
    padding: 14px 12px 24px;
    background: rgba(0, 0, 0, .88);
    border: 1px solid #2a2a2a;
    border-radius: 12px;
}

.ms-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.ms-topbar a.ms-link {
    color: #fff !important;
    text-decoration: none !important;
    background: #1d1d1d;
    border: 1px solid var(--ms-line);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
}

.ms-topbar a.ms-link:hover {
    border-color: var(--ms-yellow);
    color: var(--ms-yellow) !important;
}

.ms-topbar-title {
    color: var(--ms-muted);
    font-size: 14px;
}

/* ---------- list hero ---------- */
.ms-hero {
    background: linear-gradient(135deg, #1a1a12 0%, #111 55%, #1a0f12 100%);
    border: 1px solid #2e2e1a;
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 16px;
}

.ms-hero-top {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    margin-bottom: 14px;
}

.ms-hero h2 {
    margin: 0 0 6px;
    color: var(--ms-yellow);
    font-size: 1.6rem;
    font-weight: 800;
}

.ms-hero p {
    margin: 0;
    color: var(--ms-muted);
    font-size: 14px;
}

.ms-search {
    display: flex;
    gap: 8px;
}

.ms-search input[type="search"] {
    flex: 1;
    min-width: 0;
    background: #0f0f0f;
    border: 1px solid var(--ms-line);
    color: #fff;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 15px;
}

.ms-search button {
    background: var(--ms-yellow);
    color: #111;
    border: 0;
    border-radius: 10px;
    padding: 12px 18px;
    font-weight: 800;
    cursor: pointer;
}

/* Platform segmented control — wrap 2 rows (desktop) / 3 rows (narrow) */
.ms-platform-seg {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: 100%;
    box-sizing: border-box;
    background: #0d0d0d;
    border: 1px solid #333;
    border-radius: 12px;
    padding: 6px;
    gap: 6px;
}

a.ms-platform-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-width: 0;
    min-height: 42px;
    padding: 8px 10px;
    border-radius: 9px;
    text-decoration: none !important;
    color: #bbb !important;
    font-size: 13px;
    font-weight: 800;
    background: transparent;
    border: 0;
    transition: background .15s ease, color .15s ease;
}

.ms-platform-logo {
    width: 20px;
    height: 20px;
    border-radius: 5px;
    object-fit: cover;
    flex: 0 0 auto;
    display: block;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .08);
}

.ms-platform-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.15;
}

a.ms-platform-btn:hover {
    color: #fff !important;
    background: #222;
}

a.ms-platform-btn.is-active {
    background: var(--ms-yellow) !important;
    color: #111 !important;
}

a.ms-platform-btn.is-active .ms-platform-logo {
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .12);
}

/* Category bar — own row, clear separation */
.ms-cat-bar {
    margin: 0 0 18px;
    padding: 12px;
    background: #121212;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
}

.ms-cat-label {
    margin: 0 0 10px;
    color: #f2eb16;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .02em;
}

.ms-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 0 4px;
    margin: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.ms-tabs::-webkit-scrollbar {
    height: 4px;
}

.ms-tabs::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

a.ms-tab {
    flex: 0 0 auto;
    display: inline-flex !important;
    align-items: center;
    text-decoration: none !important;
    color: #ddd !important;
    background: #1c1c1c;
    border: 1px solid #333;
    border-radius: 999px;
    padding: 9px 14px;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    line-height: 1.2;
}

a.ms-tab.is-active,
a.ms-tab:hover {
    background: var(--ms-yellow) !important;
    border-color: var(--ms-yellow);
    color: #111 !important;
}

@media (max-width: 980px) {
    .ms-platform-seg {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .ms-platform-seg {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 5px;
        padding: 5px;
    }
    a.ms-platform-btn {
        flex-direction: column;
        gap: 4px;
        min-height: 52px;
        padding: 7px 6px;
        font-size: 11px;
    }
    .ms-platform-logo {
        width: 22px;
        height: 22px;
        border-radius: 6px;
    }
}

/* ---------- rails / grid ---------- */
.ms-rail {
    margin: 0 0 18px;
}

.ms-rail-title {
    margin: 0 0 10px;
    font-size: 1.1rem;
    font-weight: 800;
    color: #fff;
}

.ms-rail-track {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
}

.ms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

/* ---------- cards ---------- */
.ms-card {
    flex: 0 0 158px;
    scroll-snap-align: start;
    background: var(--ms-card);
    border: 1px solid var(--ms-line);
    border-radius: 12px;
    overflow: hidden;
}

a.ms-card-link {
    display: block;
    color: inherit !important;
    text-decoration: none !important;
}

.ms-card-poster {
    position: relative;
    aspect-ratio: 2 / 3;
    background: #222;
}

.ms-card-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ms-card-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,.82);
    color: var(--ms-yellow);
    font-size: 11px;
    font-weight: 800;
    padding: 3px 7px;
    border-radius: 6px;
    z-index: 1;
}

.ms-card-platform {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(242, 235, 22, .92);
    color: #111;
    font-size: 10px;
    font-weight: 900;
    padding: 3px 7px;
    border-radius: 6px;
    z-index: 1;
    max-width: calc(100% - 72px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ms-search-group {
    margin-bottom: 22px;
}

.ms-search-group-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ms-search-group-logo {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    object-fit: cover;
    flex: 0 0 auto;
}

.ms-search-group-count {
    margin-left: auto;
    color: var(--ms-muted);
    font-size: 12px;
    font-weight: 700;
    background: #1c1c1c;
    border: 1px solid #333;
    border-radius: 999px;
    padding: 2px 9px;
}

.ms-card-langs {
    position: absolute;
    left: 6px;
    bottom: 6px;
    right: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    z-index: 1;
}

.ms-card-lang {
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 5px;
    color: #111;
    background: #f2eb16;
}

.ms-card-lang.is-sub {
    background: #22c55e;
    color: #04140a;
}

.ms-card-lang.is-dub {
    background: #f2eb16;
    color: #111;
}

.ms-card-body {
    padding: 9px 10px 11px;
}

.ms-card-title {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.7em;
    color: #fff;
}

.ms-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.ms-card-tags span {
    font-size: 10px;
    font-weight: 700;
    color: #ddd;
    background: #222;
    border: 1px solid #333;
    border-radius: 999px;
    padding: 2px 7px;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ms-card-meta {
    margin-top: 6px;
    color: var(--ms-muted);
    font-size: 11px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* ---------- detail ---------- */
.ms-detail {
    display: grid;
    grid-template-columns: 210px 1fr;
    gap: 18px;
    background: var(--ms-card);
    border: 1px solid var(--ms-line);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 14px;
}

.ms-detail-poster img {
    width: 100%;
    border-radius: 10px;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    display: block;
    background: #222;
}

.ms-detail-title {
    margin: 0 0 10px;
    font-size: 1.5rem;
    font-weight: 800;
    color: #fff;
}

.ms-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.ms-chips span {
    background: #222;
    color: var(--ms-yellow);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 700;
}

.ms-chips span.is-dub {
    background: #f2eb16;
    color: #111;
}

.ms-chips span.is-sub {
    background: #22c55e;
    color: #04140a;
}

.ms-detail-desc {
    color: #cfcfcf;
    line-height: 1.7;
    font-size: 14px;
    margin: 0 0 14px;
}

.ms-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

a.ms-btn,
button.ms-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 800;
    text-decoration: none !important;
    border: 1px solid transparent;
    cursor: pointer;
}

a.ms-btn-primary,
button.ms-btn-primary {
    background: var(--ms-yellow);
    color: #111 !important;
}

a.ms-btn-ghost,
button.ms-btn-ghost {
    background: transparent;
    color: #fff !important;
    border-color: var(--ms-line);
}

a.ms-btn.is-disabled {
    opacity: .35;
    pointer-events: none;
}

/* ---------- episodes ---------- */
.ms-panel {
    background: var(--ms-card);
    border: 1px solid var(--ms-line);
    border-radius: 12px;
    padding: 14px;
}

.ms-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.ms-panel-head h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
}

.ms-panel-head span {
    color: var(--ms-muted);
    font-size: 13px;
}

.ms-ep-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
    gap: 8px;
}

a.ms-ep {
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    background: #1c1c1c !important;
    color: #fff !important;
    text-decoration: none !important;
    border: 1px solid var(--ms-line);
    border-radius: 10px;
    font-weight: 800;
}

a.ms-ep.is-active,
a.ms-ep:hover {
    background: var(--ms-yellow) !important;
    border-color: var(--ms-yellow);
    color: #111 !important;
}

/* ---------- player (iDrama-style HD/CC bar) ---------- */
.ms-player-wrap {
    max-width: 420px;
    margin: 0 auto 16px;
    background: #000;
    border: 1px solid #2a2a2a;
    border-radius: 14px;
    overflow: hidden;
}
.ms-player-top {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(0, 0, 0, .55);
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.ms-player-back {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    border: none;
    background: rgba(255, 255, 255, .1);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}
.ms-player-back:hover { background: rgba(255, 255, 255, .18); color: #fff; }
.ms-now-playing {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex: 1;
}
.ms-now-playing-label {
    font-size: .62rem;
    font-weight: 800;
    letter-spacing: .04em;
    color: #ff2d7a;
    background: rgba(255, 45, 122, .16);
    padding: 3px 7px;
    border-radius: 5px;
    flex-shrink: 0;
}
.ms-now-playing-meta {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    flex: 1;
}
.ms-now-playing-title {
    font-size: .78rem;
    font-weight: 700;
    line-height: 1.2;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ms-now-playing-text {
    font-size: .7rem;
    font-weight: 500;
    color: rgba(255, 255, 255, .68);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}
.ms-video-shell {
    position: relative;
    background: #000;
    container-type: inline-size;
}
.ms-video-shell video {
    width: 100%;
    display: block;
    background: #000;
    aspect-ratio: 9 / 16;
    max-height: min(72vh, 72dvh);
    object-fit: contain;
}
.ms-player-loading {
    position: absolute;
    inset: 0;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .4);
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s;
}
.ms-player-loading.show {
    opacity: 1;
    pointer-events: auto;
}
.ms-player-spinner {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, .2);
    border-top-color: #fff;
    animation: ms-spin .7s linear infinite;
}
@keyframes ms-spin { to { transform: rotate(360deg); } }
.ms-player-nav {
    position: absolute;
    inset: 0;
    z-index: 12;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2px;
    pointer-events: none;
}
.ms-player-nav a,
.ms-player-nav span {
    pointer-events: auto;
    width: 36px;
    height: 48px;
    border: none;
    border-radius: 6px;
    background: rgba(0, 0, 0, .35);
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}
@media (hover: hover) {
    .ms-video-shell:hover .ms-player-nav a,
    .ms-video-shell:focus-within .ms-player-nav a { opacity: .8; }
}
@media (pointer: coarse) {
    .ms-player-nav a { opacity: .65; }
}
.ms-player-nav .is-disabled {
    opacity: 0 !important;
    pointer-events: none;
    cursor: default;
}
.ms-subtitle-overlay {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 10;
    bottom: clamp(44px, 9%, 64px);
    padding: 0 clamp(8px, 4%, 24px);
    text-align: center;
    pointer-events: none;
}
.ms-subtitle-overlay span {
    display: inline-block;
    max-width: min(92%, 30em);
    color: #fff;
    font-size: clamp(12px, 3.2cqi, 17px);
    font-weight: 600;
    line-height: 1.3;
    text-shadow: 0 1px 4px rgba(0, 0, 0, .95), 0 0 6px rgba(0, 0, 0, .8);
    white-space: pre-line;
}
.ms-player-wrap.subtitle-off .ms-subtitle-overlay { display: none; }
.ms-next-hint {
    position: absolute;
    bottom: 16%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 14;
    background: rgba(0, 0, 0, .72);
    border: 1px solid rgba(255, 255, 255, .12);
    padding: 7px 14px;
    border-radius: 999px;
    font-size: .74rem;
    color: #fff;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
    white-space: nowrap;
}
.ms-next-hint.show { opacity: 1; }
.ms-player-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: #0e0e14;
    border-top: 1px solid rgba(255, 255, 255, .06);
}
.ms-player-bar .spacer { flex: 1; }
.ms-ctrl-group {
    display: flex;
    align-items: center;
    gap: 5px;
    background: #1a1a22;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 3px 8px;
    color-scheme: dark;
}
.ms-ctrl-group label {
    font-size: .7rem;
    color: #9ca3af;
    font-weight: 700;
}
.ms-ctrl-picker {
    position: relative;
    padding-right: 18px;
    min-height: 28px;
}
.ms-ctrl-value {
    display: inline-block;
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff;
    font-size: .78rem;
    font-weight: 800;
    line-height: 1.3;
    letter-spacing: .02em;
    text-transform: uppercase;
    min-width: 28px;
    pointer-events: none;
    user-select: none;
}
.ms-ctrl-picker select {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    font-size: 16px; /* avoid iOS zoom */
    appearance: none;
    -webkit-appearance: none;
    border: none;
    background: transparent;
    color: #fff;
}
.ms-ctrl-picker::after {
    content: "";
    position: absolute;
    right: 6px;
    top: 50%;
    width: 8px;
    height: 8px;
    margin-top: -5px;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(45deg);
    pointer-events: none;
}
.ms-ctrl-group select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: #1a1a22;
    border: none;
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff;
    font-size: .78rem;
    font-weight: 700;
    cursor: pointer;
    padding: 4px 2px;
    outline: none;
}
.ms-ctrl-group select option {
    background-color: #1a1a22;
    color: #ffffff;
}
.ms-auto-btn {
    background: #1a1a22;
    border: 1px solid #333;
    color: #9ca3af;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: .68rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}
.ms-auto-btn.is-active {
    color: #c4b5fd;
    border-color: rgba(139, 92, 246, .55);
    background: rgba(139, 92, 246, .14);
}
.ms-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid #333;
    background: #1a1a22;
    color: #fff;
    cursor: pointer;
    font-size: .85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.ms-ep-nav {
    display: flex;
    gap: 10px;
    max-width: 420px;
    margin: 0 auto 16px;
}
.ms-ep-nav a.ms-btn {
    flex: 1;
    background: #222 !important;
    border: 1px solid #555 !important;
    color: #fff !important;
}
.ms-ep-nav a.ms-btn-primary {
    background: #f2eb16 !important;
    border-color: #f2eb16 !important;
    color: #111 !important;
}
.ms-ep-nav a.ms-btn.is-disabled {
    opacity: .45;
    pointer-events: none;
}
.ms-empty {
    text-align: center;
    color: #bbb;
    padding: 40px 16px;
    border: 1px dashed #444;
    border-radius: 12px;
}

@media (max-width: 720px) {
    body.ms-mode .header-top-section {
        height: auto;
        flex-wrap: wrap;
        justify-content: center;
    }
    body.ms-mode .header-top-section > div:nth-child(2) {
        display: none;
    }
    .ms-detail {
        grid-template-columns: 1fr;
        text-align: center;
    }
    .ms-detail-poster {
        max-width: 200px;
        margin: 0 auto;
    }
    .ms-chips,
    .ms-actions {
        justify-content: center;
    }
    .ms-detail-desc {
        text-align: left;
    }
    .ms-card {
        flex-basis: 148px;
    }
    .ms-player-wrap {
        max-width: none;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
    }
}
