:root {
  --topbar-height: 108px;
}

.topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 50;
  width: 100%;
  min-height: var(--topbar-height);
  border-bottom: 0;
  background: var(--bg);
}

body {
  padding-top: var(--topbar-height);
}

/* Draw the divider inside the header without a fractional border box. */
.topbar::after {
  content: '';
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 1px;
  background-color: var(--line, var(--dm-hover, #e5e7eb));
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.topbar.scrolled::after {
  opacity: 1;
}

.topbar-inner {
  display: flex;
  position: relative;
  width: 100%;
  max-width: 1280px;
  min-height: var(--topbar-height);
  margin: 0 auto;
  align-items: center;
  padding: 0 48px;
}

.topbar-brand {
  z-index: 1;
  flex: 0 0 auto;
}

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

.topbar-tools {
  display: none;
  align-items: center;
  gap: 10px;
}

.mobile-menu-toggle {
  display: none;
}

.mobile-menu-panel {
  display: contents;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--public-brand-gap);
  color: var(--ink);
  font-size: var(--public-brand-font-size);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.brand-logo {
  display: block;
  width: var(--public-brand-logo-size);
  height: var(--public-brand-logo-size);
  flex: 0 0 auto;
}

.site-nav {
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
}

.topbar .nav-link {
  font-size: 16.5px;
}

/* Navigation uses color feedback, matching the Portal sidebar. The separate
   Log In / Portal action retains its existing press behavior. */
.topbar :is(.site-nav .nav-link, .mobile-menu-toggle) {
  transform: none;
  transition: background-color 120ms ease, color 120ms ease;
}

.topbar :is(.site-nav .nav-link, .mobile-menu-toggle):active {
  transform: none;
  color: var(--ink);
  background: var(--portal-sidebar-press);
}

/* About stays a plain text link in every interaction state. */
.topbar .site-nav .nav-link[data-nav="system"] {
  background: transparent;
  transition: color 120ms ease;
}

.site-nav > .nav-link,
.site-nav .research-toggle {
  min-height: 36px;
  padding: 6px 9px;
  line-height: 24px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-actions .nav-login {
  justify-content: center;
  min-width: 122px;
  min-height: 36px;
  padding: 6px 34px;
  font-weight: 400;
  line-height: 24px;
}

.topbar-actions .nav-login,
.topbar-actions .nav-login.active {
  color: #fff;
  background: var(--brand-color);
}
@media (hover: hover) and (pointer: fine) {
  .topbar-actions .nav-login:hover {
    color: #fff;
    background: var(--brand-color);
  }
}

.research-nav {
  /* Match ArxivStone's SharedMegaMenu panel, content and chevron motion. */
  --research-panel-duration: 160ms;
  --research-fade-duration: 120ms;
  --research-content-duration: 140ms;
  --research-resize-duration: 180ms;
  --research-chevron-duration: 300ms;
  --research-easing: cubic-bezier(0.2, 0.8, 0.2, 1);
  position: relative;
}

.research-toggle {
  gap: 8px;
  border: 0;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
}

.research-toggle[aria-expanded="true"] {
  color: var(--ink);
  background: var(--hover);
}

.research-chevron {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--research-chevron-duration) cubic-bezier(0.16, 1, 0.3, 1);
}

.research-nav.is-open .research-chevron {
  transform: rotate(180deg);
}

.research-menu {
  position: absolute;
  top: 100%;
  left: 50%;
  z-index: 65;
  min-width: 235px;
  padding-top: 9px;
  opacity: 0;
  transform: translateX(-50%) translateY(4px) scale(0.995);
  transform-origin: top center;
  backface-visibility: hidden;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity var(--research-fade-duration) var(--research-easing),
    transform var(--research-panel-duration) var(--research-easing),
    visibility 0s linear var(--research-panel-duration);
}

.research-nav.is-open .research-menu {
  opacity: 1;
  transform: translateX(-50%);
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}

.research-menu-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px;
  border: 0.8px solid var(--line);
  border-radius: 0;
  background: var(--card);
  box-shadow: 0 12px 30px rgb(0 0 0 / 10%);
  opacity: 0;
  transform: translateY(4px);
  transition:
    opacity var(--research-content-duration) var(--research-easing),
    transform var(--research-content-duration) var(--research-easing);
}

.research-nav.is-open .research-menu-links {
  opacity: 1;
  transform: none;
}

.research-menu-links .nav-link {
  width: 100%;
  min-height: 42px;
  padding: 9px 13px;
  font-size: 16px;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .topbar :is(.site-nav .nav-link, .mobile-menu-toggle) {
    transition: none;
  }
  .research-nav {
    --research-panel-duration: 0s;
    --research-fade-duration: 0s;
    --research-content-duration: 0s;
    --research-resize-duration: 0s;
    --research-chevron-duration: 0s;
  }
}

.shell {
  width: 100%;
  max-width: 1240px;
  min-width: 0;
  flex: 1;
  margin: 0 auto;
  /* No overflow-x: clip here: it makes sticky descendants (doc TOC,
     page navigation) jitter while scrolling in Safari (WebKit bug
     247130). The viewport-level clip on html covers horizontal
     overflow protection. */
  padding: 38px 24px 24px;
}

.shell[aria-busy="true"] {
  min-height: 520px;
}

.app-shell-fallback {
  padding: 48px 0 20px;
}

.app-shell-fallback-copy {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 15px;
}

.page {
  display: none;
  max-width: 100%;
  min-width: 0;
}

.page.active {
  display: block;
}

html[data-initial-page="home"] #systemRealizationPage[data-prerender],
html[data-initial-page="about"] #aboutPage[data-prerender] {
  display: block;
}

html[data-initial-page="home"] .app-shell-fallback,
html[data-initial-page="about"] .app-shell-fallback,
html[data-lang="en"] [data-initial-lang="zh"],
html[data-lang="zh"] [data-initial-lang="en"] {
  display: none;
}

html[data-initial-page="home"] body,
html[data-initial-page="about"] body,
body:has(#systemRealizationPage.active, #aboutPage.active) {
  min-height: 100vh;
  min-height: 100dvh;
}

html[data-initial-page="home"],
html[data-initial-page="about"],
html:has(#systemRealizationPage.active, #aboutPage.active) {
  scrollbar-gutter: stable;
}

/* Retain the old painted page beneath the new one: there is no blank frame
   between the blue home panel and About, and no fade or scale on the header. */
html.public-page-transition {
  scroll-behavior: auto;
  view-transition-name: none;
}

.public-page-transition .shell { view-transition-name: public-content; }
.public-page-transition .site-footer { view-transition-name: public-footer; }

.public-page-transition::view-transition {
  pointer-events: none;
  clip-path: inset(var(--topbar-height) 0 0);
}

.public-page-transition::view-transition-old(public-content) {
  animation: public-page-exit 200ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
  mix-blend-mode: plus-lighter;
}

.public-page-transition::view-transition-new(public-content) {
  animation: public-page-enter 200ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
  mix-blend-mode: plus-lighter;
}

.public-page-transition::view-transition-image-pair(public-content) {
  isolation: isolate;
  overflow: hidden;
}

.public-page-transition::view-transition-old(public-content),
.public-page-transition::view-transition-new(public-content) {
  width: 100%;
  height: auto;
}

.public-page-transition::view-transition-group(public-content),
.public-page-transition::view-transition-group(public-footer) {
  animation-duration: 200ms;
  animation-timing-function: cubic-bezier(0.2, 0.7, 0.2, 1);
}

.public-page-transition::view-transition-old(public-footer) { display: none; }

.public-page-transition::view-transition-new(public-footer) {
  animation: none;
  mix-blend-mode: normal;
}

@keyframes public-page-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes public-page-exit {
  from { opacity: 1; }
  to { opacity: 0; }
}

html[data-initial-page="home"] .shell,
html[data-initial-page="about"] .shell,
.shell:has(#systemRealizationPage.active, #aboutPage.active) {
  max-width: none;
  padding: 0;
  background: var(--bg);
}

html[data-initial-page="home"] .shell[aria-busy="true"] {
  min-height: 0;
}

.home-statement {
  display: grid;
  min-height: 400px;
  place-items: center;
  align-content: center;
  row-gap: 48px;
  padding: 112px 48px;
  color: #fff;
  background: var(--brand-color);
}

.home-statement-title {
  width: 100%;
  max-width: 1184px;
  margin: 0;
  font-family: var(--font-sans);
  font-size: clamp(28px, 2.3vw, 36px);
  font-weight: 300;
  line-height: 1.35;
  letter-spacing: -0.015em;
  text-align: center;
  text-wrap: balance;
}

.home-inquiry {
  max-width: 100%;
  margin: 0;
  color: rgb(255 255 255 / 80%);
  font-size: clamp(14px, 1.1vw, 16px);
  font-weight: 400;
  line-height: 1.65;
  text-align: center;
  text-wrap: balance;
}

.home-inquiry a {
  color: inherit;
  white-space: nowrap;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

@media (hover: hover) and (pointer: fine) {
  .home-inquiry a:hover { color: #fff; }
}

.content-page {
  max-width: 920px;
  margin: 0 auto;
  padding: 32px 0 20px;
}

.about-page {
  max-width: 1048px;
  padding: calc(38px + clamp(30px, 5vw, 72px)) 24px calc(24px + clamp(40px, 6vw, 96px));
}

@media (max-width: 620px) {
  .content-page.about-page { padding: 34px 14px 60px; }
}

.about-page h1 {
  margin-bottom: 28px;
  color: var(--brand-ink);
  font-size: clamp(36px, 3.5vw, 48px);
}

.about-description {
  margin: 0;
  color: var(--ink-soft);
  font-size: clamp(17px, 1.4vw, 20px);
  line-height: 1.85;
}

.shell:has(.has-doc-toc.active) {
  max-width: none;
  padding-left: 8px;
}

.content-page.has-doc-toc {
  max-width: none;
}

.doc-layout {
  display: grid;
  width: 100%;
  min-width: 0;
  grid-template-columns: 320px minmax(40px, 1fr) minmax(0, 760px) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "toc . intro ."
    "toc . doc .";
  justify-content: stretch;
  align-items: start;
}

.doc-toc-rail {
  grid-area: toc;
  align-self: stretch;
  min-width: 0;
  min-height: 0;
  margin-top: calc(-38px - 32px);
}

.doc-layout .strategy-intro {
  grid-area: intro;
  min-width: 0;
}

.doc-layout .strategy-document {
  grid-area: doc;
  min-width: 0;
}

@media (max-width: 1020px) {
  .shell:has(.has-doc-toc.active) {
    padding-left: 24px;
  }

  .content-page.has-doc-toc {
    max-width: 920px;
  }

  .doc-layout {
    grid-template-columns: minmax(0, 100%);
    grid-template-rows: none;
    grid-template-areas:
      "intro"
      "toc"
      "doc";
    gap: 20px;
  }

  .doc-toc-rail {
    margin-top: 0;
  }

  .doc-toc {
    position: static;
    margin-left: 0;
    width: 100%;
    height: auto;
    max-height: none;
  }
}

.hero {
  padding: 24px 0 40px;
  border-bottom: 0.8px solid var(--line);
}

.hero h1 {
  max-width: 720px;
  font-size: clamp(34px, 6vw, 56px);
  font-weight: 300;
  line-height: 1.08;
}

.hero p {
  max-width: 650px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.6;
}

.section-heading {
  margin: 34px 0 14px;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 300;
  letter-spacing: -0.02em;
}

.tracking-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  text-align: right;
  white-space: nowrap;
}

.meta strong {
  color: var(--ink);
  font-weight: 700;
}

.shell:has(#portalPage.active) { width: 100%; min-width: 0; max-width: none; padding: 0; }
