:root {
    /* 淺色模式 (預設) */
    --bg-color: #ffffff;
    --text-color: #1a1a1a;
    --text-muted: #64748b;
    --accent-color: #334155; /* 改為深灰色 */
    --card-bg: #fdfdfd;
    --border-color: #eef0f2;
    --nav-bg: rgba(255, 255, 255, 0.9);
    --transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

[data-theme="dark"] {
    /* 深色模式 */
    --bg-color: #121212;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --accent-color: #94a3b8; /* 深色模式下的強調灰色 */
    --card-bg: #1e1e1e;
    --border-color: #2d2d2d;
    --nav-bg: rgba(18, 18, 18, 0.9);
}

/* 主題切換按鈕樣式 */
.theme-toggle {
    background: var(--border-color);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--text-color);
    transition: var(--transition);
}

.theme-toggle:hover {
    transform: scale(1.05);
    background: var(--accent-color);
    color: white;
}

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

body {
    font-family: 'Inter', 'Noto Sans TC', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: var(--transition);
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
}

header {
    padding: 60px 0 30px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

#logo {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -1px;
    margin: 0;
}

.search-container {
    flex: 1;
    max-width: 300px;
    margin-left: 20px;
}

#search-input {
    width: 100%;
    padding: 10px 15px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

#search-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(0,0,0,0.05);
}

.subtitle {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 300;
    text-align: left;
}

#category-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--nav-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    padding: 15px 0;
    margin-bottom: 40px;
    transition: var(--transition);
}

#categories {
    display: flex;
    list-style: none;
    overflow-x: auto;
    gap: 20px;
    scrollbar-width: none;
}

#categories::-webkit-scrollbar {
    display: none;
}

#categories li {
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
    color: var(--text-muted);
    transition: var(--transition);
    padding-bottom: 5px;
    border-bottom: 2px solid transparent;
}

#category-nav li:hover, #category-nav li.active {
    color: var(--text-color);
    border-bottom-color: var(--accent-color);
}

#source-nav {
    border-bottom: 1px solid var(--border-color);
    padding: 10px 0;
    margin-bottom: 30px;
    background: var(--bg-color);
    transition: var(--transition);
}

#sources {
    display: flex;
    list-style: none;
    overflow-x: auto;
    gap: 15px;
    scrollbar-width: none;
}

#sources li {
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
    color: var(--text-muted);
    transition: var(--transition);
    padding: 2px 10px;
    border-radius: 15px;
    border: 1px solid var(--border-color);
}

#sources li:hover, #sources li.active {
    color: var(--text-color);
    background: var(--border-color);
}

.news-grid {
    display: flex;
    flex-direction: column;
    gap: 40px;
    margin-bottom: 80px;
}

.article-card {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 40px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.article-card:last-child {
    border-bottom: none;
}

.article-body {
    display: flex;
    gap: 25px;
    align-items: flex-start;
}

.article-content {
    flex: 1;
}

.article-image {
    width: 200px;
    height: 140px;
    object-fit: cover;
    border-radius: 8px;
    background: var(--border-color);
    flex-shrink: 0; /* 防止圖片被擠壓 */
}

/* 修正：防止摘要中的圖片或其他元素塞爆頁面 */
.article-card img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

.article-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    display: flex;
    gap: 15px;
}

.article-source {
    font-weight: 600;
    color: var(--text-color);
}

.article-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 15px;
    line-height: 1.3;
}

.article-title a {
    text-decoration: none;
    color: var(--text-color);
    transition: var(--transition);
}

.article-title a:hover {
    opacity: 0.7;
}

.article-summary {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 300;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

footer {
    padding: 40px 0;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.article-card.read .article-title a {
    color: var(--text-muted);
}

.article-card.read .article-summary {
    opacity: 0.6;
}

.article-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.bookmark-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-muted);
    transition: var(--transition);
    padding: 0 5px;
}

.bookmark-btn:hover {
    color: var(--accent-color);
}

.bookmark-btn.active {
    color: #ffcc00;
}

@media (max-width: 600px) {
    header {
        padding: 40px 0 20px;
    }
    
    #logo {
        font-size: 2rem;
    }
    
    .article-title {
        font-size: 1.25rem;
    }
}
