/* =========================================================
   CSS 变量定义：亮色模式（默认）
   所有颜色、阴影、间距等可在此集中调整
   ========================================================= */
:root {
    /* 页面背景渐变 */
    --bg-gradient-from: #fef5f9;
    --bg-gradient-via: #fdf2f8;
    --bg-gradient-to: #f3e8ff;
    --bg-pattern-color: rgba(236, 72, 153, 0.03);

    /* 侧边栏 */
    --sidebar-bg: rgba(255, 255, 255, 0.75);
    --sidebar-backdrop: blur(18px);
    --sidebar-border: rgba(236, 72, 153, 0.12);
    --sidebar-shadow: 0 4px 32px rgba(180, 120, 160, 0.10);

    /* 卡片 */
    --card-bg: rgba(255, 255, 255, 0.82);
    --card-backdrop: blur(12px);
    --card-border: rgba(220, 180, 200, 0.18);
    --card-shadow: 0 2px 16px rgba(160, 120, 150, 0.07);
    --card-hover-shadow: 0 6px 28px rgba(160, 120, 150, 0.14);
    --card-hover-border: rgba(236, 72, 153, 0.22);

    /* 文字颜色 */
    --text-primary: #3d2c3a;
    --text-secondary: #6b5b68;
    --text-muted: #9a8b97;
    --text-heading: #2c1a28;

    /* 强调/交互色 */
    --accent: #e8789a;
    --accent-soft: #fce4ec;
    --accent-hover: #d46281;
    --accent-text: #c04e6e;

    /* 标签组件 */
    --tag-bg: #fef0f5;
    --tag-text: #c0607a;
    --tag-hover-bg: #fcd8e5;
    --tag-active-bg: #f9c5d7;
    --tag-active-text: #a04060;

    /* 分类组件 */
    --category-bg: #f5f0ff;
    --category-text: #7c5cbf;
    --category-hover-bg: #ede0ff;
    --category-active-bg: #e0ccff;
    --category-active-text: #5a3d9e;

    /* 搜索框 */
    --search-bg: rgba(255, 255, 255, 0.7);
    --search-border: rgba(200, 170, 185, 0.35);
    --search-focus-border: rgba(232, 120, 154, 0.55);
    --search-focus-shadow: 0 0 0 3px rgba(232, 120, 154, 0.10);

    /* 统计卡片 */
    --stat-bg: rgba(255, 255, 255, 0.55);
    --stat-border: rgba(220, 180, 200, 0.15);
    --stat-icon-color: #e8789a;

    /* 分割线 */
    --divider: rgba(200, 170, 185, 0.25);

    /* 滚动条 */
    --scrollbar-thumb: #e0c8d5;
    --scrollbar-track: transparent;

    /* 按钮 */
    --btn-bg: #fef0f5;
    --btn-text: #c0607a;
    --btn-hover-bg: #fcd8e5;

    /* 文章内图片 */
    --content-img-border: rgba(220, 180, 200, 0.3);
    --content-img-shadow: 0 2px 12px rgba(150, 100, 130, 0.08);

    /* 视频容器 */
    --video-bg: #f8f0f4;
    --video-border: rgba(200, 170, 185, 0.25);

    /* 返回按钮 */
    --back-btn-bg: rgba(255, 255, 255, 0.7);
    --back-btn-hover: rgba(255, 255, 255, 0.9);

    /* 加载动画 */
    --loader-color: #e8789a;
}

/* =========================================================
   CSS 变量覆盖：暗色模式
   ========================================================= */
body.dark-mode {
    --bg-gradient-from: #1a1625;
    --bg-gradient-via: #1f1a2e;
    --bg-gradient-to: #1c1a2c;
    --bg-pattern-color: rgba(180, 140, 200, 0.03);

    --sidebar-bg: rgba(30, 25, 38, 0.78);
    --sidebar-backdrop: blur(20px);
    --sidebar-border: rgba(140, 110, 160, 0.18);
    --sidebar-shadow: 0 4px 32px rgba(0, 0, 0, 0.25);

    --card-bg: rgba(35, 30, 44, 0.75);
    --card-backdrop: blur(12px);
    --card-border: rgba(120, 100, 145, 0.20);
    --card-shadow: 0 2px 16px rgba(0, 0, 0, 0.20);
    --card-hover-shadow: 0 6px 28px rgba(0, 0, 0, 0.32);
    --card-hover-border: rgba(180, 140, 200, 0.30);

    --text-primary: #e0d8e6;
    --text-secondary: #c4bacf;
    --text-muted: #9a8da8;
    --text-heading: #ede4f2;

    --accent: #c896b8;
    --accent-soft: #3a2a3a;
    --accent-hover: #d4a8c4;
    --accent-text: #d4a8c4;

    --tag-bg: #352a38;
    --tag-text: #c896b8;
    --tag-hover-bg: #423044;
    --tag-active-bg: #4e3852;
    --tag-active-text: #dbb8cf;

    --category-bg: #2e2640;
    --category-text: #a890d0;
    --category-hover-bg: #38304c;
    --category-active-bg: #423858;
    --category-active-text: #c0a8e0;

    --search-bg: rgba(40, 34, 50, 0.7);
    --search-border: rgba(120, 100, 145, 0.35);
    --search-focus-border: rgba(200, 150, 180, 0.50);
    --search-focus-shadow: 0 0 0 3px rgba(200, 150, 180, 0.08);

    --stat-bg: rgba(40, 34, 50, 0.50);
    --stat-border: rgba(120, 100, 145, 0.18);
    --stat-icon-color: #c896b8;

    --divider: rgba(140, 110, 160, 0.22);

    --scrollbar-thumb: #4a3d55;
    --scrollbar-track: transparent;

    --btn-bg: #352a38;
    --btn-text: #c896b8;
    --btn-hover-bg: #423044;

    --content-img-border: rgba(140, 110, 160, 0.28);
    --content-img-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);

    --video-bg: #282030;
    --video-border: rgba(120, 100, 145, 0.25);

    --back-btn-bg: rgba(40, 34, 50, 0.7);
    --back-btn-hover: rgba(50, 42, 60, 0.9);

    --loader-color: #c896b8;
}

/* =========================================================
   全局重置与基础排版
   ========================================================= */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
    background: linear-gradient(160deg, var(--bg-gradient-from) 0%, var(--bg-gradient-via) 35%, var(--bg-gradient-to) 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.7;
    letter-spacing: 0.02em;
    transition: background 0.5s ease, color 0.4s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 背景纹理装饰 */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.5;
    background-image:
        radial-gradient(circle at 20% 30%, var(--bg-pattern-color) 0%, transparent 50%),
        radial-gradient(circle at 75% 60%, var(--bg-pattern-color) 0%, transparent 45%),
        radial-gradient(circle at 50% 85%, var(--bg-pattern-color) 0%, transparent 55%);
}

/* 滚动条美化 */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); border-radius: 10px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* =========================================================
   主布局：侧边栏 + 内容区
   ========================================================= */
.app-container {
    display: flex;
    max-width: 1300px;
    margin: 0 auto;
    padding: 20px 24px;
    gap: 28px;
    position: relative;
    z-index: 1;
    min-height: 100vh;
}

/* =========================================================
   侧边栏样式
   ========================================================= */
.sidebar {
    flex: 0 0 310px;
    width: 310px;
    position: sticky;
    top: 20px;
    align-self: flex-start;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: var(--sidebar-bg);
    backdrop-filter: var(--sidebar-backdrop);
    -webkit-backdrop-filter: var(--sidebar-backdrop);
    border: 1px solid var(--sidebar-border);
    border-radius: 22px;
    padding: 28px 22px;
    box-shadow: var(--sidebar-shadow);
    display: flex;
    flex-direction: column;
    gap: 22px;
    z-index: 10;
}

.sidebar-section {
    padding-bottom: 18px;
    border-bottom: 1px solid var(--divider);
}
.sidebar-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

/* 头像区域 */
.profile-area { text-align: center; }
.avatar {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--accent-soft);
    box-shadow: 0 4px 16px rgba(180, 120, 160, 0.18);
    background: linear-gradient(135deg, #fce4ec, #f8d8e8);
}
body.dark-mode .avatar {
    border-color: rgba(200, 150, 180, 0.35);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.profile-name {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-heading);
    margin: 8px 0 4px;
}
.profile-bio {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* 统计卡片网格 */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.stat-item {
    background: var(--stat-bg);
    border: 1px solid var(--stat-border);
    border-radius: 14px;
    padding: 10px 8px;
    text-align: center;
}
.stat-icon { font-size: 1.3rem; color: var(--stat-icon-color); display: block; margin-bottom: 2px; }
.stat-value { font-size: 1.15rem; font-weight: 700; color: var(--text-heading); }
.stat-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* 运行时间 */
.runtime-display {
    font-size: 0.78rem;
    color: var(--accent-text);
    font-weight: 600;
    text-align: center;
    padding: 6px 0;
    background: var(--stat-bg);
    border-radius: 10px;
    margin-top: 8px;
}

/* 分类与标签 */
.section-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.category-list, .tag-cloud { display: flex; flex-wrap: wrap; gap: 7px; }
.category-chip, .tag-chip {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    cursor: pointer;
    border: 1px solid transparent;
    font-weight: 500;
    transition: 0.2s;
    user-select: none;
    white-space: nowrap;
}
.category-chip { background: var(--category-bg); color: var(--category-text); }
.tag-chip { background: var(--tag-bg); color: var(--tag-text); font-size: 0.75rem; padding: 4px 11px; border-radius: 16px; }
.category-chip:hover, .tag-chip:hover { background: var(--category-hover-bg); }
.tag-chip:hover { background: var(--tag-hover-bg); }
.category-chip.active { background: var(--category-active-bg); color: var(--category-active-text); font-weight: 700; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.tag-chip.active { background: var(--tag-active-bg); color: var(--tag-active-text); font-weight: 700; }

/* 清除筛选按钮 */
.clear-filter-btn {
    display: inline-block;
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 12px;
    cursor: pointer;
    background: transparent;
    color: var(--accent-text);
    border: 1px dashed var(--accent);
    margin-top: 4px;
}

/* 主题切换按钮 */
.theme-toggle-wrapper { display: flex; align-items: center; justify-content: center; gap: 8px; }
.theme-toggle-btn {
    width: 48px; height: 26px; border-radius: 13px;
    background: var(--tag-bg); border: 1px solid var(--sidebar-border);
    cursor: pointer; position: relative;
}
.theme-toggle-btn::after {
    content: ""; position: absolute; top: 3px; left: 3px;
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--accent); transition: 0.3s;
}
body.dark-mode .theme-toggle-btn::after { left: 25px; background: #c896b8; }
.theme-toggle-label { font-size: 0.8rem; color: var(--text-secondary); }

/* =========================================================
   主内容区
   ========================================================= */
.main-content { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 20px; }

/* 搜索栏 */
.search-bar-wrapper { position: relative; }
.search-input {
    width: 100%; padding: 14px 18px 14px 44px; border-radius: 16px;
    border: 1.5px solid var(--search-border); background: var(--search-bg);
    backdrop-filter: blur(8px); font-size: 0.95rem; color: var(--text-primary);
    outline: none; transition: 0.3s;
}
.search-input:focus { border-color: var(--search-focus-border); box-shadow: var(--search-focus-shadow); }
.search-icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-size: 1.1rem; color: var(--text-muted); }

/* 筛选状态 */
.filter-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.82rem; color: var(--text-secondary); min-height: 24px; }
.active-filter-tag { background: var(--accent-soft); color: var(--accent-text); padding: 3px 10px; border-radius: 12px; font-weight: 600; font-size: 0.78rem; }
.clear-search { cursor: pointer; color: var(--accent-text); font-weight: 600; font-size: 0.78rem; text-decoration: underline; }

/* =========================================================
   文章卡片
   ========================================================= */
.articles-list { display: flex; flex-direction: column; gap: 16px; }
.article-card {
    background: var(--card-bg); backdrop-filter: var(--card-backdrop);
    -webkit-backdrop-filter: var(--card-backdrop); border: 1px solid var(--card-border);
    border-radius: 18px; padding: 22px 24px; cursor: pointer;
    box-shadow: var(--card-shadow); transition: 0.3s;
}
.article-card:hover { box-shadow: var(--card-hover-shadow); border-color: var(--card-hover-border); transform: translateY(-2px); }
.article-card-header { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 10px; }
.article-card-cover {
    width: 100px; height: 72px; border-radius: 12px; object-fit: cover;
    flex-shrink: 0; background: var(--stat-bg); border: 1px solid var(--content-img-border);
}
.article-card-info { flex: 1; min-width: 0; }
.article-card-title { font-size: 1.1rem; font-weight: 700; color: var(--text-heading); }
.article-card-meta { font-size: 0.75rem; color: var(--text-muted); display: flex; gap: 8px; flex-wrap: wrap; }
.article-card-summary {
    font-size: 0.88rem; color: var(--text-secondary); line-height: 1.55;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.article-card-tags { display: flex; gap: 5px; margin-top: 8px; }
.mini-tag { font-size: 0.7rem; padding: 2px 8px; border-radius: 10px; background: var(--tag-bg); color: var(--tag-text); }

/* 无搜索结果 */
.no-results {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.no-results-emoji { font-size: 3rem; display: block; margin-bottom: 12px; }
.no-results p { font-size: 1rem; }

/* =========================================================
   文章详情
   ========================================================= */
.article-detail {
    display: none; background: var(--card-bg); backdrop-filter: var(--card-backdrop);
    border-radius: 20px; padding: 28px 30px; box-shadow: var(--card-shadow);
    animation: fadeSlideIn 0.35s;
}
.article-detail.visible { display: block; }
@keyframes fadeSlideIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.detail-back-btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 20px;
    cursor: pointer; background: var(--back-btn-bg); border: 1px solid var(--sidebar-border);
    color: var(--text-secondary); font-size: 0.85rem; font-weight: 600; margin-bottom: 18px;
}
.detail-back-btn:hover { background: var(--back-btn-hover); color: var(--text-primary); }
.detail-title { font-size: 1.5rem; font-weight: 700; color: var(--text-heading); margin-bottom: 8px; }
.detail-meta { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 20px; display: flex; gap: 10px; }
.detail-content { font-size: 0.95rem; line-height: 1.85; color: var(--text-primary); }
.detail-content p { margin-bottom: 16px; }
.detail-content img { max-width: 100%; border-radius: 14px; margin: 18px auto; display: block; border: 1px solid var(--content-img-border); box-shadow: var(--content-img-shadow); }
.detail-tags { display: flex; gap: 7px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--divider); }
.detail-tag { font-size: 0.78rem; padding: 5px 13px; border-radius: 16px; background: var(--tag-bg); color: var(--tag-text); }

/* =========================================================
   加载动画（文章内容加载中）
   ========================================================= */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--divider);
    border-top-color: var(--loader-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-spinner p { font-size: 0.9rem; }

/* 加载错误 */
.load-error {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.load-error .error-icon { font-size: 2.5rem; display: block; margin-bottom: 10px; }
.load-error p { margin-bottom: 12px; }
.retry-btn {
    display: inline-block;
    padding: 8px 20px;
    border-radius: 16px;
    background: var(--btn-bg);
    color: var(--btn-text);
    border: 1px solid var(--sidebar-border);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
}
.retry-btn:hover { background: var(--btn-hover-bg); }

/* 初始加载（整站） */
.initial-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    color: var(--text-muted);
}
.initial-loading .spinner { width: 50px; height: 50px; margin-bottom: 16px; }

/* =========================================================
   回到顶部按钮
   ========================================================= */
.back-to-top {
    position: fixed; bottom: 30px; right: 30px; width: 48px; height: 48px; border-radius: 50%;
    background: linear-gradient(145deg, #fce4ec, #f8d8e8); backdrop-filter: blur(10px);
    border: 1.5px solid rgba(236,72,153,0.2); color: #c04e6e; font-size: 1.8rem; cursor: pointer;
    box-shadow: 0 4px 16px rgba(200,120,160,0.25); z-index: 99;
    opacity: 0; visibility: hidden; transform: translateY(10px); transition: 0.35s;
    display: flex; align-items: center; justify-content: center;
}
body.dark-mode .back-to-top {
    background: linear-gradient(145deg, #3a2a3a, #4e3852);
    border-color: rgba(200,150,180,0.3); color: #dbb8cf;
}
.back-to-top.visible { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:hover {
    background: linear-gradient(145deg, #fcd8e5, #f9c5d7);
    transform: translateY(-3px) scale(1.05);
}
body.dark-mode .back-to-top:hover { background: linear-gradient(145deg, #4e3852, #5a4460); }

/* =========================================================
   响应式设计
   ========================================================= */
@media (max-width: 900px) {
    .app-container { flex-direction: column; padding: 12px 10px; }
    .sidebar { flex: auto; width: 100%; position: relative; top: auto; max-height: none; }
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
    .article-card-header { flex-direction: column; }
    .article-card-cover { width: 100%; height: 140px; }
    .detail-title { font-size: 1.2rem; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-value { font-size: 0.9rem; }
    .article-card { padding: 14px 12px; }
    .back-to-top { bottom: 20px; right: 16px; width: 42px; height: 42px; font-size: 1.6rem; }
}
