/* Shared appearance menu and semantic colors for new components. */
:root {
  --theme-canvas: #f6f8f4;
  --theme-surface: #ffffff;
  --theme-surface-muted: #f0f4ed;
  --theme-text: #202723;
  --theme-text-muted: #657164;
  --theme-border: #d7dfd4;
  --theme-focus: #a93617;
  --theme-action: #bc421e;
  --theme-on-action: #ffffff;
  --theme-selected: #e7efdf;
  --theme-on-selected: #284226;
  --theme-shadow-rgb: 24 37 27;
}
.account-site-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  column-gap: 24px;
  position: relative;
  z-index: 20;
}
.account-site-header .header-brand-group { display: flex; align-items: center; }
.account-site-header > nav { justify-content: flex-end; min-width: 0; }
.account-site-header > .header-theme { justify-self: end; }
/* The appearance choices stay clickable above the non-modal chat (layer 80).
   Native modal dialogs remain in the browser top layer. */
.account-site-header:has(.theme-menu[open]) { z-index: 90; }
.theme-menu { position: relative; color: var(--theme-text); flex-shrink: 0; }
.theme-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 44px;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--theme-text-muted);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.theme-trigger::-webkit-details-marker { display: none; }
.theme-trigger:hover, .theme-menu[open] > .theme-trigger {
  background: var(--theme-surface-muted);
  color: var(--theme-text);
}
.theme-trigger:focus-visible, .theme-option:has(input:focus-visible) {
  outline: 3px solid var(--theme-focus);
  outline-offset: 3px;
}
.theme-trigger > .theme-icon { display: none; width: 18px; height: 18px; }
html:not([data-theme-preference]) .theme-icon--system,
html[data-theme-preference="system"] .theme-icon--system,
html[data-theme-preference="light"] .theme-icon--light,
html[data-theme-preference="dark"] .theme-icon--dark { display: block; }
.theme-panel {
  position: absolute;
  inset: calc(100% + 8px) 0 auto auto;
  width: 224px;
  max-width: calc(100vw - 32px);
  padding: 8px;
  border: 1px solid var(--theme-border);
  border-radius: 14px;
  background: var(--theme-surface);
  box-shadow: 0 12px 32px rgb(var(--theme-shadow-rgb) / 16%);
}
.theme-options { min-width: 0; margin: 0; padding: 0; border: 0; }
.theme-options legend { padding: 6px 10px 9px; font-size: 13px; color: var(--theme-text-muted); }
.theme-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--theme-text);
  font-size: 14px;
  line-height: 1.5;
}
.theme-option:hover { background: var(--theme-surface-muted); }
.theme-option:has(input:checked) { background: var(--theme-selected); color: var(--theme-on-selected); }
.theme-option input[type="radio"] {
  order: 3;
  margin: 0 0 0 auto;
  padding: 0;
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  min-height: 0;
  accent-color: var(--theme-on-selected);
  cursor: pointer;
}
.theme-option > svg { flex: 0 0 18px; }
@media (min-width: 701px) and (max-width: 1100px) {
  .account-site-header { column-gap: 10px; }
  .account-site-header > nav { gap: 2px; }
  .theme-trigger { padding-inline: 8px; }
}
@media (max-width: 700px) {
  .account-site-header {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 8px;
  }
  .account-site-header > .header-brand-group { grid-column: 1; grid-row: 1; width: auto; }
  .account-site-header > .header-theme { grid-column: 2; grid-row: 1; }
  .account-site-header > nav { grid-column: 1 / -1; grid-row: 2; justify-content: space-between; }
}
@media (forced-colors: active) {
  .theme-trigger, .theme-panel { border: 1px solid ButtonText; }
  .theme-option:has(input:checked) { outline: 1px solid Highlight; outline-offset: -1px; }
}
@media print { .theme-menu { display: none !important; } }
