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

:root {
    --app-height: 100vh;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #161c2d;
    color: #e2e8f0;
    min-height: 100vh;
    padding: 0;
    margin: 0;
    overflow-y: auto;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content {
    display: flex;
    flex: 1;
    gap: 24px;
    padding: 24px;
    padding-bottom: 48px;
    align-items: flex-start;
}

.player-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-width: 0;
    background: #000;
}

.sidebar {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    flex-shrink: 0;
    max-height: calc(100vh - 200px);
    position: sticky;
    top: 24px;
    overflow-y: auto;
}

.sidebar.hidden {
    display: none;
}

.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* 響應式設計 */
@media (max-width: 1024px) {
    .main-content {
        flex-direction: column;
    }

    .player-container {
        background: #000;
        border-radius: 0;
        margin-bottom: 0;
    }

    .sidebar {
        width: 100%;
        max-height: 400px;
        position: static;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .channel-list {
        max-height: 400px;
        overflow: hidden;
    }
    
    .channel-list-container {
        max-height: 320px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 768px), (hover: none) and (pointer: coarse) and (orientation: portrait) {
    body {
        overflow-x: hidden;
    }
    
    .container {
        width: 100%;
        max-width: 100%;
    }
    
    .header {
        padding: 8px 16px;
        width: 100%;
    }

    .header-logo {
        height: 28px;
    }

    .header-actions {
        gap: 4px;
    }

    .header .btn-primary {
        padding: 6px 10px;
        font-size: 12px;
    }

    .keyboard-hint {
        display: none !important;
    }
    
    .osd {
        display: none !important;
    }
    
    .controls {
        display: none !important;
    }
    
    .main-content {
        padding: 0;
        gap: 0;
    }
    
    /* 播放區維持 16:9 比例，避免電視框延伸到空白區域 */
    .player-section {
        width: 100%;
        gap: 0;
        flex-shrink: 0;
    }

    .player-container {
        position: relative;
        margin-bottom: 0;
        border-radius: 0;
        width: 100%;
        display: flex;
        flex-direction: column;
        background: #000;
    }

    /* CRT 外框維持 16:9 比例，不延伸到影片以外的空白區域 */
    .player-section .crt-wrapper {
        width: 100%;
        aspect-ratio: 16 / 9;
        position: relative;
    }

    /* 影片區域填滿容器 */
    .video-wrapper {
        padding-top: 0;
        position: absolute;
        inset: 0;
    }

    .channel-info {
        padding: 8px 16px;
    }
    
    /* 手機版按鈕優化（精簡高度以保留更多影片空間） */
    .mobile-controls {
        display: flex !important;
        gap: 6px;
        padding: 12px 8px;
        margin-top: 4px;
        margin-bottom: 8px;
    }

    .mobile-control-row {
        gap: 6px;
    }

    .mobile-btn {
        padding: 10px 6px;
        font-size: 13px;
        max-width: none;
    }

    .mobile-btn .icon {
        font-size: 16px;
    }
    
    .mobile-btn .label {
        font-size: 10px;
    }
    
    /* 手機版頻道列表優化 */
    .sidebar {
        max-height: 300px;
        width: 100%;
    }
    
    .channel-list {
        padding: 16px;
    }
    
    .channel-list h2 {
        font-size: 18px;
    }
    
    .channel-list-header {
        margin-bottom: 12px;
    }
    
    .channel-list-actions {
        gap: 4px;
    }
    
    .btn-action {
        padding: 4px 8px;
        font-size: 11px;
    }
    
    .channel-list-container {
        max-height: 220px;
    }
    
    /* 手機版表單優化 */
    .add-form {
        padding: 16px;
        margin: 0 8px 8px 8px !important;
    }
    
    .add-form h2 {
        font-size: 18px;
    }
    
    .hint {
        font-size: 13px;
    }
    
    /* 直向模式的 CRT 控制面板 - 隱藏右側的 */
    .crt-controls,
    .crt-controls.show {
        display: none !important;
    }
    
    /* 直向模式的電視框 */
    .crt-wrapper.crt-active .video-wrapper {
        border-radius: 0;
    }
    
    /* 平板直向全螢幕模式 - 跟一般全螢幕一樣，不顯示電視框 */
    .player-container.fullscreen.crt-fullscreen-mode .crt-fullscreen-panel {
        display: none !important;
    }
    
    .player-container.fullscreen.crt-fullscreen-mode .crt-frame-overlay {
        display: none !important;
    }
    
    /* 隱藏 CRT 特效在直向全螢幕時 */
    .player-container.fullscreen.crt-fullscreen-mode .crt-scanlines,
    .player-container.fullscreen.crt-fullscreen-mode .crt-curve,
    .player-container.fullscreen.crt-fullscreen-mode .crt-rgb {
        display: none !important;
    }
    
    /* 覆蓋桌面版的 CRT 全螢幕設定，恢復正常全螢幕行為 */
    .player-container.fullscreen.crt-fullscreen-mode {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .player-container.fullscreen.crt-fullscreen-mode .crt-wrapper {
        width: 100vw;
        height: 100vh;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .player-container.fullscreen.crt-fullscreen-mode .crt-wrapper .video-wrapper {
        position: relative;
        inset: auto;
        width: 100%;
        height: auto;
        aspect-ratio: 16 / 9;
        max-height: 100vh;
        padding-top: 0;
        border-radius: 0;
    }
    
    .player-container.fullscreen.crt-fullscreen-mode .crt-wrapper .video-wrapper #player,
    .player-container.fullscreen.crt-fullscreen-mode .crt-wrapper .video-wrapper iframe {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
}

/* 手機橫向模式優化 */
@media (max-width: 932px) and (orientation: landscape), (hover: none) and (pointer: coarse) and (orientation: landscape) {
    html {
        /* 不鎖定 overflow，讓整個頁面可捲動以觸發 Safari 自動隱藏網址列/工具列 */
        background: #000;
    }

    body {
        /* 允許垂直捲動手勢，讓瀏覽器網址列/工具列可自動縮起 */
        overflow-x: hidden;
        overflow-y: auto;
        background: #000;
    }

    /* 在 body 底部加入捲動緩衝區，讓使用者能向下滑動觸發 Safari 縮小工具列 */
    body::after {
        content: '';
        display: block;
        height: 80px;
        background: #161c2d;
    }

    /* 沉浸式橫屏：只保留播放區和右側按鈕列 */
    .header,
    .sidebar,
    .channel-info,
    .add-form,
    .keyboard-hint,
    .controls,
    .crt-controls {
        display: none !important;
    }

    .container {
        /* position: sticky 讓內容固定在視窗頂部，同時保留在文件流中，
           使整個頁面可捲動，觸發 Safari 隱藏網址列與 tabs */
        position: sticky;
        top: 0;
        left: 0;
        width: 100vw;
        height: var(--app-height);
        /* 留出 iOS Home Indicator / 底部 safe area 空間 */
        padding-bottom: env(safe-area-inset-bottom);
        box-sizing: border-box;
    }

    .main-content {
        width: 100%;
        height: 100%;
        padding: 0;
        gap: 0;
        display: block;
    }

    /* 播放器區域：左側影片 + 右側固定按鈕列 */
    .player-section {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 64px;
        grid-template-rows: 1fr;
        gap: 0;
        width: 100%;
        height: 100%;
        overflow: hidden;
    }
    
    .player-container {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        margin: 0;
        border-radius: 0;
        overflow: hidden;
        grid-column: 1;
        grid-row: 1;
        background: #000;
        min-height: 0;
        min-width: 0;
    }

    /*
     * 注意：基礎樣式裡的 `.player-container` / `.crt-wrapper` / `.video-wrapper`
     * 定義寫在這個 media query 後面，若用同等選擇器會被覆蓋。
     * 這裡提高 selector specificity，確保橫屏尺寸規則真的生效。
     */
    .player-section .player-container {
        margin: 0;
        min-height: 0;
        min-width: 0;
    }

    /* 以高度優先保持 16:9，不讓外框壓縮造成上下裁切 */
    .player-section .crt-wrapper {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .player-section .video-wrapper {
        position: relative;
        width: 100%;
        height: auto;
        max-height: 100%;
        padding-top: 0;
        aspect-ratio: 16 / 9;
        background: black;
    }
    
    #player {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }

    /* 讓影片區域的垂直滑動手勢用於頁面捲動，觸發 Safari 隱藏工具列
       touch-action: pan-y 告訴瀏覽器：垂直滑動應捲動父頁面而非由 iframe 攔截 */
    .player-container,
    .crt-wrapper,
    .video-wrapper,
    #player {
        touch-action: pan-y !important;
    }

    /* 橫向模式：右側按鈕列 - 單行直列，可滾動 */
    .mobile-controls {
        display: flex !important;
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 4px;
        padding: 4px;
        padding-top: max(4px, env(safe-area-inset-top));
        padding-bottom: 4px;
        background: #1e2535;
        border-radius: 0;
        grid-column: 2;
        grid-row: 1;
        align-self: stretch;
        width: 64px;
        /* min-height: 0 讓 grid item 可收縮，overflow-y: auto 才能正常作用 */
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        /* 確保觸控滑動手勢在縱向可用 */
        touch-action: pan-y;
    }
    
    /* row 也變成單行直列 */
    .mobile-control-row {
        display: flex;
        flex-direction: column;
        gap: 4px;
        width: 100%;
    }
    
    .mobile-btn {
        width: 100%;
        height: 44px;
        padding: 4px;
        border-radius: 6px;
        min-height: 44px;
        flex-shrink: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }
    
    .mobile-btn .icon {
        font-size: 16px;
        margin: 0;
        line-height: 1;
    }
    
    /* 橫向模式隱藏按鈕文字 */
    .mobile-btn .label {
        display: none;
    }
    
    /* 平板橫向模式的電視框要填滿 */
    .crt-wrapper.crt-active .video-wrapper {
        border-radius: 0;
    }
    
    /* 平板橫向全螢幕 CRT 模式 - 跟桌面版一樣，控制面板在右側 */
    .player-container.fullscreen.crt-fullscreen-mode {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        background: #000;
    }
    
    .player-container.fullscreen.crt-fullscreen-mode .crt-wrapper {
        flex: 0 0 auto;
        width: auto;
        height: 100vh;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 10px;
        padding-right: 5px;
    }
    
    .player-container.fullscreen.crt-fullscreen-mode .crt-wrapper .video-wrapper {
        position: relative;
        width: auto;
        height: 85vh;
        aspect-ratio: 4 / 3;
        padding-top: 0;
        border-radius: 8px;
        overflow: hidden;
    }
    
    .player-container.fullscreen.crt-fullscreen-mode .crt-fullscreen-panel {
        display: flex;
        position: relative;
        bottom: auto;
        left: auto;
        transform: none;
        flex-direction: column;
        padding: 10px;
        min-width: 140px;
    }
    
    .player-container.fullscreen.crt-fullscreen-mode .crt-panel-box {
        flex-direction: column;
        gap: 12px;
        padding: 16px 12px;
    }
    
    .player-container.fullscreen.crt-fullscreen-mode .crt-panel-section {
        flex-direction: column;
        gap: 6px;
    }
    
    .player-container.fullscreen.crt-fullscreen-mode .crt-panel-label {
        display: block;
        font-size: 10px;
    }
    
    .player-container.fullscreen.crt-fullscreen-mode .crt-panel-btn {
        width: 40px;
        height: 40px;
    }
    
    .player-container.fullscreen.crt-fullscreen-mode .crt-panel-btn-control {
        width: 32px;
        height: 32px;
    }
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 24px;
    background: #1e2535;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.header-logo-wrap {
    display: flex;
    align-items: center;
}

.header-logo {
    display: block;
    height: 36px;
    width: auto;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: #1C3563;
    color: #93c5fd;
    box-shadow: -3px -3px 7px rgba(255, 255, 255, 0.06), 3px 3px 8px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.07);
}

.btn-primary:hover {
    background: #22437a;
    box-shadow: -2px -2px 5px rgba(255, 255, 255, 0.05), 4px 4px 10px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255,255,255,0.05);
}

.btn-primary:active {
    box-shadow: inset -2px -2px 5px rgba(255, 255, 255, 0.06), inset 3px 3px 8px rgba(0, 0, 0, 0.5);
}

.btn-secondary {
    background: #1e2535;
    color: #cbd5e1;
    box-shadow: -3px -3px 7px rgba(255, 255, 255, 0.05), 3px 3px 8px rgba(0, 0, 0, 0.5);
}

.btn-secondary:hover {
    background: #242d42;
    box-shadow: -2px -2px 5px rgba(255, 255, 255, 0.05), 4px 4px 10px rgba(0, 0, 0, 0.6);
}

.btn-secondary:active {
    box-shadow: inset -2px -2px 5px rgba(255, 255, 255, 0.05), inset 3px 3px 8px rgba(0, 0, 0, 0.5);
}

.btn:disabled {
    background: #1a2030;
    color: #4b5563;
    cursor: not-allowed;
    box-shadow: none;
}

.add-form {
    background: #1e2535;
    padding: 24px;
    border-radius: 16px;
    margin-bottom: 24px;
    box-shadow: -5px -5px 12px rgba(255, 255, 255, 0.04), 6px 6px 14px rgba(0, 0, 0, 0.5);
}

.add-form h2 {
    font-size: 20px;
    margin-bottom: 16px;
    color: #e2e8f0;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
}

.form-group input,
.form-group textarea {
    flex: 1;
    padding: 12px 16px;
    background: #1a2030;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    color: #e2e8f0;
    font-size: 16px;
    font-family: inherit;
    box-shadow: inset -2px -2px 5px rgba(255, 255, 255, 0.04), inset 3px 3px 7px rgba(0, 0, 0, 0.5);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: inset -2px -2px 5px rgba(255, 255, 255, 0.04), inset 3px 3px 7px rgba(0, 0, 0, 0.5), 0 0 0 2px rgba(37, 99, 235, 0.3);
}

.form-group textarea {
    min-height: 120px;
    line-height: 1.5;
}

.form-group .btn {
    align-self: flex-end;
    min-width: 120px;
}

.hint {
    color: #94a3b8;
    font-size: 14px;
    line-height: 1.6;
}

.hint code {
    background: #1a2030;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 13px;
}

.player-container {
    position: relative;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 24px;
}

.player-container.fullscreen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    border-radius: 0;
    background: #000;
    overflow: hidden;
}

.video-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%;
}

.player-container.fullscreen .video-wrapper {
    padding-top: 0;
    height: 100vh;
}

#player {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.static-overlay {
    position: absolute;
    inset: 0;
    background: black;
    z-index: 200;
    display: none;
    pointer-events: none;
}

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

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

/* NO SIGNAL 復古文字 */
.no-signal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Courier New', monospace;
    font-size: clamp(24px, 5vw, 48px);
    font-weight: bold;
    color: #ffffff;
    text-shadow: 
        0 0 10px rgba(255, 255, 255, 0.8),
        0 0 20px rgba(255, 255, 255, 0.4),
        2px 2px 0 #000;
    letter-spacing: 8px;
    opacity: 0;
    z-index: 201;
    pointer-events: none;
}

.no-signal.show {
    animation: noSignalBlink 1.5s ease-in-out infinite;
}

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

/* YouTube 介面遮罩 + 復古 OSD */
.youtube-mask {
    position: absolute;
    left: 0;
    right: 0;
    height: 10%;
    min-height: 40px;
    background: #000000;
    z-index: 250;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease-out;
    display: flex;
    align-items: center;
    padding: 0 20px;
    font-family: 'Courier New', monospace;
}

.youtube-mask.show {
    opacity: 1;
    transition: opacity 0s; /* 顯示時瞬間出現 */
}

.youtube-mask-top {
    top: 0;
    justify-content: flex-start;
    gap: 16px;
}

.youtube-mask-bottom {
    bottom: 0;
    justify-content: flex-end;
    height: 20%;
    min-height: 60px;
}

.osd-channel-number {
    color: #00ff00;
    font-size: clamp(18px, 3vw, 28px);
    font-weight: bold;
    text-shadow: 0 0 8px rgba(0, 255, 0, 0.8);
    letter-spacing: 2px;
}

.osd-channel-name {
    color: #00ff00;
    font-size: clamp(14px, 2vw, 20px);
    text-shadow: 0 0 6px rgba(0, 255, 0, 0.6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
}

.osd-stereo {
    color: #00ff00;
    font-size: clamp(12px, 1.5vw, 16px);
    text-shadow: 0 0 6px rgba(0, 255, 0, 0.6);
    letter-spacing: 3px;
}

.osd-stereo::before {
    content: '♪ ';
}

/* CRT 電視外框 */
.crt-wrapper {
    position: relative;
    display: block;
}

.crt-wrapper.crt-active {
    /* 非全螢幕模式：外框在影片內部 */
}

.crt-frame-overlay {
    position: absolute;
    /* 外框框住整個影片 */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 300;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.crt-wrapper.crt-active .crt-frame-overlay {
    opacity: 1;
}

.crt-frame-overlay img {
    width: 100%;
    height: 100%;
    object-fit: fill;
}

.crt-wrapper.crt-active .video-wrapper {
    overflow: hidden;
}

/* CRT 模式下影片縮小避免被框裁切 */
.crt-wrapper.crt-active .video-wrapper #player,
.crt-wrapper.crt-active .video-wrapper iframe {
    transform: scale(0.88);
    transform-origin: center center;
}

/* CRT 模式下 youtube-mask 和 OSD 也要跟著調整位置 */
.crt-wrapper.crt-active .youtube-mask-top {
    top: 6%;
    left: 0;
    right: 0;
    height: 12%;
    padding-left: 12%;
    padding-right: 12%;
}

.crt-wrapper.crt-active .youtube-mask-bottom {
    bottom: 6%;
    left: 0;
    right: 0;
    height: 18%;
    padding-left: 12%;
    padding-right: 12%;
}

.crt-wrapper.crt-active .osd {
    top: 6%;
    left: 12%;
    right: 12%;
}

/* ===== 全螢幕 CRT 模式 - 4:3 電視介面 ===== */
.player-container.fullscreen .crt-wrapper {
    height: 100vh;
    width: 100vw;
}

.player-container.fullscreen .crt-wrapper .video-wrapper {
    width: 100%;
    height: 100%;
    padding-top: 0;
}

.player-container.fullscreen.crt-fullscreen-mode {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

.player-container.fullscreen.crt-fullscreen-mode .crt-wrapper {
    flex: 0 0 auto;
    width: auto;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    padding-right: 10px;
}

.player-container.fullscreen.crt-fullscreen-mode .crt-wrapper .video-wrapper {
    position: relative;
    width: auto;
    height: 90vh;
    aspect-ratio: 4 / 3;
    padding-top: 0;
    border-radius: 12px;
    overflow: hidden;
}

.player-container.fullscreen.crt-fullscreen-mode .crt-frame-overlay {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* 全螢幕 CRT 模式下的 youtube-mask 要在外框下面 */
.player-container.fullscreen.crt-fullscreen-mode .youtube-mask {
    z-index: 250;
}

/* 全螢幕 CRT 控制面板 */
.crt-fullscreen-panel {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    min-width: 180px;
}

.player-container.fullscreen.crt-fullscreen-mode .crt-fullscreen-panel {
    display: flex;
}

.crt-panel-box {
    background: #1a1a1a;
    border-radius: 16px;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: -4px -4px 10px rgba(255, 255, 255, 0.04), 6px 6px 14px rgba(0, 0, 0, 0.7);
}

.crt-panel-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.crt-panel-label {
    color: #888;
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.crt-panel-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.crt-panel-btn-power {
    background: #1a1a1a;
    color: #00ff00;
    box-shadow: 0 0 15px rgba(0, 255, 0, 0.3);
}

.crt-panel-btn-power:hover {
    box-shadow: 0 0 25px rgba(0, 255, 0, 0.5);
}

.crt-panel-btn-control {
    background: #3a3a3a;
    color: #fff;
    width: 40px;
    height: 40px;
    font-size: 14px;
}

.crt-panel-btn-control:hover {
    background: #4a4a4a;
}

.crt-panel-btn-control:active {
    background: #555;
    transform: scale(0.95);
}

.crt-panel-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.crt-panel-btn-guide {
    background: #3a3a3a;
    color: #fff;
    width: 40px;
    height: 40px;
    font-size: 18px;
}

.crt-panel-btn-guide:hover {
    background: #4a4a4a;
}

.crt-panel-btn-random {
    background: #3a3a3a;
    color: #fff;
    width: 40px;
    height: 40px;
    font-size: 18px;
}

.crt-panel-btn-random:hover {
    background: #4a4a4a;
}

.crt-panel-btn-mute {
    background: #3a3a3a;
    color: #fff;
    width: auto;
    height: 36px;
    padding: 0 16px;
    border-radius: 6px;
    font-size: 12px;
    letter-spacing: 1px;
}

.crt-panel-btn-exit {
    background: #3a3a3a;
    color: #fff;
    width: auto;
    height: 40px;
    padding: 0 24px;
    border-radius: 6px;
    font-size: 13px;
    letter-spacing: 1px;
}

.crt-panel-btn-exit:hover {
    background: #4a4a4a;
}

/* 全螢幕 CRT 控制面板的滑桿 */
.crt-panel-slider-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.crt-panel-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #1a1a1a;
    border-radius: 3px;
    outline: none;
}

.crt-panel-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #00ff00;
    border-radius: 50%;
    cursor: pointer;
}

.crt-panel-slider-value {
    color: #00ff00;
    font-size: 12px;
}

/* 真電視模式按鈕的字幕提示 */
.tv-mode-tooltip {
    position: relative;
}

.tv-mode-tooltip::after {
    content: '💡 建議先用滑鼠將字幕位置上移，避免被電視外框遮擋';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: #fbbf24;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 1000;
    pointer-events: none;
    margin-bottom: 8px;
}

.tv-mode-tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

@media (max-width: 768px) {
    .tv-mode-tooltip::after {
        white-space: normal;
        width: 200px;
        left: 0;
        transform: none;
    }
}

/* CRT 掃描線特效 */
.crt-scanlines {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 5;
    opacity: 0;
}

.crt-scanlines.show {
    opacity: var(--crt-intensity, 0.5);
}

/* CRT 曲面暗角效果 */
.crt-curve {
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse at center,
        transparent 0%,
        transparent 60%,
        rgba(0, 0, 0, 0.4) 100%
    );
    pointer-events: none;
    z-index: 6;
    opacity: 0;
}

.crt-curve.show {
    opacity: var(--crt-intensity, 0.5);
}

/* CRT RGB 像素效果 */
.crt-rgb {
    position: absolute;
    inset: 0;
    background-image: repeating-linear-gradient(
        90deg,
        rgba(255, 0, 0, 0.03),
        rgba(255, 0, 0, 0.03) 1px,
        rgba(0, 255, 0, 0.03) 1px,
        rgba(0, 255, 0, 0.03) 2px,
        rgba(0, 0, 255, 0.03) 2px,
        rgba(0, 0, 255, 0.03) 3px
    );
    pointer-events: none;
    z-index: 4;
    opacity: 0;
}

.crt-rgb.show {
    opacity: var(--crt-intensity, 0.5);
}

/* CRT 控制面板 */
.crt-controls {
    display: none;
    background: #1e2535;
    padding: 16px 24px;
    border-radius: 12px;
    margin-top: 16px;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
    box-shadow: -3px -3px 8px rgba(255, 255, 255, 0.04), 4px 4px 10px rgba(0, 0, 0, 0.5);
}

.crt-controls.show {
    display: flex;
}

.crt-control-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.crt-control-label {
    color: #94a3b8;
    font-size: 14px;
    white-space: nowrap;
}

.crt-slider {
    width: 150px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #1a2030;
    border-radius: 3px;
    outline: none;
    box-shadow: inset -1px -1px 3px rgba(255,255,255,0.04), inset 2px 2px 4px rgba(0,0,0,0.5);
}

.crt-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #2563eb;
    border-radius: 50%;
    cursor: pointer;
}

.crt-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #2563eb;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.crt-value {
    color: #e2e8f0;
    font-size: 14px;
    min-width: 40px;
}

@media (max-width: 768px) {
    .crt-controls {
        padding: 12px 16px;
        gap: 12px;
    }
    
    .crt-slider {
        width: 100px;
    }
}

.osd {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 0;
    z-index: 250;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.osd.show {
    opacity: 1;
}

.osd-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px;
}

.osd-info {
    background: rgba(0, 0, 0, 0.85);
    padding: 12px 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    font-family: 'Courier New', monospace;
    text-shadow: 0 0 8px rgba(0, 255, 0, 0.5);
}

.osd-info h2 {
    font-size: 20px;
    font-weight: normal;
    margin-bottom: 4px;
    color: #00ff00;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.osd-info p {
    color: #00ff00;
    font-size: 14px;
    letter-spacing: 0.5px;
}

.osd-controls {
    background: rgba(0, 0, 0, 0.85);
    padding: 12px 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.osd-controls kbd {
    background: rgba(0, 255, 0, 0.2);
    border: 1px solid #00ff00;
    color: #00ff00;
    font-family: 'Courier New', monospace;
    padding: 4px 8px;
    border-radius: 2px;
    font-size: 12px;
    text-shadow: 0 0 4px rgba(0, 255, 0, 0.5);
}

.osd-controls span {
    color: #00ff00;
    font-size: 12px;
    font-family: 'Courier New', monospace;
    text-shadow: 0 0 4px rgba(0, 255, 0, 0.5);
}

.osd-controls .btn {
    display: none;
}

/* OSD 頻道表 */
.channel-guide {
    position: fixed;
    inset: 0;
    z-index: 2147483647;
    background: transparent;
    display: none;
    align-items: center;
    justify-content: flex-end;
    padding: 40px;
    pointer-events: none;
}

.channel-guide.show {
    display: flex;
    pointer-events: auto;
}

.channel-guide-container {
    background: rgba(0, 0, 0, 0.7);
    border: 3px solid #00ff00;
    padding: 30px;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 0 30px rgba(0, 255, 0, 0.3);
    pointer-events: auto;
}

@media (max-width: 768px) {
    .channel-guide {
        padding: 20px;
    }
    
    .channel-guide-container {
        max-width: calc(100vw - 40px);
        padding: 20px;
    }
}

.channel-guide-container::-webkit-scrollbar {
    width: 12px;
}

.channel-guide-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.5);
}

.channel-guide-container::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 0, 0.3);
    border: 1px solid #00ff00;
}

.channel-guide h2 {
    color: #00ff00;
    font-family: 'Courier New', monospace;
    text-align: center;
    font-size: 28px;
    margin-bottom: 20px;
    text-shadow: 0 0 10px rgba(0, 255, 0, 0.8);
    letter-spacing: 2px;
}

.channel-guide-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.channel-guide-item {
    background: rgba(0, 255, 0, 0.1);
    border: 2px solid rgba(0, 255, 0, 0.3);
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Courier New', monospace;
}

.channel-guide-item:hover {
    background: rgba(0, 255, 0, 0.2);
    border-color: #00ff00;
    transform: scale(1.05);
}

.channel-guide-item.active {
    background: rgba(0, 255, 0, 0.3);
    border-color: #00ff00;
    box-shadow: 0 0 15px rgba(0, 255, 0, 0.5);
}

.channel-guide-number {
    color: #00ff00;
    font-size: 20px;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(0, 255, 0, 0.8);
}

.channel-guide-name {
    color: #00ff00;
    font-size: 14px;
    margin-top: 4px;
    text-shadow: 0 0 5px rgba(0, 255, 0, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-guide-hint {
    text-align: center;
    margin-top: 20px;
    color: #00ff00;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    text-shadow: 0 0 5px rgba(0, 255, 0, 0.5);
}

.channel-info {
    background: #1e2535;
    padding: 16px 24px;
    position: relative;
    z-index: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.channel-info h3 {
    font-size: 18px;
    margin-bottom: 4px;
}

.channel-info p {
    color: #94a3b8;
    font-size: 14px;
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
}

.keyboard-hint {
    text-align: center;
    padding: 0 24px;
}

.keyboard-hint p {
    font-size: 14px;
    color: #94a3b8;
    margin-bottom: 8px;
}

.keyboard-hint div {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.keyboard-hint kbd {
    background: #1e2535;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: -2px -2px 5px rgba(255, 255, 255, 0.05), 2px 2px 6px rgba(0, 0, 0, 0.5);
    color: #cbd5e1;
}

/* 手機專用觸控按鈕 */
.mobile-controls {
    display: none;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
    background: #1e2535;
    border-radius: 16px;
    padding: 16px 12px;
}

.mobile-control-row {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.mobile-btn {
    flex: 1;
    padding: 16px 12px;
    background: #1e2535;
    border: none;
    border-radius: 12px;
    color: #cbd5e1;
    font-size: 14px;
    cursor: pointer;
    transition: box-shadow 0.12s ease, transform 0.12s ease, background 0.12s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    max-width: 120px;
    box-shadow:
        -5px -5px 12px rgba(255, 255, 255, 0.09),
        5px 5px 12px rgba(0, 0, 0, 0.6);
}

.mobile-btn:active {
    box-shadow:
        inset -4px -4px 9px rgba(255, 255, 255, 0.07),
        inset 4px 4px 10px rgba(0, 0, 0, 0.6);
    transform: scale(0.98);
}

.mobile-btn .icon {
    font-size: 20px;
}

.mobile-btn .label {
    font-size: 11px;
    color: #64748b;
}

.mobile-btn-primary {
    background: #1C3563;
    color: #93c5fd;
    box-shadow:
        -5px -5px 12px rgba(255, 255, 255, 0.08),
        5px 5px 12px rgba(0, 0, 0, 0.6);
}

.mobile-btn-primary:active {
    background: #1C3563;
    box-shadow:
        inset -4px -4px 9px rgba(255, 255, 255, 0.06),
        inset 4px 4px 10px rgba(0, 0, 0, 0.6);
}

/* 頻道切換按鈕樣式 */
.mobile-btn-channel {
    background: #1e2535;
}

.mobile-btn-channel:active {
    box-shadow:
        inset -4px -4px 9px rgba(255, 255, 255, 0.07),
        inset 4px 4px 10px rgba(0, 0, 0, 0.6);
}

/* 影片切換按鈕樣式 */
.mobile-btn-video {
    background: #1e2535;
}

.mobile-btn-video:active {
    box-shadow:
        inset -4px -4px 9px rgba(255, 255, 255, 0.07),
        inset 4px 4px 10px rgba(0, 0, 0, 0.6);
}

.mobile-btn-video:disabled {
    background: #1a2030;
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

/* 隨機播放按鈕 */
.mobile-btn-random {
    background: #1e2535;
}

.mobile-btn-random:active {
    box-shadow:
        inset -4px -4px 9px rgba(255, 255, 255, 0.07),
        inset 4px 4px 10px rgba(0, 0, 0, 0.6);
}

/* 真電視模式按鈕 */
.mobile-btn-tvmode {
    background: #1e2535;
}

.mobile-btn-tvmode:active {
    box-shadow:
        inset -4px -4px 9px rgba(255, 255, 255, 0.07),
        inset 4px 4px 10px rgba(0, 0, 0, 0.6);
}

.mobile-btn-active {
    background: #065f46 !important;
    color: #6ee7b7 !important;
    box-shadow:
        -5px -5px 12px rgba(255, 255, 255, 0.07),
        5px 5px 12px rgba(0, 0, 0, 0.6) !important;
}

.mobile-btn-active:active {
    box-shadow:
        inset -4px -4px 9px rgba(255, 255, 255, 0.06),
        inset 4px 4px 10px rgba(0, 0, 0, 0.6) !important;
}

.btn-tvmode {
    background: #1e2535;
    color: #cbd5e1;
    box-shadow: -3px -3px 7px rgba(255, 255, 255, 0.05), 3px 3px 8px rgba(0, 0, 0, 0.5);
}

.btn-tvmode:hover {
    background: #242d42;
}

.btn-tvmode.active {
    background: #065f46;
    color: #6ee7b7;
    box-shadow: inset -2px -2px 5px rgba(255, 255, 255, 0.04), inset 3px 3px 7px rgba(0, 0, 0, 0.5);
}

.btn-tvmode.active:hover {
    background: #064e39;
}

.btn-lightmode {
    background: #1e2535;
    color: #cbd5e1;
    box-shadow: -3px -3px 7px rgba(255, 255, 255, 0.05), 3px 3px 8px rgba(0, 0, 0, 0.5);
}

.btn-lightmode:hover {
    background: #242d42;
}

.btn-lightmode.active {
    background: #065f46;
    color: #6ee7b7;
    box-shadow: inset -2px -2px 5px rgba(255, 255, 255, 0.04), inset 3px 3px 7px rgba(0, 0, 0, 0.5);
}

.btn-lightmode.active:hover {
    background: #064e39;
}

.mobile-btn-lightmode {
    background: #1e2535;
}

.mobile-btn-lightmode:active {
    box-shadow:
        inset -4px -4px 9px rgba(255, 255, 255, 0.07),
        inset 4px 4px 10px rgba(0, 0, 0, 0.6);
}

.mobile-btn-lightmode-active {
    background: #065f46 !important;
    color: #6ee7b7 !important;
    box-shadow:
        -5px -5px 12px rgba(255, 255, 255, 0.07),
        5px 5px 12px rgba(0, 0, 0, 0.6) !important;
}

.mobile-btn-lightmode-active:active {
    box-shadow:
        inset -4px -4px 9px rgba(255, 255, 255, 0.06),
        inset 4px 4px 10px rgba(0, 0, 0, 0.6) !important;
}

.channel-list {
    background: #1e2535;
    padding: 24px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
    box-shadow: -5px -5px 12px rgba(255, 255, 255, 0.04), 6px 6px 14px rgba(0, 0, 0, 0.5);
}

.channel-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.channel-list h2 {
    font-size: 20px;
    margin: 0;
    flex-shrink: 0;
}

.channel-list-actions {
    display: flex;
    gap: 8px;
}

.btn-action {
    background: #1e2535;
    border: none;
    color: #94a3b8;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
    box-shadow: -2px -2px 5px rgba(255, 255, 255, 0.05), 2px 2px 6px rgba(0, 0, 0, 0.5);
}

.btn-action:hover {
    color: #e2e8f0;
    box-shadow: -1px -1px 4px rgba(255, 255, 255, 0.05), 3px 3px 7px rgba(0, 0, 0, 0.5);
}

.btn-action:active {
    box-shadow: inset -1px -1px 4px rgba(255, 255, 255, 0.05), inset 2px 2px 5px rgba(0, 0, 0, 0.5);
}

.btn-action.active {
    background: #1e3a6e;
    color: #93c5fd;
    box-shadow: inset -2px -2px 5px rgba(255, 255, 255, 0.04), inset 3px 3px 7px rgba(0, 0, 0, 0.5);
}

.btn-action-danger:hover {
    background: #3f1212;
    color: #fca5a5;
}

.channel-list-container {
    overflow-y: auto;
    flex: 1;
}

.channel-list-container::-webkit-scrollbar {
    width: 8px;
}

.channel-list-container::-webkit-scrollbar-track {
    background: transparent;
}

.channel-list-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.channel-list-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

.channel-item {
    background: #1e2535;
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.15s;
    cursor: pointer;
    box-shadow: -3px -3px 7px rgba(255, 255, 255, 0.04), 3px 3px 8px rgba(0, 0, 0, 0.4);
}

.channel-item:hover {
    background: #242d42;
    box-shadow: -2px -2px 5px rgba(255, 255, 255, 0.04), 4px 4px 10px rgba(0, 0, 0, 0.5);
}

.channel-item.active {
    background: #1e3a6e;
    color: #93c5fd;
    box-shadow: inset -2px -2px 5px rgba(255, 255, 255, 0.04), inset 3px 3px 8px rgba(0, 0, 0, 0.5);
}

/* 排序模式樣式 */
.drag-handle {
    color: #64748b;
    margin-right: 8px;
    display: none;
}

.sorting-mode .drag-handle {
    display: block;
}

.sorting-mode .btn-delete {
    display: none;
}

.channel-item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sort-buttons {
    display: none;
    gap: 2px;
}

.sorting-mode .sort-buttons {
    display: flex;
}

.btn-sort {
    background: #1e2535;
    border: none;
    color: #64748b;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    box-shadow: -1px -1px 4px rgba(255, 255, 255, 0.05), 2px 2px 5px rgba(0, 0, 0, 0.5);
}

.btn-sort:hover:not(:disabled) {
    background: #1e3a6e;
    color: #93c5fd;
}

.btn-sort:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.channel-item-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.channel-number {
    color: #94a3b8;
    font-family: monospace;
    font-size: 14px;
}

.channel-id {
    font-family: monospace;
    font-size: 14px;
}

.btn-delete {
    background: none;
    border: none;
    color: #f87171;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.btn-delete:hover {
    background: rgba(248, 113, 113, 0.2);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: #64748b;
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
}

.hidden {
    display: none !important;
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(37, 99, 235, 0.3);
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 首次使用教學彈窗 */
.onboarding-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.onboarding-modal {
    background: #1e2535;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: -8px -8px 20px rgba(255, 255, 255, 0.04), 10px 10px 24px rgba(0, 0, 0, 0.6);
}

.onboarding-header {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    padding: 24px;
    text-align: center;
}

.onboarding-header h2 {
    font-size: 28px;
    margin-bottom: 8px;
}

.onboarding-header p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 16px;
}

.onboarding-content {
    padding: 24px;
}

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

.onboarding-section h3 {
    color: #2563eb;
    font-size: 18px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.onboarding-section p {
    color: #94a3b8;
    line-height: 1.6;
    margin-bottom: 8px;
}

.onboarding-controls {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 12px;
}

.onboarding-control-item {
    background: #1e2535;
    padding: 12px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: -2px -2px 5px rgba(255, 255, 255, 0.04), 3px 3px 7px rgba(0, 0, 0, 0.5);
}

.onboarding-control-item kbd {
    background: #1a2030;
    padding: 6px 10px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 14px;
    min-width: 40px;
    text-align: center;
    box-shadow: -1px -1px 3px rgba(255,255,255,0.05), 2px 2px 4px rgba(0,0,0,0.5);
    color: #93c5fd;
}

.onboarding-control-item span {
    color: #e2e8f0;
    font-size: 14px;
}

.onboarding-tip {
    background: rgba(37, 99, 235, 0.1);
    border-left: 3px solid #2563eb;
    padding: 12px 16px;
    margin-top: 16px;
    border-radius: 0 8px 8px 0;
}

.onboarding-tip p {
    color: #e2e8f0;
    margin: 0;
}

.onboarding-footer {
    padding: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.onboarding-checkbox {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.onboarding-checkbox input {
    width: 20px;
    height: 20px;
    accent-color: #2563eb;
}

.onboarding-checkbox span {
    color: #94a3b8;
    font-size: 14px;
}

.onboarding-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.onboarding-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
}

@media (max-width: 600px) {
    .onboarding-controls {
        grid-template-columns: 1fr;
    }

    .onboarding-header h2 {
        font-size: 22px;
    }
}

/* 頻道選擇器 Modal */
.channel-picker-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.channel-picker-modal {
    background: #1e2535;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    max-width: 800px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: -8px -8px 20px rgba(255, 255, 255, 0.04), 10px 10px 24px rgba(0, 0, 0, 0.6);
}

.channel-picker-header {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    padding: 20px 24px;
    border-radius: 14px 14px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.channel-picker-header h2 {
    font-size: 22px;
    margin: 0;
}

.channel-picker-header p {
    color: rgba(255, 255, 255, 0.85);
    font-size: 14px;
    margin-top: 4px;
}

.channel-picker-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.channel-picker-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.channel-picker-categories {
    display: flex;
    gap: 8px;
    padding: 16px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-wrap: wrap;
}

.category-tab {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    white-space: nowrap;
}

.category-tab:hover {
    border-color: #2563eb;
    color: #e2e8f0;
}

.category-tab.active {
    background: #2563eb;
    border-color: #2563eb;
    color: white;
}

.channel-picker-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
}

.channel-picker-body::-webkit-scrollbar {
    width: 8px;
}

.channel-picker-body::-webkit-scrollbar-track {
    background: transparent;
}

.channel-picker-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.picker-category-section {
    margin-bottom: 24px;
}

.picker-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.picker-category-title {
    font-size: 18px;
    font-weight: bold;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.picker-select-all {
    font-size: 13px;
    color: #2563eb;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.picker-select-all:hover {
    background: rgba(37, 99, 235, 0.15);
}

.picker-channel-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.picker-channel-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: #1e2535;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: -2px -2px 5px rgba(255, 255, 255, 0.04), 2px 2px 6px rgba(0, 0, 0, 0.4);
}

.picker-channel-item:hover {
    border-color: rgba(37, 99, 235, 0.4);
    background: #242d42;
    box-shadow: -2px -2px 5px rgba(255, 255, 255, 0.04), 3px 3px 8px rgba(0, 0, 0, 0.5);
}

.picker-channel-item.selected {
    border-color: #2563eb;
    background: #1e3a6e;
    box-shadow: inset -1px -1px 4px rgba(255, 255, 255, 0.04), inset 2px 2px 6px rgba(0, 0, 0, 0.4);
}

.picker-channel-item.already-added {
    opacity: 0.45;
    cursor: default;
}

.picker-channel-item.already-added:hover {
    border-color: rgba(255, 255, 255, 0.05);
    background: #1e2535;
    box-shadow: -2px -2px 5px rgba(255, 255, 255, 0.04), 2px 2px 6px rgba(0, 0, 0, 0.4);
}

.picker-channel-checkbox {
    width: 18px;
    height: 18px;
    accent-color: #2563eb;
    flex-shrink: 0;
    pointer-events: none;
    margin-top: 2px;
}

.picker-channel-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.picker-channel-name {
    color: #e2e8f0;
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.picker-channel-desc {
    color: #64748b;
    font-size: 12px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.picker-channel-item.already-added .picker-channel-name::after {
    content: '（已加入）';
    color: #64748b;
    font-size: 12px;
    font-weight: normal;
    margin-left: 6px;
}

.channel-picker-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.picker-selection-count {
    color: #94a3b8;
    font-size: 14px;
}

.picker-selection-count strong {
    color: #2563eb;
}

.picker-footer-actions {
    display: flex;
    gap: 8px;
}

.picker-btn {
    padding: 10px 20px;
    border-radius: 10px;
    border: none;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s;
}

.picker-btn-cancel {
    background: #1e2535;
    color: #94a3b8;
    box-shadow: -2px -2px 5px rgba(255, 255, 255, 0.05), 3px 3px 7px rgba(0, 0, 0, 0.5);
}

.picker-btn-cancel:hover {
    background: #242d42;
    color: #e2e8f0;
}

.picker-btn-confirm {
    background: #1C3563;
    color: #93c5fd;
    box-shadow: -3px -3px 7px rgba(255, 255, 255, 0.06), 3px 3px 8px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.07);
}

.picker-btn-confirm:hover {
    background: #22437a;
    box-shadow: -2px -2px 5px rgba(255, 255, 255, 0.05), 4px 4px 10px rgba(0, 0, 0, 0.6);
}

.picker-btn-confirm:disabled {
    opacity: 0.5;
    cursor: default;
    transform: none;
    box-shadow: none;
}

@media (max-width: 600px) {
    .channel-picker-modal {
        max-height: 95vh;
    }

    .picker-channel-grid {
        grid-template-columns: 1fr;
    }

    .channel-picker-footer {
        flex-direction: column;
    }

    .channel-picker-categories {
        padding: 12px 16px;
    }

    .channel-picker-body {
        padding: 12px 16px;
    }

    .channel-picker-header {
        padding: 16px;
    }

    .channel-picker-footer {
        padding: 12px 16px;
    }
}

/* ========== 會員制 ========== */
.membership-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.membership-modal {
    background: #1e2535;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    max-width: 480px;
    width: 100%;
    box-shadow: -8px -8px 20px rgba(255, 255, 255, 0.04), 10px 10px 24px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

.membership-header {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.membership-header h2 {
    font-size: 22px;
    margin: 0;
}

.membership-header p {
    color: rgba(255, 255, 255, 0.85);
    font-size: 14px;
    margin-top: 4px;
}

.membership-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.membership-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.membership-body {
    padding: 24px;
}

.membership-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.membership-status.inactive {
    background: rgba(100, 116, 139, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.membership-status.active {
    background: rgba(37, 99, 235, 0.15);
    border: 1px solid #2563eb;
}

.membership-status-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.membership-status-text {
    flex: 1;
}

.membership-status-text .label {
    font-size: 13px;
    color: #94a3b8;
}

.membership-status-text .value {
    font-size: 16px;
    font-weight: 600;
    margin-top: 2px;
}

.membership-status.active .value {
    color: #93c5fd;
}

.membership-status.inactive .value {
    color: #94a3b8;
}

.membership-input-group {
    margin-bottom: 16px;
}

.membership-input-group label {
    display: block;
    font-size: 14px;
    color: #cbd5e1;
    margin-bottom: 8px;
}

.membership-input-row {
    display: flex;
    gap: 8px;
}

.membership-input-row input {
    flex: 1;
    background: #1a2030;
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 15px;
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
    outline: none;
    transition: border-color 0.2s;
    box-shadow: inset -2px -2px 5px rgba(255, 255, 255, 0.04), inset 3px 3px 7px rgba(0, 0, 0, 0.5);
}

.membership-input-row input:focus {
    border-color: #2563eb;
    box-shadow: inset -2px -2px 5px rgba(255, 255, 255, 0.04), inset 3px 3px 7px rgba(0, 0, 0, 0.5), 0 0 0 2px rgba(37, 99, 235, 0.3);
}

.membership-input-row input::placeholder {
    color: #4b5563;
    letter-spacing: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.membership-btn-activate {
    background: #1C3563;
    color: #93c5fd;
    border: none;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    box-shadow: -3px -3px 7px rgba(255, 255, 255, 0.06), 3px 3px 8px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.07);
}

.membership-btn-activate:hover {
    background: #22437a;
}

.membership-btn-deactivate {
    background: #1e2535;
    color: #64748b;
    border: none;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    width: 100%;
    margin-top: 8px;
    box-shadow: -2px -2px 5px rgba(255, 255, 255, 0.04), 2px 2px 6px rgba(0, 0, 0, 0.4);
}

.membership-btn-deactivate:hover {
    background: #242d42;
    color: #94a3b8;
}

.membership-error {
    color: #ef4444;
    font-size: 13px;
    margin-top: 8px;
    display: none;
}

.membership-error.show {
    display: block;
}

.membership-perks {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.membership-perks h3 {
    font-size: 15px;
    color: #93c5fd;
    margin-bottom: 12px;
}

.membership-perk-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    font-size: 14px;
    color: #e2e8f0;
}

.membership-perk-item .perk-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.membership-sponsor {
    margin-top: 20px;
    padding: 16px;
    background: rgba(37, 99, 235, 0.08);
    border: 1px dashed #2563eb;
    border-radius: 12px;
    text-align: center;
}

.membership-sponsor p {
    font-size: 13px;
    color: #94a3b8;
    margin-bottom: 10px;
}

.membership-sponsor a {
    display: inline-block;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    text-decoration: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    transition: opacity 0.2s;
}

.membership-sponsor a:hover {
    opacity: 0.9;
}

/* 會員徽章（header） */
.btn-membership {
    background: #1C3563;
    color: #93c5fd;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: opacity 0.2s;
    font-weight: 600;
}

.btn-membership:hover {
    opacity: 0.9;
}

.btn-membership.is-member {
    background: #1C3563;
    color: #a5b4fc;
    box-shadow: inset -2px -2px 5px rgba(255, 255, 255, 0.05), inset 3px 3px 7px rgba(0, 0, 0, 0.4);
}

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

/* 鎖定覆蓋（頻道選擇器分類） */
.picker-category-section.locked {
    position: relative;
}

.picker-category-section.locked .picker-channel-grid {
    filter: blur(2px);
    pointer-events: none;
    opacity: 0.4;
}

.picker-category-section.locked .picker-select-all {
    display: none;
}

.picker-lock-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(37, 99, 235, 0.12);
    border: 1px solid rgba(37, 99, 235, 0.3);
    border-radius: 8px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.picker-lock-banner:hover {
    background: rgba(37, 99, 235, 0.2);
}

.picker-lock-banner span {
    font-size: 13px;
    color: #93c5fd;
}

/* 新增頻道鎖定提示 */
.add-form-lock {
    text-align: center;
    padding: 20px;
    color: #94a3b8;
}

.add-form-lock p {
    margin-bottom: 12px;
    font-size: 14px;
}

.add-form-lock .btn-unlock {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.add-form-lock .btn-unlock:hover {
    opacity: 0.9;
}

/* 手機版會員按鈕 */
@media (max-width: 768px), (hover: none) and (pointer: coarse) and (orientation: portrait) {
    .btn-membership {
        padding: 6px 10px;
        font-size: 12px;
    }

    .membership-modal {
        max-width: 100%;
        max-height: 90vh;
        overflow-y: auto;
    }

    .membership-header {
        padding: 16px;
    }

    .membership-body {
        padding: 16px;
    }

    .membership-input-row {
        flex-direction: column;
    }

    .membership-btn-activate {
        width: 100%;
    }
}
