/* CXD Chat — light is the default. Dark is opt-in via data-theme="dark". */

:root {
  color-scheme: light;
  --cxd-bg: #f8fafc;
  --cxd-surface: #ffffff;
  --cxd-surface-2: #f1f5f9;
  --cxd-border: #e2e8f0;
  --cxd-border-strong: #cbd5e1;
  --cxd-text: #0f172a;
  --cxd-muted: #475569;
  --cxd-primary: #e11d48;
  --cxd-primary-hover: #be123c;
  --cxd-cta: #00A7B9;
  --cxd-cta-hover: #008A99;
  --cxd-accent: #00A7B9;
  --cxd-accent-soft: #E5F8FA;
  --cxd-online: #15803d;
  --cxd-own: #fff1f2;
  --cxd-own-border: #fecdd3;
  --cxd-name: #9f1239;
  --cxd-name-own: #be123c;
  --cxd-link: #008A99;
  --cxd-danger: #b91c1c;
  --cxd-avatar-bg: #e2e8f0;
  --cxd-logo-fg: #ffffff;
  --cxd-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --cxd-shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.14);
  --cxd-radius: 14px;
  --cxd-header: 58px;
  --cxd-rail: 50px;
  --cxd-side: 260px;
  --cxd-members: 260px;
  --cxd-footer: 40px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --font-head: "Urbanist", "Segoe UI", sans-serif;
  --font-body: "Urbanist", "Segoe UI", sans-serif;
  --ease: 180ms ease;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --cxd-bg: #0c0f14;
  --cxd-surface: #141a22;
  --cxd-surface-2: #1c2430;
  --cxd-border: #2a3441;
  --cxd-border-strong: #3d4b5c;
  --cxd-text: #e8eef5;
  --cxd-muted: #94a3b8;
  --cxd-online: #22c55e;
  --cxd-own: #172554;
  --cxd-own-border: #1e3a8a;
  --cxd-name: #fda4af;
  --cxd-name-own: #93c5fd;
  --cxd-link: #5ee4ef;
  --cxd-danger: #f87171;
  --cxd-avatar-bg: #334155;
  --cxd-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --cxd-shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.theme-icon {
  display: grid;
  place-items: center;
}
.theme-icon--sun { display: none; }
html[data-theme="dark"] .theme-icon--moon { display: none; }
html[data-theme="dark"] .theme-icon--sun { display: grid; }

.theme-toggle-auth {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.theme-toggle-auth button {
  background: transparent;
  border: 1px solid var(--cxd-border);
  color: var(--cxd-muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}

.theme-toggle-auth button:hover {
  border-color: var(--cxd-border-strong);
  color: var(--cxd-text);
}

/* Pack wallpapers (chat main only) */
html[data-theme="catween"] .chat-main,
html[data-theme="forest"] .chat-main,
html[data-theme="arc"] .chat-main,
html[data-theme="remix"] .chat-main {
  background-color: var(--cxd-bg);
  background-image: var(--cxd-chat-wallpaper);
  background-size: cover;
  background-position: center;
  background-attachment: local;
}

html[data-theme="catween"] .chat-logs,
html[data-theme="forest"] .chat-logs,
html[data-theme="arc"] .chat-logs,
html[data-theme="remix"] .chat-logs {
  background: transparent;
}

.chat-box--theme {
  width: min(560px, 94vw);
}

.cxd-theme-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 4px 2px 8px;
}

.cxd-theme-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  border: 2px solid var(--cxd-border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--cxd-surface);
  color: var(--cxd-text);
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.cxd-theme-card.is-on {
  border-color: var(--cxd-accent);
  box-shadow: 0 0 0 1px var(--cxd-accent);
}

.cxd-theme-card__preview {
  display: block;
  height: 84px;
  background-size: cover;
  background-position: center;
  background-color: var(--cxd-surface-2);
}

.cxd-theme-card__bar {
  display: block;
  height: 4px;
  width: 100%;
}

.cxd-theme-card strong {
  display: block;
  padding: 10px 12px 12px;
  font-size: 13.5px;
  letter-spacing: 0.3px;
}

@media (max-width: 480px) {
  .cxd-theme-grid {
    grid-template-columns: 1fr;
  }
}

/* Chat chrome that depends on active theme */
@media (max-width: 768px) {
  .chat-header [data-theme-toggle] { display: none; }
}
