/* ========================================
   מילנר TV — Premium IPTV Player
   ======================================== */

:root {
    /* Backgrounds — dark red/black base */
    --bg-base: #0e0608;
    --bg-surface: #1a0a0e;
    --bg-elevated: #2a1018;
    --bg-card: rgba(255, 255, 255, 0.05);
    --bg-card-hover: rgba(255, 255, 255, 0.09);
    --bg-input: rgba(255, 255, 255, 0.06);
    --bg-input-focus: rgba(255, 255, 255, 0.10);

    /* Brand — Hapoel Tel Aviv red */
    --primary: #dc2626;
    --primary-light: #f87171;
    --primary-dark: #991b1b;
    --accent: #fb7185;
    --gradient-brand: linear-gradient(135deg, #b91c1c 0%, #dc2626 50%, #ef4444 100%);

    /* Semantic */
    --success: #22c55e;
    --error: #ef4444;
    --error-subtle: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --gold: #f87171;

    /* Text */
    --text-primary: #f5f0f0;
    --text-secondary: rgba(245, 240, 240, 0.6);
    --text-muted: rgba(245, 240, 240, 0.3);

    /* Borders */
    --border: rgba(255, 255, 255, 0.06);
    --border-light: rgba(255, 255, 255, 0.12);
    --border-focus: rgba(220, 38, 38, 0.5);

    /* Radii */
    --radius-xs: 6px;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --radius-full: 9999px;

    /* Layout */
    --header-height: 56px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);

    /* Motion */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --dur-fast: 150ms;
    --dur-normal: 250ms;
    --dur-slow: 400ms;
}

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

html {
    direction: rtl;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Heebo', -apple-system, 'Segoe UI', sans-serif;
    background: var(--bg-base);
    background-image:
        radial-gradient(ellipse at 20% 0%, rgba(220, 38, 38, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(185, 28, 28, 0.08) 0%, transparent 50%);
    color: var(--text-primary);
    height: 100%;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

/* ===== Icon Base ===== */
.icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon--xs { width: 14px; height: 14px; }
.icon--sm { width: 16px; height: 16px; }
.icon--lg { width: 24px; height: 24px; }
.icon--xl { width: 32px; height: 32px; }
.icon--filled { fill: currentColor; stroke: none; }

/* ===== View System ===== */
.view {
    position: fixed;
    inset: 0;
    display: none;
    flex-direction: column;
    z-index: 1;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
}

.view--active {
    display: flex;
    z-index: 10;
}

#view-modal.view--active {
    z-index: 100;
}

/* ===== VIEW: Modal ===== */
#view-modal {
    background: var(--bg-base);
    background-image:
        radial-gradient(ellipse at 30% 20%, rgba(220, 38, 38, 0.15) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 80%, rgba(153, 27, 27, 0.1) 0%, transparent 60%);
    align-items: center;
    justify-content: center;
}

.modal-scroll {
    width: 100%;
    max-height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 32px 24px;
}

.modal-content {
    max-width: 420px;
    margin: 0 auto;
}

.modal-brand {
    text-align: center;
    margin-bottom: 36px;
}

.modal-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.modal-logo-symbol {
    height: 72px;
    width: auto;
    filter: drop-shadow(0 4px 16px rgba(228, 26, 23, 0.35));
}

.modal-logo-text {
    height: 18px;
    width: auto;
    opacity: 0.9;
}

.modal-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* User Profiles */
.user-profiles {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 8px;
}

.user-card {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    aspect-ratio: 1;
    border-radius: var(--radius-lg);
    cursor: pointer;
    overflow: hidden;
    border: 2px solid transparent;
    transition: all var(--dur-normal) var(--ease-out);
    font-family: inherit;
    background: #000;
}

.user-card:hover {
    border-color: var(--primary);
    transform: scale(1.03);
    box-shadow: 0 8px 30px rgba(220, 38, 38, 0.25);
}

.user-card:active {
    transform: scale(0.96);
    border-color: var(--primary-light);
}

.user-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform var(--dur-normal);
}

.user-card:hover .user-bg {
    transform: scale(1.05);
}

.user-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.2) 50%, transparent 100%);
    pointer-events: none;
}

.user-name {
    position: relative;
    z-index: 1;
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    padding-bottom: 14px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.7);
}

/* 3-dot More Button */
.more-btn {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--dur-normal);
    z-index: 5;
}

.more-btn:active {
    transform: scale(0.9);
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.more-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Advanced Options (hidden by default) */
.advanced-options {
    margin-top: 16px;
    overflow: hidden;
    transition: max-height var(--dur-slow) var(--ease-out), opacity var(--dur-normal);
    max-height: 500px;
    opacity: 1;
}

.advanced-options--hidden {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    pointer-events: none;
}

/* Input Group */
.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 4px;
}

.input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    height: 50px;
    background: var(--bg-input);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    transition: border-color var(--dur-normal), background var(--dur-normal), box-shadow var(--dur-normal);
}

.input-wrapper:focus-within {
    border-color: var(--border-focus);
    background: var(--bg-input-focus);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.input-wrapper .icon {
    color: var(--text-muted);
    transition: color var(--dur-normal);
}

.input-wrapper:focus-within .icon {
    color: var(--primary-light);
}

.input-wrapper input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    outline: none;
    font-family: inherit;
    width: 0;
    min-width: 0;
}

.input-wrapper input::placeholder {
    color: var(--text-muted);
}

.btn-primary {
    background: var(--gradient-brand);
    color: #fff;
    border: none;
    padding: 0 22px;
    height: 50px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    flex-shrink: 0;
    transition: transform var(--dur-fast), opacity var(--dur-fast);
    box-shadow: 0 4px 16px rgba(220, 38, 38, 0.3);
}

.btn-primary:active {
    transform: scale(0.95);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Upload Button */
.btn-upload {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 24px;
    background: var(--bg-input);
    border: 1.5px dashed var(--border-light);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--dur-normal), border-color var(--dur-normal), transform var(--dur-fast);
    color: var(--text-muted);
}

.btn-upload:active {
    transform: scale(0.98);
    background: var(--bg-input-focus);
    border-color: var(--primary);
}

.upload-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.upload-hint {
    font-size: 11px;
    color: var(--text-muted);
}

/* Divider */
.divider {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 20px 0;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* Section Label */
.section-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Recent Playlists */
#recent-playlists {
    margin-top: 28px;
}

.recent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    cursor: pointer;
    transition: background var(--dur-fast), transform var(--dur-fast);
}

.recent-item:active {
    transform: scale(0.98);
    background: var(--bg-card-hover);
}

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

.recent-item-url {
    font-size: 12px;
    color: var(--text-secondary);
    direction: ltr;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-item-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 3px;
}

.recent-item-delete {
    background: rgba(255,255,255,0.06);
    border: none;
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-inline-start: 8px;
    transition: color var(--dur-fast), background var(--dur-fast);
}

.recent-item-delete:active {
    color: var(--error);
    background: var(--error-subtle);
}

/* Loader */
.loader-dots {
    display: flex;
    gap: 6px;
    justify-content: center;
    padding: 8px 0;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    animation: dotBounce 0.5s ease-in-out infinite alternate;
}

.dot:nth-child(2) {
    background: var(--primary-light);
    animation-delay: 0.12s;
}

.dot:nth-child(3) {
    background: var(--accent);
    animation-delay: 0.24s;
}

@keyframes dotBounce {
    from { transform: translateY(0); opacity: 0.4; }
    to { transform: translateY(-8px); opacity: 1; }
}

#playlist-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 24px;
}

.loader-text {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Playlist Error */
#playlist-error {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--error-subtle);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-top: 16px;
}

#playlist-error .icon {
    color: var(--error);
    flex-shrink: 0;
    margin-top: 1px;
}

#playlist-error p {
    font-size: 13px;
    color: #fca5a5;
    line-height: 1.5;
}

.playlist-error-hint {
    font-size: 11px !important;
    color: rgba(252, 165, 165, 0.4) !important;
    margin-top: 4px;
}

#playlist-debug,
#player-debug {
    margin-top: 8px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 11px;
    color: #fca5a5;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
    text-align: left;
    direction: ltr;
    width: 100%;
    border: 1px solid rgba(239, 68, 68, 0.15);
}

.player-error-hint,
.playlist-error-hint {
    font-size: 12px;
    opacity: 0.6;
    cursor: pointer;
}

/* ===== VIEW: Channel Browser ===== */
#view-channels {
    background: var(--bg-base);
}

/* Header */
#app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 14px;
    background: rgba(26, 10, 14, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-logo-text {
    height: 14px;
    width: auto;
}

.header-actions {
    display: flex;
    gap: 2px;
}

.header-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--dur-fast), background var(--dur-fast), transform var(--dur-fast);
}

.header-btn:active {
    transform: scale(0.88);
}

.header-btn.active {
    color: var(--primary-light);
    background: rgba(220, 38, 38, 0.12);
}

/* ===== Home Screen ===== */
#home-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    gap: 24px;
}

/* Continue Watching */
.continue-watching {
    padding: 0 20px 16px;
}

.continue-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-secondary);
}

.continue-list {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
}

.continue-list::-webkit-scrollbar {
    display: none;
}

.continue-item {
    flex-shrink: 0;
    width: 140px;
    cursor: pointer;
    transition: transform var(--dur-fast);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.continue-item:active {
    transform: scale(0.95);
}

.continue-poster {
    width: 100%;
    height: 80px;
    object-fit: cover;
    display: block;
    background: var(--bg-elevated);
}

.continue-poster-placeholder {
    width: 100%;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    color: var(--text-muted);
    font-size: 24px;
    font-weight: 800;
}

.continue-progress {
    height: 3px;
    background: var(--bg-elevated);
}

.continue-progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
}

.continue-name {
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.continue-item {
    position: relative;
}

.continue-delete {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(0,0,0,0.7);
    border: none;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    line-height: 1;
    transition: background var(--dur-fast);
}

.continue-delete:active {
    background: var(--accent);
}

.home-greeting {
    font-size: 22px;
    font-weight: 800;
    text-align: center;
}

.package-info {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 500;
}

.package-info.expired {
    color: var(--accent);
    font-weight: 700;
    font-size: 13px;
}

#home-user-name {
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.home-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    width: 100%;
    max-width: 400px;
}

.home-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 28px 12px 22px;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-family: inherit;
    transition: all var(--dur-normal) var(--ease-out);
    position: relative;
    overflow: hidden;
}

.home-tile::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity var(--dur-normal);
    border-radius: inherit;
}

.home-tile:hover::before {
    opacity: 1;
}

.home-tile:active {
    transform: scale(0.96);
}

.home-tile--israel::before { background: linear-gradient(135deg, rgba(59,130,246,0.12), rgba(255,255,255,0.04)); }
.home-tile--sport::before  { background: linear-gradient(135deg, rgba(34,197,94,0.12), rgba(255,255,255,0.04)); }
.home-tile--news::before   { background: linear-gradient(135deg, rgba(226,232,240,0.1), rgba(255,255,255,0.04)); }
.home-tile--vod::before    { background: linear-gradient(135deg, rgba(168,85,247,0.12), rgba(255,255,255,0.04)); }
.home-tile--all::before    { background: linear-gradient(135deg, rgba(220,38,38,0.10), rgba(255,255,255,0.04)); }

.home-tile--israel { border-color: rgba(59,130,246,0.2); }
.home-tile--sport  { border-color: rgba(34,197,94,0.2); }
.home-tile--news   { border-color: rgba(226,232,240,0.15); }
.home-tile--vod    { border-color: rgba(168,85,247,0.2); }
.home-tile--all    { border-color: rgba(220,38,38,0.2); grid-column: 1 / -1; }

.home-tile:active.home-tile--israel { border-color: rgba(59,130,246,0.5); box-shadow: 0 0 24px rgba(59,130,246,0.15); }
.home-tile:active.home-tile--sport  { border-color: rgba(34,197,94,0.5); box-shadow: 0 0 24px rgba(34,197,94,0.15); }
.home-tile:active.home-tile--news   { border-color: rgba(226,232,240,0.4); box-shadow: 0 0 24px rgba(226,232,240,0.1); }
.home-tile:active.home-tile--vod    { border-color: rgba(168,85,247,0.5); box-shadow: 0 0 24px rgba(168,85,247,0.15); }
.home-tile:active.home-tile--all    { border-color: rgba(220,38,38,0.5); box-shadow: 0 0 24px rgba(220,38,38,0.15); }

.tile-icon {
    position: relative;
    z-index: 1;
}

.home-tile--israel .tile-icon { color: #60a5fa; }
.home-tile--sport  .tile-icon { color: #4ade80; }
.home-tile--news   .tile-icon { color: #e2e8f0; }
.home-tile--vod    .tile-icon { color: #c084fc; }
.home-tile--all    .tile-icon { color: #f87171; }

.tile-label {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    position: relative;
    z-index: 1;
}

.tile-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    position: relative;
    z-index: 1;
}

/* Channel Section */
#channel-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

/* Section Title */
.section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px 4px;
    flex-shrink: 0;
}

.section-back-btn {
    background: none;
    border: none;
    color: var(--accent);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--dur-fast);
}

.section-back-btn:active {
    background: var(--bg-card);
    transform: scale(0.9);
}

.section-title {
    font-size: 22px;
    font-weight: 800;
    padding: 0;
    flex: 1;
    letter-spacing: -0.01em;
}

/* Search */
#search-container {
    padding: 10px 14px;
    flex-shrink: 0;
}

#search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    height: 44px;
    background: var(--bg-input);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-full);
    transition: border-color var(--dur-normal), background var(--dur-normal), box-shadow var(--dur-normal);
}

#search-bar:focus-within {
    background: var(--bg-input-focus);
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

#search-bar .icon {
    color: var(--text-muted);
    transition: color var(--dur-normal);
}

#search-bar:focus-within .icon {
    color: var(--primary-light);
}

#search-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    outline: none;
    font-family: inherit;
}

#search-input::placeholder {
    color: var(--text-muted);
}

.btn-clear {
    background: rgba(255,255,255,0.1);
    border: none;
    color: var(--text-secondary);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--dur-fast);
}

.btn-clear:active {
    transform: scale(0.85);
}

/* Category Bar */
#category-bar {
    display: flex;
    gap: 6px;
    padding: 4px 14px 10px;
    overflow-x: auto;
    flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

#category-bar::-webkit-scrollbar {
    display: none;
}

.category-chip {
    flex-shrink: 0;
    padding: 7px 16px;
    border-radius: var(--radius-full);
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--dur-normal) var(--ease-in-out);
    white-space: nowrap;
    user-select: none;
    -webkit-user-select: none;
    font-family: inherit;
}

.category-chip:active {
    transform: scale(0.94);
}

.category-chip.active {
    background: var(--gradient-brand);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 3px 12px rgba(220, 38, 38, 0.3);
}

/* Channel Bar (count + view toggle) */
#channel-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 16px 6px;
    flex-shrink: 0;
}

#channel-count {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
}

#view-toggle {
    display: flex;
    gap: 2px;
}

.view-toggle-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    width: 30px;
    height: 30px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--dur-fast), background var(--dur-fast);
}

.view-toggle-btn.active {
    color: var(--text-primary);
    background: var(--bg-card);
}

/* Channel List */
#channel-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    padding: 0 8px;
}

.channel-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 2px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--dur-fast), transform var(--dur-fast);
    user-select: none;
    -webkit-user-select: none;
}

.channel-item:active {
    transform: scale(0.985);
    background: var(--bg-card);
}

.channel-item.active {
    background: rgba(220, 38, 38, 0.12);
}

.channel-item.active .channel-name {
    color: var(--accent);
}

.channel-logo {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--bg-card);
    flex-shrink: 0;
    border: 1px solid var(--border);
}

.channel-logo-placeholder {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 17px;
    font-weight: 700;
    border: 1px solid var(--border);
}

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

.channel-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    transition: color var(--dur-fast);
}

.channel-group {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.channel-now-playing {
    font-size: 11px;
    color: var(--primary-light);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
}

.channel-fav {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: color var(--dur-fast), transform var(--dur-fast);
}

.channel-fav:active {
    transform: scale(1.2);
}

.channel-fav.is-fav {
    color: var(--gold);
    animation: starPop 0.35s ease;
}

.channel-fav svg {
    width: 18px;
    height: 18px;
}

@keyframes starPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.35); }
    100% { transform: scale(1); }
}

/* Channel Grid View */
#channel-list.grid-view {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 4px 10px;
}

.channel-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 6px 10px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--dur-fast), transform var(--dur-fast);
    user-select: none;
    -webkit-user-select: none;
    text-align: center;
}

.channel-tile:active {
    transform: scale(0.96);
    background: var(--bg-card-hover);
}

.channel-tile.active {
    border-color: var(--primary);
    background: rgba(220, 38, 38, 0.12);
}

.channel-tile .channel-logo {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
}

.channel-tile .channel-logo-placeholder {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    font-size: 20px;
}

.tile-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    max-width: 100%;
}

/* Country List */
.country-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    margin-bottom: 2px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--dur-fast), transform var(--dur-fast);
    user-select: none;
    -webkit-user-select: none;
}

.country-item:active {
    transform: scale(0.985);
    background: var(--bg-card);
}

.country-flag {
    font-size: 28px;
    line-height: 1;
    flex-shrink: 0;
    width: 40px;
    text-align: center;
}

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

.country-name {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
}

.country-count {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.country-arrow {
    color: var(--text-muted);
    flex-shrink: 0;
}

/* Season Header */
.season-header {
    padding: 14px 16px 6px;
    font-size: 15px;
    font-weight: 700;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    margin-top: 8px;
    position: sticky;
    top: 0;
    background: var(--bg-base);
    z-index: 2;
}

/* Back chip */
.category-chip--back {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    font-weight: 700;
}

/* Empty State */
#empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 40px 20px;
}

.empty-icon {
    color: var(--text-muted);
    opacity: 0.25;
    margin-bottom: 8px;
}

#empty-message {
    font-size: 15px;
    color: var(--text-secondary);
    font-weight: 600;
}

.empty-hint {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== VIEW: Player ===== */
#view-player {
    background: #000;
}

/* Player Header */
#player-header {
    display: flex;
    align-items: center;
    height: var(--header-height);
    padding: 0 8px;
    background: rgba(0, 0, 0, 0.9);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
    z-index: 5;
}

.player-header-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: color var(--dur-fast);
}

.player-header-btn:active {
    color: var(--text-primary);
}

#player-header-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: center;
    min-width: 0;
}

#player-header-logo {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-xs);
    object-fit: cover;
    background: var(--bg-card);
}

#player-header-name {
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-header-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.player-header-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--dur-fast), background var(--dur-fast);
}

.player-header-icon:active {
    transform: scale(0.88);
    color: var(--text-primary);
}

.player-header-icon.active {
    color: var(--primary-light);
}

/* Live Badge */
.live-badge {
    background: #ef4444;
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    letter-spacing: 0.06em;
    animation: livePulse 2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Player Container */
#player-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 0;
    background: #000;
}

#player-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 100%;
    background: #000;
    overflow: hidden;
}

#video-player {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

/* Player Overlay */
/* Channel Switch Toast */
.channel-toast {
    position: absolute;
    top: 16px;
    right: 16px;
    left: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255,255,255,0.1);
    z-index: 8;
    transition: opacity 0.4s ease, transform 0.4s var(--ease-out);
}

.channel-toast--hidden {
    opacity: 0;
    transform: translateY(-12px);
    pointer-events: none;
}

.channel-toast img {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-xs);
    object-fit: cover;
    background: rgba(255,255,255,0.1);
}

.toast-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

#toast-name {
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#toast-group {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 1px;
}

/* ===== Floating Player Controls ===== */
#player-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
    z-index: 5;
    padding: 12px;
}

#player-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Floating glassmorphic bar */
.control-bar {
    width: 100%;
    max-width: 540px;
    background: rgba(17, 17, 17, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 18px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transform: translateY(20px);
    opacity: 0;
    filter: blur(6px);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.4s ease,
                filter 0.4s ease;
}

#player-overlay.visible .control-bar {
    transform: translateY(0);
    opacity: 1;
    filter: blur(0);
}

/* Seek row */
.seek-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.seek-time {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255,255,255,0.6);
    font-variant-numeric: tabular-nums;
    min-width: 38px;
    text-align: center;
    direction: ltr;
    flex-shrink: 0;
}

/* Custom seek track (div-based) */
.seek-track {
    flex: 1;
    height: 5px;
    background: rgba(255,255,255,0.15);
    border-radius: 3px;
    position: relative;
    cursor: pointer;
    direction: ltr;
}

.seek-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: #fff;
    border-radius: 3px;
    transition: width 0.1s linear;
    pointer-events: none;
}

.seek-thumb {
    position: absolute;
    top: 50%;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 6px rgba(0,0,0,0.4);
    pointer-events: none;
    transition: left 0.1s linear;
}

.seek-track:active .seek-thumb {
    width: 18px;
    height: 18px;
}

/* Controls row */
.controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.controls-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Control button */
.ctrl-btn {
    background: none;
    border: none;
    color: #fff;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.15s;
}

.ctrl-btn:hover {
    background: rgba(255,255,255,0.1);
}

.ctrl-btn:active {
    transform: scale(0.88);
    background: rgba(255,255,255,0.18);
}

.ctrl-btn--play {
    width: 42px;
    height: 42px;
}

/* Volume slider */
.vol-track-wrap {
    width: 70px;
}

.vol-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    direction: ltr;
}

.vol-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
}

.vol-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    border: none;
}

/* Speed selector */
.speed-selector {
    display: flex;
    gap: 2px;
}

.speed-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    padding: 4px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.speed-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.speed-btn.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

/* Aspect ratio modes */
.aspect-contain { object-fit: contain !important; }
.aspect-cover { object-fit: cover !important; }
.aspect-fill { object-fit: fill !important; }

/* Player Error */
#player-error {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(15, 10, 30, 0.95);
    gap: 14px;
    z-index: 10;
}

#player-error p {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
}

.btn-retry {
    background: var(--gradient-brand);
    color: #fff;
    border: none;
    padding: 10px 28px;
    border-radius: var(--radius-full);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: transform var(--dur-fast);
    box-shadow: 0 4px 16px rgba(220, 38, 38, 0.3);
}

.btn-retry:active {
    transform: scale(0.94);
}

/* Player Loading */
#player-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(15, 10, 30, 0.8);
    gap: 16px;
    z-index: 10;
}

#player-loading p {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Player Sidebar (tablet) */

/* ===== EPG Panel ===== */
.backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
    display: none;
}

.backdrop--visible {
    display: block;
}

.backdrop--hidden {
    display: none;
}

.panel {
    position: fixed;
    top: 0;
    inset-inline-end: 0;
    bottom: 0;
    width: 85%;
    max-width: 380px;
    background: var(--bg-surface);
    z-index: 200;
    display: none;
    flex-direction: column;
    box-shadow: 0 0 40px rgba(0,0,0,0.4);
    border-inline-start: 1px solid var(--border);
}

.panel--hidden {
    display: none;
}

.panel--visible {
    display: flex;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.panel-header h2 {
    font-size: 17px;
    font-weight: 700;
}

#epg-channel-name {
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

#epg-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 6px 0;
}

.epg-item {
    padding: 12px 16px;
    margin: 0 8px 4px;
    border-radius: var(--radius-sm);
}

.epg-item.now {
    background: rgba(220, 38, 38, 0.1);
    border: 1px solid rgba(220, 38, 38, 0.2);
}

.epg-time {
    font-size: 12px;
    color: var(--primary-light);
    font-weight: 700;
    direction: ltr;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.epg-title {
    font-size: 13px;
    margin-top: 3px;
    font-weight: 600;
}

.epg-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.4;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }

/* ===== Selection ===== */
::selection {
    background: rgba(220, 38, 38, 0.3);
}

/* ===== Responsive ===== */
@media (min-width: 768px) {
    .sidebar-search {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 10px 14px;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
    }

    .sidebar-search input {
        flex: 1;
        background: none;
        border: none;
        color: var(--text-primary);
        font-size: 14px;
        outline: none;
        font-family: inherit;
    }

    .sidebar-search input::placeholder {
        color: var(--text-muted);
    }

    .sidebar-channels {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    #player-header {
        display: none;
    }

    #player-container {
        aspect-ratio: auto;
        height: 100%;
        max-height: none;
    }
}

/* ===== Mini Player ===== */
.mini-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 72px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px 0 0;
    z-index: 150;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
}

.mini-player--hidden {
    transform: translateY(100%);
    pointer-events: none;
}

.mini-player-video {
    width: 120px;
    height: 72px;
    flex-shrink: 0;
    background: #000;
    overflow: hidden;
}

.mini-player-video video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mini-player-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#mini-player-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#mini-player-program {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-player-close {
    background: none;
    border: none;
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color var(--dur-fast);
}

.mini-player-close:active {
    color: var(--accent);
}

/* Add bottom padding to channel list when mini player is visible */
body.mini-player-active #channel-list {
    padding-bottom: 80px;
}

body.mini-player-active #home-screen {
    padding-bottom: 80px;
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
