:root {
  --bg: #f5f6f8; --panel: #ffffff; --text: #1f2430; --muted: #6b7280; --border: #e5e7eb;
  --primary: #2563eb; --primary-weak: #e8effd; --danger: #dc2626; --ok: #16a34a; --hover: #f1f4f9;
  --shadow: 0 6px 24px rgba(15, 23, 42, .12); --radius: 10px;
}
[data-theme="dark"] {
  --bg: #11141a; --panel: #1a1e26; --text: #e6e9ef; --muted: #98a1b3; --border: #2b313c;
  --primary: #5b8cff; --primary-weak: #1f2a44; --danger: #f06262; --ok: #4ade80; --hover: #222834;
  --shadow: 0 6px 24px rgba(0, 0, 0, .5);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); font: 14px/1.5 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
svg.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 16px;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: var(--text); white-space: nowrap; }
.brand .ic { color: var(--primary); width: 22px; height: 22px; }
.spacer { flex: 1; }
.search { position: relative; flex: 0 1 360px; }
.search input { width: 100%; padding: 7px 12px 7px 34px; border: 1px solid var(--border); border-radius: 20px; background: var(--bg); outline: none; }
.search input:focus { border-color: var(--primary); }
.search .ic { position: absolute; left: 11px; top: 8px; color: var(--muted); width: 16px; height: 16px; }
.container { max-width: 1200px; margin: 0 auto; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel); cursor: pointer; white-space: nowrap; transition: background .12s;
}
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.icon { padding: 6px; border-color: transparent; background: transparent; }
.btn.icon:hover { background: var(--hover); }
.btn.sm { padding: 3px 8px; font-size: 13px; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; flex: 1; min-width: 200px; }
.crumbs a { padding: 2px 6px; border-radius: 6px; color: var(--text); cursor: pointer; }
.crumbs a:hover { background: var(--hover); }
.crumbs .ic { width: 14px; height: 14px; color: var(--muted); }
.crumbs .last { font-weight: 600; }
.selbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; margin-bottom: 12px; background: var(--primary-weak); border-radius: var(--radius); flex-wrap: wrap; }

table.files { width: 100%; border-collapse: collapse; }
table.files th { text-align: left; font-weight: 500; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; user-select: none; white-space: nowrap; }
table.files td { padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.files tr:last-child td { border-bottom: 0; }
table.files tbody tr:hover { background: var(--hover); }
table.files tr.sel { background: var(--primary-weak); }
table.files td.name { width: 100%; max-width: 0; }
.fname { display: flex; align-items: center; gap: 10px; cursor: pointer; overflow: hidden; }
.fname span { overflow: hidden; text-overflow: ellipsis; }
.fname .ic { width: 22px; height: 22px; }
.t-folder { color: #f59e0b; } .t-image { color: #10b981; } .t-video { color: #8b5cf6; } .t-audio { color: #ec4899; }
.t-text { color: #3b82f6; } .t-pdf { color: #ef4444; } .t-archive { color: #a16207; } .t-other { color: var(--muted); }
.muted { color: var(--muted); }
.actions { display: flex; gap: 2px; justify-content: flex-end; }
td.chk, th.chk { width: 36px; padding-right: 0; }
input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 12px; }
.tile { position: relative; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius); text-align: center; cursor: pointer; overflow: hidden; }
.tile:hover { background: var(--hover); }
.tile.sel { background: var(--primary-weak); border-color: var(--primary); }
.tile .thumb { height: 120px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.tile .thumb .ic { width: 44px; height: 44px; }
.tile .thumb img { width: 100%; height: 100%; border-radius: 6px; object-fit: cover; display: block; }
.tile .tn { margin-top: 6px; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile input { position: absolute; left: 8px; top: 8px; }

.empty { padding: 60px 0; text-align: center; color: var(--muted); }
.readme { margin-top: 16px; padding: 16px; white-space: pre-wrap; word-break: break-word; font-size: 13px; }
.dropzone { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(37, 99, 235, .15); border: 3px dashed var(--primary); color: var(--primary); font-size: 22px; font-weight: 600; pointer-events: none; }

.overlay { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .45); padding: 16px; }
.modal { background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); width: min(480px, 100%); max-height: 90vh; display: flex; flex-direction: column; }
.modal.wide { width: min(640px, 100%); }
.modal-h { display: flex; align-items: center; padding: 14px 18px; font-weight: 600; font-size: 16px; border-bottom: 1px solid var(--border); }
.modal-h .title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-b { padding: 18px; overflow: auto; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
.preview { width: min(1000px, 100%); height: min(86vh, 800px); }
.preview .modal-b { flex: 1; padding: 0; display: flex; align-items: center; justify-content: center; background: #0b0d12; position: relative; min-height: 200px; }
.preview img, .preview video { max-width: 100%; max-height: 100%; }
.preview audio { width: 80%; }
.preview iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.preview textarea { width: 100%; height: 100%; border: 0; padding: 14px; resize: none; background: var(--panel); font: 13px/1.6 ui-monospace, Menlo, Consolas, monospace; outline: none; }
.preview .nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0, 0, 0, .5); color: #fff; border: 0; border-radius: 50%; width: 40px; height: 40px; cursor: pointer; font-size: 20px; }
.preview .nav.l { left: 10px; } .preview .nav.r { right: 10px; }
.noprev { color: #cbd5e1; text-align: center; }

.form-row { margin-bottom: 14px; }
.form-row label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 13px; }
.form-row .help { font-size: 12px; color: var(--muted); margin-top: 3px; }
.form-row label.inline { display: flex; align-items: center; gap: 8px; color: var(--text); }
.inp { width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); outline: none; }
.inp:focus { border-color: var(--primary); }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.checks label { display: flex; align-items: center; gap: 6px; color: var(--text); margin: 0; }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.tabs a.on { color: var(--primary); border-color: var(--primary); font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { padding: 16px; } .stat b { display: block; font-size: 26px; }
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th, table.t td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
table.t th { color: var(--muted); font-weight: 500; white-space: nowrap; }
table.t tr:last-child td { border-bottom: 0; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: var(--hover); color: var(--muted); }
.tag.ok { background: rgba(22, 163, 74, .12); color: var(--ok); } .tag.bad { background: rgba(220, 38, 38, .12); color: var(--danger); }
.bar { height: 8px; background: var(--hover); border-radius: 4px; overflow: hidden; min-width: 100px; }
.bar > i { display: block; height: 100%; background: var(--primary); }
.head-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 8px; }

.toasts { position: fixed; top: 66px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast { padding: 9px 16px; border-radius: 8px; background: #1f2937; color: #fff; box-shadow: var(--shadow); }
.toast.err { background: var(--danger); } .toast.ok { background: var(--ok); }

.uploads { position: fixed; right: 16px; bottom: 16px; z-index: 30; width: min(360px, calc(100vw - 32px)); max-height: 50vh; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.uploads .u-body { overflow: auto; }
.u-item { padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.u-item .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-item .err { color: var(--danger); }

.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: min(380px, 100%); padding: 28px; box-shadow: var(--shadow); }
.login h1 { margin: 0 0 4px; font-size: 22px; display: flex; gap: 8px; align-items: center; }
.login h1 .ic { color: var(--primary); width: 26px; height: 26px; }
.login p.sub { margin: 0 0 20px; color: var(--muted); }
.notice { padding: 10px 14px; margin-bottom: 12px; border-radius: var(--radius); background: var(--primary-weak); }
.picker-list { max-height: 300px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.picker-list div { display: flex; gap: 8px; align-items: center; padding: 8px 12px; cursor: pointer; }
.picker-list div:hover { background: var(--hover); }
code.url { padding: 2px 6px; background: var(--hover); border-radius: 4px; word-break: break-all; }

@media (max-width: 720px) {
  .search { display: none; }
  .hide-sm { display: none; }
  .container { padding: 10px; }
  table.files td, table.files th { padding: 8px 6px; }
}
