:root {
    --bg: #f3f5f8;
    --panel: #ffffff;
    --sidebar: #151922;
    --sidebar-2: #1d2330;
    --text: #1a1d26;
    --muted: #6b7280;
    --line: #e6e9ef;
    --brand: #3b6cff;
    --brand-2: #2f5aef;
    --danger: #e11d48;
    --ok: #059669;
    --shadow: 0 10px 40px rgba(21, 25, 34, 0.12);
    --radius: 12px;
}

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

html, body {
    height: 100%;
    font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background: var(--bg);
}

button, input { font-family: inherit; }

[hidden] { display: none !important; }

.app {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100%;
}

.sidebar {
    background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
    color: #e8ecf4;
    padding: 22px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 8px;
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--brand);
    color: white;
    display: grid;
    place-items: center;
}

.brand strong { display: block; font-size: 1.05rem; }
.brand span { font-size: 0.75rem; color: #9aa3b5; }

.upload-main {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    border: 0;
    border-radius: 10px;
    padding: 12px 14px;
    background: var(--brand);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}

.upload-main:hover { background: var(--brand-2); transform: translateY(-1px); }

.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: 0;
    background: transparent;
    color: #c5ccda;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    font-size: 0.95rem;
}

.nav-item:hover { background: rgba(255,255,255,0.06); color: white; }
.nav-item.active { background: rgba(59,108,255,0.22); color: white; font-weight: 600; }
.nav-ico { width: 1.4rem; text-align: center; }

.quota {
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 12px;
    font-size: 0.8rem;
}

.quota-top { display: flex; justify-content: space-between; color: #b7bfce; margin-bottom: 8px; }
.quota-bar { height: 6px; background: #2a3142; border-radius: 99px; overflow: hidden; }
.quota-bar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, #3b6cff, #67e8f9); }
.quota-hint { margin-top: 8px; color: #8b95a8; line-height: 1.4; }

.workspace { display: flex; flex-direction: column; min-width: 0; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 24px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 36px; }
.crumbs button {
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 0.95rem;
    padding: 4px 6px;
    border-radius: 6px;
}
.crumbs button:hover { background: #eef2ff; color: var(--brand); }
.crumbs button.current { color: var(--text); font-weight: 600; }
.sep { color: #c5cad3; }

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

.search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0 12px;
    min-width: 240px;
}

.search input {
    border: 0;
    background: transparent;
    outline: none;
    height: 38px;
    width: 100%;
    font-size: 0.92rem;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    color: #4b5563;
}
.icon-btn.active { background: #eef2ff; color: var(--brand); border-color: #c7d2fe; }

.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    flex-wrap: wrap;
}

.tool-btn, .btn {
    border: 1px solid var(--line);
    background: white;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 500;
}
.tool-btn:hover:not(:disabled), .btn:hover { background: #f8fafc; }
.tool-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.tool-btn.danger { color: var(--danger); }
.btn.primary { background: var(--brand); color: white; border-color: var(--brand); }
.btn.ghost { background: transparent; }
.sel-count { margin-left: auto; color: var(--muted); font-size: 0.85rem; }

.file-pane {
    position: relative;
    margin: 0 16px 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    flex: 1;
    min-height: 420px;
    overflow: auto;
}

.file-pane.dragging { outline: 2px dashed var(--brand); outline-offset: -8px; background: #f5f8ff; }
.drop-hint {
    display: none;
    position: sticky;
    top: 0;
    z-index: 2;
    background: #dbeafe;
    color: #1e40af;
    text-align: center;
    padding: 10px;
    font-weight: 600;
}
.file-pane.dragging .drop-hint { display: block; }

.list-head, .file-row {
    display: grid;
    grid-template-columns: minmax(220px, 1.6fr) 110px 180px 120px;
    gap: 12px;
    padding: 10px 18px;
    align-items: center;
}
.list-head {
    position: sticky;
    top: 0;
    background: #fafbfc;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    z-index: 1;
}

.file-row {
    border-bottom: 1px solid #f1f3f7;
    cursor: default;
    user-select: none;
}
.file-row:hover { background: #f7f9fc; }
.file-row.selected { background: #eef2ff; }
.file-row .name {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    font-weight: 500;
}
.file-row .name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .meta { color: var(--muted); font-size: 0.85rem; }
.fico {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    background: #eef2ff;
}

.file-list.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    padding: 16px;
}
.file-list.grid .file-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px 10px;
    min-height: 140px;
}
.file-list.grid .meta { display: none; }
.file-list.grid .name { flex-direction: column; width: 100%; }
.file-list.grid .fico { width: 48px; height: 48px; font-size: 1.4rem; }

.empty {
    display: grid;
    place-items: center;
    text-align: center;
    min-height: 360px;
    color: var(--muted);
    padding: 40px;
    gap: 8px;
}
.empty-ico { font-size: 3rem; }
.empty h2 { color: var(--text); margin-top: 8px; }

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 40;
}

.modal {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(420px, calc(100% - 32px));
    background: white;
    border-radius: 14px;
    padding: 22px;
    z-index: 50;
    box-shadow: var(--shadow);
}
.modal h3 { margin-bottom: 14px; }
.modal input {
    width: 100%;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 12px;
    outline: none;
}
.modal input:focus { border-color: var(--brand); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.preview {
    position: fixed;
    inset: 24px;
    background: #0f172a;
    color: white;
    border-radius: 16px;
    z-index: 60;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.preview header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #111827;
}
.preview header .icon-btn { color: white; background: transparent; border-color: #334155; }
.preview-body {
    flex: 1;
    overflow: auto;
    display: grid;
    place-items: center;
    padding: 16px;
}
.preview-body img, .preview-body video { max-width: 100%; max-height: calc(100vh - 140px); }
.preview-body pre {
    width: 100%;
    max-width: 900px;
    white-space: pre-wrap;
    background: #1e2937;
    padding: 16px;
    border-radius: 10px;
    font-size: 0.85rem;
}
.preview-body audio { width: min(520px, 100%); }

.ctx {
    position: fixed;
    z-index: 70;
    list-style: none;
    background: white;
    border: 1px solid var(--line);
    border-radius: 10px;
    min-width: 160px;
    padding: 6px;
    box-shadow: var(--shadow);
}
.ctx li {
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}
.ctx li:hover { background: #eef2ff; }
.ctx li.danger { color: var(--danger); }

.toast-wrap {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 80;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    background: #111827;
    color: white;
    padding: 10px 14px;
    border-radius: 10px;
    min-width: 200px;
    box-shadow: var(--shadow);
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }

@media (max-width: 860px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { padding-bottom: 8px; }
    .side-nav { flex-direction: row; overflow: auto; flex: unset; }
    .nav-item { white-space: nowrap; }
    .quota { display: none; }
    .list-head, .file-row { grid-template-columns: 1fr 90px; }
    .list-head span:nth-child(n+3), .file-row .meta:nth-child(n+3) { display: none; }
    .search { min-width: 140px; }
    .preview { inset: 0; border-radius: 0; }
}
