/* ═══════════════════════════════════════════════════════════════════════
   Y2K MEDIA VAULT — Main Stylesheet
   Inspired by early-2000s media portals, DVD menus, silver electronics.
   System font stack. No remote fonts, no blur filters, no heavy effects.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Reset & Base ────────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, "Noto Sans", sans-serif,
                 "Apple Color Emoji", "Segoe UI Emoji";
    background: #0a0e1a;
    color: #c8d0e0;
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    color: #7ecce6;
    text-decoration: none;
}
a:hover { color: #a0e8ff; }

img { max-width: 100%; height: auto; display: block; }

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* ── Y2K Color Tokens ────────────────────────────────────────────────── */
/* Using fallback values before custom properties for old browser compat */

/* ── TV-Safe Area ────────────────────────────────────────────────────── */
.tv-safe-area {
    max-width: 1600px;
    margin: 0 auto;
    padding-left: 48px;
    padding-left: var(--tv-margin, 48px);
    padding-right: 48px;
    padding-right: var(--tv-margin, 48px);
}



/* ── Y2K Panel ───────────────────────────────────────────────────────── */
.y2k-panel {
    background: linear-gradient(180deg, #1a2038 0%, #141928 100%);
    border: 1px solid #2a3555;
    border-top-color: #3d4f7a;
    border-left-color: #3d4f7a;
    border-radius: 4px;
    padding: 24px;
}

/* ── Navigation ──────────────────────────────────────────────────────── */
.y2k-nav {
    background: linear-gradient(180deg, #1c2440 0%, #131830 100%);
    border-bottom: 2px solid #2a3555;
    border-bottom-color: #3d4f7a;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-inner {
    max-width: 1600px;
    margin: 0 auto;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    padding: 0 48px;
    height: 64px;
}

.nav-logo {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    color: #7ecce6;
    font-weight: 700;
    font-size: 20px;
    margin-right: 32px;
    -ms-flex-negative: 0;
    flex-shrink: 0;
}

.logo-icon {
    display: inline-block;
    width: 28px;
    height: 28px;
    line-height: 28px;
    text-align: center;
    background: linear-gradient(135deg, #7ecce6, #5b8fbf);
    color: #0a0e1a;
    border-radius: 4px;
    margin-right: 10px;
    font-size: 14px;
}

.logo-text {
    white-space: nowrap;
}

.nav-links {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    gap: 4px;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
}

.nav-link {
    color: #8899bb;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 18px;
    white-space: nowrap;
    transition: color 0.1s, background 0.1s;
}

.nav-link:hover {
    color: #c8d0e0;
    background: rgba(126, 204, 230, 0.08);
}

.nav-link:focus {
    outline: 3px solid #7ecce6;
    outline-offset: 2px;
    color: #fff;
    background: rgba(126, 204, 230, 0.12);
}

/* ── Main Content ────────────────────────────────────────────────────── */
.y2k-main {
    min-height: calc(100vh - 128px);
    padding: 32px 0;
}

/* ── Footer ──────────────────────────────────────────────────────────── */
.y2k-footer {
    border-top: 1px solid #1e2744;
    padding: 16px 0;
    text-align: center;
}

.footer-text {
    font-size: 13px;
    color: #4a5680;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ── Flash Messages ──────────────────────────────────────────────────── */
.flash-messages {
    margin-bottom: 24px;
}

.flash {
    padding: 14px 20px;
    border-radius: 4px;
    margin-bottom: 8px;
    font-size: 16px;
    border: 1px solid;
}

.flash-success {
    background: rgba(100, 220, 160, 0.1);
    border-color: #3a8860;
    color: #8eddb8;
}

.flash-error, .flash-danger {
    background: rgba(220, 100, 100, 0.1);
    border-color: #884444;
    color: #e8a0a0;
}

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 12px 28px;
    border: 2px solid transparent;
    border-radius: 4px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    white-space: nowrap;
    transition: background 0.1s, border-color 0.1s, color 0.1s;
    line-height: 1.4;
    -webkit-user-select: none;
    user-select: none;
}

.btn:focus {
    outline: 3px solid #7ecce6;
    outline-offset: 2px;
}

.btn-primary {
    background: linear-gradient(180deg, #3d8fb5 0%, #2b6f90 100%);
    color: #fff;
    border-color: #4da8d0;
    border-top-color: #6ec4e8;
    border-left-color: #6ec4e8;
}

.btn-primary:hover {
    background: linear-gradient(180deg, #4da8d0 0%, #3d8fb5 100%);
}

.btn-secondary {
    background: linear-gradient(180deg, #2a3050 0%, #1e2440 100%);
    color: #8899bb;
    border-color: #3a4a70;
    border-top-color: #4a5a88;
    border-left-color: #4a5a88;
}

.btn-secondary:hover {
    color: #c8d0e0;
    background: linear-gradient(180deg, #303860 0%, #252e4e 100%);
}

.btn-danger {
    background: linear-gradient(180deg, #8b3040 0%, #6a2030 100%);
    color: #f0c0c0;
    border-color: #a04050;
    border-top-color: #c06070;
    border-left-color: #c06070;
}

.btn-danger:hover {
    background: linear-gradient(180deg, #a04050 0%, #8b3040 100%);
}

.btn-large {
    padding: 16px 40px;
    font-size: 22px;
    width: 100%;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

.btn[disabled] {
    opacity: 0.5;
    cursor: default;
}

/* ── Form Elements ───────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 15px;
    color: #6880aa;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    background: #0d1120;
    border: 2px solid #2a3555;
    border-top-color: #1a2038;
    border-left-color: #1a2038;
    border-radius: 4px;
    color: #c8d0e0;
    font-size: 18px;
}

.form-input:focus {
    outline: none;
    border-color: #7ecce6;
    box-shadow: 0 0 0 2px rgba(126, 204, 230, 0.2);
}

.form-input-lg {
    font-size: 22px;
    padding: 16px 20px;
}

.form-input-sm {
    font-size: 14px;
    padding: 8px 12px;
}

.form-select {
    padding: 10px 14px;
    background: #0d1120;
    border: 2px solid #2a3555;
    border-radius: 4px;
    color: #c8d0e0;
    font-size: 16px;
    cursor: pointer;
}

.form-select:focus {
    outline: none;
    border-color: #7ecce6;
}

/* ── Login Page ──────────────────────────────────────────────────────── */
.login-container {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    min-height: 80vh;
    padding: 32px;
}

.login-panel {
    width: 100%;
    max-width: 440px;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.logo-icon-large {
    display: inline-block;
    width: 56px;
    height: 56px;
    line-height: 56px;
    text-align: center;
    background: linear-gradient(135deg, #7ecce6, #5b8fbf);
    color: #0a0e1a;
    border-radius: 8px;
    font-size: 24px;
    margin-bottom: 16px;
}

.login-title {
    font-size: 28px;
    color: #d0daf0;
    font-weight: 700;
}

.login-subtitle {
    font-size: 14px;
    color: #5a6a8e;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 4px;
}

.login-error {
    background: rgba(220, 80, 80, 0.1);
    border: 1px solid #6a3030;
    border-radius: 4px;
    padding: 12px 16px;
    margin-bottom: 20px;
    color: #e8a0a0;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 10px;
}

.error-indicator {
    display: inline-block;
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    background: #6a3030;
    color: #e8a0a0;
    border-radius: 50%;
    font-weight: bold;
    font-size: 14px;
    -ms-flex-negative: 0;
    flex-shrink: 0;
}

.login-status-bar {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #1e2744;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 8px;
}

.status-led {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #4ccc80;
    border-radius: 50%;
    box-shadow: 0 0 4px rgba(76, 204, 128, 0.4);
}

.status-text {
    font-size: 12px;
    color: #4a5680;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ── Page Headers ────────────────────────────────────────────────────── */
.page-header {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: baseline;
    -ms-flex-align: baseline;
    align-items: baseline;
    gap: 16px;
    margin-bottom: 24px;
}

.page-title {
    font-size: 32px;
    color: #d0daf0;
    font-weight: 700;
}

.page-count {
    font-size: 16px;
    color: #5a6a8e;
}

/* ── Media Sections (Home rows) ──────────────────────────────────────── */
.media-section {
    margin-bottom: 40px;
}

.section-header {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-title {
    font-size: 22px;
    color: #b0bce0;
    font-weight: 600;
}

.section-link {
    font-size: 15px;
    color: #5a7aa0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.section-link:focus {
    outline: 3px solid #7ecce6;
    outline-offset: 2px;
}

.subsection-title {
    font-size: 20px;
    color: #8899bb;
    margin-bottom: 16px;
}

/* ── Media Row (horizontal scroll) ───────────────────────────────────── */
.media-row {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    gap: 16px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.media-row::-webkit-scrollbar {
    height: 4px;
}

.media-row::-webkit-scrollbar-track {
    background: #0d1120;
}

.media-row::-webkit-scrollbar-thumb {
    background: #2a3555;
    border-radius: 2px;
}

/* ── Media Grid ──────────────────────────────────────────────────────── */
.media-grid {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    gap: 20px;
}

/* ── Media Card ──────────────────────────────────────────────────────── */
.media-card {
    display: block;
    width: 180px;
    -ms-flex-negative: 0;
    flex-shrink: 0;
    background: #111628;
    border: 2px solid #1e2744;
    border-radius: 4px;
    overflow: hidden;
    color: #c8d0e0;
    position: relative;
    transition: border-color 0.1s;
}

.media-card:hover {
    border-color: #3a5080;
}

.media-card:focus {
    outline: none;
    border-color: #7ecce6;
    box-shadow: 0 0 0 3px rgba(126, 204, 230, 0.25);
    -webkit-transform: scale(1.03);
    transform: scale(1.03);
}

/* ── Card Poster ─────────────────────────────────────────────────────── */
.card-poster {
    position: relative;
    width: 100%;
    /* 3:4 aspect ratio via padding trick for compat */
    padding-top: 150%;
    background: #0d1120;
    overflow: hidden;
}

.poster-img {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ── Poster Placeholder ──────────────────────────────────────────────── */
.poster-placeholder {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    padding: 16px;
    background: linear-gradient(150deg, #141e38 0%, #0d1428 50%, #161e35 100%);
    text-align: center;
}

.placeholder-pattern {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 8px,
        rgba(126, 204, 230, 0.03) 8px,
        rgba(126, 204, 230, 0.03) 9px
    );
    pointer-events: none;
}

.placeholder-title {
    position: relative;
    font-size: 14px;
    font-weight: 600;
    color: #6880aa;
    word-break: break-word;
    max-height: 4em;
    overflow: hidden;
}

.placeholder-format {
    position: relative;
    font-size: 11px;
    text-transform: uppercase;
    color: #3d5070;
    letter-spacing: 2px;
    margin-top: 8px;
    padding: 2px 8px;
    border: 1px solid #2a3555;
    border-radius: 2px;
}

/* ── Card Badge ──────────────────────────────────────────────────────── */
.card-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 2px 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 2px;
    z-index: 2;
}

.badge-watched {
    background: rgba(76, 204, 128, 0.15);
    border: 1px solid #3a8860;
    color: #8eddb8;
}

/* ── Card Info ────────────────────────────────────────────────────────── */
.card-info {
    padding: 10px 12px;
}

.card-title {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #b0bce0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-meta {
    display: block;
    font-size: 12px;
    color: #5a6a8e;
    margin-top: 2px;
}

/* ── Card Progress Bar ───────────────────────────────────────────────── */
.card-progress {
    height: 3px;
    background: #1a2038;
}

.card-progress-bar {
    height: 100%;
    background: #7ecce6;
    min-width: 2px;
}

/* ── Series Page ─────────────────────────────────────────────────────── */
.series-header {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    gap: 32px;
    margin-bottom: 40px;
}

.series-poster-wrap {
    width: 240px;
    -ms-flex-negative: 0;
    flex-shrink: 0;
}

.series-poster-img {
    width: 100%;
    height: auto;
    border-radius: 4px;
    border: 2px solid #2a3555;
}

.poster-placeholder-large {
    position: relative;
    width: 100%;
    padding-top: 150%;
    border-radius: 4px;
    border: 2px solid #2a3555;
}

.series-info {
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
}

.series-title {
    font-size: 36px;
    color: #d0daf0;
    margin-bottom: 12px;
}

.series-meta {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
}

.meta-badge {
    padding: 4px 12px;
    background: #1a2038;
    border: 1px solid #2a3555;
    border-radius: 4px;
    font-size: 14px;
    color: #6880aa;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.series-actions {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    gap: 12px;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
}

/* ── Season & Episode List ───────────────────────────────────────────── */
.season-section {
    margin-bottom: 32px;
}

.season-title {
    font-size: 20px;
    color: #7ecce6;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #1e2744;
}

.episode-list {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    gap: 2px;
}

.episode-item {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    background: #111628;
    border: 2px solid transparent;
    border-radius: 4px;
    color: #c8d0e0;
    position: relative;
    transition: border-color 0.1s, background 0.1s;
}

.episode-item:hover {
    background: #161d35;
    border-color: #2a3a60;
}

.episode-item:focus {
    outline: none;
    border-color: #7ecce6;
    background: #1a2240;
    box-shadow: 0 0 0 2px rgba(126, 204, 230, 0.2);
}

.episode-number {
    font-size: 16px;
    font-weight: 700;
    color: #5a7aa0;
    width: 48px;
    text-align: center;
    -ms-flex-negative: 0;
    flex-shrink: 0;
}

.episode-info {
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
    min-width: 0;
}

.episode-title {
    display: block;
    font-size: 18px;
    color: #b0bce0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.episode-meta {
    display: block;
    font-size: 13px;
    color: #4a5680;
    margin-top: 2px;
}

.episode-status {
    -ms-flex-negative: 0;
    flex-shrink: 0;
}

.status-badge {
    padding: 3px 10px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 2px;
}

.status-watched {
    background: rgba(76, 204, 128, 0.1);
    color: #6cc090;
    border: 1px solid #3a6a4a;
}

.status-progress {
    background: rgba(126, 204, 230, 0.1);
    color: #7ecce6;
    border: 1px solid #2a5a70;
}

.episode-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #1a2038;
}

.episode-progress-bar {
    height: 100%;
    background: #7ecce6;
}

/* ── Player Page ─────────────────────────────────────────────────────── */
.player-page {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #000;
    z-index: 200;
}

.video-container {
    position: relative;
    width: 100%;
    height: 100%;
}

#main-video {
    width: 100%;
    height: 100%;
    background: #000;
}

/* Player overlay */
.player-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
    pointer-events: none;
    z-index: 10;
}

.player-top-bar {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    background: linear-gradient(180deg, rgba(0,0,0,0.7) 0%, transparent 100%);
    pointer-events: auto;
}

.player-back-btn {
    color: #c8d0e0;
    font-size: 16px;
    padding: 8px 16px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    -ms-flex-negative: 0;
    flex-shrink: 0;
}

.player-back-btn:focus {
    outline: 3px solid #7ecce6;
    outline-offset: 2px;
}

.player-title-info {
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
    min-width: 0;
}

.player-title {
    display: block;
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-series {
    display: block;
    color: #8899bb;
    font-size: 14px;
}

.player-format-badge {
    padding: 4px 10px;
    background: rgba(255,255,255,0.1);
    color: #8899bb;
    border-radius: 4px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    -ms-flex-negative: 0;
    flex-shrink: 0;
}

.player-bottom-bar {
    padding: 16px 24px;
    background: linear-gradient(0deg, rgba(0,0,0,0.7) 0%, transparent 100%);
    pointer-events: auto;
}

.player-nav-buttons {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    gap: 12px;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
}

/* Next episode prompt */
.next-episode-prompt {
    position: absolute;
    bottom: 80px;
    right: 24px;
    z-index: 20;
}

.next-prompt-inner {
    max-width: 320px;
}

.next-prompt-label {
    display: block;
    font-size: 12px;
    color: #5a6a8e;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.next-prompt-title {
    display: block;
    font-size: 18px;
    color: #d0daf0;
    margin-bottom: 12px;
}

.next-prompt-actions {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    gap: 8px;
}

/* Player error */
.player-error {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    z-index: 30;
}

.error-inner {
    max-width: 500px;
    text-align: center;
}

.error-icon {
    font-size: 48px;
    color: #cc8844;
    margin-bottom: 16px;
}

.error-message {
    font-size: 18px;
    color: #c8d0e0;
    margin-bottom: 24px;
}

.error-actions {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    gap: 8px;
}

/* ── Search Page ─────────────────────────────────────────────────────── */
.search-form {
    margin-bottom: 24px;
}

.search-input-wrap {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    gap: 12px;
}

.search-input-wrap .form-input {
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
}

.search-result-count {
    color: #5a6a8e;
    margin-bottom: 20px;
    font-size: 16px;
}

/* ── Filters Bar ─────────────────────────────────────────────────────── */
.filters-bar {
    margin-bottom: 24px;
    padding: 16px 20px;
    background: #111628;
    border: 1px solid #1e2744;
    border-radius: 4px;
}

.filters-form {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: end;
    -ms-flex-align: end;
    align-items: flex-end;
    gap: 16px;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
}

.filter-group {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    gap: 4px;
}

.filter-label {
    font-size: 11px;
    color: #4a5680;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.filter-search {
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
    min-width: 200px;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
    -ms-flex-direction: row;
    flex-direction: row;
    -webkit-box-align: end;
    -ms-flex-align: end;
    align-items: flex-end;
    gap: 8px;
}

.filter-search .filter-label {
    display: none;
}

.filter-search .form-input {
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
}

/* ── Settings Page ───────────────────────────────────────────────────── */
.settings-page {
    max-width: 700px;
}

.settings-section {
    margin-bottom: 24px;
}

.settings-section-title {
    font-size: 20px;
    color: #7ecce6;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #1e2744;
}

.settings-grid {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}

.stat-item {
    -webkit-box-flex: 1;
    -ms-flex: 1 1 calc(50% - 8px);
    flex: 1 1 calc(50% - 8px);
    min-width: 160px;
}

.stat-label {
    display: block;
    font-size: 12px;
    color: #4a5680;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    display: block;
    font-size: 18px;
    color: #b0bce0;
    margin-top: 2px;
}

.settings-form {
    max-width: 400px;
}

.settings-action {
    margin-top: 16px;
}

.settings-text {
    color: #6880aa;
    margin-bottom: 12px;
    font-size: 16px;
}

/* Storage bar */
.storage-bar-wrap {
    margin-bottom: 16px;
}

.storage-label {
    font-size: 14px;
    color: #6880aa;
    margin-bottom: 6px;
}

.storage-bar {
    height: 8px;
    background: #0d1120;
    border: 1px solid #1e2744;
    border-radius: 4px;
    overflow: hidden;
}

.storage-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #3d8fb5, #7ecce6);
    border-radius: 3px;
}

.storage-free {
    font-size: 13px;
    color: #4a5680;
    margin-top: 4px;
}

/* ── Error Page ──────────────────────────────────────────────────────── */
.error-page {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    min-height: 60vh;
}

.error-panel {
    text-align: center;
    max-width: 480px;
}

.error-code-display {
    margin-bottom: 16px;
}

.error-code {
    font-size: 72px;
    font-weight: 700;
    color: #2a4060;
    letter-spacing: 4px;
    /* Segmented display effect */
    text-shadow: 0 0 8px rgba(126, 204, 230, 0.15);
}

.error-title {
    font-size: 24px;
    color: #b0bce0;
    margin-bottom: 8px;
}

.error-description {
    color: #6880aa;
    margin-bottom: 24px;
    font-size: 16px;
}

.error-nav {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    gap: 12px;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
}

/* ── Empty State ─────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 80px 24px;
}

.empty-icon {
    font-size: 48px;
    color: #2a3555;
    margin-bottom: 16px;
}

.empty-state h2 {
    font-size: 24px;
    color: #6880aa;
    margin-bottom: 8px;
}

.empty-state p {
    color: #4a5680;
    margin-bottom: 24px;
}

/* ── Pagination ──────────────────────────────────────────────────────── */
.pagination {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    gap: 16px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid #1e2744;
}

.page-info {
    font-size: 16px;
    color: #5a6a8e;
}

/* ── Responsive ──────────────────────────────────────────────────────── */

/* Small mobile */
@media (max-width: 480px) {
    .tv-safe-area {
        padding-left: 16px;
        padding-right: 16px;
    }

    .nav-inner {
        padding: 0 16px;
    }

    .nav-links {
        display: none; /* Use home page navigation on mobile */
    }

    .media-card {
        width: 140px;
    }

    .series-header {
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        -ms-flex-direction: column;
        flex-direction: column;
    }

    .series-poster-wrap {
        width: 160px;
    }

    .page-title {
        font-size: 24px;
    }

    .series-title {
        font-size: 26px;
    }
}

/* Tablet */
@media (min-width: 481px) and (max-width: 960px) {
    .tv-safe-area {
        padding-left: 24px;
        padding-right: 24px;
    }

    .media-card {
        width: 160px;
    }
}

/* 720p TV */
@media (min-width: 961px) and (max-width: 1366px) {
    .media-card {
        width: 170px;
    }

    .nav-link {
        padding: 8px 12px;
        font-size: 16px;
    }
}

/* 1080p TV / Desktop */
@media (min-width: 1367px) {
    .media-card {
        width: 190px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        transition-duration: 0.01ms !important;
    }
    .media-card:focus {
        -webkit-transform: none;
        transform: none;
    }
}

/* ── Utility ─────────────────────────────────────────────────────────── */
/* Replaces inline style="display:none" so the Content-Security-Policy can
   forbid inline styles entirely. */
.is-hidden {
    display: none !important;
}

/* Progress bar widths are applied by app.js from data-progress, again to
   keep style attributes out of the markup. */
.card-progress-bar,
.episode-progress-bar,
.storage-bar-fill {
    width: 0;
}

/* ── Player Mode ─────────────────────────────────────────────────────── */
/* Was an inline <style> block in player.html. */
body.player-mode .y2k-nav,
body.player-mode .y2k-footer {
    display: none;
}

body.player-mode .y2k-main {
    padding: 0;
}

body.player-mode .tv-safe-area {
    margin: 0;
    padding: 0;
    max-width: none;
}

.player-nav-buttons-top {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    gap: 8px;
    -ms-flex-negative: 0;
    flex-shrink: 0;
}

.player-notice {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 12px 24px;
    background: rgba(60, 30, 10, 0.92);
    border-top: 1px solid #cc8844;
    color: #f0c89a;
    font-size: 14px;
    text-align: center;
    z-index: 25;
}

/* ── Transcoded Playback Controls ────────────────────────────────────── */
/* A transcoded stream is a live pipe with no index, so the native scrubber
   cannot seek in it. These controls seek by restarting the stream at a new
   offset. */
.transcode-controls {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 16px;
    padding: 16px 24px 24px;
    background: linear-gradient(0deg, rgba(0,0,0,0.85) 0%, transparent 100%);
    pointer-events: auto;
}

.transcode-time {
    color: #c8d0e0;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    min-width: 56px;
    -ms-flex-negative: 0;
    flex-shrink: 0;
}

.transcode-seek {
    position: relative;
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
    height: 6px;
    background: #1a2038;
    border: 1px solid #2a3350;
    border-radius: 3px;
    cursor: pointer;
}

.transcode-seek:focus {
    outline: 3px solid #7ecce6;
    outline-offset: 4px;
}

.transcode-seek-fill {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 0;
    background: #7ecce6;
    border-radius: 2px;
}

.transcode-seek-knob {
    position: absolute;
    top: 50%;
    left: 0;
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    background: #7ecce6;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(126, 204, 230, 0.8);
}

.transcode-badge {
    padding: 4px 10px;
    background: rgba(126, 204, 230, 0.15);
    border: 1px solid #7ecce6;
    color: #7ecce6;
    border-radius: 4px;
    font-size: 11px;
    letter-spacing: 1px;
    -ms-flex-negative: 0;
    flex-shrink: 0;
}

/* ── Buffering Spinner ───────────────────────────────────────────────── */
.player-spinner {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    pointer-events: none;
    z-index: 15;
}

.spinner-box {
    padding: 12px 24px;
    background: rgba(10, 14, 26, 0.9);
    border: 1px solid #2a3350;
    border-radius: 4px;
}

.spinner-text {
    color: #7ecce6;
    font-size: 15px;
    letter-spacing: 1px;
}
