/* Theme preference is applied by theme.js before the stylesheets load. */
:root {
  --focus: #f58150;
}
::selection { background: #ee581f35; }
input, textarea { caret-color: var(--accent); }
.theme-switcher {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
  flex-shrink: 0;
}
.theme-select { position: relative; display: inline-flex; }
.theme-select > .icon {
  position: absolute;
  right: 12px;
  top: 50%;
  width: 14px;
  height: 14px;
  transform: translateY(-50%) rotate(90deg);
  pointer-events: none;
  color: var(--muted);
}
.theme-switcher select {
  appearance: none;
  min-height: 38px;
  width: 116px;
  padding: 8px 32px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: var(--bg);
  cursor: pointer;
}
.theme-switcher select:hover { border-color: var(--muted); }
.login-topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 45px; }

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f5f3;
  --panel: rgba(255,255,255,.94);
  --panel2: #eeefec;
  --line: #d9dad5;
  --text: #242421;
  --muted: #61615b;
  --soft: #555555;
  --success: #4e7555;
  --focus: #b93a0c;
}
[data-theme="light"] .material-bg {
  background:
    radial-gradient(ellipse at 92% 0%, rgba(226,169,135,.16), transparent 46%),
    radial-gradient(ellipse at 0% 100%, rgba(140,153,163,.10), transparent 52%),
    repeating-linear-gradient(128deg, transparent 0 140px,
      rgba(91,91,83,.025) 141px 142px, transparent 143px 220px);
}
[data-theme="light"] .material-bg:after { display: none; }
[data-theme="light"] .brand-wordmark { filter: invert(1); }
[data-theme="light"] .brand-word span { border-color: #61615b; }
[data-theme="light"] .btn { background: #f8f8f6; }
[data-theme="light"] .btn:hover,
[data-theme="light"] .icon-btn:hover,
[data-theme="light"] .nav button:hover,
[data-theme="light"] .history-item:hover { background: #eeefec; color: var(--text); }
[data-theme="light"] .btn.primary { background: #cc4714; border-color: #cc4714; color: white; }
[data-theme="light"] .btn.primary:hover { background: #b93a0c; border-color: #b93a0c; }
[data-theme="light"] .btn.quiet { background: transparent; }
[data-theme="light"] .sidebar .new-chat,
[data-theme="light"] .tag.orange { color: #a83b10; background: #fff1e9; border-color: #f3d0bd; }
[data-theme="light"] .nav button.active { background: #eeefec; }
[data-theme="light"] .nav button.active .icon { color: #b93a0c; }
[data-theme="light"] .nav-label,
[data-theme="light"] .history-date,
[data-theme="light"] .history-item .history-meta,
[data-theme="light"] .history-bottom,
[data-theme="light"] .composer-hint,
[data-theme="light"] .composer-disclaimer,
[data-theme="light"] .context-footer,
[data-theme="light"] .login-footer { color: var(--muted); }
[data-theme="light"] .side-note strong,
[data-theme="light"] .field,
[data-theme="light"] .dialog-body .source-text { color: var(--text); }
[data-theme="light"] .avatar { background: #eee9e1; color: #69513c; }
[data-theme="light"] .history-item.selected { background: #f5eeea; border-color: #e5dad3; }
[data-theme="light"] .search-box,
[data-theme="light"] .suggestion { background: #fbfbf9; }
[data-theme="light"] .suggestion:hover { background: #fff1e9; border-color: #e3b497; }
[data-theme="light"] .suggestion .icon,
[data-theme="light"] .file-icon,
[data-theme="light"] .side-note .icon { color: #9a4c28; }
[data-theme="light"] .chat-main { background: transparent; }
[data-theme="light"] .message.user { background: #f1f2ee; }
[data-theme="light"] .message-actions .btn { background: transparent; }
[data-theme="light"] .message-actions .btn:hover,
[data-theme="light"] .message-actions .rated { color: #b93a0c; background: #fff1e9; }
[data-theme="light"] .source-pill { background: #f8f8f6; color: #575750; }
[data-theme="light"] .source-pill:hover { border-color: #a85c36; }
[data-theme="light"] .message.error,
[data-theme="light"] .status.error,
[data-theme="light"] .error-text { color: #a33517; }
[data-theme="light"] .message.insufficient { color: #68531d; }
[data-theme="light"] .composer { border-color: #c5c7bf; background: #fbfbf9; }
[data-theme="light"] .composer:focus-within { border-color: var(--focus); }
[data-theme="light"] .expert-art { background: radial-gradient(circle,#f4dfd1,#f7f6f3 70%); }
[data-theme="light"] .status { background: #eeefec; }
[data-theme="light"] .status.active,
[data-theme="light"] .status.complete { color: #3d6746; background: #e8f1e8; }
[data-theme="light"] .status.ready { color: #785018; background: #faf1df; }
[data-theme="light"] .field input,
[data-theme="light"] .field textarea,
[data-theme="light"] .field select,
[data-theme="light"] .toolbar select { background: #fbfbf9; }
[data-theme="light"] input::placeholder,
[data-theme="light"] textarea::placeholder { color: #6d6d65; opacity: 1; }
[data-theme="light"] .login-form-panel { background: rgba(255,255,255,.94); }
[data-theme="light"] .login-art span { background: #f2e3d9; border-color: #e4d3c8; }
[data-theme="light"] .login-art span:nth-child(2n) { background: #eeefec; border-color: #d9ddd7; }
[data-theme="light"] .login-art span:nth-child(3n) { background: #e3e5e3; border-color: #d3d7d3; }
[data-theme="light"] dialog { background: #fff; border-color: #d9dad5; }
[data-theme="light"] dialog::backdrop { background: #24242166; }
[data-theme="light"] #toast { background: #fff; border-color: #d6c2b4; color: var(--text); box-shadow: 0 8px 24px #24242120; }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: #a7a9a0; }
[data-theme="light"] button:focus-visible,
[data-theme="light"] a:focus-visible,
[data-theme="light"] input:focus-visible,
[data-theme="light"] textarea:focus-visible,
[data-theme="light"] select:focus-visible { outline-color: var(--focus); }

.theme-switcher select:focus,
.theme-switcher select:focus-visible {
  outline: none;
  box-shadow: none;
  border-color: var(--muted);
}

@media(max-width:640px) {
  .brand-caption { max-width: 98px; }
  .theme-switcher { gap: 0; }
  .theme-switcher > span:not(.theme-select) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .theme-switcher select { font-size: 11px; }
  .login-topbar { gap: 12px; margin-bottom: 30px; }
  [data-theme="light"] .sidebar,
  [data-theme="light"] .history-panel { background: #fff; }
}
@media(max-width:380px) {
  .topbar .brand-caption,
  .login-topbar .brand-caption { display: none; }
}
