/* One appearance control across the site. The menu is portaled to <body>. */
html[data-theme="light"] { color-scheme: light; background: #f5f5f9; }
html[data-theme="dark"] { color-scheme: dark; background: #1e2133; }
html {
  --theme-control-text: #566a7f;
  --theme-control-hover: #f0f1f6;
  --theme-control-accent: #5b50d6;
  --theme-control-selected: #eeecff;
  --theme-menu-bg: #fff;
  --theme-menu-text: #384551;
  --theme-menu-muted: #627187;
  --theme-menu-border: #e7e8f0;
  --theme-menu-shadow: 0 10px 36px #26344a1a, 0 2px 8px #26344a0a;
}
html[data-theme="dark"] {
  --theme-control-text: #c4c5dc;
  --theme-control-hover: #3a3a50;
  --theme-control-accent: #c2baff;
  --theme-control-selected: #454061;
  --theme-menu-bg: #2d2d42;
  --theme-menu-text: #e5e5f2;
  --theme-menu-muted: #a4a6c0;
  --theme-menu-border: #46465f;
  --theme-menu-shadow: 0 12px 40px #08091552, 0 2px 8px #08091533;
}
[data-site-theme-control] { display: inline-flex; flex: 0 0 auto; align-items: center; }
html body .site-theme-control { display: inline-flex; align-items: center; flex: 0 0 auto; margin: 0; padding: 0; line-height: 1; }
/* Scoped resets keep form, login and public-page button styles out of this control. */
html[data-theme] body .site-theme-control button.site-theme-trigger {
  box-sizing: border-box; position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 42px; min-width: 42px; max-width: 42px; height: 42px; min-height: 42px; flex: 0 0 42px;
  margin: 0; padding: 0; border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--theme-control-text); box-shadow: none; appearance: none;
  font: 500 14px/1 system-ui, sans-serif; text-align: center; text-decoration: none; letter-spacing: normal;
  cursor: pointer; opacity: 1; transform: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: background-color .15s ease, color .15s ease;
}
html[data-theme] body .site-theme-control button.site-theme-trigger:hover {
  background: var(--theme-control-hover); color: var(--theme-menu-text); border-color: transparent;
  box-shadow: none; transform: none;
}
html[data-theme] body .site-theme-control button.site-theme-trigger[aria-expanded="true"] {
  background: var(--theme-control-selected); color: var(--theme-control-accent);
}
html[data-theme] body .site-theme-control button.site-theme-trigger:active { transform: none; background: var(--theme-control-selected); }
html[data-theme] body .site-theme-control button.site-theme-trigger::before,
html[data-theme] body .site-theme-control button.site-theme-trigger::after,
html[data-theme] body .site-theme-menu button.site-theme-item::before,
html[data-theme] body .site-theme-menu button.site-theme-item::after { content: none; }
html[data-theme] body .site-theme-control button.site-theme-trigger:focus-visible {
  outline: 2px solid var(--theme-control-accent); outline-offset: 3px; box-shadow: none;
}
html body .site-theme-control svg,
html body .site-theme-menu .site-theme-icon { display: block; width: 20px; height: 20px; flex: 0 0 20px; color: inherit; pointer-events: none; }

html[data-theme] body .site-theme-menu {
  box-sizing: border-box; position: fixed; z-index: 12000; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px;
  width: 192px; max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); overflow-y: auto;
  margin: 0; padding: 6px; border: 1px solid var(--theme-menu-border); border-radius: 12px;
  background: var(--theme-menu-bg); color: var(--theme-menu-text); box-shadow: var(--theme-menu-shadow);
  font: 500 14px/1.4 system-ui, -apple-system, "PingFang SC", sans-serif;
  text-align: left; letter-spacing: normal; overscroll-behavior: contain;
}
html body .site-theme-menu[hidden] { display: none !important; }
html body .site-theme-menu .site-theme-menu-title {
  display: block; margin: 0; padding: 6px 10px 8px; color: var(--theme-menu-muted);
  font: 500 11px/1.5 system-ui, -apple-system, "PingFang SC", sans-serif; letter-spacing: .03em;
}
html[data-theme] body .site-theme-menu button.site-theme-item {
  box-sizing: border-box; display: flex; position: relative; align-items: center; justify-content: flex-start; gap: 11px;
  width: 100%; min-width: 0; min-height: 44px; height: auto; margin: 0; padding: 10px;
  border: 0; border-radius: 7px; background: transparent; color: var(--theme-menu-text); box-shadow: none;
  font: inherit; text-align: left; text-decoration: none; letter-spacing: normal; white-space: nowrap;
  appearance: none; cursor: pointer; opacity: 1; transform: none; touch-action: manipulation;
  transition: background-color .12s ease, color .12s ease;
}
html[data-theme] body .site-theme-menu button.site-theme-item:hover {
  background: var(--theme-control-hover); box-shadow: none; transform: none;
}
html[data-theme] body .site-theme-menu button.site-theme-item[aria-checked="true"] {
  background: var(--theme-control-selected); color: var(--theme-control-accent); font-weight: 600;
}
html[data-theme] body .site-theme-menu button.site-theme-item:focus-visible {
  outline: 2px solid var(--theme-control-accent); outline-offset: -2px; box-shadow: none;
}
html body .site-theme-menu .site-theme-item-label { flex: 1 1 auto; margin: 0; color: inherit; font: inherit; }
html body .site-theme-menu .site-theme-check {
  display: block; width: 16px; height: 16px; flex: 0 0 16px; margin-left: auto;
  color: inherit; opacity: 0; pointer-events: none;
}
html body .site-theme-menu .site-theme-item[aria-checked="true"] .site-theme-check { opacity: 1; }

html body .site-theme-login { display: flex; justify-content: flex-end; margin-bottom: 20px; }
html body .site-theme-verify { display: flex; justify-content: flex-end; margin-bottom: 16px; }
html body .agent-topbar { gap: 16px; }
html body .agent-topbar > [data-site-theme-control] { margin-left: auto; }
html body .agent-topbar-right { flex-shrink: 0; }
html body .tenant-topbar-user, html body .topbar-actions { gap: 16px; }
html body.sneat-pool .user-menu { flex-wrap: wrap; }
body.sneat-shop .topbar { flex-wrap: wrap; gap: 18px; }
@media(max-width: 1100px) { .admin-body .topbar-end .region-badge { display: none; } }
@media(max-width: 820px) {
  body.sneat-shop .topbar { grid-template-columns: minmax(0, 1fr) auto; height: auto; gap: 12px; }
  body.sneat-shop .topbar > .brand { grid-column: 1; grid-row: 1; }
  body.sneat-shop .topbar > [data-site-theme-control] { grid-column: 2; grid-row: 1; justify-self: end; }
  body.sneat-shop .network { display: none; }
}
@media(max-width: 700px) {
  html body .agent-topbar { gap: 8px; flex-wrap: wrap; }
  html body .topbar-end { gap: 8px; }
  .admin-body .topbar-end .api-badge { display: none; }
  body.sneat-api-docs .topbar-actions { flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
  body.sneat-api-docs .public-label { display: none; }
  body.sneat-shop .network { display: none; }
  body.sneat-shop .shop-nav { order: 3; width: 100%; justify-content: center; }
  body.sneat-shop .topbar > [data-site-theme-control] { margin-left: auto; }
}
@media(prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  html[data-theme] body .site-theme-control button.site-theme-trigger,
  html[data-theme] body .site-theme-menu button.site-theme-item { transition: none; }
}
@media(forced-colors: active) {
  html[data-theme] body .site-theme-control button.site-theme-trigger,
  html[data-theme] body .site-theme-menu { border: 1px solid ButtonText; }
  html[data-theme] body .site-theme-menu button.site-theme-item[aria-checked="true"] { outline: 1px solid Highlight; outline-offset: -2px; }
}
@media print { [data-site-theme-control], .site-theme-menu { display: none !important; } }
