:root {
    --bg-primary: #f5f0e8;
    --bg-secondary: #ffffff;
    --bg-tertiary: #faf7f2;
    --accent-secondary: #8b0000;
    --text-primary: #1a1a1a;
    --text-secondary: #444444;
    --text-dim: #888888;
    --border: #c8c0b0;
    --border-heavy: #1a1a1a;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

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

body {
    font-family: 'Source Serif 4', 'Georgia', serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: clip;
    min-height: 100vh;
}

/* Header */
.header {
    background: var(--bg-secondary);
    border-bottom: 4px double var(--border-heavy);
    padding: 1.5rem 2rem 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
}

.logo h1 {
    font-family: 'Playfair Display', serif;
    font-size: 2.8rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    text-transform: uppercase;
    line-height: 1;
}

.logo .glow {
    color: var(--accent-secondary);
    text-shadow: none;
    animation: none;
}

.date-time {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.15rem;
}

.current-time {
    font-family: 'Inter', sans-serif;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
    text-shadow: none;
    letter-spacing: 0;
}

.current-date {
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* Date Selector */
.date-selector {
    max-width: 1600px;
    margin: 1.5rem auto;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1.5rem;
}

.date-nav {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.75rem 1.25rem;
    min-height: 44px;
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.date-nav:disabled {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

.date-nav:hover {
    background: var(--text-primary);
    color: var(--bg-secondary);
    border-color: var(--text-primary);
}

.date-nav:active {
    transform: translateY(0);
}

.selected-date {
    padding: 0.5rem 1.5rem;
    background: transparent;
    border: none;
    font-family: 'Playfair Display', serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0;
    box-shadow: none;
    text-transform: none;
}

/* Search Bar */
.search-bar {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 2rem 1rem;
}

.search-input-wrapper {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 0.65rem 2.5rem 0.65rem 1rem;
    min-height: 44px;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    outline: none;
    transition: border-color 0.2s ease;
}

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

.search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    display: none;
}

.search-input:focus {
    border-color: var(--text-primary);
}

.search-clear {
    position: absolute;
    right: 6px;
    top: 6px;
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 0.9rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: color 0.15s ease, background 0.15s ease;
}

.search-clear[hidden] {
    display: none;
}

.search-clear:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.search-empty {
    text-align: center;
    padding: 3rem 1rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    color: var(--text-dim);
}

@media (max-width: 768px) {
    .search-bar {
        padding: 0 1rem 1rem;
    }
}

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6rem 2rem;
    gap: 1.2rem;
}

.loading[hidden] {
    display: none;
}

.loading-spinner {
    width: 28px;
    height: 28px;
    border: 2.5px solid var(--border);
    border-top-color: var(--accent-secondary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    color: var(--text-dim);
    letter-spacing: 0.03em;
}

/* Guide Columns */
.guide-columns {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 2rem 3rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

/* Channel Column */
.channel-column {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    overflow: hidden;
    animation: fadeIn 0.4s ease-out;
    animation-fill-mode: both;
    scroll-margin-top: 6rem;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Channel Header */
.channel-column-header {
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border-heavy);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.channel-column-logo {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    font-size: 0.65rem;
    letter-spacing: -0.02em;
    flex-shrink: 0;
    overflow: hidden;
    background: var(--bg-tertiary);
    padding: 4px;
}

.channel-column-logo.dark-bg {
    background: #1a1a1a;
}

.channel-column-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.channel-column-name {
    font-family: 'Playfair Display', serif;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0;
    text-transform: uppercase;
}

/* Program List */
.channel-programs {
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.program-card {
    padding: 0.75rem 1rem;
    min-height: 44px;
    background: var(--bg-secondary);
    border-bottom: 1px solid #e8e2d8;
    border-left: none;
    cursor: pointer;
    transition: background 0.15s ease;
    position: relative;
    overflow: hidden;
}

.program-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--accent-secondary);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.program-card:hover {
    background: var(--bg-tertiary);
    transform: none;
    z-index: auto;
    box-shadow: none;
}

.program-card:hover::before {
    opacity: 1;
}

.program-card.current {
    background: #fffde6;
    border-left: 3px solid var(--accent-secondary);
}

.program-card.current::after {
    content: 'NU';
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    background: var(--accent-secondary);
    color: #ffffff;
    padding: 0.15rem 0.5rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    border-radius: 2px;
    animation: none;
}

.progress-bar {
    height: 3px;
    background: #e8e2d8;
    border-radius: 1.5px;
    margin-top: 0.5rem;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent-secondary);
    border-radius: 1.5px;
    transition: width 1s linear;
}

.program-time {
    font-family: 'Inter', sans-serif;
    font-size: 0.7rem;
    color: var(--accent-secondary);
    font-weight: 600;
    margin-bottom: 0.3rem;
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: #d32f2f;
    color: #ffffff;
    padding: 0.1rem 0.4rem;
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    border-radius: 2px;
    line-height: 1;
}

.live-badge::before {
    content: '';
    width: 5px;
    height: 5px;
    background: #ffffff;
    border-radius: 50%;
}

.program-title {
    font-family: 'Source Serif 4', serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
    line-height: 1.25;
}

.program-description {
    font-family: 'Source Serif 4', serif;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-style: italic;
}

/* Finished programs */
.finished-toggle {
    padding: 0.75rem 1rem;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-secondary);
    cursor: pointer;
    text-align: center;
    border-bottom: 1px solid #e8e2d8;
    transition: background 0.15s ease;
    letter-spacing: 0.02em;
}

.finished-toggle:hover {
    background: var(--bg-tertiary);
}

.finished-programs.collapsed .finished-list {
    display: none;
}

.program-card.finished {
    opacity: 0.5;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    max-width: 550px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.modal-close:hover {
    background: var(--text-primary);
    color: var(--bg-secondary);
    border-color: var(--text-primary);
    transform: none;
}

.modal-body {
    padding: 2rem;
}

.modal-header {
    border-bottom: 2px solid var(--border-heavy);
    padding-bottom: 1rem;
    margin-bottom: 1.25rem;
}

.modal-time {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    color: var(--accent-secondary);
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.modal-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
    line-height: 1.2;
}

.modal-channel {
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    color: var(--text-dim);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.modal-details {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-section {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.modal-label {
    font-family: 'Inter', sans-serif;
    font-size: 0.65rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 600;
}

.modal-text {
    font-family: 'Source Serif 4', serif;
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.6;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        padding: 1rem;
    }

    .header-content {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .logo h1 {
        font-size: 2rem;
    }

    .current-time {
        font-size: 1.1rem;
    }

    .date-selector {
        padding: 0 1rem 1rem;
        gap: 1rem;
    }

    .guide-columns {
        padding: 0 1rem 2rem;
        grid-template-columns: 1fr;
    }

    .channel-column {
        overflow: visible;
        animation: none;
    }

    .channel-column-header {
        position: sticky;
        top: 72px;
        z-index: 50;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    .program-card {
        padding: 0.6rem 0.75rem;
    }
}

@media (max-width: 480px) {
    .logo h1 {
        font-size: 1.6rem;
    }

    .date-time {
        align-items: flex-start;
    }

    .selected-date {
        font-size: 1.1rem;
    }

    .date-nav-label {
        display: none;
    }

    .program-description {
        display: none;
    }
}

/* FAB */
.fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--text-primary);
    color: var(--bg-secondary);
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.fab:active {
    transform: scale(0.95);
}

/* Channel Picker */
.channel-picker {
    display: none;
    position: fixed;
    bottom: 6rem;
    right: 2rem;
    width: 380px;
    max-height: 70vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    flex-direction: column;
    overflow: hidden;
}

.channel-picker.active {
    display: flex;
    animation: pickerSlideUp 0.25s ease-out;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.4);
}

@keyframes pickerSlideUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.channel-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--border-heavy);
    font-family: 'Playfair Display', serif;
    font-size: 1rem;
    font-weight: 700;
    flex-shrink: 0;
}

.channel-picker-close {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.channel-picker-close:hover {
    background: var(--text-primary);
    color: var(--bg-secondary);
    border-color: var(--text-primary);
}

.channel-picker-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    padding: 0.75rem;
    overflow-y: auto;
}

.channel-picker-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.5rem 0.25rem 0.6rem;
    background: var(--bg-tertiary);
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
    min-height: 80px;
}

.channel-picker-item:hover {
    background: var(--bg-primary);
    border-color: var(--border);
}

.channel-picker-item:active {
    background: var(--text-primary);
    color: var(--bg-secondary);
}

.channel-picker-item-logo {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    font-size: 0.55rem;
    overflow: hidden;
    background: var(--bg-secondary);
    padding: 3px;
    flex-shrink: 0;
}

.channel-picker-item-logo.dark-bg {
    background: #1a1a1a;
}

.channel-picker-item-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.channel-picker-item-name {
    font-family: 'Inter', sans-serif;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary);
    line-height: 1.3;
    letter-spacing: 0.01em;
    word-break: break-word;
}

.channel-picker-item:active .channel-picker-item-name {
    color: var(--bg-secondary);
}

@media (max-width: 480px) {
    .fab {
        bottom: 1rem;
        right: 1rem;
        width: 48px;
        height: 48px;
        font-size: 1.2rem;
    }

    .channel-picker {
        bottom: 4.5rem;
        right: 1rem;
        left: 1rem;
        width: auto;
        max-height: 60vh;
    }

    .channel-picker-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .channel-picker {
        width: 340px;
    }
}

/* QR Modal */
.qr-modal-content {
    max-width: 320px;
}

.qr-modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 1rem;
    gap: 0.6rem;
}

.qr-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.3rem;
    font-weight: 700;
}

.qr-subtitle {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    color: var(--text-dim);
    text-align: center;
    margin-bottom: 0.5rem;
}

.qr-code {
    width: 200px;
    height: 200px;
}

.qr-url {
    font-family: 'Inter', sans-serif;
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 0.3rem;
    word-break: break-all;
    text-align: center;
}

/* Install Banner */
.install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--text-primary);
    color: var(--bg-secondary);
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    z-index: 2000;
    animation: bannerSlideUp 0.3s ease-out;
}

.install-banner[hidden] {
    display: none;
}

@keyframes bannerSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.install-banner-text {
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
}

.install-banner-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.install-banner-btn {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: none;
    padding: 0.4rem 1rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 3px;
    cursor: pointer;
}

.install-banner-dismiss {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.2rem;
    line-height: 1;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}
