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

:root {
    --bg-color: #fff;
    --text-color: #333;
    --text-secondary: #666;
    --link-color: #0066cc;
    --link-visited: #1364b6;
    --border-color: #eee;
    --toc-bg: #e3f2fd;
}

[data-theme="dark"] {
    --bg-color: #0d1525;
    --text-color: #e0e0e0;
    --text-secondary: #a0a0a0;
    --link-color: #6db3f2;
    --link-visited: #a0c4e8;
    --border-color: #333333;
    --toc-bg: #1a2332;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.6;
    max-width: 700px;
    margin: 0 auto;
    padding: 2rem 1rem;
    color: var(--text-color);
    background-color: var(--bg-color);
}

a {
    color: var(--link-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

a:visited {
    color: var(--link-visited);
}

header {
    margin-bottom: 3rem;
}

header nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.site-title {
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-color);
    text-decoration: none;
}

.site-title:visited {
    color: var(--text-color);
}

.nav-links {
    display: flex;
    align-items: center;
}

.nav-links a {
    margin-left: 1.5rem;
    color: var(--text-secondary);
}

.nav-links a:visited {
    color: var(--text-secondary);
}

.nav-links a:hover {
    color: var(--text-color);
    text-decoration: none;
}

.theme-toggle {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    margin-left: 1rem;  /* 從 1.5rem 改成 1rem */
    display: flex;
    align-items: center;
}

.theme-toggle:hover {
    color: var(--text-color);
}

.theme-toggle svg {
    vertical-align: middle;
    height: 1.4em;  /* 從 1.2em 改成 1.4em 或更大 */
    transition: transform 0.3s ease;
}


.theme-toggle:hover .sun {
    transform: rotate(-15deg);
}

.theme-toggle:hover .moon {
    transform: rotate(-15deg);
}

.theme-toggle .sun,
.theme-toggle .moon {
    display: none;
}

[data-theme="dark"] .theme-toggle .sun {
    display: inline;
}

[data-theme="light"] .theme-toggle .moon {
    display: inline;
}


main h1 {
    margin-bottom: 0.5rem;
}

main h2 {
    margin-top: 2rem;
    margin-bottom: 1rem;
}

main h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

article {
    margin-bottom: 1rem;
}

article time {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-left: 0.5rem;
}

.content {
    margin-top: 2rem;
}

.content ul, .content ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.content ul ul, .content ol ol, .content ul ol, .content ol ul {
    margin-bottom: 0;
}

.content li {
    margin-bottom: 0.25rem;
}

.content p {
    margin-bottom: 1rem;
}

main > ul {
    list-style: none;
    margin-left: 0;
}

main > ul li {
    margin-bottom: 0.5rem;
}

main > ul li time {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-left: 0.5rem;
}

footer {
    margin-top: 4rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Homepage */
.homepage-header {
    text-align: center;
    margin-bottom: 2rem;
}

.homepage-gif {
    max-width: 300px;
    width: 100%;
    height: auto;
    margin-bottom: 1rem;
    border-radius: 8px;
}

.about-header-image {
    display: block;
    margin: 0 auto 2rem;
    max-width: 300px;
    width: 100%;
    border-radius: 8px;
}

/* Contact page */
.contact-list {
    margin-top: 2rem;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 0;
    font-size: 1rem;
}

.contact-item i {
    width: 1.5rem;
    font-size: 1.2rem;
    color: var(--link-color);
}

.contact-item a {
    color: var(--text-color);
}

.contact-item a:hover {
    color: var(--link-color);
}

/* Code blocks */
.code-block {
    margin: 1.5rem 0;
    border-radius: 6px;
    overflow: hidden;
    background: #272822;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1e1e1e;
    padding: 0.4rem 0.75rem;
}

.code-lang {
    font-size: 0.75rem;
    color: #75715e;
    font-family: monospace;
}

.copy-button {
    background: none;
    border: none;
    color: #75715e;
    padding: 0.2rem 0.4rem;
    font-size: 0.7rem;
    cursor: pointer;
    font-family: monospace;
    transition: color 0.2s;
}

.copy-button:hover {
    color: #a6e22e;
}

.copy-button.copied {
    color: #a6e22e;
}

.copy-text {
    font-size: 0.75rem;
}

.code-block .highlight {
    margin: 0;
}

.code-block .highlight pre {
    margin: 0;
    padding: 1rem;
    overflow-x: auto;
    background: #272822;
}

.code-block .chroma {
    background: #272822;
}

.code-block .lntable {
    border-spacing: 0;
    padding: 0;
}

.code-block .lntd {
    padding: 0;
}

.code-block .lnt,
.code-block .ln {
    padding-right: 1rem;
    color: #75715e;
}

.code-block .lntd:last-child {
    width: 100%;
}

/* Tables */
.content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.9rem;
}

.content table th,
.content table td {
    padding: 0.75rem;
    text-align: left;
    border: 1px solid var(--border-color);
}

.content table th {
    background: var(--border-color);
    font-weight: 600;
}

.content table tr:hover {
    background: rgba(128, 128, 128, 0.05);
}

[data-theme="dark"] .content table th {
    background: #2a2a2a;
}

[data-theme="dark"] .content table tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Table of Contents */
.toc {
    background: var(--toc-bg);
    border-left: 3px solid var(--link-color);
    border-radius: 4px;
    padding: 1rem;
    margin: 1.5rem 0;
}

.toc summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-color);
    user-select: none;
}

.toc summary:hover {
    color: var(--link-color);
}

.toc nav {
    margin-top: 0.75rem;
}

.toc ul {
    list-style: disc;
    margin-left: 1rem;
    padding-left: 0;
}

.toc ul ul {
    margin-left: 1rem;
    margin-top: 0.25rem;
}

.toc li {
    margin-bottom: 0.35rem;
}

.toc > nav > ul > li {
    font-size: 0.95rem;
    font-weight: 500;
}

.toc ul ul li {
    font-size: 0.85rem;
    font-weight: 400;
}

.toc a {
    color: var(--text-color);
    text-decoration: none;
}

.toc a:hover {
    color: var(--link-color);
}

/* Tags */
.post-meta {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}

.tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tag {
    color: var(--text-secondary);
    
    padding: 0.2rem 0.6rem;
    border-radius: 3px;
    font-size: 0.8rem;
    text-decoration: none;
}

.tag:hover {
    color: white;
    text-decoration: none;
}

.tag:visited {
    color: var(--text-secondary);
}

.tag:visited:hover {
    color: white;
}

.tag-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.tag-count {
    color: var(--text-secondary);
    font-size: 0.85rem;
}


/* Language switcher */
.language-switcher {
    margin-left: 1rem;
}

.language-switcher a {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.language-switcher a:hover {
    color: var(--text-color);
}