/* ==================== CSS 变量 & 全局重置 ==================== */
:root {
    --glass-bg: rgba(255, 255, 255, 0.18);
    --glass-bg-strong: rgba(255, 255, 255, 0.35);
    --glass-bg-hover: rgba(255, 255, 255, 0.28);
    --glass-border: rgba(255, 255, 255, 0.35);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    --glass-blur: blur(18px);
    --glass-blur-light: blur(10px);
    --text-primary: #1a1a2e;
    --text-secondary: #444;
    --text-muted: #777;
    --accent: #5b7fff;
    --accent-light: #eef1ff;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-width: 300px;
    --toolbar-height: 52px;
    --font-sans: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
    --font-mono: 'SF Mono', 'Cascadia Code', 'Consolas', 'Monaco', monospace;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* 锁定全局滚动，防止整体页面滑动 */
html {
    height: 100%;
    overflow: hidden;
}

body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font-sans);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==================== 背景图层 ==================== */
.bg-layer {
    position: fixed;
    inset: 0;
    z-index: -1;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800"><defs><linearGradient id="g" x1="0%25" y1="0%25" x2="100%25" y2="100%25"><stop offset="0%25" style="stop-color:%23e0c3fc"/><stop offset="50%25" style="stop-color:%238ec5fc"/><stop offset="100%25" style="stop-color:%23c2e9fb"/></linearGradient></defs><rect width="1200" height="800" fill="url(%23g)"/></svg>');
}

.bg-layer::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.08);
    pointer-events: none;
}

/* ==================== 主容器（固定高度） ==================== */
.app-container {
    display: flex;
    height: 100vh;          /* 占满视口高度 */
    overflow: hidden;        /* 禁止容器自身滚动 */
    position: relative;
    z-index: 1;
}

/* ==================== 侧边栏（桌面端） ==================== */
.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    height: 100vh;          /* 占满高度 */
    padding: 20px;
    z-index: 10;
    display: flex;
    align-items: stretch;
}

.sidebar-inner {
    width: 100%;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--glass-shadow);
    padding: 28px 20px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    overflow-y: auto;        /* 侧边栏内容过多时自己滚动 */
    transition: var(--transition);
}

/* 头像 */
.sidebar-avatar-wrap {
    flex-shrink: 0;
}

.avatar-ring {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    padding: 3px;
    background: linear-gradient(135deg, rgba(255,255,255,0.6), rgba(255,255,255,0.2));
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    overflow: hidden;
}

.avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.avatar-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
}

/* 名称 */
.sidebar-name {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    letter-spacing: 0.02em;
}

/* 个人介绍 */
.sidebar-bio {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.5;
    max-width: 220px;
}

/* 社交链接 */
.sidebar-links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.sidebar-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur-light);
    -webkit-backdrop-filter: var(--glass-blur-light);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    transition: var(--transition);
    text-decoration: none;
}

.sidebar-links a:hover {
    background: var(--glass-bg-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
    color: var(--accent);
}

.sidebar-links a svg {
    width: 18px;
    height: 18px;
}

/* 侧边栏底部 */
.sidebar-footer {
    margin-top: auto;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-runtime,
.sidebar-copyright {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.6;
}

/* ==================== 主内容区域 ==================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px 24px 20px 8px;
    overflow: hidden;          /* 禁止主容器自身滚动，让子容器滚动 */
    min-height: 0;            /* 防止 flex 子项溢出 */
}

/* 移动端头部 */
.mobile-header {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 8px 4px 16px;
    flex-shrink: 0;            /* 不参与滚动 */
}

.mobile-avatar-wrap {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 3px 12px rgba(0,0,0,0.12);
    background: linear-gradient(135deg, rgba(255,255,255,0.6), rgba(255,255,255,0.2));
    padding: 2px;
}

.mobile-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.mobile-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
}

.mobile-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* 工具栏（固定不滚动） */
.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 14px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur-light);
    -webkit-backdrop-filter: var(--glass-blur-light);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    min-height: var(--toolbar-height);
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    flex-shrink: 0;            /* 不参与滚动 */
}

.btn-back {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--glass-bg-strong);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xs);
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-primary);
    transition: var(--transition);
    font-family: inherit;
}

.btn-back:hover {
    background: var(--glass-bg-hover);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.toolbar-title {
    flex: 1;
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.layout-toggle {
    display: flex;
    gap: 4px;
}

.layout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-xs);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
    font-family: inherit;
}

.layout-btn:hover {
    background: var(--glass-bg);
    color: var(--text-primary);
}

.layout-btn.active {
    background: var(--glass-bg-strong);
    border-color: var(--glass-border);
    color: var(--accent);
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

/* ==================== 内容区域（唯一滚动容器） ==================== */
.content-area {
    flex: 1;                    /* 占据剩余高度 */
    overflow-y: auto;           /* 独立垂直滚动 */
    overflow-x: hidden;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 20px 22px;
    box-shadow: var(--glass-shadow);
    min-height: 0;              /* 避免内容撑开 */
}

/* 自定义透明滚动条（Webkit 内核浏览器） */
.content-area::-webkit-scrollbar {
    width: 5px;
    background: transparent;
}

.content-area::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 8px;
}

.content-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.45);
    border-radius: 8px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: background 0.2s;
}

.content-area::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.65);
}

/* Firefox 滚动条样式 */
.content-area {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.45) transparent;
}

/* ==================== 文章列表 ==================== */
.article-list.list-mode {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.article-list.list-mode .article-card {
    display: flex;
    gap: 16px;
    padding: 16px 18px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur-light);
    -webkit-backdrop-filter: var(--glass-blur-light);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    align-items: center;
}

.article-list.list-mode .article-card:hover {
    background: var(--glass-bg-hover);
    transform: translateX(4px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.article-list.list-mode .card-cover {
    width: 70px;
    height: 56px;
    border-radius: var(--radius-xs);
    object-fit: cover;
    flex-shrink: 0;
    background: rgba(200,200,220,0.3);
}

.article-list.list-mode .card-cover-placeholder {
    width: 70px;
    height: 56px;
    border-radius: var(--radius-xs);
    flex-shrink: 0;
    background: linear-gradient(135deg, rgba(180,190,220,0.4), rgba(200,210,240,0.3));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #aaa;
}

.article-list.list-mode .card-info {
    flex: 1;
    min-width: 0;
}

.article-list.list-mode .card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.article-list.list-mode .card-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.article-list.list-mode .card-summary {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.article-list.list-mode .card-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 4px;
}

/* 块模式 */
.article-list.grid-mode {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.article-list.grid-mode .article-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur-light);
    -webkit-backdrop-filter: var(--glass-blur-light);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.article-list.grid-mode .article-card:hover {
    background: var(--glass-bg-hover);
    transform: translateY(-4px);
    box-shadow: 0 8px 28px rgba(0,0,0,0.12);
}

.article-list.grid-mode .card-cover {
    width: 100%;
    height: 140px;
    object-fit: cover;
    background: rgba(200,200,220,0.3);
}

.article-list.grid-mode .card-cover-placeholder {
    width: 100%;
    height: 140px;
    background: linear-gradient(135deg, rgba(180,190,220,0.4), rgba(200,210,240,0.3));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #bbb;
}

.article-list.grid-mode .card-info {
    padding: 14px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.article-list.grid-mode .card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-list.grid-mode .card-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.article-list.grid-mode .card-summary {
    font-size: 0.83rem;
    color: var(--text-secondary);
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-list.grid-mode .card-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

/* 标签 */
.tag {
    font-size: 0.72rem;
    padding: 3px 10px;
    border-radius: 20px;
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 500;
    white-space: nowrap;
}

/* ==================== 文章详情 ==================== */
.article-detail {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.article-detail-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}

.article-detail-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.3;
}

.article-detail-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    align-items: center;
}

.article-detail-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

/* Markdown 内容样式 */
.markdown-body {
    line-height: 1.8;
    color: var(--text-primary);
    word-break: break-word;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
    margin-top: 1.4em;
    margin-bottom: 0.6em;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-primary);
}

.markdown-body h1 { font-size: 1.5rem; border-bottom: 2px solid rgba(0,0,0,0.08); padding-bottom: 8px; }
.markdown-body h2 { font-size: 1.3rem; }
.markdown-body h3 { font-size: 1.15rem; }

.markdown-body p { margin-bottom: 1em; }

.markdown-body a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px dashed var(--accent);
}
.markdown-body a:hover { border-bottom-style: solid; }

.markdown-body img {
    max-width: 100%;
    border-radius: var(--radius-xs);
    margin: 8px 0;
}

.markdown-body blockquote {
    border-left: 4px solid var(--accent);
    padding: 8px 16px;
    margin: 12px 0;
    background: rgba(91,127,255,0.06);
    border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
    color: var(--text-secondary);
}

.markdown-body code {
    font-family: var(--font-mono);
    background: rgba(0,0,0,0.06);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.9em;
}

.markdown-body pre {
    background: rgba(30,30,40,0.9);
    color: #e0e0e0;
    padding: 16px 18px;
    border-radius: var(--radius-xs);
    overflow-x: auto;
    margin: 12px 0;
    font-size: 0.88rem;
    line-height: 1.5;
}

.markdown-body pre code {
    background: transparent;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

.markdown-body ul, .markdown-body ol {
    padding-left: 1.5em;
    margin-bottom: 1em;
}

.markdown-body li { margin-bottom: 4px; }

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
}

.markdown-body th, .markdown-body td {
    border: 1px solid rgba(0,0,0,0.1);
    padding: 8px 12px;
    text-align: left;
}

.markdown-body th { background: rgba(0,0,0,0.04); font-weight: 600; }

.markdown-body hr {
    border: none;
    border-top: 1px solid rgba(0,0,0,0.1);
    margin: 20px 0;
}

/* ==================== 状态提示 ==================== */
.empty-state, .loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    gap: 12px;
    text-align: center;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(0,0,0,0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== 移动端底部 ==================== */
.mobile-footer {
    display: none;
    text-align: center;
    padding: 16px 8px 8px;
    flex-shrink: 0;            /* 底部不滚动 */
}

.mobile-runtime, .mobile-copyright {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.6;
}

/* ==================== 响应式：移动端 ==================== */
@media (max-width: 768px) {
    .sidebar {
        display: none !important;
    }

    .app-container {
        flex-direction: column;
    }

    .main-content {
        max-width: 100%;
        padding: 12px 12px 16px;
    }

    .mobile-header {
        display: flex;
    }

    .mobile-footer {
        display: block;
    }

    .content-area {
        border-radius: var(--radius-sm);
        padding: 14px 12px;
    }

    .toolbar {
        border-radius: var(--radius-sm);
        margin-bottom: 10px;
    }

    /* 移动端强制列表模式 */
    .article-list.grid-mode {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .article-list.grid-mode .article-card {
        flex-direction: row;
        align-items: center;
        padding: 12px 14px;
        gap: 12px;
    }

    .article-list.grid-mode .card-cover,
    .article-list.grid-mode .card-cover-placeholder {
        width: 60px;
        height: 48px;
        flex-shrink: 0;
        border-radius: var(--radius-xs);
    }

    .article-list.grid-mode .card-info {
        padding: 0;
        flex: 1;
        min-width: 0;
    }

    .article-list.grid-mode .card-title {
        font-size: 0.95rem;
        -webkit-line-clamp: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .article-list.grid-mode .card-summary {
        -webkit-line-clamp: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .layout-toggle {
        display: none !important;
    }

    .article-detail-title {
        font-size: 1.3rem;
    }

    .markdown-body {
        font-size: 0.92rem;
    }
}

/* 平板小屏适配 */
@media (max-width: 900px) and (min-width: 769px) {
    .sidebar { width: 240px; padding: 14px; }
    .sidebar-inner { padding: 20px 14px 14px; }
    .avatar-ring { width: 80px; height: 80px; }
    .sidebar-name { font-size: 1.15rem; }
    .sidebar-bio { font-size: 0.8rem; max-width: 170px; }
    .main-content {
        padding: 16px 16px 16px 4px;
    }
}