.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-width: 40px; min-height: 40px; padding: 9px 12px; border: 1px solid #dbe4dd;
  border-radius: 8px; background: transparent; color: #506d5b; font: inherit;
  font-size: 12px; cursor: pointer; flex-shrink: 0;
}
.theme-toggle svg {
  width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}
.theme-toggle:hover { background: #edf3ee; }
.theme-toggle:focus-visible { outline: 2px solid #548d66; outline-offset: 2px; }
.theme-toggle-icon { width: 40px; padding: 9px; }
.theme-toggle-icon span { display: none; }
.login-layout { position: relative; }
.login-theme-toggle { position: absolute; right: 24px; top: 20px; z-index: 1; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  color: #e2ece6; background: #121a17;
  --ink: #e2ece6; --muted: #a7b9ad; --line: #35463c; --paper: #121a17;
  --green: #2d805d; --surface: #1b2620; --surface-raised: #24342b; --accent: #91d9b2;
  --chat-paper: #121a17; --chat-ink: #e2ece6; --chat-muted: #a7b9ad;
  --chat-line: #35463c; --chat-accent: #82d1a4;
  color-scheme: dark;
}
:root[data-theme="dark"] body { background: var(--paper); color: var(--ink); }
:root[data-theme="dark"] :is(.sidebar, .login-form-panel) { background: #17211c; }
:root[data-theme="dark"] :is(.topbar, .panel, .stat, .card, .node-card, .composer, dialog, .new-chat, .suggestions button) {
  background: var(--surface); color: var(--ink); border-color: var(--line);
}
:root[data-theme="dark"] :is(.chat-page, .testlab-page) header { background: var(--surface); border-color: var(--line); }
:root[data-theme="dark"] :is(.nav-item, .rail-control, .icon-button, .small-button, .theme-toggle, .secondary) {
  color: #c6d8cc; background: transparent; border-color: var(--line);
}
:root[data-theme="dark"] :is(.nav-item, .rail-control, .theme-toggle, .secondary, .new-chat):hover { background: var(--surface-raised); }
:root[data-theme="dark"] .nav-item.active { color: #e2f8e9; background: #264435; }
:root[data-theme="dark"] :is(.nav-item, .rail-control, .theme-toggle, .secondary):focus-visible { outline-color: var(--accent); }
:root[data-theme="dark"] :is(input, select, textarea) {
  background: #121c16; color: var(--ink); border-color: #496053;
}
:root[data-theme="dark"] :is(input, select, textarea)::placeholder { color: #9aafa1; }
:root[data-theme="dark"] :is(label, h1, h2, h3, .brand, .breadcrumb strong, .message-content, .heading strong) { color: var(--ink); }
:root[data-theme="dark"] :is(.eyebrow, .back, .text-link, .section-title > span, .header-actions a, .model-bar select) { color: var(--accent); }
:root[data-theme="dark"] :is(.muted, .workspace-label, .stat-label, .stat-caption, .panel-header p, .empty p, .breadcrumb,
  .page-footer, .user-card small, .endpoint-card small, .brand small, .project-label, .history-heading, .account small,
  .heading span, .private-label, .welcome p, .suggestions small, .message-label, .message-footer, .model-detail,
  .model-bar label, .footnote, .subtle, .node-details, .feature-note, .testlab-page small, .testlab-page .fine) { color: var(--muted); }
:root[data-theme="dark"] :is(.panel-header, th, td, .endpoint-card, .account, header, .page-footer, footer) { border-color: var(--line); }
:root[data-theme="dark"] th { background: #202e25; color: var(--muted); }
:root[data-theme="dark"] .badge { background: #213e2c; border-color: #426b50; color: #acdfbb; }
:root[data-theme="dark"] :is(.badge.neutral, .pill, .tag, .avatar, .empty-symbol, .welcome-symbol, .message .speaker) {
  background: #263c2e; border-color: #42604c; color: #b9d9c2;
}
:root[data-theme="dark"] .badge.warning { background: #3c3420; color: #edcf8f; border-color: #6f5b32; }
:root[data-theme="dark"] :is(.error, .notice) { background: #3b2921; color: #ffd3b7; border-color: #77503b; }
:root[data-theme="dark"] .message-error { color: #ffcbac; }
:root[data-theme="dark"] :is(code, pre, .api-block, .sample) { background: #101b14; color: #c0e4cc; border-color: var(--line); }
:root[data-theme="dark"] :is(.primary, #run-form button[type="submit"], .send-button) { background: #327956; color: #fff; border-color: #578e6c; }
:root[data-theme="dark"] .login-story { background: #10251c; }
:root[data-theme="dark"] .login-story :is(.brand, h1) { color: #e1f3e7; }
:root[data-theme="dark"] .story-copy p { color: #b3cbbd; }
:root[data-theme="dark"] .chat-page .composer-area { background: linear-gradient(transparent, var(--chat-paper) 12px); }
:root[data-theme="dark"] .chat-page .composer textarea { background: transparent; color: var(--chat-ink); }
:root[data-theme="dark"] .chat-page #history button { color: #c6d6ca !important; }
:root[data-theme="dark"] .chat-page #history button:hover,
:root[data-theme="dark"] .chat-page #history button.active { background: #293e30 !important; }
:root[data-theme="dark"] .attachment { background: #253c2d; color: #c0ddc8; border-color: var(--line); }
:root[data-theme="dark"] .message.user .speaker { background: #293f50; color: #c6deee; }
:root[data-theme="dark"] .message-attachments a { color: var(--accent); border-color: var(--line); }
:root[data-theme="dark"] .testlab-page .status { background: #253c2d; border-color: var(--line); }
:root[data-theme="dark"] .testlab-page .activity svg { background: linear-gradient(0deg, #16251b, #1b2620); }
:root[data-theme="dark"] .testlab-page svg text { fill: #b1c9b9; }
:root[data-theme="dark"] .testlab-page .worker-bar { background: #2c4334; }
:root[data-theme="dark"] .testlab-page .good { color: #91dfad; }
:root[data-theme="dark"] .testlab-page .bad { color: #ffb6a9; }
:root[data-theme="dark"] dialog::backdrop { background: #0009; }
@media (max-width: 740px) {
  .theme-toggle-icon { min-width: 36px; width: 36px; padding: 8px; }
  .testlab-page header { gap: 10px; padding-inline: 16px; }
  .chat-page .header-actions { gap: 8px; }
}
@media (max-width: 520px) {
  .testlab-page header .tag { display: none; }
}
