/* Shared surfaces keep the chat, community, account and rules in the same palette. */
:root {
  color-scheme: light;
  --page: #f7f9f9;
  --sidebar: #eff4f4;
  --surface: #ffffff;
  --surface-raised: #f8fbfb;
  --soft: #edf3f3;
  --ink: #293f48;
  --muted: #566c75;
  --link: #315f67;
  --line: #dce6e7;
  --border: #b9cbcf;
  --action: #487279;
  --on-action: #ffffff;
  --selected: #e1efed;
  --selected-ink: #315d62;
  --selected-border: #90b4b5;
  --focus: #638d92;
  --focus-ring: #90b4b533;
  --selection: #cce4e1;
  --selection-ink: #244e54;
  --warning-bg: #faf1eb;
  --warning: #894a32;
  --warning-border: #e6d2c5;
  --shadow: #18333e1c;
  --backdrop: #162b3b66;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #101010;
  --sidebar: #151515;
  --surface: #1b1b1b;
  --surface-raised: #202020;
  --soft: #232323;
  --ink: #e8e7e5;
  --muted: #aaa9a6;
  --link: #c9cec9;
  --line: #313131;
  --border: #4b4b4b;
  --action: #d5d4cf;
  --on-action: #202020;
  --selected: #2c2c2c;
  --selected-ink: #ecebe8;
  --selected-border: #626262;
  --focus: #aaa9a2;
  --focus-ring: #aaa9a226;
  --selection: #424642;
  --selection-ink: #f1f1ed;
  --warning-bg: #30241f;
  --warning: #dcb39f;
  --warning-border: #61483c;
  --shadow: #00000040;
  --backdrop: #000000b8;
}
:root[data-theme="dark"] :is(.brand img, .avatar) { filter: grayscale(1); }
::selection { background: var(--selection); color: var(--selection-ink); }
html { scrollbar-color: var(--border) var(--page); }
input, textarea, select { color: var(--ink); background-color: var(--surface); accent-color: var(--action); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
dialog { background: var(--surface); }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible,
select:focus-visible, summary:focus-visible, [tabindex="-1"]:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 3px; box-shadow: none;
}
/* The composer itself carries focus, so the textarea does not get a second frame. */
.composer:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px var(--focus-ring); }
.composer textarea:focus-visible { outline: none; box-shadow: none; }
.auth-tabs button.primary, .qh-button.tab[aria-pressed="true"],
.nav-item.active, .strategy-options button[aria-pressed="true"],
.moods button[aria-pressed="true"], .qh-post-toolbar .qh-button[aria-pressed="true"] {
  background: var(--selected); color: var(--selected-ink);
  box-shadow: inset 0 0 0 1px var(--selected-border);
  border-color: transparent;
}
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-width: 44px; min-height: 44px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  color: var(--muted); background: var(--surface); font-size: 13px;
}
.theme-toggle:hover { background: var(--soft); color: var(--ink); }
.theme-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.theme-sun, [data-theme="dark"] .theme-moon { display: none; }
[data-theme="dark"] .theme-sun { display: block; }
.theme-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 24px 0 18px; }
.theme-choice { min-height: 64px; padding: 14px 8px; border: 1px solid var(--line); border-radius: 12px; font-size: 14px; color: var(--muted); background: var(--surface-raised); }
.theme-choice:hover { border-color: var(--selected-border); }
.theme-choice[aria-pressed="true"] { background: var(--selected); color: var(--selected-ink); border-color: var(--selected-border); font-weight: 600; }
#theme-summary { font-size: 13px; margin-bottom: 0; color: var(--muted); }
#appearance-dialog .close { color: var(--muted); }
@media (max-width: 620px) {
  .theme-toggle { padding: 9px; }
  .theme-toggle .theme-label { display: none; }
  .topbar-actions { flex-wrap: wrap; }
}
@media (forced-colors: active) {
  .composer textarea:focus-visible { outline: 2px solid Highlight; }
  .auth-tabs button.primary, .qh-button.tab[aria-pressed="true"], .nav-item.active,
  .strategy-options button[aria-pressed="true"], .moods button[aria-pressed="true"],
  .theme-choice[aria-pressed="true"] { outline: 2px solid Highlight; outline-offset: -2px; }
}
