button.theme-control {
  --theme-control-surface: #edf4ea;
  --theme-control-hover: #ddebd9;
  --theme-control-border: #bacdbb;
  --theme-control-ink: #224632;
  --theme-control-focus: #23653e;
  box-sizing: border-box;
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  inline-size: 44px;
  block-size: 44px;
  min-inline-size: 44px;
  min-block-size: 44px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--theme-control-border);
  border-radius: 12px;
  background: var(--theme-control-surface);
  color: var(--theme-control-ink);
  cursor: pointer;
  vertical-align: middle;
}

.app-shell .topbar button.theme-control,
html[data-theme="dark"] button.theme-control {
  --theme-control-surface: #263f30;
  --theme-control-hover: #365341;
  --theme-control-border: #5a7862;
  --theme-control-ink: #edf5e4;
  --theme-control-focus: #b1e6b4;
}

button.theme-control:hover { background: var(--theme-control-hover); }
button.theme-control:focus-visible {
  outline: 2px solid var(--theme-control-focus);
  outline-offset: 3px;
}

.theme-control-icon {
  display: block;
  font: 700 1.45rem/1 Georgia, "Segoe UI Symbol", serif;
}

.theme-auth-controls,
.theme-marketing-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-auth-controls { margin-block-end: 1rem; }
.theme-auth-controls .mobile-brand { margin-block-end: 0; }
.theme-auth-controls .theme-control { margin-inline-start: auto; }
.theme-control-fallback {
  display: flex;
  justify-content: flex-end;
  padding: 12px;
}

.legal-header nav:has(.theme-control) {
  align-items: center;
  column-gap: clamp(10px, 3vw, 18px);
}

@media (max-width: 760px) {
  .app-shell .topbar-actions:has(.theme-control),
  .app-shell .topbar-actions:has(.theme-control) .wallet-pill,
  .app-shell .topbar-actions:has(.theme-control) .wallet-pill strong {
    min-inline-size: 0;
  }

  .app-shell .topbar-actions:has(.theme-control) .wallet-pill strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-shell .topbar-actions:has(.theme-control) :is(.level-pill, .account-button) {
    flex: 0 0 auto;
  }
}

@media (max-width: 620px) {
  .marketing-header:has(.theme-marketing-controls) {
    flex-wrap: wrap;
    gap: 8px 12px;
    padding-block: 8px;
  }

  .theme-marketing-controls {
    gap: 8px;
    margin-inline-start: auto;
  }

  .admin-topbar:has(.theme-control) { gap: 12px; }
  .admin-topbar .topbar-actions:has(.theme-control) { gap: 6px; }
}

@media (max-width: 500px) {
  .app-shell .topbar:has(.theme-control) .brand > span:last-child { display: none; }
}

@media (max-width: 440px) {
  .wiki-header:has(.theme-control) {
    flex-wrap: wrap;
    gap: 8px 12px;
  }
}

@media print {
  button.theme-control,
  .theme-control-fallback { display: none; }
}
