:root {
    --bg: #0d0d0d;
    --surface: #181818;
    --surface2: #222222;
    --border: rgba(255,255,255,0.07);
    --accent: #e50914;
    --accent-hover: #c1070f;
    --text: #f0f0f0;
    --text-secondary: #888;
    --text-dim: rgba(255,255,255,0.35);
    --radius: 10px;
    --radius-sm: 6px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 2rem 3rem;
}

/* ── Header ── */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #0a0a0a 0%, #12121e 100%);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 32px rgba(0,0,0,0.6);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0.75rem 2rem;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    text-decoration: none;
}

.header-logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #e50914, #8b0000);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 16px rgba(229,9,20,0.4);
    flex-shrink: 0;
}

.header-logo-icon svg { width: 20px; height: 20px; fill: #fff; }

.header-logo-info { display: flex; flex-direction: column; gap: 1px; }

.header-logo-text {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    color: #fff;
    line-height: 1.2;
}

.header-logo-text span { color: var(--accent); }

.header-logo-username {
    font-size: 0.72rem;
    color: var(--text-dim);
    font-weight: 400;
    line-height: 1;
}

.user-info { display: flex; align-items: center; gap: 0.65rem; }
.user-name { display: none; }

.history-btn,
.logout-btn {
    padding: 0.4rem 0.9rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    transition: all 0.18s;
    border: none;
    outline: none;
}

.history-btn { background: rgba(255,255,255,0.08); color: #c0c0c0; }
.history-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }
.logout-btn { background: rgba(229,9,20,0.15); color: var(--accent); }
.logout-btn:hover { background: var(--accent); color: #fff; }

/* ── Request Bar ── */
.request-bar-wrap {
    margin: 1.5rem 0 2rem;
}

.request-bar-label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.5rem;
}

.request-bar-label-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f59e0b;
    box-shadow: 0 0 6px #f59e0b;
    flex-shrink: 0;
}

.request-bar-label span {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #f59e0b;
}

.request-bar {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    background: rgba(245,158,11,0.07);
    border: 1px solid rgba(245,158,11,0.3);
    border-radius: var(--radius);
    padding: 0.65rem 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.request-bar:focus-within {
    border-color: rgba(245,158,11,0.6);
    box-shadow: 0 0 0 3px rgba(245,158,11,0.08);
}

.request-bar input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
}

.request-bar input::placeholder {
    color: rgba(245,158,11,0.4);
    font-weight: 400;
}

.request-bar-btn {
    padding: 0.4rem 1rem;
    background: #f59e0b;
    color: #0d0d0d;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.18s;
    flex-shrink: 0;
}

.request-bar-btn:hover { background: #d97706; }
.request-bar-btn:disabled { background: #333; color: #666; cursor: default; }

.request-bar-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* ── Modal ── */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    inset: 0;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(6px);
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.75rem;
    max-width: 820px;
    width: 92%;
    max-height: 82vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 { font-size: 1.1rem; font-weight: 600; color: var(--text); }

.close-btn {
    background: rgba(255,255,255,0.07);
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s;
}

.close-btn:hover { background: rgba(255,255,255,0.14); color: var(--text); }

.history-list { display: flex; flex-direction: column; gap: 0.75rem; }

.history-item {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.history-item:hover { background: #282828; border-color: rgba(255,255,255,0.13); }

.history-poster {
    width: 52px;
    height: 78px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    background: #333;
    flex-shrink: 0;
}

.history-details { flex: 1; }
.history-show-title { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.2rem; }
.history-episode { color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 0.2rem; }
.history-time { color: var(--text-secondary); font-size: 0.78rem; }

.history-progress { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.5rem; }

.history-progress-bar {
    flex: 1;
    height: 3px;
    background: #333;
    border-radius: 2px;
    overflow: hidden;
}

.history-progress-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s;
}

.history-progress-text { color: var(--text-secondary); font-size: 0.75rem; min-width: 40px; }

.no-history { text-align: center; padding: 3rem; color: var(--text-secondary); }

/* ── Typography ── */
h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1rem;
    letter-spacing: -0.2px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.section-title::after {
    content: '';
    display: block;
    height: 2px;
    width: 28px;
    background: var(--accent);
    border-radius: 2px;
}

/* ── Cards Grid ── */
.shows-grid {
    display: flex;
    flex-wrap: nowrap;
    gap: 1rem;
    padding: 0.25rem 0 1.25rem;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: #333 transparent;
}

.shows-grid::-webkit-scrollbar { height: 4px; }
.shows-grid::-webkit-scrollbar-track { background: transparent; }
.shows-grid::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }

.show-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s;
    cursor: pointer;
    flex: 0 0 160px;
    position: relative;
}

.show-card:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: 0 16px 40px rgba(0,0,0,0.6);
    border-color: rgba(229,9,20,0.3);
}

.show-image {
    width: 100%;
    height: 230px;
    object-fit: cover;
    background: #1e1e1e;
    display: block;
}

.show-info { padding: 0.65rem 0.7rem 0.75rem; }

.show-title {
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: var(--text);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.episode-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.55rem;
}

.show-button {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.78rem;
    transition: background 0.18s;
    border: none;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
}

.show-button:hover { background: var(--accent-hover); }

.show-buttons { display: flex; gap: 0.4rem; margin-top: 0.4rem; flex-wrap: wrap; }

.continue-episode-btn {
    padding: 0.35rem 0.75rem;
    background: rgba(229,9,20,0.12);
    color: var(--accent);
    border: 1px solid rgba(229,9,20,0.25);
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    transition: all 0.18s;
}

.continue-episode-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.show-continue-info { margin: 0.4rem 0; }

.continue-label { font-size: 0.72rem; color: var(--accent); font-weight: 600; }

.show-progress-bar {
    height: 2px;
    background: #333;
    border-radius: 2px;
    overflow: hidden;
    margin-top: 0.2rem;
}

.show-progress-fill { height: 100%; background: var(--accent); transition: width 0.3s; }

/* ── Episode List ── */
.episode-list { display: none; margin-top: 2rem; }
.episode-list.active { display: block; }

.episode-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0.75rem; }

.episode-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.18s, background 0.18s;
}

.episode-card:hover { background: var(--surface2); border-color: rgba(255,255,255,0.12); }
.episode-title { margin-right: 1rem; font-size: 0.9rem; }
.episode-actions { display: flex; gap: 0.4rem; align-items: center; flex-shrink: 0; }

/* Secondary to the accent-filled Watch button: downloading is the rarer
   action, and on this uplink it should not be the one that draws the eye. */
.download-button {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim, #a0a0ab);
    padding: 0.35rem 0.6rem;
    line-height: 1;
}
.download-button:hover {
    background: var(--surface2);
    border-color: rgba(255,255,255,0.22);
    color: #fff;
}

.back-button {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
    transition: background 0.18s;
}

.back-button:hover { background: var(--surface2); }

/* ── Search ── */
.search-container {
    position: relative;
    max-width: 560px;
    margin: 0 auto 1.75rem;
}

#search-input {
    width: 100%;
    padding: 0.75rem 2.75rem 0.75rem 1rem;
    font-size: 0.92rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
    font-family: 'Inter', sans-serif;
}

#search-input:focus { border-color: rgba(229,9,20,0.4); }
#search-input::placeholder { color: var(--text-dim); }

.search-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    pointer-events: none;
    opacity: 0.4;
}

.no-results { text-align: center; padding: 3rem; color: var(--text-secondary); font-size: 1rem; }

/* ── Continue Watching ── */
.continue-watching-section { margin-bottom: 2.5rem; display: none; }
.continue-watching-section.has-items { display: block; }

.continue-grid {
    display: flex;
    gap: 0.85rem;
    overflow-x: auto;
    padding-bottom: 0.75rem;
    scrollbar-width: thin;
    scrollbar-color: #333 transparent;
}

.continue-grid::-webkit-scrollbar { height: 4px; }
.continue-grid::-webkit-scrollbar-track { background: transparent; }
.continue-grid::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }

.continue-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.7rem;
    display: flex;
    gap: 0.7rem;
    align-items: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.2s;
    flex: 0 0 210px;
    position: relative;
}

.continue-card:hover {
    background: var(--surface2);
    border-color: rgba(229,9,20,0.25);
    transform: translateY(-2px);
}

.continue-poster {
    width: 42px;
    height: 62px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    background: #2a2a2a;
    flex-shrink: 0;
}

.continue-info { flex: 1; min-width: 0; }

.continue-show-title {
    font-weight: 600;
    font-size: 0.8rem;
    margin-bottom: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.continue-episode {
    color: var(--text-secondary);
    font-size: 0.72rem;
    margin-bottom: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.continue-time { color: var(--accent); font-size: 0.68rem; margin-bottom: 0.35rem; }

.progress-bar { height: 2px; background: #333; border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); transition: width 0.3s; }

.continue-play-btn {
    padding: 0.3rem 0.5rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.72rem;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.18s;
}

.continue-play-btn:hover { background: var(--accent-hover); }

.continue-dismiss-btn {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    width: 20px;
    height: 20px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    line-height: 1;
}

.continue-dismiss-btn:hover {
    background: rgba(229,9,20,0.6);
    color: #fff;
}

/* ── Category Tabs ── */
.category-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.75rem;
    border-bottom: 1px solid var(--border);
}

.category-tab {
    padding: 0.65rem 1.4rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    border-bottom: 2px solid transparent;
    transition: color 0.18s, border-color 0.18s;
    margin-bottom: -1px;
    letter-spacing: 0.1px;
}

.category-tab:hover { color: var(--text); }

.category-tab.active {
    color: var(--text);
    border-bottom-color: var(--accent);
}

/* ── Season Select ── */
.season-select-container {
    margin-bottom: 2rem;
}

.season-select-container select,
#season-select {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    border: 1px solid #444;
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
    min-width: 200px;
}

.season-select-container select:focus,
#season-select:focus { border-color: rgba(229,9,20,0.4); }

#season-select option {
    background-color: var(--surface2);
    color: var(--text);
}

/* ── Section headings ── */
section h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

section h2::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
    margin-left: 0.5rem;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .container { padding: 0 1rem 2rem; }
    header { padding: 0.65rem 1rem; }
    .show-card { flex: 0 0 130px; }
    .show-image { height: 185px; }
    .episode-grid { grid-template-columns: 1fr; }
    .continue-card { flex: 0 0 185px; }
}
