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

:root {
    --bg-primary: #121212;
    --bg-secondary: #1e1e1e;
    --bg-card: #252525;
    --bg-hover: #2a2a2a;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --text-muted: #707070;
    --accent: #8ab4f8;
    --accent-hover: #aecbfa;
    --border: #333333;
    --shadow: rgba(0, 0, 0, 0.3);
    --tech: #4caf50;
    --science: #2196f3;
    --finance: #ff9800;
    --world: #f44336;
    --politics: #9c27b0;
    --regional: #00bcd4;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    max-width: 1200px;
    margin: 0 auto;
}

.category-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex: 1;
}

.category-nav::-webkit-scrollbar {
    display: none;
}

.refresh-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.refresh-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.refresh-btn:active {
    transform: scale(0.95);
}

.category-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.category-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.category-btn.active {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
}

.articles-container {
    display: grid;
    gap: 16px;
}

@media (min-width: 768px) {
    .articles-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .articles-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

.article-card {
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border);
}

.article-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--shadow);
    border-color: var(--text-muted);
}

.article-card:active {
    transform: translateY(0);
}

/* Hide image section when image fails to load */
.article-card.image-failed .article-image {
    display: none;
}

.article-image {
    width: 100%;
    height: 160px;
    object-fit: cover;
    background: var(--bg-secondary);
}

/* Compact section for articles without images */
.compact-section {
    grid-column: 1 / -1;
    margin-top: 8px;
    margin-bottom: 8px;
}

.compact-articles {
    display: grid;
    gap: 8px;
}

@media (min-width: 768px) {
    .compact-articles {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .compact-articles {
        grid-template-columns: repeat(3, 1fr);
    }
}

.article-card-compact {
    background: var(--bg-card);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border);
    padding: 12px 16px;
}

.article-card-compact:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

.article-card-compact:active {
    transform: scale(0.99);
}

.article-card-compact .article-title {
    font-size: 14px;
    margin-bottom: 6px;
    -webkit-line-clamp: 2;
}

.article-card-compact .article-meta {
    margin-bottom: 6px;
}

.article-card-compact .article-footer {
    margin-top: 4px;
}

.article-content {
    padding: 12px 16px 16px;
}

.article-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.article-source {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.article-category {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.category-technology { background: var(--tech); color: #000; }
.category-science { background: var(--science); color: #fff; }
.category-finance { background: var(--finance); color: #000; }
.category-world { background: var(--world); color: #fff; }
.category-politics { background: var(--politics); color: #fff; }
.category-regional { background: var(--regional); color: #000; }
.category-general { background: var(--text-muted); color: #fff; }

.article-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-description {
    font-size: 13px;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 8px;
}

.article-time {
    font-size: 11px;
    color: var(--text-muted);
}

.article-score {
    font-size: 11px;
    color: var(--accent);
    margin-left: auto;
}

.article-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.loading-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 16px;
    color: var(--text-secondary);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}

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

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px 16px;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow);
    transition: transform 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.language-tag {
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 3px;
    background: var(--bg-hover);
    color: var(--text-muted);
    margin-left: 4px;
}

@media (max-width: 480px) {
    .header-content {
        padding: 10px 12px;
    }

    .category-nav {
        padding: 6px 12px 10px;
    }

    .main-content {
        padding: 12px;
    }

    .articles-container {
        gap: 12px;
    }

    .article-image {
        height: 140px;
    }
}
