html[data-cb-theme="dark"] {
  --bg: #09090b;
  --fg: #f8fafc;
  --gray-50: #111318;
  --gray-100: #1b1f27;
  --gray-200: #2b313c;
  --gray-300: #3d4654;
  --gray-400: #8b95a5;
  --gray-500: #a8b0bd;
  --gray-600: #c8ced8;
  --gray-700: #e2e6ed;
  --gray-800: #f0f3f8;
  --gray-900: #f9fafb;
  --shadow-lg: 0 18px 40px rgba(0,0,0,.42);
  --shadow-xl: 0 28px 70px rgba(0,0,0,.52);
}

html[data-cb-theme="dark"] body {
  background: var(--bg);
  color: var(--fg);
}

html[data-cb-theme="dark"] .nav,
html[data-cb-theme="dark"] .page-nav,
html[data-cb-theme="dark"] .site-nav,
html[data-cb-theme="dark"] .footer,
html[data-cb-theme="dark"] .site-footer {
  background: rgba(9,9,11,.9);
  border-color: var(--gray-100);
}

html[data-cb-theme="dark"] .nav-logo-icon,
html[data-cb-theme="dark"] .page-nav-icon,
html[data-cb-theme="dark"] .site-logo-mark,
html[data-cb-theme="dark"] .modal-header-icon {
  background: #fff;
  color: #000;
}

html[data-cb-theme="dark"] .nav-user,
html[data-cb-theme="dark"] .site-user {
  background: #f9fafb;
  color: #09090b;
  border-color: var(--gray-200);
}

html[data-cb-theme="dark"] .user-dropdown,
html[data-cb-theme="dark"] .site-user-menu,
html[data-cb-theme="dark"] .search-box,
html[data-cb-theme="dark"] .project-card,
html[data-cb-theme="dark"] .pc-badge,
html[data-cb-theme="dark"] .card,
html[data-cb-theme="dark"] .skeleton-card,
html[data-cb-theme="dark"] .lowconf-notice,
html[data-cb-theme="dark"] .modal,
html[data-cb-theme="dark"] .rate-popup,
html[data-cb-theme="dark"] .wt-box,
html[data-cb-theme="dark"] .fulltext-modal,
html[data-cb-theme="dark"] .bm-panel,
html[data-cb-theme="dark"] .bm-card,
html[data-cb-theme="dark"] .bm-card-badge,
html[data-cb-theme="dark"] .card-bm-split,
html[data-cb-theme="dark"] .bm-pop,
html[data-cb-theme="dark"] .bm-folder,
html[data-cb-theme="dark"] .bm-modal,
html[data-cb-theme="dark"] .bm-modal-btn,
html[data-cb-theme="dark"] .bm-new-coll-btn,
html[data-cb-theme="dark"] .section,
html[data-cb-theme="dark"] .delete-box {
  background: var(--gray-50);
  border-color: var(--gray-200);
}

html[data-cb-theme="dark"] .user-dropdown a,
html[data-cb-theme="dark"] .user-dropdown button,
html[data-cb-theme="dark"] .site-user-menu a,
html[data-cb-theme="dark"] .site-user-menu button {
  background: transparent;
  color: var(--gray-700);
}

html[data-cb-theme="dark"] .user-dropdown a:hover,
html[data-cb-theme="dark"] .user-dropdown button:hover,
html[data-cb-theme="dark"] .site-user-menu a:hover,
html[data-cb-theme="dark"] .site-user-menu button:hover,
html[data-cb-theme="dark"] .project-card.pending,
html[data-cb-theme="dark"] .project-card.new,
html[data-cb-theme="dark"] .sidebar-box,
html[data-cb-theme="dark"] .card-ai,
html[data-cb-theme="dark"] .skeleton-ai,
html[data-cb-theme="dark"] .modal-close,
html[data-cb-theme="dark"] .rate-popup-icon,
html[data-cb-theme="dark"] .wt-close,
html[data-cb-theme="dark"] .bm-panel-close,
html[data-cb-theme="dark"] .bm-modal-close,
html[data-cb-theme="dark"] .bm-folder-head:hover,
html[data-cb-theme="dark"] .similar-chip,
html[data-cb-theme="dark"] .similar-chip-icon,
html[data-cb-theme="dark"] .similar-chip-close,
html[data-cb-theme="dark"] .nav-similar-chip,
html[data-cb-theme="dark"] .nav-similar-chip-close,
html[data-cb-theme="dark"] .theme-choice.active {
  background: var(--gray-100);
}

html[data-cb-theme="dark"] .hero-adjective {
  background: linear-gradient(135deg, var(--gray-900), var(--gray-500));
  -webkit-background-clip: text;
  background-clip: text;
}

html[data-cb-theme="dark"] .search-glow {
  background: linear-gradient(135deg, var(--gray-300), var(--gray-100));
  opacity: .35;
}

html[data-cb-theme="dark"] input,
html[data-cb-theme="dark"] textarea,
html[data-cb-theme="dark"] select,
html[data-cb-theme="dark"] .nav-search textarea,
html[data-cb-theme="dark"] .form-input,
html[data-cb-theme="dark"] .sidebar-row input,
html[data-cb-theme="dark"] .bm-field input[type=text],
html[data-cb-theme="dark"] .bm-field textarea,
html[data-cb-theme="dark"] .bm-pop-note-wrap textarea,
html[data-cb-theme="dark"] .bm-pop-newform input {
  background-color: var(--gray-50);
  border-color: var(--gray-200);
  color: var(--gray-800);
}

html[data-cb-theme="dark"] input:focus,
html[data-cb-theme="dark"] textarea:focus,
html[data-cb-theme="dark"] select:focus,
html[data-cb-theme="dark"] .nav-search textarea:focus,
html[data-cb-theme="dark"] .form-input:focus {
  border-color: var(--gray-600);
  box-shadow: 0 0 0 3px rgba(248,250,252,.08);
}

html[data-cb-theme="dark"] input::placeholder,
html[data-cb-theme="dark"] textarea::placeholder {
  color: var(--gray-400);
}

html[data-cb-theme="dark"] .loader-overlay {
  background: rgba(9,9,11,.82);
}

html[data-cb-theme="dark"] .skeleton-line::after {
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.08) 50%, transparent 100%);
}

html[data-cb-theme="dark"] .form-btn.primary,
html[data-cb-theme="dark"] .hero-btn,
html[data-cb-theme="dark"] .rate-popup-btn.primary,
html[data-cb-theme="dark"] .bm-modal-btn.primary,
html[data-cb-theme="dark"] .bm-pop-newbtn,
html[data-cb-theme="dark"] .quota-banner-cta,
html[data-cb-theme="dark"] .site-nav-link.cta,
html[data-cb-theme="dark"] .hp-new,
html[data-cb-theme="dark"] .nav-link[style*="background"] {
  background: #f9fafb !important;
  color: #09090b !important;
  border-color: #f9fafb !important;
}

html[data-cb-theme="dark"] .form-btn.primary:hover,
html[data-cb-theme="dark"] .hero-btn:hover,
html[data-cb-theme="dark"] .rate-popup-btn.primary:hover,
html[data-cb-theme="dark"] .bm-modal-btn.primary:hover,
html[data-cb-theme="dark"] .hp-new:hover {
  background: #fff !important;
  color: #000 !important;
}

html[data-cb-theme="dark"] .form-btn.secondary,
html[data-cb-theme="dark"] .rate-popup-btn.secondary,
html[data-cb-theme="dark"] .bm-modal-btn,
html[data-cb-theme="dark"] .card-ai-copy,
html[data-cb-theme="dark"] .nav-bookmark,
html[data-cb-theme="dark"] .card-bookmark,
html[data-cb-theme="dark"] .bm-clear-btn {
  background: transparent;
  border-color: var(--gray-200);
  color: var(--gray-700);
}

html[data-cb-theme="dark"] .card-bm-split.active,
html[data-cb-theme="dark"] .card-bookmark.active {
  background: rgba(245,158,11,.13);
  border-color: rgba(245,158,11,.65);
}

html[data-cb-theme="dark"] .sub-upgrade-banner,
html[data-cb-theme="dark"] .modal-badge.beta,
html[data-cb-theme="dark"] .theme-choice.active[data-cb-theme-choice="night"] {
  background: rgba(245,158,11,.14);
  border-color: rgba(245,158,11,.35);
  color: #fde68a;
}

html[data-cb-theme="dark"] .msg-ok,
html[data-cb-theme="dark"] .sub-status-chip {
  background: rgba(16,185,129,.16);
  border-color: rgba(16,185,129,.35);
  color: #a7f3d0;
}

html[data-cb-theme="dark"] .msg-err,
html[data-cb-theme="dark"] .form-btn.danger,
html[data-cb-theme="dark"] .bm-modal-btn.danger {
  background: rgba(239,68,68,.14);
  border-color: rgba(239,68,68,.35);
  color: #fecaca;
}

html[data-cb-theme="dark"] .quota-banner {
  background: #f9fafb;
  color: #09090b;
  border-color: var(--gray-200);
}

html[data-cb-theme="dark"] .quota-banner-close {
  color: #374151;
}

html[data-cb-theme="dark"] .quota-banner-close:hover {
  color: #000;
}

html[data-cb-theme="dark"] .bm-toast,
html[data-cb-theme="dark"] .rehydrate-toast,
html[data-cb-theme="dark"] .cb-theme-toast {
  background: #f9fafb;
  color: #09090b;
}

.theme-nudge {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 850;
  width: min(17.5rem, calc(100vw - 2rem));
  padding: .8rem;
  border: 1px solid var(--gray-200);
  border-radius: .75rem;
  background: rgba(255,255,255,.96);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(.5rem);
  transition: opacity .18s, transform .18s;
}

.theme-nudge.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.theme-nudge-title {
  font-size: .88rem;
  font-weight: 700;
  color: var(--gray-900);
}

.theme-nudge-copy {
  margin-top: .15rem;
  font-size: .78rem;
  color: var(--gray-500);
  line-height: 1.35;
}

.theme-nudge-actions {
  display: flex;
  gap: .45rem;
  justify-content: flex-end;
  margin-top: .65rem;
}

.theme-nudge button {
  border: 1px solid var(--gray-200);
  background: #fff;
  color: var(--gray-700);
  border-radius: .45rem;
  padding: .35rem .55rem;
  font-size: .74rem;
  font-weight: 600;
}

.theme-nudge button.primary {
  background: var(--gray-900);
  border-color: var(--gray-900);
  color: #fff;
}

html[data-cb-theme="dark"] .theme-nudge {
  background: rgba(17,19,24,.96);
  border-color: var(--gray-200);
}

html[data-cb-theme="dark"] .theme-nudge button {
  background: var(--gray-50);
  color: var(--gray-800);
  border-color: var(--gray-200);
}

html[data-cb-theme="dark"] .theme-nudge button.primary {
  background: #f9fafb;
  color: #09090b;
  border-color: #f9fafb;
}

.cb-theme-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(2rem);
  background: var(--gray-900);
  color: #fff;
  font-size: .8rem;
  padding: .55rem 1rem;
  border-radius: .4rem;
  opacity: 0;
  pointer-events: none;
  z-index: 900;
  transition: opacity .2s, transform .2s;
}

.cb-theme-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.theme-choice-grid {
  display: grid;
  gap: .55rem;
}

.theme-choice {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .75rem;
  border: 1px solid var(--gray-200);
  border-radius: .6rem;
  background: #fff;
  color: var(--gray-700);
  text-align: left;
  transition: border-color .15s, background .15s, color .15s;
}

.theme-choice:hover {
  border-color: var(--gray-300);
  color: var(--gray-900);
}

.theme-choice-copy {
  min-width: 0;
}

.theme-choice-title {
  display: block;
  font-size: .9rem;
  font-weight: 600;
  color: var(--gray-900);
}

.theme-choice-sub {
  display: block;
  margin-top: .12rem;
  font-size: .75rem;
  color: var(--gray-500);
  line-height: 1.35;
}

.theme-choice-mark {
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  border: 1px solid var(--gray-300);
  flex: none;
  display: grid;
  place-items: center;
}

.theme-choice.active .theme-choice-mark {
  border-color: var(--gray-900);
  background: var(--gray-900);
}

.theme-choice.active .theme-choice-mark::after {
  content: "";
  width: .42rem;
  height: .42rem;
  border-radius: 50%;
  background: var(--bg);
}

.theme-status {
  margin-top: .75rem;
  font-size: .78rem;
  color: var(--gray-500);
  line-height: 1.5;
}

html[data-cb-theme="dark"] .theme-choice {
  background: var(--gray-50);
  border-color: var(--gray-200);
}

html[data-cb-theme="dark"] #mcpConnectBox,
html[data-cb-theme="dark"] #adminEntrySection,
html[data-cb-theme="dark"] .section[style*="border-color:#fecaca"],
html[data-cb-theme="dark"] #mcpContent details > div {
  background: var(--gray-50) !important;
  border-color: var(--gray-200) !important;
}

html[data-cb-theme="dark"] #mcpConnectBox [style*="background:#fff"],
html[data-cb-theme="dark"] #mcpContent [style*="background:#f9fafb"],
html[data-cb-theme="dark"] #mcpContent [style*="background:#fffbeb"] {
  background: var(--gray-100) !important;
  border-color: var(--gray-200) !important;
}

html[data-cb-theme="dark"] #mcpConnectBox,
html[data-cb-theme="dark"] #mcpConnectBox *,
html[data-cb-theme="dark"] #adminEntrySection,
html[data-cb-theme="dark"] #adminEntrySection *,
html[data-cb-theme="dark"] #mcpContent [style*="color:#0c4a6e"],
html[data-cb-theme="dark"] #mcpContent [style*="color:#065f46"],
html[data-cb-theme="dark"] #mcpContent [style*="color:#78350f"],
html[data-cb-theme="dark"] #mcpContent [style*="color:#92400e"] {
  color: var(--gray-700) !important;
}
