.part--header {
  --header-height: var(--header-bar, 80px);
  position: relative;
  color: var(--color-text);
  font-family: var(--font-body);
}
.part--header .header__bar {
  position: relative;
  z-index: 60;
  border-bottom: 1px solid var(--color-border);
  transition: box-shadow 0.3s ease, border-color 0.3s ease, transform 0.35s ease;
}
.part--header.is-plain .header__bar {
  border-bottom: 0;
}
.part--header.is-sticky.is-stuck .header__bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--sc-ground, var(--color-background));
}
.part--header.is-sticky.is-stuck .header__spacer {
  height: var(--header-room, var(--header-height));
}
.part--header.is-up.is-stuck.is-away .header__bar {
  transform: translateY(-102%);
}
.part--header.is-scrolled .header__bar {
  box-shadow: 0 6px 24px -12px color-mix(in srgb, var(--color-heading) 35%, transparent);
}
.part--header .header__inner {
  display: flex;
  align-items: center;
  gap: clamp(16px, 2.4vw, 40px);
  max-width: calc(var(--space-content-width) + 160px);
  min-height: var(--header-height);
  margin: 0 auto;
  padding: 0 var(--space-gutter);
}
.part--header.header--content .header__inner {
  max-width: calc(var(--space-content-width) + var(--space-gutter) * 2);
}
.part--header.header--wide .header__inner {
  max-width: calc(var(--space-content-wide) + var(--space-gutter) * 2);
}
.part--header.header--full .header__inner {
  max-width: none;
}
.part--header .header__brand {
  display: flex;
  align-items: center;
  flex: none;
  min-width: 0;
}
.part--header .header__panel {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  gap: clamp(16px, 2vw, 32px);
  min-width: 0;
}
.part--header .header__nav {
  display: flex;
  justify-content: flex-end;
  flex: 1 1 auto;
  min-width: 0;
}
.part--header .header__right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: none;
}
.part--header .header__right:empty,
.part--header .header__nav:empty {
  display: none;
}
.part--header .header__toggle {
  display: none;
}

/* Logo in the middle, the menu on its own row beneath. */
.part--header.is-center .header__inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  row-gap: 0;
  padding-top: 18px;
}
.part--header.is-center .header__brand {
  grid-column: 2;
  justify-content: center;
}
.part--header.is-center .header__panel {
  display: contents;
}
.part--header.is-center .header__right {
  grid-column: 3;
  grid-row: 1;
  justify-content: flex-end;
}
.part--header.is-center .header__nav {
  grid-column: 1 / -1;
  justify-content: center;
  padding: 10px 0 4px;
}
.part--header.is-center {
  --header-height: calc(var(--header-bar, 80px) + 56px);
}

/* Logo and the right side on one row, the menu on its own beneath, under a line. */
.part--header.is-rows {
  --header-height: calc(var(--header-bar, 80px) + 52px);
}
.part--header.is-rows .header__inner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: var(--header-bar, 80px) 52px;
  row-gap: 0;
}
.part--header.is-rows .header__panel {
  display: contents;
}
.part--header.is-rows .header__right {
  grid-column: 2;
  grid-row: 1;
  justify-content: flex-end;
}
.part--header.is-rows .header__nav {
  grid-column: 1 / -1;
  grid-row: 2;
  align-self: stretch;
  align-items: center;
  justify-content: flex-start;
  margin-inline: calc(var(--space-gutter) * -1);
  padding-inline: var(--space-gutter);
  border-top: 1px solid var(--color-border);
}

/* Transparent over the first section, with the text colours of a dark background, until the page
   scrolls. */
.part--header.is-overlay {
  --sc-ground: var(--color-background);
}
.part--header.is-overlay .header__bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: transparent;
  transition: background-color 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease, transform 0.35s ease;
}
.part--header.is-overlay.is-sticky.is-stuck .header__bar {
  position: fixed;
}
.part--header.is-overlay .header__spacer {
  display: none;
}
.part--header.is-overlay.is-scrolled .header__bar,
.part--header.is-overlay.is-open .header__bar {
  background: var(--sc-ground);
  border-bottom-color: transparent;
}

/* Tablets and small laptops: the menu gets a row of its own under the logo. */
@media (max-width: 1279px) and (min-width: 768px) {
  .part--header,
  .part--header.is-center,
  .part--header.is-rows {
    --header-height: calc(var(--header-bar, 80px) + 48px);
  }
  .part--header .header__inner,
  .part--header.is-center .header__inner,
  .part--header.is-rows .header__inner {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: none;
    row-gap: 0;
    padding-top: 12px;
  }
  .part--header .header__brand,
  .part--header.is-center .header__brand {
    grid-column: 1;
    grid-row: 1;
    justify-content: flex-start;
  }
  .part--header .header__panel {
    display: contents;
  }
  .part--header .header__right,
  .part--header.is-center .header__right {
    grid-column: 2;
    grid-row: 1;
    justify-content: flex-end;
  }
  .part--header .header__nav,
  .part--header.is-center .header__nav,
  .part--header.is-rows .header__nav {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
    margin-inline: 0;
    padding: 6px 0 2px;
    border-top: 0;
  }
}

@media (max-width: 767px) {
  .part--header,
  .part--header.is-center,
  .part--header.is-rows {
    --header-height: var(--header-bar-mobile, 64px);
  }
  .part--header .header__inner,
  .part--header.is-center .header__inner,
  .part--header.is-rows .header__inner {
    display: flex;
    justify-content: space-between;
    padding-top: 0;
  }
  .part--header .header__toggle {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    margin-right: -10px;
    padding: 0 11px;
    border: 0;
    border-radius: var(--radius-small);
    background: transparent;
    color: inherit;
    cursor: pointer;
  }
  .part--header .header__toggle:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
  }
  .part--header .header__toggle-line {
    display: block;
    height: 2px;
    width: 22px;
    border-radius: 2px;
    background: currentColor;
    transition: transform 0.3s ease, opacity 0.2s ease;
  }
  .part--header.is-open .header__toggle-line:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  .part--header.is-open .header__toggle-line:nth-child(2) {
    opacity: 0;
  }
  .part--header.is-open .header__toggle-line:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }
  .part--header .header__panel,
  .part--header.is-center .header__panel,
  .part--header.is-rows .header__panel {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 24px;
    max-height: calc(100vh - var(--header-height));
    overflow-y: auto;
    padding: 16px var(--space-gutter) 32px;
    background: var(--sc-ground, var(--color-background));
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 24px 40px -24px color-mix(in srgb, var(--color-heading) 40%, transparent);
    visibility: hidden;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.25s ease, transform 0.3s ease, visibility 0s linear 0.3s;
  }
  .part--header.is-open .header__panel {
    visibility: visible;
    opacity: 1;
    transform: none;
    transition: opacity 0.25s ease, transform 0.3s ease;
  }
  .part--header .header__nav,
  .part--header.is-center .header__nav,
  .part--header.is-rows .header__nav {
    justify-content: flex-start;
    margin-inline: 0;
    padding: 0;
    border-top: 0;
  }
  .part--header .header__nav > .sc-element {
    flex: 1 1 auto;
  }
  .part--header .header__right,
  .part--header.is-center .header__right,
  .part--header.is-rows .header__right {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
  }
}

@media (prefers-reduced-motion: reduce) {
  .part--header .header__bar,
  .part--header .header__panel,
  .part--header .header__toggle-line {
    transition: none;
  }
}

/* 1.8.0 (區塊模型 6.18): where the menu sits, what scrolling turns the bar into, and how the
   phone's menu opens. None of it applies to a header set as 1.7.0 could be. */
.part--header {
  --header-base: var(--header-bar, 80px);
}
.part--header .header__alt {
  display: none;
}

/* A menu set to 平均排开 spreads over the whole of the navigation's room. */
@media (min-width: 768px) {
  .part--header .header__nav > .sc-element:has(> .menu--gap-even) {
    flex: 1 1 auto;
    width: auto;
  }
}

@media (min-width: 1280px) {
  .part--header.is-nav-brand .header__nav {
    justify-content: flex-start;
  }
  .part--header.is-nav-center .header__inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
  }
  .part--header.is-nav-center .header__panel {
    display: contents;
  }
  .part--header.is-nav-center .header__nav {
    grid-column: 2;
    justify-content: center;
  }
  .part--header.is-nav-center .header__right {
    grid-column: 3;
    justify-self: end;
  }
}

/* 收窄: once scrolled, the logo's row is three quarters as tall, and the logo with it. */
.part--header.is-slim .header__inner {
  transition: min-height 0.3s ease;
}
.part--header.is-slim.is-scrolled .header__bar {
  --header-bar: max(48px, calc(var(--header-base) * 0.75));
  --header-height: var(--header-bar);
}
.part--header.is-slim.is-center.is-scrolled .header__bar {
  --header-height: calc(var(--header-bar) + 56px);
}
.part--header.is-slim.is-rows.is-scrolled .header__bar {
  --header-height: calc(var(--header-bar) + 52px);
}
.part--header.is-slim.is-scrolled .header__brand .part--logo {
  --logo-shown: min(var(--logo-height), calc(var(--header-bar) - 16px));
}
@media (max-width: 1279px) and (min-width: 768px) {
  .part--header.is-slim.is-scrolled .header__bar,
  .part--header.is-slim.is-center.is-scrolled .header__bar,
  .part--header.is-slim.is-rows.is-scrolled .header__bar {
    --header-height: calc(var(--header-bar) + 48px);
  }
}
@media (max-width: 767px) {
  .part--header.is-slim.is-scrolled .header__bar,
  .part--header.is-slim.is-center.is-scrolled .header__bar,
  .part--header.is-slim.is-rows.is-scrolled .header__bar {
    --header-bar: max(44px, calc(var(--header-bar-mobile, 64px) * 0.8));
    --header-height: var(--header-bar);
  }
}

/* 换成另一行: once scrolled past the header, its own row gives way to the slot's. Not on phones. */
@media (min-width: 768px) {
  .part--header.is-swap.is-swapped .header__inner {
    display: none;
  }
  .part--header.is-swap.is-swapped .header__alt {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px clamp(16px, 2.4vw, 40px);
    max-width: calc(var(--space-content-width) + 160px);
    min-height: max(56px, calc(var(--header-base) * 0.75));
    margin: 0 auto;
    padding: 0 var(--space-gutter);
    animation: header-swap 0.3s ease;
  }
  .part--header.header--content.is-swap .header__alt {
    max-width: calc(var(--space-content-width) + var(--space-gutter) * 2);
  }
  .part--header.header--wide.is-swap .header__alt {
    max-width: calc(var(--space-content-wide) + var(--space-gutter) * 2);
  }
  .part--header.header--full.is-swap .header__alt {
    max-width: none;
  }
}
@keyframes header-swap {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* The phone's menu sliding in from the side over a shade, or filling the screen under the bar. */
@media (max-width: 767px) {
  .part--header:is(.is-side, .is-full) .header__panel {
    position: fixed;
    top: var(--header-panel-top, var(--header-height));
    right: 0;
    bottom: 0;
    left: auto;
    width: min(86vw, 360px);
    max-height: none;
    border-bottom: 0;
    border-left: 1px solid var(--color-border);
    box-shadow: -24px 0 40px -24px color-mix(in srgb, var(--color-heading) 40%, transparent);
    transform: translateX(100%);
  }
  .part--header.is-full .header__panel {
    left: 0;
    width: auto;
    border-left: 0;
    box-shadow: none;
    transform: translateY(-8px);
  }
  .part--header:is(.is-side, .is-full).is-open .header__panel {
    transform: none;
  }
  .part--header.is-side.is-open::after {
    content: "";
    position: fixed;
    top: var(--header-panel-top, 0);
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 59;
    background: color-mix(in srgb, var(--color-heading) 40%, transparent);
  }
}

/* Without scripts the button cannot open the menu, so on a phone it is laid out under the bar. */
@media (scripting: none) and (max-width: 767px) {
  .part--header .header__toggle {
    display: none;
  }
  .part--header .header__inner {
    flex-wrap: wrap;
  }
  .part--header:is(*, .is-center, .is-rows, .is-side, .is-full) .header__panel {
    position: static;
    flex: 1 0 100%;
    width: auto;
    max-height: none;
    padding: 0 0 16px;
    border: 0;
    box-shadow: none;
    visibility: visible;
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .part--header .header__inner,
  .part--header .header__alt {
    transition: none;
    animation: none;
  }
}
