:root {
  --bg:        #f4f5f7;
  --panel:     #ffffff;
  --line:      #e5e7eb;
  --line-soft: #f1f2f5;
  --text:      #1c2027;
  --muted:     #6b7280;
  --faint:     #9aa1ad;
  --brand:     #2b6cb0;
  --brand-dk:  #235891;
  --brand-bg:  #edf3fb;
  --warn-bg:   #fff8e6;
  --warn-line: #f2dda6;
  --warn-text: #8a6100;
  --radius:    10px;
  --shadow:    0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 12px 44px rgba(16, 24, 40, .2);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #131619;
    --panel:     #1b1f24;
    --line:      #2a3038;
    --line-soft: #22272e;
    --text:      #e6e9ec;
    --muted:     #9ca4b0;
    --faint:     #79818d;
    --brand:     #69a3de;
    --brand-dk:  #8bbcf0;
    --brand-bg:  #1a2938;
    --warn-bg:   #2b2416;
    --warn-line: #57461f;
    --warn-text: #e6c673;
    --shadow:    0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 12px 44px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }

/* .list / .overlay 显式设了 display:flex，会盖掉 UA 的 [hidden]{display:none} */
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }

/* ── 顶栏 ── */
.topbar { background: var(--panel); border-bottom: 1px solid var(--line); }
.bar { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.topbar h1 {
  margin: 0; font-size: 17px; font-weight: 650;
  display: flex; align-items: center; gap: 9px;
}
.logo {
  width: 22px; height: 22px; border-radius: 6px; position: relative; flex: none;
  background: linear-gradient(135deg, var(--brand), var(--brand-dk));
}
.logo::after {
  content: ""; position: absolute; left: 50%; top: 5px;
  width: 2px; height: 7px; margin-left: -1px;
  background: #fff; border-radius: 1px;
}
.logo::before {
  content: ""; position: absolute; left: 50%; top: 10px;
  width: 6px; height: 6px; margin-left: -3px;
  border-right: 2px solid #fff; border-bottom: 2px solid #fff;
  transform: rotate(45deg); border-radius: 0 0 1px 0;
}
.ghost-btn {
  color: var(--brand); text-decoration: none; font-size: 13.5px;
  padding: 5px 11px; border-radius: 7px; white-space: nowrap;
}
.ghost-btn:hover { background: var(--brand-bg); }

/* ── 主体 ── */
.main { padding: 18px 16px 0; }

/* ── 分区筛选 ── */
.zones { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.zones:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px;
  font-size: 13.5px; text-decoration: none; color: var(--text);
  background: var(--line-soft); white-space: nowrap; border: 1px solid transparent;
}
.chip:hover { background: var(--brand-bg); color: var(--brand); }
.chip.on {
  background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600;
}
.chip-n {
  font-size: 11px; padding: 0 6px; border-radius: 999px;
  background: rgba(0, 0, 0, .07); color: inherit; font-weight: 600;
}
.chip.on .chip-n { background: rgba(255, 255, 255, .25); }

/* ── 面板 ── */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.head-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 220px; }
.count { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.head-right { display: flex; align-items: center; gap: 12px; }

.search {
  flex: 1 1 auto; min-width: 0; max-width: 260px;
  padding: 6px 11px; font: inherit; font-size: 13.5px;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--panel); color: var(--text);
}
.search:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-bg); }
.search::placeholder { color: var(--faint); }

.chk {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--muted); cursor: pointer; user-select: none;
}
.chk input { width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; margin: 0; }

/* ── 列表 ── */
.list { display: flex; flex-direction: column; }

.row {
  display: grid; grid-template-columns: 22px 30px minmax(0, 1fr);
  align-items: center; gap: 12px;
  padding: 11px 14px; border-bottom: 1px solid var(--line-soft);
  background: none; border-left: 0; border-right: 0; border-top: 0;
  font: inherit; color: inherit; text-align: left; width: 100%; cursor: pointer;
}
.list .row:last-child { border-bottom: 0; }
.row:hover { background: var(--brand-bg); }
.row.sel { background: var(--brand-bg); }
.row:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

.row .pick { width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; margin: 0; }

.icon { width: 30px; height: 30px; border-radius: 7px; position: relative; flex: none; }
.icon.dir  { background: #eab308; }
.icon.file { background: #8b94a3; }
.icon.dir::after {
  content: ""; position: absolute; left: 6px; top: 12px;
  width: 18px; height: 11px; background: #fff; border-radius: 2px; opacity: .93;
}
.icon.dir::before {
  content: ""; position: absolute; left: 6px; top: 8px;
  width: 9px; height: 6px; background: #fff; border-radius: 2px 2px 0 0; opacity: .93;
}
.icon.file::after {
  content: ""; position: absolute; left: 8px; top: 7px;
  width: 14px; height: 2px; background: #fff; border-radius: 1px;
  box-shadow: 0 5px 0 #fff, 0 10px 0 #fff; opacity: .93;
}

.meta-col { min-width: 0; }
.name { display: block; font-size: 14.5px; font-weight: 500; word-break: break-all; line-height: 1.4; }
.sub-line { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 1px 7px; border-radius: 999px; margin-right: 6px;
  background: var(--brand-bg); color: var(--brand); vertical-align: 1px;
}
.badge.alt { background: var(--line-soft); color: var(--muted); }

.state { padding: 40px 16px; text-align: center; color: var(--muted); font-size: 14px; }
.foot { padding: 18px 16px 30px; color: var(--faint); font-size: 12.5px; text-align: center; }

/* ── 按钮 ── */
.btn {
  padding: 9px 17px; border-radius: 8px; font: inherit; font-size: 14px;
  cursor: pointer; border: 1px solid transparent;
}
.btn.sm { padding: 6px 14px; font-size: 13.5px; border-radius: 7px; }
.btn.ghost { background: none; border-color: var(--line); color: var(--text); }
.btn.ghost:hover { background: var(--line-soft); }
.btn.primary { background: var(--brand); color: #fff; font-weight: 500; }
.btn.primary:hover { background: var(--brand-dk); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:disabled:hover { background: var(--brand); }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ── 弹窗 ── */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(12, 16, 22, .55);
  display: flex; align-items: center; justify-content: center; padding: 18px;
  animation: fade .14s ease-out;
}
@keyframes fade { from { opacity: 0 } }
@keyframes pop  { from { transform: translateY(8px) scale(.98); opacity: 0 } }

.dialog {
  background: var(--panel); border-radius: 14px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto;
  padding: 22px 22px 18px; position: relative;
  animation: pop .16s ease-out;
}

.dialog-x {
  position: absolute; right: 12px; top: 10px;
  border: 0; background: none; font-size: 24px; line-height: 1;
  color: var(--faint); cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.dialog-x:hover { background: var(--line-soft); color: var(--text); }

.dialog-icon {
  width: 42px; height: 42px; border-radius: 11px;
  background: var(--brand-bg); position: relative; margin-bottom: 12px;
}
.dialog-icon::after {
  content: ""; position: absolute; left: 50%; top: 9px;
  width: 3px; height: 12px; margin-left: -1.5px;
  background: var(--brand); border-radius: 2px;
}
.dialog-icon::before {
  content: ""; position: absolute; left: 50%; top: 18px;
  width: 9px; height: 9px; margin-left: -4.5px;
  border-right: 3px solid var(--brand); border-bottom: 3px solid var(--brand);
  transform: rotate(45deg);
}

.dialog-title { margin: 0 0 14px; font-size: 17px; font-weight: 650; padding-right: 26px; }

.picked {
  list-style: none; margin: 0 0 14px; padding: 0;
  max-height: 168px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 9px;
}
.picked li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 8px 12px; font-size: 13.5px;
  border-bottom: 1px solid var(--line-soft);
}
.picked li:last-child { border-bottom: 0; }
.picked .p-name { word-break: break-all; }
.picked .p-size { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.picked .p-more { justify-content: center; color: var(--muted); font-size: 12.5px; }

.meta {
  display: flex; gap: 10px; margin: 0 0 16px; padding: 12px 14px;
  background: var(--line-soft); border-radius: 9px;
}
.meta > div { flex: 1; min-width: 0; }
.meta dt { font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
.meta dd { margin: 0; font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }

.notice {
  background: var(--warn-bg); border: 1px solid var(--warn-line);
  border-radius: 9px; padding: 13px 14px; margin-bottom: 18px;
}
.notice strong { display: block; font-size: 14px; color: var(--warn-text); margin-bottom: 5px; }
.notice p { margin: 0; font-size: 13px; line-height: 1.65; }

.linkbox { display: flex; gap: 7px; margin-top: 10px; }
.linkinput {
  flex: 1; min-width: 0; padding: 8px 10px;
  font: 12.5px/1.5 ui-monospace, Consolas, monospace;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--panel); color: var(--text);
}
.copy-btn {
  flex: none; padding: 8px 15px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text);
  border-radius: 7px; font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.copy-btn:hover { background: var(--brand-bg); border-color: var(--brand); color: var(--brand); }
.copy-btn.done { background: var(--brand); border-color: var(--brand); color: #fff; }

.dialog-actions { display: flex; gap: 9px; justify-content: flex-end; }

@media (max-width: 620px) {
  .row { grid-template-columns: 22px 26px minmax(0, 1fr); gap: 10px; padding: 10px 12px; }
  .icon { width: 26px; height: 26px; }
  .icon.dir::after { left: 5px; top: 11px; width: 16px; height: 9px; }
  .icon.dir::before { left: 5px; top: 7px; }
  .icon.file::after { left: 7px; top: 6px; width: 12px; }
  .panel-head { align-items: stretch; flex-direction: column; gap: 8px; }
  .head-left { flex: 1 1 auto; }
  .search { max-width: none; }
  .head-right { width: 100%; justify-content: space-between; }
  .dialog { padding: 20px 16px 16px; }
  .dialog-actions { flex-direction: column-reverse; }
  .btn { width: 100%; }
}
