.tool-switcher,
:root {
  --theme-toggle-bg: #ececeb;
  --theme-toggle-border: #d7d4d7;
  --theme-toggle-hover: #e3e2e1;
}

.language-menu__button {
  background: color-mix(in srgb, var(--panel, var(--audio-panel, #f0f0ef)) 96%, transparent);
}

[data-sticky-header] {
  position: sticky;
  top: 10px;
  z-index: 500;
  isolation: isolate;
  overflow-anchor: none;
  transform-origin: top center;
  will-change: transform, box-shadow, backdrop-filter;
  transition:
    min-height 300ms cubic-bezier(0.22, 1, 0.36, 1),
    padding 300ms cubic-bezier(0.22, 1, 0.36, 1),
    border-radius 300ms cubic-bezier(0.22, 1, 0.36, 1),
    border-color 300ms ease,
    background 300ms ease,
    box-shadow 360ms cubic-bezier(0.22, 1, 0.36, 1),
    backdrop-filter 360ms ease;
}

[data-sticky-header]::after {
  content: "";
  position: absolute;
  right: 18px;
  bottom: -1px;
  left: 18px;
  z-index: -1;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--accent, var(--audio-accent, #e56f8f)) 32%,
    var(--primary, var(--audio-primary, #4f9f93)) 68%,
    transparent
  );
  opacity: 0;
  transform: scaleX(0.2);
  transform-origin: center;
  transition: opacity 220ms ease, transform 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

[data-sticky-header].is-stuck {
  top: 0;
  min-height: 60px;
  padding-top: 6px;
  padding-bottom: 6px;
  border-radius: 0 0 14px 14px;
  background: color-mix(in srgb, var(--panel, var(--audio-panel, #f0f0ef)) 94%, transparent);
  box-shadow: 0 14px 34px rgba(35, 31, 34, 0.16);
  backdrop-filter: blur(18px) saturate(1.12);
  animation: sticky-header-settle 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

[data-sticky-header].is-stuck::after {
  opacity: 0.72;
  transform: scaleX(1);
}

@keyframes sticky-header-settle {
  0% {
    filter: saturate(0.94);
    transform: translateY(8px) scale(0.992);
  }
  68% {
    filter: saturate(1.04);
    transform: translateY(-1px) scale(1.002);
  }
  100% {
    filter: none;
    transform: translateY(0) scale(1);
  }
}

[data-sticky-header] .brand-lockup,
[data-sticky-header] .audio-converter-brand img,
[data-sticky-header] .brand-wordmark,
[data-sticky-header] .brand-tagline {
  transition: width 220ms ease, height 220ms ease, font-size 220ms ease, opacity 160ms ease, max-width 220ms ease, margin 220ms ease;
}

[data-sticky-header].is-stuck .brand-lockup,
[data-sticky-header].is-stuck .audio-converter-brand img {
  width: 36px;
  height: 36px;
}

[data-sticky-header].is-stuck .brand-wordmark,
[data-sticky-header].is-stuck .audio-converter-brand {
  font-size: 20px;
}

[data-sticky-header].is-stuck .brand-tagline {
  max-width: 0;
  margin: 0;
  overflow: hidden;
  opacity: 0;
}

.tool-switcher {
  --tool-switcher-line: var(--line, var(--audio-line, #eadfe9));
  --tool-switcher-panel: var(--panel, var(--audio-panel, #ffffff));
  --tool-switcher-text: var(--text, var(--audio-text, #332a35));
  --tool-switcher-muted: var(--muted, var(--audio-muted, #756b77));
  position: relative;
  flex: 0 0 auto;
  color: var(--tool-switcher-text);
}

.tool-switcher summary {
  min-width: 142px;
  height: 38px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid var(--tool-switcher-line);
  border-radius: 7px;
  background: color-mix(in srgb, var(--tool-switcher-panel) 92%, transparent);
  color: var(--tool-switcher-text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 780;
  list-style: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.tool-switcher summary::-webkit-details-marker {
  display: none;
}

.tool-switcher summary:hover,
.tool-switcher[open] summary {
  border-color: color-mix(in srgb, var(--tool-switcher-text) 28%, var(--tool-switcher-line));
}

.tool-switcher summary:focus-visible {
  outline: 0;
  border-color: #4f9f93;
  box-shadow: 0 0 0 3px rgba(79, 159, 147, 0.18);
}

.tool-switcher__grid-icon,
.tool-switcher__chevron {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.tool-switcher__grid-icon rect {
  fill: currentColor;
}

.tool-switcher__chevron {
  width: 14px;
  transition: transform 160ms ease;
}

.tool-switcher[open] .tool-switcher__chevron {
  transform: rotate(180deg);
}

.tool-switcher__menu {
  position: absolute;
  z-index: 90;
  top: calc(100% + 10px);
  right: 0;
  width: min(430px, calc(100vw - 28px));
  box-sizing: border-box;
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid color-mix(in srgb, var(--tool-switcher-line) 86%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--tool-switcher-panel) 96%, transparent);
  box-shadow: 0 20px 50px rgba(29, 18, 30, 0.18);
  backdrop-filter: blur(18px);
}

.tool-switcher__menu-title {
  margin: 3px 8px 7px;
  color: var(--tool-switcher-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tool-switcher__item {
  min-height: 80px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: inherit;
  text-decoration: none;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.tool-switcher__item:hover,
.tool-switcher__item:focus-visible {
  border-color: color-mix(in srgb, #4f9f93 22%, var(--tool-switcher-line));
  background: color-mix(in srgb, #4f9f93 9%, var(--tool-switcher-panel));
  outline: 0;
  transform: translateY(-1px);
}

.tool-switcher__item[aria-current="page"] {
  background: color-mix(in srgb, #4f9f93 8%, var(--tool-switcher-panel));
}

.tool-switcher__item-icon {
  position: relative;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--tool-switcher-line) 82%, transparent);
  border-radius: 11px;
  background: #e4e3e2;
  color: #343135;
}

.tool-switcher__item-icon::after {
  content: "";
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #e56f8f;
}

[data-theme="dark"] .tool-switcher__item-icon--piano {
  background: #302d30;
  color: #f7eef2;
}

[data-theme="dark"] .tool-switcher__item-icon--audio {
  background: #302d30;
  color: #f7eef2;
}

.tool-switcher__item-icon--vocal {
  background: linear-gradient(135deg, #efe9ff, #ffe7ef);
  color: #7657d7;
  font-size: 16px;
  font-weight: 900;
}

[data-theme="dark"] .tool-switcher__item-icon--vocal {
  background: linear-gradient(135deg, #382b57, #4a2633);
  color: #c3adff;
}

.tool-switcher__item-icon svg {
  width: 23px;
  height: 23px;
}

.tool-switcher__item-copy {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.tool-switcher__item-copy strong {
  font-size: 15px;
  line-height: 1.2;
}

.tool-switcher__item-copy small {
  color: var(--tool-switcher-muted);
  font-size: 12px;
  line-height: 1.45;
}

.tool-switcher__current {
  align-self: start;
  padding: 4px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, #4f9f93 15%, var(--tool-switcher-panel));
  color: #367a71;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

@media (max-width: 820px) {
  .nav:has([data-tool-switcher]) {
    flex-wrap: wrap;
    overflow: visible;
  }

  [data-sticky-header].is-stuck {
    align-items: center;
    flex-direction: row;
    gap: 6px;
    padding-right: 8px;
    padding-left: 8px;
  }

  .topbar.is-stuck .brand-button,
  .audio-converter-topbar.is-stuck .audio-converter-brand {
    flex: 0 0 auto;
  }

  [data-sticky-header].is-stuck .brand-lockup,
  [data-sticky-header].is-stuck .audio-converter-brand img {
    width: 32px;
    height: 32px;
  }

  [data-sticky-header].is-stuck .brand-wordmark,
  [data-sticky-header].is-stuck .audio-converter-brand {
    font-size: 16px;
  }

  .topbar.is-stuck .nav,
  .audio-converter-topbar.is-stuck .audio-converter-nav-actions {
    width: auto;
    min-width: 0;
    flex: 1 1 auto;
    flex-wrap: nowrap;
    justify-content: flex-end;
    overflow: visible;
  }

  .topbar.is-stuck .theme-toggle,
  .topbar.is-stuck .ghost,
  .topbar.is-stuck .user-chip,
  .audio-converter-topbar.is-stuck .audio-converter-icon-button {
    display: none !important;
  }

  [data-sticky-header].is-stuck .language-menu__button {
    width: 92px;
    padding-right: 8px;
    padding-left: 8px;
  }

  [data-sticky-header].is-stuck .tool-switcher summary {
    min-width: 112px;
    gap: 6px;
    padding-right: 8px;
    padding-left: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-sticky-header],
  [data-sticky-header] * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

@media (min-width: 821px) {
  .topbar .tool-switcher__menu,
  .audio-converter-topbar .tool-switcher__menu {
    right: auto;
    left: 0;
  }
}

@media (max-width: 520px) {
  .tool-switcher summary {
    min-width: 132px;
    font-size: 13px;
  }

  .tool-switcher__menu {
    top: calc(100% + 8px);
    right: -54px;
    left: auto;
    width: min(280px, calc(100vw - 20px));
  }

  .tool-switcher__item {
    min-height: 74px;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 10px;
  }

  .tool-switcher__item-icon {
    width: 38px;
    height: 38px;
  }
}

/* Product headers share account-name visibility and language-control colors. */
html body :is(.topbar, .vocal-topbar, .audio-converter-topbar)[data-sticky-header] :is(.user-chip, .vocal-user-chip, .audio-converter-user-chip) {
  min-width: 0;
  max-width: 100%;
  height: auto;
  min-height: 38px;
  padding-top: 5px;
  padding-bottom: 5px;
}
html body :is(.topbar, .vocal-topbar, .audio-converter-topbar)[data-sticky-header] :is(.user-name, .vocal-user-name, .audio-converter-user-name) {
  min-width: 0;
  max-width: none;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.4;
}
html body :is(.topbar, .vocal-topbar, .audio-converter-topbar)[data-sticky-header] .language-menu__button {
  background: #242326;
  border-color: rgba(255,255,255,.2);
  color: #f7f4f1;
}
html body .language-menu__list {
  background: #ffffff;
  border-color: #d7d4d7;
  color: #332a35;
}
html body .language-menu__option:is(:hover, :focus-visible, .active) {
  background: #f2ebff;
  color: #7028f4;
}
html[data-theme="dark"] body .language-menu__list {
  background: #211a22;
  border-color: #4a3d47;
  color: #f7eef2;
}
html[data-theme="dark"] body .language-menu__option:is(:hover, :focus-visible, .active) {
  background: #352630;
  color: #ffb4c8;
}
