@font-face {
  font-family: "Caveat Hello";
  src: url("/assets/fonts/caveat-hello.woff2") format("woff2");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  /* Clean, harmonious neutral canvas without yellow patches */
  --page: #f7f8fa;
  --page-2: #f1f3f6;
  --blob-a: rgba(255, 255, 255, 0.82);
  --blob-b: rgba(210, 225, 244, 0.16);
  --blob-c: rgba(255, 255, 255, 0.46);
  --text: #1c1c1e;
  --muted: #6b6f7b;
  --quiet: #9a9ea9;
  /* 更薄更通透的苹果高质感毛玻璃 */
  --glass: #ffffff;
  --glass-strong: #ffffff;
  --glass-soft: #f4f5f7;
  --stroke: rgba(255, 255, 255, 0.90);
  --stroke-soft: rgba(28, 28, 30, 0.055);
  --shadow: 0 5px 18px rgba(24, 32, 44, 0.055);
  --shadow-lg: 0 16px 42px rgba(24, 32, 44, 0.09);
  --accent: #0071e3;
  --accent-2: #0a84ff;
  --focus: rgba(0, 113, 227, 0.18);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 17px;
  --radius-sm: 12px;
  --icon: 48px;
  --icon-box: 54px;
  --icon-pad: 5px;
  --tile-min: 112px;
  --blur: 30px;
  --sat: 150%;
}

html[data-theme="dark"],
body[data-theme="dark"] {
  color-scheme: dark;
  --page: #101216;
  --page-2: #101216;
  --blob-a: rgba(90, 140, 255, 0.10);
  --blob-b: rgba(155, 110, 255, 0.07);
  --blob-c: rgba(255, 255, 255, 0.025);
  --text: #f2f2f7;
  --muted: #a1a1aa;
  --quiet: #939ba8;
  --glass: #191c22;
  --glass-strong: #22262e;
  --glass-soft: #191c22;
  --stroke: rgba(255, 255, 255, 0.10);
  --stroke-soft: rgba(255, 255, 255, 0.07);
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.44);
  --shadow-lg: 0 16px 44px rgba(0, 0, 0, 0.56);
  --accent: #0a84ff;
  --accent-2: #5e5ce6;
  --focus: rgba(10, 132, 255, 0.26);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --page: #101216;
    --page-2: #101216;
    --blob-a: rgba(90, 140, 255, 0.10);
    --blob-b: rgba(155, 110, 255, 0.07);
    --blob-c: rgba(255, 255, 255, 0.025);
    --text: #f2f2f7;
    --muted: #a1a1aa;
    --quiet: #939ba8;
    --glass: #191c22;
    --glass-strong: #22262e;
    --glass-soft: #191c22;
    --stroke: rgba(255, 255, 255, 0.10);
    --stroke-soft: rgba(255, 255, 255, 0.07);
    --shadow: 0 6px 20px rgba(0, 0, 0, 0.44);
    --shadow-lg: 0 16px 44px rgba(0, 0, 0, 0.56);
    --accent: #0a84ff;
    --accent-2: #5e5ce6;
    --focus: rgba(10, 132, 255, 0.26);
  }
  html:not([data-theme]) {
    background: #101216;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html.theme-switching *, html.theme-switching *::before, html.theme-switching *::after {
  transition: none !important;
  animation: none !important;
}
html {
  min-height: 100%;
  background-color: var(--page);
  background: var(--page);
  -webkit-text-size-adjust: 100%;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
html[data-theme="dark"] {
  color-scheme: dark;
  /* Match the browser/status-bar tint so the top edge does not hard-cut to black. */
  background: #101216;
}
body {
  min-height: 100vh;
  min-height: 100dvh;
  scrollbar-width: none;
  -ms-overflow-style: none;
  color: var(--text);
  background-color: var(--page);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Segoe UI Variable", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  background: var(--page);
  overscroll-behavior-y: auto;
}

.page-scroll-surface {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: clip;
  scrollbar-width: none !important;
  scrollbar-color: transparent transparent !important;
  -ms-overflow-style: none !important;
  padding-bottom: calc(18px + var(--safe-bottom));
}
.page-scroll-surface::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  background: transparent !important;
}
.page-scroll-surface::-webkit-scrollbar-track,
.page-scroll-surface::-webkit-scrollbar-thumb,
.page-scroll-surface::-webkit-scrollbar-corner {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

button, input { font: inherit; color: inherit; }
button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ===== Header: floating glass island ===== */
.app-header {
  position: static;
  padding: calc(10px + var(--safe-top)) 16px 8px;
  background: transparent;
  border: 0;
  display: flex;
  justify-content: center;
}
.topbar {
  width: fit-content;
  max-width: calc(100% - 8px);
  min-height: 48px;
  margin: 0 auto;
  padding: 6px 6px 6px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* 主题按钮是 42px 圆形按钮、内部图标仅 18px，本身已带约 12px 留白。
     这里再加 gap 会让「标题→按钮」的视觉间距是「图标→标题」的 2.5 倍，
     所以此处不加 gap，改由 .brand-block 的 gap 统一控制节奏。 */
  gap: 4px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--stroke-soft);
  box-shadow: none;

}
html[data-theme="dark"] .topbar,
body[data-theme="dark"] .topbar {
  background: var(--glass);
  border-color: var(--stroke-soft);
  box-shadow: none;
}

.brand-block, .brand-copy {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.brand-copy,
.brand-copy:visited,
.brand-copy:hover,
.brand-copy:active {
  text-decoration: none;
}
.brand-copy h1 {
  display: inline-block;
  min-width: 74px;
  font-family: "Caveat Hello", "Segoe Print", cursive;
  font-size: 31px;
  line-height: 1;
  font-weight: 500;
  letter-spacing: 0.005em;
  white-space: nowrap;
  color: transparent;
  background: linear-gradient(90deg, #ff375f 0%, #ff9f0a 22%, #ffd60a 40%, #30d158 58%, #0a84ff 78%, #bf5af2 100%);
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  padding: 0 2px 3px 0;
}
html[data-theme="dark"] .brand-copy h1,
body[data-theme="dark"] .brand-copy h1 {
  background: linear-gradient(90deg, #ff375f 0%, #ff9f0a 22%, #ffd60a 40%, #30d158 58%, #0a84ff 78%, #bf5af2 100%);
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.icon-button, #back-to-top {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  cursor: pointer;
  transition: transform .15s ease, background-color .15s ease, color .15s ease;
}
.icon-button:hover, #back-to-top:hover {
  color: var(--text);
  background: var(--glass-strong);
  transform: scale(1.03);
}
.icon-button:active, #back-to-top:active { transform: scale(0.96); }
.icon-button svg, #back-to-top svg {
  width: 18px; height: 18px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.theme-icon-moon,
html[data-theme="dark"] .theme-icon-sun,
body[data-theme="dark"] .theme-icon-sun { display: none; }
html[data-theme="dark"] .theme-icon-moon,
body[data-theme="dark"] .theme-icon-moon { display: block; }

/* Keep the handwritten wordmark and the theme control visually separated. */
.topbar .icon-button { margin-left: 0; }

#back-to-top {
  position: fixed;
  right: 18px;
  bottom: calc(18px + var(--safe-bottom));
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px) scale(0.96);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background: var(--glass);
  box-shadow: none;
}
#back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* ===== Workspace ===== */
.workspace {
  /* Eight occupied desktop columns at the existing tile/gap size. */
  width: min(1048px, calc(100% - 28px));
  margin: 0 auto;
  padding: 10px 0 24px;
}

/* ===== Search: iOS capsule ===== */
.search-container {
  position: relative;
  width: min(720px, 100%);
  margin: 6px auto 26px;
}
.search-label-row,
.search-label { display: none !important; }
.search-box {
  height: 54px;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 48px;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--stroke-soft);
  background: var(--glass);
  box-shadow: none;

  overflow: hidden;
  transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}
html[data-theme="dark"] .search-box,
body[data-theme="dark"] .search-box {
  background: var(--glass);
  border-color: var(--stroke-soft);
  box-shadow: none;
}
.search-box:focus-within {
  border-color: rgba(68, 139, 187, 0.22);
  box-shadow: 0 0 0 3px var(--focus);
  transform: none;
}
.search-engine-trigger {
  width: 54px; height: 54px;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.search-engine-trigger:hover { color: var(--text); }
.search-engine-trigger-icon {
  width: 22px; height: 22px; background: center / contain no-repeat;
}
.search-engine-trigger-caret { opacity: .65; transition: transform .15s ease; }
.search-engine-trigger[aria-expanded="true"] .search-engine-trigger-caret { transform: rotate(180deg); }
.search-input-area {
  height: 100%; min-width: 0; position: relative; display: flex; align-items: center;
}
.search-input {
  width: 100%; height: 100%;
  padding: 0 40px 0 4px;
  border: 0; outline: 0; background: transparent;
  color: var(--text); font-size: 16px; /* iOS no-zoom */
}
.search-input::placeholder { color: var(--quiet); }
.search-clear {
  position: absolute; right: 4px;
  width: 28px; height: 28px; display: grid; place-items: center;
  border: 0; border-radius: 999px; background: transparent; color: var(--muted);
  cursor: pointer; opacity: 0; visibility: hidden;
}
.search-clear.visible { opacity: 1; visibility: visible; }
.search-clear:hover { background: var(--glass-soft); color: var(--text); }
.search-button {
  width: 48px; height: 54px; display: grid; place-items: center;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.search-button:hover { color: var(--text); }
.search-button svg { width: 19px; height: 19px; }
.search-results-count {
  display: none; margin: 10px auto 0; text-align: center; color: var(--muted); font-size: 12px;
}
.search-results-count.visible {
  display: block; width: fit-content;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid var(--stroke-soft);
  background: var(--glass);
  box-shadow: var(--shadow);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 550;
  letter-spacing: -0.01em;
}

.search-engine-dropdown {
  position: absolute;
  top: 60px; left: 50%; z-index: 60;
  width: min(520px, 100%);
  padding: 10px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--stroke);
  background: var(--glass-strong);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  transform: translate(-50%, -6px);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .15s ease, transform .15s ease, visibility .15s ease;
}
.search-engine-dropdown[hidden] { display: none; }
.search-engine-dropdown.visible {
  opacity: 1; visibility: visible; transform: translate(-50%, 0); pointer-events: auto;
}
.search-engine-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 6px;
}
.search-engine-item {
  min-height: 74px; padding: 10px 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 16px;
  background: transparent; color: var(--muted); font-size: 12px; cursor: pointer;
}
.search-engine-item:hover { background: var(--glass-soft); color: var(--text); }
.search-engine-item.active {
  border-color: var(--stroke);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
}
.search-engine-item-icon { width: 26px; height: 26px; background: center / contain no-repeat; }
[data-theme="dark"] .search-engine-item-icon[data-engine="baidu"],
[data-theme="dark"] .search-engine-trigger-icon[data-engine="baidu"] {
  /* Keep shape like Google/Bing: no plate, just lift contrast on dark glass */
  filter: brightness(1.22) saturate(1.08) drop-shadow(0 0 0.6px rgba(255,255,255,0.35));
}
.search-engine-item-name {
  width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center;
}

/* ===== Sections / tiles ===== */
main { min-height: 280px; }
section { margin: 0 0 20px; }
section h2 {
  margin: 0 0 14px 0;
  display: flex; align-items: center; gap: 9px;
  color: #475569;
  font-size: 14px;
  font-weight: 600;
}
html[data-theme="dark"] section h2 { color: #c4cbd5; }
section h2::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: none;
}
.category-count {
  min-width: 22px; height: 20px; padding: 0;
  display: inline-grid; place-items: center;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px; font-weight: 400;
}
html[data-theme="dark"] .category-count { color: var(--muted); }

/* App icon grid like iOS home screen */
ul {
  list-style: none;
  display: grid;
  /* Keep one shared column system; short groups occupy its leftmost tracks. */
  grid-template-columns: repeat(auto-fill, minmax(var(--tile-min), 1fr));
  gap: 12px;
}
li {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-width: 0;
  min-height: var(--tile-min);
  border-radius: 14px;
  border: 1px solid rgba(15,23,42,.06);
  /* Matte surface: uniform separation for every source icon. */
  background: #ffffff;
  box-shadow: none;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
  -webkit-tap-highlight-color: transparent;
}
/* 玻璃表面的斜向柔光，pointer-events 防止遮挡链接 */
li::before {
  content: none;
  position: absolute;
  z-index: -1;
  pointer-events: none;
  top: -42%;
  left: -28%;
  width: 112%;
  height: 78%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center,
    rgba(255, 255, 255, 0.68) 0%,
    rgba(255, 255, 255, 0.22) 50%,
    transparent 74%);
  transform: rotate(-12deg);
}
li:hover {
  transform: none;
  border-color: transparent;
  background: #edf0f5;
  box-shadow: none;
}
html[data-theme="dark"] li,
body[data-theme="dark"] li {
  /* 纯正午夜黑磨砂卡片，去除泛蓝杂色 */
  background: #262930;
  border-color: transparent;
  box-shadow: none;
}
html[data-theme="dark"] li:hover,
body[data-theme="dark"] li:hover {
  background: #30343c;
  border-color: transparent;
  box-shadow: none;
}
li:active {
  transform: none;
  transition-duration: .08s;
}
li:focus-within {
  border-color: var(--accent);
  box-shadow: none;
}
li a {
  width: 100%;
  min-height: var(--tile-min);
  padding: 12px 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  text-align: center;
}

/* Unframed source artwork. */
.favicon-container {width:var(--icon-box);height:var(--icon-box);flex:0 0 var(--icon-box);display:grid;place-items:center;border:0;border-radius:15px;background:transparent;box-shadow:none;overflow:hidden;position:relative}
.favicon {position:absolute;inset:0;width:100%;height:100%;padding:0;border-radius:inherit;object-fit:cover;object-position:center;opacity:0;filter:none}
.favicon.loaded {opacity:1}

.link-text {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  line-height: 1.25;
  color: var(--text);
}

.external-icon,
li .url { display: none; }

footer {
  margin: 0 auto;
  padding: 0 16px calc(10px + var(--safe-bottom));
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}
footer a { color: var(--muted); text-decoration: none; }
footer a:hover { color: var(--accent); }
body.hide-favicon .favicon-container,
li.no-icon .favicon-container { display: none; }

.loading, .error-message, .empty-state {
  min-height: 260px;
  display: grid;
  place-items: center;
  color: var(--muted);
}
.error-message { gap: 12px; align-content: center; }
.error-message button {
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--glass);
  color: var(--text);
  cursor: pointer;
}
.empty-state {
  gap: 6px;
  border: 1px dashed var(--stroke);
  border-radius: var(--radius-lg);
  background: var(--glass-soft);
}
.empty-state strong { color: var(--text); font-size: 15px; font-weight: 700; }
.empty-state span { font-size: 13px; }

:focus-visible { outline: none; }
button:focus-visible, a:focus-visible { box-shadow: 0 0 0 4px var(--focus); }

html::-webkit-scrollbar,
body::-webkit-scrollbar,
.page-scroll-surface::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  background: transparent !important;
}

/* Responsive like iPhone home screen density */
/* 断点只调整最小列宽，由 auto-fill 决定列数。
   必须保持单调递减：窗口越窄，--tile-min 越小。
   以前 920px 设 118px（比 1180px 的 116px 更大）、380px 设 92px（比 520px 的 84px 更大），
   导致列数随窗口缩小不单调跳变（800px→5列，缩到 700px 反而→6列）。 */
@media (max-width: 1180px) { :root { --tile-min: 108px; } }
@media (max-width: 920px)  { :root { --tile-min: 104px; } }
@media (max-width: 720px) {
  .workspace { width: min(100% - 20px, 1048px); }
  ul { gap: 10px; }
  :root { --icon: 44px; --icon-box: 54px; --tile-min: 96px; }
}
@media (max-width: 520px) {
  .app-header { padding-left: 12px; padding-right: 12px; }
  .topbar { min-height: 46px; padding: 5px 5px 5px 15px; gap: 2px; }
  .brand-copy h1 { font-size: 32px; }
  .search-container { margin-bottom: 22px; }
  .search-box { height: 48px; grid-template-columns: 48px minmax(0,1fr) 44px; }
  .search-engine-trigger { width: 48px; height: 48px; }
  .search-button { width: 44px; height: 48px; }
  .search-engine-dropdown { top: 56px; }
  ul {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
  }
  :root { --icon: 42px; --icon-box: 50px; --tile-min: 0px; --radius-lg: 18px; }
  li, li a { min-height: 96px; }
  .link-text { font-size: 11.5px; }
  li a { padding: 12px 6px 10px; gap: 8px; }
}
@media (max-width: 380px) {
  :root { --icon: 38px; --icon-box: 50px; }
  ul { gap: 8px; }
  li, li a { min-height: 90px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}

/* Fixed search shell; only the site list owns vertical scrolling. */
html, body {
  height: 100%;
  overflow: hidden;
}
.page-scroll-surface {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 0;
}
.app-header { flex: 0 0 auto; }
.workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
}
.search-container { flex: 0 0 auto; z-index: 2; }
#nav-container {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 4px 4px calc(76px + var(--safe-bottom));
  margin: -4px -4px 0;
}
/* Hide native Safari overlay indicators without disabling list scrolling. */
#nav-container {
  scrollbar-width: none !important;
  scrollbar-color: transparent transparent !important;
  -ms-overflow-style: none !important;
}
#nav-container::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  background: transparent !important;
}
#nav-container::-webkit-scrollbar-thumb,
#nav-container::-webkit-scrollbar-track,
#nav-container::-webkit-scrollbar-track-piece,
#nav-container::-webkit-scrollbar-corner,
#nav-container::-webkit-scrollbar-button {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  opacity: 0 !important;
}
.page-scroll-surface > footer:has(small:empty) { display: none; }

/* iOS PWA / standalone polish */
@supports (-webkit-touch-callout: none) {
  .page-scroll-surface { min-height: -webkit-fill-available; }
}




/* Crop Safari's native overlay scrollbar outside the visible list edge. */
.nav-scroll-clip {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  margin: -4px -4px 0;
}
.nav-scroll-clip > #nav-container {
  box-sizing: border-box;
  width: calc(100% + 32px);
  height: 100%;
  margin: 0;
  padding-right: 36px;
  -webkit-clip-path: inset(0 32px 0 0);
  clip-path: inset(0 32px 0 0);
}
@media (pointer: coarse), (max-width: 600px) {
  .icon-button, #back-to-top, .search-clear { min-width: 44px; min-height: 44px; }
}
