/* ============================
   ދިވެހި ނިއުސް — Dhivehi News
   All Features CSS
   ============================ */

@font-face {
    font-family: 'MVTyper';
    src: url('fonts/mvtyper.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* --- Tokens (Dark) --- */
:root,
[data-theme="dark"] {
    --bg: #0a0a0f;
    --bg-surface: #12121a;
    --bg-card: #1a1a26;
    --bg-card-hover: #22222f;
    --bg-glass: rgba(26, 26, 38, 0.7);
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --text: #e8e8ec;
    --text-secondary: #9a9aaf;
    --text-muted: #5a5a72;
    --accent: #818cf8;
    --accent-glow: rgba(129, 140, 248, 0.15);
    --shadow-card: 0 16px 48px rgba(0, 0, 0, 0.35);
    --shadow-hero: 0 20px 60px rgba(0, 0, 0, 0.4);
    --header-bg: rgba(10, 10, 15, 0.85);
    --badge-bg: rgba(0, 0, 0, 0.5);
    --shimmer-color: rgba(255, 255, 255, 0.03);
    --inset-shine: rgba(255, 255, 255, 0.04);
    --glow-secondary: rgba(239, 68, 68, 0.05);
    --ticker-bg: #1a0a0a;
    --positive: #10b981;
    --negative: #ef4444;
    --neutral: #6b7280;
    --dhauru: #10b981;
    --sun: #f59e0b;
    --psm: #6366f1;
    --oneonline: #ef4444;
    --mihaaru: #ec4899;
    --avas: #06b6d4;
    --radius: 16px;
    --radius-sm: 10px;
    --font-dv: 'MVTyper', 'MV Faseyha', 'Faruma', 'MV Waheed', sans-serif;
    --font-en: 'Inter', sans-serif;
    --max-width: 1200px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Light --- */
[data-theme="light"] {
    --bg: #f5f5f7;
    --bg-surface: #eaeaef;
    --bg-card: #ffffff;
    --bg-card-hover: #f8f8fc;
    --bg-glass: rgba(255, 255, 255, 0.75);
    --border: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.15);
    --text: #1a1a2e;
    --text-secondary: #555568;
    --text-muted: #8888a0;
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.08);
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.08);
    --shadow-hero: 0 12px 40px rgba(0, 0, 0, 0.1);
    --header-bg: rgba(245, 245, 247, 0.88);
    --badge-bg: rgba(255, 255, 255, 0.85);
    --shimmer-color: rgba(0, 0, 0, 0.04);
    --inset-shine: rgba(255, 255, 255, 0.5);
    --glow-secondary: rgba(99, 102, 241, 0.04);
    --ticker-bg: #fef2f2;
    --dhauru: #059669;
    --sun: #d97706;
    --psm: #4f46e5;
    --oneonline: #dc2626;
    --mihaaru: #db2777;
    --avas: #0891b2;
}

/* --- Reset --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box
}

html {
    scroll-behavior: smooth
}

body {
    font-family: var(--font-dv);
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    line-height: 1.8;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    transition: background var(--transition), color var(--transition)
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: radial-gradient(circle at 20% 20%, var(--accent-glow) 0%, transparent 50%), radial-gradient(circle at 80% 80%, var(--glow-secondary) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0
}

a {
    color: inherit;
    text-decoration: none
}

img {
    display: block;
    max-width: 100%
}

/* ========= TICKER ========= */
.ticker {
    background: var(--ticker-bg);
    border-bottom: 1px solid rgba(239, 68, 68, 0.15);
    display: flex;
    align-items: center;
    overflow: hidden;
    height: 36px
}

.ticker-label {
    flex-shrink: 0;
    padding: 0 14px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    height: 100%;
    display: flex;
    align-items: center;
    gap: 6px;
    border-left: 1px solid rgba(239, 68, 68, 0.15);
    white-space: nowrap
}

.ticker-track {
    flex: 1;
    overflow: hidden;
    height: 100%;
    display: flex;
    align-items: center
}

.ticker-content {
    display: flex;
    gap: 50px;
    white-space: nowrap;
    animation: tickerScroll 45s linear infinite;
    padding-right: 20px;
    font-size: 0.8rem;
    color: var(--text-secondary)
}

.ticker-content a {
    white-space: nowrap;
    transition: color 0.2s
}

.ticker-content a:hover {
    color: var(--accent)
}

.ticker-separator {
    color: var(--text-muted);
    opacity: 0.4
}

@keyframes tickerScroll {
    0% {
        transform: translateX(0)
    }

    100% {
        transform: translateX(50%)
    }
}

/* ========= HEADER ========= */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--header-bg);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border-bottom: 1px solid var(--border);
    transition: background var(--transition)
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 8px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    text-decoration: none
}

.brand-icon {
    flex-shrink: 0
}

.brand-name {
    font-size: 1.3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent) 0%, #a78bfa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text
}

.search-wrap {
    flex: 1;
    max-width: 360px;
    position: relative;
    display: flex;
    align-items: center
}

.search-icon {
    position: absolute;
    right: 12px;
    font-size: 0.8rem;
    pointer-events: none;
    z-index: 1
}

.search-input {
    width: 100%;
    padding: 8px 36px 8px 44px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-dv);
    font-size: 0.85rem;
    outline: none;
    transition: all var(--transition);
    direction: rtl
}

.search-input::placeholder {
    color: var(--text-muted)
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow)
}

.search-kbd {
    position: absolute;
    left: 8px;
    font-family: var(--font-en);
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    pointer-events: none
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all var(--transition);
    position: relative
}

.icon-btn:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
    transform: scale(1.05)
}

.bookmark-count {
    position: absolute;
    top: -4px;
    left: -4px;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-family: var(--font-en);
    font-size: 0.6rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-en);
    font-size: 0.8rem;
    color: var(--text-secondary)
}

.theme-toggle {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    transition: all var(--transition);
    font-size: 1rem
}

.theme-toggle:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
    transform: scale(1.05)
}

.theme-toggle:active {
    transform: scale(0.95)
}

.theme-icon-sun,
.theme-icon-moon {
    position: absolute;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1)
}

[data-theme="dark"] .theme-icon-sun,
:root:not([data-theme]) .theme-icon-sun {
    opacity: 1;
    transform: rotate(0) scale(1)
}

[data-theme="dark"] .theme-icon-moon,
:root:not([data-theme]) .theme-icon-moon {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5)
}

[data-theme="light"] .theme-icon-moon {
    opacity: 1;
    transform: rotate(0) scale(1)
}

[data-theme="light"] .theme-icon-sun {
    opacity: 0;
    transform: rotate(90deg) scale(0.5)
}

.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    animation: pulse-dot 2s ease-in-out infinite
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4)
    }

    50% {
        opacity: 0.7;
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0)
    }
}

/* ========= TRENDING BAR ========= */
.trending-bar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border)
}

.trending-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 8px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    overflow-x: auto;
    scrollbar-width: none
}

.trending-inner::-webkit-scrollbar {
    display: none
}

.trending-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--accent);
    white-space: nowrap;
    flex-shrink: 0
}

.trending-tags {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap
}

.trending-tag {
    padding: 4px 12px;
    border-radius: 100px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    font-size: 0.72rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap
}

.trending-tag:hover {
    border-color: var(--accent);
    color: var(--accent)
}

.trending-tag.active {
    background: var(--accent-glow);
    border-color: var(--accent);
    color: var(--accent)
}

/* ========= TABS ========= */
.source-tabs {
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky;
    top: 53px;
    z-index: 90;
    transition: background var(--transition)
}

.tabs-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    gap: 2px;
    overflow-x: auto;
    scrollbar-width: none;
    align-items: center
}

.tabs-inner::-webkit-scrollbar {
    display: none
}

.tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-dv);
    font-size: 0.82rem;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: all var(--transition)
}

.tab:hover {
    color: var(--text);
    background: rgba(128, 128, 128, 0.05)
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent)
}

.tab-icon {
    font-size: 0.7rem
}

.tab-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0
}

.tab-divider {
    width: 1px;
    height: 20px;
    background: var(--border);
    flex-shrink: 0;
    margin: 0 4px
}

.category-tab {
    display: inline-flex;
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: 100px;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-dv);
    font-size: 0.72rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
    margin: 2px
}

.category-tab:hover {
    color: var(--text);
    border-color: var(--border-hover)
}

.category-tab.active {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-glow)
}

/* ========= STATS BAR ========= */
.stats-bar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    transition: background var(--transition)
}

.stats-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 8px 20px;
    display: flex;
    gap: 24px;
    align-items: center;
    flex-wrap: wrap
}

.stat {
    display: flex;
    align-items: baseline;
    gap: 6px
}

.stat-value {
    font-family: var(--font-en);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text)
}

.stat-label {
    font-size: 0.72rem;
    color: var(--text-muted)
}

.auto-refresh-stat {
    margin-right: auto;
    margin-left: 0;
    display: flex;
    align-items: center;
    gap: 6px
}

.refresh-ring {
    display: flex;
    align-items: center
}

.refresh-ring svg {
    transform: rotate(-90deg)
}

.source-health {
    display: flex;
    gap: 8px;
    align-items: center
}

.health-dot {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.65rem;
    font-family: var(--font-en);
    color: var(--text-muted)
}

.health-dot .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%
}

.health-dot .dot.up {
    background: var(--positive)
}

.health-dot .dot.down {
    background: var(--negative)
}

.health-dot .dot.slow {
    background: var(--sun)
}

/* ========= SEARCH RESULTS ========= */
.search-results-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.82rem;
    color: var(--text-secondary)
}

.clear-search-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 2px 6px;
    border-radius: 6px;
    transition: all var(--transition)
}

.clear-search-btn:hover {
    color: var(--text);
    background: var(--bg-surface)
}

/* ========= MAIN ========= */
.main {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
    min-height: 60vh
}

/* Hero */
.hero-section {
    margin-bottom: 24px
}

.hero-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all var(--transition);
    cursor: pointer;
    position: relative
}

.hero-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--accent-glow) 0%, transparent 40%);
    opacity: 0;
    transition: opacity var(--transition);
    pointer-events: none;
    z-index: 1
}

.hero-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hero)
}

.hero-card:hover::before {
    opacity: 1
}

.hero-card.focused {
    outline: 2px solid var(--accent);
    outline-offset: 2px
}

.hero-img-wrap {
    position: relative;
    overflow: hidden;
    aspect-ratio: 16/10
}

.hero-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease
}

.hero-card:hover .hero-img-wrap img {
    transform: scale(1.05)
}

.hero-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    position: relative;
    z-index: 2
}

.hero-content .source-badge {
    align-self: flex-start
}

.hero-content h2 {
    font-size: 1.3rem;
    line-height: 1.7;
    font-weight: 700;
    color: var(--text)
}

.hero-content .meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-family: var(--font-en)
}

.hero-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 2px
}

/* Sentiment indicator on cards */
.sentiment-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0
}

.sentiment-dot.positive {
    background: var(--positive)
}

.sentiment-dot.negative {
    background: var(--negative)
}

.sentiment-dot.neutral {
    background: var(--neutral)
}

/* Grid */
.news-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px
}

.news-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all var(--transition);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    position: relative
}

.news-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius);
    box-shadow: inset 0 1px 0 var(--inset-shine);
    pointer-events: none
}

.news-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-3px);
    box-shadow: var(--shadow-card);
    background: var(--bg-card-hover)
}

.news-card.focused {
    outline: 2px solid var(--accent);
    outline-offset: 2px
}

/* Dedup indicator */
.news-card.is-duplicate {
    opacity: 0.5;
    order: 999
}

.news-card.is-duplicate::before {
    content: '🔄 ތަކެތިރާރު';
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 5;
    font-size: 0.6rem;
    padding: 2px 8px;
    border-radius: 100px;
    background: var(--bg-glass);
    color: var(--text-muted);
    backdrop-filter: blur(8px)
}

.card-img-wrap {
    position: relative;
    overflow: hidden;
    aspect-ratio: 16/9;
    background: var(--bg-surface)
}

.card-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease
}

.news-card:hover .card-img-wrap img {
    transform: scale(1.06)
}

.card-img-wrap .source-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2
}

.card-img-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-surface) 0%, var(--bg-card) 100%);
    font-size: 2rem;
    opacity: 0.2
}

.card-body {
    padding: 14px 16px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px
}

.card-body h3 {
    font-size: 0.9rem;
    line-height: 1.8;
    font-weight: 600;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden
}

.card-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px
}

.card-time {
    font-family: var(--font-en);
    font-size: 0.7rem;
    color: var(--text-muted)
}

.card-read-time {
    font-size: 0.65rem;
    color: var(--accent);
    opacity: 0.7;
    font-family: var(--font-en)
}

.card-actions {
    display: flex;
    gap: 2px;
    align-items: center
}

.bookmark-btn,
.share-card-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 3px;
    border-radius: 6px;
    transition: all var(--transition);
    opacity: 0.35;
    line-height: 1
}

.bookmark-btn:hover,
.share-card-btn:hover {
    opacity: 1;
    transform: scale(1.15)
}

.bookmark-btn.bookmarked {
    opacity: 1
}

.source-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--badge-bg);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border)
}

.source-badge .badge-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%
}

.source-badge[data-source="dhauru"] {
    color: var(--dhauru)
}

.source-badge[data-source="dhauru"] .badge-dot {
    background: var(--dhauru)
}

.source-badge[data-source="sun"] {
    color: var(--sun)
}

.source-badge[data-source="sun"] .badge-dot {
    background: var(--sun)
}

.source-badge[data-source="psm"] {
    color: var(--psm)
}

.source-badge[data-source="psm"] .badge-dot {
    background: var(--psm)
}

.source-badge[data-source="oneonline"] {
    color: var(--oneonline)
}

.source-badge[data-source="oneonline"] .badge-dot {
    background: var(--oneonline)
}

.source-badge[data-source="mihaaru"] {
    color: var(--mihaaru)
}

.source-badge[data-source="mihaaru"] .badge-dot {
    background: var(--mihaaru)
}

.source-badge[data-source="avas"] {
    color: var(--avas)
}

.source-badge[data-source="avas"] .badge-dot {
    background: var(--avas)
}

.card-category {
    font-size: 0.65rem;
    color: var(--accent);
    opacity: 0.7
}

/* ========= TIMELINE VIEW ========= */
.timeline-view {
    padding: 0 20px
}

.timeline {
    position: relative;
    padding-right: 30px
}

.timeline::before {
    content: '';
    position: absolute;
    right: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border)
}

.timeline-item {
    position: relative;
    padding: 16px 40px 16px 0;
    border-bottom: 1px solid var(--border)
}

.timeline-item::before {
    content: '';
    position: absolute;
    right: 5px;
    top: 24px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg);
    z-index: 1
}

.timeline-time {
    font-family: var(--font-en);
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 6px
}

.timeline-title {
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text);
    cursor: pointer;
    transition: color 0.2s
}

.timeline-title:hover {
    color: var(--accent)
}

.timeline-source {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 6px
}

.timeline-hour-label {
    font-family: var(--font-en);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent);
    padding: 12px 0 4px;
    border-bottom: 2px solid var(--accent);
    margin-bottom: 8px
}

/* ========= READING PANE ========= */
.reading-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: flex-start;
    animation: fadeIn 0.2s ease
}

.reading-pane {
    width: min(600px, 90vw);
    height: 100vh;
    background: var(--bg);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideIn 0.3s ease
}

@keyframes slideIn {
    from {
        transform: translateX(-100%)
    }

    to {
        transform: translateX(0)
    }
}

@keyframes fadeIn {
    from {
        opacity: 0
    }

    to {
        opacity: 1
    }
}

.reading-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0
}

.reading-close {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s
}

.reading-close:hover {
    background: var(--bg-surface)
}

.reading-actions {
    display: flex;
    gap: 6px
}

.reading-action-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all var(--transition);
    text-decoration: none;
    display: flex;
    align-items: center
}

.reading-action-btn:hover {
    border-color: var(--accent);
    background: var(--accent-glow)
}

.reading-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px
}

.reading-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap
}

.reading-title {
    font-size: 1.3rem;
    line-height: 1.8;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 20px
}

.reading-content {
    line-height: 2;
    font-size: 0.95rem;
    color: var(--text-secondary)
}

.reading-content img {
    border-radius: var(--radius-sm);
    margin: 16px 0;
    width: 100%
}

.reading-content p {
    margin-bottom: 14px
}

.reading-loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted)
}

.reactions-bar {
    display: flex;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    justify-content: center
}

.reaction-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 4px
}

.reaction-btn span {
    font-family: var(--font-en);
    font-size: 0.7rem;
    color: var(--text-muted)
}

.reaction-btn:hover {
    border-color: var(--accent);
    transform: scale(1.05)
}

.reaction-btn.active {
    border-color: var(--accent);
    background: var(--accent-glow)
}

/* ========= MODALS ========= */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 600;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease
}

.modal {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: min(700px, 92vw);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-hero)
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border)
}

.modal-header h2 {
    font-size: 1rem;
    color: var(--text)
}

.modal-close {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px
}

.modal-close:hover {
    background: var(--bg-surface)
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px
}

/* Analytics */
.analytics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px
}

.analytics-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px
}

.analytics-card h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px
}

.chart-bars {
    display: flex;
    flex-direction: column;
    gap: 8px
}

.chart-bar {
    display: flex;
    align-items: center;
    gap: 8px
}

.chart-bar-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    width: 60px;
    text-align: left;
    font-family: var(--font-en);
    flex-shrink: 0
}

.chart-bar-track {
    flex: 1;
    height: 20px;
    background: var(--bg-surface);
    border-radius: 4px;
    overflow: hidden;
    position: relative
}

.chart-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    padding-right: 6px
}

.chart-bar-value {
    font-size: 0.6rem;
    font-family: var(--font-en);
    color: #fff;
    font-weight: 600;
    margin-right: 4px
}

.sentiment-breakdown {
    display: flex;
    gap: 12px;
    flex-wrap: wrap
}

.sentiment-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem
}

.sentiment-item .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%
}

.sentiment-pct {
    font-family: var(--font-en);
    font-weight: 600;
    font-size: 0.85rem
}

/* Newsletter */
.newsletter-preview {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
    font-size: 0.85rem;
    line-height: 1.8;
    white-space: pre-wrap;
    direction: rtl
}

.newsletter-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    justify-content: center
}

.btn-primary {
    padding: 10px 24px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font-dv);
    font-size: 0.88rem;
    transition: all var(--transition)
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px)
}

.btn-secondary {
    padding: 10px 24px;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font-dv);
    font-size: 0.88rem;
    transition: all var(--transition)
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent)
}

/* ========= TOAST ========= */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.82rem;
    z-index: 9999;
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-card);
    animation: fadeInUp 0.3s ease;
    white-space: nowrap
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px)
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0)
    }
}

/* ========= LOADING / ERROR ========= */
.loading-state {
    padding: 0
}

.skeleton-hero {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 24px;
    height: 280px
}

.skeleton-img {
    background: var(--bg-surface);
    height: 100%
}

.skeleton-text-group {
    padding: 28px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px
}

.skeleton-line {
    height: 16px;
    background: var(--bg-surface);
    border-radius: 8px
}

.skeleton-line.w80 {
    width: 80%
}

.skeleton-line.w60 {
    width: 60%
}

.skeleton-line.w40 {
    width: 40%
}

.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px
}

.skeleton-card {
    height: 260px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius)
}

.shimmer {
    position: relative;
    overflow: hidden
}

.shimmer::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, var(--shimmer-color) 50%, transparent 100%);
    animation: shimmer 1.8s infinite
}

@keyframes shimmer {
    0% {
        transform: translateX(100%)
    }

    100% {
        transform: translateX(-100%)
    }
}

.error-state {
    text-align: center;
    padding: 60px 20px
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5
}

.error-msg {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 20px
}

.retry-btn {
    padding: 10px 28px;
    border: 1px solid var(--accent);
    background: transparent;
    color: var(--accent);
    font-family: var(--font-dv);
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition)
}

.retry-btn:hover {
    background: var(--accent);
    color: var(--bg)
}

.hidden {
    display: none !important
}

/* ========= KEYBOARD HINT ========= */
.keyboard-hint {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.7rem;
    color: var(--text-secondary);
    backdrop-filter: blur(12px);
    z-index: 200;
    white-space: nowrap;
    direction: ltr;
    font-family: var(--font-en);
    box-shadow: var(--shadow-card);
    animation: fadeInUp 0.3s ease
}

/* ========= FOOTER ========= */
.footer {
    text-align: center;
    padding: 24px 20px 20px;
    color: var(--text-muted);
    font-size: 0.75rem;
    border-top: 1px solid var(--border);
    margin-top: 40px
}

.footer-en {
    font-family: var(--font-en);
    font-weight: 600;
    color: var(--text-secondary)
}

.footer-brand {
    margin-top: 4px
}

.footer-shortcuts {
    direction: ltr;
    font-family: var(--font-en);
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    opacity: 0.5
}

.footer-shortcuts kbd {
    display: inline-block;
    padding: 1px 4px;
    border-radius: 3px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    font-family: var(--font-en);
    font-size: 0.6rem;
    margin: 0 1px
}

/* ========= ANIMATIONS ========= */
@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(16px)
    }

    to {
        opacity: 1;
        transform: translateY(0)
    }
}

.news-card,
.hero-card {
    animation: cardIn 0.4s ease forwards
}

.news-card:nth-child(1) {
    animation-delay: 0.03s
}

.news-card:nth-child(2) {
    animation-delay: 0.06s
}

.news-card:nth-child(3) {
    animation-delay: 0.09s
}

.news-card:nth-child(4) {
    animation-delay: 0.12s
}

.news-card:nth-child(5) {
    animation-delay: 0.15s
}

.news-card:nth-child(6) {
    animation-delay: 0.18s
}

/* ========= PRINT ========= */
@media print {

    .header,
    .ticker,
    .source-tabs,
    .stats-bar,
    .trending-bar,
    .footer,
    .keyboard-hint,
    .reading-overlay,
    .modal-overlay,
    .toast,
    .search-wrap,
    .header-actions {
        display: none !important
    }

    body {
        background: #fff;
        color: #000;
        direction: rtl
    }

    .main {
        max-width: 100%;
        padding: 0
    }

    .news-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px
    }

    .news-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd
    }

    .hero-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd
    }

    .card-img-wrap {
        max-height: 150px
    }
}

/* ========= RESPONSIVE ========= */

/* Tablet */
@media (max-width: 1024px) {
    .news-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .skeleton-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .analytics-grid {
        grid-template-columns: 1fr;
    }
}

/* Small tablet / Large phone */
@media (max-width: 768px) {

    /* Header: search goes full-width below brand */
    .header-inner {
        flex-wrap: wrap;
        padding: 8px 14px;
        gap: 8px;
    }

    .search-wrap {
        order: 10;
        flex: 1 1 100%;
        max-width: 100%;
    }

    .search-input {
        padding: 12px 40px 12px 50px;
        font-size: 1rem;
        border-radius: 12px;
    }

    .brand-name {
        font-size: 1.15rem;
    }

    /* Hero: single column */
    .hero-card {
        grid-template-columns: 1fr;
    }

    .hero-img-wrap {
        aspect-ratio: 16/9;
    }

    .hero-content {
        padding: 16px;
    }

    .hero-content h2 {
        font-size: 1.1rem;
    }

    .skeleton-hero {
        grid-template-columns: 1fr;
        height: auto;
    }

    /* Stats */
    .stats-inner {
        gap: 12px;
        flex-wrap: wrap;
    }

    /* Tabs: scrollable with touch momentum */
    .tabs-inner {
        padding: 0 10px;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
    }

    .tab {
        scroll-snap-align: start;
        padding: 10px 12px;
        font-size: 0.78rem;
    }

    /* Trending */
    .trending-inner {
        padding: 6px 10px;
        gap: 8px;
    }

    /* Reading pane: full screen */
    .reading-pane {
        width: 100vw;
    }

    .reading-body {
        padding: 16px;
    }

    .reading-title {
        font-size: 1.15rem;
    }

    /* Modals: near full screen */
    .modal {
        width: 96vw;
        max-height: 90vh;
        border-radius: 12px;
    }

    /* Timeline */
    .timeline {
        padding-right: 24px;
    }
}

/* Phone */
@media (max-width: 600px) {

    /* Single column grid */
    .news-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .skeleton-grid {
        grid-template-columns: 1fr;
    }

    /* Header: compact */
    .header-inner {
        padding: 8px 10px;
        gap: 6px;
    }

    .brand-name {
        font-size: 1rem;
    }

    .brand-icon {
        width: 26px;
        height: 26px;
    }

    .header-meta {
        display: none;
    }

    .header-actions {
        gap: 4px;
    }

    /* Touch-friendly button sizes (min 44px tap target) */
    .icon-btn {
        width: 38px;
        height: 38px;
        font-size: 0.95rem;
        border-radius: 10px;
        min-width: 44px;
        min-height: 44px;
    }

    .theme-toggle {
        width: 38px;
        height: 38px;
        font-size: 0.95rem;
        min-width: 44px;
        min-height: 44px;
    }

    /* Full width search */
    .search-input {
        padding: 14px 40px 14px 50px;
        font-size: 1rem;
    }

    /* Main content */
    .main {
        padding: 10px;
    }

    .hero-section {
        margin-bottom: 12px;
    }

    .hero-content {
        padding: 14px;
        gap: 8px;
    }

    .hero-content h2 {
        font-size: 1rem;
        line-height: 1.7;
    }

    .hero-actions {
        flex-wrap: wrap;
        gap: 6px;
    }

    /* Cards: bigger touch targets */
    .card-body {
        padding: 12px 14px 14px;
    }

    .card-body h3 {
        font-size: 0.88rem;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }

    .card-footer {
        gap: 4px;
        flex-wrap: wrap;
    }

    .bookmark-btn,
    .share-card-btn {
        font-size: 1rem;
        padding: 6px;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Tabs: smaller, scrollable */
    .source-tabs {
        top: auto;
        position: relative;
    }

    .tabs-inner {
        padding: 0 8px;
        gap: 0;
    }

    .tab {
        padding: 10px 10px;
        font-size: 0.75rem;
        min-height: 44px;
    }

    .tab-dot {
        width: 6px;
        height: 6px;
    }

    /* Stats: compact */
    .stats-inner {
        padding: 6px 10px;
        gap: 8px;
    }

    .stat-value {
        font-size: 0.85rem;
    }

    .stat-label {
        font-size: 0.65rem;
    }

    /* Trending */
    .trending-inner {
        padding: 6px 8px;
        gap: 6px;
    }

    .trending-label {
        font-size: 0.7rem;
    }

    .trending-tag {
        padding: 6px 10px;
        font-size: 0.68rem;
        min-height: 32px;
    }

    /* Reading pane: full screen, stacked */
    .reading-overlay {
        align-items: stretch;
    }

    .reading-pane {
        width: 100vw;
        border-left: none;
    }

    .reading-header {
        padding: 10px 12px;
    }

    .reading-actions {
        gap: 4px;
    }

    .reading-action-btn {
        padding: 8px 12px;
        min-height: 44px;
    }

    .reading-body {
        padding: 14px 12px;
    }

    .reading-title {
        font-size: 1.1rem;
        line-height: 1.7;
    }

    .reading-content {
        font-size: 0.9rem;
        line-height: 1.9;
    }

    .reading-content img {
        border-radius: 8px;
        margin: 10px 0;
    }

    /* Reactions: wrap, touch-friendly */
    .reactions-bar {
        padding: 10px 12px;
        gap: 6px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .reaction-btn {
        padding: 8px 12px;
        font-size: 0.9rem;
        min-height: 40px;
    }

    /* Modals: full screen on phone */
    .modal {
        width: 100vw;
        max-height: 100vh;
        border-radius: 12px 12px 0 0;
    }

    .modal-body {
        padding: 14px;
    }

    .analytics-card {
        padding: 12px;
    }

    .analytics-card h3 {
        font-size: 0.8rem;
    }

    .newsletter-preview {
        padding: 14px;
        font-size: 0.8rem;
        max-height: 300px;
    }

    .newsletter-actions {
        flex-direction: column;
    }

    .btn-primary,
    .btn-secondary {
        width: 100%;
        text-align: center;
        min-height: 48px;
    }

    /* Source health: compact */
    .source-health {
        gap: 4px;
    }

    .health-dot {
        font-size: 0.6rem;
    }

    /* Search results */
    .search-results-info {
        padding: 8px 12px;
        font-size: 0.78rem;
    }

    /* Keyboard hint: hide on mobile */
    .keyboard-hint {
        display: none !important;
    }

    /* Footer: compact */
    .footer {
        padding: 16px 10px 14px;
    }

    .footer-shortcuts {
        display: none;
    }

    /* Toast: wider on mobile */
    .toast {
        left: 10px;
        right: 10px;
        transform: none;
        text-align: center;
    }

    /* Timeline: phone adjustments */
    .timeline {
        padding-right: 20px;
    }

    .timeline-item {
        padding: 12px 30px 12px 0;
    }

    .timeline-title {
        font-size: 0.85rem;
    }

    .timeline-hour-label {
        font-size: 0.8rem;
    }
}

/* Very small phones */
@media (max-width: 380px) {
    .brand-name {
        font-size: 0.9rem;
    }

    .header-actions {
        gap: 2px;
    }

    .icon-btn,
    .theme-toggle {
        width: 34px;
        height: 34px;
        min-width: 38px;
        min-height: 38px;
    }

    .tab {
        padding: 8px 8px;
        font-size: 0.7rem;
    }

    .hero-content h2 {
        font-size: 0.95rem;
    }

    .card-body h3 {
        font-size: 0.82rem;
    }

    .search-input {
        font-size: 0.9rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {

    /* Remove hover transforms on touch — they feel jarring */
    .news-card:hover {
        transform: none;
    }

    .hero-card:hover {
        transform: none;
    }

    .icon-btn:hover {
        transform: none;
    }

    .theme-toggle:hover {
        transform: none;
    }

    /* Active states for touch feedback */
    .news-card:active {
        transform: scale(0.98);
        background: var(--bg-card-hover);
    }

    .hero-card:active {
        transform: scale(0.99);
    }

    .icon-btn:active {
        transform: scale(0.9);
    }

    .tab:active {
        background: rgba(128, 128, 128, 0.1);
    }

    .bookmark-btn:active,
    .share-card-btn:active {
        transform: scale(1.3);
    }

    .trending-tag:active {
        background: var(--accent-glow);
    }

    /* Smoother scrolling */
    .tabs-inner,
    .trending-inner {
        -webkit-overflow-scrolling: touch;
    }
}

/* Landscape phone */
@media (max-height: 500px) and (orientation: landscape) {
    .ticker {
        height: 28px;
    }

    .ticker-label {
        font-size: 0.65rem;
        padding: 0 10px;
    }

    .header-inner {
        padding: 4px 10px;
    }

    .stats-bar {
        display: none;
    }

    .trending-bar {
        display: none;
    }

    .news-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .reading-body {
        padding: 10px;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}