/* ==========================================================================
   锚点 · Anchor — a personal bookmark workspace
   Style: achromatic-ledger (draw.mjs --app, seed 342973901) — no colour in
   the chrome, one hue on the main data element, ink everywhere else.
   Face: a paper-stone ground (#f5f4f1) with white index cards, so 569 colour
   favicons are the only colour on the page.
   Signature elements: the index-card bookmark, the themed share rail, and the
   ⌘K launcher.
   ========================================================================== */

/* ---------- faces (local woff2, latin subset; CJK falls to the system face) */
@font-face { font-family: Geist; src: url(fonts/Geist-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: Geist; src: url(fonts/Geist-500.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: Geist; src: url(fonts/Geist-600.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: Geist; src: url(fonts/Geist-700.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url(fonts/GeistMono-400.woff2) format("woff2"); font-weight: 400; font-display: swap; } /* taste-skill-ignore */
@font-face { font-family: "Geist Mono"; src: url(fonts/GeistMono-500.woff2) format("woff2"); font-weight: 500; font-display: swap; } /* taste-skill-ignore */

/* ---------- tokens (dealt style) ---------- */
:root {
  color-scheme: light;
  --ground: #f4f4f2;
  --surface: #ffffff;
  --raised: #f1efea;
  --active: #eae7e0;
  --border: #e4e1da;
  --rule: #efede7;
  --control: #d5d1c8;

  --text: #141412;
  --muted: #5f5d57;
  --faint: #605d56;

  --accent: #1d5fbf;          /* the one hue: the selected theme's share */
  --primary: #141412;
  --primary-ink: #ffffff;

  --positive: #247b50;
  --negative: #b3261e;
  --pill-neutral-bg: #eeece6;
  --pill-neutral-ink: #3d3b36;

  --grid: #e6e3dc;

  /* hover / fill 层：全部走变量，深色主题才能整体翻转 */
  --card-hover-bg: #fdfcfa;
  --card-hover-border: #cec9bd;
  --fill-soft: #eeece5;
  --fill-soft-hover: #e8e5dd;
  --fill-accent: #dce6f6;
  --rail-soft: #ded9cf;
  --rail-soft-hover: #a39d90;
  --primary-hover: #2a2a26;
  --scrim: rgba(20, 20, 18, .38);
  --shadow-modal: 0 18px 48px rgba(20, 20, 18, .22);
  --shadow-pop: 0 12px 32px rgba(20, 20, 18, .16);

  --font: "Geist", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; /* taste-skill-ignore */

  --fs-title: 24px;
  --fs-section: 16px;
  --fs-kpi: 30px;
  --fs-body: 14px;
  --fs-small: 12px;
  --fs-meta: 12px;   /* 原来散落各处的 11px，统一到 12px 以便中文在小字下也清楚 */

  --sidebar-width: 256px;
  --pad: 32px;
  --gap: 12px;
  --card-pad: 20px;
  --radius-card: 8px;
  --radius-control: 6px;
  --control-height: 32px;
  --row-height: 44px;
  --nav-row: 30px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --t-press: 120ms; --t-hover: 150ms; --t-ui: 200ms;
}

/* ---------- dark: 同一条纸感逻辑，换成墨底与提亮的索引卡 ---------- */
:root[data-theme="dark"] {
  --ground: #0e0e0f;
  --surface: #17171a;
  --raised: #1d1d20;
  --active: #26262a;
  --border: #2b2b30;
  --rule: #202024;
  --control: #3c3c42;

  --text: #f3f3f1;
  --muted: #a9a9a4;
  --faint: #8d8d88;

  --accent: #6c9ce8;
  --primary: #f3f3f1;
  --primary-ink: #0e0e0f;

  --positive: #4fbf86;
  --negative: #ef7070;
  --pill-neutral-bg: #26262a;
  --pill-neutral-ink: #e9e9e6;
  --grid: #2c2c30;

  --card-hover-bg: #1c1c20;
  --card-hover-border: #3d3d44;
  --fill-soft: #2a2a30;
  --fill-soft-hover: #2d2d33;
  --fill-accent: #1c2f4d;
  --rail-soft: #35353b;
  --rail-soft-hover: #5c5c64;
  --primary-hover: #dcdcd8;
  --scrim: rgba(0, 0, 0, .58);
  --shadow-modal: 0 18px 48px rgba(0, 0, 0, .55);
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, .45);

  color-scheme: dark;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.5;
}
h1, h2, h3, h4, p, figure, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg, video, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.num, table, .kpi-value, td.n { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100svh; }

.sidebar {
  position: sticky; top: 0; height: 100svh; display: flex; flex-direction: column;
  padding: 20px 12px 12px; border-right: 1px solid transparent; overflow: hidden;
}
.sidebar-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; }
.sidebar-scroll::-webkit-scrollbar { width: 8px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--control); border-radius: 4px; }

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 16px; }
.brand svg { width: 24px; height: 24px; flex: none; }
.brand-text { display: grid; line-height: 1.15; }
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.brand-sub { font-size: var(--fs-meta); color: var(--faint); letter-spacing: 0.02em; }

.scope {
  display: flex; align-items: center; gap: 8px; width: 100%; margin-bottom: 4px;
  padding: 7px 8px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border);
  font-size: var(--fs-small); color: var(--muted); text-align: left;
}
.scope .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text); flex: none; }
.scope b { color: var(--text); font-weight: 500; }

.group-label { margin: 18px 8px 5px; font-size: var(--fs-meta); color: var(--faint); }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: var(--nav-row); padding: 0 8px;
  border-radius: 6px; color: var(--muted);
  transition: background-color var(--t-hover) ease, color var(--t-hover) ease;
}
.nav-item svg { width: 16px; height: 16px; flex: none; stroke-width: 1.5; }
.nav-item .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .cnt { font-size: var(--fs-meta); color: var(--faint); font-variant-numeric: tabular-nums; }
.nav-item:hover { background: var(--raised); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--active); color: var(--text); }
.nav-item[aria-current="page"] .cnt { color: var(--muted); }
.nav-item .lock { color: var(--faint); }

.sidebar-foot { padding-top: 10px; display: grid; gap: 6px; border-top: 1px solid var(--border); margin-top: 10px; }
.foot-btn {
  display: flex; align-items: center; gap: 10px; height: var(--nav-row); padding: 0 8px;
  border: 0; background: none; border-radius: 6px; color: var(--muted); cursor: pointer; text-align: left;
}
.foot-btn:hover { background: var(--raised); color: var(--text); }
.foot-btn svg { width: 16px; height: 16px; stroke-width: 1.5; flex: none; }
.foot-btn .cnt { margin-left: auto; font-size: var(--fs-meta); color: var(--faint); }

.canvas { min-width: 0; padding: var(--pad); }
.main { min-width: 0; display: flex; flex-direction: column; }
/* 画布宽度分档：宽屏不把 1,000 张卡片挤在左边 1100px 里 */
.wrap { max-width: 1120px; margin-inline: auto; }
@media (min-width: 1500px) {
  :root { --fs-body: 15px; --fs-small: 13px; --fs-meta: 13px; --fs-title: 26px; --fs-kpi: 32px; }
  .wrap { max-width: 1340px; }
}
@media (min-width: 1800px) { .wrap { max-width: 1580px; } }
@media (min-width: 2200px) { .wrap { max-width: 1840px; } }

/* a stretched link keeps the whole card clickable without nesting a button in an anchor */
.bm-link { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.bm-acts, .bmline .acts { position: relative; z-index: 2; }
.bmline .bm-link { position: absolute; inset: 0; z-index: 1; }
.bmline { position: relative; }

/* ---------- title block ---------- */
.title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 4px; }
.title-row h1 { font-size: var(--fs-title); line-height: 1.25; font-weight: 600; letter-spacing: -0.012em; }
.title-row .sub { margin-top: 6px; color: var(--muted); font-size: var(--fs-body); }
.title-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.crumb { margin-bottom: 6px; min-height: 16px; font-size: var(--fs-small); color: var(--faint); display: flex; align-items: center; gap: 6px; }
.crumb a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- search ---------- */
.searchbar {
  display: flex; align-items: center; gap: 10px; height: 48px; margin: 20px 0;
  padding: 0 12px 0 14px; background: var(--surface); border: 1px solid var(--control);
  border-radius: var(--radius-card); transition: border-color var(--t-hover) ease;
}
.searchbar:focus-within { border-color: var(--text); }
.searchbar svg { width: 16px; height: 16px; flex: none; color: var(--faint); stroke-width: 1.5; }
.searchbar input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; outline: none; font-size: 15px; }
.searchbar input::placeholder { color: var(--faint); }
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.searchbar kbd {
  font: 12px/1 var(--font-mono); color: var(--faint); border: 1px solid var(--border); /* taste-skill-ignore */
  border-radius: 4px; padding: 4px 6px; background: var(--ground);
}
.searchbar .clear { border: 0; background: none; color: var(--faint); cursor: pointer; padding: 4px; display: none; }
.searchbar.has-value .clear { display: block; }

/* ---------- KPI strip (one container, hairlines, no tiles) ---------- */
.kpis {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  margin-bottom: 28px; overflow: hidden;
}
.kpi { padding: 14px 20px 16px; }
.kpi + .kpi { border-left: 1px solid var(--border); }
.kpi-label { color: var(--muted); font-size: var(--fs-small); }
.kpi-value { margin-top: 4px; font-size: var(--fs-kpi); line-height: 1.1; font-weight: 400; letter-spacing: -0.02em; }
.kpi-value small { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 4px; letter-spacing: 0; }
.kpi .note { margin-top: 2px; font-size: var(--fs-meta); color: var(--faint); }

/* ---------- sections ---------- */
.section { margin-bottom: 32px; }
.section-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.section-head h2 { font-size: var(--fs-section); font-weight: 600; line-height: 1.3; }
.section-head .meta { font-size: var(--fs-small); color: var(--faint); }
.section-head .spacer { flex: 1; }

.grid12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); align-items: start; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: var(--card-pad); min-width: 0;
}
.panel > header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.panel > header h2 { font-size: var(--fs-section); font-weight: 600; }
.panel > header .meta { font-size: var(--fs-small); color: var(--faint); }
.panel > header .spacer { flex: 1; }

.start-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.start-col { background: var(--raised); border-radius: var(--radius-control); padding: 16px; }
.start-col b { font-size: var(--fs-body); font-weight: 500; }
.start-col p { margin-top: 6px; font-size: var(--fs-small); line-height: 1.6; color: var(--muted); }

/* ---------- the themed share rail + index grid ---------- */
.rail { display: flex; gap: 2px; height: 12px; margin-bottom: 16px; }
.rail button {
  height: 100%; min-width: 4px; border: 0; padding: 0; background: var(--rail-soft);
  border-radius: 2px; cursor: pointer; transition: background-color var(--t-hover) ease;
}
.rail button:hover { background: var(--rail-soft-hover); }
.rail button[aria-current="true"], .rail button.is-peak { background: var(--accent); }

/* 16 个主题：4 列或 8 列都能整除，不让最后一行剩下孤零零一个 */
.catgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px 4px; }
@media (min-width: 1500px) { .catgrid { grid-template-columns: repeat(8, minmax(0, 1fr)); } }
/* the row itself is the bar: its fill runs as far as the theme's share of the library */
.cat {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 2px 8px;
  padding: 9px 8px 10px; border-radius: var(--radius-control);
  transition: background-color var(--t-hover) ease;
}
.cat-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--fill-soft); border-radius: 5px; }
.cat:hover .cat-fill { background: var(--fill-soft-hover); }
.cat[aria-current="page"] .cat-fill { background: var(--fill-accent); }
.cat-name { position: relative; font-size: var(--fs-body); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-cnt { position: relative; font-size: var(--fs-small); color: var(--faint); font-variant-numeric: tabular-nums; }

/* ---------- bookmark rows (inside panels) ---------- */
.rows { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; }
.brow {
  display: flex; align-items: center; gap: 10px; min-width: 0; overflow: hidden;
  min-height: 56px; padding: 8px 8px;
  margin: 0 -8px; border-radius: 6px; transition: background-color var(--t-hover) ease;
}
.brow:hover { background: var(--raised); }
.brow + .brow { border-top: 1px solid var(--rule); border-radius: 0; }
.brow + .brow:hover { border-radius: 6px; }
.brow-main { min-width: 0; flex: 1; overflow: hidden; }
.brow-title { display: block; font-size: var(--fs-body); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brow-host { display: block; font: 12px/16px var(--font-mono); color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } /* taste-skill-ignore */
.brow-time { font-size: var(--fs-meta); color: var(--faint); flex: none; }

/* ---------- favicon ---------- */
.fav {
  width: 20px; height: 20px; flex: none; border-radius: 4px; object-fit: contain;
  background: var(--raised);
}
.fav-letter {
  width: 20px; height: 20px; flex: none; border-radius: 4px; display: grid; place-items: center;
  background: var(--raised); color: var(--muted); font-size: var(--fs-meta); font-weight: 600; line-height: 1;
  text-transform: uppercase;
}
.fav-lg, .fav-lg .fav-letter { width: 28px; height: 28px; border-radius: 6px; }
.fav-lg .fav-letter { font-size: 13px; }

/* ---------- bookmark card grid (the index card) ---------- */
.bmgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(224px, 1fr)); gap: var(--gap); }
.bm {
  position: relative; display: grid; grid-template-columns: 20px minmax(0, 1fr);
  grid-template-rows: min-content min-content 1fr; gap: 1px 10px; align-content: start;
  padding: 14px 12px 12px; min-height: 96px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  transition: border-color var(--t-hover) ease, background-color var(--t-hover) ease;
}
.bm:hover { border-color: var(--card-hover-border); background: var(--card-hover-bg); }
.bm:active { transform: translateY(1px); }
.bm .fav, .bm .fav-letter { margin-top: 1px; }
.bm-title {
  font-size: var(--fs-body); font-weight: 500; line-height: 1.35; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  word-break: break-word;
}
.bm-host {
  grid-column: 2; font: 12px/16px var(--font-mono); color: var(--faint); /* taste-skill-ignore */
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px;
}
.bm-tags { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; min-height: 18px; align-self: end; }
.tag {
  display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 4px;
  background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); font-size: var(--fs-meta); line-height: 1;
  white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.bm-acts { position: absolute; top: 8px; right: 8px; display: flex; gap: 2px; opacity: 0; transition: opacity var(--t-hover) ease; }
.bm:hover .bm-acts, .bm:focus-within .bm-acts, .bm[data-pinned="1"] .bm-acts { opacity: 1; }
.icon-btn {
  display: grid; place-items: center; width: 26px; height: 26px; border: 0; border-radius: 5px;
  background: var(--surface); color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--active); color: var(--text); }
.icon-btn svg { width: 14px; height: 14px; stroke-width: 1.6; }
.icon-btn[aria-pressed="true"] { color: var(--text); }
.icon-btn[aria-pressed="true"] svg { fill: var(--text); }

/* the list layout of the same data */
.bmlist { display: grid; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); overflow: hidden; }
.bmhead {
  display: grid; grid-template-columns: 20px minmax(0, 2.2fr) minmax(0, 1fr) 88px 26px;
  gap: 12px; align-items: center; height: 34px; padding: 0 14px;
  border-bottom: 1px solid var(--border); font-size: var(--fs-small); color: var(--muted);
}
.bmline {
  position: relative;
  display: grid; grid-template-columns: 20px minmax(0, 2.2fr) minmax(0, 1fr) 88px 26px;
  align-items: center; gap: 12px; min-height: 44px; padding: 0 14px;
  transition: background-color var(--t-hover) ease;
}
.bmline + .bmline { border-top: 1px solid var(--rule); }
.bmline:hover { background: var(--raised); }
.bmline .t { font-size: var(--fs-body); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bmline .h { font: 12px/16px var(--font-mono); color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } /* taste-skill-ignore */
.bmline .c { font-size: var(--fs-meta); color: var(--faint); white-space: nowrap; }
.bmline .acts { display: flex; gap: 2px; opacity: 0; }
.bmline:hover .acts, .bmline:focus-within .acts, .bmline[data-pinned="1"] .acts { opacity: 1; }

/* ---------- filter bar ---------- */
.filterbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filterbar .spacer { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  color: var(--muted); font-size: var(--fs-small); cursor: pointer;
  transition: border-color var(--t-hover) ease, color var(--t-hover) ease, background-color var(--t-hover) ease;
}
.chip:hover { border-color: var(--control); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--primary-ink); }
.chip .x { font-size: 13px; line-height: 1; opacity: .7; }
.chip .n { opacity: .65; font-variant-numeric: tabular-nums; }

.select {
  height: 28px; padding: 0 24px 0 10px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%236f6c65' stroke-width='1.3' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 9px center / 11px;
  appearance: none; font-size: var(--fs-small); color: var(--muted); cursor: pointer;
}
.select:hover { color: var(--text); border-color: var(--control); }

.segmented { display: inline-flex; padding: 2px; border-radius: 999px; background: var(--raised); }
.segmented button {
  height: 24px; padding: 0 10px; border: 0; border-radius: 999px; background: transparent;
  color: var(--muted); font-size: var(--fs-small); cursor: pointer; display: flex; align-items: center; gap: 5px;
}
.segmented button svg { width: 13px; height: 13px; stroke-width: 1.6; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: var(--control-height); padding: 0 12px; border-radius: var(--radius-control);
  border: 1px solid var(--control); background: var(--surface); font-weight: 500; font-size: var(--fs-body);
  cursor: pointer; transition: background-color var(--t-hover) ease, border-color var(--t-hover) ease, transform var(--t-press) var(--ease-out);
}
.btn:hover { background: var(--raised); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 14px; height: 14px; stroke-width: 1.6; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--raised); color: var(--text); }
.btn.sm { height: 26px; padding: 0 9px; font-size: var(--fs-small); }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- empty & loading ---------- */
.empty {
  grid-column: 1 / -1; display: grid; place-items: center; gap: 4px; min-height: 56px;
  padding: 8px 16px; border: 1px dashed var(--control); border-radius: var(--radius-control);
  color: var(--muted); text-align: center;
}
.empty b { font-weight: 500; color: var(--text); }
.empty span { font-size: var(--fs-small); color: var(--faint); }
.empty-tips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }

/* ---------- command launcher ---------- */
.cmdk { position: fixed; inset: 0; z-index: 60; display: none; }
.cmdk[open="true"] { display: block; }
.cmdk-backdrop { position: absolute; inset: 0; background: var(--scrim); }
.cmdk-panel {
  position: relative; width: min(680px, calc(100vw - 32px)); margin: 10vh auto 0;
  background: var(--surface); border-radius: 10px; border: 1px solid var(--border);
  box-shadow: var(--shadow-modal); overflow: hidden; /* taste-skill-ignore */
}
.cmdk-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; height: 54px; border-bottom: 1px solid var(--border); }
.cmdk-input svg { width: 16px; height: 16px; color: var(--faint); stroke-width: 1.5; flex: none; }
.cmdk-input input { flex: 1; min-width: 0; border: 0; outline: none; background: none; font-size: 16px; }
.cmdk-list { max-height: min(52vh, 420px); overflow-y: auto; padding: 6px; }
.cmdk-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 6px; cursor: pointer;
}
.cmdk-item[aria-selected="true"] { background: var(--active); }
.cmdk-item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-body); }
.cmdk-item .h { font: 12px/16px var(--font-mono); color: var(--faint); flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } /* taste-skill-ignore */
.cmdk-item .c { font-size: var(--fs-meta); color: var(--faint); flex: none; }
.cmdk-foot {
  display: flex; align-items: center; gap: 14px; padding: 8px 16px; border-top: 1px solid var(--border);
  font-size: var(--fs-meta); color: var(--faint);
}
.cmdk-foot kbd { font: 12px/1 var(--font-mono); border: 1px solid var(--border); border-radius: 3px; padding: 3px 5px; } /* taste-skill-ignore */

/* ---------- popover (tags & row actions) ---------- */
.pop {
  position: absolute; z-index: 40; width: 268px; padding: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-pop); /* taste-skill-ignore */
}
.pop h3 { font-size: var(--fs-small); font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.pop .taglist { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; min-height: 18px; }
.pop .taglist .tag { cursor: pointer; }
.pop .taglist .tag:hover { background: var(--active); }
.pop input[type="text"] {
  width: 100%; height: 30px; padding: 0 9px; border: 1px solid var(--control);
  border-radius: 5px; background: var(--surface); font-size: var(--fs-small); outline: none;
}
.pop input[type="text"]:focus { border-color: var(--text); }
.pop .suggest { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.pop .suggest .tag { background: transparent; border: 1px dashed var(--control); color: var(--muted); cursor: pointer; }
.pop .pop-actions { display: flex; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--rule); }
.link-btn { border: 0; background: none; padding: 0; color: var(--muted); font-size: var(--fs-small); cursor: pointer; }
.link-btn:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.link-btn.danger:hover { color: var(--negative); }

/* ---------- settings ---------- */
.setting { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 24px; padding: 24px 0; border-top: 1px solid var(--border); }
.setting:first-of-type { border-top: 0; padding-top: 0; }
.setting .label h2 { font-size: var(--fs-section); font-weight: 600; }
.setting .label p { margin-top: 6px; color: var(--muted); font-size: var(--fs-small); line-height: 1.55; }
.setting .body { min-width: 0; }
.setting .body > .panel { background: var(--raised); border-color: transparent; border-radius: 12px; }

.dropzone {
  display: grid; place-items: center; gap: 6px; padding: 28px 20px; text-align: center;
  border: 1px dashed var(--control); border-radius: 8px; background: var(--surface); cursor: pointer;
  transition: border-color var(--t-hover) ease, background-color var(--t-hover) ease;
}
.dropzone:hover, .dropzone.over { border-color: var(--text); background: var(--card-hover-bg); }
.dropzone b { font-weight: 500; }
.dropzone span { font-size: var(--fs-small); color: var(--faint); }

.stat-table { width: 100%; border-collapse: collapse; }
.stat-table td { padding: 8px 0; font-size: var(--fs-body); vertical-align: baseline; }
.stat-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.stat-table tr + tr td { border-top: 1px solid var(--rule); }
.stat-table .k { color: var(--muted); }

.tagmanage { max-height: 420px; overflow-y: auto; }
.tagrow { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 4px; }
.tagrow + .tagrow { border-top: 1px solid var(--rule); }
.tagrow .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tagrow .n { font-size: var(--fs-small); color: var(--faint); font-variant-numeric: tabular-nums; }

.dupe { display: grid; gap: 4px; padding: 10px 0; }
.dupe + .dupe { border-top: 1px solid var(--rule); }
.dupe .dupe-line { display: flex; align-items: center; gap: 8px; font-size: var(--fs-small); color: var(--muted); }
.dupe .dupe-line .t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dupe .dupe-line .h { font-family: var(--font-mono); color: var(--faint); flex: none; } /* taste-skill-ignore */

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px);
  padding: 9px 14px; background: var(--text); color: var(--primary-ink);
  border-radius: 8px; font-size: var(--fs-small); opacity: 0; pointer-events: none;
  transition: opacity var(--t-ui) ease, transform var(--t-ui) var(--ease-out); z-index: 70;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- lock screen (access gate) ---------- */
body[data-locked="true"] .app { display: none; }
body[data-locked="true"] .cmdk { display: none !important; }

.lock {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  padding: 24px; background: var(--ground); overflow-y: auto;
}
.lock[hidden] { display: none; }
.lock-card {
  width: min(420px, 100%); padding: 28px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
.lock-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; }
.lock-brand svg { width: 26px; height: 26px; flex: none; color: var(--text); }
.lock-brand-text { display: grid; line-height: 1.15; }
.lock-brand-name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.lock-brand-sub { font-size: var(--fs-meta); color: var(--faint); letter-spacing: 0.02em; }

.lock-title { font-size: 22px; line-height: 1.3; font-weight: 600; letter-spacing: -0.012em; }
.lock-desc { margin-top: 8px; font-size: var(--fs-small); line-height: 1.65; color: var(--muted); }

.lock-form { margin-top: 22px; display: grid; gap: 8px; }
.lock-form label { font-size: var(--fs-small); font-weight: 500; color: var(--muted); }
.lock-input { position: relative; display: flex; }
.lock-form input {
  flex: 1; height: 40px; padding: 0 40px 0 12px; border: 1px solid var(--control); border-radius: var(--radius-control);
  background: var(--surface); font-size: 15px; letter-spacing: 0.08em; outline: none;
  transition: border-color var(--t-hover) ease;
}
.lock-form input:focus { border-color: var(--text); }
.lock-form input:disabled { background: var(--raised); color: var(--muted); }
.pw-eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; display: grid; place-items: center;
  border: 0; border-radius: 5px; background: none; color: var(--faint); cursor: pointer;
}
.pw-eye:hover { background: var(--raised); color: var(--text); }
.pw-eye svg { width: 17px; height: 17px; }
.pw-eye[aria-pressed="true"] { color: var(--text); }
.lock-btn { height: 40px; margin-top: 4px; width: 100%; }
.lock-btn:disabled { opacity: .55; }

.lock-msg { margin-top: 10px; min-height: 18px; font-size: var(--fs-small); line-height: 1.55; color: var(--muted); white-space: pre-line; }
.lock-msg[data-kind="error"] { color: var(--negative); }
.lock-msg[data-kind="warn"] { color: var(--muted); font-variant-numeric: tabular-nums; }

/* 环境自检：三格状态，出问题时变成可读的诊断而不是“密码不对” */
.lock-env { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 12px; font-size: var(--fs-meta); color: var(--faint); }
.lock-env span { display: inline-flex; align-items: center; gap: 4px; }
.lock-env b { font-weight: 500; color: var(--muted); }
.lock-env .bad { color: var(--negative); }
.lock-env .bad b { color: var(--negative); }
.lock-env-note { margin-top: 8px; font-size: var(--fs-small); line-height: 1.6; color: var(--negative); }

.lock-meta {
  display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 20px; padding-top: 14px;
  border-top: 1px solid var(--rule); font-size: var(--fs-meta); color: var(--faint);
}
.lock-forgot { margin-top: 12px; font-size: var(--fs-small); }

@keyframes lock-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}
.lock-card.shake { animation: lock-shake 320ms cubic-bezier(0.36, 0.07, 0.19, 0.97); }

/* ---------- phone ---------- */
.mobilebar { display: none; }
@media (max-width: 1100px) {
  .bmgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .catgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 880px) {
  :root { --pad: 16px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0; width: 100%; height: 100svh; z-index: 50;
    background: var(--surface); transform: translateX(-100%);
    transition: transform var(--t-ui) var(--ease-out); padding: 16px 16px 20px;
  }
  .sidebar.open { transform: none; }
  .mobilebar {
    display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 var(--pad);
    border-bottom: 1px solid var(--border); background: var(--ground);
    position: sticky; top: 0; z-index: 30;
  }
  .mobilebar .mtitle { font-size: 15px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobilebar .mb-btn { width: 36px; height: 36px; display: grid; place-items: center; border: 0; background: none; border-radius: 6px; }
  .mobilebar .mb-btn svg { width: 18px; height: 18px; stroke-width: 1.6; }
  .canvas { padding: 16px; }
  .kpis { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi + .kpi { border-left: 0; }
  .kpi:nth-child(2n) { border-left: 1px solid var(--border); }
  .kpi:nth-child(n + 3) { border-top: 1px solid var(--border); }
  .bmgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .catgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; }
  .grid12 { grid-template-columns: minmax(0, 1fr); }
  .grid12 > * { grid-column: 1 / -1 !important; }
  .bmline { grid-template-columns: 20px minmax(0, 1fr) auto 26px; }
  .bmline .h { display: none; }
  .bmline .c { display: none; }
  .setting { grid-template-columns: 1fr; gap: 12px; padding: 20px 0; }
  .searchbar kbd { display: none; }
  .title-row { flex-wrap: wrap; }
  .bm-acts { opacity: 1; }
  .sidebar-foot { border-top: 0; }
}
@media (max-width: 560px) {
  .bmgrid { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  .kpi-value { font-size: 26px; }
  .title-row h1 { font-size: 21px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation: none !important; }
}

/* 品牌标记内折：跟随底色，浅/深主题自动适配 */
.brand-cut { fill: var(--ground); }

/* 主题切换按钮（侧栏品牌行右侧） */
.theme-btn {
  margin-left: auto; flex: none; width: 28px; height: 28px;
  display: grid; place-items: center; padding: 0;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--muted); cursor: pointer;
  transition: color var(--t-hover) ease, border-color var(--t-hover) ease;
}
.theme-btn:hover { color: var(--text); border-color: var(--control); }
.theme-btn svg { width: 15px; height: 15px; stroke-width: 1.5; }

:root[data-theme="dark"] .sidebar { border-right: 1px solid var(--border); }

/* 说明文字不要被拉成一行两百字 */
.start-col p { max-width: 56ch; }
