/* ===========================================================================
   FansMap 后台 — 布局与组件
   所有颜色 / 间距 / 圆角 / 动效都必须走 tokens.css 的变量。
   =========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 14px; line-height: 22px; font-weight: 400;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, dl, dd, dt { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.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;
}
.icon {
  width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* —— 字号阶梯：只用规格里的 8 档 —— */
.t-page { font-size: 24px; line-height: 32px; font-weight: 600; letter-spacing: -0.015em; }
.t-block { font-size: 16px; line-height: 24px; font-weight: 600; }
.t-body { font-size: 14px; line-height: 22px; font-weight: 400; }
.t-ctrl { font-size: 13px; line-height: 20px; font-weight: 500; }
.t-cell { font-size: 13px; line-height: 20px; font-weight: 400; }
.t-meta { font-size: 12px; line-height: 18px; font-weight: 400; color: var(--text-3); }
.t-badge { font-size: 11px; line-height: 16px; font-weight: 500; letter-spacing: .01em; }
.t-stat { font-size: 32px; line-height: 36px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* 键盘焦点：全局可见，禁止 outline:none */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }

/* ============================ globalbar ============================ */
.globalbar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center;
  gap: var(--s-3); height: 56px; padding: 0 var(--s-5);
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: var(--s-2); flex: none; }
.brand:hover .brand-name { color: var(--accent); }
.brand-mark {
  width: 20px; height: 20px; flex: none; color: var(--accent);
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.brand-name {
  font-size: 15px; line-height: 22px; font-weight: 600; letter-spacing: -0.01em;
  transition: color var(--t-fast) var(--ease);
}
.bar-spacer { flex: 1; }
/* 顶栏只留必须的状态：健康点裸化，不再用一条药丸去抢注意力 */
.health {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: 0 var(--s-1); color: var(--text-3); white-space: nowrap;
}
.health-dot { width: 8px; height: 8px; border-radius: var(--r-full); background: var(--text-3); flex: none; }
.health[data-health="ok"] .health-dot { background: var(--ok-fg); }
.health[data-health="down"] .health-dot { background: var(--err-fg); }
.pending-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 24px;
  padding: 0 var(--s-2); border-radius: var(--r-sm);
  background: var(--place-bg); color: var(--place-fg);
  font-size: 12px; line-height: 18px; font-weight: 500; white-space: nowrap;
}
.pending-pill b { font-weight: 600; }
.pending-pill[hidden] { display: none; }

/* ============================ shell / rail ============================ */
.shell { display: flex; align-items: flex-start; min-height: calc(100dvh - 56px); }
.rail {
  position: sticky; top: 56px; flex: none; width: 200px;
  height: calc(100dvh - 56px); padding: var(--s-3) var(--s-2) var(--s-4);
  border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 1px;
  overflow-y: auto;
}
.rail-label {
  padding: var(--s-4) var(--s-3) var(--s-2);
  font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: .06em;
  color: var(--text-3); text-transform: uppercase;
}
.rail > .rail-label:first-child { padding-top: var(--s-1); }
.rail-item {
  position: relative; display: flex; align-items: center; gap: var(--s-2);
  height: 34px; padding: 0 var(--s-3); border-radius: var(--r-md);
  color: var(--text-2); font-size: 13px; line-height: 20px; font-weight: 500;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.rail-item .icon { width: 18px; height: 18px; }
.rail-item:hover { background: var(--surface-2); color: var(--text); }
.rail-item[aria-current="page"] { background: var(--surface-3); color: var(--text); font-weight: 600; }
.rail-item[aria-current="page"]::before {
  content: ""; position: absolute; left: 0; top: var(--s-2); bottom: var(--s-2);
  width: 2px; border-radius: var(--r-full); background: var(--accent);
}
.rail-count {
  margin-left: auto; font-size: 12px; line-height: 18px; color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.rail-count[hidden] { display: none; }

.content { flex: 1; min-width: 0; width: 100%; max-width: 1360px; margin: 0 auto; padding: var(--s-8); }
.page { display: flex; flex-direction: column; gap: var(--s-6); }
.page[hidden] { display: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }
.page-sub { margin-top: var(--s-1); color: var(--text-3); font-size: 14px; line-height: 22px; max-width: 60ch; }
.head-actions { display: flex; align-items: center; gap: var(--s-2); }

/* ============================ 按钮 ============================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: 36px; padding: 0 var(--s-4); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); background: var(--surface); color: var(--text);
  font-size: 13px; line-height: 20px; font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease);
}
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:active:not(:disabled) { transform: translateY(0.5px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn[aria-pressed="true"] { background: var(--surface-3); border-color: var(--border-strong); }
.btn-sm { height: 28px; padding: 0 var(--s-3); font-size: 13px; line-height: 20px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn-danger { color: var(--err-fg); border-color: var(--err-fg); background: var(--surface); }
.btn-danger:hover:not(:disabled) { background: var(--err-bg); }
/* loading：文字保留 + 左侧 14px spinner，宽度不跳变 */
.btn[data-loading="true"] { pointer-events: none; }
.btn[data-loading="true"]::before {
  content: ""; width: 14px; height: 14px; flex: none; border-radius: var(--r-full);
  border: 2px solid currentColor; border-top-color: transparent;
  animation: spin 640ms linear infinite;
}
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; border: 1px solid transparent;
  border-radius: var(--r-md); background: transparent; color: var(--text-3); cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.btn-icon:hover { background: var(--surface-3); color: var(--text); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================ 表单 ============================ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; line-height: 18px; font-weight: 500; color: var(--text-2); }
.input, .textarea, .select {
  width: 100%; height: 36px; padding: 0 var(--s-3);
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--text); font: inherit;
  font-size: 13px; line-height: 20px;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.textarea { height: auto; min-height: 84px; padding: var(--s-2) var(--s-3); line-height: 22px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--err-fg); }
.field-error { font-size: 12px; line-height: 18px; color: var(--err-fg); }
.field-error[hidden] { display: none; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; line-height: 18px; color: var(--text-2); cursor: pointer; }
.check input { width: 14px; height: 14px; accent-color: var(--accent); }
.search { position: relative; flex: 1; min-width: 180px; max-width: 360px; }
.search .icon { position: absolute; left: var(--s-3); top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search .input { padding-left: calc(var(--s-8) + var(--s-2)); }
/* 筛选栏：搜索与计数同一行，避免堆成四层 */
.toolbar { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.toolbar .search { flex: 1 1 220px; } .toolbar-meta { margin-left: auto; white-space: nowrap; }
/* 批量管理条：只在管理模式下出现，不挤占默认列表节奏 */
.manage-bar {
  display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  padding: var(--s-2) var(--s-3); border: 1px solid var(--border);
  border-radius: var(--r-md); background: var(--surface-2);
}
.manage-bar[hidden] { display: none; }
.manage-bar .btn-danger { margin-left: auto; }

/* ============================ 徽章 / 进度 ============================ */
.badge {
  display: inline-flex; align-items: center; gap: var(--s-1); padding: 2px var(--s-2);
  border-radius: var(--r-full); font-size: 11px; line-height: 16px; font-weight: 500;
  letter-spacing: .01em; white-space: nowrap;
  background: var(--queued-bg); color: var(--queued-fg);
}
.badge[data-tone="run"] { background: var(--run-bg); color: var(--run-fg); }
.badge[data-tone="place"] { background: var(--place-bg); color: var(--place-fg); }
.badge[data-tone="ok"] { background: var(--ok-bg); color: var(--ok-fg); }
.badge[data-tone="err"] { background: var(--err-bg); color: var(--err-fg); }
.progress { height: 4px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.progress > span {
  display: block; height: 100%; width: 0; border-radius: inherit;
  background: var(--run-fg); transition: width var(--t-base) var(--ease);
}
.progress[data-tone="queued"] > span { background: var(--queued-fg); }
.progress[data-tone="place"] > span { background: var(--place-fg); }
.progress[data-tone="ok"] > span { background: var(--ok-fg); }
.progress[data-tone="err"] > span { background: var(--err-fg); }

/* ============================ 卡片 / 面板 ============================ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s-4);
  transition: border-color var(--t-fast) var(--ease);
}
.card-hover:hover { border-color: var(--border-strong); }
.card-flush { padding: 0; overflow: hidden; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-4); border-bottom: 1px solid var(--border);
}
.card-body { padding: var(--s-4); }

/* ============================ 统计块 ============================ */
/* 四个统计合并成一条仪表，避免四张同尺寸白卡把页面压平 */
.stat-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden;
}
.stat { padding: var(--s-3) var(--s-5); border-left: 1px solid var(--border); }
.stat:first-child { border-left: 0; }
.stat-label { display: flex; align-items: center; gap: 6px; font-size: 12px; line-height: 18px; color: var(--text-3); }
.stat-label::before {
  content: ""; width: 6px; height: 6px; border-radius: var(--r-full);
  background: var(--border-strong); flex: none;
}
.stat[data-tone="run"] .stat-label::before { background: var(--run-fg); }
.stat[data-tone="place"] .stat-label::before { background: var(--place-fg); }
.stat[data-tone="ok"] .stat-label::before { background: var(--ok-fg); }
.stat[data-tone="err"] .stat-label::before { background: var(--err-fg); }
.stat-value {
  display: block; margin-top: 2px; font-size: 28px; line-height: 34px;
  font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}
.stat[data-tone="run"] .stat-value { color: var(--run-fg); }
.stat[data-tone="place"] .stat-value { color: var(--place-fg); }
.stat[data-tone="ok"] .stat-value { color: var(--ok-fg); }
.stat[data-tone="err"] .stat-value { color: var(--err-fg); }

/* ============================ chips ============================ */
.chips { display: flex; gap: var(--s-1); flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 var(--s-3);
  border: 1px solid transparent; border-radius: var(--r-sm); background: transparent;
  color: var(--text-3); font-size: 13px; line-height: 20px; font-weight: 500; cursor: pointer;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.chip:hover { background: var(--surface-3); color: var(--text); }
.chip[aria-pressed="true"] {
  background: var(--accent-soft); border-color: var(--accent-line);
  color: var(--accent); font-weight: 600;
}
.chip-num { font-variant-numeric: tabular-nums; opacity: .8; }

/* ============================ 空态 / 骨架 / 错误 ============================ */
.state {
  display: flex; flex-direction: column; align-items: center; gap: var(--s-2);
  padding: var(--s-12) var(--s-4); text-align: center;
  border: 1px dashed var(--border-strong); border-radius: var(--r-lg); background: transparent;
}
/* 状态块已经落在带边框的容器里时，去掉自己的框，避免框套框 */
.rows > .state, .card-flush .state { border: 0; border-radius: 0; }
.state-icon {
  display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: var(--s-1);
  border-radius: var(--r-full); background: var(--surface-3); color: var(--text-3);
}
.state-icon .icon { width: 20px; height: 20px; }
.state-title { font-size: 14px; line-height: 22px; font-weight: 500; color: var(--text); }
.state-text { font-size: 12px; line-height: 18px; color: var(--text-3); max-width: 42ch; }
.state[data-tone="error"] { border: 1px solid transparent; background: var(--err-bg); }
.state[data-tone="error"] .state-icon { background: transparent; color: var(--err-fg); }
.state[data-tone="error"] .state-title { color: var(--err-fg); }
.state .btn { margin-top: var(--s-2); }
.skeleton { display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-4); }
.sk-line, .sk-card, .sk-block {
  background: var(--surface-3); border-radius: var(--r-sm);
  animation: breathe 1.4s var(--ease) infinite;
}
.sk-line { height: 12px; }
.sk-line[data-w="40"] { width: 40%; } .sk-line[data-w="60"] { width: 60%; } .sk-line[data-w="80"] { width: 80%; }
.sk-card { aspect-ratio: 16 / 9; border-radius: var(--r-lg); }
.sk-block { height: 120px; border-radius: var(--r-lg); }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

/* ============================ Toast ============================ */
.toasts {
  position: fixed; right: var(--s-5); bottom: var(--s-5); z-index: 80;
  display: flex; flex-direction: column; gap: var(--s-2); align-items: flex-end; pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: var(--s-2); width: 320px; max-width: calc(100vw - var(--s-8));
  padding: var(--s-3); border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  background: var(--surface); color: var(--text); box-shadow: var(--sh-2);
  font-size: 13px; line-height: 20px; pointer-events: auto;
  animation: toast-in var(--t-base) var(--ease) both;
}
.toast .icon { width: 18px; height: 18px; }
.toast[data-tone="ok"] .icon { color: var(--ok-fg); }
.toast[data-tone="err"] .icon { color: var(--err-fg); }
.toast[data-tone="info"] .icon { color: var(--run-fg); }
.toast-close { margin-left: auto; border: 0; background: transparent; color: var(--text-3); cursor: pointer; padding: 0; line-height: 1; }
.toast[data-leaving="true"] { animation: toast-out var(--t-base) var(--ease) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(4px); } }

/* ============================ 导入页 ============================ */
.import-form { display: flex; flex-direction: column; gap: var(--s-3); }
.import-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.detect { font-size: 12px; line-height: 18px; color: var(--text-3); }
.detect[data-kind="video"] { color: var(--run-fg); }
.detect[data-kind="creator"] { color: var(--accent); }
.detect[data-kind="unknown"] { color: var(--place-fg); }
.import-actions { display: flex; align-items: center; gap: var(--s-3); }

/* ============================ 任务队列 ============================ */
.rows { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.rows-flush { border: 0; border-radius: 0; background: transparent; }
.row {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: var(--s-3);
  align-items: center; min-height: 60px; padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border); transition: background var(--t-fast) var(--ease);
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.row.is-open { background: var(--surface-2); }
.row-thumb { display: block; flex: none; width: 64px; height: 36px; border-radius: var(--r-sm); background: var(--surface-3); object-fit: cover; }
.row-main { min-width: 0; display: flex; flex-direction: column; gap: var(--s-1); }
.row-title { display: flex; align-items: center; gap: var(--s-2); min-width: 0; }
.row-title strong { font-size: 13px; line-height: 20px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { display: flex; align-items: center; gap: var(--s-2); font-size: 12px; line-height: 18px; color: var(--text-3); font-variant-numeric: tabular-nums; flex-wrap: wrap; }
/* 用间隔点代替拥挤的空白，扫读时字段边界更清楚 */
.row-meta > span:not(.badge) + span:not(.badge)::before {
  content: "·"; margin-right: var(--s-2); color: var(--border-strong);
}
.row-side { display: flex; align-items: center; gap: var(--s-2); }
.row-progress { display: flex; align-items: center; gap: var(--s-2); width: 132px; }
.row-progress .progress { flex: 1; }
.row-progress .t-meta { width: 32px; text-align: right; }
.row-toggle { width: 28px; height: 28px; }
.row-toggle .icon { width: 16px; height: 16px; transition: transform var(--t-fast) var(--ease); }
.row-toggle[aria-expanded="true"] .icon { transform: rotate(90deg); }
.row-detail { grid-column: 1 / -1; display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-3); border-radius: var(--r-md); background: var(--surface-3); }
.row-detail .row-error { margin: 0; font-family: var(--mono); font-size: 12px; line-height: 18px; color: var(--text-2); white-space: pre-wrap; word-break: break-word; max-height: 160px; overflow: auto; user-select: text; }

/* ============================ 视频网格 ============================ */
.workbench { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: var(--s-6); align-items: start; }
.workbench[data-detail="off"] { grid-template-columns: minmax(0, 1fr); }
.workbench-main { min-width: 0; display: flex; flex-direction: column; gap: var(--s-4); }
.vgrid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s-4); }
.vcard {
  display: flex; flex-direction: column; text-align: left; padding: 0; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface);
  cursor: pointer; transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.vcard:hover { border-color: var(--border-strong); }
.vcard[aria-pressed="true"] { border-color: var(--accent); }
.vcard-cover { position: relative; display: block; aspect-ratio: 2 / 2.7; background: var(--surface-3); }
.vcard-cover img { width: 100%; height: 100%; object-fit: cover; }
.vcard-cover .badge { position: absolute; top: var(--s-2); right: var(--s-2); }
.vcard-body { display: flex; flex-direction: column; gap: var(--s-1); padding: var(--s-3) var(--s-4) var(--s-4); min-width: 0; flex: 1; }
.vcard-title {
  font-size: 14px; line-height: 22px; font-weight: 500; letter-spacing: -0.005em;
  min-height: 44px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.vcard-meta { display: flex; align-items: center; gap: var(--s-2); font-size: 12px; line-height: 18px; color: var(--text-3); }
.vcard-meta .creator { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vcard-meta .likes { margin-left: auto; display: inline-flex; align-items: center; gap: var(--s-1); font-variant-numeric: tabular-nums; }
.vcard-meta .likes .icon { width: 14px; height: 14px; }
.vcard-wrap { position: relative; display: flex; min-width: 0; }
.vcard-wrap .vcard { width: 100%; }
.vcard-author { display: flex; align-items: center; gap: var(--s-2); min-width: 0; }
.vcard-author .creator { flex: 1; min-width: 0; }
.vcard-meta .followers { white-space: nowrap; font-variant-numeric: tabular-nums; }
.vcard-edit {
  position: absolute; top: var(--s-2); left: var(--s-2); z-index: 2;
  background: var(--surface); border-color: var(--border); color: var(--text-2);
  transition: opacity var(--t-fast) var(--ease), background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.vcard-edit .icon { width: 16px; height: 16px; }
.vcard-check {
  display: none; position: absolute; top: var(--s-2); left: var(--s-2); z-index: 2;
  width: 22px; height: 22px; place-items: center; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: transparent;
}
.vcard-check .icon { width: 14px; height: 14px; }
.vgrid[data-manage="on"] .vcard-check { display: grid; }
.vgrid[data-manage="on"] .vcard-edit { display: none; }
.vgrid[data-manage="on"] .vcard[aria-pressed="true"] { background: var(--accent-soft); }
.vcard[aria-pressed="true"] .vcard-check { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
@media (hover: hover) {
  .vcard-edit { opacity: 0; }
  .vcard-wrap:hover .vcard-edit, .vcard-edit:focus-visible { opacity: 1; }
}
.cover-fallback { display: grid; place-items: center; width: 100%; height: 100%; background: var(--surface-3); color: var(--text-3); }

/* ============================ inspector ============================ */
.inspector {
  position: sticky; top: 72px; display: flex; flex-direction: column; gap: var(--s-4);
  width: 420px; max-height: calc(100dvh - 96px); overflow-y: auto;
  padding: var(--s-4); border: 1px solid var(--border);
  border-radius: var(--r-lg); background: var(--surface);
  animation: drawer-in var(--t-base) var(--ease) both;
}
.inspector[hidden] { display: none; }
@keyframes drawer-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
.inspector-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-2);
  padding-bottom: var(--s-3); border-bottom: 1px solid var(--border);
}
.inspector-cover { aspect-ratio: 16 / 9; border-radius: var(--r-lg); overflow: hidden; background: var(--surface-3); }
.inspector-title { font-size: 16px; line-height: 24px; font-weight: 600; letter-spacing: -0.01em; }
.inspector-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-2); }
.inspector-title-row .inspector-title { flex: 1; min-width: 0; }
.author { display: flex; align-items: center; gap: var(--s-2); font-size: 12px; line-height: 18px; color: var(--text-2); }
.avatar {
  width: 24px; height: 24px; flex: none; border-radius: var(--r-full); overflow: hidden;
  background: var(--surface-3); display: grid; place-items: center;
  font-size: 11px; line-height: 16px; font-weight: 600; color: var(--text-3);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 40px; height: 40px; font-size: 14px; }
.avatar-sm { width: 20px; height: 20px; font-size: 10px; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); }
.metric { padding: var(--s-2); border-radius: var(--r-md); background: var(--surface-2); text-align: center; }
.metric-value { display: block; font-size: 16px; line-height: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.metric-label { font-size: 12px; line-height: 18px; color: var(--text-3); }
.kv { display: flex; flex-direction: column; gap: var(--s-2); }
.kv-row { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: var(--s-2); font-size: 12px; line-height: 18px; }
.kv-row dt { color: var(--text-3); }
.kv-row dd { color: var(--text-2); word-break: break-word; font-variant-numeric: tabular-nums; }
.kv-row dd.mono { font-size: 12px; word-break: break-all; }
.kv-row a { color: var(--accent); }
.kv-row a:hover { text-decoration: underline; }
.place-warn { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3); border-radius: var(--r-md); background: var(--place-bg); color: var(--place-fg); font-size: 12px; line-height: 18px; }
.place-warn .icon { width: 16px; height: 16px; }
.inspector-form { display: flex; flex-direction: column; gap: var(--s-3); }
.inspector-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.inspector-actions { display: flex; gap: var(--s-2); }
.inspector-actions .btn { flex: 1; }
.inspector-foot { position: sticky; bottom: 0; padding-top: var(--s-3); background: var(--surface); }
.inspector-foot .btn { width: 100%; }
.map-sm { height: 280px; border-radius: var(--r-lg); overflow: hidden; background: var(--surface-3); }

/* ============================ 地点页 ============================ */
.split { display: grid; grid-template-columns: minmax(280px, 400px) minmax(0, 1fr); gap: var(--s-6); align-items: start; }
.split-map { position: sticky; top: 72px; }
.map-lg { height: calc(100dvh - 140px); min-height: 360px; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--surface-3); }
.map-skeleton {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 12px; line-height: 18px; color: var(--text-3); background: var(--surface-3);
}
.map-skeleton[hidden] { display: none; }
.map-frame { position: relative; }
.place-row-wrap { display: flex; align-items: center; border-bottom: 1px solid var(--border); }
.place-row-wrap:last-child { border-bottom: 0; }
.place-row { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left; padding: var(--s-3) var(--s-4); border: 0; background: transparent; cursor: pointer; }
.place-row:hover { background: var(--surface-2); }
.place-row[aria-pressed="true"] { background: var(--accent-soft); }
.place-delete { margin-right: var(--s-3); flex: none; }
/* 视频 inspector：多地点关联 + 视频店单选 */
.place-editor { display: flex; flex-direction: column; gap: var(--s-3); }
.place-editor-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.place-picked { border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.place-picked > .t-meta { padding: var(--s-3); }
.place-picked-row { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--border); }
.place-picked-row:last-child { border-bottom: 0; }
.place-picked-row[data-store="true"] { background: var(--accent-soft); }
.place-picked-row > input[type="checkbox"] { width: 14px; height: 14px; flex: none; accent-color: var(--accent); }
.place-picked-text { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 0; border: 0; background: transparent; text-align: left; font: inherit; cursor: pointer; }
.place-picked-text:hover .place-name { color: var(--accent); }
.place-picked-text .place-name { font-size: 13px; line-height: 20px; }
.place-store { flex: none; white-space: nowrap; }
.place-editor-actions { position: sticky; bottom: 0; padding-top: var(--s-3); border-top: 1px solid var(--border); background: var(--surface); }
.place-manual { display: flex; flex-direction: column; gap: var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--border); }
.place-address-row { display: flex; align-items: center; gap: var(--s-2); }
.place-address-row .input { flex: 1; min-width: 0; }
.place-address-row .btn { flex: none; }
.place-name { font-size: 13px; line-height: 20px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place-addr { font-size: 12px; line-height: 18px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place-results {
  position: absolute; left: 0; right: 0; top: calc(100% + var(--s-1)); z-index: 20;
  padding: var(--s-1); border: 1px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--surface); box-shadow: var(--sh-2); max-height: 240px; overflow-y: auto;
}
.place-results[hidden] { display: none; }
.place-result { display: block; width: 100%; text-align: left; padding: var(--s-2); border: 0; border-radius: var(--r-sm); background: transparent; font-size: 12px; line-height: 18px; color: var(--text-2); cursor: pointer; }
.place-result:hover, .place-result[data-active="true"] { background: var(--surface-3); color: var(--text); }
.place-result strong { color: var(--text); font-weight: 500; }
.place-result-check { display: flex; align-items: flex-start; gap: var(--s-2); width: 100%; padding: var(--s-2); border-radius: var(--r-sm); font-size: 12px; line-height: 18px; color: var(--text-2); }
.place-result-check:hover { background: var(--surface-3); }
.place-result-check input { margin-top: 2px; accent-color: var(--accent); flex: none; }
.place-result-main { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 0; border: 0; background: transparent; text-align: left; font: inherit; cursor: pointer; }
.place-result-main:hover strong { color: var(--accent); }
.place-result-main strong { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place-result-main span { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place-result-check .badge { flex: none; }
.place-status { padding: var(--s-2); font-size: 12px; line-height: 18px; color: var(--text-3); }
.place-search { position: relative; }

/* ============================ 博主 ============================ */
.cgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--s-4); }
.ccard { display: flex; flex-direction: column; gap: var(--s-3); }
.ccard-top { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.ccard-name { min-width: 0; flex: 1; }
.ccard-name strong { display: block; font-size: 16px; line-height: 24px; font-weight: 600; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ccard-name a { display: block; font-size: 12px; line-height: 18px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ccard-name a:hover { color: var(--accent); }
.ccard-stats { display: flex; gap: var(--s-4); font-size: 12px; line-height: 18px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.ccard-stats b { color: var(--text); font-weight: 600; }
.ccard-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* ============================ 弹窗 ============================ */
.modal {
  width: min(420px, calc(100vw - var(--s-8))); padding: var(--s-5);
  border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  background: var(--surface); color: var(--text); box-shadow: var(--sh-2);
}
.modal::backdrop { background: var(--scrim); }
.modal .t-body { margin-top: var(--s-2); color: var(--text-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--s-2); margin-top: var(--s-4); }
/* ============================ 账号弹层 ============================ */
.popover {
  position: fixed; top: calc(56px - 2px); right: var(--s-5); z-index: 70; width: 300px;
  display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-4);
  border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--sh-2);
}
.popover[hidden] { display: none; }
.popover-actions { display: flex; gap: var(--s-2); }

/* ============================ 响应式 ============================ */
@media (max-width: 1023px) {
  .content { padding: var(--s-5); }
  .workbench { grid-template-columns: minmax(0, 1fr); }
  /* inspector 变底部 sheet，高 70vh */
  .inspector {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto;
    height: 70vh; max-height: 70vh; border-radius: var(--r-xl) var(--r-xl) 0 0;
    z-index: 60;
    animation: sheet-in var(--t-base) var(--ease) both;
  }
  @keyframes sheet-in { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
  .split { grid-template-columns: minmax(0, 1fr); }
  .split-map { position: static; }
  .map-lg { height: 360px; }
  .vgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
  .content { padding: var(--s-4) var(--s-4) calc(56px + var(--s-8) + env(safe-area-inset-bottom)); }
  .globalbar { padding: 0 var(--s-4); gap: var(--s-2); }
  /* 顶栏在窄屏只留图标，避免横向溢出 */
  .globalbar .health span,
  .globalbar .bar-label { display: none; }
  /* 手机上只剩一个无文字的灰点会被当成渲染 bug，直接收起来 */
  .globalbar .health { display: none; }
  .globalbar .health { padding: 0 var(--s-2); }
  .brand-name { font-size: 14px; }
  .shell { display: block; }
  /* rail → 底部 tab bar */
  .rail {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0; z-index: 50;
    flex-direction: row; width: auto; height: calc(56px + env(safe-area-inset-bottom));
    padding: 0 var(--s-1) env(safe-area-inset-bottom); gap: 0;
    border-right: 0; border-top: 1px solid var(--border); background: var(--surface); overflow: visible;
  }
  .rail-item { flex: 1; flex-direction: column; justify-content: center; gap: var(--s-1); height: 100%; padding: 0; font-size: 10px; line-height: 14px; border-radius: 0; }
  .rail-item .icon { width: 20px; height: 20px; }
  .rail-item[aria-current="page"] { background: transparent; color: var(--accent); }
  .rail-item[aria-current="page"]::before { display: none; }
  .rail-label { display: none; }
  .rail-count { display: none; }
  .page { gap: var(--s-4); }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: var(--s-3) var(--s-4); }
  .stat:nth-child(odd) { border-left: 0; }
  .stat:nth-child(n + 3) { border-top: 1px solid var(--border); }
  .stat-value { font-size: 20px; line-height: 26px; }
  .vgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
  .cgrid { grid-template-columns: minmax(0, 1fr); }
  .row { grid-template-columns: 56px minmax(0, 1fr); padding: var(--s-3) var(--s-3); }
  .row-side { grid-column: 1 / -1; justify-content: flex-end; }
  .row-progress { width: 100%; }
  .row-thumb { width: 56px; height: 36px; }
  .inspector { height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .inspector-grid { grid-template-columns: 1fr; }
  .toasts { left: var(--s-3); right: var(--s-3); bottom: calc(56px + var(--s-3) + env(safe-area-inset-bottom)); align-items: stretch; }
  .toast { width: auto; max-width: none; }
  .search { max-width: none; }
  .popover { left: var(--s-3); right: var(--s-3); width: auto; }
}

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