/* 小白云盘系统V1.0 UI —— 响应式，桌面/移动同一套 */
:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --panel-2: #f0f3f9;
    --text: #1e293b;
    --muted: #64748b;
    --line: #e2e8f0;
    --brand: #2563eb;
    --brand-soft: #dbeafe;
    --danger: #dc2626;
    --ok: #16a34a;
    --radius: 12px;
    --shadow: 0 10px 30px rgba(15, 23, 42, .12);
    --sidebar-w: 232px;
    --topbar-h: 60px;
    --footer-h: 46px;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b1220;
        --panel: #131c2e;
        --panel-2: #1b2740;
        --text: #e2e8f0;
        --muted: #94a3b8;
        --line: #253148;
        --brand: #3b82f6;
        --brand-soft: #1e3a8a;
        --shadow: 0 10px 30px rgba(0, 0, 0, .45);
    }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
    margin: 0; background: var(--bg); color: var(--text);
    font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
    /* 整页纵向布局：内容区自适应撑满，页脚永远贴在最底部 */
    display: flex; flex-direction: column; min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
.ic { width: 18px; height: 18px; flex: 0 0 auto; }
.hint { color: var(--muted); font-size: 12.5px; }
.break { word-break: break-all; }
.only-mobile { display: none !important; }

/* ── 图标按钮 / 按钮 ─────────────────────────── */
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border: 0; border-radius: 9px;
    background: transparent; color: var(--muted); cursor: pointer; transition: .15s;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn.danger:hover { background: #fee2e2; color: var(--danger); }
.btn {
    display: inline-flex; align-items: center; gap: 6px; justify-content: center;
    padding: 9px 14px; border: 0; border-radius: 9px; cursor: pointer;
    background: var(--brand); color: #fff; font-weight: 600; font-size: 14px;
    transition: .15s; white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: var(--panel-2); color: var(--text); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; padding: 12px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.input, .select {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
    background: var(--panel); outline: none;
}
.input:focus, .select:focus { border-color: var(--brand); }
.select { width: auto; padding: 7px 10px; font-size: 13px; }

/* ── 页脚（每个页面底部都有）──────────────────── */
.site-footer {
    flex: 0 0 auto;
    text-align: center;
    padding: 12px 16px;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--muted);
    background: var(--panel);
    border-top: 1px solid var(--line);
}

/* ── 登录 ─────────────────────────────────────── */
#auth { flex: 1 0 auto; display: flex; align-items: center; justify-content: center; padding: 20px; }
/* 登录成功后必须整个隐藏：否则它会在页面顶部留一整屏空白 */
#auth[hidden] { display: none !important; }
.auth-card {
    width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line);
    border-radius: 18px; padding: 30px 26px; box-shadow: var(--shadow); text-align: center;
}
.auth-logo {
    width: 54px; height: 54px; margin: 0 auto 12px; border-radius: 15px;
    background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center;
}
.auth-logo .ic { width: 28px; height: 28px; }
.auth-card h1 { font-size: 20px; margin: 0 0 4px; }
.auth-sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.auth-tabs { display: flex; background: var(--panel-2); border-radius: 10px; padding: 4px; margin-bottom: 16px; }
.auth-tabs button {
    flex: 1; padding: 8px; border: 0; background: transparent; border-radius: 7px;
    cursor: pointer; color: var(--muted); font-weight: 600;
}
.auth-tabs button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
#auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-card .hint.err { color: var(--danger); }

/* ── 主框架 ───────────────────────────────────── */
#app { flex: 1 0 auto; display: grid; grid-template-columns: var(--sidebar-w) 1fr; }
#app[hidden], #upload-dock[hidden] { display: none !important; }
#sidebar {
    background: var(--panel); border-right: 1px solid var(--line);
    display: flex; flex-direction: column; padding: 14px 12px; gap: 6px;
    position: sticky; top: 0; height: calc(100vh - var(--footer-h));
}
.brand { display: flex; align-items: center; gap: 9px; padding: 6px 8px 14px; font-weight: 700; }
.brand .ic { color: var(--brand); }
#nav { display: flex; flex-direction: column; gap: 3px; }
#nav button, .side-foot button {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 0; border-radius: 9px;
    background: transparent; color: var(--text); cursor: pointer; text-align: left; font-size: 14.5px;
}
#nav button:hover, .side-foot button:hover { background: var(--panel-2); }
#nav button.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 3px; }
.quota { padding: 12px 10px 4px; }
.quota-bar { height: 6px; border-radius: 4px; background: var(--panel-2); overflow: hidden; }
.quota-bar i { display: block; height: 100%; background: var(--brand); }
.quota-text { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12px; color: var(--muted); }

#main { min-width: 0; display: flex; flex-direction: column; }
#topbar {
    height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 18px;
    border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 20;
}
.search-wrap { flex: 1; max-width: 520px; display: flex; align-items: center; gap: 8px;
    background: var(--panel-2); border-radius: 10px; padding: 0 12px; height: 38px; color: var(--muted); }
.search-wrap input { flex: 1; border: 0; background: transparent; outline: none; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.top-actions .icon-btn { background: var(--brand); color: #fff; font-weight: 700; border-radius: 50%; }

#content { padding: 16px 18px 120px; }
.loading { padding: 60px 0; text-align: center; color: var(--muted); }

/* ── 面包屑 / 工具栏 ─────────────────────────── */
.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.crumbs button {
    border: 0; background: transparent; color: var(--text); cursor: pointer;
    padding: 5px 8px; border-radius: 8px; display: inline-flex; align-items: center; gap: 5px; font-size: 14px;
}
.crumbs button:hover { background: var(--panel-2); }
.crumbs .sep { color: var(--muted); }
.flat-title { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.toolbar {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 10px 12px; background: var(--panel); border: 1px solid var(--line);
    border-radius: var(--radius); margin-bottom: 12px;
}
.tb-left, .tb-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tb-right { margin-left: auto; }
.sel-info { font-weight: 600; color: var(--brand); }

/* ── 文件列表 ────────────────────────────────── */
.file-list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row {
    display: grid; grid-template-columns: 34px 40px 1fr 96px 130px 150px;
    align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--line);
    cursor: default; transition: background .12s;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--panel-2); }
.row.sel { background: var(--brand-soft); }
.chk { display: flex; align-items: center; justify-content: center; cursor: pointer; }
.chk input { width: 17px; height: 17px; accent-color: var(--brand); cursor: pointer; }
.ficon { font-size: 22px; text-align: center; overflow: hidden; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.ficon .thumb { width: 34px; height: 34px; object-fit: cover; border-radius: 7px; }
.fname { min-width: 0; display: flex; flex-direction: column; cursor: pointer; }
.fname .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
.fname .meta { color: var(--muted); font-size: 12px; display: none; }
.fsize, .ftime { color: var(--muted); font-size: 13px; }
.fops { display: flex; gap: 2px; justify-content: flex-end; opacity: .35; transition: opacity .15s; }
.row:hover .fops, .row.sel .fops { opacity: 1; }

.file-list.as-grid, .file-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px;
    background: transparent; border: 0;
}
.file-grid { padding: 0; }
.cell {
    position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    overflow: hidden; display: flex; flex-direction: column;
}
.cell.sel { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.cell .chk { position: absolute; top: 8px; left: 8px; z-index: 2;
    background: rgba(255, 255, 255, .85); border-radius: 6px; padding: 2px; }
.cell-body { height: 130px; display: flex; align-items: center; justify-content: center;
    background: var(--panel-2); cursor: pointer; overflow: hidden; }
.cell-body img { width: 100%; height: 100%; object-fit: cover; }
.grid-icon { font-size: 40px; }
.cell-foot { padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; }
.cell-foot .nm { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-more { position: absolute; right: 6px; bottom: 6px; background: var(--panel); }
.tag { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; padding: 1px 6px;
    border-radius: 6px; background: var(--panel-2); color: var(--muted); }
.tag.ok { background: #dcfce7; color: #166534; }
.tag.danger { background: #fee2e2; color: #991b1b; }
@media (prefers-color-scheme: dark) {
    .tag.ok { background: #14532d; color: #86efac; }
    .tag.danger { background: #7f1d1d; color: #fca5a5; }
}

.empty { text-align: center; padding: 70px 20px; color: var(--muted); display: flex;
    flex-direction: column; align-items: center; gap: 8px; }
.empty .ic { width: 42px; height: 42px; opacity: .5; }

/* ── 分享列表 ────────────────────────────────── */
.share-list { display: flex; flex-direction: column; gap: 10px; }
.share-row {
    display: flex; gap: 12px; align-items: center; background: var(--panel);
    border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
}
.share-main { min-width: 0; flex: 1; }
.share-name { font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.share-meta { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.share-url { margin-top: 4px; word-break: break-all; }
.share-ops { display: flex; gap: 6px; align-items: center; }

/* ── 弹窗 / 菜单 / 提示 ──────────────────────── */
#modal-layer { position: fixed; inset: 0; pointer-events: none; z-index: 60; }
.modal-back {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .55); display: flex;
    align-items: center; justify-content: center; padding: 16px; pointer-events: auto;
    animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.modal {
    width: 100%; max-width: 440px; max-height: 88vh; background: var(--panel); border-radius: 16px;
    box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden;
}
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 16px; overflow: auto; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.confirm-text { margin: 0; }
.form { display: flex; flex-direction: column; gap: 8px; }
.form label { font-size: 13px; color: var(--muted); margin-top: 4px; }
.kv { display: flex; flex-direction: column; gap: 1px; background: var(--line); border-radius: 10px; overflow: hidden; }
.kv > div { display: flex; gap: 10px; padding: 9px 12px; background: var(--panel); }
.kv > div > span { color: var(--muted); width: 90px; flex: 0 0 auto; font-size: 13px; }
.kv > div > b { font-weight: 500; font-size: 13.5px; min-width: 0; }
.picker { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
.tnode { display: flex; align-items: center; gap: 7px; padding: 7px 9px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.tnode:hover { background: var(--panel-2); }
.tnode.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.copy-list { display: flex; flex-direction: column; gap: 12px; }
.copy-row { border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: flex;
    flex-direction: column; gap: 8px; position: relative; }
.copy-row .mini { width: 100%; max-height: 160px; object-fit: contain; border-radius: 8px; background: var(--panel-2); }
.copy-info { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.copy-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.log-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.log-table th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.log-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.log-table td.ua { color: var(--muted); max-width: 260px; word-break: break-all; font-size: 12px; }

.preview-modal .modal-body { padding: 0; background: #0b1220; }
.preview-image { display: flex; align-items: center; justify-content: center; min-height: 200px; }
.preview-image img { max-width: 100%; max-height: 72vh; display: block; }
.preview-media { width: 100%; max-height: 72vh; display: block; background: #000; }
.preview-frame { width: 100%; height: 72vh; border: 0; background: #fff; }
.preview-audio { padding: 40px 20px; text-align: center; color: #e2e8f0; }
.audio-name { margin-bottom: 16px; font-weight: 600; }
.preview-audio audio { width: 100%; max-width: 460px; }
.preview-text {
    margin: 0; padding: 16px; max-height: 70vh; overflow: auto; color: #e2e8f0;
    font: 13px/1.7 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-all;
}

.float-menu {
    position: fixed; z-index: 80; background: var(--panel); border: 1px solid var(--line);
    border-radius: 10px; box-shadow: var(--shadow); padding: 5px; min-width: 150px;
}
.float-menu button {
    display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border: 0;
    background: transparent; border-radius: 7px; cursor: pointer; text-align: left; font-size: 14px;
}
.float-menu button:hover { background: var(--panel-2); }
.float-menu button.danger { color: var(--danger); }

#toast-layer { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 90;
    display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
    background: #1e293b; color: #f8fafc; padding: 10px 16px; border-radius: 10px; font-size: 13.5px;
    opacity: 0; transform: translateY(10px); transition: .25s; max-width: 88vw; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.ok { background: #166534; }
.toast.error { background: #991b1b; }

.drop-overlay { position: fixed; inset: 0; z-index: 70; background: rgba(37, 99, 235, .18);
    border: 3px dashed var(--brand); display: flex; align-items: center; justify-content: center; pointer-events: none; }
.drop-overlay > div { background: var(--panel); border-radius: 14px; padding: 24px 30px; text-align: center;
    display: flex; flex-direction: column; gap: 6px; align-items: center; box-shadow: var(--shadow); }
.drop-overlay .ic { width: 30px; height: 30px; color: var(--brand); }

/* ── 上传面板 ────────────────────────────────── */
#upload-dock {
    position: fixed; right: 18px; bottom: calc(var(--footer-h) + 12px); width: 380px; max-width: calc(100vw - 36px);
    background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
    box-shadow: var(--shadow); z-index: 50; overflow: hidden;
}
#upload-dock.collapsed .dock-list { display: none; }
.dock-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.dock-head b { font-size: 14px; }
.dock-head .hint { margin-right: auto; }
.dock-list { max-height: 260px; overflow: auto; }
.job { display: grid; grid-template-columns: 1fr 60px; gap: 4px 8px; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.job:last-child { border-bottom: 0; }
.job-name { grid-column: 1 / 2; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-bar { grid-column: 1 / 2; height: 5px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.job-bar i { display: block; height: 100%; background: var(--brand); transition: width .2s; }
.job-state { grid-column: 1 / 2; font-size: 12px; color: var(--muted); }
.job-ops { grid-column: 2 / 3; grid-row: 1 / 4; display: flex; align-items: center; justify-content: flex-end; gap: 2px; }
.job-ops .icon-btn { width: 28px; height: 28px; font-size: 14px; }

/* ── 移动端 ──────────────────────────────────── */
@media (max-width: 860px) {
    #app { grid-template-columns: 1fr; }
    #sidebar {
        position: fixed; left: 0; top: 0; bottom: 0; width: 250px; z-index: 65; height: 100vh;
        transform: translateX(-104%); transition: transform .22s ease; box-shadow: var(--shadow);
    }
    #sidebar.open { transform: translateX(0); }
    .only-mobile { display: inline-flex !important; }
    .only-desktop { display: none; }
    #content { padding: 12px 12px 120px; }
    .row { grid-template-columns: 30px 34px 1fr 84px; padding: 10px; }
    .fsize, .ftime { display: none; }
    .fname .meta { display: block; }
    .fops { opacity: 1; }
    .row .fops .icon-btn:not([data-act="more"]) { display: none; }
    .file-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
    .cell-body { height: 110px; }
    .share-row { flex-direction: column; align-items: stretch; }
    .share-ops { justify-content: flex-end; }
    #upload-dock { right: 10px; left: 10px; width: auto; bottom: 10px; }
    .modal { max-height: 92vh; }
    .toolbar { padding: 8px; }
}
