/* ============================================================
   万物皆可爬 · 通用组件（按钮 / 卡片 / 徽章 / 标签栏 / 表单…）
   ============================================================ */

/* —— 按钮 —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: 500 15px/1 var(--font-body);
  border: none;
  cursor: pointer;
  border-radius: var(--r-md);
  padding: 13px 20px;
  text-decoration: none;
  user-select: none;
  white-space: nowrap;
  transition: transform var(--t-fast) var(--ease-out),
              box-shadow var(--t-fast) ease,
              background var(--t-fast) ease,
              opacity var(--t-fast) ease;
}
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--accent); color: var(--accent-contrast); box-shadow: var(--shadow-sm); }
.btn-primary:hover:not([disabled]) { transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-outline { background: transparent; color: var(--ink); border: 1.5px solid var(--line-strong); }
.btn-outline:hover:not([disabled]) { border-color: var(--ink-2); background: var(--surface-2); }

.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover:not([disabled]) { color: var(--ink); background: var(--surface-2); }

.btn-danger { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); }
.btn-danger:hover:not([disabled]) { background: var(--danger); color: #fff; }

.btn[disabled], .btn.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none;
}

.btn-block { width: 100%; }
.btn-lg { padding: 16px 26px; font-size: 16px; border-radius: var(--r-lg); }
.btn-sm { padding: 8px 14px; font-size: 13px; }

/* —— 卡片 —— */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.card-click {
  display: block;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: transform var(--t-med) var(--ease-out), box-shadow var(--t-med) ease,
              border-color var(--t-med) ease;
}
.card-click:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }

/* —— 状态徽章（建模状态）—— */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: var(--r-pill);
  line-height: 1.5;
  backdrop-filter: blur(4px);
}
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.status-ok  { color: var(--green); background: var(--green-soft); }
.status-off { color: var(--ink-2); background: var(--gray-soft); }

/* 实底状态（浅色底上用）*/
.status-solid-ok  { color: #eafbef; background: rgba(43, 138, 62, 0.92); }
.status-solid-off { color: #f2f0ea; background: rgba(90, 85, 74, 0.92); }

/* —— 筛选 chip —— */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: all var(--t-fast) ease;
}
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* —— 标签 tag —— */
.tag {
  display: inline-flex;
  align-items: center;
  font-size: 11.5px;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 2px 9px;
  border-radius: var(--r-sm);
}

/* —— 头像（首字 + 色相环）—— */
.avatar {
  --h: 24;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: hsl(var(--h) 42% 52%);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  flex: none;
  letter-spacing: 0;
}
.avatar-sm { width: 30px; height: 30px; font-size: 12px; }
.avatar-lg { width: 68px; height: 68px; font-size: 26px; }

/* —— 分段控件（segmented）—— */
.seg {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: var(--r-pill);
  padding: 3px;
  gap: 2px;
}
.seg button {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  transition: all var(--t-fast) ease;
  white-space: nowrap;
}
.seg button.on {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* —— 开关（switch）—— */
.switch { position: relative; display: inline-flex; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; z-index: 1; }
.switch .track {
  width: 46px; height: 26px;
  border-radius: var(--r-pill);
  background: var(--gray-soft);
  border: 1px solid var(--line);
  transition: background var(--t-med) ease;
  position: relative;
}
.switch .knob {
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-med) var(--ease-out);
}
.switch input:checked + .track { background: var(--green); border-color: var(--green); }
.switch input:checked + .track .knob { transform: translateX(20px); }

/* —— 设置行 —— */
.row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px dashed var(--line);
}
.row:last-child { border-bottom: none; }
.row-icon { color: var(--ink-3); display: inline-flex; flex: none; }
.row-body { flex: 1; min-width: 0; }
.row-title { font-size: 14.5px; font-weight: 500; }
.row-sub { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.row-ctrl { flex: none; }

/* —— 表单 —— */
.input, .textarea, .select {
  width: 100%;
  font: 400 14.5px/1.6 var(--font-body);
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 14px;
  transition: border-color var(--t-fast) ease, box-shadow var(--t-fast) ease;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { resize: vertical; min-height: 76px; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; cursor: pointer; }

/* —— 图标按钮 —— */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: all var(--t-fast) ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

/* —— 空状态 —— */
.empty {
  text-align: center;
  padding: var(--sp-12) var(--sp-4);
  color: var(--ink-3);
}
.empty .empty-icon { opacity: 0.6; margin-bottom: 10px; }
.empty p { font-size: 13.5px; }

/* ============================================================
   导航：移动端底部标签栏 + 桌面端侧栏（同一份数据渲染）
   ============================================================ */

/* —— 品牌区 —— */
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand-mark {
  width: 38px; height: 38px;
  border-radius: var(--r-md);
  background: var(--accent);
  color: var(--accent-contrast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.brand-name { font-family: var(--font-display); font-size: 21px; font-weight: 700; line-height: 1.1; }
.brand-sub { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.3em; color: var(--ink-3); }

/* —— 移动端底部标签栏 —— */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: var(--nav-h);
  text-decoration: none;
  color: var(--ink-3);
  font-size: 11px;
  transition: color var(--t-fast) ease;
  -webkit-tap-highlight-color: transparent;
}
.tab:active { color: var(--ink); }
.tab.active { color: var(--accent); font-weight: 600; }
.tab .tab-icon { transition: transform var(--t-med) var(--ease-out); }
.tab.active .tab-icon { transform: translateY(-1px) scale(1.08); }
/* 当前项指示条 */
.tab::before {
  content: "";
  position: absolute;
  top: 0;
  width: 26px; height: 3px;
  border-radius: 0 0 4px 4px;
  background: transparent;
  transition: background var(--t-med) ease;
}
.tab { position: relative; }
.tab.active::before { background: var(--accent); }

/* —— 桌面端侧栏 —— */
.sidebar { display: none; }
@media (min-width: 900px) {
  .tabbar { display: none; }
  .sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--line);
    padding: var(--sp-6) var(--sp-4);
    z-index: 40;
  }
  .side-nav { margin-top: var(--sp-8); display: flex; flex-direction: column; gap: 4px; }
  .side-tab {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--r-md);
    text-decoration: none;
    color: var(--ink-2);
    font-size: 14.5px;
    font-weight: 500;
    transition: all var(--t-fast) ease;
    position: relative;
  }
  .side-tab:hover { background: var(--surface-2); color: var(--ink); }
  .side-tab.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .side-tab.active::before {
    content: "";
    position: absolute;
    left: 0; top: 22%; bottom: 22%;
    width: 3px;
    border-radius: 4px;
    background: var(--accent);
  }
  .side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
}

/* 侧栏底部：手机端入口 */
.side-mobile {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border-radius: var(--r-pill);
  border: 1px dashed var(--line-strong);
  color: var(--ink-2);
  font-size: 12.5px;
  text-decoration: none;
  transition: all var(--t-fast) ease;
}
.side-mobile:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* 同步状态小胶囊 */
.sync-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 6px 13px;
  cursor: pointer;
  transition: all var(--t-fast) ease;
  font-family: var(--font-mono);
}
.sync-chip:hover { border-color: var(--line-strong); color: var(--ink); }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex: none; }
.sync-dot.busy { background: var(--accent); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.3; } }

/* —— Toast —— */
.toast-root {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 24px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: 88vw;
}
@media (min-width: 900px) { .toast-root { bottom: 32px; } }
.toast {
  background: var(--ink);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: var(--r-pill);
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  animation: toastIn var(--t-med) var(--ease-out);
  text-align: center;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.toast.out { animation: toastOut var(--t-fast) ease forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }
