:root {
  --bg: #f4f6fb;
  --bg-soft: #ffffff;
  --bg-head: #eef2fa;
  --text: #1c2430;
  --muted: #667085;
  --line: #e2e6ef;
  --accent: #2563eb;
  --accent-soft: #dbe6ff;
  --danger: #c0392b;
  --ok: #0f7b4f;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
}
html[data-theme="dark"] {
  --bg: #131722;
  --bg-soft: #1b2130;
  --bg-head: #212838;
  --text: #e7ecf5;
  --muted: #9aa6bd;
  --line: #2c3446;
  --accent: #5b8cff;
  --accent-soft: #25324d;
  --danger: #ff7b6b;
  --ok: #4ade80;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC",
        "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: 92px;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; background: var(--bg-soft);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { font-size: 26px; line-height: 1; }
.brand h1 { font-size: 18px; margin: 0; letter-spacing: .2px; }
.brand .sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-shrink: 0; }
.icon-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn .lbl { font-size: 13px; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 16px 20px 8px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 14px; margin-bottom: 12px; }
.crumbs .crumb { color: var(--accent); padding: 2px 4px; border-radius: 6px; }
.crumbs .crumb:hover { background: var(--accent-soft); }
.crumbs .sep { color: var(--muted); }
.crumbs .current { color: var(--muted); padding: 2px 4px; }

.toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 12px;
}
.check-all { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.search { flex: 1 1 180px; min-width: 140px; }
.search input {
  width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg); color: var(--text);
}
.search input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.stat { font-size: 13px; color: var(--muted); }

input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }

.panel {
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.filetable { width: 100%; border-collapse: collapse; }
.filetable thead th {
  text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted);
  background: var(--bg-head); padding: 10px 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.filetable th.sortable { cursor: pointer; user-select: none; }
.filetable th.sortable:hover { color: var(--accent); }
.filetable .arrow { font-size: 10px; margin-left: 4px; color: var(--accent); }
.filetable tbody tr { border-bottom: 1px solid var(--line); }
.filetable tbody tr:last-child { border-bottom: none; }
.filetable tbody tr:hover { background: var(--bg-head); }
.filetable td { padding: 10px 12px; vertical-align: middle; }
.c-check { width: 38px; }
.c-size, .c-time { width: 150px; white-space: nowrap; color: var(--muted); font-size: 13.5px; }
.c-act { width: 96px; text-align: right; }

.name-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ficon { font-size: 19px; line-height: 1; flex-shrink: 0; }
.fname {
  cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-bottom: 1px dashed transparent;
}
.fname:hover { color: var(--accent); border-bottom-color: var(--accent); }
.ficon.dir, .fname.dir { cursor: pointer; }
.fname.dir:hover { color: var(--accent); }
.folder-flag {
  font-size: 11px; color: var(--muted); border: 1px solid var(--line);
  border-radius: 20px; padding: 0 7px; margin-left: 6px; flex-shrink: 0;
}
.dl-btn {
  display: inline-block; padding: 5px 11px; font-size: 13px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--accent);
}
.dl-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.state { padding: 26px 16px; text-align: center; color: var(--muted); font-size: 14px; }
.hidden { display: none !important; }
.spinner {
  display: inline-block; width: 14px; height: 14px; margin-right: 8px;
  border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg-soft); border-top: 1px solid var(--line);
  box-shadow: 0 -6px 18px rgba(16, 24, 40, .06); flex-wrap: wrap;
}
.actionbar .sel { font-size: 13.5px; color: var(--muted); }
.actionbar .sep { margin: 0 6px; }
.actionbar .buttons { display: flex; gap: 10px; margin-left: auto; }
button.primary, button.ghost {
  border-radius: 10px; padding: 10px 16px; border: 1px solid transparent; font-size: 14px;
}
button.primary { background: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { filter: brightness(1.08); }
button.primary:disabled { opacity: .45; cursor: not-allowed; }
button.ghost { background: var(--bg-soft); color: var(--text); border-color: var(--line); }
button.ghost:hover { border-color: var(--accent); color: var(--accent); }
button.busy { opacity: .75; cursor: progress; }

.toasts {
  position: fixed; right: 16px; bottom: 96px; z-index: 60;
  display: flex; flex-direction: column; gap: 8px; max-width: min(92vw, 380px);
}
.toast {
  background: var(--bg-soft); color: var(--text); border: 1px solid var(--line);
  border-left: 4px solid var(--accent); border-radius: 10px; padding: 10px 14px;
  box-shadow: var(--shadow); font-size: 13.5px; animation: fade .18s ease-out;
}
.toast.err { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (max-width: 720px) {
  .topbar { padding: 12px 14px; }
  .brand .sub { display: none; }
  .wrap { padding: 12px 12px 6px; }
  .icon-btn .lbl { display: none; }
  .filetable thead { display: none; }
  .filetable, .filetable tbody, .filetable tr, .filetable td { display: block; width: 100%; }
  .filetable tbody tr {
    position: relative; padding: 10px 12px 10px 46px;
    border-bottom: 1px solid var(--line);
  }
  .filetable td { padding: 0; }
  .filetable td.c-check { position: absolute; left: 12px; top: 12px; width: auto; }
  .filetable td.c-name { margin-bottom: 4px; }
  .filetable td.c-size, .filetable td.c-time { display: inline-block; width: auto; margin-right: 12px; font-size: 12.5px; }
  .filetable td.c-time::before { content: "?? "; }
  .filetable td.c-act { text-align: left; margin-top: 6px; }
  .actionbar { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .actionbar .buttons { width: 100%; }
  .actionbar .buttons button { flex: 1; }
  .toasts { left: 12px; right: 12px; bottom: 108px; max-width: none; }
}
