:root {
    --bg-base: rgba(255, 255, 255, 0.85);
    --panel-bg: rgba(248, 252, 248, 0.9);
    --panel-border: rgba(129, 199, 132, 0.25);
    --accent-1: #4caf50;
    --accent-2: #81c784;
    --accent-3: #a5d6a7;
    --text-primary: #2e7d32;
    --text-secondary: #558b2f;
    --chip-bg: rgba(76, 175, 80, 0.15);
    --shadow-soft: 0 16px 40px rgba(46, 125, 50, 0.15);
    color-scheme: light;
}

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

body {
    background: transparent;
    color: var(--text-primary);
    font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.screen {
    width: min(100%, 840px);
    margin: 0 auto;
    padding: 18px 16px 72px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.screen-header {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 20px 18px;
    border-radius: 20px;
    background: var(--bg-base);
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(18px);
}

.title-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border-radius: 999px;
    color: var(--accent-1);
    background: var(--chip-bg);
}

.screen-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
}

.tagline {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
}

.refresh {
    padding: 10px 20px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.9), rgba(129, 199, 132, 0.9));
    color: var(--text-primary);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 12px 30px rgba(76, 175, 80, 0.25);
}

.refresh:active {
    transform: scale(0.97);
}

.refresh:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.timestamp {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.insights {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.insight-card {
    padding: 16px 18px;
    background: var(--panel-bg);
    border-radius: 16px;
    border: 1px solid rgba(129, 199, 132, 0.3);
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.insight-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

.insight-value {
    font-size: 1.3rem;
    font-weight: 700;
    display: flex;
    align-items: baseline;
    gap: 4px;
    color: var(--text-primary);
}

.insight-value .unit {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.ranking {
    padding: 22px 18px 28px;
    background: var(--bg-base);
    border-radius: 24px;
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(22px);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.ranking-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ranking-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
}

.subtitle {
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.programme-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.loading,
.error-message,
.empty-message {
    padding: 18px 16px;
    text-align: center;
    color: var(--text-secondary);
    border-radius: 14px;
    border: 1px dashed rgba(129, 199, 132, 0.4);
    background: rgba(248, 252, 248, 0.6);
}

.programme-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 14px;
    padding: 16px;
    border-radius: 18px;
    background: rgba(248, 252, 248, 0.95);
    border: 1px solid rgba(129, 199, 132, 0.3);
    box-shadow: 0 14px 30px rgba(46, 125, 50, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.programme-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 36px rgba(46, 125, 50, 0.15);
}

.rank-badge {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.05rem;
    color: #ffffff;
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.9), rgba(129, 199, 132, 0.9));
}

.rank-badge.top-1 {
    background: linear-gradient(135deg, #2e7d32, #4caf50);
}

.rank-badge.top-2 {
    background: linear-gradient(135deg, #388e3c, #66bb6a);
}

.rank-badge.top-3 {
    background: linear-gradient(135deg, #4caf50, #81c784);
}

.programme-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.programme-head {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.programme-name {
    font-size: 1.05rem;
    font-weight: 700;
}

.channel-name {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.metric {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.metric-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.metric-value {
    font-size: 0.98rem;
    font-weight: 600;
}

.progress-trend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.progress-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.progress-bar {
    width: 100%;
    height: 6px;
    border-radius: 6px;
    background: rgba(116, 210, 255, 0.16);
    overflow: hidden;
}

.progress-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(116, 210, 255, 0.95), rgba(122, 185, 255, 0.95));
    width: 0;
    transition: width 0.5s ease;
}

.progress-row.attention .progress-bar span {
    background: linear-gradient(135deg, rgba(244, 156, 224, 0.95), rgba(116, 210, 255, 0.9));
}

/* Tablet layout */
@media (min-width: 600px) {
    .screen {
        padding: 24px 20px 88px;
        gap: 20px;
    }

    .screen-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 26px 28px;
    }

    .screen-header h1 {
        font-size: 1.9rem;
    }

    .tagline {
        font-size: 1rem;
    }

    .actions {
        align-items: flex-end;
    }

    .insights {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 16px;
    }

    .programme-item {
        grid-template-columns: 72px 1fr;
        padding: 18px 20px;
    }

    .rank-badge {
        width: 54px;
        height: 54px;
        font-size: 1.25rem;
    }

    .metric-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Desktop layout */
@media (min-width: 1024px) {
    .screen {
        width: min(100%, 960px);
        padding: 32px 28px 104px;
    }

    .insight-card {
        padding: 20px 22px;
    }

    .insight-value {
        font-size: 1.6rem;
    }

    .ranking {
        padding: 30px 32px 36px;
    }

    .programme-item {
        grid-template-columns: 96px 1fr;
        padding: 22px 26px;
        border-radius: 22px;
    }

    .programme-name {
        font-size: 1.25rem;
    }

    .metric-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
