/* KnowHub - 个人知识库样式 */

/* 亮色主题（默认） */
:root, [data-theme="light"] {
    /* 主色调 - 清新蓝绿色系 */
    --primary: #0891b2;
    --primary-dark: #0e7490;
    --primary-light: #06b6d4;
    
    /* 背景色 - 亮色主题 */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-hover: #e2e8f0;
    
    /* 文字色 */
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    /* 边框色 */
    --border: #e2e8f0;
    --border-light: #cbd5e1;
    
    /* 其他 */
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    
    /* 代码块 */
    --code-bg: #1e293b;
    --code-text: #e2e8f0;
    
    /* 尺寸 */
    --sidebar-width: 300px;
    --toolbar-height: 56px;
    --radius: 8px;
    --radius-sm: 4px;
    
    /* 阴影 */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
}

/* 暗色主题 */
[data-theme="dark"] {
    --primary: #22d3ee;
    --primary-dark: #06b6d4;
    --primary-light: #67e8f9;
    
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-hover: #475569;
    
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    
    --border: #334155;
    --border-light: #475569;
    
    /* 暗色主题代码块用更深的颜色 */
    --code-bg: #0c1222;
    --code-text: #e2e8f0;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4), 0 4px 6px rgba(0, 0, 0, 0.3);
}

/* 主题切换过渡动画 */
body, .sidebar, .toolbar, .document-content, .fab, .dialog, 
.comment-drawer, .ai-drawer, .context-menu, .tree-node-content {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.2s ease;
}

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

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

/* 应用容器 */
.app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ============================================================
   侧边栏
   ============================================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    box-shadow: var(--shadow);
}

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

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

.sidebar-links {
    display: flex;
    gap: 4px;
}

.sidebar-link {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 14px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.sidebar-link:hover {
    background: var(--bg-tertiary);
}

.logo-icon {
    font-size: 28px;
}

.logo-text {
    font-size: 22px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* 搜索框 */
.search-box {
    padding: 12px 16px;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.2);
}

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

.search-icon {
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    opacity: 0.6;
}

/* 搜索结果 */
.search-results {
    max-height: 400px;
    overflow-y: auto;
    border-bottom: 1px solid var(--border);
}

.search-results.hidden {
    display: none;
}

.search-result-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.search-result-item:hover {
    background: var(--bg-tertiary);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-title {
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.search-result-snippet {
    font-size: 12px;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-no-result {
    padding: 20px 16px;
    text-align: center;
    color: var(--text-muted);
}

/* 目录树 */
.tree-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.tree-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.tree-actions {
    display: flex;
    gap: 4px;
}

/* 添加菜单下拉 */
.add-menu-wrapper {
    position: relative;
}

.add-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 160px;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
}

.add-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.add-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    border: none;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
}

.add-menu-item:first-child {
    border-radius: var(--radius) var(--radius) 0 0;
}

.add-menu-item:last-child {
    border-radius: 0 0 var(--radius) var(--radius);
}

.add-menu-item:hover {
    background: var(--bg-tertiary);
}

.add-menu-icon {
    font-size: 14px;
}

.btn-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s;
}

.btn-icon:hover {
    background: var(--bg-tertiary);
}

.tree-view {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

/* 树节点 */
.tree-node {
    user-select: none;
}

.tree-node-content {
    display: flex;
    align-items: center;
    padding: 6px 16px;
    cursor: pointer;
    transition: background 0.15s;
    gap: 8px;
}

.tree-node-content:hover {
    background: var(--bg-tertiary);
}

.tree-node-content.active {
    background: rgba(8, 145, 178, 0.1);
    border-right: 3px solid var(--primary);
}

.tree-node-content.active .tree-node-name {
    color: var(--primary);
    font-weight: 500;
}

.tree-toggle {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.15s;
}

.tree-toggle.expanded {
    transform: rotate(90deg);
}

.tree-toggle.hidden {
    visibility: hidden;
}

.tree-icon {
    font-size: 16px;
}

/* 简洁的圆点图标 */
.tree-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: all 0.15s;
}

.tree-dot.has-content {
    background: var(--primary);
}

.tree-dot.no-content {
    background: transparent;
    border: 2px solid var(--border-light);
    width: 6px;
    height: 6px;
}

.tree-node-content:hover .tree-dot.no-content {
    border-color: var(--primary);
}

.tree-node-content.active .tree-dot.has-content {
    background: var(--primary);
}

.tree-node-content.active .tree-dot.no-content {
    border-color: var(--primary);
}

/* 拖放样式 */
.tree-node-content[draggable="true"] {
    cursor: grab;
}

.tree-node-content[draggable="true"]:active {
    cursor: grabbing;
}

.tree-node.dragging {
    opacity: 0.5;
}

.tree-node.dragging .tree-node-content {
    background: var(--bg-tertiary);
}

.tree-node-content.drop-above {
    border-top: 2px solid var(--primary);
    margin-top: -2px;
}

.tree-node-content.drop-below {
    border-bottom: 2px solid var(--primary);
    margin-bottom: -2px;
}

.tree-node-content.drop-inside {
    background: rgba(8, 145, 178, 0.15);
    border-radius: var(--radius-sm);
}

.tree-node-name {
    flex: 1;
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-children {
    padding-left: 20px;
}

.tree-children.collapsed {
    display: none;
}

.tree-empty {
    padding: 20px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}


/* ============================================================
   主内容区
   ============================================================ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* 阅读进度条 */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    z-index: 1000;
    transition: width 0.1s ease-out;
}

/* 工具栏 */
.toolbar {
    height: var(--toolbar-height);
    padding: 0 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

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

.breadcrumb-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.breadcrumb-separator {
    color: var(--text-muted);
}

.toolbar-actions {
    display: flex;
    gap: 12px;
}

/* 按钮 */
.btn {
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
    border: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

/* 文档内容 */
.document-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px 48px;
}

/* 文章元信息 */
.doc-meta {
    max-width: 900px;
    margin: 0 auto 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.doc-meta-left {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.doc-meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.share-btn {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.share-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* 分享菜单 */
.share-menu {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.share-menu-content {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    width: 320px;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
}

.share-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 500;
}

.share-menu-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.share-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
}

.share-option:hover {
    background: var(--bg-hover);
}

.share-menu-footer {
    padding: 12px 16px 16px;
    border-top: 1px solid var(--border);
}

.share-url-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
}

/* 欢迎页面 */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
}

.welcome-icon {
    font-size: 64px;
    margin-bottom: 24px;
}

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

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

.welcome-tips {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tip {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--text-secondary);
}

.tip-icon {
    font-size: 20px;
}

/* Markdown 内容样式 */
.markdown-body {
    max-width: 900px;
    margin: 0 auto;
}

/* 非会员禁止选中文字 */
.no-copy .markdown-body {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.no-copy .markdown-body::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

/* 代码块仍然可以选中（方便复制代码） */
.no-copy .markdown-body pre,
.no-copy .markdown-body code {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

.markdown-body h1 {
    font-size: 2.2em;
    font-weight: 700;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border);
    color: var(--text-primary);
}

.markdown-body h2 {
    font-size: 1.6em;
    font-weight: 600;
    margin-top: 32px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.markdown-body h3 {
    font-size: 1.3em;
    font-weight: 600;
    margin-top: 24px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.markdown-body h4, .markdown-body h5, .markdown-body h6 {
    font-weight: 600;
    margin-top: 20px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.markdown-body p {
    margin-bottom: 16px;
    color: var(--text-secondary);
}

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

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

.markdown-body code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
    padding: 2px 6px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    color: var(--primary-dark);
}

.markdown-body pre {
    background: var(--code-bg);
    border-radius: var(--radius);
    padding: 0;
    overflow: hidden;
    margin-bottom: 16px;
    position: relative;
}

.markdown-body pre code {
    display: block;
    padding: 16px 20px;
    background: transparent;
    color: var(--code-text);
    font-size: 13px;
    line-height: 1.6;
    overflow-x: auto;
}

/* 代码块语言标签 */
.markdown-body pre::before {
    content: attr(data-lang);
    position: absolute;
    top: 0;
    right: 0;
    padding: 4px 12px;
    font-size: 11px;
    color: #64748b;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0 var(--radius) 0 var(--radius);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 代码语法高亮颜色 */
.markdown-body pre code .keyword { color: #c792ea; }
.markdown-body pre code .string { color: #c3e88d; }
.markdown-body pre code .number { color: #f78c6c; }
.markdown-body pre code .comment { color: #546e7a; font-style: italic; }
.markdown-body pre code .function { color: #82aaff; }
.markdown-body pre code .class-name { color: #ffcb6b; }
.markdown-body pre code .operator { color: #89ddff; }
.markdown-body pre code .punctuation { color: #89ddff; }


.markdown-body blockquote {
    margin: 16px 0;
    padding: 12px 20px;
    border-left: 4px solid var(--primary);
    background: var(--bg-secondary);
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--text-secondary);
}

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

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

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
}

.markdown-body th, .markdown-body td {
    padding: 12px 16px;
    border: 1px solid var(--border);
    text-align: left;
}

.markdown-body th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-primary);
}

.markdown-body td {
    color: var(--text-secondary);
}

.markdown-body tr:hover td {
    background: var(--bg-secondary);
}

.markdown-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 32px 0;
}

.markdown-body img {
    max-width: 100%;
    border-radius: var(--radius);
    cursor: zoom-in;
    transition: transform 0.2s ease;
}

.markdown-body img:hover {
    transform: scale(1.02);
}

/* 图片点击放大查看 */
.image-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    cursor: zoom-out;
    padding: 20px;
}

.image-lightbox img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    border-radius: var(--radius);
}

/* Toast 提示 */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    font-size: 14px;
    z-index: 3000;
    opacity: 0;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

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

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

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

.toast-icon {
    font-size: 16px;
}

/* ============================================================
   文章目录 (TOC)
   ============================================================ */
.toc-sidebar {
    position: fixed;
    top: calc(var(--toolbar-height) + 24px);
    right: 24px;
    width: 200px;
    max-height: calc(100vh - var(--toolbar-height) - 100px);
    overflow-y: auto;
    display: none;
}

.toc-sidebar.visible {
    display: block;
}

.toc-header {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding-left: 12px;
}

.toc-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.toc-item {
    display: block;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    border-left: 2px solid transparent;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    transition: all 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.toc-item:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.toc-item.active {
    color: var(--primary);
    border-left-color: var(--primary);
    background: rgba(8, 145, 178, 0.08);
}

.toc-item.toc-h3 {
    padding-left: 24px;
    font-size: 12px;
}

.toc-item.toc-h4 {
    padding-left: 36px;
    font-size: 12px;
}

/* 有 TOC 时调整内容区宽度 */
.document-content.has-toc .markdown-body {
    max-width: 720px;
}

/* ============================================================
   右键菜单
   ============================================================ */
.context-menu {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    z-index: 1000;
    padding: 8px 0;
}

.context-menu.hidden {
    display: none;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.15s;
}

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

.menu-item-danger:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.menu-icon {
    font-size: 14px;
}

.menu-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

/* ============================================================
   对话框
   ============================================================ */
.dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

.dialog-overlay.hidden {
    display: none;
}

.dialog {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 400px;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
}

.dialog.dialog-lg {
    width: 560px;
}

.dialog-desc {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 16px;
    line-height: 1.5;
}

/* AI 生成预览 */
.ai-generate-preview {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    font-weight: 500;
}

.preview-tree {
    padding: 12px 14px;
    max-height: 300px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.6;
}

.preview-tree-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
}

.preview-tree-item.level-1 { padding-left: 0; }
.preview-tree-item.level-2 { padding-left: 20px; }
.preview-tree-item.level-3 { padding-left: 40px; }

.preview-tree-icon {
    color: var(--text-muted);
    font-size: 12px;
}

.btn-success {
    background: #10b981;
    color: white;
    border: none;
}

.btn-success:hover {
    background: #059669;
}

.btn-block {
    width: 100%;
}

/* AI 生成目录抽屉 */
.ai-generate-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    max-width: 100vw;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    z-index: 200;
    transform: translateX(0);
    transition: transform 0.3s ease;
}

.ai-generate-drawer.hidden {
    transform: translateX(100%);
}

.ai-generate-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
    flex-shrink: 0;
}

.ai-generate-drawer-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.ai-generate-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.drawer-desc {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 20px;
    line-height: 1.5;
}

.parent-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(8, 145, 178, 0.1);
    border: 1px solid rgba(8, 145, 178, 0.2);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13px;
}

.parent-label {
    color: var(--text-muted);
}

.parent-name {
    color: var(--primary);
    font-weight: 500;
}

.ai-generate-drawer .form-group {
    margin-bottom: 16px;
}

.ai-generate-drawer .form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.ai-generate-drawer textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
}

.ai-generate-drawer textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.ai-generate-drawer select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
}

.generate-actions {
    margin-top: 20px;
}

/* 抽屉内的预览 */
.ai-generate-drawer .ai-generate-preview {
    margin-top: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.ai-generate-drawer .preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    font-weight: 500;
}

.ai-generate-drawer .preview-tree {
    padding: 12px 14px;
    max-height: 40vh;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.6;
}

.preview-actions {
    padding: 14px;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
}

/* 移动端 */
@media (max-width: 768px) {
    .ai-generate-drawer {
        width: 100vw;
    }
}

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

.dialog-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.btn-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}

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

.dialog-body {
    padding: 20px;
}

.dialog-body input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}

.dialog-body input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.2);
}

.dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

/* 登录表单样式 */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}

.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.15);
}

.form-error {
    color: var(--danger);
    font-size: 13px;
    margin-top: 8px;
    min-height: 20px;
}

.dialog-tip {
    text-align: center;
    padding: 12px 20px;
    font-size: 13px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

.dialog-tip a {
    color: var(--primary);
    text-decoration: none;
}

.dialog-tip a:hover {
    text-decoration: underline;
}

.activate-tip {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 16px;
    line-height: 1.6;
}

/* ============================================================
   管理员面板
   ============================================================ */
.admin-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 50vw;
    min-width: 500px;
    max-width: 800px;
    height: 100vh;
    background: var(--bg-primary);
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    z-index: 250;
    transform: translateX(0);
    transition: transform 0.3s ease;
    overflow: hidden;
}

.admin-panel.hidden {
    transform: translateX(100%);
}

.admin-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.admin-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

/* 标签导航 */
.admin-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
    padding: 0 24px;
}

.admin-tab {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.admin-tab:hover {
    color: var(--text-primary);
}

.admin-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* 标签内容 */
.admin-tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.admin-tab-content.active {
    display: block;
}

/* 卡片样式 */
.admin-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 24px;
    overflow: hidden;
}

.admin-card:last-child {
    margin-bottom: 0;
}

.admin-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.admin-card-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.admin-card-body {
    padding: 20px;
}

/* 生成表单 */
.generate-form {
    margin-bottom: 0;
}

.form-inline {
    display: flex;
    align-items: flex-end;
    gap: 16px;
}

.form-inline .form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 0;
}

.form-inline .form-group label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-inline .form-group input {
    padding: 10px 14px;
    font-size: 14px;
    width: 80px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
}

.form-inline .form-group select {
    padding: 10px 14px;
    font-size: 14px;
    width: 160px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
}

.form-inline .form-group input:focus,
.form-inline .form-group select:focus {
    outline: none;
    border-color: var(--primary);
}


.form-inline .btn {
    flex-shrink: 0;
}

/* 新生成的激活码区域 */
.new-codes-area {
    background: rgba(8, 145, 178, 0.05);
    border: 1px dashed rgba(8, 145, 178, 0.3);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-top: 20px;
}

.new-codes-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
}

.new-codes-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.new-code-item {
    background: var(--bg-primary);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: var(--text-primary);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
}

.new-code-item:hover {
    border-color: var(--primary);
    background: rgba(8, 145, 178, 0.1);
    color: var(--primary);
}

/* 激活码筛选 */
.codes-filter {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.codes-filter label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.codes-filter input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* 统计 */
.codes-stats {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    gap: 24px;
}

.stats-badge {
    font-size: 13px;
    color: var(--text-muted);
}

/* 激活码/用户表格容器 */
.codes-table-container,
.users-table-container {
    max-height: 50vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
}

.code-item,
.user-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.code-item:hover,
.user-item:hover {
    background: var(--bg-tertiary);
}

.code-item:last-child,
.user-item:last-child {
    border-bottom: none;
}

.code-item.used {
    background: var(--bg-tertiary);
    opacity: 0.5;
}

.code-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.code-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

.code-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.user-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.code-level-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
}

.code-level-badge.vip {
    background: #fef3c7;
    color: #92400e;
}

.code-level-badge.svip {
    background: #fce7f3;
    color: #9d174d;
}

.code-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    margin-left: 16px;
}

.btn-delete {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-delete:hover {
    background: var(--danger);
    color: white;
}

.btn-copy-sm {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-copy-sm:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* 用户列表 */
.user-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

.user-level {
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
    border: none;
    outline: none;
}

.user-level.basic { 
    background: var(--bg-tertiary); 
    color: var(--text-secondary); 
    border: none;
}
.user-level.vip { 
    background: #fef3c7; 
    color: #92400e; 
    border: none;
}
.user-level.svip { 
    background: #fce7f3; 
    color: #9d174d; 
    border: none;
}

.loading-text,
.empty-text {
    padding: 48px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .admin-panel {
        width: 100vw;
        min-width: unset;
    }
    
    .admin-tabs {
        padding: 0 16px;
    }
    
    .admin-tab {
        padding: 12px 16px;
        font-size: 13px;
    }
    
    .admin-tab-content {
        padding: 16px;
    }
    
    .admin-card-body {
        padding: 16px;
    }
    
    .form-inline {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .form-inline .form-group input,
    .form-inline .form-group select {
        width: 100%;
    }
    
    .form-inline .btn {
        width: 100%;
    }
    
    .header-actions {
        flex-direction: column;
        align-items: flex-end;
        gap: 8px;
    }
    
    .codes-filter {
        flex-wrap: wrap;
    }
    
    .new-codes-list {
        grid-template-columns: 1fr;
    }
    
    .code-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    
    .code-actions {
        margin-left: 0;
        margin-top: 8px;
    }
    
    .code-item {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* 用户状态 */
.user-status {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    font-size: 13px;
}

.user-info .user-name {
    color: var(--text-primary);
    font-weight: 500;
}

.user-info .user-badge {
    background: var(--primary);
    color: white;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
}

.btn-logout {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-logout:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* ============================================================
   滚动条
   ============================================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

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

/* ============================================================
   AI 对话功能
   ============================================================ */

/* 右下角浮动按钮组 */
.fab-group {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 100;
}

.fab {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
}

.fab:hover {
    transform: scale(1.1);
}

.fab-icon {
    font-size: 20px;
}

.fab-ai {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: 0 4px 12px rgba(8, 145, 178, 0.4);
}

.fab-ai:hover {
    box-shadow: 0 6px 20px rgba(8, 145, 178, 0.5);
}

.fab-comment {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.fab-comment:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
}

.fab-top {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: all 0.2s;
}

.fab-top.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.fab-top:hover {
    border-color: var(--primary);
    background: var(--bg-tertiary);
}

.fab-top .fab-icon {
    font-size: 18px;
    font-weight: bold;
    color: var(--text-secondary);
}

/* 主题切换按钮 */
.fab-theme {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.fab-theme:hover {
    border-color: var(--primary);
    background: var(--bg-tertiary);
}

.fab-theme .fab-icon {
    font-size: 18px;
}

.fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--primary);
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fab-badge:empty {
    display: none;
}

/* AI 抽屉 */
.ai-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 420px;
    max-width: 100vw;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    z-index: 200;
    transform: translateX(0);
    transition: transform 0.3s ease;
}

.ai-drawer.hidden {
    transform: translateX(100%);
}

.ai-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.ai-drawer-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.ai-title-icon {
    font-size: 20px;
}

/* AI 用户状态栏 */
.ai-drawer-status {
    padding: 12px 20px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-user-status {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}

.ai-status-level {
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.ai-status-count {
    color: var(--text-muted);
}

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

.ai-user-actions .btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

.ai-drawer-context {
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.context-label {
    color: var(--text-muted);
}

.context-name {
    color: var(--primary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-drawer-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ai-message {
    display: flex;
    flex-direction: column;
    max-width: 90%;
}

.ai-message-user {
    align-self: flex-end;
}

.ai-message-assistant {
    align-self: flex-start;
}

.ai-message-content {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
}

.ai-message-user .ai-message-content {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-message-assistant .ai-message-content {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.ai-message-loading {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
}

.ai-message-loading span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: bounce 1.4s ease-in-out infinite;
}

.ai-message-loading span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-message-loading span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes bounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}

/* AI 流式输出光标 */
.ai-streaming {
    min-height: 20px;
}

.ai-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--primary);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink 0.8s ease-in-out infinite;
}

@keyframes blink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0;
    }
}

.ai-message-content code {
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
}

.ai-message-content pre {
    background: var(--bg-secondary);
    padding: 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 8px 0;
}

.ai-message-content pre code {
    background: transparent;
    padding: 0;
}

.ai-drawer-input {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.ai-drawer-input textarea {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
}

.ai-drawer-input textarea:focus {
    border-color: var(--primary);
}

.ai-send-btn {
    height: 44px;
    padding: 0 20px;
}

/* ============================================================
   评论功能
   ============================================================ */

/* 评论抽屉 */
.comment-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 420px;
    max-width: 100vw;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    z-index: 200;
    transform: translateX(0);
    transition: transform 0.3s ease;
}

.comment-drawer.hidden {
    transform: translateX(100%);
}

.comment-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.comment-drawer-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.comment-drawer-count {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: normal;
}

.comment-drawer-doc {
    padding: 12px 20px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.comment-drawer-doc .doc-label {
    color: var(--text-muted);
}

.comment-drawer-doc .doc-name {
    color: var(--primary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 评论输入表单 */
.comment-drawer-form {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
}

.comment-form-row {
    margin-bottom: 12px;
}

.comment-form-row input {
    width: 100%;
    max-width: 200px;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.comment-form-row input:focus {
    border-color: var(--primary);
}

.comment-drawer-form textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
}

.comment-drawer-form textarea:focus {
    border-color: var(--primary);
}

.comment-form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

/* 评论列表 */
.comment-drawer-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.comment-item {
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    padding: 14px 16px;
}

.comment-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.comment-author {
    display: flex;
    align-items: center;
    gap: 8px;
}

.comment-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: white;
    font-weight: 600;
}

.comment-name {
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary);
}

.comment-time {
    font-size: 11px;
    color: var(--text-muted);
}

.comment-content {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.comments-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.comments-empty-icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* ============================================================
   空状态占位
   ============================================================ */
.empty-upload {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-upload-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.empty-upload h3 {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.empty-upload p {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 20px;
}

/* ============================================================
   关于页面
   ============================================================ */
.about-page {
    max-width: 700px;
    margin: 0 auto;
    padding: 20px 0;
}

.about-header {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, rgba(8, 145, 178, 0.1), rgba(6, 182, 212, 0.05));
    border-radius: var(--radius);
    margin-bottom: 32px;
}

.about-avatar {
    font-size: 64px;
    margin-bottom: 16px;
}

.about-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.about-desc {
    color: var(--text-secondary);
    font-size: 15px;
}

.about-content {
    padding: 0 20px;
}

.about-content h2 {
    font-size: 18px;
    font-weight: 600;
    margin-top: 32px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.about-content p {
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 12px;
}

.about-content a {
    color: var(--primary);
    text-decoration: none;
}

.about-content a:hover {
    text-decoration: underline;
}

/* ============================================================
   移动端响应式设计
   ============================================================ */

/* 菜单按钮 */
.btn-menu {
    display: none;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    font-size: 20px;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.btn-menu:hover {
    background: var(--bg-tertiary);
}

/* 工具栏布局 */
.toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

/* 小按钮 */
.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* 移动端遮罩 */
.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 149;
}

.mobile-overlay.active {
    display: block;
}

/* 平板适配 (< 1024px) */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 280px;
    }
    
    .document-content {
        padding: 24px 32px;
    }
    
    .ai-drawer,
    .comment-drawer {
        width: 360px;
    }
}

/* 手机适配 (< 768px) */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 85vw;
        --toolbar-height: 52px;
    }
    
    /* 显示菜单按钮 */
    .btn-menu {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* 侧边栏变为抽屉 */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 150;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    /* 工具栏 */
    .toolbar {
        padding: 0 12px;
    }
    
    .breadcrumb {
        font-size: 13px;
    }
    
    .breadcrumb-item {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 150px;
    }
    
    /* 用户状态简化 */
    .user-info {
        padding: 4px 8px;
    }
    
    .user-info .user-name {
        display: none;
    }
    
    .user-info .user-badge {
        font-size: 10px;
    }
    
    /* 上传按钮文字隐藏 */
    .btn-text {
        display: none;
    }
    
    #uploadBtn {
        padding: 8px 12px;
    }
    
    /* 文档内容区 */
    .document-content {
        padding: 16px;
    }
    
    .markdown-body {
        font-size: 15px;
    }
    
    .markdown-body h1 {
        font-size: 1.6em;
    }
    
    .markdown-body h2 {
        font-size: 1.3em;
    }
    
    .markdown-body h3 {
        font-size: 1.15em;
    }
    
    .markdown-body pre {
        padding: 12px;
        font-size: 13px;
    }
    
    .markdown-body table {
        font-size: 13px;
        display: block;
        overflow-x: auto;
    }
    
    .markdown-body th,
    .markdown-body td {
        padding: 8px 10px;
    }
    
    /* 欢迎页 */
    .welcome-screen h1 {
        font-size: 24px;
    }
    
    .welcome-screen p {
        font-size: 14px;
    }
    
    .welcome-icon {
        font-size: 48px;
    }
    
    .welcome-tips {
        width: 100%;
        padding: 0 16px;
    }
    
    .tip {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    /* 浮动按钮组 - 移动端缩小并调整位置 */
    .fab-group {
        bottom: 12px;
        right: 12px;
        gap: 8px;
    }
    
    .fab {
        width: 42px;
        height: 42px;
    }
    
    .fab-icon {
        font-size: 16px;
    }
    
    /* 移动端隐藏主题切换按钮，减少干扰 */
    .fab-theme {
        width: 36px;
        height: 36px;
    }
    
    .fab-theme .fab-icon {
        font-size: 14px;
    }
    
    /* 隐藏 TOC */
    .toc-sidebar {
        display: none !important;
    }
    
    .document-content.has-toc .markdown-body {
        max-width: 100%;
    }
    
    /* 抽屉全屏 */
    .ai-drawer,
    .comment-drawer {
        width: 100vw;
    }
    
    .ai-drawer-messages,
    .comment-drawer-list {
        padding: 12px;
    }
    
    /* 对话框 */
    .dialog {
        width: 90vw;
        margin: 16px;
    }
    
    .dialog-body {
        padding: 16px;
    }
    
    /* 右键菜单 */
    .context-menu {
        min-width: 160px;
    }
    
    /* 搜索框 */
    .search-box input {
        padding: 8px 10px 8px 32px;
        font-size: 13px;
    }
    
    /* 树节点 */
    .tree-node-content {
        padding: 8px 12px;
    }
    
    .tree-node-name {
        font-size: 13px;
    }
}

/* 超小屏幕 (< 480px) */
@media (max-width: 480px) {
    .toolbar-actions {
        gap: 6px;
    }
    
    .btn-sm {
        padding: 6px 10px;
    }
    
    .breadcrumb-item {
        max-width: 100px;
    }
    
    .comment-fab-count {
        font-size: 11px;
        padding: 1px 6px;
    }
    
    .ai-message-content {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .ai-drawer-input textarea,
    .comment-drawer-form textarea {
        font-size: 16px; /* 防止 iOS 缩放 */
    }
    
    .form-group input,
    .dialog-body input {
        font-size: 16px; /* 防止 iOS 缩放 */
    }
}

