/* =============================================================
   我的书签 · 样式表
   - 原生 CSS，无构建、无 CDN、无外部字体/图标库
   - 颜色/圆角/阴影统一走 CSS 变量，[data-theme] 切换深浅色
   - 移动端优先，桌面端网格自适应 3~5 列
   ============================================================= */

/* ---------- 1. 设计变量 ---------- */
:root {
  color-scheme: light;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #f5f6f9;
  --bg-glow-1: rgba(99, 102, 241, 0.10);
  --bg-glow-2: rgba(34, 211, 238, 0.08);
  --surface: #ffffff;
  --surface-2: #fbfbfe;
  --surface-hover: #f7f7fc;
  --surface-sunken: #eef0f5;
  --border: #e5e7ee;
  --border-strong: #d5d9e4;

  --text: #15171c;
  --text-soft: #414652;
  --muted: #737a89;
  --faint: #9aa1b0;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: rgba(79, 70, 229, 0.10);
  --accent-line: rgba(79, 70, 229, 0.35);
  --on-accent: #ffffff;

  --danger: #d92d20;
  --danger-hover: #b42318;
  --danger-soft: rgba(217, 45, 32, 0.10);
  --on-danger: #ffffff;

  --star: #f5a524;
  --star-soft: rgba(245, 165, 36, 0.14);
  --success: #12915b;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 8px 20px -10px rgba(16, 24, 40, 0.18), 0 2px 6px -2px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 28px 60px -20px rgba(16, 24, 40, 0.30), 0 8px 20px -12px rgba(16, 24, 40, 0.14);

  --radius-xs: 7px;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --header-h: 60px;
  --sidebar-w: 236px;
  --page-max: 1560px;

  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  --dur: 150ms;

  --ring: 0 0 0 3px var(--accent-soft);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0c0e12;
  --bg-glow-1: rgba(99, 102, 241, 0.16);
  --bg-glow-2: rgba(34, 211, 238, 0.07);
  --surface: #14171d;
  --surface-2: #171a21;
  --surface-hover: #1b1f27;
  --surface-sunken: #0f1217;
  --border: #262b34;
  --border-strong: #38404d;

  --text: #edf0f5;
  --text-soft: #c4cad6;
  --muted: #8d95a4;
  --faint: #6c7484;

  --accent: #8b8cf7;
  --accent-hover: #a5a6ff;
  --accent-soft: rgba(139, 140, 247, 0.16);
  --accent-line: rgba(139, 140, 247, 0.45);
  --on-accent: #10121a;

  --danger: #ff7b72;
  --danger-hover: #ff9b94;
  --danger-soft: rgba(255, 123, 114, 0.14);
  --on-danger: #1a0f0e;

  --star: #f7c948;
  --star-soft: rgba(247, 201, 72, 0.16);
  --success: #4ade80;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 10px 24px -12px rgba(0, 0, 0, 0.75), 0 2px 6px -2px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 32px 70px -24px rgba(0, 0, 0, 0.85), 0 10px 24px -14px rgba(0, 0, 0, 0.6);

  --ring: 0 0 0 3px rgba(139, 140, 247, 0.22);
}

/* ---------- 2. 基础 ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 420px at 12% -8%, var(--bg-glow-1), transparent 70%),
    radial-gradient(760px 360px at 92% 0%, var(--bg-glow-2), transparent 68%);
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body.no-scroll {
  overflow: hidden;
}

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

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

img,
svg {
  display: block;
}

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

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

[hidden] {
  display: none !important;
}

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

/* 滚动条 */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--faint);
  background-clip: content-box;
}

/* ---------- 3. 通用控件 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 13px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 550;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease),
    color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.btn:active {
  transform: translateY(0.5px);
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-soft);
  box-shadow: var(--shadow-sm);
}
.btn-ghost:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-quiet {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}
.btn-quiet:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.btn-danger {
  background: var(--danger);
  color: var(--on-danger);
  box-shadow: var(--shadow-sm);
}
.btn-danger:hover {
  background: var(--danger-hover);
}

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

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 13px;
  border-radius: var(--radius-xs);
}

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-xs);
  color: var(--muted);
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}
.icon-btn:hover {
  background: var(--surface-sunken);
  color: var(--text);
}
.icon-btn.is-on {
  color: var(--star);
  background: var(--star-soft);
}
.icon-btn.is-on:hover {
  color: var(--star);
  background: var(--star-soft);
}
.icon-btn.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.theme-icon {
  display: inline-flex;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1;
  color: var(--muted);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
}

/* 输入框 */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.field-label .opt {
  font-weight: 500;
  color: var(--faint);
  font-size: 12px;
}

.input,
.textarea {
  width: 100%;
  padding: 9px 12px;
  font-size: 14.5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
    background-color var(--dur) var(--ease);
}
.input::placeholder,
.textarea::placeholder {
  color: var(--faint);
}
.input:hover,
.textarea:hover {
  border-color: var(--border-strong);
}
.input:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.input.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}
.textarea {
  resize: vertical;
  min-height: 84px;
  line-height: 1.5;
}

.hint {
  font-size: 12.5px;
  color: var(--faint);
  line-height: 1.45;
}

/* ---------- 4. 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: var(--page-max);
  height: var(--header-h);
  margin: 0 auto;
  padding: 0 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
  border-radius: var(--radius-sm);
  padding: 3px 2px;
}
.brand svg {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  box-shadow: 0 5px 14px -6px rgba(79, 70, 229, 0.65);
}
.brand-name {
  font-size: 15.5px;
  font-weight: 680;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* 搜索框 */
.search {
  position: relative;
  flex: 1 1 auto;
  max-width: 560px;
  min-width: 140px;
  display: flex;
  align-items: center;
}
.search > .icon {
  position: absolute;
  left: 12px;
  color: var(--faint);
  pointer-events: none;
  transition: color var(--dur) var(--ease);
}
.search-input {
  width: 100%;
  height: 38px;
  padding: 0 72px 0 37px;
  font-size: 14.5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
    background-color var(--dur) var(--ease);
}
.search-input::placeholder {
  color: var(--faint);
}
.search-input:hover {
  border-color: var(--border-strong);
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring), var(--shadow-sm);
}
.search:focus-within > .icon {
  color: var(--accent);
}
.search-clear {
  position: absolute;
  right: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-sunken);
}
.search-clear:hover {
  color: var(--text);
  background: var(--border-strong);
}
.search-kbd {
  position: absolute;
  right: 10px;
  pointer-events: none;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--faint);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  line-height: 1.5;
}
.search:focus-within .search-kbd {
  opacity: 0;
}

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

/* 排序下拉 */
.select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.select-wrap > .icon {
  position: absolute;
  right: 8px;
  pointer-events: none;
  color: var(--muted);
}
.select {
  appearance: none;
  -webkit-appearance: none;
  height: 36px;
  padding: 0 28px 0 11px;
  font-size: 13.5px;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.select:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

/* 账户 */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 650;
  color: var(--on-accent);
  background: linear-gradient(135deg, var(--accent), #22d3ee);
  border: 1px solid color-mix(in srgb, var(--accent) 60%, #ffffff);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.avatar:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px -6px rgba(79, 70, 229, 0.7);
}

.user-wrap {
  position: relative;
}
.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 208px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 60;
}
.user-menu-head {
  padding: 8px 10px 9px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 5px;
}
.user-menu-name {
  font-weight: 620;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.badge-owner {
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
}
.user-menu-sub {
  font-size: 12px;
  color: var(--faint);
  margin-top: 2px;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  font-size: 13.5px;
  color: var(--text-soft);
  text-align: left;
}
.menu-item:hover {
  background: var(--surface-sunken);
  color: var(--text);
}
.menu-item.is-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------- 4.5 离线提示细条（v1.2） ---------- */
.offline-bar {
  position: sticky;
  top: var(--topbar-bottom, var(--header-h));
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 5px 14px;
  font-size: 12.5px;
  font-weight: 550;
  letter-spacing: 0.01em;
  color: color-mix(in srgb, var(--star) 45%, var(--text));
  background: color-mix(in srgb, var(--star) 13%, var(--surface));
  border-bottom: 1px solid color-mix(in srgb, var(--star) 32%, var(--border));
  backdrop-filter: saturate(160%) blur(8px);
  -webkit-backdrop-filter: saturate(160%) blur(8px);
}
.offline-bar .icon {
  flex: 0 0 auto;
}

/* ---------- 5. 页面骨架 ---------- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 26px;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 22px 24px 64px;
  align-items: start;
}

/* ---------- 6. 侧栏 ---------- */
.sidebar {
  position: sticky;
  top: calc(var(--header-h) + 22px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-height: calc(100dvh - var(--header-h) - 46px);
  overflow-y: auto;
  padding-right: 2px;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.side-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 520;
  color: var(--text-soft);
  text-align: left;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.side-item > .icon {
  color: var(--faint);
  flex: 0 0 auto;
  transition: color var(--dur) var(--ease);
}
.side-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.side-item:hover > .icon {
  color: var(--muted);
}
.side-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 620;
}
.side-item.is-active > .icon {
  color: var(--accent);
}
.side-item .count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 550;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.side-item.is-active .count {
  color: var(--accent);
}

.side-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}
.side-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}
.side-heading .count {
  letter-spacing: 0;
  font-weight: 550;
  text-transform: none;
}

.tag-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
  max-height: 46vh;
}

.tag-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text-soft);
  text-align: left;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tag-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.tag-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.tag-item .hash {
  color: var(--faint);
  font-weight: 600;
}
.tag-item.is-active .hash {
  color: var(--accent);
}
.tag-item .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.tag-item .count {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.side-empty {
  padding: 4px 10px 8px;
  font-size: 12.5px;
  color: var(--faint);
  line-height: 1.5;
}

.side-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.side-foot-row {
  display: flex;
  gap: 6px;
}
.side-foot-row .btn {
  flex: 1 1 0;
  min-width: 0;
}
.stats-line {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 0 2px;
  font-size: 12px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.stats-line b {
  color: var(--muted);
  font-weight: 620;
}

/* ---------- 6.5 分组（v1.3） ---------- */
/* 分组区标题：标题 + 计数靠左，折叠按钮靠右 */
#group-block .side-heading {
  justify-content: flex-start;
  gap: 6px;
}
#group-block .side-heading .count {
  margin-left: 0;
}
.side-collapse {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  color: var(--faint);
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.side-collapse:hover {
  background: var(--surface-sunken);
  color: var(--text);
}
#group-block.is-collapsed .side-collapse svg {
  transform: rotate(-90deg);
}
#group-block.is-collapsed .side-collapse svg {
  transition: transform var(--dur) var(--ease);
}

.group-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 40vh;
  overflow-y: auto;
}
.group-row {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  transition: background-color var(--dur) var(--ease);
}
.group-row:hover {
  background: var(--surface-hover);
}
.group-row.is-active {
  background: var(--accent-soft);
}
.group-item {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  padding: 6px 4px 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text-soft);
  text-align: left;
}
.group-item > .icon {
  flex: 0 0 auto;
  color: var(--faint);
}
.group-row.is-active .group-item {
  color: var(--accent);
  font-weight: 600;
}
.group-row.is-active .group-item > .icon {
  color: var(--accent);
}
.group-item .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.group-item .count {
  margin-left: auto;
  font-size: 12px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.group-row.is-active .group-item .count {
  color: var(--accent);
}
.group-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-right: 2px;
  border-radius: 6px;
  color: var(--faint);
  opacity: 0;
  transition: opacity var(--dur) var(--ease), background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.group-row:hover .group-more,
.group-row:focus-within .group-more,
.group-more:focus-visible {
  opacity: 1;
}
.group-more:hover {
  background: var(--surface-sunken);
  color: var(--text);
}
@media (hover: none) {
  .group-more {
    opacity: 0.7;
  }
}
.group-row-ungrouped .group-item {
  color: var(--muted);
}

/* 卡片上的分组徽章 */
.chip-group {
  gap: 4px;
  color: var(--accent);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 24%, transparent);
  max-width: 140px;
}
.chip-group:hover {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent);
}
.chip-group .chip-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 结果栏里的多个筛选 pill */
.filter-pills {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.filter-clear-all {
  font-size: 12.5px;
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 999px;
}
.filter-clear-all:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

/* 小弹层（分组 ⋯ 菜单 / 移到分组） */
.popover {
  position: fixed;
  z-index: 240;
  min-width: 184px;
  max-width: 260px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: dialog-in 140ms var(--ease);
}
.popover[hidden] {
  display: none;
}
.popover-head {
  padding: 6px 9px 7px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--faint);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.popover-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 9px;
  border-radius: var(--radius-xs);
  font-size: 13.5px;
  color: var(--text-soft);
  text-align: left;
}
.popover-item:hover,
.popover-item:focus-visible {
  background: var(--surface-sunken);
  color: var(--text);
  outline: none;
}
.popover-item.is-danger:hover,
.popover-item.is-danger:focus-visible {
  background: var(--danger-soft);
  color: var(--danger);
}
.popover-item.is-checked {
  color: var(--accent);
  font-weight: 600;
}
.popover-item.is-checked .popover-label {
  color: var(--accent);
}
.popover-item > .icon:last-child {
  margin-left: auto;
}
.popover-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.popover-icon-space {
  width: 14px;
  flex: 0 0 auto;
}
.popover-sep {
  height: 1px;
  margin: 4px 6px;
  background: var(--border);
}

/* 移动端：分组区与标签一样横向胶囊化 */
@media (max-width: 900px) {
  .group-list {
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    max-height: none;
    scrollbar-width: none;
  }
  .group-list::-webkit-scrollbar {
    display: none;
  }
  .group-list[hidden] {
    display: none;
  }
  .group-row {
    flex: 0 0 auto;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 999px;
    overflow: hidden;
  }
  .group-row.is-active {
    border-color: var(--accent-line);
  }
  .group-item {
    padding: 5px 4px 5px 11px;
    white-space: nowrap;
    font-size: 12.5px;
  }
  .group-more {
    opacity: 0.75;
    margin-right: 0;
  }
  .popover {
    min-width: 200px;
  }
}

/* ---------- 7. 主区 ---------- */
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.results-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 30px;
  flex-wrap: wrap;
}
.results-count {
  font-size: 13.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.results-count b {
  color: var(--text);
  font-weight: 650;
}
.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 280px;
  height: 24px;
  padding: 0 4px 0 9px;
  font-size: 12.5px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 999px;
}
.filter-pill .label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.filter-pill button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 999px;
  color: var(--accent);
}
.filter-pill button:hover {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
}
.results-hint {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--faint);
  white-space: nowrap;
}
.results-hint kbd {
  margin: 0 1px;
}

/* 网格 */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  align-items: stretch;
}

/* ---------- 8. 书签卡片 ---------- */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  padding: 13px 13px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
    border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  background: var(--surface-2);
}
.card:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring), var(--shadow-md);
}
.card.is-selected {
  border-color: var(--accent);
  box-shadow: var(--ring), var(--shadow-md);
}
.card.is-selected::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

.card-head {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-width: 0;
}

.favicon {
  position: relative;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: hsl(var(--h, 220) 62% 88%);
  color: hsl(var(--h, 220) 45% 30%);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  user-select: none;
  transition: transform var(--dur) var(--ease);
}
.card:hover .favicon {
  transform: scale(1.04);
}
.favicon-letter {
  transition: opacity 120ms var(--ease);
}
.favicon img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 4px;
  object-fit: contain;
  background: var(--surface);
  opacity: 0;
  transition: opacity 160ms var(--ease);
}
.favicon.has-img img {
  opacity: 1;
}
.favicon.has-img .favicon-letter {
  opacity: 0;
}
:root[data-theme="dark"] .favicon {
  background: hsl(var(--h, 220) 34% 24%);
  color: hsl(var(--h, 220) 72% 82%);
}

.card-title-wrap {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-top: 1px;
}
.card-title {
  display: block;
  font-size: 14.5px;
  font-weight: 620;
  line-height: 1.35;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 4px;
  transition: color var(--dur) var(--ease);
}
.card:hover .card-title {
  color: var(--accent);
}
.card-domain {
  display: block;
  font-size: 12px;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  letter-spacing: -0.01em;
}

.star-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin: -2px -3px 0 0;
  border-radius: var(--radius-xs);
  color: var(--faint);
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}
.star-btn:hover {
  color: var(--star);
  background: var(--star-soft);
  transform: scale(1.08);
}
.star-btn.is-on {
  color: var(--star);
}
.star-btn.is-on svg {
  fill: currentColor;
  stroke: none;
}

.card-desc {
  font-size: 12.8px;
  line-height: 1.5;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.card-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 3px;
  min-height: 26px;
}
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
  max-height: 22px;
}
.chip {
  display: inline-flex;
  align-items: center;
  max-width: 112px;
  height: 20px;
  padding: 0 7px;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1;
  color: var(--text-soft);
  background: var(--surface-sunken);
  border: 1px solid transparent;
  border-radius: 999px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.chip:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 1px;
  margin-left: auto;
  opacity: 0.42;
  transition: opacity var(--dur) var(--ease);
}
@media (hover: none) {
  .card-actions {
    opacity: 0.8;
  }
}
.card:hover .card-actions,
.card:focus-within .card-actions {
  opacity: 1;
}
.card-actions .icon-btn {
  width: 26px;
  height: 26px;
}

/* ---------- 8.5 拖拽排序（v1.4，Pointer Events） ---------- */
.drag-handle {
  cursor: grab;
  /* 只有手柄能起拖：在手柄上禁用浏览器手势，避免和「滚动页面 / 点开链接」抢 */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.drag-handle:active,
.drag-handle.is-grabbing {
  cursor: grabbing;
  color: var(--accent);
  background: var(--accent-soft);
}
.drag-handle svg {
  pointer-events: none;
}

/* 被拖的卡片：fixed 浮层跟手 */
.card.is-ghost {
  position: fixed;
  z-index: 400;
  margin: 0;
  pointer-events: none;
  transition: none !important;
  box-shadow: var(--shadow-lg);
  border-color: var(--accent-line);
  background: var(--surface);
  opacity: 0.98;
  will-change: transform;
}

/* 原位虚线占位 */
.drag-placeholder {
  min-height: 96px;
  border: 1.5px dashed var(--accent-line);
  border-radius: var(--radius);
  background: var(--accent-soft);
  transition: height 120ms var(--ease);
}

/* 键盘拖拽模式：被“拿起”的卡片让位给占位块 */
.card.is-kbd-hidden {
  display: none;
}

/* 拖拽期间禁滚动/选择 */
body.is-dragging {
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: contain;
}
body.is-dragging,
body.is-dragging * {
  cursor: grabbing !important;
}

/* 拖到侧栏分组行 */
.group-row.is-drop-target {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: var(--accent-soft);
}
.group-row.is-drop-target .group-item {
  color: var(--accent);
  font-weight: 650;
}
.group-row.is-drop-target .group-item .count {
  color: var(--accent);
}

/* 触屏：手柄/操作按钮给足触摸目标 */
@media (pointer: coarse) {
  .card-actions {
    gap: 2px;
  }
  .card-actions .icon-btn {
    width: 30px;
    height: 30px;
  }
  .drag-handle {
    width: 32px;
    height: 30px;
  }
}

/* ---------- 9. 空状态 / 骨架 ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 64px 24px 72px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
}
.empty-mark {
  width: 58px;
  height: 58px;
  border-radius: 17px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  margin-bottom: 2px;
}
.empty h2 {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
  max-width: 100%;
}
.empty p {
  max-width: 380px;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.6;
}
.quick-add {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 460px;
  margin-top: 12px;
}
.quick-add .input {
  flex: 1 1 auto;
  height: 38px;
}
.empty-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 4px;
}
.empty-kbd {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--faint);
  margin-top: 8px;
}

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.skeleton {
  height: 132px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(
      100deg,
      var(--surface) 30%,
      var(--surface-hover) 50%,
      var(--surface) 70%
    )
    var(--surface);
  background-size: 220% 100%;
  animation: shimmer 1.4s var(--ease) infinite;
}
@keyframes shimmer {
  from {
    background-position: 180% 0;
  }
  to {
    background-position: -40% 0;
  }
}

/* ---------- 10. Toast ---------- */
.toast-host {
  position: fixed;
  /* 顶栏实际底边（app.js 会写入 --topbar-bottom）+ 20px 间距：
     保证 toast 永远在顶栏下方，不会压住排序/添加/主题/头像等可点区域 */
  top: calc(var(--topbar-bottom, var(--header-h)) + 20px);
  right: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 9px 13px;
  font-size: 13.5px;
  font-weight: 520;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  animation: toast-in 220ms var(--ease);
  pointer-events: auto;
}
.toast .icon {
  flex: 0 0 auto;
}
.toast.is-success .icon {
  color: var(--success);
}
.toast.is-error .icon {
  color: var(--danger);
}
.toast.is-error {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
}
.toast.is-info .icon {
  color: var(--accent);
}
.toast.is-leaving {
  animation: toast-out 180ms var(--ease) forwards;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
}

/* ---------- 11. 弹窗 ---------- */
.dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: min(88dvh, 780px);
  padding: 0;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.dialog::backdrop {
  background: rgba(9, 11, 16, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.dialog[open] {
  animation: dialog-in 200ms var(--ease);
}
@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.dialog.is-narrow {
  width: min(420px, calc(100vw - 32px));
}

.dialog-form {
  display: flex;
  flex-direction: column;
  max-height: min(88dvh, 780px);
}
.dialog-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 16px 13px 20px;
  border-bottom: 1px solid var(--border);
}
.dialog-head h2 {
  font-size: 16px;
  font-weight: 660;
  letter-spacing: 0.01em;
}
.dialog-head .sub {
  font-size: 12.5px;
  color: var(--faint);
  margin-left: 2px;
}
.dialog-head .icon-btn {
  margin-left: auto;
}
.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 20px;
  overflow-y: auto;
}
.dialog-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 16px 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.dialog-foot .spacer {
  margin-left: auto;
}
.dialog-foot .btn-primary kbd {
  background: color-mix(in srgb, var(--on-accent) 18%, transparent);
  border-color: transparent;
  color: inherit;
  opacity: 0.85;
  height: 17px;
}

.form-error {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12.8px;
  line-height: 1.4;
  color: var(--danger);
}
.form-error:empty {
  display: none;
}

/* 编辑弹窗里的网址预览 */
.url-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  font-size: 12.5px;
  color: var(--muted);
}
.url-preview .favicon {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  font-size: 11px;
}
.url-preview .host {
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 标签 chip 输入 */
.tag-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  min-height: 40px;
  padding: 5px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: text;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.tag-input:hover {
  border-color: var(--border-strong);
}
.tag-input:focus-within {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 23px;
  padding: 0 4px 0 8px;
  font-size: 12.5px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
}
.tag-chip button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 999px;
  color: inherit;
  opacity: 0.7;
}
.tag-chip button:hover {
  opacity: 1;
  background: color-mix(in srgb, var(--accent) 24%, transparent);
}
.tag-field {
  flex: 1 1 90px;
  min-width: 90px;
  height: 26px;
  padding: 0 4px;
  font-size: 13.5px;
  background: none;
  border: 0;
  outline: none;
}
.tag-field::placeholder {
  color: var(--faint);
}

/* 导入弹窗 */
.file-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
  cursor: pointer;
}
.file-drop:hover,
.file-drop.is-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.file-drop .icon {
  color: var(--accent);
}
.file-drop strong {
  font-size: 13.5px;
  font-weight: 600;
}
.file-drop span {
  font-size: 12px;
  color: var(--muted);
}
.file-drop input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.seg {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
}
.seg button {
  padding: 4px 11px;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--muted);
  border-radius: 7px;
}
.seg button.is-on {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* 确认弹窗 */
.confirm-text {
  font-size: 14px;
  color: var(--text-soft);
  line-height: 1.6;
}
.confirm-target {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 0;
}
.confirm-target .title {
  font-size: 13.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.confirm-target .host {
  font-size: 12px;
  color: var(--faint);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 12. 登录页 ---------- */
.auth-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px 20px;
}
.auth-card {
  width: min(940px, 100%);
  display: grid;
  grid-template-columns: 1.02fr 1fr;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.auth-aside {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 34px 32px;
  color: #f4f6ff;
  background: linear-gradient(150deg, #4338ca 0%, #4f46e5 42%, #0e7490 100%);
  overflow: hidden;
}
.auth-aside::after {
  content: "";
  position: absolute;
  inset: -40% -30% auto auto;
  width: 380px;
  height: 380px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.22), transparent 62%);
  pointer-events: none;
}
.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 680;
}
.auth-brand svg {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  box-shadow: 0 8px 20px -8px rgba(0, 0, 0, 0.5);
}
.auth-aside h1 {
  font-size: 25px;
  line-height: 1.35;
  font-weight: 680;
  letter-spacing: 0.01em;
}
.auth-aside h1 em {
  font-style: normal;
  color: #a5f3fc;
}
.auth-aside p {
  font-size: 13.5px;
  line-height: 1.7;
  color: rgba(244, 246, 255, 0.82);
}
.auth-points {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: auto;
  font-size: 13px;
  color: rgba(244, 246, 255, 0.9);
}
.auth-points li {
  display: flex;
  align-items: center;
  gap: 8px;
}
.auth-points .icon {
  color: #a5f3fc;
  flex: 0 0 auto;
}

.auth-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 32px 32px 28px;
}
.auth-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.auth-head h2 {
  font-size: 20px;
  font-weight: 680;
  letter-spacing: 0.01em;
}
.auth-head p {
  font-size: 13px;
  color: var(--muted);
}
.auth-tabs {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
}
.auth-tab {
  flex: 1 1 0;
  height: 30px;
  font-size: 13.5px;
  font-weight: 560;
  color: var(--muted);
  border-radius: 7px;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}
.auth-tab:hover {
  color: var(--text);
}
.auth-tab.is-on {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.pw-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.pw-wrap .input {
  padding-right: 40px;
}
.pw-toggle {
  position: absolute;
  right: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  color: var(--muted);
}
.pw-toggle:hover {
  color: var(--text);
  background: var(--surface-sunken);
}
.auth-error {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 13px;
  color: var(--danger);
  line-height: 1.45;
}
.auth-error:empty {
  display: none;
}
.auth-submit {
  height: 40px;
  font-size: 14.5px;
  margin-top: 2px;
}
.auth-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  font-size: 12px;
  color: var(--faint);
}
.auth-foot .theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 7px;
}
.auth-foot .theme-btn:hover {
  background: var(--surface-sunken);
  color: var(--text);
}

/* ---------- 12.5 邀请码 / 注册模式（v1.1） ---------- */
.input-code {
  font-family: var(--font-mono);
  font-size: 15px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.input-code::placeholder {
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: none;
  color: var(--faint);
}

/* 注册关闭时，注册 tab 的位置换成一句说明（不可点击） */
.auth-tab.is-closed {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 0;
  height: 30px;
  padding: 0 8px;
  font-size: 12.5px;
  color: var(--faint);
  background: none;
  border-radius: 7px;
  cursor: default;
  user-select: none;
  white-space: nowrap;
}

/* 邀请码管理弹窗 */
.invite-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 78px;
}
.invite-skeleton {
  height: 64px;
  border-radius: var(--radius-sm);
}
.invite-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 26px 14px;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 60%, transparent);
}
.invite-empty p {
  font-size: 13.5px;
  color: var(--text-soft);
  line-height: 1.55;
}
.invite-empty .invite-empty-sub {
  font-size: 12px;
  color: var(--faint);
  max-width: 300px;
}
.invite-empty .btn {
  margin-top: 4px;
}

.invite-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.invite-item-main {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}
.invite-code {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.12em;
  color: var(--text);
  overflow-wrap: anywhere;
}
.invite-badge {
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: 999px;
}
.invite-badge.is-unused {
  color: var(--success);
  background: color-mix(in srgb, var(--success) 14%, transparent);
  border-color: color-mix(in srgb, var(--success) 32%, transparent);
}
.invite-badge.is-used {
  color: var(--muted);
  background: var(--surface-sunken);
  border-color: var(--border);
}
.invite-revoke {
  margin-left: auto;
}
.invite-revoke:hover {
  color: var(--danger);
  background: var(--danger-soft);
}
.invite-meta {
  min-width: 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--faint);
  overflow-wrap: anywhere;
}
.invite-sep {
  margin: 0 5px;
  color: var(--faint);
  opacity: 0.75;
}
.invite-note {
  color: var(--muted);
  overflow-wrap: anywhere;
}
.invite-note.is-empty {
  color: var(--faint);
  font-style: italic;
}
.invite-time.is-used {
  color: var(--muted);
}

.invite-new {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
}
.invite-new-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.invite-new-row .input {
  flex: 1 1 auto;
  min-width: 0;
}
.invite-new-row .btn {
  flex: 0 0 auto;
}

.invite-item.is-new {
  animation: invite-flash 1.8s var(--ease);
}
@keyframes invite-flash {
  0% {
    background: var(--accent-soft);
    border-color: var(--accent);
    box-shadow: var(--ring);
  }
  70% {
    background: var(--accent-soft);
    border-color: var(--accent-line);
  }
  100% {
    background: var(--surface-2);
    border-color: var(--border);
    box-shadow: none;
  }
}

/* ---------- 13. 响应式 ---------- */
@media (max-width: 1080px) {
  :root {
    --sidebar-w: 210px;
  }
  .topbar-inner {
    padding: 0 18px;
  }
  .layout {
    padding: 18px 18px 56px;
    gap: 20px;
  }
  .brand-name {
    display: none;
  }
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    padding: 14px 14px 56px;
  }
  .sidebar {
    position: static;
    max-height: none;
    overflow: visible;
    gap: 10px;
  }
  .side-nav {
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .side-nav::-webkit-scrollbar {
    display: none;
  }
  .side-item {
    width: auto;
    flex: 0 0 auto;
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 999px;
    font-size: 13px;
    white-space: nowrap;
  }
  .side-item.is-active {
    border-color: var(--accent-line);
  }
  .side-item > .icon {
    width: 14px;
    height: 14px;
  }
  .side-block {
    gap: 4px;
  }
  .side-heading {
    padding: 0 4px;
  }
  .tag-list {
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    max-height: none;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .tag-list::-webkit-scrollbar {
    display: none;
  }
  .tag-item {
    flex: 0 0 auto;
    width: auto; /* 桌面端是 width:100%，移动端要还原成内容宽度，否则单标签会被拉满一行 */
    padding: 5px 11px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 999px;
    font-size: 12.5px;
    white-space: nowrap;
  }
  .tag-item.is-active {
    border-color: var(--accent-line);
  }
  .tag-item .count {
    margin-left: 2px;
  }
  .side-foot {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding-top: 8px;
  }
  .side-foot-row {
    flex: 0 0 auto;
  }
  .side-foot-row .btn {
    flex: 0 0 auto;
  }
  .stats-line {
    margin-left: auto;
    justify-content: flex-end;
  }
  .empty {
    padding: 46px 18px 52px;
  }
}

@media (max-width: 720px) {
  :root {
    --header-h: 108px;
  }
  .invite-new-row {
    flex-direction: column;
  }
  .invite-new-row .btn {
    width: 100%;
  }
  .invite-code {
    font-size: 14px;
    letter-spacing: 0.1em;
  }
  .invite-revoke {
    margin-left: 0;
  }
  .topbar {
    padding-bottom: 10px;
  }
  .topbar-inner {
    height: auto;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 14px 0;
  }
  .search {
    order: 3;
    flex: 1 0 100%;
    max-width: none;
    height: 40px;
  }
  .search-input {
    height: 40px;
  }
  .search-kbd {
    display: none;
  }
  .search-clear {
    right: 8px;
  }
  .topbar-actions {
    gap: 6px;
  }
  .topbar-actions .select {
    max-width: 116px;
  }
  .brand svg {
    width: 27px;
    height: 27px;
  }
  .results-hint {
    display: none;
  }
  .auth-card {
    grid-template-columns: minmax(0, 1fr);
    border-radius: var(--radius-lg);
  }
  .auth-aside {
    padding: 22px 22px 20px;
    gap: 12px;
  }
  .auth-aside h1 {
    font-size: 19px;
  }
  .auth-aside p,
  .auth-points {
    display: none;
  }
  .auth-panel {
    padding: 22px 22px 24px;
  }
  .dialog {
    width: 100%;
    max-width: none;
    max-height: 92dvh;
    margin: auto 0 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .dialog-form {
    max-height: 92dvh;
  }
  .dialog-body {
    padding: 16px;
  }
  .dialog-head {
    padding: 14px 12px 12px 16px;
  }
  .dialog-foot {
    padding: 12px 12px 12px 16px;
  }
  .toast-host {
    top: auto;
    bottom: 16px;
    right: 12px;
    left: 12px;
    align-items: stretch;
  }
  .toast {
    max-width: none;
  }
}

@media (max-width: 480px) {
  .grid,
  .skeleton-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  /* 375px：把顶栏压到一行不溢出（品牌只留图标） */
  .brand-name {
    display: none;
  }
  .topbar-actions {
    gap: 4px;
  }
  .topbar-actions .select {
    max-width: 100px;
    padding-right: 24px;
  }
  .topbar-actions .btn-primary span.label {
    display: none;
  }
  .topbar-actions .btn-primary {
    padding: 0 10px;
  }
  .btn:not(.btn-sm) {
    height: 34px;
  }
  .layout {
    padding: 12px 12px 52px;
  }
  .empty h2 {
    font-size: 16px;
  }
  .empty {
    padding: 38px 14px 44px;
  }
  .quick-add {
    flex-direction: column;
  }
  .quick-add .btn {
    width: 100%;
  }
}

@media (min-width: 1500px) {
  .grid,
  .skeleton-grid {
    grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  }
}

/* ---------- 14. 动效偏好 / 打印 ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .card:hover {
    transform: none;
  }
}

@media print {
  .topbar,
  .sidebar,
  .card-actions,
  .toast-host {
    display: none !important;
  }
  body {
    background: #fff;
  }
  .layout {
    display: block;
    padding: 0;
  }
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .card {
    break-inside: avoid;
    box-shadow: none;
  }
}
