/* Shared appearance tokens for the public gateway and private workspace. */
html:root {
  color-scheme: light;
  --page-bg: #fdfdff;
  --ink: #120f19;
  --purple: #7100f5;
  --muted: #6c6285;
  --line: #e7e1f0;
  --surface: #fff;
  --soft: #f2eef8;
  --selected: #eee6fa;
  --control-line: #b8a5ce;
  --button-bg: #17121f;
  --button-ink: #fff;
  --button-hover: #4b1184;
  --code-bg: #f7f4fb;
  --code-ink: #21172e;
  --code-inline-ink: #411073;
  --selection-bg: #e5d3ff;
  --selection-ink: #36016b;
  --marker: #449b2e;
  --logo-filter: none;
  background: var(--page-bg);
  color: var(--ink);
}

html:root[data-theme="dark"] {
  color-scheme: dark;
  --page-bg: #131017;
  --ink: #f2ecf9;
  --purple: #c39aff;
  --muted: #b6a9c8;
  --line: #42364e;
  --surface: #1c1723;
  --soft: #282032;
  --selected: #352447;
  --control-line: #806c96;
  --button-bg: #c5a1f0;
  --button-ink: #1a1026;
  --button-hover: #d8bbfa;
  --code-bg: #1a1521;
  --code-ink: #ece2f7;
  --code-inline-ink: #dcc4fa;
  --selection-bg: #67438c;
  --selection-ink: #fff;
  --marker: #85bf71;
  --logo-filter: brightness(1.65) saturate(.55);
}

/* Keep the OS choice usable if JavaScript is unavailable. */
@media (prefers-color-scheme: dark) {
  html:root:not([data-theme]) {
    color-scheme: dark;
    --page-bg: #131017;
    --ink: #f2ecf9;
    --purple: #c39aff;
    --muted: #b6a9c8;
    --line: #42364e;
    --surface: #1c1723;
    --soft: #282032;
    --selected: #352447;
    --control-line: #806c96;
    --button-bg: #c5a1f0;
    --button-ink: #1a1026;
    --button-hover: #d8bbfa;
    --code-bg: #1a1521;
    --code-ink: #ece2f7;
    --code-inline-ink: #dcc4fa;
    --selection-bg: #67438c;
    --selection-ink: #fff;
    --marker: #85bf71;
    --logo-filter: brightness(1.65) saturate(.55);
  }
}

html:root body { background: var(--page-bg); color: var(--ink); }
html:root * { scrollbar-color: var(--control-line) var(--page-bg); }
html:root ::selection { background: var(--selection-bg); color: var(--selection-ink); }
html:root :focus-visible { outline-color: var(--purple); }
html:root .brand img { filter: var(--logo-filter); }
html:root input, html:root textarea, html:root select {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--control-line);
  caret-color: var(--purple);
}
html:root input::placeholder, html:root textarea::placeholder { color: var(--muted); opacity: 1; }
html:root input:-webkit-autofill {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
  caret-color: var(--purple);
}
html:root button:where(:not(.motion-control, .theme-toggle, .theme-system, .sign-in)),
html:root .sign-in.primary {
  background: var(--button-bg);
  color: var(--button-ink);
  border-color: var(--button-bg);
}
html:root button:where(:not(.motion-control, .theme-toggle, .theme-system, .sign-in)):hover,
html:root .sign-in.primary:hover { background: var(--button-hover); border-color: var(--button-hover); }
html:root .quiet-form button,
html:root .code-toolbar button,
html:root .selected-file-group button {
  background: transparent;
  color: var(--purple);
  border-color: var(--control-line);
}
html:root .quiet-form button:hover,
html:root .code-toolbar button:hover,
html:root .selected-file-group button:hover { background: var(--soft); border-color: var(--control-line); }
html:root .intro strong, html:root .empty-chat h3 { color: var(--ink); }
html:root .error, html:root .user-message, html:root .message.user-message,
html:root .badge, html:root .event dl { background: var(--soft); }
html:root .chat-sidebar nav a { color: var(--ink); }
html:root .chat-sidebar nav a[aria-current] { background: var(--selected); color: var(--purple); }
html:root .chat-settings-panel, html:root #composer { background: var(--surface); border-color: var(--control-line); }
html:root .message-body p code, html:root .message-body li code { background: var(--selected); color: var(--code-inline-ink); }
html:root .code-block { background: var(--code-bg); border-color: var(--control-line); }
html:root .code-toolbar { color: var(--muted); border-color: var(--control-line); }
html:root .code-block pre { color: var(--code-ink); }
html:root .attachment-list li, html:root .controls-form, html:root .upload-button { border-color: var(--control-line); }
html:root .upload-button { color: var(--ink); }
html:root .upload-button:hover { background: var(--soft); }
html:root .composer-help, html:root .workspace-disclosure { color: var(--muted); }
html:root .composer-top { flex-wrap: wrap; }
html:root .composer-top select { flex: 1 1 180px; min-width: 0; max-width: 100%; }
html:root .model-availability { margin: 0 0 24px; padding-block: 16px; border-block: 1px solid var(--line); }
html:root .model-availability strong { display: block; color: var(--ink); font-size: 14px; line-height: 1.6; }
html:root .model-availability p { max-width: 68ch; color: var(--muted); font: 13px/1.65 Arial, sans-serif; margin: 7px 0 0; }
html:root .model-provenance { color: var(--muted); font: 11px/1.65 Arial, sans-serif; overflow-wrap: anywhere; }
html:root .model-choices { min-width: 0; margin: 0; padding: 16px; border: 1px solid var(--line); }
html:root .model-choices legend { padding-inline: 6px; color: var(--ink); font: 12px/1.6 Arial, sans-serif; }
html:root .model-choices label { display: flex; align-items: flex-start; gap: 12px; min-height: 44px; margin: 0; padding-block: 10px; font: 13px/1.6 Arial, sans-serif; overflow-wrap: anywhere; }
html:root .model-choices input[type="checkbox"] { flex: none; width: 18px; height: 18px; min-height: 18px; margin: 2px 0 0; accent-color: var(--purple); }
html:root .status i, html:root .present:before,
html:root .beta-label > span, html:root .schematic-label > span { background: var(--marker); }

/* A single, labeled 44px control is available on every page. */
html:root .theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  height: 44px;
  min-height: 44px;
  margin: 0;
  padding: 11px;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
html:root .theme-toggle:hover { color: var(--purple); border-color: var(--control-line); background: var(--soft); }
html:root .theme-toggle svg { width: 20px; height: 20px; display: block; }
html:root .theme-toggle:disabled { visibility: hidden; }
html:root .theme-toggle .theme-sun { display: none; }
html:root[data-theme="dark"] .theme-toggle .theme-sun { display: block; }
html:root[data-theme="dark"] .theme-toggle .theme-moon { display: none; }
html:root .theme-system {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin: 0;
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 12px/1.5 Consolas, 'Liberation Mono', monospace;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}
html:root .theme-system:hover { background: transparent; color: var(--purple); }
html:root .theme-system[hidden] { display: none; }
html:root .appearance-actions { display: flex; align-items: center; gap: 18px; }
html:root .auth-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 24px; }
@media (max-width: 480px) {
  html:root .auth-header { gap: 12px; }
  html:root .auth-header .brand { gap: 4px; }
  html:root .appearance-actions { gap: 10px; }
}
