/* =========================================================
   服务导航 — 样式
   ========================================================= */

:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --surface: rgba(255, 255, 255, 0.76);
  --surface-solid: #ffffff;
  --surface-soft: #f6f7fc;
  --card: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
  --border: rgba(15, 23, 42, 0.075);
  --border-strong: rgba(15, 23, 42, 0.14);
  --text: #0f172a;
  --text-2: #48546a;
  --text-3: #77839a;
  --accent: #5756d8;
  --accent-2: #8b5cf6;
  --accent-soft: rgba(87, 86, 216, 0.1);
  --accent-softer: rgba(87, 86, 216, 0.055);
  --on-accent: #ffffff;
  --intranet: #059669;
  --intranet-soft: rgba(5, 150, 105, 0.1);
  --external: #0284c7;
  --external-soft: rgba(2, 132, 199, 0.1);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.075);
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.035), 0 10px 28px -22px rgba(15, 23, 42, 0.35);
  --shadow-lift: 0 2px 4px rgba(15, 23, 42, 0.04), 0 20px 40px -24px rgba(15, 23, 42, 0.35);
  --shadow-menu: 0 18px 50px -14px rgba(15, 23, 42, 0.28), 0 2px 8px rgba(15, 23, 42, 0.05);
  --grid-line: rgba(15, 23, 42, 0.04);
  --radius-card: 20px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: "SFMono-Regular", "Cascadia Code", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #090d15;
  --surface: rgba(17, 23, 36, 0.72);
  --surface-solid: #131a28;
  --surface-soft: #18202f;
  --card: linear-gradient(180deg, rgba(27, 35, 53, 0.9) 0%, rgba(19, 26, 40, 0.96) 100%);
  --border: rgba(148, 163, 184, 0.11);
  --border-strong: rgba(148, 163, 184, 0.2);
  --text: #e9eef8;
  --text-2: #a8b3c7;
  --text-3: #8492aa;
  --accent: #818cf8;
  --accent-2: #a78bfa;
  --accent-soft: rgba(129, 140, 248, 0.13);
  --accent-softer: rgba(129, 140, 248, 0.075);
  --on-accent: #0b1020;
  --intranet: #34d399;
  --intranet-soft: rgba(52, 211, 153, 0.11);
  --external: #38bdf8;
  --external-soft: rgba(56, 189, 248, 0.11);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.1);
  --shadow-card: 0 1px 1px rgba(0, 0, 0, 0.2), 0 16px 34px -26px rgba(0, 0, 0, 0.8);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.2), 0 26px 48px -28px rgba(0, 0, 0, 0.9);
  --shadow-menu: 0 22px 60px -16px rgba(0, 0, 0, 0.75), 0 2px 8px rgba(0, 0, 0, 0.35);
  --grid-line: rgba(148, 163, 184, 0.045);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #090d15;
    --surface: rgba(17, 23, 36, 0.72);
    --surface-solid: #131a28;
    --surface-soft: #18202f;
    --card: linear-gradient(180deg, rgba(27, 35, 53, 0.9) 0%, rgba(19, 26, 40, 0.96) 100%);
    --border: rgba(148, 163, 184, 0.11);
    --border-strong: rgba(148, 163, 184, 0.2);
    --text: #e9eef8;
    --text-2: #a8b3c7;
    --text-3: #8492aa;
    --accent: #818cf8;
    --accent-2: #a78bfa;
    --accent-soft: rgba(129, 140, 248, 0.13);
    --accent-softer: rgba(129, 140, 248, 0.075);
    --on-accent: #0b1020;
    --intranet: #34d399;
    --intranet-soft: rgba(52, 211, 153, 0.11);
    --external: #38bdf8;
    --external-soft: rgba(56, 189, 248, 0.11);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.1);
    --shadow-card: 0 1px 1px rgba(0, 0, 0, 0.2), 0 16px 34px -26px rgba(0, 0, 0, 0.8);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.2), 0 26px 48px -28px rgba(0, 0, 0, 0.9);
    --shadow-menu: 0 22px 60px -16px rgba(0, 0, 0, 0.75), 0 2px 8px rgba(0, 0, 0, 0.35);
    --grid-line: rgba(148, 163, 184, 0.045);
  }
}

/* =========================================================
   Reset & base
   ========================================================= */

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(900px 520px at 8% -12%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 62%),
    radial-gradient(760px 460px at 96% -4%, color-mix(in srgb, var(--external) 9%, transparent), transparent 58%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  isolation: isolate;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse 90% 65% at 50% 0%, #000 10%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 90% 65% at 50% 0%, #000 10%, transparent 78%);
}

body.has-custom-bg::before {
  opacity: 0.32;
}

.page-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-color: transparent;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  transition: background-color 0.25s ease;
}

.page-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bg);
  opacity: var(--bg-overlay, 0);
  transition: opacity 0.2s ease;
}

::selection {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 26%, transparent);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

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

button {
  -webkit-tap-highlight-color: transparent;
}

button:not(:disabled) {
  cursor: pointer;
}

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

[hidden] {
  display: none !important;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-dots {
  stroke-width: 2.6;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 500;
  padding: 9px 14px;
  border-radius: 8px;
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow-menu);
  transform: translateY(-160%);
  transition: transform 0.15s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

/* =========================================================
   Top bar
   ========================================================= */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid transparent;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.topbar.is-scrolled {
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border-bottom-color: var(--border);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  box-shadow: 0 8px 30px -24px rgba(15, 23, 42, 0.4);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  box-shadow:
    0 8px 18px -10px color-mix(in srgb, var(--accent) 75%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.brand-mark .icon {
  width: 23px;
  height: 23px;
  stroke-width: 1.7;
}

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

.brand-text h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

/* Environment pill */

.env-pill {
  --env-color: var(--text-3);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-solid);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.01em;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.env-pill:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.env-pill[data-mode="intranet"] {
  --env-color: var(--intranet);
  border-color: color-mix(in srgb, var(--intranet) 24%, var(--border));
  background: linear-gradient(180deg, color-mix(in srgb, var(--intranet) 7%, var(--surface-solid)), var(--surface-solid));
}

.env-pill[data-mode="external"] {
  --env-color: var(--external);
  border-color: color-mix(in srgb, var(--external) 24%, var(--border));
  background: linear-gradient(180deg, color-mix(in srgb, var(--external) 7%, var(--surface-solid)), var(--surface-solid));
}

.env-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--env-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--env-color) 14%, transparent);
}

.env-pill.is-detecting .env-dot {
  animation: pulse 1.1s ease-in-out infinite;
}

.env-label {
  color: var(--text);
  white-space: nowrap;
}

.env-tag {
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--surface-soft);
  color: var(--text-3);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.env-chevron {
  width: 13px;
  height: 13px;
  margin-left: -1px;
  color: var(--text-3);
}

/* Icon & normal buttons */

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--text-2);
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.icon-btn:hover {
  background: var(--surface-solid);
  border-color: var(--border);
  color: var(--text);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 15px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-solid);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.005em;
  white-space: nowrap;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-soft);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn .icon {
  width: 15px;
  height: 15px;
}

.btn-primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: var(--on-accent);
  box-shadow: 0 8px 18px -12px color-mix(in srgb, var(--accent) 80%, transparent);
}

.btn-primary:hover {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  filter: brightness(1.045);
  box-shadow: 0 10px 22px -12px color-mix(in srgb, var(--accent) 85%, transparent);
}

.btn-danger {
  border-color: transparent;
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  border-color: transparent;
  background: color-mix(in srgb, var(--danger) 88%, #000);
}

.btn-small {
  height: 34px;
  padding: 0 11px;
  border-radius: 9px;
  font-size: 11.5px;
}

.btn-small .icon {
  width: 13px;
  height: 13px;
}

.danger-ghost {
  color: var(--danger);
}

.danger-ghost:hover {
  border-color: color-mix(in srgb, var(--danger) 30%, var(--border));
  background: var(--danger-soft);
}

.add-button {
  height: 40px;
  padding: 0 16px;
}

/* =========================================================
   Layout
   ========================================================= */

.shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 28px 56px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 4px 0 20px;
}

.search {
  position: relative;
  flex: 1 1 300px;
  min-width: 210px;
  max-width: 430px;
}

.search input {
  width: 100%;
  height: 42px;
  padding: 0 74px 0 39px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-solid);
  color: var(--text);
  font-size: 12.5px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.search input::placeholder {
  color: var(--text-3);
}

.search input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 46%, var(--border));
  box-shadow: 0 0 0 3px var(--accent-softer);
}

.search input::-webkit-search-cancel-button {
  display: none;
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 13px;
  width: 16px;
  height: 16px;
  color: var(--text-3);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-kbd {
  position: absolute;
  top: 50%;
  right: 11px;
  padding: 3px 5px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-soft);
  color: var(--text-3);
  font: 10.5px/1 var(--mono);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-clear {
  position: absolute;
  top: 50%;
  right: 7px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--text-3);
  transform: translateY(-50%);
}

.search-clear:hover {
  color: var(--text);
}

.search-clear .icon {
  width: 14px;
  height: 14px;
}

.category-bar {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1 1 auto;
  min-width: 0;
  padding: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.category-bar::-webkit-scrollbar {
  display: none;
}

.cat-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  height: 32px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 550;
  white-space: nowrap;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.cat-tab:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.cat-tab[aria-selected="true"] {
  border-color: var(--border);
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.045);
}

.cat-count {
  min-width: 17px;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-soft);
  color: var(--text-3);
  font-size: 9.5px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.cat-tab[aria-selected="true"] .cat-count {
  background: var(--accent-soft);
  color: var(--accent);
}

.toolbar-meta {
  flex: none;
  margin-left: auto;
  color: var(--text-3);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

/* =========================================================
   Site grid & cards
   ========================================================= */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 13px;
}

.site-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 180px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--card);
  box-shadow: var(--shadow-card);
  transition: transform 0.18s ease, box-shadow 0.22s ease, border-color 0.18s ease;
}

.site-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(380px 170px at 100% 0%, var(--accent-softer), transparent 68%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.site-card:hover {
  border-color: color-mix(in srgb, var(--accent) 24%, var(--border));
  box-shadow: var(--shadow-lift);
  transform: translateY(-3px);
}

.site-card:hover::before {
  opacity: 1;
}

.card-link {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
  padding: 17px 17px 12px;
  border-radius: inherit;
  color: inherit;
  text-decoration: none;
}

.card-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
}

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

.card-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: none;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-soft);
  color: var(--text-2);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

.card-icon img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-icon img.is-loaded {
  background: var(--surface-soft);
}

.card-icon.is-letter {
  border-color: color-mix(in srgb, hsl(var(--icon-h), 60%, 55%) 24%, var(--border));
  background: color-mix(in srgb, hsl(var(--icon-h), 68%, 55%) 14%, var(--surface-solid));
  color: hsl(var(--icon-h), 58%, 38%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .card-icon.is-letter {
    color: hsl(var(--icon-h), 70%, 72%);
    background: color-mix(in srgb, hsl(var(--icon-h), 68%, 55%) 18%, var(--surface-solid));
  }
}

:root[data-theme="dark"] .card-icon.is-letter {
  color: hsl(var(--icon-h), 70%, 72%);
  background: color-mix(in srgb, hsl(var(--icon-h), 68%, 55%) 18%, var(--surface-solid));
}

.card-titles {
  min-width: 0;
  padding-top: 1px;
}

.card-title {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.012em;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-category {
  margin-top: 3px;
  overflow: hidden;
  color: var(--text-3);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-desc {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--text-2);
  font-size: 11.5px;
  line-height: 1.6;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.card-host {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  margin-top: auto;
  padding-top: 4px;
  color: var(--text-3);
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.4;
}

.card-host .icon {
  width: 12px;
  height: 12px;
  flex: none;
  opacity: 0.8;
}

.card-host span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 11px 8px 17px;
  border-top: 1px dashed var(--border);
  background: color-mix(in srgb, var(--surface-soft) 52%, transparent);
}

.env-chips {
  display: flex;
  gap: 5px;
  min-width: 0;
}

.env-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.env-chip::before {
  content: "";
  width: 5px;
  height: 5px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}

.env-chip:not(.is-active):hover:not(:disabled) {
  border-color: var(--border);
  background: var(--surface-solid);
  color: var(--text-2);
}

.env-chip[data-env="intranet"].is-active {
  border-color: color-mix(in srgb, var(--intranet) 22%, transparent);
  background: var(--intranet-soft);
  color: var(--intranet);
}

.env-chip[data-env="external"].is-active {
  border-color: color-mix(in srgb, var(--external) 22%, transparent);
  background: var(--external-soft);
  color: var(--external);
}

.env-chip.is-active::before {
  opacity: 1;
}

.env-chip:disabled {
  opacity: 0.34;
  cursor: not-allowed;
}

.card-menu-btn {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  flex: none;
  padding: 0;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-3);
  transition: background 0.15s ease, color 0.15s ease;
}

.card-menu-btn:hover,
.card-menu-btn[aria-expanded="true"] {
  background: var(--surface-solid);
  color: var(--text);
}

.card-menu-btn .icon {
  width: 16px;
  height: 16px;
}

/* Add card */

.add-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 180px;
  padding: 18px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-card);
  background: transparent;
  color: var(--text-3);
  text-align: center;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.add-card:hover {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border-strong));
  background: var(--accent-softer);
  color: var(--accent);
}

.add-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 7px;
  border: 1px dashed currentColor;
  border-radius: 50%;
  transition: transform 0.18s ease;
}

.add-card:hover .add-icon {
  transform: scale(1.07);
}

.add-icon .icon {
  width: 18px;
  height: 18px;
}

.add-title {
  font-size: 12.5px;
  font-weight: 650;
}

.add-sub {
  font-size: 10.5px;
  opacity: 0.72;
}

/* =========================================================
   Empty state
   ========================================================= */

.empty {
  max-width: 540px;
  margin: 0 auto;
  padding: 64px 20px 48px;
  text-align: center;
}

.empty-art {
  width: 210px;
  margin: 0 auto 10px;
  opacity: 0.95;
}

.empty-art svg {
  display: block;
  width: 100%;
  height: auto;
}

.empty h2 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.empty p {
  max-width: 430px;
  margin: 0 auto 22px;
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.75;
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
}

/* =========================================================
   Footer
   ========================================================= */

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 42px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 10.5px;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.footer-sep {
  opacity: 0.5;
}

.footer-tip {
  margin: 0;
  line-height: 1.5;
}

.storage-dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--text-3);
}

.storage-dot[data-state="server"] {
  background: var(--intranet);
  box-shadow: 0 0 0 3px var(--intranet-soft);
}

.storage-dot[data-state="syncing"] {
  background: var(--external);
  animation: pulse 1s ease-in-out infinite;
}

.storage-dot[data-state="error"] {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

/* =========================================================
   Menus
   ========================================================= */

.menu {
  position: fixed;
  z-index: 120;
  min-width: 208px;
  max-height: calc(100vh - 16px);
  max-height: calc(100dvh - 16px);
  padding: 5px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-menu);
  animation: menu-in 0.13s ease-out;
}

.menu-head {
  padding: 8px 10px 5px;
  color: var(--text-3);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  text-align: left;
  white-space: nowrap;
}

.menu-item .icon {
  width: 15px;
  height: 15px;
  color: var(--text-3);
}

.menu-item:hover:not(:disabled),
.menu-item:focus-visible {
  outline: none;
  background: var(--surface-soft);
}

.menu-item:focus-visible {
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.menu-item:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.menu-item-danger {
  color: var(--danger);
}

.menu-item-danger .icon {
  color: var(--danger);
}

.menu-check {
  width: 15px;
  height: 15px;
  margin-left: auto;
  color: var(--accent);
}

.menu-sep {
  height: 1px;
  margin: 5px 6px;
  background: var(--border);
}

.menu-note {
  max-width: 260px;
  padding: 7px 10px 8px;
  color: var(--text-3);
  font-size: 10.5px;
  line-height: 1.55;
  white-space: normal;
}

.env-menu {
  min-width: 256px;
}

/* =========================================================
   Dialogs
   ========================================================= */

.dialog {
  width: min(620px, calc(100vw - 32px));
  max-height: min(88vh, 900px);
  max-height: min(88dvh, 900px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: 0 34px 100px -24px rgba(2, 6, 23, 0.5);
}

.dialog[open] {
  display: flex;
  flex-direction: column;
  animation: dialog-in 0.18s ease-out;
}

.dialog::backdrop {
  background: rgba(8, 12, 24, 0.5);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: backdrop-in 0.18s ease-out;
}

.dialog-sm {
  width: min(440px, calc(100vw - 32px));
}

.dialog-wide {
  width: min(700px, calc(100vw - 32px));
}

.dialog form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: inherit;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex: none;
  padding: 22px 24px 2px;
}

.dialog-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.dialog-head p {
  margin: 5px 0 0;
  color: var(--text-2);
  font-size: 11.5px;
  line-height: 1.55;
}

.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 15px;
  min-height: 0;
  padding: 18px 24px 22px;
  overflow-y: auto;
}

.dialog-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex: none;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-soft) 55%, var(--surface-solid));
}

.dialog-foot-end {
  justify-content: flex-end;
}

.foot-note {
  color: var(--text-3);
  font-size: 10.5px;
  line-height: 1.5;
}

.foot-actions {
  display: flex;
  gap: 8px;
  flex: none;
}

/* =========================================================
   Forms
   ========================================================= */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field > label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 650;
}

.label-note {
  color: var(--text-3);
  font-size: 10px;
  font-weight: 400;
}

.req {
  color: var(--danger);
}

.input {
  width: 100%;
  height: 41px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 12.5px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

textarea.input {
  height: auto;
  min-height: 68px;
  padding: 9px 12px;
  line-height: 1.6;
  resize: vertical;
}

select.input {
  padding-right: 32px;
}

.input::placeholder {
  color: var(--text-3);
  opacity: 0.82;
}

.input:hover {
  border-color: color-mix(in srgb, var(--border-strong) 72%, var(--text-3));
}

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

.field.has-error .input {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.field-error {
  display: none;
  margin: 0;
  color: var(--danger);
  font-size: 10.5px;
}

.field.has-error .field-error {
  display: block;
}

.form-error {
  display: none;
  margin: -2px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 11px;
  line-height: 1.5;
}

.form-error.is-visible {
  display: block;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
}

.dot-intranet {
  background: var(--intranet);
  box-shadow: 0 0 0 3px var(--intranet-soft);
}

.dot-external {
  background: var(--external);
  box-shadow: 0 0 0 3px var(--external-soft);
}

.hint {
  margin: 0;
  color: var(--text-3);
  font-size: 10.5px;
  line-height: 1.6;
}

.icon-input {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-input .input {
  flex: 1;
  min-width: 0;
}

.icon-preview {
  position: relative;
  display: grid;
  place-items: center;
  width: 41px;
  height: 41px;
  flex: none;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text-3);
  font-size: 10px;
}

.icon-preview img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.icon-preview img.is-loaded {
  background: var(--surface-soft);
}

.icon-preview.is-letter {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.emoji-row {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.emoji-row button {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: 13px;
  line-height: 1;
  transition: background 0.14s ease, transform 0.14s ease;
}

.emoji-row button:hover {
  background: var(--surface-soft);
  transform: scale(1.1);
}

/* =========================================================
   Settings
   ========================================================= */

.settings-body {
  gap: 0;
  padding-top: 6px;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 0 20px;
  border-bottom: 1px solid var(--border);
}

.settings-section:last-child {
  padding-bottom: 4px;
  border-bottom: none;
}

.section-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.section-head p {
  margin: 4px 0 0;
  color: var(--text-3);
  font-size: 10.5px;
  line-height: 1.55;
}

/* 背景设置 */

.bg-mode-group {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}

.bg-mode-group button {
  height: 33px;
  padding: 0 4px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.bg-mode-group button:hover {
  color: var(--text);
}

.bg-mode-group button.is-active {
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.bg-preview {
  position: relative;
  height: 102px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background-color: var(--bg);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  transition: background-color 0.2s ease;
}

.bg-preview[data-mode="default"] {
  background-image:
    radial-gradient(220px 120px at 8% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
    radial-gradient(200px 100px at 96% -8%, color-mix(in srgb, var(--external) 12%, transparent), transparent 68%);
}

.bg-preview-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.bg-preview-label {
  position: absolute;
  bottom: 8px;
  left: 9px;
  z-index: 2;
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-solid) 84%, transparent);
  color: var(--text-2);
  font-size: 9.5px;
  font-weight: 600;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.bg-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-soft) 68%, transparent);
}

.bg-panel[hidden] {
  display: none !important;
}

.color-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.color-input {
  width: 44px;
  height: 41px;
  flex: none;
  padding: 3px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
}

.color-value {
  color: var(--text-3);
  font: 10.5px/1.4 var(--mono);
  text-transform: uppercase;
}

.range-input {
  width: 100%;
  height: 22px;
  margin: 3px 0 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.bg-upload-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.bg-upload-row .btn {
  flex: none;
}

.bg-file-name {
  min-width: 0;
  max-width: 200px;
  overflow: hidden;
  padding: 4px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-solid);
  color: var(--text-3);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diagnostics {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
  font-size: 10.5px;
}

.diag-row {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 10px;
  align-items: start;
  color: var(--text-3);
}

.diag-row code {
  overflow-wrap: anywhere;
  color: var(--text-2);
  font: 10px/1.45 var(--mono);
}

.diag-row strong {
  color: var(--text);
  font-size: 10.5px;
}

.diag-row > span:last-child {
  color: var(--text-2);
  line-height: 1.45;
}

.diag-probes {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 1px;
}

.diag-probe {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-3);
  font-size: 10px;
}

.diag-probe code {
  overflow-wrap: anywhere;
  color: var(--text-2);
  font: 10px/1.4 var(--mono);
}

.diag-dot {
  width: 5px;
  height: 5px;
  flex: none;
  border-radius: 50%;
  background: var(--text-3);
}

.diag-probe[data-status="ok"] .diag-dot {
  background: var(--intranet);
}

.diag-probe[data-status="fail"] .diag-dot {
  background: var(--danger);
}

.diag-probe[data-status="skipped"] .diag-dot {
  background: var(--external);
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* =========================================================
   Toasts
   ========================================================= */

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

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-menu);
  color: var(--text);
  font-size: 11.5px;
  line-height: 1.45;
  pointer-events: auto;
  animation: toast-in 0.2s ease-out;
}

.toast .icon {
  width: 15px;
  height: 15px;
  color: var(--accent);
}

.toast[data-type="success"] .icon {
  color: var(--intranet);
}

.toast[data-type="error"] {
  border-color: color-mix(in srgb, var(--danger) 30%, var(--border));
}

.toast[data-type="error"] .icon {
  color: var(--danger);
}

.toast.is-leaving {
  animation: toast-out 0.16s ease-in forwards;
}

/* =========================================================
   Motion
   ========================================================= */

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

@keyframes menu-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes backdrop-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 900px) {
  .topbar-inner {
    padding: 16px 20px;
  }

  .shell {
    padding: 20px 20px 48px;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }
}

@media (max-width: 760px) {
  .brand-text p {
    display: none;
  }

  .topbar-inner {
    gap: 12px;
  }

  .topbar-actions {
    gap: 4px;
  }

  .toolbar-meta {
    display: none;
  }

  .search {
    max-width: none;
    flex-basis: 100%;
  }

  .category-bar {
    flex-basis: 100%;
  }
}

@media (max-width: 600px) {
  .topbar-inner {
    padding: 12px 16px;
  }

  .shell {
    padding: 16px 16px 40px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }

  .brand-mark .icon {
    width: 21px;
    height: 21px;
  }

  .brand-text h1 {
    font-size: 16px;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
  }

  .env-pill {
    height: 36px;
    padding: 0 9px 0 10px;
    gap: 6px;
  }

  .env-tag {
    display: none;
  }

  .add-button {
    width: 38px;
    height: 38px;
    padding: 0;
  }

  .add-label {
    display: none;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .site-card,
  .add-card {
    min-height: 164px;
  }

  .add-card {
    min-height: 128px;
  }

  .dialog {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    margin: auto 0 0;
    border-radius: 18px 18px 0 0;
  }

  .dialog-head {
    padding: 18px 18px 0;
  }

  .dialog-body {
    padding: 14px 18px 18px;
  }

  .dialog-foot {
    flex-wrap: wrap;
    padding: 12px 18px;
  }

  .foot-note {
    order: 2;
    width: 100%;
  }

  .foot-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .grid-2 {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .bg-preview {
    height: 88px;
  }

  .empty {
    padding-top: 42px;
  }

  .footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-top: 30px;
  }

  .search-kbd {
    display: none;
  }

  .search input {
    padding-right: 40px;
  }

  .toasts {
    bottom: 16px;
  }
}

@media (max-width: 380px) {
  .brand-mark {
    display: none;
  }

  .topbar-actions {
    gap: 2px;
  }

  .env-pill {
    padding: 0 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
