:root {
    --primary-color: #2563eb;
    --bg-color: #efefef;
    --text-color: #1f2937;
    --border-color: #f3f4f6;
    --tag-bg: #f3f4f6;
    --date-bg: #fef3c7;
    --category-bg: #e0e7ff;
    --container-bg: #ffffff;
    --date-text: #92400e;
    --category-text: #3730a3;
    --attention-bg: #fee2e2;
    --attention-text: #991b1b;
    --hover-bg: #e5e7eb;
    --hover-text: #707070;
    --link-underline: #cccccc;
}

:root.dark-mode {
    --primary-color: #3b82f6;
    --bg-color: #111827;
    --text-color: #e5e7eb;
    --border-color: #374151;
    --tag-bg: #1f2937;
    --date-bg: #78350f;
    --category-bg: #312e81;
    --container-bg: #1f2937;
    --date-text: #fef3c7;
    --category-text: #e0e7ff;
    --category-link-bg: #2d3748;
    --attention-bg: #7f1d1d;
    --attention-text: #ffffff;
    --hover-bg: #4b5563;
    --hover-text: #e5e7eb;
    --link-underline: #4b5563;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background: var(--bg-color);
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 50rem;
    width: 90%;
    margin: 1.25rem auto;
    padding: 2.1875rem 4.375rem 4.6875rem;
    background: var(--container-bg);
    border-radius: 0.9375rem;
    transition: background-color 0.3s;
    position: relative;
}

.header {
    text-align: center;
    margin: 0.8rem 0 1.25rem;
    position: relative;
}

.header img {
    width: 9.375rem;
    height: auto;
}

.categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.category-link {
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    background: var(--tag-bg);
    color: var(--text-color);
    font-size: 0.875rem;
    transition: background 0.2s, color 0.2s;
}

:root.dark-mode .category-link:not(.active):not(:hover) {
    background: var(--category-link-bg);
}

.category-link:hover,
.category-link.active {
    background: var(--primary-color);
    color: white;
}

:root.dark-mode .category-link:hover {
    background: var(--primary-color);
    color: white;
}

.news-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.news-item {
    display: flex;
    gap: 1rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.feed-logo {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    object-fit: cover;
    margin-top: 0.3125rem;
}

.news-content {
    flex: 1;
    overflow: hidden;
}

.news-title {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.news-title a {
    color: var(--text-color);
    text-decoration: none;
}

.news-title a:hover {
    color: var(--primary-color);
}

.news-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.meta-tag {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
}

.date-tag {
    background: var(--date-bg);
    color: var(--date-text);
}

.category-tag {
    background: var(--category-bg);
    color: var(--category-text);
}

.attention-tag {
    background: var(--attention-bg);
    color: var(--attention-text);
}

.news-description {
    font-size: 0.875rem;
    color: var(--text-color);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.page-link {
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    background: var(--tag-bg);
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.875rem;
}

.page-link.active,
.page-link:hover:not(.active) {
    background: var(--primary-color);
    color: white;
}

.page-content {
    line-height: 1.6;
    color: var(--text-color);
}

.page-content h2 {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
    line-height: 1.4;
    text-align: center;
}

.page-content p {
    font-size: 0.875rem;
    color: var(--text-color);
    padding-bottom: 0.9375rem;
    text-align: justify;
    text-justify: inter-word;
}

.page-content ol {
    counter-reset: item;
    padding-left: 0;
    margin-bottom: 1rem;
}

.page-content li {
    display: block;
    margin-bottom: 0.75rem;
    padding-left: 1.5rem;
    position: relative;
    font-size: 0.875rem;
    color: var(--text-color);
    line-height: 1;
}

.page-content li:before {
    content: counter(item) ".";
    counter-increment: item;
    position: absolute;
    left: 0;
    top: 0;
    color: var(--text-color);
    font-weight: 500;
    font-size: 0.875rem;
}

.page-content ol + p {
    margin-top: 1rem;
}

.page-content a,
.page-content a:visited {
    color: var(--text-color);
    text-decoration: none;
    padding: 0.0625rem;
    border-bottom: 0.1875rem solid var(--link-underline);
}

.page-content a:hover {
    color: #ffffff;
    background-color: var(--primary-color);
    text-decoration: none;
    padding: 0.125rem;
}

.footer {
    font-size: 0.75rem;
    color: var(--text-color);
    padding: 0.625rem 0;
    text-align: center;
    margin: 1.25rem 0;
    line-height: 1.25rem;
}

.footer a {
    color: var(--text-color);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

.footer .footer-links a {
    margin: 0 0.3125rem;
}

#scrollToTopBtn {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    width: 3.125rem;
    height: 3.125rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s, background-color 0.3s;
    box-shadow: 0 0.125rem 0.625rem rgba(0, 0, 0, 0.1);
}

#scrollToTopBtn:hover {
    background-color: #1e40af;
}

#scrollToTopBtn svg {
    width: 1.5rem;
    height: 1.5rem;
}

#scrollToTopBtn.show {
    opacity: 1;
}

.dark-mode-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.3125rem;
    position: absolute;
    top: -1.5625rem;
    right: -3.125rem;
    z-index: 1000;
}

.dark-mode-toggle svg {
    width: 1.5rem;
    height: 1.5rem;
    fill: var(--text-color);
    transition: fill 0.3s;
}

@media (max-width: 40rem) {
    .container {
        margin: 0.9375rem auto;
        width: 95%;
        padding: 1.5625rem 1.25rem 3.125rem;
    }

    .news-item {
        gap: 0.75rem;
    }

    .feed-logo {
        width: 2.5rem;
        height: 2.5rem;
    }

    .news-title {
        font-size: 1rem;
    }

    .header img {
        width: 8rem;
    }

    .page-content {
        padding: 0 1.5625rem;
    }

    #scrollToTopBtn {
        width: 2.5rem;
        height: 2.5rem;
        bottom: 0.9375rem;
        right: 0.9375rem;
    }

    #scrollToTopBtn svg {
        width: 1.25rem;
        height: 1.25rem;
    }

    .dark-mode-toggle {
        top: -1.5rem;
        right: -0.625rem;
    }

    .dark-mode-toggle svg {
        width: 1.25rem;
        height: 1.25rem;
    }
}