/* ==========================================================================
   搜索页样式
   对齐 CSDN 浏览器助手的「极简壁纸」版新标签页（search-bar-Simple / isSimpleLayout）：
   壁纸铺满 → 居中大时钟 → 深色毛玻璃搜索条 506×44 → 无底卡片的一排站点图标。
   数字是照它 1920×869 的实际画面量的。
   ========================================================================== */

:root {
  /* 品牌与功能色 */
  --brand: #fc5531;
  --link: #1a87ff;
  --link-dark: #0d6fe0;

  /* 面板（抽屉 / 菜单 / 弹层）用的浅色系 */
  --text-1: #222226;
  --text-2: #555666;
  --text-3: #999aaa;
  --text-4: #86909c;
  --line: #e8e8ee;
  --line-strong: #d4d4d4;
  --surface: #ffffff;
  --surface-2: #f5f6f7;
  --surface-3: #e8e8ee;

  /* 压在壁纸上的白色文字 */
  --on-wall: #ffffff;
  --on-wall-2: rgba(255, 255, 255, 0.92);
  --on-wall-3: rgba(255, 255, 255, 0.66);

  /* 毛玻璃：这几个值由 search.js 的 applyGlass() 按设置里的「透明程度」实时改写，
     这里的只是首屏兜底（等于 32%） */
  --glass-chrome: rgba(16, 18, 24, 0.28);
  --glass-chrome-hover: rgba(16, 18, 24, 0.36);
  --glass-panel: rgba(252, 252, 254, 0.66);
  --glass-border: rgba(255, 255, 255, 0.2);
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.28);
  --glass-blur: 28px;
  --glass-sat: 180%;
  /* 时钟字体：苹果设备命中 SF Pro，Windows 命中 Segoe UI Variable（最接近 SF 的可变字体） */
  --clock-font: 'SF Pro Display', -apple-system, BlinkMacSystemFont,
    'Segoe UI Variable Display', 'Segoe UI', 'PingFang SC', 'Microsoft YaHei',
    'Helvetica Neue', sans-serif;
  /* 面板里的控件底：也是半透明的，别在玻璃上糊一层死白 */
  --control-bg: rgba(255, 255, 255, 0.58);
  --control-bg-hover: rgba(255, 255, 255, 0.82);

  /* 布局：搜索条与站点的尺寸跟截图对齐 */
  --search-w: 506px;
  --search-h: 44px;
  --tile: 46px;
  --radius: 8px;
  --shadow-1: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-2: 0 8px 28px rgba(0, 0, 0, 0.18);
  --shadow-3: 0 16px 48px rgba(0, 0, 0, 0.28);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

html[data-theme='dark'] {
  --text-1: rgba(255, 255, 255, 0.9);
  --text-2: rgba(255, 255, 255, 0.74);
  --text-3: rgba(255, 255, 255, 0.5);
  --text-4: rgba(255, 255, 255, 0.42);
  --line: #2f2f31;
  --line-strong: #3a3a3d;
  --surface: #17171a;
  --surface-2: #232324;
  --surface-3: #2a2a2b;
  --control-bg: rgba(255, 255, 255, 0.08);
  --control-bg-hover: rgba(255, 255, 255, 0.14);
}

* {
  box-sizing: border-box;
}

/* 统一兜住 hidden：个别模块的 display 是 grid/flex，不加 !important 会被压过去 */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  /* 页面要能往下滚：第一屏是主舞台，第二屏是往下滚才出现的聚合导航 */
  overflow-x: hidden;
  overflow-y: auto;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--on-wall);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background: #1b2233;
}

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

button {
  border: 0;
  background: none;
  cursor: pointer;
  /* 浏览器默认给 button 加了 1px 6px 内边距，会把里面的图标挤得不居中 */
  padding: 0;
}

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

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

.icon {
  width: 1em;
  height: 1em;
  display: block;
  flex: none;
}

/* --------------------------------------------------------------- 壁纸层 */

.wallpaper,
.wallpaper-mask,
.wallpaper-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.wallpaper {
  z-index: -3;
  background-color: #1b2233;
  background-image: radial-gradient(
      1100px 620px at 18% 12%,
      rgba(120, 170, 255, 0.5),
      transparent 62%
    ),
    radial-gradient(900px 520px at 82% 18%, rgba(56, 96, 190, 0.55), transparent 60%),
    radial-gradient(1200px 700px at 50% 108%, rgba(12, 22, 48, 0.85), transparent 70%),
    linear-gradient(160deg, #24314d 0%, #17203a 52%, #101728 100%);
  background-size: cover;
  background-position: center;
  transition: background-image 0.5s var(--ease), background-color 0.5s var(--ease);
}

.wallpaper.is-image {
  background-size: cover;
}

.wallpaper-mask {
  z-index: -2;
  background: #000;
  opacity: 0.12;
  transition: opacity 0.3s var(--ease);
}

.wallpaper-noise {
  z-index: -1;
  opacity: 0.35;
  background-image: radial-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 3px 3px;
}

/* --------------------------------------------------------------- 角落按钮 */

.topbar {
  position: fixed;
  top: 22px;
  left: 24px;
  right: 26px;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.topbar > * {
  pointer-events: auto;
}

.weather {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 2px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 14px;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.4);
  opacity: 0.9;
  transition: opacity 0.2s var(--ease);
}

.weather:hover {
  opacity: 1;
}

.weather-icon {
  font-size: 15px;
  line-height: 1;
}

.weather-city {
  color: rgba(255, 255, 255, 0.72);
}

.weather-temp {
  font-variant-numeric: tabular-nums;
}

.weather-text {
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
}

/* 页面上唯一的按钮：右下角设置。开满毛玻璃、44 的点击区 */
.corner-btn {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 40;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.88);
  font-size: 18px;
  background: var(--glass-chrome);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight), 0 8px 22px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  transition: background 0.2s var(--ease), color 0.2s var(--ease),
    transform 0.2s var(--ease);
}

.corner-btn:hover {
  color: #fff;
  background: var(--glass-chrome-hover);
  transform: translateY(-1px) rotate(12deg);
}

.corner-btn:active {
  transform: translateY(0) scale(0.96);
}

/* --------------------------------------------------------------- 主舞台 */

.stage {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 60px 24px 90px;
  /* 设置里的「在页面上的位置」：0% 贴顶、50% 居中、100% 贴底 */
  transform: translateY(calc((var(--align, 50) - 50) * 0.62vh));
  transition: transform 0.25s var(--ease);
}

/* 时钟 */

.clock {
  text-align: center;
  animation: rise 0.5s var(--ease) both;
}

/*
 * 字体抄 iOS 锁屏那套：SF Pro Display（苹果设备）→ Segoe UI Variable Display（Win11 的
 * 光学尺寸可变字体，是 Windows 上最接近 SF 的）→ 系统无衬线。
 * 大字号下苹果会收紧字距，所以这里用负 tracking，而不是正的字间距。
 */
.clock-time,
.clock-date {
  font-family: var(--clock-font);
  font-optical-sizing: auto;
  font-variant-numeric: tabular-nums;
}

.clock-time {
  font-size: calc(clamp(52px, 7.2vw, 104px) * var(--clock-scale, 1));
  font-weight: var(--clock-weight, 300);
  line-height: 1.04;
  letter-spacing: -0.015em;
  color: #fff;
  text-shadow: 0 2px 22px rgba(0, 0, 0, 0.32);
}

/* 秒数和主时间同字号，只是稍透明 */
.clock-sec {
  font-size: 1em;
  margin-left: 2px;
  color: rgba(255, 255, 255, 0.86);
  letter-spacing: -0.01em;
}

.clock-date {
  margin-top: 8px;
  /* 日期跟着时钟一起缩放，但幅度小一点，免得放大后压过时间 */
  font-size: calc(clamp(14px, 1.25vw, 22px) * (0.6 + 0.4 * var(--clock-scale, 1)));
  font-weight: 300;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.94);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.34);
}

/* --------------------------------------------------------------- 搜索条 */

.search {
  position: relative;
  z-index: 30;
  width: var(--search-w);
  max-width: 100%;
  margin-top: var(--gap-clock, 24px);
  animation: rise 0.6s var(--ease) both;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  height: var(--search-h);
  border-radius: calc(var(--search-h) / 2);
  background: var(--glass-chrome);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight), 0 10px 34px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  transition: background 0.2s var(--ease), box-shadow 0.2s var(--ease),
    height 0.2s var(--ease);
}

.search-box:hover {
  background: var(--glass-chrome-hover);
}

.search-box:focus-within {
  background: var(--glass-chrome-hover);
  box-shadow: var(--glass-highlight), 0 14px 40px rgba(0, 0, 0, 0.26);
}

.engine {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  height: 100%;
  padding: 0 4px 0 14px;
  flex: none;
  border-radius: calc(var(--search-h) / 2) 0 0 calc(var(--search-h) / 2);
}

.engine-logo {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  overflow: hidden;
}

.caret {
  width: 0;
  height: 0;
  border-top: 6px solid rgba(255, 255, 255, 0.72);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  transition: transform 0.25s var(--ease);
}

.engine[aria-expanded='true'] .caret {
  transform: rotate(180deg);
}

.search-box input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  padding: 0 38px 0 14px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #fff;
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.2px;
}

.search-box input::placeholder {
  color: rgba(255, 255, 255, 0.58);
}

.clear-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
}

.clear-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

/* 搜索引擎菜单 —— 苹果风毛玻璃面板 */
.engine-menu {
  position: absolute;
  top: calc(var(--search-h) + 8px);
  left: 0;
  width: 214px;
  padding: 7px;
  border-radius: 16px;
  background: var(--glass-panel);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight), var(--shadow-3);
  backdrop-filter: blur(calc(var(--glass-blur) + 6px)) saturate(var(--glass-sat));
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) + 6px)) saturate(var(--glass-sat));
  z-index: 50;
  animation: pop 0.18s var(--ease) both;
}

.engine-menu[hidden] {
  display: none;
}

.engine-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--text-1);
  font-size: 14px;
  text-align: left;
}

.engine-item:hover,
.engine-item.is-active {
  background: var(--surface-2);
}

.engine-item .engine-logo {
  width: 22px;
  height: 22px;
  font-size: 12px;
}

.engine-item .name {
  flex: 1 1 auto;
}

.engine-item .hint {
  color: var(--text-3);
  font-size: 12px;
}

/* 联想 / 历史 */

.suggest {
  position: absolute;
  top: calc(var(--search-h) + 8px);
  left: 0;
  right: 0;
  padding: 7px;
  border-radius: 16px;
  background: var(--glass-panel);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight), var(--shadow-3);
  backdrop-filter: blur(calc(var(--glass-blur) + 6px)) saturate(var(--glass-sat));
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) + 6px)) saturate(var(--glass-sat));
  z-index: 45;
  animation: pop 0.18s var(--ease) both;
}

.suggest[hidden] {
  display: none;
}

.suggest-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--text-1);
  font-size: 14px;
  cursor: pointer;
}

.suggest-item .icon {
  color: var(--text-3);
  font-size: 14px;
}

.suggest-item .text {
  flex: 1 1 auto;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.suggest-item .tag {
  color: var(--text-3);
  font-size: 12px;
}

.suggest-item:hover,
.suggest-item.is-active {
  background: var(--surface-2);
}

.suggest-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 28px;
  padding: 0 10px;
  color: var(--text-3);
  font-size: 12px;
}

.suggest-head button {
  color: var(--text-3);
  font-size: 12px;
}

.suggest-head button:hover {
  color: var(--link);
}

/* 热搜条（默认关，设置里可以开） */

.hotwords {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 0 2px;
  font-size: 13px;
  color: var(--on-wall-2);
  animation: rise 0.65s var(--ease) both;
}

.hotwords[hidden] {
  display: none;
}

.hotwords-label {
  flex: none;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(252, 85, 49, 0.9);
  color: #fff;
  font-size: 12px;
}

.hotwords-list {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}

.hotword {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 220px;
  height: 26px;
  padding: 0 11px;
  border-radius: 13px;
  background: var(--glass-chrome);
  border: 1px solid var(--glass-border);
  color: var(--on-wall-2);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.hotword:hover {
  background: var(--glass-chrome-hover);
  color: #fff;
}

.hotword .rank {
  flex: none;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--on-wall-3);
}

.hotword.top .rank {
  color: #ff8a3d;
}

.hotword .txt {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --------------------------------------------------------------- 常用网站 */

.sites {
  margin-top: var(--gap-sites, 46px);
  opacity: var(--site-alpha, 1);
  transition: opacity 0.2s var(--ease);
}

/* 每行几个、间距、行数都来自设置（applyLayout 写这些 CSS 变量） */
.sites-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 7), var(--col-w, 74px));
  column-gap: var(--gap-x, 54px);
  row-gap: var(--gap-y, 26px);
  justify-content: center;
  align-items: start;
}

/* 外层只当定位容器，链接和删除按钮平级（button 塞进 <a> 里是无效嵌套） */
.site {
  position: relative;
  width: var(--col-w, 74px);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: transform 0.18s var(--ease);
}

.site:hover {
  transform: translateY(-2px);
}

.site-link,
.site-add {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  width: 100%;
}

/* 截图里的图标是「裸的」：没有白底卡片，就是站点自己的 favicon */
.site-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--tile, 46px);
  height: var(--tile, 46px);
  border-radius: calc(var(--tile, 46px) * 0.24);
  background: transparent;
  color: #fff;
  font-size: calc(var(--tile, 46px) * 0.39);
  font-weight: 600;
  overflow: hidden;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.32));
  transition: filter 0.2s var(--ease), transform 0.2s var(--ease);
}

.site-icon img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}

/* favicon 真的加载出来了：撤掉色块底，只留图 */
.site-icon.has-img {
  background: transparent !important;
}

.site-icon.has-img .site-letter {
  display: none;
}

.site-letter {
  font-size: calc(var(--tile, 46px) * 0.33);
  line-height: 1;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.92);
}

/* 拉不到 favicon 时的兜底：色块 + 首字 */
.site-icon.is-letter {
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(10px);
  filter: none;
}

.site:hover .site-icon {
  transform: scale(1.04);
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.4));
}

.site-name {
  width: 100%;
  text-align: center;
  font-size: 12.5px;
  line-height: 1.2;
  color: rgba(255, 255, 255, 0.92);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
}

.site-del {
  position: absolute;
  top: -7px;
  right: 8px;
  display: none;
  place-items: center;
  justify-items: center;
  width: 20px;
  height: 20px;
  /* 图标按钮一律自己居中：浏览器默认 padding + 行高都会把图形挤偏 */
  padding: 0;
  line-height: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.68);
  color: #fff;
  z-index: 3;
}

.site-del .icon {
  width: 12px;
  height: 12px;
}

.site:hover .site-del {
  display: grid;
}

.site-del:hover {
  background: var(--brand);
}

.site-add .site-icon {
  background: rgba(255, 255, 255, 0.1);
  border: 1px dashed rgba(255, 255, 255, 0.42);
  filter: none;
  color: rgba(255, 255, 255, 0.8);
}

/* 文件夹：毛玻璃方块，里面 2×2 堆叠前四个图标 */
.site-icon.is-folder {
  background: var(--glass-chrome);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight), 0 6px 18px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  filter: none;
  padding: 6px;
}

.folder-mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 3px;
  width: 100%;
  height: 100%;
}

.folder-mini {
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.16);
  font-size: 9px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.92);
}

.folder-mini img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}

.folder-mini.has-img {
  background: transparent;
}

/* 图加载出来了就必须把兜底的字藏掉，否则透明底 favicon 会跟字叠在一起 */
.folder-mini.has-img .folder-mini-letter {
  display: none;
}

.folder-mini-letter {
  font-size: calc(var(--tile, 46px) * 0.2);
  line-height: 1;
  letter-spacing: 0;
}

/* 拖动：正在拖的原件淡掉，落点用玻璃高亮环提示 */
.site.is-dragging {
  opacity: 0.35;
}

.site.drop-merge .site-icon {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9), 0 10px 24px rgba(0, 0, 0, 0.3);
  transform: scale(1.06);
}

.site.drop-before::before,
.site.drop-after::after {
  content: '';
  position: absolute;
  top: 2px;
  bottom: 22px;
  width: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.4);
}

.site.drop-before::before {
  left: -14px;
}

.site.drop-after::after {
  right: -14px;
}

/* 拖动时跟着指针的幽灵 */
.drag-ghost {
  position: fixed;
  z-index: 200;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1.06);
  opacity: 0.92;
  filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.4));
}

/* 分页点 */
.site-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 18px;
}

.site-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.34);
  transition: background 0.2s var(--ease), transform 0.2s var(--ease);
}

.site-dot:hover {
  background: rgba(255, 255, 255, 0.6);
}

.site-dot.active {
  background: #fff;
  transform: scale(1.25);
}

/* ------------------------------------------------------------ 文件夹弹层 */

.folder-pop {
  position: fixed;
  z-index: 85;
  width: 440px;
  max-width: calc(100vw - 24px);
  padding: 16px 18px 18px;
  border-radius: 24px;
  background: var(--glass-panel);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight), var(--shadow-3);
  backdrop-filter: blur(calc(var(--glass-blur) + 10px)) saturate(var(--glass-sat));
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) + 10px)) saturate(var(--glass-sat));
  animation: pop 0.18s var(--ease) both;
}

.folder-pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 0 4px;
  color: var(--text-2);
  font-size: 15px;
}

.folder-pop-close {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: var(--text-3);
  font-size: 12px;
}

.folder-pop-close:hover {
  background: var(--surface-2);
  color: var(--text-1);
}

.folder-pop-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px 10px;
}

.folder-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 2px 4px;
  border-radius: 12px;
  transition: background 0.2s var(--ease);
}

.folder-item:hover {
  background: rgba(255, 255, 255, 0.14);
}

.folder-item .site-icon {
  width: calc(var(--tile, 46px) * 1.4);
  height: calc(var(--tile, 46px) * 1.4);
  border-radius: 16px;
  filter: none;
  font-size: calc(var(--tile, 46px) * 0.44);
}

.folder-item .site-icon.is-letter {
  background: var(--surface-3);
}

.folder-item .site-letter {
  color: var(--text-1);
  font-size: 13px;
}

.folder-item .site-name {
  color: var(--text-1);
  font-size: 11.5px;
  text-shadow: none;
}

.folder-item .site-del {
  display: none;
  top: 0;
  right: 2px;
}

.folder-item:hover .site-del {
  display: grid;
}

/* ------------------------------------------------------- 聚合导航（第二屏） */

.aggregator {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 96px 24px 120px;
  /* 没下滑时整块是隐藏的，滚过阈值才淡入 */
  opacity: 0;
  transform: translateY(26px);
  pointer-events: none;
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}

.aggregator.is-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.agg-inner {
  width: min(1180px, 100%);
}

.agg-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 20px;
  padding: 0 4px;
}

.agg-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.agg-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
  align-items: start;
}

/*
 * 聚合卡片的底：**故意不加 backdrop-filter**。
 * 滚动时 Chromium 不会对 backdrop 重新采样，卡片的毛玻璃会先变透明、停下来再糊上，
 * 就是「一滚就透、停住又模糊」那个抖动。第二屏背景本来就没什么细节，直接半透明更好。
 */
.agg-card {
  padding: 18px 18px 20px;
  border-radius: 20px;
  background: var(--glass-chrome);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 16px 40px rgba(0, 0, 0, 0.22);
}

.agg-card h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
}

.agg-title-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.agg-card h3 .agg-count {
  font-size: 12px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.5);
  font-variant-numeric: tabular-nums;
}

.agg-card h3 .agg-title {
  font-size: 14px;
  font-weight: 500;
  color: #fff;
}

/* 每栏右上角的加号 */
.agg-plus {
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--glass-border);
  transition: background 0.2s var(--ease), transform 0.2s var(--ease);
}

.agg-plus:hover {
  background: rgba(255, 255, 255, 0.24);
  transform: rotate(90deg);
}

/* 点 + 后展开的那一行（名称 / 网址 / 加） */
.agg-add-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr auto;
  gap: 6px;
  margin-top: 12px;
}

.agg-add-row[hidden] {
  display: none;
}

.agg-input {
  height: 30px;
  background: rgba(0, 0, 0, 0.24);
  border-color: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 12px;
}

.agg-input::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

.agg-add-row .btn {
  height: 30px;
  padding: 0 12px;
}

.agg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 12px 8px;
}

.agg-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 6px 2px;
  border-radius: 12px;
  transition: background 0.2s var(--ease), transform 0.2s var(--ease);
}

/* 外面套一层做定位：叉叉要和 <a> 平级，button 塞进 a 里是无效嵌套 */
.agg-cell {
  position: relative;
  display: flex;
}

.agg-cell .agg-item {
  flex: 1 1 auto;
}

.agg-cell .site-del {
  top: -4px;
  right: 0;
}

.agg-cell:hover .site-del {
  display: grid;
}

.agg-item:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
}

.agg-item .site-icon {
  width: calc(var(--tile, 46px) * 0.84);
  height: calc(var(--tile, 46px) * 0.84);
  border-radius: 10px;
  filter: none;
}

.agg-item .site-letter {
  font-size: calc(var(--tile, 46px) * 0.27);
}

.agg-item .site-name {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.9);
  /* 卡片不做模糊了，名字靠自己的一层阴影压住壁纸 */
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
}

/* 设置里的聚合编辑器 */
.agg-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.agg-editor-group {
  padding: 10px 12px 12px;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: var(--control-bg);
}

.agg-editor-group > b {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-1);
}

.agg-editor-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.agg-add-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.agg-add-form .select,
.agg-add-form .btn {
  grid-column: span 2;
}

/* 设置里的两列滑杆 */
.mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

.mini-grid .field {
  margin-bottom: 16px;
}

.val {
  float: right;
  font-weight: 400;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------- 抽屉 */

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 80;
  width: 388px;
  max-width: 92vw;
  display: flex;
  flex-direction: column;
  background: var(--glass-panel);
  border-left: 1px solid var(--glass-border);
  color: var(--text-1);
  box-shadow: var(--glass-highlight), var(--shadow-3);
  backdrop-filter: blur(calc(var(--glass-blur) + 10px)) saturate(var(--glass-sat));
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) + 10px)) saturate(var(--glass-sat));
  transform: translateX(102%);
  transition: transform 0.32s var(--ease);
  visibility: hidden;
}

.drawer.is-open {
  transform: translateX(0);
  visibility: visible;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 46px;
  padding: 0 15px;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
  font-weight: 500;
}

.drawer-close {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--text-2);
  font-size: 15px;
}

.drawer-close:hover {
  background: var(--surface-2);
}

.drawer-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
}

.drawer-tabs button {
  flex: 1 1 0;
  height: 42px;
  color: var(--text-2);
  font-size: 14px;
  border-bottom: 2px solid transparent;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.drawer-tabs button:hover {
  color: var(--text-1);
}

.drawer-tabs button.active {
  color: var(--link);
  border-bottom-color: var(--link);
}

.drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px 18px 30px;
}

.drawer-body::-webkit-scrollbar {
  width: 6px;
}

.drawer-body::-webkit-scrollbar-thumb {
  border-radius: 3px;
  background: var(--surface-3);
}

.pane[hidden] {
  display: none;
}

.field {
  margin-bottom: 22px;
}

.field-label {
  display: block;
  margin-bottom: 10px;
  color: var(--text-2);
  font-size: 13px;
}

.field-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.muted {
  color: var(--text-3);
  font-size: 13px;
}

.segmented {
  display: flex;
  padding: 3px;
  border-radius: 8px;
  background: var(--surface-2);
}

.segmented button {
  flex: 1 1 0;
  height: 30px;
  border-radius: 6px;
  color: var(--text-2);
  font-size: 13px;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.segmented button.active {
  background: var(--control-bg-hover);
  color: var(--text-1);
  box-shadow: var(--shadow-1);
}

.select,
.input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: var(--control-bg);
  color: var(--text-1);
  font-size: 13px;
  outline: none;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.select:focus,
.input:focus {
  border-color: var(--link);
  background: var(--control-bg-hover);
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-1);
  font-size: 13px;
  cursor: pointer;
}

.check input {
  width: 15px;
  height: 15px;
  accent-color: var(--link);
}

.btn {
  height: 32px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  background: var(--control-bg);
  color: var(--text-1);
  font-size: 13px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease),
    background 0.2s var(--ease), transform 0.2s var(--ease);
}

.btn:hover {
  background: var(--control-bg-hover);
  border-color: var(--link);
  color: var(--link);
}

.btn.primary {
  border-color: var(--link);
  background: var(--link);
  color: #fff;
}

.btn.primary:hover {
  background: var(--link-dark);
  color: #fff;
}

.color {
  width: 44px;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.file {
  width: 100%;
  font-size: 12px;
  color: var(--text-2);
}

.range {
  width: 100%;
  accent-color: var(--link);
}

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

.tool {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control-bg);
  text-align: left;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease);
}

.tool:hover {
  border-color: var(--link);
  transform: translateY(-1px);
}

.tool strong {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-1);
}

.tool span {
  font-size: 12px;
  color: var(--text-3);
}

.drawer-foot {
  margin: 26px 0 0;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.8;
}

.pane-hint {
  margin: 0 0 14px;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.7;
}

/* 站点列表 */

.site-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.site-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: var(--control-bg);
}

.site-row .badge {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 7px;
  background: var(--surface-3);
  color: var(--text-1);
  font-size: 12px;
  font-weight: 600;
}

.site-row .meta {
  flex: 1 1 auto;
  min-width: 0;
}

.site-row .meta b {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-1);
}

.site-row .meta small {
  display: block;
  color: var(--text-3);
  font-size: 11px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  color: var(--text-3);
  font-size: 13px;
}

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

.icon-btn.danger:hover {
  background: #fff1f0;
  color: var(--brand);
}

/* 设置里的文件夹子项 */
.folder-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -4px 0 12px 36px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 4px 0 9px;
  border-radius: 12px;
  background: var(--control-bg);
  color: var(--text-2);
  font-size: 12px;
}

.chip-x {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  color: var(--text-3);
  font-size: 10px;
}

.chip-x:hover {
  background: var(--surface-3);
  color: var(--brand);
}

.site-add-form {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: 8px;
  margin-bottom: 12px;
}

/* 壁纸色板 */

.swatches {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.swatch {
  height: 54px;
  border-radius: 8px;
  border: 2px solid transparent;
  background-size: cover;
  background-position: center;
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease);
}

.swatch:hover {
  transform: translateY(-2px);
}

.swatch.active {
  border-color: var(--link);
}

/* --------------------------------------------------------------- 弹层 / toast */

.drawer-mask {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(0, 0, 0, 0.3);
}

.drawer-mask[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(2px);
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: 620px;
  max-width: 100%;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: var(--glass-panel);
  border: 1px solid var(--glass-border);
  color: var(--text-1);
  box-shadow: var(--glass-highlight), var(--shadow-3);
  backdrop-filter: blur(calc(var(--glass-blur) + 10px)) saturate(var(--glass-sat));
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) + 10px)) saturate(var(--glass-sat));
  animation: pop 0.2s var(--ease) both;
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 46px;
  padding: 0 14px 0 18px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
  font-weight: 500;
}

.modal-body {
  padding: 16px 18px 20px;
  overflow: auto;
}

.modal-body textarea {
  width: 100%;
  min-height: 160px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control-bg);
  color: var(--text-1);
  font-family: 'JetBrains Mono', Consolas, 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.7;
  resize: vertical;
  outline: none;
}

.modal-body textarea:focus {
  border-color: var(--link);
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.modal-result {
  margin-top: 12px;
  color: var(--text-3);
  font-size: 12px;
  word-break: break-all;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 42px;
  z-index: 120;
  transform: translateX(-50%);
  max-width: 80vw;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 13px;
  animation: pop 0.2s var(--ease) both;
}

.toast[hidden] {
  display: none;
}

.noscript {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: #17171a;
  color: #fff;
  font-size: 15px;
}

/* --------------------------------------------------------------- 动画 */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* --------------------------------------------------------------- 响应式 */

@media (max-width: 900px) {
  :root {
    --tile: 42px;
    --col-w: 62px;
  }

  .stage {
    padding: 70px 18px 90px;
  }

  .hotwords {
    overflow: hidden;
  }

  .topbar {
    top: 14px;
    left: 16px;
    right: 16px;
  }

  .weather-text {
    display: none;
  }
}

/* 矮屏（比如笔记本 768 高）把时钟压小一点，别把图标挤出屏幕。
   注意这里仍然乘 --clock-scale，否则设置里的「时钟大小」在小屏上会失效。 */
@media (max-height: 700px) {
  .clock-time {
    font-size: calc(clamp(40px, 6vw, 64px) * var(--clock-scale, 1));
  }

  .clock-date {
    font-size: calc(14px * (0.6 + 0.4 * var(--clock-scale, 1)));
  }

  .stage {
    gap: 0;
    padding: 56px 24px 70px;
  }
}
