* { margin: 0; padding: 0; box-sizing: border-box; }

/* ===== 主题变量：亮色（默认） ===== */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-contrast: #ffffff;
    --bg: #f3f4f6;
    --card-bg: #ffffff;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --danger: #dc2626;

    --login-grad-1: #667eea;
    --login-grad-2: #764ba2;
    --top-grad-1: #2563eb;
    --top-grad-2: #4f46e5;

    --surface-alt: #f9fafb;
    --btn-secondary-bg: #ffffff;

    --ok-bg: #f0fdf4;
    --ok-text: #16a34a;
    --ok-border: #bbf7d0;
    --err-bg: #fef2f2;
    --err-border: #fecaca;

    --dropzone-overlay: rgba(37, 99, 235, 0.12);
    --shadow-login: 0 20px 60px rgba(0, 0, 0, 0.3);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-pop: 0 8px 30px rgba(0, 0, 0, 0.2);

    --topbar-text: #ffffff;
    --topbar-btn-bg: rgba(255, 255, 255, 0.2);
    --topbar-btn-bg-hover: rgba(255, 255, 255, 0.35);

    --scrollbar-thumb: #c1c7d0;
    --scrollbar-thumb-hover: #a8afb9;
}

/* ===== 主题变量：暗黑 ===== */
[data-theme="dark"] {
    --primary: #3b82f6;
    --primary-dark: #60a5fa;
    --primary-contrast: #0b1220;
    --bg: #0f172a;
    --card-bg: #1e293b;
    --text: #e5e7eb;
    --text-muted: #94a3b8;
    --border: #334155;
    --danger: #f87171;

    --login-grad-1: #1e1b4b;
    --login-grad-2: #0f172a;
    --top-grad-1: #1e293b;
    --top-grad-2: #0f172a;

    --surface-alt: #273449;
    --btn-secondary-bg: #334155;

    --ok-bg: rgba(20, 83, 45, 0.35);
    --ok-text: #4ade80;
    --ok-border: #166534;
    --err-bg: rgba(127, 29, 29, 0.35);
    --err-border: #991b1b;

    --dropzone-overlay: rgba(59, 130, 246, 0.15);
    --shadow-login: 0 20px 60px rgba(0, 0, 0, 0.6);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-pop: 0 8px 30px rgba(0, 0, 0, 0.5);

    --topbar-text: #f1f5f9;
    --topbar-btn-bg: rgba(255, 255, 255, 0.12);
    --topbar-btn-bg-hover: rgba(255, 255, 255, 0.22);

    --scrollbar-thumb: #475569;
    --scrollbar-thumb-hover: #64748b;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    transition: background-color .25s ease, color .25s ease;
}

/* ===== 登录页 ===== */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--login-grad-1) 0%, var(--login-grad-2) 100%);
}
.login-card {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 16px;
    box-shadow: var(--shadow-login);
    width: 100%;
    max-width: 400px;
    text-align: center;
    transition: background-color .25s ease, color .25s ease;
}
.login-logo { font-size: 48px; }
.login-card h1 { font-size: 22px; margin: 12px 0 4px; }
.login-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }
.login-card form { text-align: left; }
.login-card label { display: block; font-size: 13px; color: var(--text-muted); margin: 14px 0 6px; }
.login-card input {
    width: 100%; padding: 12px 14px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 15px; transition: border-color .2s;
    background: var(--card-bg); color: var(--text);
}
.login-card input:focus { outline: none; border-color: var(--primary); }
.error-box {
    background: var(--err-bg); color: var(--danger); border: 1px solid var(--err-border);
    padding: 10px; border-radius: 8px; font-size: 14px; margin-bottom: 8px;
}

/* ===== 按钮 ===== */
.btn-primary, .btn-secondary, .btn-block, .btn-logout, .btn-mini, .btn-theme {
    cursor: pointer; border: none; border-radius: 8px; font-size: 14px;
    transition: all .15s; text-decoration: none; display: inline-block;
    font-family: inherit;
}
.btn-primary { background: var(--primary); color: var(--primary-contrast); padding: 10px 18px; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-block { width: 100%; margin-top: 24px; padding: 12px; font-size: 16px; }
.btn-secondary { background: var(--btn-secondary-bg); color: var(--text); border: 1px solid var(--border); padding: 10px 18px; }
.btn-secondary:hover { background: var(--surface-alt); }
.btn-danger { background: var(--danger); color: #ffffff; padding: 10px 18px; }
.btn-danger:hover { filter: brightness(0.9); }
.btn-mini { background: transparent; color: var(--primary); padding: 4px 10px; font-size: 13px; border: 1px solid var(--border); }
.btn-mini:hover { background: var(--surface-alt); }
.btn-mini.btn-danger { color: var(--danger); background: transparent; padding: 4px 10px; }
.btn-mini.btn-danger:hover { background: var(--err-bg); border-color: var(--err-border); }
.btn-logout { color: var(--topbar-text); background: var(--topbar-btn-bg); padding: 6px 14px; }
.btn-logout:hover { background: var(--topbar-btn-bg-hover); }

/* ===== 主题切换按钮 ===== */
.btn-theme {
    background: var(--topbar-btn-bg); color: var(--topbar-text);
    font-size: 16px; line-height: 1; padding: 6px 10px;
}
.btn-theme:hover { background: var(--topbar-btn-bg-hover); }
.btn-theme-float {
    position: fixed; top: 18px; right: 18px; z-index: 10;
    background: rgba(255, 255, 255, 0.2); color: #fff;
    backdrop-filter: blur(4px); font-size: 18px; padding: 8px 12px;
}
.btn-theme-float:hover { background: rgba(255, 255, 255, 0.35); }

/* ===== 顶栏 ===== */
.topbar {
    background: linear-gradient(135deg, var(--top-grad-1) 0%, var(--top-grad-2) 100%);
    color: var(--topbar-text); padding: 14px 24px; display: flex;
    align-items: center; justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 24px; }
.app-title { font-size: 18px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.current-user { font-size: 14px; opacity: 0.92; }

/* ===== 主容器 ===== */
.container { max-width: 1100px; margin: 24px auto; padding: 0 24px; }
.breadcrumb { font-size: 14px; margin-bottom: 16px; color: var(--text-muted); word-break: break-all; }
.breadcrumb a { color: var(--primary); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.crumb-sep { color: var(--text-muted); }
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }

/* ===== 拖拽遮罩 ===== */
.drop-zone {
    display: none; position: fixed; inset: 0; z-index: 100;
    background: var(--dropzone-overlay); backdrop-filter: blur(2px);
    align-items: center; justify-content: center;
}
.drop-zone.drop-active { display: flex; }
.drop-zone-inner {
    background: var(--card-bg); border: 3px dashed var(--primary); border-radius: 16px;
    padding: 60px 80px; text-align: center;
}
.drop-icon { font-size: 48px; }
.drop-zone-inner p { font-size: 18px; color: var(--primary); margin-top: 10px; }

/* ===== 状态条 ===== */
.status-bar { padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 14px; }
.status-ok { background: var(--ok-bg); color: var(--ok-text); border: 1px solid var(--ok-border); }
.status-error { background: var(--err-bg); color: var(--danger); border: 1px solid var(--err-border); }

/* ===== 文件表格 ===== */
.file-table-wrapper {
    background: var(--card-bg); border-radius: 12px; overflow: hidden;
    box-shadow: var(--shadow-card); transition: background-color .25s ease;
}
.file-table { width: 100%; border-collapse: collapse; }
.file-table th {
    text-align: left; padding: 12px 16px; font-size: 13px; color: var(--text-muted);
    background: var(--surface-alt); border-bottom: 1px solid var(--border); font-weight: 600;
}
.file-table td { padding: 10px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
.file-table tr:last-child td { border-bottom: none; }
.file-table tbody tr:hover { background: var(--surface-alt); }
td.col-name { display: flex; align-items: center; gap: 8px; }
.file-icon { font-size: 18px; flex-shrink: 0; }
.name-link { color: var(--text); text-decoration: none; word-break: break-all; cursor: pointer; }
.name-link:hover { color: var(--primary); text-decoration: underline; }
.dir-link { font-weight: 500; }
.col-size, .col-modified { width: 150px; color: var(--text-muted); white-space: nowrap; }
.col-actions { width: 210px; white-space: nowrap; }
.col-actions .btn-mini { margin-right: 6px; }
.empty-tip { padding: 60px; text-align: center; color: var(--text-muted); }

/* ===== 上传进度 ===== */
.upload-progress {
    position: fixed; bottom: 24px; right: 24px; z-index: 200;
    background: var(--card-bg); border-radius: 10px; padding: 14px 18px; width: 280px;
    box-shadow: var(--shadow-pop);
}
.upload-progress-text { font-size: 13px; margin-bottom: 8px; color: var(--text); }
.upload-progress-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.upload-progress-fill { height: 100%; width: 0; background: var(--primary); transition: width .2s; }

/* ===== 留言板 ===== */
/* 整页 flex：历史框占满窗口剩余高度，随窗口缩放 */
.board-body { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.board-body .topbar { flex-shrink: 0; }
.board-main { flex: 1; display: flex; flex-direction: column; min-height: 0; max-width: none; margin: 24px 0; }
.board-main .board-toolbar { flex-shrink: 0; }
/* 状态提示：屏幕正中悬浮 toast（仅动画 opacity，避免与居中 transform 冲突） */
@keyframes toast-in { from { opacity: 0; } to { opacity: 1; } }
.board-body .status-bar {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    z-index: 300; margin: 0; min-width: 220px; text-align: center;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .3); animation: toast-in .16s ease-out;
}
/* 工具行 + 发布按钮 */
.board-toolbar { display: flex; justify-content: flex-end; margin-bottom: 14px; }
/* 悬浮弹窗 */
.modal-overlay {
    display: none; position: fixed; inset: 0; z-index: 100;
    background: rgba(0, 0, 0, .45);
    align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal-card {
    background: var(--card-bg); border-radius: 14px; padding: 20px;
    width: 100%; max-width: 460px; box-shadow: 0 12px 40px rgba(0, 0, 0, .28);
    animation: modal-in .16s ease-out;
}
@keyframes modal-in {
    from { opacity: 0; transform: translateY(-12px) scale(.98); }
    to { opacity: 1; transform: none; }
}
.modal-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 14px; }
.modal-hint { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.modal-message { font-size: 14px; color: var(--text); line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
/* 下载方式选择弹窗 */
.dl-option {
    display: flex; align-items: center; gap: 8px; padding: 10px 12px;
    border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
    margin-bottom: 8px; font-size: 14px; color: var(--text);
    transition: all .15s;
}
.dl-option:hover { background: var(--surface-alt); }
.dl-option input[type="radio"] { accent-color: var(--primary); }
.dl-threads-row {
    display: flex; align-items: center; gap: 8px; font-size: 13px;
    color: var(--text-muted); margin: 4px 0 8px;
}
.dl-threads-row select {
    background: var(--btn-secondary-bg); color: var(--text);
    border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; font-size: 13px;
}
.dl-remember { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); cursor: pointer; }
.dl-remember input[type="checkbox"] { accent-color: var(--primary); }
/* 多线程下载进度悬浮条 */
.dl-progress {
    position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
    z-index: 250; width: min(420px, calc(100vw - 40px));
    background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px;
    padding: 14px 16px; box-shadow: 0 12px 40px rgba(0,0,0,.28);
}
.dl-progress-name {
    font-size: 13px; color: var(--text); margin-bottom: 8px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dl-progress-bar { height: 8px; background: var(--surface-alt); border-radius: 4px; overflow: hidden; }
.dl-progress-fill { height: 100%; width: 0%; background: var(--primary); border-radius: 4px; transition: width .15s; }
.dl-progress-row {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 8px; font-size: 12px; color: var(--text-muted);
}
.modal-card input[type="text"],
.modal-card textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--bg); color: var(--text); font-size: 14px; font-family: inherit;
    box-sizing: border-box;
}
.modal-card textarea { min-height: 110px; resize: vertical; }
.modal-card input:focus,
.modal-card textarea:focus { outline: none; border-color: var(--primary); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.board-section-title { font-size: 15px; color: var(--text-muted); margin-bottom: 12px; font-weight: 600; }
/* 历史记录框：聊天窗口式，固定高度框内滚动 */
.note-frame {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 14px 16px;
    box-shadow: var(--shadow-card);
    margin-bottom: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}
.note-frame::-webkit-scrollbar { width: 10px; }
.note-frame::-webkit-scrollbar-track { background: transparent; }
.note-frame::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 6px;
}
.note-frame::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }
.note-frame .empty-tip { padding: 60px 0; }
.note-list { display: flex; flex-direction: column; gap: 12px; }
.note-card { background: var(--card-bg); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow-card); }
.note-meta {
    display: flex; align-items: center; gap: 10px; font-size: 12px;
    color: var(--text-muted); margin-bottom: 8px; flex-wrap: wrap;
}
.note-author { font-weight: 600; color: #6495CC; }
.note-time { margin-left: auto; }
.note-meta .btn-mini { margin-left: 8px; }
.note-content { font-size: 14px; color: var(--text); white-space: pre-wrap; word-break: break-word; line-height: 1.6; }
/* 分页控件（历史框下面） */
.pager {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    margin-top: 14px; flex-shrink: 0; flex-wrap: wrap;
}
.pager-btn {
    cursor: pointer; min-width: 32px; height: 32px; padding: 0 8px;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--btn-secondary-bg); color: var(--text); font-size: 13px;
    transition: all .15s;
}
.pager-btn:hover:not(:disabled) { background: var(--surface-alt); }
.pager-btn:disabled { opacity: .4; cursor: not-allowed; }
.pager-btn.active { background: var(--primary); color: var(--primary-contrast); border-color: var(--primary); }
.pager-ellipsis { color: var(--text-muted); padding: 0 2px; }
.pager-info { margin-left: 10px; font-size: 12px; color: var(--text-muted); }

/* ===== 响应式 ===== */
@media (max-width: 640px) {
    th.col-modified, td.col-modified { display: none; }
    .col-size { width: 80px; }
    .col-actions { width: 150px; }
    .container { padding: 0 12px; }
    .app-title { font-size: 15px; }
}
