@layer layout {
  .site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    min-height: 56px;
    transform: translateY(0);
    transition: transform 420ms cubic-bezier(0.45, 0, 0.55, 1);
    background: var(--header);
    color: var(--text);
    will-change: transform;
  }
  .site-header[data-scroll-hidden] {
    transform: translateY(-100%);
  }
  .header-inner {
    display: flex;
    width: 100%;
    max-width: 1400px;
    min-height: 56px;
    margin: 0 auto;
    padding: 8px 16px;
    align-items: center;
  }
  .brand {
    display: inline-flex;
    height: 40px;
    padding-right: 12px;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.025em;
    white-space: nowrap;
    user-select: none;
    -webkit-user-select: none;
  }
  .brand img {
    width: 29px;
    height: 29px;
    object-fit: contain;
  }
  .primary-nav {
    display: flex;
    align-items: center;
    user-select: none;
    -webkit-user-select: none;
  }
  .primary-nav > a,
  .primary-nav summary {
    display: inline-flex;
    height: 40px;
    padding: 0 11px;
    align-items: center;
    gap: 6px;
    border-radius: 4px;
    color: var(--text);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    list-style: none;
    white-space: nowrap;
  }
  .primary-nav summary::-webkit-details-marker,
  .account summary::-webkit-details-marker {
    display: none;
  }
  .primary-nav > a:hover,
  .primary-nav summary:hover,
  .header-notifications:hover,
  .account summary:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
  }
  .primary-nav details,
  .account {
    position: relative;
  }
  .menu {
    position: absolute;
    top: 48px;
    left: 0;
    z-index: 20;
    width: max-content;
    min-width: 180px;
    overflow: hidden;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: var(--surface-raised);
  }
  .menu a {
    display: block;
    min-height: 42px;
    padding: 10px 13px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
  }
  .menu a:last-child {
    border-bottom: 0;
  }
  .menu a:hover {
    background: var(--accent-soft);
    color: var(--accent);
  }
  .header-actions {
    display: flex;
    margin-left: auto;
    align-items: center;
    gap: 8px;
    user-select: none;
    -webkit-user-select: none;
  }
  .header-search,
  .mobile-search {
    display: flex;
    height: 40px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 4px;
    background: #090909;
  }
  .header-search input,
  .mobile-search input {
    width: 200px;
    padding: 0 12px;
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    user-select: text;
    -webkit-user-select: text;
  }
  .header-search input::placeholder,
  .mobile-search input::placeholder {
    color: rgba(242, 239, 233, 0.52);
  }
  .header-search button,
  .mobile-search button {
    display: grid;
    width: 40px;
    padding: 0;
    place-items: center;
    border: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.09);
    background: transparent;
    color: var(--text);
    cursor: pointer;
  }
  .mobile-search {
    display: none;
  }
  .account summary,
  .header-notifications {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border-radius: 4px;
    cursor: pointer;
    list-style: none;
  }
  .header-notifications {
    flex-shrink: 0;
    color: var(--text);
  }
  .header-notifications > svg {
    width: 22px;
    height: 22px;
  }
  .menu-right {
    right: 0;
    left: auto;
    max-width: calc(100vw - 16px);
  }
  @media (max-width: 820px) {
    .primary-nav .menu {
      right: 0;
      left: auto;
    }
  }
  .wiki-layout {
    display: flex;
    width: 100%;
    max-width: 1400px;
    margin: 16px auto 0;
    padding: 0 16px;
    flex: 1 0 auto;
    align-items: flex-start;
    gap: 16px;
  }
  .content-frame {
    display: flex;
    min-width: 0;
    min-height: max(480px, calc(100vh - 280px));
    overflow: hidden;
    flex: 1 1 0;
    flex-direction: column;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: var(--surface);
  }

  .document-header {
    display: flex;
    min-height: 98px;
    padding: 22px 24px 14px;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    border-bottom: 1px solid var(--border);
  }
  .document-header h1 {
    margin: 0;
    color: var(--text);
    font-size: clamp(34px, 2.5vw, 40px);
    line-height: 1.3;
    letter-spacing: -0.025em;
    overflow-wrap: anywhere;
  }
  .document-meta {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
  }
  .document-actions {
    display: flex;
    overflow: hidden;
    flex: 0 0 auto;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
  }
  .document-actions > a {
    min-width: 54px;
    padding: 8px 11px;
    border-right: 1px solid var(--border);
    color: var(--muted);
    text-align: center;
  }
  .document-actions > a:last-child {
    border-right: 0;
  }
  .document-actions > a:hover {
    background: var(--accent-soft);
    color: var(--accent);
  }
  .document-body {
    width: 100%;
    container-type: inline-size;
    padding: 24px;
    overflow-wrap: anywhere;
  }
  .raw-document {
    margin: 0;
    white-space: pre-wrap;
    color: var(--text);
    font: inherit;
  }
  .site-footer {
    width: 100%;
    margin-top: 16px;
    padding: 16px 0 18px;
    border-top: 1px solid var(--border);
    background: var(--surface);
  }
  .site-footer > div {
    display: flex;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 16px;
    align-items: flex-start;
    flex-direction: column;
    gap: 11px;
  }
  .footer-primary {
    display: flex;
    width: 100%;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 16px;
  }
  .footer-engine {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
  }
  .footer-engine code {
    color: var(--text);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
  }
  .site-footer nav {
    display: flex;
    min-width: 0;
    align-items: baseline;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 4px 14px;
  }
  .site-footer nav a {
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
  }
  .site-footer nav a:hover {
    color: var(--accent-hover);
  }
  .footer-secondary {
    display: grid;
    width: 100%;
    padding-top: 11px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 32px;
    border-top: 1px solid var(--border);
  }
  .footer-license {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 10px;
  }
  .footer-license-copy {
    flex: 1;
    min-width: 0;
  }
  .footer-license p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
    text-wrap: pretty;
  }
  .footer-license-copy p + p {
    margin-top: 2px;
  }
  .footer-license-revision {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .footer-license p a {
    color: var(--accent);
    font-weight: 600;
  }
  .footer-license p a:hover {
    color: var(--accent-hover);
  }
  .footer-legal {
    max-width: 760px;
    justify-self: end;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
    text-align: right;
  }
  .footer-legal p {
    margin: 0;
    text-wrap: pretty;
  }
  .footer-legal p + p {
    margin-top: 2px;
  }
  @media (prefers-reduced-motion: reduce) {
    .site-header {
      transition: none;
    }
  }
}
