@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Play:wght@700&display=swap');

:root {
    --bg-body: #141518;
    --bg-container: linear-gradient(180deg, #1e2025 0%, #24272e 100%);
    --bg-sidebar: #1e2025;
    --bg-card: #282c34;
    --bg-card-hover: #2f343e;
    --bg-input: #2c303a;
    --bg-header-pill: #2c313c;
    --text-primary: #f1f3f5;
    --text-secondary: #b8c0cc;
    --text-muted: #868e96;
    --accent-primary: #4dabf7;
    --accent-hover: #74c0fc;
    --accent-visited: #845ef7;
    --accent-title: #f5c542;
    --brand-color: #00e676;
    --border-color: #373b44;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.28);
    --shadow-lg: 0 6px 20px rgba(0, 0, 0, 0.45);
}

body.light-mode {
    --bg-body: #eef1f5;
    --bg-container: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-input: #ffffff;
    --bg-header-pill: #e7f0fd;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --accent-primary: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-visited: #6d28d9;
    --accent-title: #1e3a8a;
    --brand-color: #0059b3;
    --border-color: #cbd5e1;
    --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 4px 16px rgba(15, 23, 42, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    background-color: var(--bg-body);
    color: var(--text-primary);
    padding: 12px;
    transition: background-color 0.25s ease, color 0.25s ease;
    font-size: 16px;
    overscroll-behavior: none;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    gap: 20px;
    background: var(--bg-container);
    padding: 18px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    min-height: calc(100vh - 24px);
}

/* --- SIDEBAR --- */
.sidebar {
    width: 340px;
    padding: 16px;
    position: sticky;
    top: 12px;
    align-self: flex-start;
    display: flex;
    flex-direction: column;
    background: var(--bg-sidebar);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease, width 0.3s ease, padding 0.3s ease;
    --progress: 0;
    z-index: 1000;
    flex-shrink: 0;
    transform: translateX(0);
}

.sidebar-hidden {
    transform: translateX(-100vw);
    width: 0;
    padding: 0;
    border: none;
    overflow: hidden;
}

.sidebar::before {
    content: '';
    display: none;
    height: 3px;
    background: var(--accent-primary);
    position: absolute;
    top: 0;
    left: 0;
    width: var(--progress);
    transition: width 0.25s ease;
    border-radius: 10px 10px 0 0;
}

.sidebar.loading::before {
    display: block;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.55);
    z-index: 999;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    background: var(--bg-card);
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.header-buttons {
    display: flex;
    gap: 4px;
}

.sidebar h1 {
    font-family: 'Play', sans-serif;
    font-size: 1.65em;
    font-weight: 700;
    color: var(--brand-color);
    letter-spacing: 0.5px;
}

.sidebar-image {
    display: block;
    width: 100%;
    object-fit: cover;
    margin: 0 auto 12px;
    border-radius: 8px;
}

.sidebar-section-header {
    color: var(--accent-title);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8em;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 700;
    margin-top: 16px;
    margin-bottom: 4px;
}

.sidebar-image + .sidebar-section-header {
    margin-top: 0;
}

.sidebar-section-header hr {
    flex-grow: 1;
    border: none;
    border-top: 1px solid var(--border-color);
}

.sidebar ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    padding: 2px;
}

.sidebar li {
    width: calc(50% - 4px);
    display: flex;
    align-items: center;
}

.sidebar a {
    color: var(--accent-primary);
    text-decoration: none;
    font-size: 0.92em;
    font-weight: 500;
    display: block;
    padding: 7px 10px;
    border-radius: 6px;
    border-left: 3px solid transparent;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    flex: 1;
    touch-action: manipulation;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    outline: none;
}

.sidebar a:hover {
    background-color: var(--bg-header-pill);
    color: var(--text-primary);
}

.sidebar a.active {
    background-color: var(--bg-header-pill);
    color: var(--text-primary);
    border-left-color: var(--accent-primary);
}

.sidebar a.disabled {
    color: var(--text-muted);
    opacity: 0.55;
    pointer-events: none;
    cursor: not-allowed;
}

/* --- STICKY RIGHT-PANEL ARTICLE HEADER --- */
#article-header-bar {
    position: sticky;
    top: calc(var(--top-bar-height, 64px) - 2px);
    z-index: 45;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 14px;
    margin-top: -2px;
    margin-bottom: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    background-color: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
}

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

#article-header-bar button {
    padding: 8px 14px;
    font-size: 0.9em;
}

#article-header-bar a {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--accent-primary);
    text-decoration: none;
    font-size: 0.9em;
    font-weight: 600;
    transition: background-color 0.2s, color 0.2s;
}

#article-header-bar a:hover {
    background: var(--bg-header-pill);
    color: var(--text-primary);
}

.loading-icon {
    display: none;
    width: 14px;
    height: 14px;
    border: 2px solid var(--accent-primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin-left: 4px;
}

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

/* --- HEADER & TOOLBAR BUTTONS --- */
.toggle-mode,
.refresh-feeds,
.toggle-sidebar {
    width: 34px;
    height: 34px;
    padding: 0;
    background: transparent;
    border: none;
    font-size: 1.15em;
    cursor: pointer;
    color: var(--accent-primary);
    border-radius: 6px;
    transition: background-color 0.2s, transform 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.toggle-mode:hover,
.refresh-feeds:hover,
.toggle-sidebar:hover {
    background-color: var(--bg-header-pill);
    transform: scale(1.08);
}

/* --- MAIN CONTENT & PINNED TOP CONTROLS --- */
.main-content {
    flex: 1 1 auto;
    align-self: stretch;
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
}

.panel-top-controls {
    position: sticky;
    top: 0;
    z-index: 50;
    background-color: var(--bg-sidebar);
}

.panel-top-controls .top-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    margin-bottom: 10px;
}

.panel-top-controls .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    width: auto;
    flex-shrink: 0;
    margin-bottom: 0;
}

.panel-top-controls .sidebar-header h1 {
    font-family: 'Play', sans-serif;
    font-size: 1.45em;
    font-weight: 700;
    color: var(--brand-color);
    letter-spacing: 0.5px;
    line-height: 1.1;
    white-space: nowrap;
}

.panel-top-controls .header-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.panel-top-controls h1#feed-title {
    margin: 0 0 0 auto;
    font-size: 1.35em;
    text-align: right;
    width: fit-content;
    max-width: 100%;
}

.header-controls {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-bottom: 4px;
    pointer-events: auto;
}

.header-controls button {
    pointer-events: auto;
}

h1#feed-title {
    text-align: center;
    color: var(--accent-title);
    font-size: 1.45em;
    font-weight: 700;
    margin: 0 auto 10px;
    background-color: var(--bg-header-pill);
    padding: 8px 22px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    width: fit-content;
    cursor: pointer;
    transition: border-color 0.2s ease, transform 0.15s ease;
}

h1#feed-title:hover {
    border-color: var(--accent-primary);
}

.input-group {
    display: flex;
    gap: 8px;
    margin-bottom: 0;
    align-items: center;
    width: 100%;
}

.input-group input[type="text"] {
    flex: 1 1 auto;
    min-width: 160px;
}

.input-group button {
    flex-shrink: 0;
    white-space: nowrap;
}

input[type="text"],
select.modal-input {
    flex: 1;
    padding: 11px 14px;
    font-size: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    background: var(--bg-input);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(77, 171, 247, 0.2);
}

button {
    padding: 11px 20px;
    font-size: 15px;
    font-weight: 600;
    background-color: var(--accent-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.15s;
    touch-action: manipulation;
}

button:hover:not(:disabled) {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#add-to-favorites,
#delete-from-favorites,
#edit-from-favorites {
    font-size: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    padding: 8px 10px;
    display: none;
}

/* --- EDITORIAL FEED CARDS --- */
#feed {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    max-width: 100%;
}

.feed-item {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    width: 100%;
    max-width: 100%;
    background: var(--bg-card);
    padding: 16px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    opacity: 0;
    animation: fadeIn 0.35s ease forwards;
    transition: background-color 0.2s, transform 0.2s, border-color 0.2s;
}

.feed-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-primary);
}

.feed-item img {
    width: 175px;
    height: 118px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    background: var(--bg-input);
}

.feed-item-body {
    flex: 1;
    min-width: 0;
}

.feed-item h2 {
    font-size: 1.18em;
    font-weight: 600;
    line-height: 1.35;
    margin-bottom: 6px;
}

.feed-item h2 a {
    color: var(--accent-primary);
    text-decoration: none;
}

.feed-item h2 a:visited {
    color: var(--accent-visited);
}

.feed-item h2 a:hover {
    text-decoration: underline;
}

.feed-item p {
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.95em;
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.feed-item .meta {
    font-size: 0.82em;
    color: var(--text-muted);
    font-weight: 500;
}

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

.feed-item-placeholder {
    background: var(--bg-card);
    border-radius: 10px;
    height: 110px;
    position: relative;
    overflow: hidden;
}

.feed-item-placeholder::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
    animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
    100% { left: 100%; }
}

/* --- NOTIFICATIONS & MODALS --- */
#error {
    color: #51cf66;
    text-align: center;
    margin-bottom: 14px;
    display: none;
    font-size: 0.92em;
    font-weight: 500;
    width: 100%;
    max-width: 100%;
}

#error.notification {
    color: var(--accent-title);
}

footer {
    text-align: center;
    padding: 18px;
    font-style: italic;
    font-size: 0.85em;
    color: var(--text-muted);
    margin-top: auto; 
    padding-bottom: 4px;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.72);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal {
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.modal h2 {
    margin-bottom: 14px;
}

.modal input[type="text"] {
    width: 100%;
    margin-bottom: 14px;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

#modal-cancel-btn,
#edit-modal-cancel-btn {
    background-color: var(--text-muted);
}

/* --- RESPONSIVE MOBILE --- */
@media (max-width: 700px) {
    body {
        padding: 8px;
    }

    .container {
        flex-direction: column;
        padding: 10px;
        gap: 10px;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        max-width: 320px;
        height: 100%;
        border-radius: 0;
        transform: translateX(-100%);
        overflow-y: auto;
    }

    .sidebar:not(.sidebar-hidden) {
        transform: translateX(0);
    }

    .sidebar:not(.sidebar-hidden) + .sidebar-overlay {
        display: block;
    }

    .input-group {
        flex-direction: column;
        align-items: stretch;
    }

    .feed-item {
        flex-direction: column;
    }

    .feed-item img {
        width: 100%;
        height: 190px;
    }
}

/* --- DESKTOP INDEPENDENT SCROLLING & HIDDEN SCROLLBARS --- */
@media (min-width: 701px) {
    .container {
        height: calc(100dvh - 24px);
        min-height: 0;
        overflow: hidden;
    }

    .sidebar {
        position: static;
        height: 100%;
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .sidebar::-webkit-scrollbar {
        display: none;
    }

    .sidebar ul {
        max-height: none;
        overflow-y: visible;
    }

    .main-content {
        height: 100%;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .main-content::-webkit-scrollbar {
        display: none;
    }
}

/* --- READER MODE VIEW --- */
.reader-article {
    max-width: 740px;
    margin: 0 auto;
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 28px 32px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.reader-meta {
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-primary);
    font-weight: 700;
    margin-bottom: 8px;
}

.reader-article h1 {
    font-size: 1.75em;
    line-height: 1.3;
    color: var(--text-primary);
    margin-bottom: 18px;
}

.reader-hero-img {
    width: 100%;
    max-height: 420px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 22px;
}

.reader-body p {
    font-size: 1.08em;
    line-height: 1.8;
    color: var(--text-secondary);
    margin-bottom: 18px;
}

@media (max-width: 700px) {
    .reader-article {
        padding: 18px 16px;
    }

    .reader-article h1 {
        font-size: 1.4em;
    }
}

/* --- FLOATING TOAST NOTIFICATION --- */
.toast-banner {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 9999;
    background: var(--bg-card);
    color: var(--accent-title);
    border: 1px solid var(--accent-primary);
    padding: 14px 22px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    font-size: 0.95em;
    font-weight: 600;
    opacity: 0;
    transform: translate(-50%, calc(-50% + 10px));
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
    max-width: min(90vw, 480px);
    text-align: center;
}

.toast-banner.show {
    opacity: 1;
    transform: translate(-50%, -50%);
}

/* --- SPORTS SCOREBOARD --- */
.scoreboard-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.scoreboard-updated {
    font-size: 0.88em;
    color: var(--text-muted);
    font-weight: 500;
}

#refresh-scores-btn {
    padding: 7px 14px;
    font-size: 0.88em;
}

.scoreboard-league {
    margin-bottom: 26px;
}

.scoreboard-league-title {
    font-size: 1.15em;
    font-weight: 700;
    color: var(--accent-title);
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
}

.scoreboard-empty {
    color: var(--text-muted);
    font-size: 0.92em;
    padding: 8px 4px;
}

.scoreboard-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    max-width: 100%;
}

.sb-card {
    display: block;
    text-decoration: none;
    width: max-content;
    min-width: 240px;
    max-width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 14px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.sb-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.sb-card.sb-favorite {
    border-left: 4px solid var(--accent-title);
}

.sb-card.sb-live {
    border-color: #ff6b6b;
}

.sb-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78em;
    margin-bottom: 10px;
    color: var(--text-muted);
    font-weight: 600;
}

.sb-status-live {
    color: #ff6b6b;
    font-weight: 700;
}

.sb-broadcast {
    background: var(--bg-header-pill);
    color: var(--text-secondary);
    padding: 2px 7px;
    border-radius: 4px;
}

.sb-team-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    color: var(--text-secondary);
}

.sb-team-row.sb-winner {
    color: var(--text-primary);
    font-weight: 700;
}

.sb-team-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.sb-team-logo {
    width: 22px;
    height: 22px;
    object-fit: contain;
    flex-shrink: 0;
}

.sb-team-name {
    font-size: 0.95em;
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
}

.sb-team-record {
    font-size: 0.8em;
    color: var(--text-muted);
}

.sb-team-score {
    font-size: 1.05em;
    font-variant-numeric: tabular-nums;
    margin-left: 8px;
}

/*==================================*/

.scoreboard-date-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sb-date-btn {
    padding: 5px 10px;
    font-size: 0.9em;
    line-height: 1.2;
}

.sb-date-label {
    font-size: 0.92em;
    font-weight: 700;
    color: var(--text-primary);
    background: var(--bg-header-pill);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 5px 12px;
    cursor: pointer;
    white-space: nowrap;
}

.sb-date-label:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}