/* ===================== 主题变量 ===================== */
:root {
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei",
          "PingFang SC", "Hiragino Sans GB", Roboto, "Helvetica Neue", sans-serif;
  --mono: "Cascadia Code", Consolas, "JetBrains Mono", Menlo, monospace;
  --accent: #4f8cff;
  --accent-2: #7c5cff;
  --danger: #ff5c5c;
  --ok: #33c98b;
  --shadow: 0 18px 50px rgba(0, 0, 0, .28);
  --speed: .18s;
}

html[data-theme="dark"] {
  --bg: #0e1116;
  --bg-2: #141922;
  --panel: rgba(24, 30, 40, .86);
  --panel-solid: #181e28;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .16);
  --text: #e8edf5;
  --muted: #8e9bb0;
  --hover: rgba(255, 255, 255, .05);
  --active: rgba(79, 140, 255, .16);
  --input: rgba(255, 255, 255, .06);
}

html[data-theme="light"] {
  --bg: #f2f5fa;
  --bg-2: #ffffff;
  --panel: rgba(255, 255, 255, .92);
  --panel-solid: #ffffff;
  --line: rgba(16, 24, 40, .09);
  --line-strong: rgba(16, 24, 40, .18);
  --text: #17202e;
  --muted: #667085;
  --hover: rgba(16, 24, 40, .045);
  --active: rgba(79, 140, 255, .13);
  --input: rgba(16, 24, 40, .05);
  --shadow: 0 18px 50px rgba(16, 24, 40, .14);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background:
    radial-gradient(1100px 620px at 12% -8%, rgba(79, 140, 255, .20), transparent 62%),
    radial-gradient(900px 520px at 105% 8%, rgba(124, 92, 255, .16), transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.hidden { display: none !important; }
/* 原生 hidden 属性优先于作者样式里的 display，避免 .tool-group 之类的 flex 覆盖它 */
[hidden] { display: none !important; }
.muted { color: var(--muted); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ===================== 通用控件 ===================== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  font: inherit; font-size: 13.5px;
  color: var(--text);
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--speed), border-color var(--speed), transform var(--speed), box-shadow var(--speed);
  text-decoration: none;
}
.btn:hover { background: var(--hover); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn.small { padding: 6px 10px; font-size: 12.5px; }
.btn.block { width: 100%; justify-content: center; }
.btn.primary {
  color: #fff; border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 22px rgba(79, 140, 255, .28);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: #fff; border-color: transparent; background: linear-gradient(135deg, #ff6b6b, #e0433f); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.icon-btn {
  width: 32px; height: 32px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; color: var(--text);
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer; transition: background var(--speed), border-color var(--speed);
}
.icon-btn:hover { background: var(--hover); border-color: var(--line); }

input[type="text"], input[type="password"], input[type="search"] {
  font: inherit; color: var(--text); background: var(--input);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 12px; outline: none; width: 100%;
  transition: border-color var(--speed), box-shadow var(--speed);
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 140, 255, .18); }
input::placeholder { color: var(--muted); }

/* ===================== 登录 ===================== */
.login {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center; padding: 20px;
}
.login-card {
  width: min(360px, 100%);
  padding: 34px 30px 26px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  animation: pop .26s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.login-logo { font-size: 42px; line-height: 1; }
.login-card h1 { margin: 10px 0 4px; font-size: 20px; letter-spacing: .5px; }
.login-card p { margin: 0 0 18px; font-size: 13px; }
.login-card input { margin-bottom: 12px; text-align: center; }
.login-msg { min-height: 18px; color: var(--danger); font-size: 12.5px; margin: 10px 0 0 !important; }

/* ===================== 布局 ===================== */
.app { display: flex; height: 100vh; }

.sidebar {
  width: 236px; flex: none;
  display: flex; flex-direction: column; gap: 14px;
  padding: 18px 14px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 15.5px; padding: 2px 6px 8px; }
.brand-icon { font-size: 19px; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; width: 100%;
  font: inherit; font-size: 13.5px; text-align: left; color: var(--text);
  background: transparent; border: none; border-radius: var(--radius-sm); cursor: pointer;
  transition: background var(--speed);
}
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--active); color: var(--accent); font-weight: 600; }
.nav-item span { width: 18px; text-align: center; }
.badge {
  margin-left: auto; min-width: 20px; padding: 1px 6px;
  font-size: 11px; font-style: normal; text-align: center;
  background: var(--danger); color: #fff; border-radius: 99px;
}

.storage-box { margin-top: auto; padding: 12px; background: var(--input); border: 1px solid var(--line); border-radius: var(--radius); }
.storage-head { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 8px; }
.storage-bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.storage-bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s ease; }
.storage-sub { margin-top: 8px; font-size: 11.5px; line-height: 1.5; }
.sidebar-foot { display: flex; gap: 6px; justify-content: space-between; }

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

.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 18px 10px; }
.crumb { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.crumb::-webkit-scrollbar { display: none; }
.crumb button {
  padding: 5px 8px; font: inherit; font-size: 13.5px; color: var(--muted);
  background: transparent; border: none; border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.crumb button:hover { background: var(--hover); color: var(--text); }
.crumb button:last-child { color: var(--text); font-weight: 600; }
.crumb .sep { color: var(--muted); opacity: .55; font-size: 12px; }

.search-wrap { position: relative; width: clamp(180px, 30%, 320px); flex: none; margin-left: auto; }
.search-wrap .search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); font-size: 12px; opacity: .65; pointer-events: none; }
.search-wrap input { padding-left: 32px; padding-right: 30px; }
.search-clear { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; font-size: 11px; }

.toolbar { display: flex; align-items: center; gap: 8px; padding: 4px 18px 12px; flex-wrap: wrap; }
.tool-group { display: flex; align-items: center; gap: 8px; }
.tool-group.right { margin-left: auto; }
.selinfo { font-size: 12.5px; }

/* ===================== 列表 ===================== */
.list-area { flex: 1; min-height: 0; margin: 0 18px 18px; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.list-head, .row { display: grid; grid-template-columns: 34px 1fr 110px 160px 152px; align-items: center; gap: 10px; padding: 0 14px; }
.list-head { height: 40px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); background: var(--hover); flex: none; }
.list-head span { cursor: default; }
.list-head span.sortable { cursor: pointer; user-select: none; }
.list-head span.sortable:hover { color: var(--text); }
.list-head .on { color: var(--accent); }
.list-body { flex: 1; overflow: auto; }

.row { height: 50px; border-bottom: 1px solid var(--line); cursor: default; transition: background var(--speed); }
.row:last-child { border-bottom: none; }
.row:hover { background: var(--hover); }
.row.selected { background: var(--active); }
.row.drop-target { background: var(--active); box-shadow: inset 0 0 0 1px var(--accent); }

.row .name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row .name .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .name .ico {
  width: 30px; height: 30px; flex: none; display: grid; place-items: center;
  font-size: 16px; background: var(--input); border-radius: 8px; border: 1px solid var(--line);
}
.row .name .nick { font-size: 12px; color: var(--muted); }
.row .cell { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .acts { display: flex; gap: 2px; justify-content: flex-end; opacity: 0; transition: opacity var(--speed); }
.row:hover .acts, .row.selected .acts { opacity: 1; }
.cb { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.loc { color: var(--accent); cursor: pointer; }
.loc:hover { text-decoration: underline; }

.empty { flex: 1; display: grid; place-items: center; text-align: center; color: var(--muted); }
.empty .big { font-size: 46px; margin-bottom: 12px; opacity: .75; }
.empty p { margin: 4px 0; font-size: 13.5px; }

/* ===================== 拖拽层 ===================== */
.dropzone { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center;
  background: rgba(10, 14, 22, .55); backdrop-filter: blur(3px); }
.dropzone-inner {
  padding: 44px 64px; text-align: center; font-size: 42px;
  background: var(--panel-solid); border: 2px dashed var(--accent); border-radius: 20px; box-shadow: var(--shadow);
}
.dropzone-inner p { margin: 10px 0 0; font-size: 14px; color: var(--muted); }

/* ===================== 上传面板 ===================== */
.upload-panel {
  position: fixed; right: 20px; bottom: 20px; z-index: 60;
  width: min(400px, calc(100vw - 40px));
  background: var(--panel-solid); border: 1px solid var(--line-strong);
  border-radius: 14px; box-shadow: var(--shadow); overflow: hidden;
}
.upload-head { display: flex; align-items: center; gap: 8px; padding: 11px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.upload-head b { flex: none; }
.upload-head .muted { flex: 1; font-size: 12px; text-align: right; }
.upload-list { max-height: 260px; overflow: auto; }
.upload-panel.collapsed .upload-list { display: none; }
.u-item { padding: 9px 12px; border-bottom: 1px solid var(--line); }
.u-item:last-child { border-bottom: none; }
.u-top { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.u-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-pct { color: var(--muted); font-variant-numeric: tabular-nums; }
.u-bar { margin-top: 6px; height: 4px; background: var(--line); border-radius: 99px; overflow: hidden; }
.u-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .2s; }
.u-item.err .u-bar i { background: var(--danger); }
.u-item.ok .u-bar i { background: var(--ok); }
.u-msg { margin-top: 4px; font-size: 11.5px; color: var(--danger); }

/* ===================== 模态框 ===================== */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 24px;
  background: rgba(6, 9, 15, .58); backdrop-filter: blur(4px); animation: fade .16s ease; }
@keyframes fade { from { opacity: 0; } }
.modal-box {
  width: min(960px, 100%); max-height: calc(100vh - 60px); display: flex; flex-direction: column;
  background: var(--panel-solid); border: 1px solid var(--line-strong);
  border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; animation: pop .2s ease;
}
.modal-box.small-box { width: min(420px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.modal-head b { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.modal-actions { display: flex; align-items: center; gap: 6px; }
.modal-body { padding: 16px; overflow: auto; }
.modal-body p { margin-top: 0; font-size: 13px; }
.modal-body input { margin-top: 4px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }

.preview-box .modal-body { display: grid; place-items: center; min-height: 240px; padding: 0; }
.preview-box img, .preview-box video { max-width: 100%; max-height: calc(100vh - 190px); display: block; }
.preview-box audio { width: min(560px, 90%); margin: 34px; }
.preview-box iframe { width: 100%; height: calc(100vh - 180px); border: none; background: #fff; }
.preview-box pre {
  margin: 0; padding: 16px; width: 100%; max-height: calc(100vh - 180px); overflow: auto;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.65; white-space: pre-wrap; word-break: break-word;
}
.preview-info { padding: 34px; text-align: center; color: var(--muted); font-size: 13px; }
.preview-info .big { font-size: 52px; margin-bottom: 12px; }

/* ===================== 右键菜单 / Toast ===================== */
.ctx {
  position: fixed; z-index: 95; min-width: 176px; padding: 6px;
  background: var(--panel-solid); border: 1px solid var(--line-strong);
  border-radius: 10px; box-shadow: var(--shadow); animation: pop .12s ease;
}
.ctx button {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px;
  font: inherit; font-size: 13px; text-align: left; color: var(--text);
  background: transparent; border: none; border-radius: 7px; cursor: pointer;
}
.ctx button:hover { background: var(--hover); }
.ctx button.danger { color: var(--danger); }
.ctx hr { margin: 5px 6px; border: none; border-top: 1px solid var(--line); }

.toasts { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 99; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  padding: 10px 16px; font-size: 13px; color: #fff; background: rgba(24, 30, 40, .95);
  border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow);
  animation: toastIn .2s ease; max-width: 70vw;
}
.toast.ok { background: linear-gradient(135deg, #2fae7d, #23896a); border-color: transparent; }
.toast.err { background: linear-gradient(135deg, #e2564f, #c33f38); border-color: transparent; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }
.mobile-only { display: none; }

/* ===================== 响应式 ===================== */
@media (max-width: 860px) {
  .mobile-only { display: inline-flex; }
  .sidebar { position: fixed; z-index: 75; inset: 0 auto 0 0; transform: translateX(-100%); transition: transform var(--speed); }
  .sidebar.open { transform: none; }
  .list-head, .row { grid-template-columns: 32px 1fr 142px; }
  .list-head .col-time, .row .col-time,
  .list-head .col-loc, .row .col-loc,
  .list-head .col-size, .row .col-size { display: none; }
  .search-wrap { width: 150px; }
  .toolbar .btn span.lbl { display: none; }
}
