:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

:is(.portal-theme-control, .portal-locale-control) {
  --control-ink: var(--theme-control-ink, #393c47);
  --control-border: var(--theme-control-border, #b9b4a7);
  --control-hover: var(--theme-control-hover, #eee8da);
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: .42rem;
  box-sizing: border-box;
  min-width: 44px;
  min-height: 44px;
  padding: 0 .55rem;
  font-size: .8rem;
  line-height: 1;
  color: var(--control-ink);
  white-space: nowrap;
}

[data-theme="dark"] :is(.portal-theme-control, .portal-locale-control) {
  --control-ink: var(--theme-control-ink, #efe4c9);
  --control-border: var(--theme-control-border, #897c61);
  --control-hover: var(--theme-control-hover, #233044);
}

:is(.portal-theme-control, .portal-locale-control)[hidden] { display: none; }
:is(.portal-theme-control, .portal-locale-control)::before {
  content: "";
  position: absolute;
  inset: 5px 0;
  border: 1px solid var(--control-border);
  border-radius: 5px;
  pointer-events: none;
}
:is(.portal-theme-control, .portal-locale-control):hover::before,
:is(.portal-theme-control, .portal-locale-control):focus-within::before { background: var(--control-hover); }
:is(.portal-theme-control, .portal-locale-control):focus-within { outline: 2px solid currentColor; outline-offset: 1px; }
:is(.portal-theme-control, .portal-locale-control) .portal-theme-icon {
  position: relative;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}
.portal-theme-label, .portal-locale-label { position: relative; }
.portal-theme-moon, [data-theme="dark"] .portal-theme-sun { display: none; }
[data-theme="dark"] .portal-theme-moon { display: initial; }
:is(.portal-theme-control, .portal-locale-control) select {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  font: inherit;
}
@media (max-width: 560px) {
  .portal-theme-control .portal-theme-label { display: none; }
  .portal-locale-control .portal-theme-icon { display: none; }
}
@media (forced-colors: active) {
  :is(.portal-theme-control, .portal-locale-control)::before { border-color: ButtonText; }
}
