.palette-switcher {
  position: relative;
  display: inline-flex;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  color: inherit;
  font-family: var(--font-inter), system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.4;
  letter-spacing: 0;
}

.palette-switcher,
.palette-switcher * { box-sizing: border-box; }
.palette-switcher button { font: inherit; letter-spacing: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.palette-switcher svg { display: block; width: 18px; height: 18px; flex-shrink: 0; }
.palette-switcher .palette-icons { position: absolute; width: 0; height: 0; overflow: hidden; }
.palette-switcher svg:not(.palette-icons) { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.palette-switcher__status { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.palette-switcher__toggle {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid currentColor;
  border-color: color-mix(in srgb, currentColor 30%, transparent);
  border-radius: 50%;
  background: transparent;
  color: inherit;
  transition: background .18s, border-color .18s;
}

.palette-switcher__toggle:hover,
.palette-switcher__toggle[aria-expanded=true] {
  border-color: color-mix(in srgb, currentColor 65%, transparent);
  background: color-mix(in srgb, currentColor 7%, transparent);
}
.palette-switcher__toggle svg { width: 19px; height: 19px; }

.palette-switcher__panel {
  position: absolute;
  z-index: 90;
  top: calc(100% + 12px);
  right: 0;
  width: min(250px, calc(100vw - 24px));
  max-height: calc(100svh - 100px);
  padding: 7px;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scrollbar-width: thin;
  scrollbar-color: var(--viewer-muted, #526168) var(--viewer-bg, #ebeeef);
  border: 1px solid var(--viewer-line, #2e383c30);
  border-radius: 15px;
  background: var(--viewer-bg, #ebeeef);
  color: var(--viewer-text, #2e383c);
  animation: palette-switcher-open .16s ease-out both;
}

.palette-switcher__panel[hidden] { display: none; }

.palette-switcher__themes { display: grid; gap: 2px; }
.palette-switcher__theme {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--viewer-text, #2e383c);
  text-align: left;
}
.palette-switcher__theme>span { font-size: 12px; line-height: 1.4; }
.palette-switcher__theme svg { color: var(--viewer-muted, #526168); }
.palette-switcher__theme:hover,
.palette-switcher__theme[aria-pressed=true] { background: var(--viewer-panel, #dce1e2); }
.palette-switcher__theme .palette-switcher__check { width: 16px; margin-left: auto; color: var(--viewer-text, #2e383c); font-size: 14px; text-align: center; }

.palette-switcher__style-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 7px 4px 0;
  padding: 5px 7px 0;
  border-top: 1px solid var(--viewer-line, #2e383c30);
}
.palette-switcher__style-row>span { font-size: 12px; }
.palette-switcher__style { display: grid; place-items: center; min-width: 44px; min-height: 42px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: inherit; }
.palette-switcher__track { display: block; width: 36px; height: 22px; padding: 3px; border: 1px solid var(--viewer-muted, #526168); border-radius: 20px; background: var(--viewer-panel, #dce1e2); }
.palette-switcher__track>span { display: block; width: 14px; height: 14px; border-radius: 50%; background: var(--viewer-muted, #526168); transition: transform .18s; }
.palette-switcher__style[aria-checked=true] .palette-switcher__track { border-color: var(--viewer-accent, #4e6571); background: var(--viewer-accent, #4e6571); }
.palette-switcher__style[aria-checked=true] .palette-switcher__track>span { transform: translateX(14px); background: var(--viewer-ink, #fff); }
.palette-switcher__style:hover .palette-switcher__track { border-color: var(--viewer-text, #2e383c); }

.palette-switcher :focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
.palette-switcher__theme:focus-visible { outline-offset: -2px; }

@keyframes palette-switcher-open { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .palette-switcher__panel { animation: none; } .palette-switcher * { transition: none !important; } }
