.app-switcher {
  --switcher-bg: var(--sidebar-bg, var(--panel, var(--card-bg, #fff)));
  --switcher-border: var(--border, var(--line, #e2e8f0));
  --switcher-text: var(--text, #0f172a);
  --switcher-muted: var(--muted, var(--text-dim, #64748b));
  --switcher-hover: var(--hover, rgba(37, 99, 235, 0.08));
  --switcher-accent: var(--accent, #2563eb);

  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
  color: inherit;
  line-height: inherit;
  vertical-align: middle;
}

.app-switcher__brand {
  flex: 0 0 auto;
}

.app-switcher__trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 0;
  margin: 0;
  padding: 0 19px 0 4px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  line-height: inherit;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease;
}

.app-switcher__trigger::after {
  content: "";
  position: absolute;
  right: 6px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-right: 1.8px solid currentColor;
  border-bottom: 1.8px solid currentColor;
  opacity: 0.72;
  transform: translateY(-62%) rotate(45deg);
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.app-switcher__trigger:hover,
.app-switcher__trigger:focus-visible,
.app-switcher.is-open .app-switcher__trigger {
  background: var(--switcher-hover);
  color: var(--switcher-accent);
  outline: none;
}

.app-switcher.is-open .app-switcher__trigger::after {
  opacity: 1;
  transform: translateY(-35%) rotate(225deg);
}

.app-switcher__menu {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 1000;
  display: grid;
  gap: 2px;
  min-width: 154px;
  padding: 6px 5px;
  border: 1px solid var(--switcher-border);
  border-radius: 10px;
  background: var(--switcher-bg);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.16);
  opacity: 0;
  visibility: hidden;
  clip-path: inset(0 0 100% 0 round 10px);
  transform: translateY(-10px) scaleY(0.7);
  transform-origin: top center;
  pointer-events: none;
  transition: clip-path 0.26s cubic-bezier(0.2, 0.9, 0.3, 1),
              transform 0.26s cubic-bezier(0.2, 0.9, 0.3, 1),
              opacity 0.2s ease,
              visibility 0.26s ease;
}

.app-switcher.is-open .app-switcher__menu {
  opacity: 1;
  visibility: visible;
  clip-path: inset(0 0 0% 0 round 10px);
  transform: translateY(0) scaleY(1);
  pointer-events: auto;
}

.app-switcher__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 32px;
  padding: 7px 10px;
  border-radius: 7px;
  color: var(--switcher-text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(-8px);
  transition: background 0.12s ease,
              color 0.12s ease,
              transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1),
              opacity 0.22s ease;
}

.app-switcher.is-open .app-switcher__item {
  opacity: 1;
  transform: translateY(0);
}

.app-switcher.is-open .app-switcher__item:nth-child(1) { transition-delay: 0.03s; }
.app-switcher.is-open .app-switcher__item:nth-child(2) { transition-delay: 0.06s; }
.app-switcher.is-open .app-switcher__item:nth-child(3) { transition-delay: 0.09s; }
.app-switcher.is-open .app-switcher__item:nth-child(4) { transition-delay: 0.12s; }
.app-switcher.is-open .app-switcher__item:nth-child(5) { transition-delay: 0.15s; }

.app-switcher:not(.is-open) .app-switcher__item {
  transition-delay: 0s !important;
}

.app-switcher__item:hover,
.app-switcher__item:focus-visible {
  background: var(--switcher-hover);
  color: var(--switcher-accent);
  outline: none;
}

.app-switcher__item.is-active {
  background: var(--switcher-hover);
  color: var(--switcher-accent);
}

.app-switcher__item.is-active::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
}

@media (max-width: 480px) {
  .app-switcher__menu {
    min-width: 138px;
  }
}

/* ── Cross-document View Transitions (MPA Smooth Transitions) ── */
@view-transition {
  navigation: auto;
}

::view-transition-old(root) {
  animation: 0.18s cubic-bezier(0.4, 0, 1, 1) both vt-page-fade-out;
}

::view-transition-new(root) {
  animation: 0.24s cubic-bezier(0, 0, 0.2, 1) both vt-page-fade-in;
}

@keyframes vt-page-fade-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-6px); }
}

@keyframes vt-page-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Fallback & universal smooth page transitions */
body.willow-page-exiting {
  opacity: 0 !important;
  transform: translateY(-6px);
  transition: opacity 0.16s cubic-bezier(0.4, 0, 1, 1),
              transform 0.16s cubic-bezier(0.4, 0, 1, 1) !important;
  pointer-events: none !important;
}

@keyframes willowPageEnter {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

body {
  animation: willowPageEnter 0.2s cubic-bezier(0, 0, 0.2, 1) backwards;
}
