/* ==========================================================================
   layout.css · 页面骨架（背景 / 顶栏 / Hero / 各版块 / 页脚 / 浮层）
   ========================================================================== */

/* ---------- 背景装饰 ----------
   V2.0（25）起：固定在视口后面的柔光层。顶部一层静止的柔光（--gradient-aurora），
   加两团大而软的品牌色光（::before 取 --brand-1、::after 取 --brand-2，主题页改色跟着变），
   漂移动画在 css/motion.css §13；不用模糊滤镜，柔边靠径向渐变本身。网格线（.bg-grid）已移除。 */
.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background-image: var(--gradient-aurora);
  background-repeat: no-repeat;
  pointer-events: none;
}
.aurora::before,
.aurora::after {
  content: "";
  position: absolute;
  width: 72vmax;
  height: 72vmax;
  border-radius: 50%;
  opacity: var(--aurora-strength, 0.2);
}
.aurora::before {
  top: -34vmax;
  left: -22vmax;
  background: radial-gradient(closest-side, var(--brand-1), transparent);
}
.aurora::after {
  bottom: -38vmax;
  right: -26vmax;
  background: radial-gradient(closest-side, var(--brand-2), transparent);
}

/* 顶部滚动进度条 */
.scroll-progress {
  position: fixed;
  top: 0; left: 0;
  z-index: 120;
  height: 2px;
  width: 100%;
  transform: scaleX(var(--scroll, 0));
  transform-origin: 0 50%;
  background: var(--accent);
}

/* ---------- 顶栏 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  border-bottom: 1px solid transparent;
  /* 不把 backdrop-filter 放进 transition：模糊半径过渡需要逐帧重算整条顶栏，
     滚动时开销明显，背景色与描边过渡已足够表达状态切换。 */
  transition: background-color var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
}
.site-header.is-stuck {
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border-bottom-color: var(--border);
  /* 全站两处 backdrop-filter 之一（另一处是手机抽屉）；16px、不加 saturate，滚动时开销可控 */
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.nav {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: 100%;
}
.brand { display: inline-flex; align-items: center; gap: var(--space-3); font-weight: 700; letter-spacing: -0.02em; }
.brand__mark {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 700;
  /* logo 是全站两处保留渐变的地方之一（另一处是首屏关键词） */
  background-image: var(--gradient-brand);
  border-radius: var(--radius-md);
}
.brand__text { font-size: var(--text-base); }
.brand__text small { display: block; font-size: 10px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-faint); }

.nav__links { display: flex; align-items: center; gap: var(--space-1); margin-inline-start: auto; }
.nav__link {
  position: relative;
  padding: 0.5em 0.85em;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  transition: color var(--dur) var(--ease-out), background-color var(--dur) var(--ease-out);
}
.nav__link:hover { color: var(--text); background: var(--surface); }
.nav__link[aria-current="true"] { color: var(--text); }
.nav__link[aria-current="true"]::after {
  content: "";
  position: absolute;
  left: 50%; bottom: -2px;
  width: 18px; height: 2px;
  background: var(--accent);
  border-radius: var(--radius-full);
  transform: translateX(-50%);
}
.nav__actions { display: flex; align-items: center; gap: var(--space-2); }

.nav-toggle { display: none; }
.nav-toggle__bars { display: grid; gap: 4px; width: 18px; }
.nav-toggle__bars span { height: 2px; background: currentColor; border-radius: 2px; transition: transform var(--dur) var(--ease-out), opacity var(--dur) var(--ease-out); }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 820px) {
  .nav-toggle { display: inline-flex; }
  /* 移动端导航是 fixed 定位，不占流，需要 actions 自己靠右 */
  .nav__actions { margin-inline-start: auto; }
  .nav__links {
    position: fixed;
    inset: var(--header-h) var(--space-4) auto;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-1);
    padding: var(--space-4);
    background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    opacity: 0;
    /* 收起时必须 visibility: hidden，否则里面的链接依然可以用 Tab 聚焦到
       （opacity/pointer-events 都不影响键盘焦点顺序）。visibility 参与过渡，
       展开时立即可见，收起时等淡出动画结束再隐藏。 */
    visibility: hidden;
    transform: translateY(-10px) scale(0.98);
    pointer-events: none;
    transition:
      opacity var(--dur) var(--ease-out),
      transform var(--dur) var(--ease-out),
      visibility 0s linear var(--dur);
  }
  .nav__links.is-open {
    opacity: 1;
    visibility: visible;
    transform: none;
    pointer-events: auto;
    transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out), visibility 0s;
  }
  .nav__link { padding: 0.75em 1em; font-size: var(--text-base); }
  .nav__link[aria-current="true"]::after { display: none; }
  .nav__link[aria-current="true"] { background: var(--surface); }
}

@media (prefers-reduced-transparency: reduce) {
  .site-header.is-stuck,
  .nav__links {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--bg-elev);
  }
}

@media (max-width: 480px) {
  /* 极窄屏：搜索按钮退化为纯图标 */
  #paletteBtn span:not([aria-hidden="true"]),
  #paletteBtn kbd { display: none; }
  #paletteBtn { width: 42px; padding: 0; justify-content: center; }
}

/* ---------- Hero（紧凑版） ----------
   首屏只承担三件事：说明这是什么、给出搜索入口、把第一排导航卡片留在视口内。
   上下留白从 clamp(4rem, 12vw, 8.5rem) 收到 16–24px，
   标题按 §5.1 收到桌面约 40px / 手机约 28px（原来 --text-4xl 最大 68px）。
   实测 1280×720 第一排卡片完整可见（底边 715px），390×844 可见两排（底边 782px）。 */
.hero { position: relative; padding-block: clamp(1rem, 2.2vw, 1.5rem) clamp(1rem, 2.2vw, 1.5rem); }
.hero__inner { display: grid; gap: var(--space-2); justify-items: center; text-align: center; }
.hero__title { max-width: 26ch; font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.5rem); }
/* 窄屏折行时不要在「常用网站与工具」中间断开，让语义完整地换到下一行 */
.hero__title-lead { white-space: nowrap; }
.hero__desc { margin-top: 0; max-width: 44ch; font-size: var(--text-base); }
.hero__note { font-size: var(--text-xs); }
@media (max-width: 420px) { .hero__title { max-width: 100%; } }

/* 常驻搜索：外观与命令面板一致；点击或输入后由 main.js 打开同一个 #palette，
   这里只负责「看起来可以输入」，不写任何脚本。 */
.hero__search {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  max-width: 560px;
  min-height: 48px;
  padding-inline: var(--space-5);
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition:
    background-color var(--dur) var(--ease-out),
    border-color var(--dur) var(--ease-out),
    box-shadow var(--dur) var(--ease-out);
}
/* 悬停、聚焦与精确指针的悬停只写这一处（13c 起从 motion.css §11 合并过来，顺序保持：悬停 < 聚焦 < 精确指针悬停） */
.hero__search:hover { background: var(--surface-strong); border-color: var(--border-strong); }
.hero__search:focus-within {
  background: var(--surface-strong);
  border-color: var(--accent-line);
  box-shadow: var(--focus-ring), var(--shadow-md);
}
@media (hover: hover) and (pointer: fine) {
  .hero__search:hover { border-color: var(--accent-line); box-shadow: var(--shadow-md); }
}
.hero__search-icon { font-size: var(--text-base); opacity: 0.75; }
.hero__search input {
  flex: 1;
  min-width: 0;
  padding-block: 0.85em;
  font-size: var(--text-base);
  color: var(--text);
  background: none;
  border: 0;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  cursor: text;
}
.hero__search input::placeholder { color: var(--text-faint); }
/* 焦点样式由外层 :focus-within 表达，避免输入框再叠一圈描边 */
.hero__search input:focus-visible { outline: none; }
/* Safari 自带的清除按钮会挤掉右侧 kbd，统一去掉 */
.hero__search input::-webkit-search-cancel-button { display: none; }
.hero__search kbd { flex: 0 0 auto; }
@media (max-width: 480px) {
  .hero__search { min-height: 48px; padding-inline: var(--space-4); }
  .hero__search kbd { display: none; }
}

.hero__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); justify-content: center; }

.code-block {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
}
.code-block code { white-space: nowrap; color: var(--text); }

.stat { padding: var(--space-5); background: var(--bg-elev); text-align: center; }
.stat__value { font-size: var(--text-2xl); font-weight: 700; letter-spacing: -0.03em; }
.stat__label { font-size: var(--text-xs); color: var(--text-faint); letter-spacing: 0.06em; text-transform: uppercase; }

/* ---------- 卡片文本 ---------- */
.feature__icon {
  display: grid;
  place-items: center;
  width: 42px; height: 42px;
  color: var(--accent);
  font-size: 20px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
  border-radius: var(--radius-md);
}
.feature__title { font-size: var(--text-lg); }
.feature__desc { font-size: var(--text-sm); color: var(--text-muted); }

/* ---------- 标签页 ---------- */
.tabs {
  display: flex;
  gap: var(--space-1);
  width: fit-content;          /* 不要把胶囊背景拉满整行 */
  max-width: 100%;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 0.5em 1.05em;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: color var(--dur) var(--ease-out), background-color var(--dur) var(--ease-out);
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); background: var(--bg-elev); box-shadow: var(--shadow-sm); }
.tab-panel[hidden] { display: none; }

/* ---------- 分类筛选（快捷导航） ----------
   按钮由 toolkit.js 渲染进 #siteFilters；容器只负责排布与横向滚动。
   窄屏下必须能横向滚动，否则分类一多就会把整页顶出横向滚动条。 */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  justify-content: space-between;
}
.filters {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--space-2);
  max-width: 100%;
  padding-block: 2px;          /* 给选中态的描边留出空间，避免被滚动容器裁掉 */
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.filter {
  flex: 0 0 auto;
  padding: 0.45em 1em;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  transition:
    color var(--dur) var(--ease-out),
    background-color var(--dur) var(--ease-out),
    border-color var(--dur) var(--ease-out),
    scale var(--dur-slow) var(--ease-spring);   /* 按压回弹（V2.1） */
}
.filter:hover { color: var(--text); border-color: var(--border-strong); }
/* 选中态用 --accent 底。
   注意：--accent-contrast 是 #fff，深色主题下白字压 #8b83ff 只有 3.09:1，
   而胶囊是 13px 小字，需要 4.5:1。所以深色主题改用页面底色 #06070b 作前景（6.51:1），
   浅色主题保持白字（对 #5b4bf0 为 5.66:1）。两套主题都过 WCAG AA。 */
.filter[aria-pressed="true"],
.filter.is-active {
  color: var(--accent-contrast);
  background: var(--accent);
  border-color: var(--accent);
}
[data-theme="dark"] .filter[aria-pressed="true"],
[data-theme="dark"] .filter.is-active { color: var(--bg); }
.filters__meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-xs);
  white-space: nowrap;
}
.filters__manage { font-size: var(--text-xs); font-weight: 600; color: var(--accent); }
.filters__manage:hover { text-decoration: underline; }
@media (max-width: 640px) {
  /* 窄屏：筛选条独占一行，横向滚动；结果数与「管理导航」挪到下一行 */
  .filters-bar { gap: var(--space-2); }
  .filters { width: 100%; }
}

/* ---------- 统计条（工具区与预览用） ---------- */
.stats {
  display: grid;
  gap: 1px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* ---------- 页脚 ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: var(--space-8); padding-block: var(--space-7); }
.footer__grid { display: grid; gap: var(--space-6); grid-template-columns: minmax(220px, 1.4fr) repeat(auto-fit, minmax(140px, 1fr)); }
@media (max-width: 720px) {
  .footer__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
  .footer__grid { grid-template-columns: minmax(0, 1fr); }
}
.footer__title { font-size: var(--text-sm); font-weight: 700; margin-bottom: var(--space-3); }
.footer__list { display: grid; gap: var(--space-2); font-size: var(--text-sm); }
/* 链接左右各留 8px 热区（负外边距抵消，文字位置不变），给滑动高亮（fx.js glide，V2.1）留出底色的位置 */
.footer__list a { display: inline-block; padding: 2px 8px; margin-inline: -8px; border-radius: var(--radius-sm); color: var(--text-muted); transition: color var(--dur) var(--ease-out); }
.footer__list a:hover { color: var(--accent); }
.footer__bottom { display: flex; flex-wrap: wrap; gap: var(--space-4); justify-content: space-between; align-items: center; margin-top: var(--space-6); padding-top: var(--space-5); border-top: 1px solid var(--border); font-size: var(--text-xs); color: var(--text-faint); }

/* ---------- 返回顶部 ---------- */
.back-to-top {
  position: fixed;
  right: clamp(14px, 3vw, 30px);
  bottom: clamp(14px, 3vw, 30px);
  z-index: 90;
  opacity: 0;
  transform: translateY(14px) scale(0.9);
  pointer-events: none;
  transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
}
.back-to-top.is-visible { opacity: 1; transform: none; pointer-events: auto; }

/* ---------- 命令面板（Ctrl/⌘ + K） ---------- */
.palette {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: start center;
  padding: clamp(60px, 12vh, 140px) var(--space-4) var(--space-4);
  /* 全屏遮罩只用半透明黑，不再叠 backdrop-filter：
     全屏模糊每帧都要重算整屏，而 55% 黑色遮罩本身已经足够区分前后景。 */
  background: color-mix(in srgb, #000 55%, transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease-out);
}
.palette.is-open { opacity: 1; pointer-events: auto; }
/* .palette 自己声明了 display: grid，会盖过浏览器对 [hidden] 的默认隐藏：
   关闭后面板只是透明，按 Tab 仍能把焦点送进看不见的输入框，读屏也一直读到它。
   关闭（hidden）时必须真正移出渲染与无障碍树；打开动画由 main.js 先取消 hidden、
   强制一次样式计算、再加 .is-open 来保证。 */
.palette[hidden] { display: none; }
.palette__box {
  width: min(560px, 100%);
  background: color-mix(in srgb, var(--bg-elev) 96%, transparent);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(-12px) scale(0.98);
  transition: transform var(--dur) var(--ease-out);
}
.palette.is-open .palette__box { transform: none; }
.palette__search { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border); }
.palette__search input { flex: 1; background: none; border: 0; outline: none; font-size: var(--text-base); }
.palette__list { max-height: min(52vh, 420px); overflow-y: auto; padding: var(--space-2); }
.palette__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  text-align: left;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.palette__item:hover, .palette__item.is-active { background: var(--surface-strong); color: var(--text); }
.palette__item .badge { margin-left: auto; }
/* 命令图标（06d：SVG）：固定 16px，颜色比文字淡一档，选中时跟文字一起变亮 */
.palette__item .palette__icon { width: 16px; height: 16px; color: var(--text-faint); }
.palette__item:hover .palette__icon, .palette__item.is-active .palette__icon { color: var(--accent); }
.palette__empty { padding: var(--space-5); text-align: center; font-size: var(--text-sm); color: var(--text-faint); }
.palette__hint { display: flex; gap: var(--space-4); padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border); font-size: var(--text-xs); color: var(--text-faint); }

/* ---------- 轻提示 ---------- */
.toast-stack {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 160;
  display: grid;
  gap: var(--space-2);
  width: min(380px, calc(100vw - 32px));
  transform: translateX(-50%);
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  background: color-mix(in srgb, var(--bg-elev) 96%, transparent);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: toast-in var(--dur) var(--ease-out);
}
.toast.is-leaving { animation: toast-out var(--dur) var(--ease-out) forwards; }
.toast__icon { flex: none; width: 16px; height: 16px; color: var(--accent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(0.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px) scale(0.96); } }

/* ---------- 返回顶部 / 通用小工具 ---------- */
.tag-list { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.bg-elev { background: var(--bg-elev); }

/* ---------- 快捷导航卡片：同行等高 ----------
   站点名长短不一（如 "Gemini Notebook" 会折两行），
   标题与说明都固定占两行高度，底部链接贴底，保证一行内卡片高度一致。 */
.site-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.site-card .feature__title,
.site-card .feature__desc {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
/* 标题固定两行高度（"Gemini Notebook" 这类长名不破坏对齐），
   描述保持自然高度：描述多为单行，硬撑两行会留出明显空白。 */
.site-card .feature__title { min-height: 2.36em; }
.site-card__url {
  margin-top: auto;
  font-size: var(--text-xs);
  overflow-wrap: anywhere;
}

/* 快捷导航卡片列数（方案 §4.3）：
   通用 .grid-4 的 auto-fit 在 360px 会滑到一列、390px 又是两列，宽度稍有变化就跳。
   这里按断点写死列数，390px 稳定两列；320–360px 直接一列，
   不靠截断站点名去换列数。 */
#siteGrid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { #siteGrid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 700px) { #siteGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 360px) { #siteGrid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- 首页工具区：把第一排导航卡片顶进首屏 ----------
   #toolkit 只出现在 index.html。原来 .section 的上下留白是 clamp(4rem, 9vw, 7.5rem)，
   1280px 下有 115px，加上标题区与面板间距，第一排卡片被推到 836px，720 高的首屏看不到。
   这里只收首页这一段的纵向节奏，标题层级与内容不变；其它页面不受影响。 */
#toolkit { padding-block: clamp(1rem, 2vw, 1.25rem); }
#toolkit .section-head { margin-bottom: var(--space-2); }
#toolkit .section-title { margin-top: var(--space-1); font-size: var(--text-2xl); }
#toolkit .section-desc { margin-top: var(--space-1); font-size: var(--text-base); }
#panel-nav { margin-top: var(--space-3); }
#siteGrid { margin-top: var(--space-3); }

/* 首页导航卡片更紧凑：卡片内边距与行距收到一档，
   让 1280×720 的首屏能完整看到第一排卡片（原来单卡 216px 高）。 */
#siteGrid .card { padding: var(--space-4) var(--space-4) var(--space-3); }
#siteGrid .feature__icon { width: 34px; height: 34px; font-size: 16px; }
#siteGrid .site-card__url { margin-top: var(--space-2); }
#siteGrid .mt-4 { margin-top: var(--space-2); }
#siteGrid .site-card__url { font-size: var(--text-xs); }

/* 筛选无结果时的空状态（文案由 toolkit.js 填入） */
.site-empty {
  display: grid;
  gap: var(--space-3);
  justify-items: center;
  grid-column: 1 / -1;
  padding: var(--space-6);
  text-align: center;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}

/* ---------- 我的收藏（首页 · 方案 §4 A） ----------
   收藏卡片由 js/toolkit.js 渲染进 #favoritesGrid；这里只管排布与"更紧凑"的呈现。
   与 #siteGrid 的区别：收藏是每天点的那 6–8 个入口，不显示说明与域名，一行能放更多。 */
.favorites {
  padding-block: clamp(0.75rem, 1.6vw, 1.25rem);
}
.favorites__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.favorites__title {
  font-size: var(--text-lg);
  font-weight: 650;
}
.favorites__more {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}
.favorites__more:hover { text-decoration: underline; }
.favorites__grid {
  display: grid;
  gap: var(--space-3);
  /* 桌面一行 6 个、手机 2 个：收藏是"扫一眼就点"，不需要大卡片 */
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
@media (max-width: 1024px) { .favorites__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 700px) { .favorites__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 420px) { .favorites__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* 首屏防偏移（CLS）：收藏区与导航网格由延迟脚本渲染，首帧时还是空的。
   渲染前先按默认内容预留高度（收藏引导一行、默认 16 个站点），否则内容一出现
   就把下面整块往下推——实测首页 CLS 0.35，超过 0.1 的目标。
   只作用于 :empty，渲染后以真实高度为准；默认数据量大幅变化时请同步这里的数值。 */
.favorites__grid:empty { min-height: 50px; }
@media (max-width: 420px) { .favorites__grid:empty { min-height: 97px; } }
#siteGrid:empty { min-height: 765px; }
@media (max-width: 900px) { #siteGrid:empty { min-height: 1140px; } }
@media (max-width: 700px) { #siteGrid:empty { min-height: 1500px; } }
@media (max-width: 420px) { #siteGrid:empty { min-height: 1660px; } }

.fav-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius-md);
}
.fav-card .site-card__head { margin-bottom: 0; }
.fav-card .feature__icon { width: 30px; height: 30px; font-size: 15px; }
.fav-card .feature__title {
  margin-top: 0;
  font-size: var(--text-sm);
  min-height: 0;
  -webkit-line-clamp: 1;
}
.fav-card .feature__desc,
.fav-card .site-card__url { display: none; }

/* 无收藏时的引导：一行说明，不做成大块空状态卡片 */
.favorites__empty {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
}
.favorites__empty strong { color: var(--text); font-weight: 650; }
.favorites__empty span { font-size: var(--text-xs); }

/* ---------- 站点卡片：整卡可点 + 收藏按钮 ----------
   卡片本身不再是 <a>（收藏按钮不能嵌在链接里），改由标题里的
   .site-card__link::after 铺满整张卡，点哪都进站点；收藏按钮 z-index 抬到它上面。 */
.site-card {
  position: relative;
  isolation: isolate;
}
.site-card__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  justify-content: space-between;
}
.site-card__head .badge { margin-inline-start: auto; }
.site-card__link {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.site-card__link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
}
.site-card__link:focus-visible { outline: none; }
.site-card:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* 收藏按钮：44px 触控热区但视觉只有 26px，避免在小卡片里抢注意力 */
.card-fav {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  margin: -6px -6px -6px 0;
  font-size: 15px;
  line-height: 1;
  color: var(--text-faint);
  background: transparent;
  border: 0;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
/* 触控热区：视觉不变，可点范围扩到 44×44 */
.card-fav::before {
  content: "";
  position: absolute;
  inset: -9px;
  border-radius: var(--radius-full);
}
.card-fav:hover { color: var(--accent); background: var(--surface-strong); }
.card-fav:active { transform: scale(0.9); }
.card-fav[aria-pressed="true"] { color: var(--accent); }

/* ---------- 精选资源（首页） ---------- */
.resources-featured .section-head { margin-bottom: var(--space-5); }

/* ---------- 命令面板分组标题 ----------
   js/main.js 按类型分组渲染；组标题不可聚焦、不参与 aria-activedescendant。 */
.palette__group {
  padding: var(--space-3) var(--space-4) var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  text-transform: uppercase;
}
.palette__group:first-child { padding-top: var(--space-2); }



/* ---------- 收藏星标（PR 05：SVG 星形，已收藏时填满） ---------- */
.card-fav .icon { width: 16px; height: 16px; }
.card-fav[aria-pressed="true"] .icon { fill: currentColor; }

/* ---------- 工具类（PR 05：替换页面里的 style="…"） ----------
   放在 layout.css 末尾：它在 components.css 之后加载，同特异性时这里的值生效。
   页面不再写内联样式，CSP 才能在 PR 12 去掉 style-src 'unsafe-inline'。
   只有随数据变化的值（进度、预设色块、取色预览）由脚本经 el.style 写入，CSSOM 不受 CSP 限制。 */
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-4xl { font-size: var(--text-4xl); }
.mt-2 { margin-top: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mx-auto { margin-inline: auto; }
.max-w-360 { max-width: 360px; }
.max-w-34ch { max-width: 34ch; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.cursor-pointer { cursor: pointer; }
.d-block { display: block; }
.scroll-y { overflow-y: auto; }
.max-h-160 { max-height: 160px; }
.max-h-220 { max-height: 220px; }
.max-h-280 { max-height: 280px; }
.max-h-320 { max-height: 320px; }
.is-hidden { display: none !important; }

/* 工具区的状态行：先占一行高度，提示出现时不把下面的内容顶下去 */
.status-line { font-size: var(--text-xs); min-height: 1.4em; }
/* 控件下方的说明文字 */
.hint { margin-top: var(--space-2); font-size: var(--text-xs); color: var(--text-muted); }
/* 带细边框的小块（统计格等） */
.boxed { border: 1px solid var(--border); border-radius: var(--radius-md); }
/* 与上下区块用细线隔开的 section */
.section--bordered { border-block: 1px solid var(--border); }
.textarea--short { min-height: 96px; }
input[type="color"].input--swatch { flex: 0 0 56px; padding: 4px; cursor: pointer; }

/* 多行输出的代码块：块级、可滚动；内边距两档 */
.code-block--scroll { display: block; overflow: auto; }
.code-block--pad-sm { padding: var(--space-3) var(--space-4); }
.code-block--pad-lg { padding: var(--space-5); }
.code-block code.code-wrap { white-space: pre-wrap; word-break: break-all; }
.code-block code.code-pre { white-space: pre; display: block; }

/* 404 页 */
.page-center { min-height: 100dvh; display: grid; place-items: center; padding: var(--space-5); }
.notfound-card { max-width: 560px; padding: clamp(2rem, 6vw, 3.5rem); }

/* 组件库页（components.html）的演示卡片：原来写在 components.js 拼出的 style="…" 里 */
.docs-section__head { margin-bottom: var(--space-4); }
.docs-section__title { font-size: var(--text-2xl); }
.docs-section__desc { font-size: var(--text-base); }
.docs-card { padding: 0; overflow: hidden; }
.docs-card__preview { padding: var(--space-6); display: grid; gap: var(--space-3); }
.docs-card__bar { justify-content: space-between; padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border); background: var(--surface); }
.code-block.docs-card__code { display: block; border: 0; border-radius: 0; border-top: 1px solid var(--border); max-height: 260px; overflow: auto; padding: var(--space-5); }
.hl-tag { color: var(--brand-2); }
.hl-attr { color: var(--accent); }

/* 脚本拼出的 HTML 里原来的 style="…"（PR 05） */
.p-6 { padding: var(--space-6); }
.text-xl { font-size: var(--text-xl); }
.text-left { text-align: left; }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.btn--danger { --btn-fg: var(--danger); }
.icon--down { transform: rotate(180deg); }
/* 表情速取的按钮：44px 触控区 */
.emoji-btn { min-width: 44px; min-height: 44px; padding: 0; font-size: 20px; }
/* 颜色转换的结果行：标签 / 值 / 复制 */
.color-row { justify-content: space-between; gap: var(--space-2); }
.color-row__label { font-size: var(--text-xs); min-width: 84px; }
.color-row__value { flex: 1; overflow-x: auto; }

/* 触屏：顶栏按钮与圆形图标按钮的触控区不小于 44px（WCAG 2.5.5 建议值） */
@media (pointer: coarse) {
  .btn--icon { width: 44px; min-height: 44px; }
  .site-header .btn { min-height: 44px; min-width: 44px; }
}

/* 08 发布：「笔记」入口挂在实验开关 notes 后面（默认开）。<html data-labs> 由 theme-custom.js 首帧前写好，
   关掉开关的访客看不到入口，不会先闪一下再消失。 */
html:not([data-labs~="notes"]) .nav__link--notes,
html:not([data-labs~="notes"]) .footer__notes { display: none; }
