/* URSPIRE non-music frontend — shared Apple-inspired light/dark surface system */

body:has(main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"])) {
  background: #f5f5f7;
}

body:has(main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"])) .site-bg::after {
  opacity: 0;
}

body:has(main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"])) .glass-nav {
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(250, 250, 252, 0.78);
  box-shadow: none;
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}

main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) {
  --ui-blue: #0071e3;
  --ui-blue-hover: #0077ed;
  --ui-ink: #1d1d1f;
  --ui-muted: #6e6e73;
  --ui-surface: #fff;
  --ui-surface-soft: #f2f2f4;
  --ui-line: rgba(29, 29, 31, 0.1);
  --ui-shadow: 0 2px 14px rgba(0, 0, 0, 0.045);
  --ui-shadow-hover: 0 24px 58px rgba(0, 0, 0, 0.1);
  color: var(--ui-ink);
}

main.page-main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) {
  padding-top: clamp(44px, 6vw, 76px);
}

main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) .section {
  padding-top: clamp(70px, 9vw, 112px);
}

main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(h1, h2, h3, strong) {
  color: var(--ui-ink);
}

main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(p, li, dd, small, time) {
  color: var(--ui-muted);
}

main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) h1 {
  font-size: clamp(46px, 7vw, 78px);
  font-weight: 760;
  letter-spacing: -0.055em;
  line-height: 1.02;
}

main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) h2 {
  font-weight: 720;
  letter-spacing: -0.035em;
}

main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) .eyebrow {
  color: var(--ui-blue);
  font-size: 11px;
  letter-spacing: 0.12em;
}

/* Page heroes are typographic stages instead of glass cards. */
main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(.page-hero, .chat-hero) {
  padding: clamp(34px, 6vw, 72px) 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(.page-hero, .chat-hero)::before,
main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(.page-hero, .chat-hero)::after {
  content: none;
}

main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(.page-hero, .chat-hero) > p:not(.eyebrow) {
  max-width: 620px;
  color: var(--ui-muted);
  font-size: clamp(16px, 1.6vw, 19px);
  line-height: 1.75;
}

/* Shared content surfaces. */
main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(
  .glass-panel,
  .glass-card,
  .glass-banner,
  .about-card,
  .author-panel,
  .blog-feature-card,
  .game-panel,
  .game-card,
  .blog-card,
  .join-card,
  .role-card,
  .join-project-card,
  .join-preview,
  .link-profile,
  .link-card,
  .link-contact-card,
  .wechat-qr-page,
  .chat-shell,
  .chat-model-card,
  .community-card,
  .work-card,
  .account-hero,
  .account-overview-card,
  .account-profile-card,
  .account-security-card,
  .account-email-card,
  .account-tab-panel,
  .account-work-item,
  .account-liked-item
) {
  border-color: transparent;
  border-radius: 28px;
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(.glass-panel, .glass-card, .glass-banner)::before,
main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(.glass-panel, .glass-card, .glass-banner)::after {
  content: none;
}

main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(
  .page-hero,
  .blog-hero,
  .chat-hero
) {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(
  .about-card,
  .blog-feature-card,
  .game-card,
  .join-card,
  .role-card,
  .join-project-card,
  .link-card,
  .community-card,
  .work-card,
  .account-overview-card,
  .account-work-item,
  .account-liked-item
) {
  transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.32s ease;
}

@media (hover: hover) {
  main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(
    .about-card,
    .blog-feature-card,
    .game-card,
    .join-card,
    .role-card,
    .join-project-card,
    .link-card,
    .community-card,
    .work-card,
    .account-overview-card,
    .account-work-item,
    .account-liked-item
  ):hover {
    transform: translateY(-5px);
    box-shadow: var(--ui-shadow-hover);
  }
}

/* Clean editorial section headings. */
main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(
  .section-heading,
  .blog-section-heading,
  .account-tab-head
) {
  border-color: var(--ui-line);
}

main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(
  .section-heading h2,
  .blog-section-heading h2,
  .account-tab-head h2
) {
  color: var(--ui-ink);
}

/* Controls, filters and compact actions. */
main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) .btn {
  border-radius: 999px;
  box-shadow: none;
  font-weight: 650;
}

main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) .btn-primary {
  border-color: var(--ui-blue);
  background: var(--ui-blue);
  box-shadow: 0 8px 24px rgba(0, 113, 227, 0.18);
  color: #fff;
}

main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) .btn-primary:hover {
  border-color: var(--ui-blue-hover);
  background: var(--ui-blue-hover);
}

main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) .btn-ghost {
  border-color: transparent;
  background: rgba(0, 0, 0, 0.055);
  box-shadow: none;
  color: var(--ui-ink);
}

main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(
  .filter-row,
  .blog-filter-row,
  .work-filter-bar,
  .account-tabs-bar
) {
  gap: 8px;
  padding: 6px;
  border: 0;
  border-radius: 999px;
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow);
}

main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(
  .filter-row button,
  .blog-filter-row button,
  .work-filter-bar button,
  .account-tabs-bar button
) {
  border: 0;
  border-radius: 999px;
  background: transparent;
  box-shadow: none;
  color: var(--ui-muted);
}

main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(
  .filter-row button.is-active,
  .blog-filter-row button.is-active,
  .work-filter-bar button.is-active,
  .account-tabs-bar button.is-active
) {
  background: var(--ui-blue);
  color: #fff;
}

/* Forms */
main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(
  input,
  textarea,
  select,
  .chat-composer-bar
) {
  border-color: transparent;
  border-radius: 16px;
  background: var(--ui-surface-soft);
  box-shadow: none;
  color: var(--ui-ink);
}

main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(input, textarea, select):focus {
  border-color: var(--ui-blue);
  outline: 3px solid rgba(0, 113, 227, 0.14);
  outline-offset: 1px;
}

/* Images and cover treatments */
main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(
  .blog-avatar-box,
  .community-cover,
  .work-cover,
  .link-profile-logo,
  .link-qr-box,
  .account-hero-avatar,
  .account-avatar-preview
) {
  overflow: hidden;
  border-color: transparent;
  border-radius: 22px;
  background: var(--ui-surface-soft);
  box-shadow: none;
}

/* Tags and badges */
main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(
  .tags span,
  .badge,
  .account-status-pill,
  .game-badge,
  .blog-feature-label
) {
  border-color: transparent;
  border-radius: 999px;
  background: var(--ui-surface-soft);
  box-shadow: none;
  color: var(--ui-muted);
}

/* Blog */
main[data-page-key="blog"] .blog-hero {
  gap: clamp(24px, 4vw, 48px);
}

main[data-page-key="blog"] .author-panel {
  min-height: 0;
  grid-template-rows: auto auto;
  border: 0;
}

main[data-page-key="blog"] .author-info strong {
  margin-top: 0;
}

main[data-page-key="blog"] :is(.game-panel, .blog-feature-grid) {
  border-color: transparent;
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow);
}

/* The assistant hero carries one message only; no empty model-credit column. */
main[data-page-key="chat"] .chat-hero {
  grid-template-columns: minmax(0, 1fr);
}

/* Join */
main[data-page-key="join"] .join-number {
  display: none;
}

main[data-page-key="join"] :is(.join-card, .role-card)::before {
  display: none;
  content: none;
}

main[data-page-key="join"] .join-preview-list span {
  border: 0;
  background: transparent;
  box-shadow: none;
}

/* Links and WeChat */
main[data-page-key="links"] :is(.link-profile, .link-contact-card),
main[data-page-key="wechat"] .wechat-qr-page {
  border: 0;
}

/* Chat */
main[data-page-key="chat"] .chat-shell {
  overflow: hidden;
}

main[data-page-key="chat"] .chat-shell .chat-side {
  border-color: var(--ui-line);
  background: var(--ui-surface-soft);
}

main[data-page-key="chat"] .chat-shell .chat-content {
  background: var(--ui-surface);
}

main[data-page-key="chat"] :is(.chat-option, .prompt-list button, .chat-persona-chip) {
  border-color: transparent;
  background: var(--ui-surface-soft);
  box-shadow: none;
  color: var(--ui-ink);
}

main[data-page-key="chat"] :is(.chat-option.is-active, .chat-persona-chip.is-active) {
  background: rgba(0, 113, 227, 0.1);
  color: var(--ui-blue);
}

/* Community */
main[data-page-key="community"] .community-card {
  overflow: hidden;
  padding: 0;
}

main[data-page-key="community"] .community-body {
  padding: clamp(18px, 2.4vw, 28px);
}

/* Account */
main[data-page-key="account"] .account-hero {
  overflow: hidden;
}

main[data-page-key="account"] :is(.account-tabs-bar, .account-tab-panel) {
  border-color: transparent;
}

/* Footer follows the quieter page surface. */
body:has(main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"])) .footer {
  color: #6e6e73;
}

/* ===== Dark mode ===== */
:root[data-theme="dark"] body:has(main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"])) {
  background: #000;
}

:root[data-theme="dark"] body:has(main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"])) .glass-nav {
  border-bottom-color: rgba(255, 255, 255, 0.1);
  background: rgba(22, 22, 23, 0.78);
  box-shadow: none;
}

:root[data-theme="dark"] main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) {
  --ui-blue: #2997ff;
  --ui-blue-hover: #46a6ff;
  --ui-ink: #f5f5f7;
  --ui-muted: #a1a1a6;
  --ui-surface: #1c1c1e;
  --ui-surface-soft: #2c2c2e;
  --ui-line: rgba(255, 255, 255, 0.12);
  --ui-shadow: 0 1px 0 rgba(255, 255, 255, 0.035);
  --ui-shadow-hover: 0 28px 68px rgba(0, 0, 0, 0.56);
}

/* Shared navigation material: all frontend pages use the music space's
   transparent liquid-glass shell while retaining their own page identity. */
body:has(main) .glass-nav {
  width: calc(100% - (clamp(18px, 3.5vw, 64px) * 2));
  max-width: none;
  min-height: 76px;
  top: 14px;
  margin-top: 14px;
  padding: 10px 14px 10px 18px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.14);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 14px 38px rgba(15, 23, 42, 0.1);
  -webkit-backdrop-filter: blur(28px) saturate(150%);
  backdrop-filter: blur(28px) saturate(150%);
}

body:has(main) .nav-links a,
body:has(main) .nav-account-btn {
  border: 1px solid transparent;
  padding: 11px 16px;
  transition:
    color 240ms cubic-bezier(0.22, 1, 0.36, 1),
    background 240ms cubic-bezier(0.22, 1, 0.36, 1),
    border-color 240ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 240ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

body:has(main) .nav-links a:hover,
body:has(main) .nav-links a.active,
body:has(main) .nav-account-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

body:has(main) .nav-links a.active {
  color: #105fcf;
  border-color: rgba(23, 105, 224, 0.32);
  background: rgba(255, 255, 255, 0.24);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.46),
    0 0 0 1px rgba(23, 105, 224, 0.08);
}

body:has(main) .theme-toggle,
body:has(main) .menu-btn {
  width: 48px;
  height: 48px;
  border-color: rgba(255, 255, 255, 0.42);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
  -webkit-backdrop-filter: blur(28px) saturate(150%);
  backdrop-filter: blur(28px) saturate(150%);
}

:root[data-theme="dark"] body:has(main) .glass-nav,
:root:not([data-theme="light"]) body:has(main) .glass-nav {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.09);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 16px 42px rgba(0, 0, 0, 0.18);
}

:root[data-theme="dark"] body:has(main) .theme-toggle,
:root[data-theme="dark"] body:has(main) .menu-btn,
:root:not([data-theme="light"]) body:has(main) .theme-toggle,
:root:not([data-theme="light"]) body:has(main) .menu-btn {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.09);
}

@media (min-width: 921px) {
  :root[data-theme="dark"] body:has(main) .nav-links a.active,
  :root:not([data-theme="light"]) body:has(main) .nav-links a.active {
    color: #f8fbff;
    border-color: rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.13);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.2),
      0 0 0 1px rgba(41, 151, 255, 0.12);
  }
}

@media (max-width: 920px) {
  /* Chromium clips absolutely positioned descendants to the backdrop-filter
     sampling box. The expanded menu owns the blur, so the compact header can
     drop its filter while open without changing the glass appearance. */
  body:has(main) .glass-nav:has(.nav-links.show) {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }

  body:has(main) .glass-nav:has(.nav-links.show)::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    border: 1px solid rgba(255, 255, 255, 0.42);
    border-radius: inherit;
    background: rgba(255, 255, 255, 0.14);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.28),
      0 14px 38px rgba(15, 23, 42, 0.1);
    -webkit-backdrop-filter: blur(28px) saturate(150%);
    backdrop-filter: blur(28px) saturate(150%);
    pointer-events: none;
  }

  :root[data-theme="dark"] body:has(main) .glass-nav:has(.nav-links.show)::before,
  :root:not([data-theme="light"]) body:has(main) .glass-nav:has(.nav-links.show)::before {
    border-color: rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.09);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.18),
      0 16px 42px rgba(0, 0, 0, 0.18);
  }

  body:has(main) .nav-links {
    top: calc(100% + 14px);
    left: 0;
    right: 0;
    z-index: 80;
    max-height: 0;
    padding: 0 14px;
    gap: 2px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 30px;
    background:
      linear-gradient(145deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.08)),
      rgba(238, 246, 255, 0.1);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.48),
      inset 0 0 0 1px rgba(255, 255, 255, 0.08),
      0 24px 58px rgba(15, 32, 52, 0.16);
    -webkit-backdrop-filter: blur(30px) saturate(155%);
    backdrop-filter: blur(30px) saturate(155%);
    transform: translate3d(0, -12px, 0) scale(0.985);
    transform-origin: top center;
    will-change: transform, opacity, max-height;
    transition:
      max-height 400ms cubic-bezier(0.22, 1, 0.36, 1),
      padding 360ms cubic-bezier(0.22, 1, 0.36, 1),
      opacity 220ms ease,
      transform 360ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  body:has(main) .nav-links.show {
    max-height: min(620px, calc(100dvh - 116px - env(safe-area-inset-top, 0px)));
    padding: 16px 14px;
    opacity: 1;
    pointer-events: auto;
    transform: translate3d(0, 0, 0) scale(1);
  }

  body:has(main) .nav-links a {
    min-height: 58px;
    padding: 0 22px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex: 0 0 auto;
    border-color: transparent;
    border-radius: 18px;
    color: #28384b;
    background: transparent;
    box-shadow: none;
    text-align: left;
    font-size: 16px;
    letter-spacing: 0.02em;
    opacity: 0;
    transform: translate3d(0, -5px, 0);
    transition:
      opacity 180ms ease,
      transform 280ms cubic-bezier(0.22, 1, 0.36, 1),
      color 220ms ease,
      background 220ms ease,
      border-color 220ms ease,
      box-shadow 220ms ease;
  }

  body:has(main) .nav-links.show a {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }

  body:has(main) .nav-links.show a:nth-child(2) { transition-delay: 20ms; }
  body:has(main) .nav-links.show a:nth-child(3) { transition-delay: 40ms; }
  body:has(main) .nav-links.show a:nth-child(4) { transition-delay: 60ms; }
  body:has(main) .nav-links.show a:nth-child(5) { transition-delay: 80ms; }
  body:has(main) .nav-links.show a:nth-child(6) { transition-delay: 100ms; }
  body:has(main) .nav-links.show a:nth-child(7) { transition-delay: 120ms; }

  body:has(main) .nav-links a:hover {
    color: #1769e0;
    border-color: rgba(255, 255, 255, 0.34);
    background: rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
  }

  body:has(main) .nav-links a.active {
    color: #1769e0;
    border-color: rgba(255, 255, 255, 0.72);
    background: rgba(255, 255, 255, 0.2);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.46),
      0 0 0 1px rgba(23, 105, 224, 0.1);
  }

  :root[data-theme="dark"] body:has(main) .nav-links,
  :root:not([data-theme="light"]) body:has(main) .nav-links {
    border-color: rgba(255, 255, 255, 0.24);
    background:
      linear-gradient(145deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.035)),
      rgba(8, 17, 29, 0.2);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.2),
      inset 0 0 0 1px rgba(255, 255, 255, 0.04),
      0 28px 64px rgba(0, 0, 0, 0.28);
  }

  :root[data-theme="dark"] body:has(main) .nav-links a,
  :root:not([data-theme="light"]) body:has(main) .nav-links a {
    color: rgba(255, 255, 255, 0.82);
    background: transparent;
    box-shadow: none;
  }

  :root[data-theme="dark"] body:has(main) .nav-links a:hover,
  :root:not([data-theme="light"]) body:has(main) .nav-links a:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.08);
  }

  :root[data-theme="dark"] body:has(main) .nav-links a.active,
  :root:not([data-theme="light"]) body:has(main) .nav-links a.active {
    color: #79b7ff;
    border-color: rgba(255, 255, 255, 0.34);
    background: rgba(255, 255, 255, 0.12);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.2),
      0 0 0 1px rgba(41, 151, 255, 0.1);
  }
}

@media (max-width: 720px) {
  body:has(main) .glass-nav {
    width: calc(100% - 20px);
    min-height: 70px;
    top: calc(env(safe-area-inset-top, 0px) + 8px);
    margin-top: calc(env(safe-area-inset-top, 0px) + 8px);
    padding: 8px 10px 8px 12px;
    border-radius: 24px;
  }

  body:has(main) .theme-toggle,
  body:has(main) .menu-btn {
    width: 42px;
    height: 42px;
  }

  body:has(main) .nav-links {
    border-radius: 28px;
  }

  body:has(main) .nav-links.show {
    padding: 14px 12px;
  }

  body:has(main) .nav-links a {
    min-height: 54px;
    padding: 0 20px;
    border-radius: 17px;
    font-size: 15px;
  }
}

:root[data-theme="dark"] main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(
  .glass-panel,
  .glass-card,
  .glass-banner,
  .about-card,
  .author-panel,
  .blog-feature-card,
  .game-panel,
  .game-card,
  .blog-card,
  .join-card,
  .role-card,
  .join-project-card,
  .join-preview,
  .link-profile,
  .link-card,
  .link-contact-card,
  .wechat-qr-page,
  .chat-shell,
  .chat-model-card,
  .community-card,
  .work-card,
  .account-hero,
  .account-overview-card,
  .account-profile-card,
  .account-security-card,
  .account-email-card,
  .account-tab-panel,
  .account-work-item,
  .account-liked-item
) {
  border-color: transparent;
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow);
}

:root[data-theme="dark"] main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(.page-hero, .blog-hero, .chat-hero) {
  background: transparent;
  box-shadow: none;
}

:root[data-theme="dark"] main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) .btn-ghost {
  border-color: transparent;
  background: rgba(255, 255, 255, 0.11);
  color: var(--ui-ink);
}

:root[data-theme="dark"] main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(
  .filter-row,
  .blog-filter-row,
  .work-filter-bar,
  .account-tabs-bar
) {
  background: var(--ui-surface);
}

:root[data-theme="dark"] main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(
  .filter-row button,
  .blog-filter-row button,
  .work-filter-bar button,
  .account-tabs-bar button
) {
  border-color: transparent;
  background: transparent;
  color: var(--ui-muted);
}

:root[data-theme="dark"] main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(
  .filter-row button.is-active,
  .blog-filter-row button.is-active,
  .work-filter-bar button.is-active,
  .account-tabs-bar button.is-active
) {
  background: var(--ui-blue);
  color: #fff;
}

:root[data-theme="dark"] main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(
  input,
  textarea,
  select,
  .chat-composer-bar,
  .chat-option,
  .prompt-list button,
  .chat-persona-chip,
  .tags span,
  .badge,
  .account-status-pill,
  .game-badge,
  .blog-feature-label
) {
  border-color: transparent;
  background: var(--ui-surface-soft);
  box-shadow: none;
  color: var(--ui-ink);
}

:root[data-theme="dark"] main[data-page-key="chat"] .chat-shell .chat-side {
  border-color: var(--ui-line);
  background: #161617;
}

:root[data-theme="dark"] main[data-page-key="chat"] .chat-shell .chat-content {
  background: var(--ui-surface);
}

:root[data-theme="dark"] body:has(main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"])) .footer {
  color: #a1a1a6;
}

@media (max-width: 720px) {
  main.page-main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) {
    padding-top: 28px;
  }

  main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) .section {
    padding-top: 64px;
  }

  main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) h1 {
    font-size: clamp(40px, 12vw, 56px);
  }

  main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(
    .glass-panel,
    .glass-card,
    .glass-banner,
    .about-card,
    .author-panel,
    .blog-feature-card,
    .game-panel,
    .game-card,
    .blog-card,
    .join-card,
    .role-card,
    .join-project-card,
    .join-preview,
    .link-profile,
    .link-card,
    .link-contact-card,
    .wechat-qr-page,
    .chat-shell,
    .community-card,
    .work-card,
    .account-hero,
    .account-overview-card,
    .account-profile-card,
    .account-security-card,
    .account-email-card,
    .account-tab-panel,
    .account-work-item,
    .account-liked-item
  ) {
    border-radius: 22px;
  }

  main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) :is(
    .filter-row,
    .blog-filter-row,
    .work-filter-bar,
    .account-tabs-bar
  ) {
    border-radius: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  main[data-page-key]:not([data-page-key="music"]):not([data-page-key="home"]) * {
    scroll-behavior: auto;
  }
}

/* Specificity bridge for page-level legacy navigation themes. */
body:has(main) .glass-nav.glass-nav {
  border: 1px solid var(--floating-shell-border, rgba(82, 96, 112, 0.20)) !important;
  background: var(--floating-shell-background, rgba(248, 249, 251, 0.76)) !important;
  box-shadow: var(--floating-shell-shadow, 0 18px 52px rgba(25, 34, 46, 0.14)) !important;
  -webkit-backdrop-filter: var(--floating-shell-filter, blur(16px) saturate(135%)) !important;
  backdrop-filter: var(--floating-shell-filter, blur(16px) saturate(135%)) !important;
}

:root[data-theme="dark"] body:has(main) .glass-nav.glass-nav,
:root:not([data-theme="light"]) body:has(main) .glass-nav.glass-nav {
  border-color: var(--floating-shell-border, rgba(255, 255, 255, 0.15)) !important;
  background: var(--floating-shell-background, rgba(24, 27, 32, 0.78)) !important;
  box-shadow: var(--floating-shell-shadow, 0 20px 58px rgba(0, 0, 0, 0.46)) !important;
}

/* Compact shared navigation. Keep this final so older page themes cannot
   stretch the header or replace the single sliding selection indicator. */
body:has(main) .glass-nav.nav-compact {
  width: max-content !important;
  max-width: calc(100% - 28px) !important;
  min-height: 62px !important;
  padding: 8px 10px !important;
  border-radius: var(--floating-shell-radius, 999px) !important;
}

body:has(main) .nav-compact .nav-links a {
  width: var(--nav-item-width);
  height: var(--nav-item-height);
  flex-basis: var(--nav-item-width);
  padding: 0 12px;
  align-items: center;
  justify-content: center;
  line-height: 1;
  text-align: center;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

body:has(main) .nav-compact .nav-links a.active {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

body:has(main) .nav-compact .brand-logo,
body:has(main) .nav-compact .brand-logo:hover,
body:has(main) .nav-compact .brand-logo:focus-visible,
body:has(main) .nav-compact .brand-logo.is-home-active,
body:has(main) .nav-compact .brand-logo[aria-current="page"] {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  filter: none !important;
}

body:has(main) .nav-compact .brand-logo-box,
body:has(main) .nav-compact .brand-logo-box:hover,
body:has(main) .nav-compact .brand-logo:hover .brand-logo-box,
body:has(main) .nav-compact .brand-logo:focus-visible .brand-logo-box {
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  filter: none !important;
}

:root[data-theme="dark"] body:has(main) .nav-compact .brand-logo-box > img,
:root:not([data-theme="light"]) body:has(main) .nav-compact .brand-logo-box > img {
  filter: invert(1) brightness(1.18) !important;
}

body:has(main) .nav-compact :is(.nav-ai-search, .nav-account-btn, .theme-toggle) {
  width: 42px;
  height: 42px;
  flex-basis: 42px;
}

body:has(main) .nav-compact .nav-account-btn {
  padding: 0;
  border-color: rgba(255, 255, 255, 0.28);
}

:root[data-theme="dark"] body:has(main) .nav-compact :is(.nav-ai-search, .nav-account-btn, .theme-toggle),
:root:not([data-theme="light"]) body:has(main) .nav-compact :is(.nav-ai-search, .nav-account-btn, .theme-toggle) {
  color: #e5eef8;
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.055);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.10), 0 8px 22px rgba(0, 0, 0, 0.18);
}

:root[data-theme="dark"] body:has(main) .nav-compact :is(.nav-ai-search.is-active, .nav-ai-search[aria-current="page"], .nav-account-btn.is-active, .nav-account-btn.is-page-active, .nav-account-btn[aria-expanded="true"]),
:root:not([data-theme="light"]) body:has(main) .nav-compact :is(.nav-ai-search.is-active, .nav-ai-search[aria-current="page"], .nav-account-btn.is-active, .nav-account-btn.is-page-active, .nav-account-btn[aria-expanded="true"]) {
  color: #9ed7ff;
  border-color: rgba(126, 207, 255, 0.34);
  background: rgba(83, 169, 225, 0.15);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.17), 0 9px 24px rgba(0, 0, 0, 0.20);
}

body:has(main) .nav-compact .nav-active-slider {
  -webkit-backdrop-filter: blur(16px) saturate(155%);
  backdrop-filter: blur(16px) saturate(155%);
  transition: transform 460ms cubic-bezier(0.16, 1, 0.3, 1), opacity 120ms ease;
}

body:has(main) .nav-compact .nav-active-slider.is-traveling {
  transition-timing-function: cubic-bezier(0.18, 0.9, 0.24, 1), ease;
}

:root[data-theme="dark"] body:has(main) .nav-compact .nav-active-slider,
:root:not([data-theme="light"]) body:has(main) .nav-compact .nav-active-slider {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.09);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.16), 0 7px 18px rgba(0,0,0,0.14);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
}

@media (max-width: 920px) {
  body:has(main) .glass-nav.nav-compact {
    width: max-content !important;
    max-width: calc(100% - 20px) !important;
    min-height: 56px !important;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    overscroll-behavior-inline: contain;
  }

  body:has(main) .glass-nav.nav-compact::-webkit-scrollbar { display: none; }

  body:has(main) .nav-compact .nav-primary {
    position: relative;
    flex: 0 0 auto;
  }

  body:has(main) .nav-compact .nav-links {
    position: relative;
    inset: auto;
    z-index: 1;
    display: flex;
    width: auto;
    max-height: none;
    padding: 0;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    overflow: visible;
    opacity: 1;
    pointer-events: auto;
    transform: none;
    border: 0 !important;
    border-radius: 0;
    background: transparent !important;
    background-image: none !important;
    box-shadow: none !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }

  :root[data-theme="dark"] body:has(main) .nav-compact .nav-links,
  :root:not([data-theme="light"]) body:has(main) .nav-compact .nav-links {
    border: 0 !important;
    background: transparent !important;
    background-image: none !important;
    box-shadow: none !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }

  body:has(main) .nav-compact .nav-links a {
    width: var(--nav-item-width);
    height: var(--nav-item-height);
    flex-basis: var(--nav-item-width);
    min-height: var(--nav-item-height);
    padding: 0 10px;
    opacity: 1;
    transform: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
    text-align: center;
  }

  body:has(main) .nav-compact .nav-links a.active {
    border-color: transparent !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  body:has(main) .nav-compact .nav-active-slider { display: block; }
  body:has(main) .nav-compact .menu-btn { display: none !important; }

  body:has(main) .nav-compact :is(.nav-ai-search, .nav-account-btn, .theme-toggle) {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }
}

@media (min-width: 921px) {
  :root[data-theme="dark"] body:has(main) .nav-compact .nav-links a.active,
  :root:not([data-theme="light"]) body:has(main) .nav-compact .nav-links a.active {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
  }
}

@media (max-width: 640px) {
  body:has(main) .glass-nav.nav-compact {
    --mobile-nav-scale: 0.82;
    width: max-content !important;
    max-width: calc(100% - 12px) !important;
    min-height: 50px !important;
    padding: 5px 6px !important;
    gap: 5px;
    border-radius: var(--floating-shell-radius, 999px) !important;
  }

  body:has(main) .nav-compact .nav-primary {
    --nav-item-width: 58px;
    --nav-item-height: 38px;
    gap: 2px;
  }

  body:has(main) .nav-compact .brand-logo {
    width: 42px;
    min-width: 42px;
    height: 38px;
    min-height: 38px;
  }

  body:has(main) .nav-compact .brand-logo-box {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
  }

  body:has(main) .nav-compact .nav-links { gap: 2px; }
  body:has(main) .nav-compact .nav-links a {
    padding: 0 5px;
    font-size: 11px;
    white-space: nowrap;
  }

  body:has(main) .nav-compact :is(.nav-ai-search, .nav-account-btn, .theme-toggle) {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  body:has(main) .nav-compact .nav-controls { gap: 3px; }
  body:has(main) .nav-compact .nav-ai-search [data-icon] { font-size: 17px; }
  body:has(main) .nav-compact .theme-icon { font-size: 16px; }
  body:has(main) .nav-compact .nav-account-avatar {
    width: 27px;
    height: 27px;
  }

  body:has(main) .nav-compact .nav-active-slider {
    /* The navigation shell already performs the blur. Avoid resampling a
       moving backdrop-filter layer on mobile Safari during page changes. */
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    transform: translate3d(var(--nav-slider-x, 0px), 0, 0) scale(1.001);
    will-change: transform;
  }
}

@media (max-width: 375px) {
  body:has(main) .nav-compact .nav-primary { --nav-item-width: 54px; }
  body:has(main) .nav-compact .brand-logo { width: 40px; min-width: 40px; }
  body:has(main) .nav-compact :is(.nav-ai-search, .nav-account-btn, .theme-toggle) {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }
}
