/* ==================== CSS 变量与主题 ==================== */
:root {
    /* 颜色系统 */
    --color-primary: #6366f1;
    --color-primary-hover: #4f46e5;
    --color-primary-light: rgba(99, 102, 241, 0.1);
    --color-primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;

    /* 暗色主题 */
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #252542;
    --bg-card: #1e1e35;
    --bg-hover: rgba(255, 255, 255, 0.05);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-light: rgba(255, 255, 255, 0.04);

    /* 阴影 */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.15);

    /* 圆角 */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* 过渡 */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;

    /* 布局 */
    --sidebar-width: 320px;
    --header-height: 64px;
}

/* ==================== 重置与基础样式 ==================== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

body {
    font-family: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ==================== 应用容器 ==================== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ==================== 侧边栏 ==================== */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition-normal);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--color-primary-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
}

.logo-icon svg {
    width: 22px;
    height: 22px;
    color: white;
}

.logo-text {
    font-size: 18px;
    font-weight: 600;
    background: var(--color-primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.menu-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.menu-toggle svg {
    width: 24px;
    height: 24px;
}

/* ==================== 侧边栏操作区 ==================== */
.sidebar-actions {
    padding: 16px 20px;
}

.action-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

.action-btn.primary {
    background: var(--color-primary-gradient);
    color: white;
    box-shadow: var(--shadow-md);
}

.action-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.action-btn.primary:active {
    transform: translateY(0);
}

.action-btn svg {
    width: 18px;
    height: 18px;
}

/* ==================== 搜索框 ==================== */
.sidebar-search {
    padding: 0 20px 16px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    transition: var(--transition-fast);
}

.search-box:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.search-box svg {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 14px;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

/* ==================== 文章列表 ==================== */
.article-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.article-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    margin-bottom: 4px;
}

.article-item:hover {
    background: var(--bg-hover);
}

.article-item.active {
    background: var(--color-primary-light);
}

.article-thumbnail {
    width: 80px;
    height: 45px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--bg-tertiary);
    flex-shrink: 0;
}

.article-item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.article-item-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}

.article-item-date {
    font-size: 11px;
    color: var(--text-muted);
}

/* ==================== 侧边栏底部 ==================== */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.status-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--color-success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ==================== 主内容区 ==================== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background: var(--bg-primary);
}

/* ==================== 欢迎页面 ==================== */
.welcome-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.welcome-content {
    max-width: 600px;
    text-align: center;
}

.welcome-icon {
    width: 100px;
    height: 100px;
    margin: 0 auto 32px;
    background: var(--color-primary-gradient);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
}

.welcome-icon svg {
    width: 50px;
    height: 50px;
    color: white;
}

.welcome-content h1 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-content>p {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 48px;
}

.welcome-features {
    display: grid;
    gap: 20px;
    margin-bottom: 48px;
}

.feature-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    text-align: left;
    transition: var(--transition-fast);
}

.feature-item:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.feature-icon {
    width: 44px;
    height: 44px;
    background: var(--color-primary-light);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.feature-icon svg {
    width: 22px;
    height: 22px;
    color: var(--color-primary);
}

.feature-text h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.feature-text p {
    font-size: 13px;
    color: var(--text-secondary);
}

.welcome-hint {
    font-size: 14px;
    color: var(--text-muted);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateX(0);
    }

    50% {
        transform: translateX(-10px);
    }
}

/* ==================== 文章页面 ==================== */
.article-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px;
}

.article-header {
    margin-bottom: 40px;
}

/* 音频播放器容器 */
.audio-player {
    margin-bottom: 20px;
    text-align: center;
}
.audio-player audio {
    width: 100%;
    max-width: 600px;
    outline: none;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    padding: 8px 16px;
    margin-left: -16px;
    margin-bottom: 24px;
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
}

.back-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.back-btn svg {
    width: 18px;
    height: 18px;
}

.article-meta {
    margin-bottom: 20px;
}

.article-title {
    font-size: 32px;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--color-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.article-info {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

.article-info-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.article-info-item svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.article-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.icon-btn:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

/* ==================== 文章内容 ==================== */
.article-body {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4 {
    color: var(--text-primary);
    margin: 32px 0 16px;
    font-weight: 600;
}

.article-body h1:first-child,
.article-body h2:first-child {
    margin-top: 0;
}

.article-body h2 {
    font-size: 24px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--color-primary-light);
}

.article-body h3 {
    font-size: 20px;
}

.article-body p {
    margin-bottom: 16px;
    color: var(--text-secondary);
    line-height: 1.8;
}

.article-body ul,
.article-body ol {
    margin: 16px 0;
    padding-left: 24px;
    color: var(--text-secondary);
}

.article-body li {
    margin-bottom: 8px;
}

.article-body a {
    color: var(--color-primary);
    text-decoration: none;
    transition: var(--transition-fast);
}

.article-body a:hover {
    text-decoration: underline;
}

.article-body img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    margin: 24px 0;
}

.article-body hr {
    border: none;
    height: 1px;
    background: var(--border-color);
    margin: 32px 0;
}

.article-body blockquote {
    border-left: 4px solid var(--color-primary);
    padding-left: 20px;
    margin: 24px 0;
    color: var(--text-secondary);
    font-style: italic;
}

.article-body code {
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'SF Mono', monospace;
    font-size: 14px;
}

.article-body pre {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 20px;
    overflow-x: auto;
    margin: 24px 0;
}

.article-body pre code {
    background: transparent;
    padding: 0;
}

.article-body strong {
    color: var(--text-primary);
    font-weight: 600;
}

.article-body em {
    color: var(--text-muted);
}

/* ==================== 可折叠标题 ==================== */
.collapsible-heading {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    user-select: none;
    -webkit-user-select: none;
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    margin-left: -12px;
    margin-right: -12px;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.collapsible-heading:hover {
    background: var(--bg-hover);
}

.collapsible-heading.collapsed {
    color: var(--text-secondary);
    margin-bottom: 0;
}

.collapsible-chevron {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-normal);
    color: var(--text-muted);
}

.collapsible-chevron svg {
    width: 18px;
    height: 18px;
}

.collapsible-heading.collapsed .collapsible-chevron {
    transform: rotate(-90deg);
}

.collapsible-content {
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.3s ease;
    opacity: 1;
}

.collapsible-heading.collapsed+.collapsible-content {
    opacity: 0.01;
}

/* ==================== Loading 状态 ==================== */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    gap: 16px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==================== Toast 通知 ==================== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1000;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.success {
    border-left: 4px solid var(--color-success);
}

.toast.error {
    border-left: 4px solid var(--color-danger);
}

.toast.info {
    border-left: 4px solid var(--color-primary);
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.toast.success .toast-icon {
    color: var(--color-success);
}

.toast.error .toast-icon {
    color: var(--color-danger);
}

.toast.info .toast-icon {
    color: var(--color-primary);
}

.toast-message {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
}

/* ==================== 空状态 ==================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 60px;
    height: 60px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 14px;
}

/* ==================== 移动端菜单按钮 ==================== */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 20px;
    left: 20px;
    width: 44px;
    height: 44px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 50;
    cursor: pointer;
    transition: var(--transition-fast);
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    padding: 0;
}

.mobile-menu-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--color-primary);
}

.mobile-menu-btn svg {
    width: 24px;
    height: 24px;
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 1024px) {
    .mobile-menu-btn {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.5);
    }

    /* 添加遮罩层 */
    .sidebar.open::before {
        content: '';
        position: fixed;
        top: 0;
        left: var(--sidebar-width);
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .menu-toggle {
        display: block;
    }

    .article-page {
        padding: 24px;
        padding-top: 80px;
        /* 为固定的菜单按钮留出空间 */
    }

    .article-body {
        padding: 24px;
    }

    .article-title {
        font-size: 24px;
    }

    .welcome-page {
        padding-top: 80px;
    }
}

@media (max-width: 640px) {
    .welcome-content h1 {
        font-size: 24px;
    }

    .welcome-features {
        grid-template-columns: 1fr;
    }

    .article-page {
        padding: 16px;
        padding-top: 80px;
    }

    .article-body {
        padding: 16px;
    }

    .article-title {
        font-size: 20px;
    }

    .article-info {
        font-size: 12px;
    }

    .article-thumbnail {
        width: 60px;
        height: 34px;
    }

    .article-item-title {
        font-size: 12px;
    }

    .article-item-date {
        font-size: 10px;
    }
}