:root {
    --bg-color: #ffffff;
    --text-color: #222222;
    --accent-color: #000000;
    --gray-color: #888888;
    --light-gray: #f5f5f5;
    --border-color: #eaeaea;
    --card-hover-bg: #fafafa;
    
    /* 字体设置 */
    --font-serif: 'Cormorant Garamond', serif;
    --font-sans: 'Inter', sans-serif;
    --font-mono: 'Menlo', 'Monaco', 'Courier New', monospace;
    
    /* 尺寸 */
    --header-height-expanded: 140px;
    --header-height-collapsed: 70px;
    --content-width: 800px;
}

[data-theme="dark"] {
    --bg-color: #111111;
    --text-color: #e0e0e0;
    --accent-color: #ffffff;
    --gray-color: #999999;
    --light-gray: #1a1a1a;
    --border-color: #333333;
    --card-hover-bg: #161616;
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-sans);
    margin: 0;
    padding: 0;
    line-height: 1.8;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Header Styles */
#site-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-height-expanded);
    display: flex;
    align-items: center;
    padding: 0 5vw;
    z-index: 1000;
    transition: height 0.5s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.3s ease;
    background-color: rgba(255, 255, 255, 0); /* 初始透明 */
}

/* 滚动时增加背景模糊 */
#site-header.scrolled {
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
}

[data-theme="dark"] #site-header.scrolled {
    background-color: rgba(17, 17, 17, 0.9);
}

#logo {
    font-family: var(--font-serif);
    font-size: 3rem;
    font-weight: 600;
    margin: 0;
    color: var(--accent-color);
    letter-spacing: -0.02em;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
    transform-origin: left center;
    cursor: pointer;
}

/* Theme Toggle Button */
#theme-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    margin-left: auto; /* 靠右对齐 */
    color: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

#theme-toggle:hover {
    background-color: var(--light-gray);
}

#theme-toggle:active {
    transform: scale(0.95);
}

#theme-toggle svg {
    width: 20px;
    height: 20px;
    stroke-width: 2px;
}

/* 图标切换逻辑 */
#theme-toggle .icon-moon {
    display: none;
}

#theme-toggle .icon-sun {
    display: block;
}

[data-theme="dark"] #theme-toggle .icon-moon {
    display: block;
}

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

/* Collapsed State (缩小折叠) */
#site-header.collapsed {
    height: var(--header-height-collapsed);
}

#site-header.collapsed #logo {
    transform: scale(0.6);
}

/* Content Container */
#content-container {
    max-width: var(--content-width);
    margin: 0 auto;
    padding-top: calc(var(--header-height-expanded) + 40px);
    padding-bottom: 120px;
    padding-left: 20px;
    padding-right: 20px;
    min-height: 100vh;
}

/* Views Management */
.view {
    opacity: 1;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.view.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

.view.fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Home View Styles */
.hero-search {
    margin-bottom: 60px;
    position: relative;
}

#search-input {
    width: 100%;
    padding: 20px 0;
    font-family: var(--font-serif);
    font-size: 2.5rem;
    border: none;
    border-bottom: 2px solid var(--border-color);
    background: transparent;
    color: var(--accent-color);
    outline: none;
    transition: border-color 0.3s ease;
}

#search-input::placeholder {
    color: var(--gray-color);
    opacity: 0.5;
}

#search-input:focus {
    border-color: var(--accent-color);
}

/* Topics Section */
#topics-section {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 60px;
}

.topic-tag {
    font-size: 0.9rem;
    padding: 6px 16px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--gray-color);
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
}

.topic-tag:hover, .topic-tag.active {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.topic-tag.active {
    background-color: var(--accent-color);
    color: var(--bg-color);
}

/* Articles List */
.article-card {
    padding: 30px 0;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

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

.article-card:hover h2 {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
}

.article-meta {
    font-size: 0.85rem;
    color: var(--gray-color);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.article-title {
    font-family: var(--font-serif);
    font-size: 2rem;
    margin: 0 0 12px 0;
    color: var(--accent-color);
    line-height: 1.2;
}

.article-excerpt {
    font-size: 1rem;
    color: var(--text-color);
    margin: 0;
    opacity: 0.8;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Markdown Typography */
.markdown-body {
    font-size: 1.125rem; /* 18px */
}

.markdown-body h1, 
.markdown-body h2, 
.markdown-body h3, 
.markdown-body h4, 
.markdown-body h5, 
.markdown-body h6 {
    font-family: var(--font-serif);
    color: var(--accent-color);
    margin-top: 2.5em;
    margin-bottom: 1em;
    line-height: 1.2;
    font-weight: 600;
}

.markdown-body h1 {
    font-size: 3.5rem;
    line-height: 1.1;
    margin-top: 0; /* 第一个标题不需要 margin-top */
    letter-spacing: -0.03em;
}

.markdown-body h2 {
    font-size: 2.25rem;
    letter-spacing: -0.02em;
}

.markdown-body h3 {
    font-size: 1.75rem;
}

.markdown-body p {
    margin-bottom: 1.8em;
    color: var(--text-color); /* 适配主题色 */
    font-weight: 300;
}

.markdown-body strong {
    font-weight: 600;
    color: var(--accent-color);
}

.markdown-body em {
    font-family: var(--font-serif);
    font-style: italic;
}

.markdown-body a {
    color: var(--accent-color);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
    transition: opacity 0.2s;
}

.markdown-body a:hover {
    opacity: 0.7;
}

.markdown-body blockquote {
    margin: 2.5em 0;
    padding-left: 1.5em;
    border-left: 2px solid var(--accent-color);
    font-family: var(--font-serif);
    font-size: 1.4rem;
    font-style: italic;
    color: var(--gray-color);
    line-height: 1.6;
}

.markdown-body ul, .markdown-body ol {
    margin-bottom: 1.8em;
    padding-left: 1.5em;
}

.markdown-body li {
    margin-bottom: 0.5em;
    padding-left: 0.5em;
}

/* Code Blocks */
.markdown-body code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background-color: var(--light-gray);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    color: var(--text-color);
}

.markdown-body pre {
    background-color: var(--light-gray);
    padding: 1.5em;
    border-radius: 8px;
    overflow-x: auto;
    margin: 2em 0;
    border: 1px solid var(--border-color);
}

.markdown-body pre code {
    background-color: transparent;
    padding: 0;
    font-size: 0.9em;
    color: inherit;
}

/* Images */
.markdown-body img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 3em auto;
    border-radius: 4px;
    filter: grayscale(100%) contrast(1.1); /* 默认黑白 */
    transition: filter 0.4s ease;
}

.markdown-body img:hover {
    filter: grayscale(0%) contrast(1); /* 悬停恢复彩色 */
}

/* Divider */
.markdown-body hr {
    border: 0;
    height: 1px;
    background: var(--border-color);
    margin: 4em 0;
}

/* Footer */
#site-footer {
    text-align: center;
    padding: 60px 20px;
    border-top: 1px solid var(--border-color);
    font-family: var(--font-serif);
    font-size: 1rem;
    color: var(--gray-color);
    margin-top: 40px;
}

/* Loading State */
.loading-state {
    text-align: center;
    padding: 40px;
    color: var(--gray-color);
    font-family: var(--font-serif);
    font-style: italic;
}

/* Responsive */
@media (max-width: 768px) {
    :root {
        --header-height-expanded: 100px;
        --header-height-collapsed: 60px;
    }
    
    #logo {
        font-size: 2rem;
    }
    
    .markdown-body h1 {
        font-size: 2.5rem;
    }
    
    #content-container {
        padding-top: calc(var(--header-height-expanded) + 20px);
    }

    #search-input {
        font-size: 1.8rem;
    }
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
    transition: opacity 0.3s ease;
}

.modal.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--bg-color);
    padding: 40px;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    transform: translateY(0);
    transition: transform 0.3s ease;
}

.modal.hidden .modal-content {
    transform: translateY(20px);
}

.modal h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-family: var(--font-serif);
    font-size: 1.8rem;
    color: var(--accent-color);
}

.modal input,
.modal textarea {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-sans);
    border-radius: 4px;
    outline: none;
    transition: border-color 0.2s;
}

.modal input:focus,
.modal textarea:focus {
    border-color: var(--accent-color);
}

.modal textarea {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    resize: vertical;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal button {
    padding: 10px 20px;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

#cancel-upload {
    background: transparent;
    color: var(--gray-color);
}

#cancel-upload:hover {
    color: var(--accent-color);
    background: var(--light-gray);
}

#confirm-upload {
    background: var(--accent-color);
    color: var(--bg-color);
}

#confirm-upload:hover {
    opacity: 0.9;
}

#confirm-upload:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Footer Upload Trigger */
#footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    /* 背景透明，不显眼 */
    pointer-events: none; 
    z-index: 100;
}

#upload-trigger {
    pointer-events: auto;
    background: transparent;
    border: none;
    color: var(--border-color); /* 颜色很浅，几乎看不见 */
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.3s ease, transform 0.3s ease;
    padding: 10px;
}

#upload-trigger:hover {
    color: var(--gray-color);
    transform: scale(1.2);
}
