/* ==========================================================================
   默拉智能 · 对象存储 — 设计系统
   一套克制的视觉语言：中性底、单一强调色、细线分隔、克制的投影。
   ========================================================================== */

:root {
  color-scheme: light;

  /* 表面层级 */
  --bg: #fbfbfa;
  --surface: #ffffff;
  --surface-sunken: #f6f6f5;
  --surface-hover: #f7f7f6;

  /* 线与分隔 */
  --line: #ebebe8;
  --line-strong: #dededa;

  /* 文字 */
  --text: #1b1c1a;
  --text-secondary: #5c5f5a;
  --text-tertiary: #8a8d86;
  --text-inverse: #ffffff;

  /* 强调色 */
  --accent: #0d7a6f;
  --accent-hover: #0a655c;
  --accent-soft: #eaf6f4;
  --accent-border: #bfe3de;

  /* 语义色 */
  --danger: #b42318;
  --danger-soft: #fdf0ef;
  --danger-border: #f5cdc9;
  --success: #0a6b3d;
  --success-soft: #e9f6ee;
  --success-border: #c2e5d0;
  --warning: #8a5a00;
  --warning-soft: #fdf6e7;
  --warning-border: #f0dfb5;

  /* 形状 */
  --r-lg: 14px;
  --r-md: 9px;
  --r-sm: 6px;
  --r-pill: 999px;

  /* 投影：只在真正需要层次时使用 */
  --shadow-sm: 0 1px 2px rgba(24, 28, 25, .05);
  --shadow-md: 0 2px 6px rgba(24, 28, 25, .06), 0 8px 24px rgba(24, 28, 25, .06);
  --shadow-lg: 0 12px 40px rgba(24, 28, 25, .14);

  /* 排版 */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* 动效 */
  --ease: cubic-bezier(.2, .7, .3, 1);
  --fast: 120ms;
  --normal: 200ms;

  --masthead-h: 56px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101211;
  --surface: #171918;
  --surface-sunken: #1d201f;
  --surface-hover: #212423;
  --line: #262927;
  --line-strong: #333735;
  --text: #eceded;
  --text-secondary: #a2a6a2;
  --text-tertiary: #747974;
  --text-inverse: #0d0f0e;
  --accent: #3ddbc8;
  --accent-hover: #6ee7d7;
  --accent-soft: #0f2f2c;
  --accent-border: #1d4b46;
  --danger: #f3857c;
  --danger-soft: #2b1614;
  --danger-border: #4a2521;
  --success: #5ee89b;
  --success-soft: #0f271a;
  --success-border: #1d4430;
  --warning: #f2c05e;
  --warning-soft: #29200c;
  --warning-border: #46360f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #101211;
    --surface: #171918;
    --surface-sunken: #1d201f;
    --surface-hover: #212423;
    --line: #262927;
    --line-strong: #333735;
    --text: #eceded;
    --text-secondary: #a2a6a2;
    --text-tertiary: #747974;
    --text-inverse: #0d0f0e;
    --accent: #3ddbc8;
    --accent-hover: #6ee7d7;
    --accent-soft: #0f2f2c;
    --accent-border: #1d4b46;
    --danger: #f3857c;
    --danger-soft: #2b1614;
    --danger-border: #4a2521;
    --success: #5ee89b;
    --success-soft: #0f271a;
    --success-border: #1d4430;
    --warning: #f2c05e;
    --warning-soft: #29200c;
    --warning-border: #46360f;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-md: 0 2px 6px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
  }
}

/* ---------- 基础重置 ---------- */

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, figure { margin: 0; }

button, input, select, textarea { font: inherit; color: inherit; }

::selection { background: var(--accent-soft); color: var(--text); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   布局
   ========================================================================== */

.shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px 72px;
}

/* ---------- 顶栏 ---------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--masthead-h);
  margin: 0 -20px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--normal) var(--ease);
}

.masthead.scrolled { border-bottom-color: var(--line); }

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-right: auto;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 26px;
  height: 26px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--text);
  color: var(--surface);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -.03em;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }

.brand-name {
  font-size: 13.5px;
  font-weight: 560;
  letter-spacing: -.01em;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  letter-spacing: .01em;
}

.masthead-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* ---------- 主标题区 ---------- */

.hero {
  display: flex;
  align-items: flex-end;
  gap: 20px;
  flex-wrap: wrap;
  padding: 34px 0 20px;
}

.hero-text { min-width: 0; }

.hero h1 {
  font-size: 25px;
  font-weight: 620;
  letter-spacing: -.025em;
  line-height: 1.2;
}

.hero p {
  margin-top: 5px;
  font-size: 13px;
  color: var(--text-secondary);
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* ---------- 统计条 ---------- */

.stats {
  display: flex;
  gap: 28px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.stat-value {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 11.5px;
  color: var(--text-tertiary);
  letter-spacing: .02em;
  margin-top: 1px;
}

/* ==========================================================================
   控件
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--accent);
  color: var(--text-inverse);
  font-size: 13px;
  font-weight: 520;
  letter-spacing: -.005em;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease),
              color var(--fast) var(--ease), transform var(--fast) var(--ease);
}

:root[data-theme="dark"] .btn:not(.secondary):not(.quiet) { color: #06211e; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn:not(.secondary):not(.quiet) { color: #06211e; }
}

.btn svg { width: 15px; height: 15px; flex: none; }

.btn:hover:not(:disabled) { background: var(--accent-hover); }
.btn:active:not(:disabled) { transform: translateY(.5px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn.secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line-strong);
}
.btn.secondary:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--text-tertiary); }

.btn.danger {
  background: var(--danger);
  color: #fff;
}
.btn.danger:hover:not(:disabled) { filter: brightness(1.06); }

.btn.quiet {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
}
.btn.quiet:hover:not(:disabled) { background: var(--danger-soft); }

.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: var(--r-sm); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}

.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }

.icon-btn.spin svg { animation: spin 900ms linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 输入 ---------- */

.field {
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
  min-width: 0;
}

.field::placeholder { color: var(--text-tertiary); }

.field:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

select.field {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8d86' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}

/* ---------- 搜索框 ---------- */

.search {
  position: relative;
  flex: 1 1 220px;
  max-width: 320px;
}

.search > svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.search .field {
  width: 100%;
  padding-left: 32px;
  padding-right: 44px;
}

.search kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  padding: 0 5px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface-sunken);
  color: var(--text-tertiary);
  font-family: var(--font);
  font-size: 10.5px;
  line-height: 16px;
  pointer-events: none;
  transition: opacity var(--fast) var(--ease);
}

.search .field:focus ~ kbd,
.search .field:not(:placeholder-shown) ~ kbd { opacity: 0; }

/* ---------- 分段控件 ---------- */

.seg {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  border-radius: var(--r-md);
  background: var(--surface-sunken);
  border: 1px solid var(--line);
}

.seg button {
  height: 28px;
  padding: 0 11px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease),
              box-shadow var(--fast) var(--ease);
}

.seg button:hover { color: var(--text); }

.seg button[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.seg .count {
  margin-left: 5px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
}

/* ==========================================================================
   工具栏
   ========================================================================== */

.toolbar {
  position: sticky;
  top: var(--masthead-h);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

/* ==========================================================================
   提示条
   ========================================================================== */

.notice {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  animation: rise var(--normal) var(--ease);
}

.notice > svg { width: 15px; height: 15px; flex: none; margin-top: 1px; }

.notice.info { color: var(--text-secondary); background: var(--surface-sunken); border-color: var(--line); }
.notice.ok { color: var(--success); background: var(--success-soft); border-color: var(--success-border); }
.notice.warn { color: var(--warning); background: var(--warning-soft); border-color: var(--warning-border); }
.notice.err { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-border); }

@keyframes rise {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   列表
   ========================================================================== */

.list {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
}

.list-head,
.row {
  display: grid;
  grid-template-columns: 22px 46px minmax(0, 1fr) 84px 96px 34px;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
}

.list-head {
  height: 38px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-sunken);
  font-size: 11px;
  font-weight: 560;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.list-head button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.list-head button:hover { color: var(--text-secondary); }
.list-head button svg { width: 11px; height: 11px; opacity: 0; transition: opacity var(--fast); }
.list-head button[data-sorted] { color: var(--text); }
.list-head button[data-sorted] svg { opacity: 1; }
.list-head .num { text-align: right; }
.list-head .num button { justify-content: flex-end; }

.row {
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  transition: background var(--fast) var(--ease);
}

.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-hover); }
.row[data-selected="true"] { background: var(--accent-soft); }

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

.row-name {
  font-size: 13.5px;
  font-weight: 490;
  letter-spacing: -.005em;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-key {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-mobile-meta { display: none; }

.row-meta {
  font-size: 12.5px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.row-meta.right { text-align: right; }

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--fast) var(--ease);
}

.row:hover .row-actions,
.row:focus-within .row-actions,
.row[data-selected="true"] .row-actions { opacity: 1; }

@media (hover: none) {
  .row-actions { opacity: 1; }
}

/* ---------- 缩略图 ---------- */

.thumb {
  width: 44px;
  height: 36px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface-sunken);
  object-fit: cover;
  display: block;
  overflow: hidden;
}

button.thumb-btn {
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
  border-radius: var(--r-sm);
  display: block;
  line-height: 0;
}

.thumb-ph {
  width: 44px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface-sunken);
  color: var(--text-tertiary);
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  user-select: none;
}

/* ---------- 复选框 ---------- */

.check {
  appearance: none;
  width: 15px;
  height: 15px;
  margin: 0;
  border: 1.5px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease);
}

.check:checked,
.check:indeterminate {
  background: var(--accent);
  border-color: var(--accent);
}

.check:checked::after {
  content: "";
  width: 8px;
  height: 4.5px;
  border: 1.5px solid #fff;
  border-top: 0;
  border-right: 0;
  transform: rotate(-45deg) translateY(-1px);
}

.check:indeterminate::after {
  content: "";
  width: 7px;
  height: 1.5px;
  background: #fff;
}

:root[data-theme="dark"] .check:checked::after { border-color: #06211e; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .check:checked::after { border-color: #06211e; }
}
:root[data-theme="dark"] .check:indeterminate::after { background: #06211e; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .check:indeterminate::after { background: #06211e; }
}

/* ---------- 徽标 ---------- */

.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface-sunken);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .01em;
  white-space: nowrap;
}

/* ==========================================================================
   空状态 / 骨架屏
   ========================================================================== */

.empty {
  display: grid;
  justify-items: center;
  gap: 5px;
  padding: 60px 24px;
  text-align: center;
}

.empty > svg {
  width: 38px;
  height: 38px;
  color: var(--line-strong);
  margin-bottom: 8px;
}

.empty-title {
  font-size: 13.5px;
  font-weight: 520;
  color: var(--text-secondary);
}

.empty-text {
  font-size: 12.5px;
  color: var(--text-tertiary);
  max-width: 330px;
  line-height: 1.55;
}

.empty .btn { margin-top: 12px; }

.skeleton-row {
  display: grid;
  grid-template-columns: 22px 46px minmax(0, 1fr) 84px 96px 34px;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  height: 58px;
  border-bottom: 1px solid var(--line);
}

.skeleton-row:last-child { border-bottom: 0; }

.sk {
  height: 10px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--surface-sunken) 25%, var(--line) 37%, var(--surface-sunken) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

.sk.thumb-sk { height: 36px; border-radius: var(--r-sm); }
.sk.w-40 { width: 40%; }
.sk.w-60 { width: 60%; }
.sk.w-80 { width: 80%; }
.sk.w-100 { width: 100%; }

@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: 0 0; }
}

/* ==========================================================================
   列表页脚 / 分页
   ========================================================================== */

.list-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 11px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface-sunken);
  font-size: 12.5px;
  color: var(--text-tertiary);
}

.list-foot .spacer { margin-left: auto; }

.pager {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.pager button {
  min-width: 28px;
  height: 28px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease);
}

.pager button:hover:not(:disabled) { background: var(--surface); border-color: var(--line); color: var(--text); }
.pager button[aria-current="page"] { background: var(--surface); border-color: var(--line-strong); color: var(--text); font-weight: 560; }
.pager button:disabled { opacity: .35; cursor: not-allowed; }

/* ==========================================================================
   全屏拖放遮罩
   ========================================================================== */

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--bg) 74%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade var(--fast) var(--ease);
  pointer-events: none;
}

.drop-overlay-inner {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 52px 68px;
  border: 1.5px dashed var(--accent);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.drop-overlay svg { width: 32px; height: 32px; color: var(--accent); }
.drop-overlay strong { font-size: 15px; font-weight: 580; letter-spacing: -.01em; }
.drop-overlay span { font-size: 12.5px; color: var(--text-tertiary); }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ==========================================================================
   上传托盘
   ========================================================================== */

.tray {
  margin: 16px 0 4px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
  animation: rise var(--normal) var(--ease);
}

.tray-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-sunken);
}

.tray-head h2 {
  font-size: 12.5px;
  font-weight: 560;
  letter-spacing: -.005em;
}

.tray-sum {
  font-size: 12px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.tray-head .spacer { margin-left: auto; }

.tray-list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; }

.tray-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
}

.tray-item:last-child { border-bottom: 0; }

.tray-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--surface-sunken);
  color: var(--text-tertiary);
}

.tray-icon svg { width: 15px; height: 15px; }

.tray-item[data-state="done"] .tray-icon { background: var(--success-soft); color: var(--success); }
.tray-item[data-state="error"] .tray-icon { background: var(--danger-soft); color: var(--danger); }

.tray-info { min-width: 0; display: flex; flex-direction: column; gap: 4px; }

.tray-name {
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tray-bar {
  height: 3px;
  border-radius: var(--r-pill);
  background: var(--line);
  overflow: hidden;
}

.tray-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: var(--r-pill);
  background: var(--accent);
  transition: width 180ms var(--ease);
}

.tray-item[data-state="done"] .tray-bar i { background: var(--success); }
.tray-item[data-state="error"] .tray-bar i { background: var(--danger); width: 100% !important; }

.tray-note {
  font-size: 11px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tray-item[data-state="error"] .tray-note { color: var(--danger); }
.tray-item[data-state="done"] .tray-note { color: var(--success); }

.tray-act { display: flex; gap: 2px; align-items: center; }

/* ==========================================================================
   对话框
   ========================================================================== */

dialog {
  padding: 0;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  max-width: min(430px, calc(100vw - 32px));
  width: 100%;
}

dialog::backdrop {
  background: rgba(12, 16, 14, .38);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

dialog[open] { animation: dialog-in var(--normal) var(--ease); }

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(6px) scale(.985); }
  to { opacity: 1; transform: none; }
}

.dialog-body { padding: 22px 22px 4px; }

.dialog-body h2 {
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -.015em;
}

.dialog-body p {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.dialog-subject {
  margin-top: 13px;
  padding: 9px 11px;
  border-radius: var(--r-sm);
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-secondary);
  word-break: break-all;
  max-height: 96px;
  overflow-y: auto;
}

.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 18px 22px 20px;
}

/* ---------- 灯箱 ---------- */

dialog.lightbox {
  max-width: min(1100px, calc(100vw - 32px));
  width: auto;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.lightbox-figure { display: grid; gap: 12px; justify-items: center; }

.lightbox-figure img {
  max-width: 100%;
  max-height: calc(100dvh - 150px);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  object-fit: contain;
  display: block;
}

.lightbox-cap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 13px;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 12px;
  color: var(--text-secondary);
  max-width: min(640px, 90vw);
}

.lightbox-cap strong {
  font-weight: 520;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  color: var(--text);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: opacity var(--fast) var(--ease), background var(--fast) var(--ease);
}

.lightbox-nav svg { width: 18px; height: 18px; }
.lightbox-nav.prev { left: 16px; }
.lightbox-nav.next { right: 16px; }
.lightbox-nav:disabled { opacity: 0; pointer-events: none; }

/* ==========================================================================
   提示消息
   ========================================================================== */

.toast-layer {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: var(--r-pill);
  background: var(--text);
  color: var(--surface);
  font-size: 12.5px;
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  animation: toast-in 220ms var(--ease);
}

.toast.leaving { animation: toast-out 180ms var(--ease) forwards; }

.toast.err { background: var(--danger); color: #fff; }
.toast.ok { background: var(--success); color: #fff; }

.toast button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: 12.5px;
  font-weight: 560;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  opacity: .85;
}

.toast button:hover { opacity: 1; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(6px) scale(.98); }
}

/* ==========================================================================
   批量操作条
   ========================================================================== */

.bulkbar {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 8px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  font-size: 12.5px;
  animation: toast-in 220ms var(--ease);
}

.bulkbar .count { font-weight: 560; font-variant-numeric: tabular-nums; }

/* ==========================================================================
   响应式
   ========================================================================== */

@media (max-width: 720px) {
  .shell { padding: 0 14px 64px; }
  .masthead { margin: 0 -14px; padding: 0 14px; }

  .hero { padding: 24px 0 16px; gap: 14px; }
  .hero h1 { font-size: 21px; }
  .hero-actions { margin-left: 0; width: 100%; }
  .hero-actions .btn { flex: 1; }

  .stats { gap: 20px; }

  .toolbar { gap: 6px; }
  .search { flex: 1 1 100%; max-width: none; order: 3; }

  .list-head { display: none; }

  .row {
    grid-template-columns: 20px 44px minmax(0, 1fr) auto;
    row-gap: 2px;
    padding: 10px 12px;
    min-height: 0;
  }

  .row .cell-size,
  .row .cell-date { display: none; }

  /* 窄屏把尺寸与时间并入主信息，原始 key 让位 */
  .row .row-key { display: none; }
  .row-mobile-meta { display: block; font-size: 11.5px; color: var(--text-tertiary); }

  .row { grid-template-columns: 20px 44px minmax(0, 1fr) auto; }
  .row .row-actions { gap: 0; }

  .row-actions { opacity: 1; }

  .skeleton-row {
    grid-template-columns: 20px 44px minmax(0, 1fr) auto;
    padding: 10px 12px;
    height: 56px;
  }

  .skeleton-row > :nth-child(4),
  .skeleton-row > :nth-child(5) { display: none; }

  .drop-overlay-inner { padding: 40px 26px; }

  .tray-item { grid-template-columns: 26px minmax(0, 1fr) auto; gap: 9px; padding: 8px 12px; }

  .lightbox-nav { display: none; }

  .bulkbar { width: calc(100vw - 28px); justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
