/* ============================================================================
   TGRepo — UI Polish (override stylesheet) — BOLD v2
   Loaded after the Astro stylesheets. Tokens first, then components.
   Revert: remove the <link href="/custom.css"> tag from the page <head>.
   ============================================================================ */

/* --------------------------------------------------------------------------
   1. Design tokens — light
   -------------------------------------------------------------------------- */
:root {
  /* 系统字体栈：避免 Google Fonts @import 阻塞 FCP/LCP */
  --md-sys-typescale-font-plain: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans SC", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --site-bg: #E9F3F0;
  --glass-bg: rgba(255, 255, 255, .7);
  --glass-bg-hover: rgba(255, 255, 255, .95);
  --glass-border: rgba(15, 118, 110, .22);
  --glass-border-hover: rgba(15, 118, 110, .55);
  --glass-shadow:
    0 16px 40px -16px rgba(15, 118, 110, .42),
    0 3px 10px -4px rgba(15, 118, 110, .18),
    inset 0 1px 0 rgba(255, 255, 255, .95);
  --glass-shadow-hover:
    0 34px 66px -20px rgba(15, 118, 110, .6),
    0 10px 24px -8px rgba(15, 118, 110, .3),
    inset 0 1px 0 #fff;
  --glass-blur: blur(18px) saturate(160%);
  --glass-blur-card: blur(10px) saturate(150%);
  --glass-bg-nav: rgba(255, 255, 255, .62);
  --glass-border-nav: rgba(15, 118, 110, .22);
  --md-transition: .3s cubic-bezier(.2, .8, .2, 1);
  --tg-ring: 0 0 0 2px rgba(255, 255, 255, .95), 0 0 0 4px rgba(15, 118, 110, .5);
  --tg-grad: linear-gradient(135deg, #0F766E, #0D9488 45%, #2DD4BF);
  --tg-grad-warm: linear-gradient(135deg, #C2410C, #EA580C 50%, #F59E0B);
  --tg-border: linear-gradient(135deg,
    rgba(15, 118, 110, .55), rgba(45, 212, 191, .28) 45%, rgba(194, 65, 12, .45));
  --tg-border-hover: linear-gradient(135deg, #0F766E, #2DD4BF 45%, #C2410C);
  --tg-card-bg: linear-gradient(180deg, rgba(255, 255, 255, .82), rgba(255, 255, 255, .7));
  --tg-card-bg-hover: linear-gradient(180deg, rgba(255, 255, 255, .96), rgba(255, 255, 255, .86));
}

html, body {
  font-family: var(--md-sys-typescale-font-plain);
}

/* --------------------------------------------------------------------------
   2. Design tokens — dark
   -------------------------------------------------------------------------- */
:root[data-theme=dark] {
  --site-bg: #04100E;
  --glass-bg: rgba(18, 28, 27, .62);
  --glass-bg-hover: rgba(30, 44, 42, .85);
  --glass-border: rgba(45, 212, 191, .22);
  --glass-border-hover: rgba(45, 212, 191, .6);
  --glass-shadow:
    0 16px 40px -16px rgba(0, 0, 0, .72),
    0 3px 10px -4px rgba(0, 0, 0, .5),
    inset 0 1px 0 rgba(255, 255, 255, .08);
  --glass-shadow-hover:
    0 34px 66px -20px rgba(45, 212, 191, .38),
    0 10px 24px -8px rgba(0, 0, 0, .6),
    inset 0 1px 0 rgba(255, 255, 255, .14);
  --glass-bg-nav: rgba(6, 12, 12, .76);
  --glass-border-nav: rgba(45, 212, 191, .22);
  --tg-ring: 0 0 0 2px rgba(10, 18, 18, .95), 0 0 0 4px rgba(45, 212, 191, .55);
  --tg-grad: linear-gradient(135deg, #14B8A6, #2DD4BF 45%, #5EEAD4);
  --tg-grad-warm: linear-gradient(135deg, #FB923C, #F59E0B 50%, #FCD34D);
  --tg-border: linear-gradient(135deg,
    rgba(45, 212, 191, .65), rgba(129, 140, 248, .4) 45%, rgba(251, 146, 60, .5));
  --tg-border-hover: linear-gradient(135deg, #2DD4BF, #818CF8 45%, #FB923C);
  --tg-card-bg: linear-gradient(180deg, rgba(22, 34, 32, .78), rgba(15, 25, 24, .72));
  --tg-card-bg-hover: linear-gradient(180deg, rgba(32, 46, 44, .9), rgba(22, 34, 32, .84));
}

/* --------------------------------------------------------------------------
   3. Ambient background — vivid mesh + aurora + grain
   -------------------------------------------------------------------------- */
.glass-bg-blobs {
  background:
    radial-gradient(900px 620px at 6% -6%, #a9e2d6 0%, rgba(169, 226, 214, 0) 58%),
    radial-gradient(820px 620px at 102% -2%, #ffd9b0 0%, rgba(255, 217, 176, 0) 55%),
    radial-gradient(860px 640px at 50% 112%, #c3cffe 0%, rgba(195, 207, 254, 0) 58%),
    linear-gradient(135deg, #eef7f4, #e8eefc 52%, #fdf2e7) !important;
}

:root[data-theme=dark] .glass-bg-blobs {
  background:
    radial-gradient(900px 620px at 6% -6%, #0f5f52 0%, rgba(15, 95, 82, 0) 58%),
    radial-gradient(820px 620px at 102% -2%, #5a3314 0%, rgba(90, 51, 20, 0) 55%),
    radial-gradient(860px 640px at 50% 112%, #1e2a5e 0%, rgba(30, 42, 94, 0) 58%),
    linear-gradient(135deg, #04120f, #050b18 52%, #150b05) !important;
}

.glass-bg-blobs:before {
  content: "";
  position: absolute;
  inset: -25%;
  pointer-events: none;
  background: conic-gradient(from 0deg at 50% 50%,
    rgba(15, 118, 110, .30),
    rgba(45, 212, 191, .20),
    rgba(194, 65, 12, .22),
    rgba(99, 102, 241, .26),
    rgba(15, 118, 110, .30));
  filter: blur(90px);
  opacity: .75;
  animation: tg-aurora 26s linear infinite;
}

:root[data-theme=dark] .glass-bg-blobs:before {
  background: conic-gradient(from 0deg at 50% 50%,
    rgba(45, 212, 191, .35),
    rgba(129, 140, 248, .3),
    rgba(251, 146, 60, .26),
    rgba(45, 212, 191, .35));
  opacity: .8;
}

@keyframes tg-aurora { to { transform: rotate(360deg); } }

.glass-bg-blobs .blob { opacity: .45 !important; filter: blur(95px) !important; }
:root[data-theme=dark] .glass-bg-blobs .blob { opacity: .38 !important; }

.glass-bg-blobs:after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* --------------------------------------------------------------------------
   4. Navigation — topbar / drawer
   -------------------------------------------------------------------------- */
/* logo.png 已是站点青绿，不再做 hue-rotate（会把绿色拧成紫色） */

.md-topbar {
  background-color: var(--glass-bg) !important;
  border-bottom-color: var(--glass-border) !important;
  overflow: visible !important;
}
.topbar-right {
  overflow: visible !important;
  position: relative;
  z-index: 130;
}

.topbar-nav-item.active {
  background: var(--tg-grad) !important;
  color: #fff !important;
  box-shadow: 0 10px 24px -6px rgba(15, 118, 110, .8) !important;
  transform: translateY(-1px);
}

.topbar-nav-item:not(.active):hover {
  background-color: rgba(15, 118, 110, .14) !important;
  color: var(--md-sys-color-primary) !important;
  transform: translateY(-1px);
}

.md-drawer { background-color: var(--glass-bg) !important; }

.md-drawer-item.active {
  background: var(--tg-grad) !important;
  color: #fff !important;
  box-shadow: 0 10px 24px -6px rgba(15, 118, 110, .8) !important;
}

.md-drawer-item:not(.active):hover { background-color: rgba(15, 118, 110, .14) !important; }

:root[data-theme=dark] .topbar-nav-item.active,
:root[data-theme=dark] .md-drawer-item.active {
  background: var(--tg-grad) !important;
  color: #002b26 !important;
  box-shadow: 0 10px 28px -6px rgba(45, 212, 191, .8) !important;
}

:root[data-theme=dark] .topbar-nav-item:not(.active):hover,
:root[data-theme=dark] .md-drawer-item:not(.active):hover {
  background-color: rgba(45, 212, 191, .16) !important;
}

/* --------------------------------------------------------------------------
   5. Hero — animated gradient + glow
   -------------------------------------------------------------------------- */
.home-hero { isolation: isolate; }

.home-hero:before {
  content: "";
  position: absolute;
  top: 48%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(680px, 94%);
  height: 220px;
  background: radial-gradient(ellipse at center,
    rgba(15, 118, 110, .42), rgba(194, 65, 12, .2) 45%, transparent 72%);
  filter: blur(38px);
  z-index: -1;
  pointer-events: none;
}

:root[data-theme=dark] .home-hero:before {
  background: radial-gradient(ellipse at center,
    rgba(45, 212, 191, .45), rgba(129, 140, 248, .28) 45%, transparent 72%);
}

.hero-title {
  background: linear-gradient(118deg, #0B6B63 0%, #0F766E 28%, #14B8A6 52%, #C2410C 100%) !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  filter: drop-shadow(0 12px 30px rgba(15, 118, 110, .5)) !important;
}

:root[data-theme=dark] .hero-title {
  background: linear-gradient(118deg, #2DD4BF 0%, #5EEAD4 32%, #A5B4FC 58%, #FB923C 100%) !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  filter: drop-shadow(0 12px 34px rgba(45, 212, 191, .55)) !important;
}

@keyframes tg-gradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* --------------------------------------------------------------------------
   6. Search
   -------------------------------------------------------------------------- */
.home-search-box {
  background: rgba(255, 255, 255, .85) !important;
  border-color: rgba(15, 118, 110, .28) !important;
  box-shadow:
    0 22px 48px -18px rgba(15, 118, 110, .6),
    0 2px 8px -4px rgba(15, 118, 110, .24),
    inset 0 1px 0 #fff !important;
}

.home-search-box:hover {
  border-color: var(--glass-border-hover) !important;
  box-shadow:
    0 30px 64px -20px rgba(15, 118, 110, .7),
    0 0 0 5px rgba(15, 118, 110, .14),
    inset 0 1px 0 #fff !important;
  transform: translateY(-3px) !important;
}

.search-trigger-box {
  background-color: var(--glass-bg) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7) !important;
}

:root[data-theme=dark] .home-search-box {
  background: rgba(24, 38, 36, .8) !important;
  box-shadow:
    0 22px 48px -18px rgba(0, 0, 0, .75),
    0 0 0 5px rgba(45, 212, 191, .12),
    inset 0 1px 0 rgba(255, 255, 255, .08) !important;
}

:root[data-theme=dark] .search-trigger-box {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06) !important;
}

/* --------------------------------------------------------------------------
   7. Cards — always-on gradient border + lift + glow
   -------------------------------------------------------------------------- */
.latest-card-item,
.md-card,
.friend-link-card,
.rec-panel,
.contact-card,
.md-detail-article {
  background: var(--tg-card-bg) padding-box, var(--tg-border) border-box !important;
  border: 1.5px solid transparent !important;
}

.latest-card-item,
.friend-link-card { border-radius: 20px !important; }

.md-card { border-radius: 22px !important; }

.rec-panel { border-radius: 24px !important; }

.latest-card-item,
.md-card,
.friend-link-card,
.rec-panel { box-shadow: var(--glass-shadow) !important; }

.latest-card-item:hover,
.md-card:hover,
.friend-link-card:hover {
  background: var(--tg-card-bg-hover) padding-box, var(--tg-border-hover) border-box !important;
  transform: translateY(-7px) scale(1.02) !important;
  box-shadow: var(--glass-shadow-hover) !important;
}

.rec-panel:hover {
  background: var(--tg-card-bg-hover) padding-box, var(--tg-border-hover) border-box !important;
  transform: translateY(-5px) !important;
  box-shadow: var(--glass-shadow-hover) !important;
}

.promo-card-item,
.detail-promo-card-item { border-radius: 16px !important; }

.promo-card-item:hover,
.detail-promo-card-item:hover {
  box-shadow: var(--glass-shadow-hover) !important;
  transform: translateY(-4px) !important;
}

.latest-card-avatar,
.md-card-avatar,
.rec-item-avatar {
  border-color: transparent !important;
  box-shadow: var(--tg-ring) !important;
}

/* --------------------------------------------------------------------------
   8. Chips / tags / buttons
   -------------------------------------------------------------------------- */
.md-chip {
  background: var(--tg-card-bg) padding-box, var(--tg-border) border-box !important;
  border: 1.5px solid transparent !important;
}

.md-chip.active {
  background: var(--tg-grad) !important;
  color: #fff !important;
  border-color: transparent !important;
  box-shadow: 0 10px 24px -8px rgba(15, 118, 110, .8) !important;
}

.quick-tag {
  background: var(--tg-card-bg) padding-box, var(--tg-border) border-box !important;
  border: 1.5px solid transparent !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .8),
    0 8px 20px -10px rgba(15, 118, 110, .5) !important;
  flex-shrink: 0;
}

.quick-tag:hover {
  transform: translateY(-3px) !important;
  background: var(--tg-card-bg-hover) padding-box, var(--tg-border-hover) border-box !important;
  box-shadow: var(--glass-shadow-hover) !important;
}

/*
  PC (>600px): title sits left of search. Put quick-tags in the same
  column as the search box so the row centers under the bar (not the page).
*/
@media (min-width: 601px) {
  .home-hero {
    display: grid !important;
    grid-template-columns: auto minmax(0, 560px);
    justify-content: center;
    align-items: center;
    column-gap: 20px;
    row-gap: 8px;
  }
  .home-hero > .hero-main-row {
    display: contents;
  }
  .home-hero .hero-title {
    grid-column: 1;
    grid-row: 1;
  }
  .home-hero .home-search-box {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    max-width: none;
  }
  .home-hero .quick-tags-container {
    grid-column: 2;
    grid-row: 2;
    width: 100%;
    max-width: none;
    margin-top: 0;
    flex-wrap: nowrap !important;
    justify-content: center;
  }
}

/* Mobile: left-align wrap (ZH/EN); PC layout above stays unchanged */
@media (max-width: 600px) {
  .quick-tags-container {
    justify-content: flex-start !important;
    padding-inline: 4px;
  }
}

.md-button-tonal {
  background: var(--tg-grad) !important;
  color: #fff !important;
  box-shadow: 0 10px 26px -10px rgba(15, 118, 110, .75) !important;
}

.md-button-tonal:hover {
  background: var(--tg-grad) !important;
  color: #fff !important;
  filter: brightness(1.08) saturate(1.1);
  transform: translateY(-2px) !important;
  box-shadow: 0 16px 34px -10px rgba(15, 118, 110, .85) !important;
}

:root[data-theme=dark] .md-button-tonal { color: #002b26 !important; }

/* --------------------------------------------------------------------------
   9. Sections / detail
   -------------------------------------------------------------------------- */
.section-title-bar {
  position: relative;
  border-bottom: none !important;
  padding-bottom: 12px;
}

.section-title-bar:after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg,
    var(--md-sys-color-primary), rgba(45, 212, 191, .4) 42%, transparent 85%);
}

.section-title-icon {
  background: var(--tg-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.md-detail-article { border-radius: 26px !important; }
.quick-stats-grid { border-color: rgba(15, 118, 110, .2) !important; }
:root[data-theme=dark] .quick-stats-grid { border-color: rgba(45, 212, 191, .2) !important; }

/* --------------------------------------------------------------------------
   10. Footer / bottom nav / modal
   -------------------------------------------------------------------------- */
.md-footer {
  background-color: var(--glass-bg) !important;
  border-top-color: var(--glass-border) !important;
}

.md-bottom-nav {
  background-color: var(--glass-bg-nav) !important;
  border-color: var(--glass-border-nav) !important;
  box-shadow: 0 20px 44px -14px rgba(15, 118, 110, .6) !important;
}

:root[data-theme=dark] .md-bottom-nav {
  box-shadow: 0 20px 44px -12px rgba(0, 0, 0, .85) !important;
}

.md-bottom-nav-item.active {
  color: var(--md-sys-color-primary) !important;
  background: linear-gradient(135deg, rgba(15, 118, 110, .22), rgba(45, 212, 191, .12)) !important;
  border-color: rgba(15, 118, 110, .38) !important;
  box-shadow: inset 0 1px 0 #fff, 0 8px 18px -6px rgba(15, 118, 110, .7) !important;
}

:root[data-theme=dark] .md-bottom-nav-item.active {
  background: linear-gradient(135deg, rgba(45, 212, 191, .24), rgba(129, 140, 248, .14)) !important;
  border-color: rgba(45, 212, 191, .44) !important;
  box-shadow: 0 8px 20px -6px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 255, 255, .12) !important;
}

.search-modal-card {
  background: rgba(255, 255, 255, .94) !important;
  border-color: var(--glass-border) !important;
}

:root[data-theme=dark] .search-modal-card { background: rgba(14, 22, 21, .95) !important; }

/* Search close — pill with Esc hint (desktop floats under modal) */
.search-modal-close {
  gap: 8px !important;
  min-width: 44px;
  min-height: 40px;
  padding: 8px 14px !important;
  border-radius: 999px !important;
  background: rgba(15, 23, 22, .58) !important;
  border: 1px solid rgba(255, 255, 255, .22) !important;
  color: #fff !important;
  font-size: 15px !important;
  line-height: 1 !important;
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .32);
  bottom: -44px !important;
}
.search-modal-close i {
  font-size: 15px !important;
  line-height: 1;
}
.search-modal-close:hover {
  color: #fff !important;
  background: rgba(15, 118, 110, .88) !important;
  border-color: rgba(45, 212, 191, .45) !important;
  transform: translate(-50%) translateY(-1px) !important;
}
.search-modal-close:focus-visible {
  outline: 2px solid #2DD4BF;
  outline-offset: 3px;
}
.search-modal-close .search-close-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 20px;
  padding: 0 6px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, .28);
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font: 600 11px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .03em;
  pointer-events: none;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .18);
}
@media (max-width: 600px) {
  /* Tall enough for results, still not edge-to-edge */
  .search-modal-overlay {
    align-items: flex-start !important;
    padding: 10px !important;
    padding-top: max(10px, env(safe-area-inset-top, 0px)) !important;
  }
  .search-modal-card {
    height: min(70dvh, calc(100dvh - 20px)) !important;
    max-height: min(70dvh, calc(100dvh - 20px)) !important;
    margin-top: 2vh !important;
  }
  .search-modal-body {
    min-height: 0 !important;
    flex: 1 1 auto !important;
  }
  .search-suggestions-card {
    flex: 1 1 auto !important;
    min-height: 180px !important;
  }
  /* Mobile: plain top-right X only — no Esc pill */
  .search-modal-close {
    inset: 8px 8px auto auto !important;
    bottom: auto !important;
    left: auto !important;
    transform: none !important;
    gap: 0 !important;
    min-width: 36px !important;
    min-height: 36px !important;
    width: 36px !important;
    height: 36px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    background: transparent !important;
    border: none !important;
    color: var(--md-sys-color-on-surface-variant) !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
  .search-modal-close i {
    font-size: 18px !important;
  }
  .search-modal-close:hover,
  .search-modal-close:active {
    color: var(--md-sys-color-primary) !important;
    background: rgba(15, 118, 110, .1) !important;
    transform: none !important;
  }
  .search-modal-close .search-close-kbd {
    display: none !important;
  }
}

/* --------------------------------------------------------------------------
   11. Utility surfaces on go / link / 404 pages (dark)
   -------------------------------------------------------------------------- */
:root[data-theme=dark] .go-card,
:root[data-theme=dark] .loading-container,
:root[data-theme=dark] .error-card {
  background: rgba(14, 22, 21, .94) !important;
  border-color: rgba(45, 212, 191, .22) !important;
}

/* --------------------------------------------------------------------------
   12. Announcement
   -------------------------------------------------------------------------- */
.announcement-banner {
  background-color: var(--glass-bg) !important;
  border-left-color: var(--md-sys-color-primary) !important;
}

/* --------------------------------------------------------------------------
   13. Selection / focus / scrollbar
   -------------------------------------------------------------------------- */
::selection { background: rgba(15, 118, 110, .3); color: inherit; }
:root[data-theme=dark] ::selection { background: rgba(45, 212, 191, .34); }

:focus-visible { outline: 2px solid var(--md-sys-color-primary); outline-offset: 3px; border-radius: 6px; }

::-webkit-scrollbar-thumb { background: linear-gradient(#0F766E, #2DD4BF) !important; border-radius: 3px; }
:root[data-theme=dark] ::-webkit-scrollbar-thumb { background: linear-gradient(#2DD4BF, #818CF8) !important; }

/* --------------------------------------------------------------------------
   14. Desktop rhythm
   -------------------------------------------------------------------------- */
@media (min-width: 901px) {
  .md-topbar { height: 64px !important; padding: 0 24px !important; }
  .md-content { padding: 28px 32px !important; }
}

/* --------------------------------------------------------------------------
   15. Micro-interactions — staggered entrance
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  .latest-card-item,
  .promo-card-item,
  .md-card,
  .friend-link-card,
  .rec-panel {
    animation: tg-rise .55s cubic-bezier(.2, .8, .2, 1) backwards;
  }
  .latest-card-item:nth-child(1), .promo-card-item:nth-child(1), .md-card:nth-child(1) { animation-delay: .02s; }
  .latest-card-item:nth-child(2), .promo-card-item:nth-child(2), .md-card:nth-child(2) { animation-delay: .06s; }
  .latest-card-item:nth-child(3), .promo-card-item:nth-child(3), .md-card:nth-child(3) { animation-delay: .10s; }
  .latest-card-item:nth-child(4), .promo-card-item:nth-child(4), .md-card:nth-child(4) { animation-delay: .14s; }
  .latest-card-item:nth-child(5), .promo-card-item:nth-child(5), .md-card:nth-child(5) { animation-delay: .18s; }
  .latest-card-item:nth-child(6), .promo-card-item:nth-child(6), .md-card:nth-child(6) { animation-delay: .22s; }
  .latest-card-item:nth-child(7), .promo-card-item:nth-child(7), .md-card:nth-child(7) { animation-delay: .26s; }
  .latest-card-item:nth-child(8), .promo-card-item:nth-child(8), .md-card:nth-child(8) { animation-delay: .30s; }

  @keyframes tg-rise {
    from { opacity: 0; transform: translateY(16px) scale(.98); }
    to { opacity: 1; transform: none; }
  }
}

@media (prefers-reduced-motion: reduce) {
  .latest-card-item,
  .promo-card-item,
  .md-card,
  .friend-link-card,
  .rec-panel,
  .hero-title,
  .glass-bg-blobs:before,
  .blob { animation: none !important; }
}

/* --------------------------------------------------------------------------
   Scroll progress FAB — fix skewed outer ring
   Astro Layout uses border-box + 48×48 + 1px border, so content becomes 46×46
   while the SVG stays 48×48 → ring looks off-center. Align by content-box +
   SVG filled to the content area; keep circular clip.
   -------------------------------------------------------------------------- */
.scroll-widget.circular {
  box-sizing: content-box;
  width: 48px;
  height: 48px;
  padding: 0;
  overflow: hidden;
  border-radius: 50%;
  /* avoid sub-pixel warp on hover scale */
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transform: translateZ(0);
}
.scroll-widget.circular:hover {
  transform: translateY(-4px) scale(1.05) translateZ(0);
}
.scroll-widget.circular .scroll-progress-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 48px !important;
  height: 48px !important;
  max-width: none;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  overflow: visible;
}
.scroll-widget.circular .scroll-content {
  border-radius: 50%;
}

/* --------------------------------------------------------------------------
   Language switcher (framework i18n)
   -------------------------------------------------------------------------- */
/* FOUC guard also inlined via tgrepo-i18n-boot-css; keep here as backup */
html.tgrepo-i18n-pending body {
  visibility: hidden !important;
}
.tgrepo-lang-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  margin-left: 4px;
  z-index: 130;
}
.tgrepo-lang-trigger {
  appearance: none;
  border: 1px solid var(--glass-border, rgba(0, 0, 0, .08));
  background: var(--glass-bg, rgba(255, 255, 255, .55));
  color: var(--md-sys-color-on-surface, inherit);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 36px;
  min-width: 36px;
  padding: 0 10px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .01em;
  line-height: 1;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.tgrepo-lang-trigger:hover {
  border-color: var(--glass-border-hover, rgba(15, 118, 110, .28));
  background: var(--glass-bg-hover, rgba(255, 255, 255, .75));
}
.tgrepo-lang-flag {
  flex: 0 0 auto;
  font-size: 15px;
  line-height: 1;
  font-weight: 400;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",
    "Noto Color Emoji", "Twemoji Mozilla", "Android Emoji", sans-serif;
}
.tgrepo-lang-label {
  flex: 0 0 auto;
  line-height: 1;
  white-space: nowrap;
}
/* lang-menu multi */
.tgrepo-lang-menu {
  max-height: min(70vh, 320px);
  overflow-x: hidden;
  overflow-y: auto;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 168px;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, .1);
  background: #fff;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: 0 12px 32px rgba(15, 30, 28, .18);
  z-index: 140;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tgrepo-lang-menu[hidden] {
  display: none !important;
}
.tgrepo-lang-option {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--md-sys-color-on-surface, inherit);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  word-break: keep-all;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.tgrepo-lang-option .tgrepo-lang-flag {
  width: 1.35em;
  text-align: center;
}
.tgrepo-lang-option:hover {
  background: rgba(15, 118, 110, .1);
  color: var(--md-sys-color-primary, #0F766E);
}
.tgrepo-lang-option.is-active {
  background: var(--tg-grad, linear-gradient(135deg, #0F766E, #2DD4BF));
  color: #fff;
}
html[data-theme="dark"] .tgrepo-lang-trigger,
html.dark .tgrepo-lang-trigger {
  background: rgba(20, 30, 28, .55);
  border-color: rgba(45, 212, 191, .22);
}
html[data-theme="dark"] .tgrepo-lang-menu,
html.dark .tgrepo-lang-menu {
  background: #1a2422;
  border-color: rgba(45, 212, 191, .28);
}
html[data-theme="dark"] .tgrepo-lang-option:hover,
html.dark .tgrepo-lang-option:hover {
  background: rgba(45, 212, 191, .14);
  color: var(--md-sys-color-primary, #2DD4BF);
}
@media (max-width: 900px) {
  .tgrepo-lang-switch { margin-left: 2px; }
  .tgrepo-lang-trigger {
    height: 34px;
    padding: 0 8px;
    font-size: 11px;
    gap: 4px;
  }
  .tgrepo-lang-flag { font-size: 14px; }
  .tgrepo-lang-menu {
    min-width: 168px;
    right: 0;
  }
}
