/* ============================================================
   biji666.com 笔记管理 - 全局样式
   ============================================================ */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --bg: #f8fafc;
    --bg-white: #ffffff;
    --bg-hover: #f1f5f9;
    --bg-active: #dbeafe;
    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
    --shadow: 0 1px 3px 0 rgba(0,0,0,0.1), 0 1px 2px 0 rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --radius: 8px;
    --radius-sm: 6px;
    --sidebar-width: 280px;
    --toolbar-height: 48px;
}

/* ============ 深色主题 ============ */
[data-theme="dark"] {
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-light: #1e3a5f;
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --danger-hover: #ef4444;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --border-light: #1e293b;
    --bg: #0f172a;
    --bg-white: #1e293b;
    --bg-hover: #334155;
    --bg-active: #1e3a5f;
    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.3);
    --shadow: 0 1px 3px 0 rgba(0,0,0,0.4), 0 1px 2px 0 rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4), 0 2px 4px -1px rgba(0,0,0,0.3);
}

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

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg);
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input {
    font-family: inherit;
}

/* ============================================================
   主布局
   ============================================================ */

.note-app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ---------- 侧边栏 ---------- */

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    height: var(--toolbar-height);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: var(--bg-white);
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    cursor: pointer;
}
.brand:hover { opacity: 0.85; }

.brand i {
    font-size: 20px;
}

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

.icon-btn {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all 0.15s;
    font-size: 14px;
}

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

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

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

/* ---------- 搜索框 ---------- */

.sidebar-search {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
}

.search-input-wrap {
    position: relative;
}

.search-input-wrap i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 12px;
}

.search-input {
    width: 100%;
    height: 32px;
    padding: 0 10px 0 30px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--bg);
    transition: all 0.15s;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-white);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* ---------- 菜单树 ---------- */

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

.menu-node {
    user-select: none;
}

.menu-node-header {
    display: flex;
    align-items: center;
    height: 32px;
    padding: 0 12px;
    cursor: default;
    transition: background 0.15s;
    position: relative;
}

.menu-node-header:hover {
    background: var(--bg-hover);
}

.menu-node-header.active {
    background: var(--primary-light);
    color: var(--primary);
}

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

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

.menu-toggle i {
    line-height: 1;
    display: block;
}

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

.menu-toggle.leaf {
    visibility: hidden;
}

.menu-icon {
    margin: 0 6px;
    font-size: 13px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.menu-name {
    flex: 1;
    font-size: 13px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.menu-count {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-hover);
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 6px;
}

.menu-node-header.active .menu-count {
    background: var(--bg-white);
    color: var(--primary);
}

.menu-actions {
    display: none;
    gap: 2px;
}

.menu-node-header:hover .menu-actions {
    display: flex;
}

.menu-actions .icon-btn {
    width: 22px;
    height: 22px;
    font-size: 11px;
}

.menu-children {
    display: none;
}

.menu-children.expanded {
    display: block;
}

/* "全部文章" 特殊节点 */
.menu-node.all-articles .menu-node-header {
    font-weight: 600;
}

/* ---------- 侧边栏底部 ---------- */

.sidebar-footer {
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
}

.footer-btn {
    flex: 1;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}

.footer-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

/* ============================================================
   文章列表
   ============================================================ */

.article-panel {
    width: 260px;
    background: var(--bg-white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.article-panel-header {
    height: var(--toolbar-height);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

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

.article-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.article-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: default;
    transition: background 0.15s;
    margin-bottom: 2px;
    border: 1px solid transparent;
}

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

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

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

.article-type-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    margin-right: 10px;
    flex-shrink: 0;
}

.article-type-icon.rich {
    background: #dbeafe;
    color: #2563eb;
}

.article-type-icon.markdown {
    background: #dcfce7;
    color: #16a34a;
}

.article-type-icon.drawio {
    background: #fef3c7;
    color: #d97706;
}

.article-type-icon.mind {
    background: #ede9fe;
    color: #7c3aed;
}

.article-info {
    flex: 1;
    min-width: 0;
}

.article-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 2px;
}

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

/* 空状态 */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 20px;
    color: var(--text-muted);
    text-align: center;
}

.empty-state i {
    font-size: 44px;
    /*margin-bottom: 14px;*/
    opacity: 0.35;
}

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

.empty-state .btn-primary-sm {
    padding: 10px 22px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-md, 8px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.empty-state .btn-primary-sm:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

/* ============================================================
   内容编辑区
   ============================================================ */

.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    min-width: 0;
}

.content-toolbar {
    height: var(--toolbar-height);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    flex-shrink: 0;
}

.content-toolbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.content-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 400px;
}

/* 保存状态（标题右侧，标准文档编辑器样式） */
.save-status-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    line-height: 1;
    color: var(--text-muted);
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: 999px;
    padding: 4px 10px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: color 0.2s, border-color 0.2s;
}

.save-status-inline .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    flex-shrink: 0;
}

.save-status-inline.saving .dot {
    background: var(--warning);
    animation: save-pulse 1s infinite;
}

.save-status-inline.error {
    color: var(--danger);
    border-color: var(--danger);
}

.save-status-inline.error .dot {
    background: var(--danger);
}

@keyframes save-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.content-type-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.content-type-badge.rich {
    background: #dbeafe;
    color: #2563eb;
}

.content-type-badge.markdown {
    background: #dcfce7;
    color: #16a34a;
}

.content-type-badge.drawio {
    background: #fef3c7;
    color: #d97706;
}

.content-type-badge.mind {
    background: #ede9fe;
    color: #7c3aed;
}

.content-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-size-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.page-size-selector select {
    height: 28px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    background: var(--bg-white);
    color: var(--text-primary);
    cursor: pointer;
}

/* 深色主题下原生下拉选项也用深色底、浅色字 */
[data-theme="dark"] .page-size-selector select option {
    background: var(--bg-white);
    color: var(--text-primary);
}

.page-size-selector select:focus {
    outline: none;
    border-color: var(--primary);
}

.content-frame-wrap {
    flex: 1;
    position: relative;
    background: var(--bg);
    overflow: hidden;
}

.content-frame {
    width: 100%;
    height: 100%;
    border: none;
    background: var(--bg-white);
}

.content-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    background: var(--bg);
}

.content-placeholder i {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.content-placeholder h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.content-placeholder p {
    font-size: 13px;
}

/* ============================================================
   按钮
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 13px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    transition: all 0.15s;
    white-space: nowrap;
}

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

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

.btn-secondary {
    background: var(--bg-white);
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

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

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

.btn-primary-sm {
    background: var(--primary);
    color: white;
    padding: 6px 14px;
    font-size: 13px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

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

.btn-ghost {
    color: var(--text-secondary);
    background: transparent;
}

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

/* ============================================================
   模态框
   ============================================================ */

.modal-mask {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-mask.show {
    display: flex;
}

.modal {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    width: 90%;
    max-width: 440px;
    overflow: hidden;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

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

.modal-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    border-radius: 4px;
    transition: all 0.15s;
}

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

.modal-body {
    padding: 20px;
}

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

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

.form-group:last-child {
    margin-bottom: 0;
}

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

.form-control {
    width: 100%;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    transition: all 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* 类型选择卡片 */

.type-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.type-card {
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
}

.type-card:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.type-card.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

.type-card i {
    font-size: 22px;
    margin-bottom: 6px;
    display: block;
}

.type-card.rich i { color: #2563eb; }
.type-card.markdown i { color: #16a34a; }
.type-card.drawio i { color: #d97706; }
.type-card.mind i { color: #7c3aed; }

.type-card span {
    font-size: 12px;
    color: var(--text-secondary);
}

.type-card.selected span {
    color: var(--primary);
    font-weight: 500;
}

/* ============================================================
   Toast 提示
   ============================================================ */

.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-white);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    min-width: 200px;
    animation: toastIn 0.2s ease;
    border-left: 3px solid var(--primary);
}

@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.success { border-left-color: var(--success); }
.toast.success i { color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.warning i { color: var(--warning); }
.toast.error { border-left-color: var(--danger); }
.toast.error i { color: var(--danger); }

/* ============================================================
   滚动条
   ============================================================ */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ============================================================
   上下文菜单
   ============================================================ */

.context-menu {
    position: fixed;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: 4px 0;
    min-width: 140px;
    z-index: 10001;
    display: none;
}

.context-menu.show {
    display: block;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.1s;
}

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

.context-menu-item.danger {
    color: var(--danger);
}

.context-menu-item.danger:hover {
    background: #fee2e2;
}

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

/* ============================================================
   回收站面板
   ============================================================ */

.recycle-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: var(--bg-white);
    box-shadow: -4px 0 16px rgba(0,0,0,0.1);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    transition: right 0.25s ease;
}

.recycle-panel.show {
    right: 0;
}

.recycle-panel-header {
    height: var(--toolbar-height);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.recycle-panel-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.recycle-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.recycle-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
    transition: background 0.15s;
}

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

.recycle-item .article-type-icon {
    width: 26px;
    height: 26px;
    font-size: 12px;
}

.recycle-item-info {
    flex: 1;
    min-width: 0;
}

.recycle-item-title {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

/* 加载动画 */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(37,99,235,0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================================
   面板折叠/展开
   ============================================================ */

.sidebar, .article-panel {
    transition: width 0.25s ease, transform 0.25s ease, opacity 0.2s ease;
}

.sidebar.collapsed {
    width: 0 !important;
    overflow: hidden;
    opacity: 0;
}

.article-panel.collapsed {
    width: 0 !important;
    overflow: hidden;
    opacity: 0;
}

/* 折叠面板展开条：竖向驻留条（图标 + 竖排文字 + 箭头），明确标识是哪个面板 */
.panel-expand-btn {
    flex-shrink: 0;
    background: var(--bg-white);
    border: none;
    border-right: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 0;
    gap: 10px;
    transition: background 0.15s, color 0.15s;
}

.panel-expand-btn > i:first-child {
    font-size: 14px;
}

/* 竖排文字 */
.panel-expand-label {
    writing-mode: vertical-rl;
    font-size: 12px;
    letter-spacing: 2px;
    line-height: 1;
}

.panel-expand-arrow {
    font-size: 10px;
    opacity: 0.6;
    margin-top: auto;
    padding-bottom: 4px;
}

.panel-expand-btn:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.panel-expand-btn:hover .panel-expand-arrow {
    opacity: 1;
}

/* 折叠面板展开区：左右按钮纵向叠放 */
.panel-expand-stack {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

/* 按钮显隐用 class 控制（面板展开时隐藏对应按钮） */
.panel-expand-stack .panel-expand-btn.is-hidden {
    display: none;
}

/* 两个面板都折叠时：默认只露第一个（菜单），第二个（文章列表）收起 */
.panel-expand-stack.both-collapsed #btn-expand-articles:not(.is-hidden) {
    width: 0;
    overflow: hidden;
    opacity: 0;
    padding-left: 0;
    padding-right: 0;
    border-right-width: 0;
    transition: width 0.2s ease, opacity 0.2s ease;
}

/* 悬停展开区时，第二个按钮滑出，可分别展开菜单或文章列表 */
.panel-expand-stack.both-collapsed:hover #btn-expand-articles:not(.is-hidden) {
    width: 40px;
    opacity: 1;
    border-right-width: 1px;
}

/* 展开条宽度（单面板折叠或双折叠都统一 40px） */
.panel-expand-btn:not(.is-hidden) {
    width: 40px;
}

/* 双折叠时给展开区一点可悬停的热区宽度 */
.panel-expand-stack.both-collapsed {
    min-width: 40px;
}


/* ============================================================
   面板宽度拖拽调整
   ============================================================ */

.panel-resizer {
    width: 6px;
    flex-shrink: 0;
    position: relative;
    cursor: col-resize;
    z-index: 5;
}

/* 默认不可见的指示线，悬停时高亮 */
.panel-resizer::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 2px;
    width: 2px;
    background: transparent;
    transition: background 0.15s;
}

.panel-resizer:hover::after {
    background: var(--primary-light);
}

.panel-resizer.active::after {
    background: var(--primary);
    width: 3px;
}

/* 折叠时隐藏对应手柄 */
.sidebar.collapsed + .panel-resizer,
.article-panel.collapsed + .panel-resizer {
    display: none;
}

/* 拖拽中：锁定光标、禁止选中文本、屏蔽 iframe 捕获鼠标、关闭宽度过渡 */
body.resizing {
    cursor: col-resize;
    user-select: none;
    -webkit-user-select: none;
}

body.resizing iframe {
    pointer-events: none;
}

body.resizing .sidebar,
body.resizing .article-panel {
    transition: none;
}

/* 深色主题滚动条 */
[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #475569;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

[data-theme="dark"] .form-control:focus {
    box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}

/* ============================================================
   拖拽排序
   ============================================================ */

.menu-node-header, .article-item {
    position: relative;
}

.draggable {
    /* 拖拽功能由 draggable 属性提供，不显示手型光标 */
}

.dragging {
    opacity: 0.4 !important;
}

.drag-over-top::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 8px;
    right: 8px;
    height: 2px;
    background: var(--primary);
    border-radius: 1px;
    z-index: 10;
}

.drag-over-bottom::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 8px;
    right: 8px;
    height: 2px;
    background: var(--primary);
    border-radius: 1px;
    z-index: 10;
}

/* 拖拽手柄（可选视觉提示） */
.drag-handle {
    opacity: 0;
    color: var(--text-muted);
    font-size: 12px;
    margin-right: 4px;
    transition: opacity 0.15s;
}

.menu-node-header:hover .drag-handle,
.article-item:hover .drag-handle {
    opacity: 0.5;
}

/* ============================================================
   按日增量备份弹窗
   ============================================================ */

/* 备份按钮图标：代理在线=安全色，离线=警告色（每 30 秒巡检） */
#btn-backup.agent-online i {
    color: var(--success);
}

#btn-backup.agent-offline i {
    color: var(--warning);
}

.backup-modal-body {
    max-height: 70vh;
    overflow-y: auto;
}

.backup-section {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

.backup-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.backup-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.backup-key-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.backup-key-row .form-control {
    flex: 1;
    font-family: Consolas, Monaco, monospace;
    font-size: 12px;
    background: var(--bg);
}

.backup-tip {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ============ Linux 一键命令安装指引 ============ */
.agent-cmd-panel {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: 8px;
}

.agent-cmd-intro {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 10px;
}

.agent-cmd-block {
    margin-bottom: 10px;
}

.agent-cmd-block:last-of-type {
    margin-bottom: 0;
}

.agent-cmd-block-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.agent-cmd-block-head i {
    color: var(--primary);
    margin-right: 4px;
}

.agent-cmd-copy {
    flex-shrink: 0;
    border: 1px solid var(--border-light);
    background: var(--bg-elevated, #fff);
    color: var(--text-secondary);
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.agent-cmd-copy:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.agent-cmd-pre {
    margin: 0;
    padding: 10px 12px;
    background: #1e293b;
    color: #e2e8f0;
    border-radius: 6px;
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 11.5px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
    overflow-x: auto;
    user-select: all;
}

.agent-cmd-note {
    margin-top: 10px;
    font-size: 11.5px;
    color: var(--text-muted);
    line-height: 1.7;
}

.agent-cmd-note i {
    color: var(--primary);
    margin-right: 4px;
}

.agent-cmd-note code {
    background: var(--bg-elevated, #eef2f7);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 1px 5px;
    font-family: Consolas, Monaco, monospace;
    font-size: 11px;
    color: var(--text-primary);
}

.backup-option {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.backup-option-text {
    flex: 1;
}

.backup-option-label {
    font-size: 13px;
    color: var(--text-primary);
}

.backup-option-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
    line-height: 1.4;
}

.backup-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

/* 开关 */
.backup-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}

.backup-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.backup-slider {
    position: absolute;
    inset: 0;
    cursor: pointer;
    background: var(--border);
    border-radius: 20px;
    transition: background 0.2s;
}

.backup-slider::before {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: var(--shadow-sm);
}

.backup-switch input:checked + .backup-slider {
    background: var(--primary);
}

.backup-switch input:checked + .backup-slider::before {
    transform: translateX(16px);
}

/* 代理状态 */
.backup-agent-status {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
}

.backup-agent i,
.backup-agent-offline i {
    font-size: 8px;
    margin-right: 4px;
    vertical-align: middle;
}

.backup-agent.online {
    color: var(--success);
}

.backup-agent.offline,
.backup-agent-offline {
    color: var(--text-muted);
}

/* 备份记录 */
.backup-records {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
}

.backup-records-empty {
    padding: 20px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
}

.backup-record-item {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
}

.backup-record-item:last-child {
    border-bottom: none;
}

.backup-record-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.backup-record-date {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.backup-record-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.backup-record-sub {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: 3px;
}

.backup-record-status {
    font-size: 11px;
    padding: 1px 8px;
    border-radius: 10px;
}

.backup-record-status.pending {
    background: var(--primary-light);
    color: var(--primary);
}

.backup-record-status.downloaded {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
}

.backup-record-status.expired {
    background: var(--bg-hover);
    color: var(--text-muted);
}

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