:root {
  --text: #24324a;
  --muted: #73809b;
  --line: rgba(255,255,255,.78);
  --glass: rgba(247,247,252,.76);
  --glass-strong: rgba(250,250,255,.88);
  --shadow: 0 20px 50px rgba(45,36,85,.16);
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "PingFang SC",
    "Hiragino Sans GB",
    "Microsoft YaHei",
    "Noto Sans CJK SC",
    sans-serif;
  background: #b9aad2;
}

button,
input,
select {
  font: inherit;
}

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

button {
  color: inherit;
}

.page-bg,
.page-veil {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.page-bg {
  z-index: -3;
  background:
    linear-gradient(135deg, rgba(97,76,150,.18), rgba(255,202,226,.12)),
    url("assets/wallpaper.webp") center 28% / cover no-repeat,
    linear-gradient(135deg, #7769a8, #dfb8c9 58%, #e3d9ef);
}

.page-veil {
  z-index: -2;
  background:
    linear-gradient(90deg,
      rgba(81,61,127,.44) 0%,
      rgba(105,82,139,.34) 34%,
      rgba(139,112,151,.20) 68%,
      rgba(255,255,255,.18) 100%);
}

.site-header {
  position: relative;
  z-index: 10;
  width: min(1380px, calc(100% - 72px));
  margin: 0 auto;
  padding: 22px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-shadow: 0 2px 12px rgba(48,36,92,.25);
}

.brand-mark {
  width: 52px;
  height: 40px;
  border: 2px solid rgba(255,255,255,.92);
  border-radius: 15px;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 700;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand-copy strong {
  font-size: 24px;
  letter-spacing: .02em;
}

.brand-copy small {
  margin-top: 6px;
  font-size: 10px;
  letter-spacing: .28em;
  font-weight: 700;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 22px;
  color: rgba(255,255,255,.94);
  font-size: 14px;
  font-weight: 600;
}

.top-nav a {
  opacity: .92;
}

.top-nav a:hover {
  opacity: 1;
}

.page-shell {
  width: min(1380px, calc(100% - 72px));
  margin: 0 auto;
}

.hero {
  min-height: 450px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 40px;
}

.search-box {
  width: min(720px, 100%);
  height: 60px;
  display: grid;
  grid-template-columns: 120px 1fr 66px;
  align-items: center;
  overflow: hidden;
  border-radius: 20px;
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(255,255,255,.9);
  box-shadow: 0 14px 36px rgba(58,40,105,.2);
}

.search-box select,
.search-box input {
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: #34415e;
}

.search-box select {
  padding: 0 20px;
  border-right: 1px solid rgba(75,85,120,.08);
}

.search-box input {
  min-width: 0;
  padding: 0 18px;
}

.search-box button {
  height: calc(100% - 8px);
  margin-right: 4px;
  border: 0;
  border-radius: 17px;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  background: linear-gradient(135deg, #8062ff, #8f73ff);
}


.glass-panel {
  background: rgba(242,241,248,var(--panel-alpha,.64));
  border: 1px solid rgba(255,255,255,.82);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}

.content-panel {
  border-radius: var(--radius-lg);
  padding: 18px;
}

.favorites-block,
.friends-block {
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(255,255,255,.86);
  border-radius: 22px;
  padding: 16px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 12px;
}

.section-heading h2 {
  margin: 0;
  font-size: 18px;
}

.section-heading h2 span {
  margin-right: 8px;
}

.section-heading a,
.plain-button {
  font-size: 13px;
  color: #71809c;
}

.plain-button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.favorite-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 10px;
}

.favorite-item,
.site-link,
.expanded-site {
  border: 1px solid rgba(102,113,145,.11);
  background: rgba(255,255,255,.78);
  border-radius: 14px;
}

.favorite-item {
  min-height: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: 12px;
}

.favorite-icon,
.site-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-weight: 800;
  color: #fff;
}

.favorite-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--accent, #7f67ff);
}

.ad-slot {
  min-height: 104px;
  margin: 16px 0;
  border-radius: 20px;
  border: 1px dashed rgba(98,108,142,.25);
  background: rgba(255,255,255,.54);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  padding: 16px;
}

.ad-slot strong,
.ad-slot small {
  display: block;
}

.ad-slot small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.ad-label {
  font-size: 10px;
  letter-spacing: .18em;
  color: #8b93a9;
}

.premium-ad {
  background: linear-gradient(135deg, rgba(255,255,255,.76), rgba(248,241,255,.70));
  border-style: solid;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.category-card {
  min-width: 0;
  border-radius: 21px;
  padding: 15px;
  overflow: hidden;
  background:
    linear-gradient(180deg, var(--tint) 0%, rgba(255,255,255,.78) 58%);
  border: 1px solid rgba(255,255,255,.9);
}

.category-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 13px;
}

.category-meta {
  min-width: 0;
  display: flex;
  gap: 10px;
}

.category-symbol {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--accent);
  font-size: 20px;
}

.category-copy {
  min-width: 0;
}

.category-copy h3 {
  margin: 1px 0 4px;
  color: var(--accent);
  font-size: 18px;
}

.category-copy p {
  margin: 0;
  color: var(--accent);
  opacity: .78;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.more-button {
  flex: 0 0 auto;
  border: 0;
  padding: 3px 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
}

.site-track {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.site-link {
  min-width: 0;
  height: 67px;
  padding: 7px 4px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  font-size: 10px;
}

.site-link span:last-child {
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.site-icon {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  color: var(--accent);
  background: var(--icon-bg);
  font-size: 12px;
}

.friends-block {
  margin-top: 16px;
}

.friend-links {
  display: flex;
  flex-wrap: wrap;
  gap: 11px 28px;
}

.friend-links a {
  color: #65718a;
  font-size: 13px;
}

.friend-links a:hover {
  color: #6656d9;
}

.site-footer {
  width: min(1380px, calc(100% - 72px));
  margin: 16px auto 26px;
  display: flex;
  justify-content: space-between;
  color: rgba(255,255,255,.88);
  font-size: 12px;
}

.category-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 40px;
  visibility: hidden;
  opacity: 0;
  transition: opacity .22s ease, visibility .22s ease;
}

.category-modal.is-open {
  visibility: visible;
  opacity: 1;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(35,27,61,.42);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: default;
}

.expanded-card {
  position: relative;
  z-index: 1;
  width: min(1080px, calc(100vw - 80px));
  max-height: 78vh;
  overflow: auto;
  border-radius: 28px;
  border: 1px solid rgba(255,255,255,.9);
  background:
    linear-gradient(180deg, var(--modal-tint, rgba(244,240,255,.96)), rgba(255,255,255,.96) 190px);
  box-shadow: 0 34px 90px rgba(31,22,57,.28);
  padding: 24px;
  transform: scale(.96) translateY(12px);
  transition: transform .22s ease;
}

.category-modal.is-open .expanded-card {
  transform: scale(1) translateY(0);
}

.expanded-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.expanded-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.expanded-title-row h2 {
  margin: 0;
  font-size: 28px;
  color: var(--modal-accent, #745fff);
}

.expanded-symbol {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--modal-accent, #745fff);
  font-size: 22px;
}

.expanded-head p {
  margin: 8px 0 0 60px;
  color: var(--muted);
  font-size: 13px;
}

.close-modal {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.76);
  cursor: pointer;
  font-size: 26px;
  line-height: 1;
}

.expanded-sites {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.expanded-site {
  min-height: 90px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  transition: transform .16s ease, box-shadow .16s ease;
}

.expanded-site:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(59,49,99,.10);
}

.expanded-site .site-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
}

.expanded-site strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 13px;
}

.expanded-site small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 1180px) {
  .favorite-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .category-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .expanded-sites {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 767px) {
  .site-header,
  .page-shell,
  .site-footer {
    width: min(100% - 28px, 100%);
  }

  .site-header {
    padding-top: 14px;
  }

  .brand-copy strong {
    font-size: 20px;
  }

  .brand-mark {
    width: 44px;
    height: 36px;
  }

  .top-nav {
    gap: 12px;
    font-size: 12px;
  }

  .top-nav a:nth-child(-n+2) {
    display: none;
  }

  .hero {
    min-height: 380px;
    padding-bottom: 28px;
  }

  .search-box {
    height: 54px;
    grid-template-columns: 92px 1fr 58px;
    border-radius: 18px;
  }

  .search-box select {
    padding: 0 12px;
    font-size: 13px;
  }

  .search-box input {
    padding: 0 12px;
    font-size: 13px;
  }


  .content-panel {
    padding: 10px;
    border-radius: 22px;
  }

  .favorites-block,
  .friends-block {
    padding: 13px;
    border-radius: 18px;
  }

  .favorite-grid {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 3px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .favorite-grid::-webkit-scrollbar,
  .site-track::-webkit-scrollbar {
    display: none;
  }

  .favorite-item {
    flex: 0 0 84px;
    min-height: 82px;
    scroll-snap-align: start;
  }

  .ad-slot {
    min-height: 90px;
    margin: 10px 0;
    border-radius: 17px;
  }

  .category-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .category-card {
    padding: 13px;
    border-radius: 18px;
  }

  .category-head {
    margin-bottom: 11px;
  }

  .more-button {
    display: none;
  }

  .site-track {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 3px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .site-link {
    flex: 0 0 82px;
    height: 68px;
    scroll-snap-align: start;
  }

  .friend-links {
    gap: 10px 20px;
  }

  .site-footer {
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
  }

  .category-modal {
    display: none !important;
  }
}

@media (max-width: 480px) {
  .top-nav a:nth-child(3) {
    display: none;
  }

  .search-box {
    grid-template-columns: 82px 1fr 54px;
  }

  .section-heading h2 {
    font-size: 16px;
  }

  .category-symbol {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .category-copy h3 {
    font-size: 16px;
  }
}


/* 每一横排分类独立成组，广告插在组与组之间 */
.category-row + .ad-slot {
  margin-top: 16px;
}

.ad-slot + .category-row {
  margin-top: 16px;
}

.category-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

/* 旧 category-grid 规则保留给兼容，但新版使用 category-row */
@media (max-width: 1180px) {
  .category-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 767px) {
  .category-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}


/* PC / 平板只显示前 6 项；手机直接显示全部并横向滑动 */
.mobile-sites {
  display: none;
}

@media (max-width: 767px) {
  .desktop-sites {
    display: none;
  }

  .mobile-sites {
    display: flex;
  }
}

.top-nav button{border:0;background:transparent;color:rgba(255,255,255,.94);font-weight:600;cursor:pointer}.page-veil{opacity:var(--veil-opacity,1)}
.info-modal{position:fixed;inset:0;z-index:110;display:grid;place-items:center;padding:28px;visibility:hidden;opacity:0;transition:.2s}.info-modal.is-open{visibility:visible;opacity:1}.info-backdrop{position:absolute;inset:0;border:0;background:rgba(35,27,61,.42);backdrop-filter:blur(10px)}.info-card{position:relative;z-index:1;width:min(680px,calc(100vw - 40px));border:1px solid rgba(255,255,255,.88);border-radius:26px;background:rgba(255,255,255,.94);box-shadow:0 30px 80px rgba(31,22,57,.28);padding:24px}.info-head,.settings-head{display:flex;align-items:center;justify-content:space-between;gap:20px}.info-head h2,.settings-head h2{margin:0}.info-close,#settingsClose{width:38px;height:38px;border:0;border-radius:50%;background:rgba(117,98,175,.08);cursor:pointer;font-size:24px}.info-content{color:#59657d;line-height:1.85}.mailto-button{display:inline-flex;margin-top:8px;padding:10px 16px;border-radius:12px;color:#fff;background:#7c63ee}
.settings-panel{position:fixed;z-index:120;top:18px;right:18px;width:min(360px,calc(100vw - 36px));border:1px solid rgba(255,255,255,.88);border-radius:22px;background:rgba(255,255,255,.94);box-shadow:0 28px 70px rgba(31,22,57,.24);padding:20px;transform:translateX(calc(100% + 32px));transition:transform .22s}.settings-panel.is-open{transform:translateX(0)}.setting-row{margin-top:16px;display:flex;align-items:flex-end;justify-content:space-between;gap:20px}.setting-row strong,.setting-row small{display:block}.setting-row small{margin-top:3px;color:#7d879a;font-size:11px}.setting-row output{color:#7160d5;font-size:12px;font-weight:700}.settings-panel input[type=range]{width:100%;margin-top:10px;accent-color:#7c63ee}.reset-button{width:100%;margin-top:22px;border:0;border-radius:12px;padding:10px;cursor:pointer;color:#5c5574;background:rgba(121,104,175,.10)}
@media(max-width:767px){.settings-panel{top:auto;right:10px;bottom:10px;left:10px;width:auto;transform:translateY(calc(100% + 24px))}.settings-panel.is-open{transform:translateY(0)}}


/* v6: 常用网站去标题后保留自然间距 */
.favorites-block {
  padding-top: 2px;
}

/* v6: 所有圆形关闭按钮使用真正的几何居中 */
.close-modal,
.info-close,
#settingsClose {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  box-sizing: border-box;
  aspect-ratio: 1 / 1;
  padding: 0;
  line-height: 1;
  text-align: center;
}

/* × 字形自身视觉中心略偏，用 transform 做极小修正 */
.close-modal,
.info-close,
#settingsClose {
  text-indent: 0;
}

/* 栏目详情说明允许两行，但避免把卡片撑得过高 */
.expanded-site > span:last-child {
  min-width: 0;
}

.expanded-site small {
  display: -webkit-box;
  margin-top: 3px;
  overflow: hidden;
  color: #7c8597;
  font-size: 11px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}


/* =========================
   v7 visual polish
   ========================= */

/* 常用网站：不再强制填满整行，未占满时作为整体居中 */
.favorite-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 135px));
  justify-content: center;
  align-items: stretch;
  gap: 10px;
}

.favorite-item {
  width: 100%;
  min-width: 0;
}

.favorite-icon,
.site-icon {
  background: var(--site-icon-color, var(--accent, #7f67ff));
}

.favorite-icon.image-icon,
.site-icon.image-icon {
  overflow: hidden;
  background: rgba(255,255,255,.78);
  border: 1px solid rgba(89,102,137,.10);
}

.favorite-icon.image-icon img,
.site-icon.image-icon img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

/* 所有 UI 按钮都使用 SVG，彻底摆脱字体字符基线 */
.ui-icon {
  display: block;
  pointer-events: none;
}

.search-box button {
  position: relative;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 0;
  line-height: 0;
}

.search-box .search-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.close-modal,
.info-close,
#settingsClose {
  display: grid;
  place-items: center;
  padding: 0;
  line-height: 0;
  font-size: 0;
  border-radius: 999px;
}

.close-modal .close-icon,
.info-close .close-icon,
#settingsClose .close-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: #34415e;
  stroke-width: 1.8;
  stroke-linecap: round;
}

/* 栏目详情的图标和介绍 */
.expanded-site .site-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: -.02em;
}

.expanded-site-copy {
  min-width: 0;
}

.expanded-site-copy strong {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.expanded-site-copy small {
  display: -webkit-box;
  margin-top: 4px;
  min-height: 2.7em;
  overflow: hidden;
  color: #7c8597;
  font-size: 10px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

@media (max-width: 767px) {
  .favorite-grid {
    display: flex;
    justify-content: flex-start;
    flex-wrap: nowrap;
  }

  .favorite-item {
    flex: 0 0 118px;
  }
}


/* =========================
   v8 alignment + Font Awesome
   ========================= */

.favorites-block {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  min-height: 0;
}

.favorite-grid {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  align-content: center;
  gap: 10px;
}

.favorite-item {
  flex: 0 1 135px;
  width: 135px;
  height: 78px;
  min-height: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 10px;
}

.favorite-icon {
  width: 38px;
  height: 38px;
  min-width: 38px;
  min-height: 38px;
  flex: 0 0 38px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  background: var(--site-icon-color, #7f67ff);
  color: #fff;
  line-height: 1;
}

.site-icon {
  box-sizing: border-box;
  background: var(--site-icon-color, var(--accent, #7f67ff));
  color: #fff;
  line-height: 1;
}

.fa-icon i {
  display: block;
  line-height: 1;
  font-size: 17px;
}

.expanded-site .fa-icon i {
  font-size: 18px;
}

.search-box button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  font-size: 18px;
}

.search-box button > i {
  display: block;
  width: 1em;
  height: 1em;
  line-height: 1em;
  text-align: center;
  color: #fff;
}

.close-modal,
.info-close,
#settingsClose {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 0;
  border-radius: 50%;
  line-height: 1;
  font-size: 18px;
}

.close-modal > i,
.info-close > i,
#settingsClose > i {
  display: block;
  width: 1em;
  height: 1em;
  line-height: 1em;
  text-align: center;
}

#contentRows > .ad-slot:last-child {
  margin-bottom: 16px;
}

@media (max-width: 767px) {
  .favorites-block {
    display: block;
    padding: 12px;
    overflow: hidden;
  }

  .favorite-grid {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: center;
    overflow-x: auto;
    scroll-snap-type: x proximity;
  }

  .favorite-item {
    flex: 0 0 118px;
    width: 118px;
    height: 76px;
    scroll-snap-align: start;
  }
}


/* =========================
   v9 bug fixes
   ========================= */

/* JSON 背景图覆盖原本 wallpaper.webp，同时保留渐变兜底 */
.page-bg {
  background:
    linear-gradient(135deg, rgba(97,76,150,.18), rgba(255,202,226,.12)),
    var(--wallpaper-image, linear-gradient(135deg, transparent, transparent)) center 28% / cover no-repeat,
    linear-gradient(135deg, #7769a8, #dfb8c9 58%, #e3d9ef);
}

/* 搜索引擎选择框加宽，长选项不再被截断 */
.search-box {
  grid-template-columns: 170px minmax(0, 1fr) 66px;
}

.search-box select {
  width: 170px;
  padding: 0 38px 0 24px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 普通栏目和展开栏目共用相同的图标逻辑 */
.site-link .site-icon {
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  flex: 0 0 30px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--site-icon-color, var(--accent, #7f67ff));
  color: #fff;
  font-size: 10px;
  font-weight: 800;
}

.site-link .site-icon.fa-icon i {
  font-size: 14px;
  line-height: 1;
}

.site-link .site-icon.image-icon {
  background: rgba(255,255,255,.82);
  border: 1px solid rgba(80,90,120,.09);
}

.site-link .site-icon.image-icon img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.site-name {
  display: block;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* 右上角按钮统一带图标与文字 */
.top-nav button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.top-nav button i {
  font-size: 12px;
}

/* 手机端稍微缩短搜索选择框，避免压缩输入框 */
@media (max-width: 767px) {
  .search-box {
    grid-template-columns: 132px minmax(0, 1fr) 58px;
  }

  .search-box select {
    width: 132px;
    padding-left: 16px;
    padding-right: 30px;
  }

  #changeBgBtn span {
    display: none;
  }
}


/* =========================
   v9.1 category row spacing fix
   ========================= */

/*
 * 栏目之间的间距由内容结构自己负责，
 * 不再依赖广告位的 margin / 占位。
 */
#contentRows {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/*
 * 由于 #contentRows 已经统一负责纵向 gap，
 * 清掉栏目行和广告自身可能遗留的上下 margin，
 * 防止有广告时产生双倍间距。
 */
#contentRows > .category-row,
#contentRows > .ad-slot {
  margin-top: 0;
  margin-bottom: 0;
}

/*
 * 每一行的 4 个栏目自身保持横向间距。
 * 如果旧 CSS 已有同样规则，这里作为最终覆盖。
 */
.category-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

/* 手机布局继续独立处理 */
@media (max-width: 767px) {
  #contentRows {
    gap: 14px;
  }
}


/* =========================
   v9.2 favorites spacing fix
   ========================= */

/*
 * 常用网站位于 #contentRows 外部，
 * 因此需要自己负责与后续广告 / 第一排栏目的间距。
 */
.favorites-block {
  margin-bottom: 16px;
}

@media (max-width: 767px) {
  .favorites-block {
    margin-bottom: 14px;
  }
}


/* =========================
   v9.3 mobile category layout fix
   ========================= */

/*
 * v9.1 在文件末尾重新声明了 .category-row 的 4 列规则，
 * 覆盖了更早的移动端 1 列媒体查询。
 * 这里把移动端最终规则放在样式表最末尾，确保优先级正确。
 */
@media (max-width: 767px) {
  .category-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    width: 100%;
  }

  .category-card {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  /*
   * 手机端首页不显示“更多”按钮。
   * 每个栏目直接显示全部站点，并横向滑动。
   */
  .more-button {
    display: none;
  }

  .desktop-sites {
    display: none;
  }

  .mobile-sites {
    display: flex;
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 8px;
    padding-bottom: 3px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-sites::-webkit-scrollbar {
    display: none;
  }

  .mobile-sites .site-link {
    flex: 0 0 84px;
    width: 84px;
    min-width: 84px;
    height: 68px;
    scroll-snap-align: start;
  }

  /*
   * 防止标题区域被超长说明或图标撑出卡片。
   */
  .category-head,
  .category-meta,
  .category-copy {
    min-width: 0;
  }

  .category-copy h3,
  .category-copy p {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
}


/* =========================
   v10 configurable logo / category icons / ads / quick nav
   ========================= */

/* 自定义 Logo：PC 直接按 JSON 里的 290×82 使用 */
.brand.has-image-logo {
  display: flex;
  align-items: center;
}

.brand-logo {
  display: block;
  width: 290px;
  height: 82px;
  max-width: none;
  object-fit: contain;
  object-position: left center;
}

/* 栏目标题图标与站点图标共用 iconHtml() */
.category-symbol,
.expanded-category-icon {
  overflow: hidden;
  box-sizing: border-box;
}

.category-symbol img,
.expanded-category-icon img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.category-symbol.fa-icon,
.category-symbol.text-icon {
  background: var(--site-icon-color, var(--accent, #7866d8));
  color: #fff;
}

.category-symbol.fa-icon i {
  font-size: 17px;
  line-height: 1;
}

.expanded-category-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 48px;
  background: var(--site-icon-color, var(--modal-accent, #7866d8));
  color: #fff;
}

.expanded-category-icon.fa-icon i {
  font-size: 20px;
}

/* 真正的图片广告，不再渲染文字占位 */
.ad-slot.image-ad {
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  background: transparent;
}

.ad-slot.image-ad a {
  display: block;
  width: 100%;
  border-radius: inherit;
  overflow: hidden;
}

.ad-slot.image-ad img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 160px;
  object-fit: cover;
}

/* 右下角快速导航 */
.quick-nav {
  position: fixed;
  z-index: 85;
  right: 18px;
  bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  border: 1px solid rgba(255,255,255,.82);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255,255,255,.86);
  box-shadow: 0 14px 36px rgba(38,29,68,.18);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.quick-nav button {
  min-width: 88px;
  padding: 9px 12px;
  border: 0;
  border-bottom: 1px solid rgba(91,80,127,.10);
  background: transparent;
  color: #3b4258;
  font: inherit;
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

.quick-nav button:last-child {
  border-bottom: 0;
}

.quick-nav button:hover {
  background: rgba(124,99,238,.10);
  color: #7058db;
}

/* scrollIntoView 时别让栏目标题紧贴浏览器顶边 */
.category-row {
  scroll-margin-top: 24px;
}

@media (max-width: 767px) {
  /* 手机 Logo 随设备宽度收缩，保持原始 290:82 比例 */
  .brand-logo {
    width: min(52vw, 190px);
    height: auto;
    aspect-ratio: 290 / 82;
  }

  .quick-nav {
    right: 8px;
    bottom: 10px;
    border-radius: 11px;
    opacity: .92;
  }

  .quick-nav button {
    min-width: 66px;
    padding: 7px 8px;
    font-size: 10px;
  }

  .ad-slot.image-ad img {
    max-height: 110px;
  }
}


/* =========================
   v11 tablet + compact quick nav
   ========================= */

/*
 * Tablet and phone share the same navigation content model:
 * - one category per row
 * - all category sites in a horizontal track
 * - no "more" modal entry from the card
 */
@media (max-width: 1024px) {
  .category-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    width: 100%;
  }

  .category-card {
    width: 100%;
    min-width: 0;
  }

  .more-button {
    display: none;
  }

  .desktop-sites {
    display: none;
  }

  .mobile-sites {
    display: flex;
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 8px;
    padding-bottom: 3px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-sites::-webkit-scrollbar {
    display: none;
  }

  .mobile-sites .site-link {
    flex: 0 0 92px;
    width: 92px;
    min-width: 92px;
    height: 70px;
    scroll-snap-align: start;
  }

  .favorite-grid {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 10px;
    padding-bottom: 3px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .favorite-grid::-webkit-scrollbar {
    display: none;
  }

  .favorite-item {
    flex: 0 0 126px;
    width: 126px;
    scroll-snap-align: start;
  }

  /*
   * Compact quick navigation:
   * mostly hidden beyond right edge, handle remains visible.
   */
  .quick-nav {
    right: 0;
    bottom: 14px;
    width: 104px;
    border-radius: 14px 0 0 14px;
    overflow: visible;
    transform: translateX(calc(100% - 18px));
    transition: transform .22s ease;
  }

  .quick-nav.is-open {
    transform: translateX(0);
  }

  .quick-nav-handle {
    position: absolute;
    left: -24px;
    top: 50%;
    transform: translateY(-50%);
    width: 26px;
    min-width: 26px;
    height: 52px;
    padding: 0;
    border: 1px solid rgba(255,255,255,.82);
    border-right: 0;
    border-radius: 12px 0 0 12px;
    background: rgba(255,255,255,.90);
    box-shadow: -6px 8px 20px rgba(38,29,68,.12);
    color: #6354b7;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .quick-nav-items {
    display: flex;
    flex-direction: column;
  }

  .quick-nav-items button {
    min-width: 104px;
  }
}

/* Desktop doesn't need the handle. */
@media (min-width: 1025px) {
  .quick-nav-handle {
    display: none;
  }

  .quick-nav-items {
    display: flex;
    flex-direction: column;
  }
}

/* Phones can use slightly smaller track items. */
@media (max-width: 767px) {
  .mobile-sites .site-link {
    flex-basis: 84px;
    width: 84px;
    min-width: 84px;
  }

  .favorite-item {
    flex-basis: 118px;
    width: 118px;
  }

  .quick-nav {
    width: 92px;
  }

  .quick-nav-items button {
    min-width: 92px;
  }
}


/* =========================
   v12 PWA
   ========================= */

#installPwaBtn[hidden] {
  display: none !important;
}

/* standalone 模式下让页面更像独立应用 */
@media (display-mode: standalone) {
  body {
    overscroll-behavior-y: contain;
  }

  .site-header {
    padding-top: max(18px, env(safe-area-inset-top));
  }
}
