/* Shared geometry for the primary AI Lishishu ecosystem navigation. */
html {
  scrollbar-gutter: stable;
}

html::-webkit-scrollbar {
  width: 15px;
}

.ecosystem-skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 12000;
  padding: 10px 14px;
  border-radius: 10px;
  color: #fff;
  background: #071c3f;
  font: 700 14px/1.2 "Noto Sans SC", "Microsoft YaHei", sans-serif;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 140ms ease;
}

.ecosystem-skip-link:focus { transform: none; }

.ecosystem-menu-button {
  min-width: 44px;
  min-height: 44px;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid rgba(49, 46, 88, .14);
  border-radius: 11px;
  color: #1c2030;
  background: #fff;
  font: 700 12px/1 "Noto Sans SC", "Microsoft YaHei", sans-serif;
  cursor: pointer;
}

.ecosystem-header-without-nav .ecosystem-menu-button { display: inline-flex; }

.ecosystem-action-cluster > .ecosystem-menu-button {
  flex: 0 0 auto;
  margin: 0;
}

.ecosystem-menu-button:focus-visible,
.ecosystem-product-panel a:focus-visible,
.ecosystem-product-panel button:focus-visible {
  outline: 3px solid rgba(110, 64, 255, .3);
  outline-offset: 3px;
}

.ecosystem-product-panel[hidden] { display: none !important; }

.ecosystem-product-panel {
  position: fixed;
  inset: 0;
  z-index: 11000;
  display: grid;
  align-content: start;
  padding: max(18px, env(safe-area-inset-top)) 16px 24px;
  color: #141722;
  background: rgba(248, 249, 255, .98);
  backdrop-filter: blur(18px);
  overflow-y: auto;
}

.ecosystem-product-panel__head {
  width: min(720px, 100%);
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 auto 18px;
}

.ecosystem-product-panel__head strong { font-size: 18px; }
.ecosystem-product-panel__head button {
  width: 44px;
  height: 44px;
  border: 1px solid #e1e3ec;
  border-radius: 12px;
  background: #fff;
  color: #303447;
  font-size: 26px;
  cursor: pointer;
}

.ecosystem-product-panel nav {
  width: min(720px, 100%);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 auto;
}

.ecosystem-product-panel nav a,
.ecosystem-product-panel__account {
  min-height: 52px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border: 1px solid #e2e4ee;
  border-radius: 13px;
  color: #34384a;
  background: #fff;
  font: 700 14px/1.3 "Noto Sans SC", "Microsoft YaHei", sans-serif;
  text-decoration: none;
}

.ecosystem-product-panel nav a[aria-current="page"] {
  border-color: rgba(110, 64, 255, .32);
  color: #5732d2;
  background: #f0ecff;
}

.ecosystem-product-panel__subroutes {
  width: min(720px, 100%);
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px auto 0;
  color: #68677b;
  font: 650 12px/1.3 "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

.ecosystem-product-panel__subroutes a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 0 13px;
  border-radius: 10px;
  color: #1558b7;
  background: #edf5ff;
  font-weight: 750;
  text-decoration: none;
}

.ecosystem-product-panel__subroutes a[aria-current="page"] {
  color: #5732d2;
  background: #f0ecff;
}

.ecosystem-product-panel__account {
  width: min(720px, 100%);
  margin: 14px auto 0;
  border-color: rgba(17, 96, 224, .2);
  color: #1558b7;
  background: #edf5ff;
}

.ecosystem-menu-open { overflow: hidden; }

@media (min-width: 861px) {
  :root {
    --header-height: 76px;
    --topbar-h: 76px;
    --ecosystem-header-height: 76px;
  }

  .site-header,
  #topbar,
  body > header,
  .ecosystem-header[aria-label="AI历史书生态导航"] {
    height: 76px;
    min-height: 76px;
  }

  #topbar,
  body > header:not(.site-header):not(.ecosystem-header) {
    position: relative;
  }

  .ecosystem-header-without-nav { position: relative; }

  .site-header > .site-nav[aria-label="AI历史书生态导航"],
  #topbar > .ecosystem-nav[aria-label="AI历史书生态导航"],
  body > header > nav[aria-label="AI历史书生态导航"],
  .ecosystem-header[aria-label="AI历史书生态导航"] > .ecosystem-nav {
    position: absolute;
    top: 50%;
    left: 50vw;
    z-index: 2;
    display: flex;
    width: max-content;
    max-width: none;
    margin: 0;
    padding: 0;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transform: translate(-50%, -50%);
    white-space: nowrap;
  }

  .site-header > .site-nav[aria-label="AI历史书生态导航"] a,
  #topbar > .ecosystem-nav[aria-label="AI历史书生态导航"] a,
  body > header > nav[aria-label="AI历史书生态导航"] a,
  .ecosystem-header[aria-label="AI历史书生态导航"] > .ecosystem-nav a {
    flex: 0 0 auto;
    padding: 9px 11px;
    font-size: 0.84rem;
    font-weight: 650;
    line-height: 1.2;
  }

  .site-header > .account-button,
  .site-header > .header-actions,
  body > header > .account,
  .ecosystem-header[aria-label="AI历史书生态导航"] > .ecosystem-account {
    grid-column: 3;
    justify-self: end;
  }

  #topbar > .top-account-actions {
    margin-left: 0;
  }

  /* Reading mode hides the compact search spacer. Keep the account controls
     pinned to the right so they never collide with the centered navigation. */
  body.knowledge-mode #topbar > .top-account-actions {
    margin-left: auto;
  }
}

/* Keep encyclopedia search available without letting it push the nav off-axis. */
@media (min-width: 1101px) and (max-width: 1699px) {
  #topbar > #top-search-box {
    position: relative;
    width: 44px;
    height: 38px;
    max-width: 44px;
    min-width: 44px;
    min-height: 38px;
    margin-left: auto;
    padding-inline: 13px;
    overflow: hidden;
    cursor: text;
    transition: width 180ms ease, max-width 180ms ease, box-shadow 180ms ease;
  }

  #topbar > #top-search-box > input {
    position: absolute;
    inset: 0;
    width: 100%;
    min-width: 0;
    opacity: 0;
    cursor: text;
  }

  #topbar > #top-search-box > .s-btn {
    display: none;
  }

  #topbar > #top-search-box:focus-within {
    z-index: 4;
    width: 280px;
    max-width: 280px;
    padding-inline: 12px;
    overflow: visible;
    background: var(--bg-1, #fff);
    box-shadow: 0 12px 34px rgba(27, 22, 55, 0.14);
  }

  #topbar > #top-search-box:focus-within > input {
    position: static;
    flex: 1 1 auto;
    width: auto;
    opacity: 1;
  }
}

@media (min-width: 861px) and (max-width: 1100px) {
  #topbar > #top-search-box {
    display: none;
  }

  #topbar > .top-account-actions {
    margin-left: auto;
  }

  #topbar #theme-btn,
  #topbar #top-register-btn,
  #topbar #live2dMiniIcon {
    display: none;
  }

  #topbar #top-user-label {
    max-width: 84px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 1360px) {
  .site-header > .site-nav[aria-label="AI历史书生态导航"],
  #topbar > .ecosystem-nav[aria-label="AI历史书生态导航"],
  body > header > nav[aria-label="AI历史书生态导航"],
  .ecosystem-header[aria-label="AI历史书生态导航"] > .ecosystem-nav,
  nav[aria-label="全生态导航"] { display: none !important; }

  .ecosystem-menu-button { display: inline-flex; margin-left: auto; }
  .ecosystem-menu-button + [data-auth-user],
  .ecosystem-menu-button + .account-button,
  .ecosystem-menu-button + .model-account,
  .ecosystem-menu-button + .practice-account,
  .ecosystem-menu-button + .header-actions { margin-left: 8px; }
  .ecosystem-menu-button + .header-actions .mobile-menu-button { display: none !important; }
  .ecosystem-action-cluster > .mobile-menu-button { display: none !important; }
}

@media (min-width: 861px) and (max-width: 1360px) {
  .site-header {
    grid-template-columns: auto minmax(0, 1fr) auto !important;
    grid-template-rows: 76px !important;
  }

  .site-header > .brand,
  .site-header > .ecosystem-brand {
    grid-column: 1;
    grid-row: 1;
  }

  .site-header > .ecosystem-menu-button {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  .site-header > .account-button,
  .site-header > .header-actions {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
  }

  .agent-header > .ecosystem-menu-button,
  body > header > .ecosystem-menu-button {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  .agent-header > [data-auth-user],
  body > header > .account {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
  }

  .practice-global-header,
  .model-global-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 8px;
  }

  .practice-global-header > .practice-brand,
  .model-global-header > .model-brand {
    position: static;
    grid-column: 1;
    width: max-content;
    justify-self: start;
    transform: none;
  }

  .practice-global-header > .ecosystem-menu-button,
  .model-global-header > .ecosystem-menu-button {
    grid-column: 2;
    justify-self: end;
  }

  .practice-global-header > .practice-account,
  .model-global-header > .model-account {
    position: static;
    grid-column: 3;
    transform: none;
  }

  #topbar > .ecosystem-menu-button {
    position: static;
    flex: 0 0 auto;
    margin-left: 8px;
    transform: none;
  }
}

@media (min-width: 861px) and (max-width: 1100px) {
  #topbar > .ecosystem-menu-button { margin-left: auto; }
  #topbar > .top-account-actions { margin-left: 8px; }
}

@media (max-width: 520px) {
  .ecosystem-menu-button { padding-inline: 10px; }
  .ecosystem-menu-button strong { display: none; }
  .ecosystem-product-panel nav { grid-template-columns: 1fr; }
}
