:root {
  color-scheme: light dark;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1c2333;
  --text-dim: #6b7386;
  --line: #e6e9f2;
  --accent: #2f6bff;
  --accent-weak: #eaf0ff;
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.05), 0 8px 24px -12px rgba(20, 30, 60, 0.12);
  --shadow-hover: 0 2px 4px rgba(20, 30, 60, 0.06), 0 14px 34px -10px rgba(47, 107, 255, 0.25);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10141f;
    --card: #1a2030;
    --text: #e7eaf3;
    --text-dim: #8b93a8;
    --line: #2a3245;
    --accent: #5b8cff;
    --accent-weak: #1e2a48;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
    --shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.3), 0 14px 34px -10px rgba(91, 140, 255, 0.35);
  }
}
/* 手动切换的主题优先于系统偏好 */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10141f;
  --card: #1a2030;
  --text: #e7eaf3;
  --text-dim: #8b93a8;
  --line: #2a3245;
  --accent: #5b8cff;
  --accent-weak: #1e2a48;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  --shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.3), 0 14px 34px -10px rgba(91, 140, 255, 0.35);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1c2333;
  --text-dim: #6b7386;
  --line: #e6e9f2;
  --accent: #2f6bff;
  --accent-weak: #eaf0ff;
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.05), 0 8px 24px -12px rgba(20, 30, 60, 0.12);
  --shadow-hover: 0 2px 4px rgba(20, 30, 60, 0.06), 0 14px 34px -10px rgba(47, 107, 255, 0.25);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  /* 纯色打底（仅用 var()，任何浏览器都成立）；渐变单独走 background-image，
     旧浏览器不支持 color-mix 时只丢弃 background-image，纯色背景仍在，避免暗色模式白底白字 */
  background-color: var(--bg);
  background-image:
    radial-gradient(1000px 400px at 15% -10%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 60%),
    radial-gradient(800px 300px at 90% -5%, color-mix(in srgb, var(--accent) 6%, transparent), transparent 55%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* —— 顶栏 —— */
.topbar {
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1440px; margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; flex: none; overflow: hidden;
  background: linear-gradient(135deg, var(--accent), #7c4dff);
  color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--accent) 60%, transparent);
}
.brand-mark.has-img { background: transparent; box-shadow: none; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-title { font-size: 17px; font-weight: 700; letter-spacing: 0.5px; }
.brand-sub { font-size: 12px; color: var(--text-dim); }
.topbar-right { display: flex; align-items: center; gap: 12px; min-width: 0; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; color: var(--text-dim); width: 230px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
.search-box input { border: 0; outline: 0; background: transparent; color: var(--text); font-size: 14px; width: 100%; }

.btn-primary {
  background: var(--accent); color: #fff; text-decoration: none;
  padding: 8px 20px; border-radius: 10px; font-size: 14px; font-weight: 600;
  box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--accent) 55%, transparent);
  transition: transform 0.12s, filter 0.12s; white-space: nowrap;
}
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-ghost {
  color: var(--text-dim); text-decoration: none; font-size: 13px;
  padding: 5px 10px; border-radius: 8px; white-space: nowrap;
}
.btn-ghost:hover { background: var(--accent-weak); color: var(--accent); }

.user-chip { display: flex; align-items: center; gap: 8px; min-width: 0; }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, var(--accent), #7c4dff); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600;
}
.user-name { font-size: 14px; font-weight: 500; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* —— 主体 —— */
.container { max-width: 1440px; margin: 0 auto; padding: 28px 24px 40px; width: 100%; flex: 1; }

.login-hint {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--accent-weak); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  color: var(--text); border-radius: 12px; padding: 12px 18px; margin-bottom: 26px; font-size: 14px;
}
.login-hint a { color: var(--accent); font-weight: 600; text-decoration: none; }
.login-hint a:hover { text-decoration: underline; }

.category { margin-bottom: 34px; }
.category-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 700; margin-bottom: 14px;
}
.category-dot { width: 6px; height: 18px; border-radius: 3px; background: linear-gradient(180deg, var(--accent), #7c4dff); }
.category-count {
  font-size: 12px; font-weight: 500; color: var(--text-dim);
  background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 1px 9px;
}

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

.card {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 44px 16px 16px; /* 右侧留出收藏/状态角标的位置 */
  text-decoration: none; color: var(--text); min-height: 84px;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  position: relative; overflow: hidden;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.card-icon {
  width: 48px; height: 48px; border-radius: 12px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 25px; font-weight: 700; background: var(--accent-weak); overflow: hidden;
}
.card-icon img { width: 100%; height: 100%; object-fit: contain; padding: 5px; }
/* 文字区占满剩余宽度，不被角标挤压 */
.card-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 auto; }
.card-name {
  font-size: 15.5px; font-weight: 600; line-height: 1.35;
  /* 名字长时最多折两行，不再一个字一行 */
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word;
}
.card-desc {
  font-size: 12.5px; color: var(--text-dim); line-height: 1.45;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* 可见性 / 健康状态角标：绝对定位，不占文字宽度 */
.card-marks {
  position: absolute; right: 12px; bottom: 10px;
  display: flex; align-items: center; gap: 5px; color: var(--text-dim);
}
.card-marks .lock { flex: none; }

.no-result { text-align: center; color: var(--text-dim); padding: 60px 0; font-size: 15px; }

/* —— 主题切换按钮 —— */
.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex: none; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text-dim); transition: color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.icon-btn .ico-moon { display: none; }
@media (prefers-color-scheme: dark) {
  .icon-btn .ico-sun { display: none; }
  .icon-btn .ico-moon { display: block; }
}
:root[data-theme="dark"] .icon-btn .ico-sun { display: none; }
:root[data-theme="dark"] .icon-btn .ico-moon { display: block; }
:root[data-theme="light"] .icon-btn .ico-sun { display: block; }
:root[data-theme="light"] .icon-btn .ico-moon { display: none; }

/* —— 公告 —— */
.notice {
  display: flex; align-items: flex-start; gap: 10px;
  border-radius: 12px; padding: 12px 16px; margin-bottom: 14px;
  font-size: 14px; line-height: 1.6; border: 1px solid transparent;
}
.notice-ico { flex: none; }
.notice-info { background: var(--accent-weak); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.notice-warn { background: color-mix(in srgb, #d97706 12%, transparent); border-color: color-mix(in srgb, #d97706 35%, transparent); }
.notice-danger { background: color-mix(in srgb, #e5484d 12%, transparent); border-color: color-mix(in srgb, #e5484d 35%, transparent); }

.login-hint.subtle { background: transparent; border-style: dashed; color: var(--text-dim); font-size: 13px; }
.category-dot.star { background: linear-gradient(180deg, #f5a524, #f76808); }
.cat-ico { font-size: 15px; }

/* —— 收藏按钮（绝对定位在右上角，不占文字宽度）—— */
.fav-btn {
  position: absolute; top: 10px; right: 10px; flex: none; cursor: pointer;
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: 7px;
  color: var(--text-dim); opacity: 0; transition: opacity .15s, color .15s, background .15s;
}
.card:hover .fav-btn, .fav-btn:focus-visible { opacity: 1; }
.fav-btn:hover { background: var(--accent-weak); color: #f5a524; }
.fav-btn.on { opacity: 1; color: #f5a524; }
.fav-btn.on svg { fill: #f5a524; }

.dot-down {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: #e5484d; flex: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, #e5484d 20%, transparent);
}

.footer { text-align: center; padding: 22px; color: var(--text-dim); font-size: 12.5px; border-top: 1px solid var(--line); }

@media (max-width: 640px) {
  .topbar-inner { flex-wrap: wrap; padding: 10px 16px; }
  .topbar-right { width: 100%; justify-content: space-between; }
  .search-box { width: auto; flex: 1; }
  .brand-sub { display: none; }
  .container { padding: 20px 16px 32px; }
  .grid { grid-template-columns: 1fr; }
}
