.brand .project-logo {
  display: block;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 8px;
}

.language-toggle {
  border: 1px solid #abcac7;
  border-radius: 999px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 750;
  padding: 3px 9px;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.language-toggle:hover {
  background: var(--teal);
  color: #fff;
}

/* Keep the documentation header on one line, then switch to the menu. */
.topbar .brand {
  flex: 0 0 auto;
  gap: 8px;
}

.topbar .brand small {
  display: inline;
  margin-left: 6px;
  font-size: 9.5px;
}

.topbar nav {
  min-width: 0;
  height: 100%;
  flex: 1 1 auto;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: nowrap;
  gap: clamp(8px, 1.2vw, 18px);
}

.reference-topbar .topbar-links {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 20px;
}

.topbar nav a,
.dropdown-toggle {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted-dark);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s ease;
}

.topbar nav a:hover,
.topbar nav a.active,
.dropdown-toggle:hover,
.dropdown-toggle.active {
  color: var(--teal);
}

/* Nav Dropdown Container */
.nav-dropdown {
  position: relative;
  height: 100%;
  display: inline-flex;
  align-items: center;
}

.dropdown-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 6px;
  height: 38px;
}

.dropdown-toggle .chevron {
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.2s ease;
}

.nav-dropdown:hover .dropdown-toggle .chevron,
.nav-dropdown.open .dropdown-toggle .chevron {
  transform: rotate(180deg);
  color: var(--teal);
}

/* Dropdown Menu Popup */
.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  min-width: 280px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 18px 40px -8px rgba(15, 23, 42, 0.14), 0 4px 14px -2px rgba(15, 23, 42, 0.06);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* Invisible hover bridge connecting button and menu seamlessly */
.dropdown-menu::before {
  content: "";
  position: absolute;
  top: -18px;
  left: -15px;
  right: -15px;
  height: 20px;
  display: block;
}

.nav-dropdown:hover .dropdown-menu,
.nav-dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.dropdown-item {
  display: flex !important;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none !important;
  color: var(--ink) !important;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: normal !important;
}

.dropdown-item:hover,
.dropdown-item.active {
  background: #f0fdfa !important;
  color: var(--teal) !important;
}

.dropdown-item .item-icon {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

.dropdown-item .item-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  text-align: left;
}

.dropdown-item strong {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}

.dropdown-item:hover strong,
.dropdown-item.active strong {
  color: var(--teal);
}

.dropdown-item small {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.2;
  font-weight: 400;
}

.topbar .github,
.topbar .language-toggle {
  white-space: nowrap;
  flex: 0 0 auto;
}

@media (max-width: 1240px) {
  .topbar {
    padding-left: 18px;
    padding-right: 18px;
    gap: 10px;
  }

  .topbar .menu-toggle {
    display: block;
    margin-left: auto;
  }

  .topbar nav {
    display: none;
    position: absolute;
    top: 76px;
    left: 0;
    right: 0;
    height: auto;
    padding: 16px 22px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    box-shadow: var(--shadow);
  }

  .topbar nav.open {
    display: flex;
  }

  .topbar nav a {
    padding: 6px 0;
    font-size: 14.5px;
  }
}

@media (max-width: 800px) {
  .topbar .github {
    display: none;
  }
}

/* Shared layout polish */
html,
body {
  overflow-x: hidden;
}

.topbar,
.topbar .brand,
.topbar nav,
.reference-topbar,
.reference-topbar .topbar-links {
  min-width: 0;
}

.topbar .brand > span {
  min-width: 0;
}

.topbar .brand small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar .menu-toggle {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  line-height: 1;
  place-items: center;
}

.reference-topbar {
  gap: 18px;
}

.reference-topbar .topbar-title {
  flex: 0 1 260px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-topbar .topbar-links {
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: nowrap;
  overflow: visible;
  white-space: nowrap;
}

.reference-topbar .topbar-links > * {
  flex: 0 0 auto;
}

.reference-topbar .language-toggle {
  flex: 0 0 auto;
}

.docs-layout,
.docs-layout > *,
.doc-content {
  min-width: 0;
}

@media (max-width: 1240px) {
  .topbar .menu-toggle {
    display: grid;
  }

  .topbar nav {
    max-height: calc(100vh - 76px);
    overflow-y: auto;
  }
}

@media (min-width: 961px) and (max-width: 1180px) {
  .reference-topbar {
    padding-left: 24px;
    padding-right: 24px;
    gap: 12px;
  }

  .reference-topbar .topbar-title {
    flex-basis: 180px;
    font-size: 12px;
  }

  .reference-topbar .topbar-links {
    gap: 13px;
  }
}

@media (max-width: 800px) {
  .topbar .menu-toggle {
    display: grid;
  }

  .topbar nav {
    top: 76px;
  }

  .reference-topbar .topbar-title {
    flex-basis: 100%;
  }

  .docs-layout {
    width: 100%;
  }

  .docs-layout .side-nav {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 960px) {
  .reference-topbar .topbar-links {
    flex-wrap: wrap;
    overflow: visible;
    white-space: normal;
  }
}

/* Final reading rhythm across guide and reference pages */
.docs-layout {
  gap: clamp(40px, 5vw, 65px);
}

.doc-content {
  font-size: 16px;
}

.doc-content h1 {
  font-size: clamp(42px, 5vw, 54px);
  line-height: 1.08;
  letter-spacing: -0.055em;
}

.doc-content h2 {
  font-size: clamp(30px, 3.2vw, 38px);
  line-height: 1.16;
}

.doc-content h3 {
  font-size: clamp(18px, 2vw, 20px);
  line-height: 1.3;
}

.doc-content p,
.doc-content li {
  line-height: 1.72;
}

.doc-content > section {
  margin-bottom: 64px;
}

.doc-content .doc-lead {
  max-width: 720px;
  font-size: clamp(18px, 1.7vw, 20px);
  line-height: 1.65;
}

.side-nav {
  line-height: 1.45;
}

.side-nav a {
  padding: 6px 0;
}

.api-reference-page .reference-content {
  padding: 44px clamp(28px, 4vw, 48px) 96px;
  font-size: 15px;
}

.api-reference-page .reference-title h1 {
  font-size: clamp(34px, 3.2vw, 44px);
  line-height: 1.12;
}

.api-reference-page .reference-lead {
  max-width: 760px;
  line-height: 1.7;
}

.api-reference-page .reference-section {
  margin-bottom: 52px;
}

.api-reference-page .reference-section > h2 {
  font-size: clamp(22px, 2.2vw, 27px);
  line-height: 1.25;
}

.api-reference-page .type-desc,
.api-reference-page .member-detail p,
.api-reference-page .member-table .desc-col {
  line-height: 1.65;
}

@media (max-width: 960px) {
  .api-reference-page .reference-content {
    padding: 32px 18px 72px;
  }

  .api-reference-page .reference-title h1 {
    font-size: clamp(30px, 8vw, 38px);
  }

  .api-reference-page .reference-section {
    margin-bottom: 38px;
  }
}

@media (max-width: 800px) {
  .docs-layout {
    gap: 34px;
    padding-top: 42px;
    padding-bottom: 64px;
  }

  .doc-content h1 {
    font-size: clamp(36px, 10vw, 42px);
  }

  .doc-content h2 {
    font-size: clamp(27px, 8vw, 31px);
  }

  .doc-content .doc-lead {
    margin-bottom: 38px;
    font-size: 18px;
  }

  .doc-content > section {
    margin-bottom: 56px;
  }
}

/* Site-wide visual refinement */
:root {
  --ui-border: #d9e7e4;
  --ui-border-strong: #bddbd5;
  --ui-surface: #ffffff;
  --ui-shadow-hover: 0 20px 46px rgba(16, 43, 52, 0.11);
}

body:not(.api-reference-page) {
  background:
    radial-gradient(circle at 96% -12%, rgba(12, 117, 111, 0.08), transparent 27rem),
    var(--paper);
}

.topbar {
  height: 72px;
  background: rgba(247, 250, 248, 0.9);
  border-bottom-color: rgba(190, 214, 210, 0.78);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
}

.topbar .brand {
  min-height: 38px;
}

.topbar nav a,
.topbar nav .dropdown-toggle {
  min-height: 34px;
  padding: 7px 9px;
  border-radius: 8px;
}

.topbar nav a:hover,
.topbar nav a.active,
.topbar nav .dropdown-toggle:hover,
.topbar nav .dropdown-toggle.active {
  background: #eaf7f4;
  color: var(--teal);
}

.topbar .github {
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid transparent;
}

.topbar .github:hover {
  border-color: var(--ui-border-strong);
  background: #ffffff;
}

.language-toggle {
  display: inline-grid;
  place-items: center;
  min-width: 36px;
  height: 34px;
  padding: 0 9px;
  background: rgba(255, 255, 255, 0.72);
}

.topbar .menu-toggle {
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
  cursor: pointer;
}

.docs-layout {
  grid-template-columns: 200px minmax(0, 790px);
  justify-content: center;
  gap: clamp(42px, 5vw, 64px);
}

.side-nav {
  top: 96px;
  padding: 14px 0 18px 18px;
  border-left-color: #cfe2de;
}

.side-nav a {
  margin-left: -10px;
  padding: 7px 10px;
  border-radius: 8px;
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.side-nav a:hover,
.side-nav a.active {
  background: #eef8f5;
  color: var(--teal);
  transform: translateX(2px);
}

.doc-content h1,
.doc-content h2,
.docs-home-head h1,
.docs-home-section h2 {
  text-wrap: balance;
}

.doc-content .code-block {
  border: 1px solid rgba(100, 151, 148, 0.22);
  box-shadow: 0 14px 30px rgba(16, 43, 52, 0.1);
}

.doc-content .code-block pre {
  scrollbar-color: #547d82 #102b34;
  scrollbar-width: thin;
}

.doc-content .copy-code {
  background: rgba(16, 43, 52, 0.35);
  border-color: rgba(168, 206, 200, 0.42);
  transition: background 0.16s ease, border-color 0.16s ease;
}

.doc-content .copy-code:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(168, 206, 200, 0.78);
}

.doc-content .callout,
.doc-content .api-table,
.doc-content .command-table,
.doc-content .policy,
.doc-content .state-panel,
.doc-content .number-list {
  border-radius: 11px;
}

.doc-content .callout {
  box-shadow: 0 8px 22px rgba(16, 43, 52, 0.04);
}

.doc-content .api-table,
.doc-content .command-table {
  box-shadow: 0 8px 24px rgba(16, 43, 52, 0.045);
}

.pillar-card,
.card,
.api-quick-card,
.quick-start-notes,
.nuget-section {
  box-shadow: 0 8px 26px rgba(16, 43, 52, 0.055);
}

.pillar-card:hover,
.card:hover,
.api-quick-card:hover,
.nuget-section:hover {
  box-shadow: var(--ui-shadow-hover);
}

@media (max-width: 1100px) and (min-width: 801px) {
  .docs-layout {
    grid-template-columns: 180px minmax(0, 1fr);
    justify-content: stretch;
    gap: 36px;
  }
}

@media (max-width: 1240px) {
  .topbar nav {
    top: 72px;
  }
}

@media (max-width: 800px) {
  .topbar {
    height: 72px;
  }

  .topbar nav {
    top: 72px;
  }

  .docs-layout {
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .side-nav {
    scrollbar-width: none;
  }

  .side-nav::-webkit-scrollbar {
    display: none;
  }

  .side-nav a {
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.36);
  }

  .side-nav a:hover,
  .side-nav a.active {
    transform: none;
    border-color: #cfe2de;
  }
}
