/* ============================================================
   Nav · 导航  —  浅色为主 / 深色可切换
   ============================================================ */

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f2f3f5;
  --surface-3: #e8eaed;
  --text: #1f2329;
  --text-2: #646a73;
  --text-3: #8f959e;
  --border: #e5e6eb;
  --border-strong: #d8dadf;
  --accent: #1f5fd0;
  --accent-hover: #1a51b5;
  --accent-weak: rgba(31, 95, 208, 0.08);
  --danger: #d54941;
  --danger-weak: rgba(213, 73, 65, 0.08);
  --shadow-sm: 0 1px 2px rgba(31, 35, 41, 0.05);
  --shadow-md: 0 4px 16px rgba(31, 35, 41, 0.08);
  --shadow-lg: 0 12px 40px rgba(31, 35, 41, 0.16);
  --topbar-bg: rgba(255, 255, 255, 0.82);
  --ring: 0 0 0 3px rgba(31, 95, 208, 0.14);
}

html[data-theme="dark"] {
  --bg: #131519;
  --surface: #1b1e23;
  --surface-2: #24272d;
  --surface-3: #2d3138;
  --text: #e6e8eb;
  --text-2: #a2a8b0;
  --text-3: #6e747d;
  --border: #2d3138;
  --border-strong: #3a3f47;
  --accent: #4c82e8;
  --accent-hover: #5d8fec;
  --accent-weak: rgba(76, 130, 232, 0.16);
  --danger: #e06860;
  --danger-weak: rgba(224, 104, 96, 0.14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
  --topbar-bg: rgba(19, 21, 25, 0.82);
  --ring: 0 0 0 3px rgba(76, 130, 232, 0.22);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

[hidden] { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

::selection { background: var(--accent-weak); }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 顶栏 ============ */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: transparent;
  z-index: 100;
}

.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.icon-btn {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* 主题按钮图标切换 */
html[data-theme="light"] .i-sun { display: none; }
html[data-theme="dark"] .i-moon { display: none; }

.user-area { position: relative; }
.user-btn {
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 10px 0 6px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text);
  transition: background .15s, border-color .15s;
}
.user-btn:hover { background: var(--surface-2); }
.user-avatar {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}
.user-name { font-size: 13px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.user-menu {
  position: absolute;
  top: calc(100% + 8px); right: 0;
  min-width: 148px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 6px;
  display: none;
  z-index: 200;
}
.user-menu.open { display: block; animation: pop .16s ease-out; }
.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  font-size: 13px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
}
.menu-item:hover { background: var(--surface-2); }
.menu-item.danger { color: var(--danger); }
.menu-divider { border: none; border-top: 1px solid var(--border); margin: 6px 4px; }

/* ============ 三屏切换 ============ */
.pages {
  position: fixed;
  inset: 0;
  overflow: hidden;
}
.pages-track {
  height: 100%;
  transition: transform .42s cubic-bezier(.25, .59, .3, 1);
  will-change: transform;
}
.page {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 76px 24px 58px;
}
/* 合并页（搜索+导航）：搜索框在上，导航面板紧随其下，一页完整显示 */
.page-search {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start; /* 顶部锚定：面板显示/收起时搜索区位置不变 */
  height: 100vh;
  padding: 76px 24px 24px;
  overflow: hidden;
}
.page-search .panel {
  /* 固定尺寸：宽高比恒为黄金比例 1.618 : 1（高度自动扣除搜索区占用的 17vh；
     309px = 顶部内边距 76 + 搜索区内容 + 面板上边距 44 + 底部内边距 24，改动上边距需同步此值）
     1120px 为宽度上限：视口允许时面板放大到该上限，比例与防溢出由后两个 min 项保证 */
  width: min(1120px, calc(100vw - 48px), calc((100vh - 309px - 17vh) * 1.618));
  height: min(calc(min(1120px, 100vw - 48px) / 1.618), calc(100vh - 309px - 17vh));
  margin-top: 44px;
  flex: 0 0 auto;
  /* 默认隐藏：首次滚轮/触摸下滑后淡入；background-color 供导航⇄资讯面板底色淡入淡出 */
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px);
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease, visibility 0s linear .25s, background-color .3s ease, backdrop-filter .3s ease;
}
.page-search.panel-open .panel {
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
  transition: opacity .25s ease, transform .25s ease, visibility 0s, background-color .3s ease, backdrop-filter .3s ease;
}
/* 聚焦搜索框输入时淡出隐藏（失焦淡入恢复） */
.page-search.panel-open.input-focused .panel {
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s, background-color .3s ease, backdrop-filter .3s ease;
}

/* ============ 第一屏：搜索 ============ */
.search-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(680px, 100%);
  flex: none;
  margin-top: 17vh; /* 搜索图标与搜索框距顶位置（与下方面板尺寸公式中的 17vh 联动） */
}
.greeting { text-align: center; }
.engine-switch { position: relative; display: flex; flex-direction: column; align-items: center; min-height: 52px; }
.engine-current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 102px;
  padding: 0 12px;
  border: none;
  border-radius: 20px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: background .15s, transform .15s;
}
.engine-current:hover {
  transform: translateY(-1px);
}
/* 引擎图标滚动容器（滚轮/点击切换时的卷帘动画） */
.engine-roller {
  display: block;
  height: 66px;
  overflow: hidden;
}
.engine-roller img {
  display: block;
  height: 66px;
  width: auto;
  pointer-events: none;
}
/* 切换时的引擎名称小标签 */
.engine-name-hint {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  padding: 3px 10px;
  font-size: 12px;
  color: #fff;
  background: rgba(22, 25, 31, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity .2s ease;
}
.engine-name-hint.show { opacity: 1; }
/* 点击当前引擎 → 克隆层从图标位置放大为黑色毛玻璃选择卡片（iOS 风格） */
.engine-zoom-clone {
  position: fixed;
  z-index: 9999;
  overflow: hidden;
  pointer-events: none;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  will-change: left, top, width, height, border-radius, background-color;
  backface-visibility: hidden;
}
.engine-zoom-clone.show { pointer-events: auto; }
/* 当前引擎图形：绝对定位居中，不参与卡片高度 */
.engine-zoom-art {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.engine-zoom-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: center;
  justify-content: center;
  gap: 8px 6px;
  padding: 10px 12px;
  opacity: 0;
  transition: opacity .2s ease;
}
.engine-zoom-clone.show .engine-zoom-grid { opacity: 1; }
.engine-zoom-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
  transition: transform .13s cubic-bezier(.4, 0, .2, 1), background .15s, border-color .15s;
}
.engine-zoom-item:hover { background: rgba(255, 255, 255, 0.16); }
.engine-zoom-item:active { transform: scale(.92); }
.engine-zoom-item img {
  display: block;
  width: 54px;
  height: 18px;
  object-fit: contain;
  pointer-events: none;
}
.engine-zoom-item.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--ring); }
/* 选择引擎时：轻微按下 → 弹性回弹 → 微幅收敛（果冻感，段间速度连续不生硬） */
@keyframes enginePop {
  0%   { transform: scale(1);    animation-timing-function: cubic-bezier(.33, 0, .4, 1); }
  26%  { transform: scale(.87);  animation-timing-function: cubic-bezier(.3, 0, .26, 1); }
  58%  { transform: scale(1.06); animation-timing-function: cubic-bezier(.3, 0, .3, 1); }
  79%  { transform: scale(.98);  animation-timing-function: cubic-bezier(.3, 0, .3, 1); }
  100% { transform: scale(1); }
}
.engine-zoom-item.pop {
  animation: enginePop .5s cubic-bezier(.3, 0, .4, 1) both;
}
/* 引擎选择卡片关闭落位后：当前引擎图标淡入 */
@keyframes rollerFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.engine-roller.fade-in { animation: rollerFade .32s ease both; }

.chip {
  padding: 6px 16px;
  font-size: 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  transition: all .15s;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active {
  color: var(--accent);
  border-color: var(--accent);
  background: #fff; /* 选中态白底 */
  font-weight: 500;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  margin-top: 9px;
  height: 54px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 8px 0 0;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  margin-top: 2px; /* 视觉上下移，与文字基线对齐 */
  transform: translateY(-50%);
  color: var(--text-3);
  flex: none;
  pointer-events: none;
  overflow: visible;
  transition: transform .35s cubic-bezier(.65, 0, .35, 1) .15s;
}
/* 聚焦：图标边收缩边右滑 11px，使收缩点正好落在光标位置(42px) */
.search-box:focus-within .search-icon { transform: translateY(-50%) translateX(11px); }
/* 镜片：周长 2π×7 ≈ 44；右边缘固定，聚焦时收缩为一个点 */
.search-box .lens {
  stroke-dasharray: 44;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset .35s cubic-bezier(.65, 0, .35, 1) .15s;
}
/* 镜柄：长度 ≈ 4.53；外端固定，聚焦时先缩短消失 */
.search-box .handle {
  stroke-dasharray: 4.53;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset .25s cubic-bezier(.65, 0, .35, 1);
}
.search-box:focus-within .handle { stroke-dashoffset: -4.53; }
.search-box:focus-within .lens { stroke-dashoffset: 44; }

/* 聚焦动画时序
   0ms    镜柄从外端向镜片端缩短 → 250ms 消失
   150ms  镜片从右边缘向圆心收缩 → 500ms 归零
   500ms  假光标从收缩点上下展开 → 750ms
   850ms  光标开始闪烁 */

/* 假光标：从镜片收缩点展开；输入内容后交给系统光标 */
.search-caret {
  position: absolute;
  left: 42px;
  top: 50%;
  width: 2px;
  height: 18px;
  margin-top: -9px;
  border-radius: 1px;
  background: var(--accent);
  opacity: 0;
  transform: scaleY(0);
  transform-origin: center;
  pointer-events: none;
  transition: transform .2s ease, opacity .15s ease;
}
.search-box:focus-within .search-caret {
  opacity: 1;
  transform: scaleY(1);
  transition: transform .25s cubic-bezier(.34, 1.3, .64, 1) .5s, opacity .15s ease .5s;
  animation: searchBlink 1.05s step-end .85s infinite;
}
@keyframes searchBlink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}
#searchInput {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: 16px;
  color: var(--text);
  padding: 0 14px 0 42px;
  caret-color: transparent;
}
#searchInput::placeholder { color: var(--text-3); }
.search-go {
  flex: none;
  height: 40px;
  padding: 0 24px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  transition: background .15s;
}
.search-go:hover { background: var(--accent-hover); }

.sug-list {
  position: absolute;
  top: calc(100% + 8px); left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 6px;
  display: none;
  z-index: 50;
}
.sug-list.open { display: block; }
.sug-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 14px 9px 36px; /* 左 36px 使文字与搜索框内文字起点(43px)对齐 */
  font-size: 14px;
  border: none;
  background: transparent;
  border-radius: 8px;
  color: var(--text);
}
.sug-item:hover, .sug-item.active { background: var(--surface-2); }
.sug-item b { color: var(--accent); font-weight: 600; }

/* ============ 集成面板（导航 / 资讯 双视图） ============ */
.panel {
  width: min(1060px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  padding: 18px 22px 14px;
}
/* 面板内的内容视图：同一 .panel 在导航/资讯间切换 */
.panel-view {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.panel-view[hidden] { display: none; }
.panel-view:not([hidden]) { animation: fade .2s ease-out; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.panel-title { margin: 0; font-size: 17px; font-weight: 600; }
.panel-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
/* 导航面板底部操作栏：分类筛选 + 添加按钮（资讯视图的操作栏在头部，不套用） */
.page-search .view-nav .panel-actions {
  justify-content: flex-start; /* 添加按钮跟随在分类标签之后（左侧末尾） */
  padding: 12px 0 0;
  border-top: 1px solid var(--border);
}
.page-search .view-nav .panel-actions .add-tile-btn { margin-left: 6px; }
.cat-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-tabs .chip { padding: 4px 13px; font-size: 12.5px; }
.news-updated { font-size: 12px; color: var(--text-3); }

.scrollable { overflow-y: auto; overscroll-behavior: contain; }

.empty-tip {
  padding: 40px 0;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

/* ============ 第二屏：收藏 ============ */
.sites-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 2px 6px;
  flex: 1 1 auto;
  min-height: 0;
}
.site-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 16px 12px;
}
.site-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 8px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, transform .15s;
  cursor: pointer;
}
.site-card:hover { background: var(--surface-2); border-color: var(--border); }
.site-card.dragging { opacity: 0.35; }
.site-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  object-fit: contain;
  background: var(--surface-2);
  padding: 4px;
}
/* 深色模式下图标底衬白色，保证浅色 logo 可见 */
html[data-theme="dark"] .site-icon { background: #f5f6f7; }
.site-letter {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
}
.site-name {
  font-size: 12.5px;
  color: var(--text-2);
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.site-card:hover .site-name { color: var(--text); }
.card-actions {
  position: absolute;
  top: 4px; right: 4px;
  display: none;
  gap: 2px;
}
.card-actions .icon-btn { width: 24px; height: 24px; border-radius: 6px; color: var(--text-3); }
.card-actions .icon-btn:hover { color: var(--text); background: var(--surface-3); }
.card-actions .icon-btn.del:hover { color: var(--danger); background: var(--danger-weak); }

/* 面板右键菜单 */
.panel-ctx-menu {
  position: fixed;
  z-index: 1200;
  min-width: 168px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  display: none;
}
.panel-ctx-menu.open { display: block; animation: fade .12s ease-out; }
.panel-ctx-menu .ctx-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  font-size: 13px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.panel-ctx-menu .ctx-item:hover { background: var(--surface-2); }
/* 可勾选功能项：使能时右侧显示 ✓ */
.panel-ctx-menu .ctx-item.on::after {
  content: '✓';
  float: right;
  color: var(--accent);
  font-weight: 600;
}
/* 网格对齐（snap）：空档占位格 + 拖动吸附目标 + 跟随指针的图标影子 */
.grid-hole { border-radius: 12px; min-height: 96px; }
/* 编辑模式下显示空档位置（浅虚线），便于看清格位 */
.page-search .panel.editing .site-grid[data-mode="snap"] .grid-hole {
  border: 1px dashed var(--border);
  opacity: .7;
}
/* 拖动吸附目标：相当于 Windows「将图标与网格对齐」的落点提示 */
.site-grid .snap-target {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
  border-radius: 12px;
  background: var(--accent-weak);
}
.grid-hole.snap-target { border-color: transparent; opacity: 1; }
/* 拖动中跟随指针的图标影子（松手后飞向落点并淡出）
   影子是 .site-card 的克隆，必须显式关掉卡片自带的 transform 过渡：
   否则每次 pointermove 都会重新开始一段 150ms 缓动，图标始终落在指针后面（不跟手）。 */
.drag-ghost {
  position: fixed;
  left: 0; top: 0;
  z-index: 1400;
  pointer-events: none;
  border-radius: 12px;
  border: 1px solid var(--accent);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  opacity: .92;
  transform-origin: top left;
  transition: none;
  will-change: transform;
}
.drag-ghost.settling { transition: transform .18s cubic-bezier(.22, .61, .25, 1), opacity .18s ease; }
.drag-ghost .card-actions { display: none; }
body.card-dragging, body.card-dragging * { cursor: grabbing !important; }

/* 功能项与「进入/退出编辑模式」之间的分隔线（仅编辑模式显示时） */
.panel-ctx-menu .ctx-item[data-act="auto-arrange"]:not([hidden]) {
  margin-top: 4px;
  border-top: 1px solid var(--border);
}

/* 编辑模式：图标常显编辑/删除按钮、可拖动（拖动方式见右键菜单的排列项） */
.page-search .panel.editing { border-style: dashed; }
.page-search .panel.editing .site-card {
  cursor: grab;
  border-color: var(--border);
  user-select: none;               /* 拖动排序时不产生文本/图片选中 */
  -webkit-user-drag: none;
}
.page-search .panel.editing .site-card:active { cursor: grabbing; }
/* 网格对齐：按格位排列，内容顶到上方 */
.site-grid[data-mode="snap"] { align-content: start; }
/* 自由摆放（pixel）：卡片绝对定位，网格高度由脚本按内容设置 */
.site-grid[data-mode="pixel"] { position: relative; align-content: start; }
.site-grid[data-mode="pixel"] > .site-card { position: absolute; }
/* 自由摆放时被拖走的图标留一个更淡的残影（图标本体已随指针移动） */
.site-grid[data-mode="pixel"] > .site-card.dragging { opacity: .12; }
/* 拖动时鼠标压过的图标会触发 :hover 白底，编辑模式下抑制（含被拖动图标自身） */
.page-search .panel.editing .site-card:hover { background: transparent; }
.page-search .panel.editing .site-card:hover .site-name { color: var(--text-2); }
/* 占位卡不受抑制影响，保留主题色 hover */
.page-search .panel.editing .site-card.add-tile:hover { background: var(--accent-weak); }
.page-search .panel.editing .card-actions { display: flex; }
.card-actions svg { width: 13px; height: 13px; }

/* 编辑模式：网格末尾「添加导航」占位卡 */
.add-tile {
  justify-content: center;
  background: transparent;
  font: inherit;
  border: 1.5px dashed var(--border-strong);
  color: var(--text-3);
}
.page-search .panel.editing .add-tile { cursor: pointer; }
/* 占位卡内的方形图标区：与 .site-icon 的尺寸完全一致（40×40，含 4px 内边距由 box-sizing 统一），
   使占位卡宽高与普通图标卡严格对齐，任何布局模式下都不会与图标「不一样大」 */
.add-tile-mark {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: grid; place-items: center;
  border: 1px dashed var(--border-strong);
  color: inherit;
}
.add-tile:hover .add-tile-mark { border-color: var(--accent); }
.add-tile:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-weak);
}
/* 底部操作栏：与占位卡同风格的「添加导航」按钮 */
.btn.add-tile-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text-3);
}
.btn.add-tile-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-weak);
}

/* 编辑模式：底部操作栏的分类标签同样可编辑（重命名/删除） */
.chip-wrap { position: relative; display: inline-flex; }
.chip-actions {
  position: absolute;
  top: -8px; right: -8px;
  display: none;
  gap: 2px;
  z-index: 2;
}
.page-search .panel.editing .chip-actions { display: flex; }
/* 编辑模式：分类标签可拖动排序 */
.page-search .panel.editing .chip-wrap,
.page-search .panel.editing .chip-wrap .chip { cursor: grab; }
.chip-wrap.dragging { opacity: .4; }
.chip-actions .icon-btn {
  width: 18px; height: 18px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-3);
}
.chip-actions .icon-btn svg { width: 10px; height: 10px; }
.chip-actions .icon-btn:hover { color: var(--text); background: var(--surface-2); }
.chip-actions .icon-btn.del:hover { color: var(--danger); background: var(--danger-weak); }

/* ============ 第三屏：资讯 ============ */
/* 全屏按钮：展开 / 收起图标切换 */
#newsFullscreen .i-compress { display: none; }
#newsFullscreen.is-fs .i-expand { display: none; }
#newsFullscreen.is-fs .i-compress { display: block; }
/* 网页全屏态：资讯视图 fixed 铺满浏览器视口（非系统全屏），进入/退出带缩放淡入特效 */
#viewNews.fs-page {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: #fff;
  padding: 28px 36px;
  overflow: auto;
  animation: newsFsIn .28s cubic-bezier(.22, .61, .25, 1) both;
}
#viewNews.fs-page.closing { animation: newsFsOut .2s ease-in both; }
@keyframes newsFsIn {
  from { opacity: 0; transform: scale(.94) translateY(28px); }
  to   { opacity: 1; transform: none; }
}
@keyframes newsFsOut {
  from { opacity: 1; transform: none; }
  to   { opacity: 0; transform: scale(.95) translateY(24px); }
}
#newsFsBackdrop {
  position: fixed;
  inset: 0;
  z-index: 1900;
  background: rgba(15, 17, 21, .45);
  animation: fade .28s ease-out both;
}
#newsFsBackdrop.closing { animation: fadeOut .2s ease-in both; }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  #viewNews.fs-page, #viewNews.fs-page.closing,
  #newsFsBackdrop, #newsFsBackdrop.closing { animation-duration: .01s; }
}
html[data-theme="dark"] #viewNews.fs-page { background: #1b1e23; }
html.news-fs-lock, html.news-fs-lock body { overflow: hidden; }
.news-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 2px 4px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 28px;
  align-content: start;
  flex: 1 1 auto;
  min-height: 0;
}
.news-group-title {
  grid-column: 1 / -1;
  font-size: 12.5px;
  color: var(--text-3);
  font-weight: 500;
  letter-spacing: 0.5px;
  margin: 8px 0 2px;
}
.news-item {
  display: block;
  padding: 10px 6px;
  border-bottom: 1px solid var(--border);
}
.news-title {
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.news-item:hover .news-title { color: var(--accent); }
.news-meta {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  gap: 8px;
  align-items: center;
}
.news-src { color: var(--text-2); }
.news-error {
  grid-column: 1 / -1;
  padding: 8px 6px;
  font-size: 12.5px;
  color: var(--danger);
  opacity: .8;
}
.loading-tip, .news-empty {
  grid-column: 1 / -1;
  padding: 48px 0;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

/* ============ 按钮 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-weak); border-color: var(--danger); }
.btn-sm { height: 30px; padding: 0 12px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ============ 表单 ============ */
.field { display: block; margin: 14px 22px 0; }
.field-label {
  display: block;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 6px;
}
.field input, .select {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .select:focus { border-color: var(--accent); box-shadow: var(--ring); }
.form-error {
  margin: 12px 22px 0;
  font-size: 13px;
  color: var(--danger);
}
.form-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 20px 22px 20px;
}

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 21, 0.42);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  animation: fade .16s ease-out;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: min(420px, calc(100vw - 40px));
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  animation: rise .2s cubic-bezier(.22, .61, .25, 1);
  overflow: hidden;
}
.modal-lg { width: min(600px, calc(100vw - 40px)); }
/* 动态弹窗（确认/输入）正文 */
.dialog-text {
  padding: 24px 22px 0;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  word-break: break-all;
}
/* 设置面板：固定尺寸，宽高比为黄金比例 1.618 : 1（880 × 544） */
#settingsModal .modal-lg {
  width: min(880px, calc(100vw - 40px));
  height: min(calc(min(880px, 100vw - 40px) / 1.618), calc(100vh - 80px));
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 0 22px;
  flex: none;
}.modal-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.modal form { overflow-y: auto; padding-bottom: 4px; flex: 1 1 auto; min-height: 0; }

.auth-switch {
  display: flex;
  gap: 4px;
  margin: 14px 22px 0;
  background: var(--surface-2);
  border-radius: 9px;
  padding: 3px;
}
.auth-tab {
  flex: 1;
  height: 32px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px;
}
.auth-tab.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}
#authForm .btn-block { margin: 20px 22px; width: calc(100% - 44px); }

/* ============ 设置 ============ */
.settings-tabs {
  display: flex;
  gap: 2px;
  margin: 12px 22px 0;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.settings-tab {
  padding: 9px 14px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.settings-tab:hover { color: var(--text); }
.settings-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; }
.settings-pane { padding: 6px 0 14px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
}
.setting-row + .setting-row { border-top: 1px solid var(--border); }
.setting-name { font-size: 14px; }
.setting-desc { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }

.seg {
  display: flex;
  background: var(--surface-2);
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
  flex: none;
}
.seg button {
  height: 30px;
  padding: 0 14px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
}
.seg button.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}
/* 未登录：壁纸沿用站点（管理员）设置，选项只作展示 */
.seg.locked { cursor: not-allowed; }
.seg.locked button { cursor: not-allowed; }
.seg.locked button.active { box-shadow: none; color: var(--text-2); }
.select { width: 170px; }

.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i {
  position: absolute; inset: 0;
  background: var(--surface-3);
  border-radius: 999px;
  transition: background .18s;
}
.switch i::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform .18s;
}
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(16px); }

.pane-tip {
  margin: 10px 22px 0;
  font-size: 12.5px;
  color: var(--text-3);
}

.source-list { padding: 6px 22px 0; }
.source-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.source-row:last-child { border-bottom: none; }
.source-name { font-size: 13.5px; min-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-url {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: rtl;
  text-align: left;
}
.source-row .icon-btn { width: 28px; height: 28px; }

.source-add {
  display: flex;
  gap: 8px;
  margin: 12px 22px 4px;
}
.source-add input {
  height: 34px;
  padding: 0 10px;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}
.source-add input:focus { border-color: var(--accent); }
.source-add input:first-child { width: 130px; flex: none; }
.source-add input:nth-child(2) { flex: 1; min-width: 0; }

.admin-users { padding: 4px 22px 10px; }
.admin-user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.admin-user-row:last-child { border-bottom: none; }
.admin-user-name { min-width: 100px; font-weight: 500; }
.admin-user-meta { flex: 1; color: var(--text-3); font-size: 12px; }
.badge {
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-weak);
  color: var(--accent);
}
.badge.off { background: var(--danger-weak); color: var(--danger); }

/* ============ Toast ============ */
.toast-wrap {
  position: fixed;
  top: 68px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 400;
  pointer-events: none;
}
.toast {
  padding: 9px 18px;
  border-radius: 10px;
  background: #26282c;
  color: #f2f3f5;
  font-size: 13.5px;
  box-shadow: var(--shadow-md);
  animation: rise .2s ease-out;
}
html[data-theme="dark"] .toast { background: #e6e8eb; color: #1f2329; }
.toast.error { background: var(--danger); color: #fff; }
.toast.hide { opacity: 0; transition: opacity .25s; }

/* ============ 动画 ============ */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pop {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .pages-track { transition: none; }
  .engine-zoom-item.pop { animation: none; }
  .engine-roller.fade-in { animation: none; }
  .page-search .panel { transition: none; }
  .search-box .lens, .search-box .handle, .search-caret { transition: none; animation: none; }
  .engine-zoom-clone { transition: none; }
  .engine-zoom-grid { transition: none; }
  .drag-ghost, .drag-ghost.settling { transition: none; }         /* 拖动影子直接归位，不做缓动 */
  .site-card { transition: none; }                                /* 挤占让位排序不做平移动画 */
}

/* ============ 壁纸 ============ */
.wallpaper-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.wallpaper-layer::after {
  content: "";
  position: absolute;
  inset: 0;
  background: transparent;
  transition: background .3s;
}
html[data-theme="dark"] body.has-wallpaper .wallpaper-layer::after { background: rgba(10, 12, 16, 0.42); }
body.has-wallpaper .search-box {
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
html[data-theme="dark"] .panel { background: rgba(27, 30, 35, 0.45); }
/* 资讯视图：面板背景不透明，保证长文阅读不受壁纸干扰（深色主题用不透明深色底，避免浅色文字看不清）
   backdrop-filter 写成 blur(0) 而非 none，便于与毛玻璃状态插值过渡 */
.page-search .panel.news-view {
  background: #fff;
  backdrop-filter: blur(0px) saturate(1.4);
  -webkit-backdrop-filter: blur(0px) saturate(1.4);
}
html[data-theme="dark"] .page-search .panel.news-view { background: #1b1e23; }
html[data-theme="dark"] body.has-wallpaper .search-box {
  background: rgba(27, 30, 35, 0.78);
}
html[data-theme="dark"] body.has-wallpaper .site-icon { background: transparent; }

/* ============ 底部栏 ============ */
.footer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  font-size: 12px;
  color: var(--text-3);
  background: transparent;
  z-index: 80;
}
.foot-left { display: flex; align-items: center; gap: 8px; }
.foot-sep { opacity: .6; }
.foot-link {
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
}
.foot-link:hover { color: var(--accent); background: var(--accent-weak); }
.foot-beian {
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
  transition: color .15s;
}
.foot-beian:hover { color: var(--accent); text-decoration: underline; }

/* ============ 帮助 ============ */
.help-body {
  padding: 4px 22px 20px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  font-size: 13.5px;
  color: var(--text-2);
}
.help-body h4 {
  margin: 18px 0 6px;
  font-size: 14px;
  color: var(--text);
}
.help-body h4:first-child { margin-top: 10px; }
.help-body p { margin: 4px 0; line-height: 1.7; }
.help-list { list-style: none; margin: 6px 0 0; padding: 0; }
.help-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--border);
}
.help-list li:last-child { border-bottom: none; }
kbd {
  display: inline-block;
  padding: 1px 7px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  margin: 0 1px;
}

/* ============ 书签管理 ============ */
.bm-list { padding: 6px 22px 0; }
.bm-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.bm-row:last-child { border-bottom: none; }
.bm-title {
  min-width: 110px;
  max-width: 160px;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bm-cat {
  flex: none;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
}
.bm-url {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: rtl;
  text-align: left;
}
.bm-row .icon-btn { width: 28px; height: 28px; }
.pane-foot { padding: 12px 22px 6px; }
.wall-inline { display: flex; gap: 8px; align-items: center; }
.wall-input {
  width: 220px;
  height: 30px;
  padding: 0 10px;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}
.wall-input:focus { border-color: var(--accent); }

/* ============ 响应式 ============ */
@media (max-width: 760px) {
  .page { padding: 70px 14px 58px; }
  .engine-switch { min-height: 44px; }
  .engine-current { height: 88px; padding: 0 12px; border-radius: 16px; }
  .engine-roller { height: 54px; }
  .engine-roller img { height: 54px; }
  .engine-zoom-grid { gap: 6px 5px; padding: 8px 10px; }
  .panel { padding: 14px 14px 10px; border-radius: 12px; }
  .news-body { grid-template-columns: 1fr; }
  .site-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .user-name { display: none; }
  .source-add { flex-wrap: wrap; }
  .source-add input:first-child { width: 100%; }
  .source-add input:nth-child(2) { width: 100%; }
  .setting-row { flex-wrap: wrap; }
  .wall-inline { flex-wrap: wrap; }
  .wall-input { width: 100%; }
  /* 备案号需长期可见：小屏隐藏「数据保存在本服务器」(DOM 第 3 子项) 及其前导分隔符 (第 2 子项)。
     备案号是 <a> 第 5 子项，不匹配 span 选择器，故始终保留。 */
  .foot-left span:nth-child(2).foot-sep,
  .foot-left span:nth-child(3) { display: none; }
  .bm-title { max-width: 110px; min-width: 0; }
  /* 小屏取消固定高度，保证设置内容可用 */
  #settingsModal .modal-lg { height: auto; max-height: calc(100vh - 80px); }
}
