/* CyberUnion Design System — shared chrome + gentle surface wash.
   Aggressive remaps are scoped so maps/charts/canvases stay intact. */

html {
  --ink: var(--cu-ink);
  --text: var(--cu-text);
  --muted-ink: var(--cu-muted);
  --paper: var(--cu-bg);
  --surface: var(--cu-surface-solid);
  --line: var(--cu-line);
  --green: var(--cu-accent);
  --mint: var(--cu-accent-soft);
}

/* Portal / simple HTML shells inherit theme canvas */
html[data-cu-shell="1"] body,
body.cu-shell,
.portal-shell,
body:has(> .portal-shell),
body:has(> .wrap > .card) {
  background: var(--cu-bg) !important;
  color: var(--cu-text) !important;
  font-family: var(--cu-font-sans) !important;
}

/* Soft sitewide wash (non-destructive overlay) */
html::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 2147482000;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% -10%, color-mix(in srgb, var(--cu-accent) 10%, transparent), transparent 42%),
    radial-gradient(circle at 1px 1px, var(--cu-noise) 0.7px, transparent 1px);
  background-size: auto, 26px 26px;
  opacity: 0.55;
  mix-blend-mode: soft-light;
}

html[data-cu-theme="healing"]::before,
html[data-cu-theme="paper"]::before,
html[data-cu-theme="calendar"]::before {
  mix-blend-mode: multiply;
  opacity: 0.28;
}

::selection {
  background: var(--cu-accent-soft);
  color: var(--cu-ink);
}

/* Brand display titles */
.cu-glow-title,
.brand-title {
  font-family: var(--cu-font-display);
  color: var(--cu-accent);
}

html[data-cu-theme="stellar"] .cu-glow-title,
html[data-cu-theme="stellar"] .brand-title {
  text-shadow: 0 0 12px var(--cu-accent-glow), 0 0 28px rgba(229, 180, 83, 0.28);
}

/* Theme switcher chrome */
#cu-theme-switcher {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 2147483000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  font-family: var(--cu-font-sans);
}

#cu-theme-switcher .cu-theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--cu-line-strong);
  border-radius: var(--cu-radius-pill);
  background: var(--cu-surface);
  color: var(--cu-ink);
  box-shadow: var(--cu-shadow);
  backdrop-filter: blur(16px);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

#cu-theme-switcher .cu-theme-toggle:hover { border-color: var(--cu-accent); }

#cu-theme-switcher .cu-theme-toggle .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--cu-accent);
  box-shadow: 0 0 0 3px var(--cu-accent-soft), 0 0 12px var(--cu-accent-glow);
}

#cu-theme-switcher .cu-theme-menu {
  display: none;
  min-width: 210px;
  padding: 8px;
  border: 1px solid var(--cu-line);
  border-radius: 16px;
  background: var(--cu-surface-solid);
  box-shadow: var(--cu-shadow);
}

#cu-theme-switcher.open .cu-theme-menu { display: grid; gap: 4px; }

#cu-theme-switcher .cu-theme-option {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--cu-text);
  cursor: pointer;
  text-align: left;
  font-size: 13px;
}

#cu-theme-switcher .cu-theme-option:hover,
#cu-theme-switcher .cu-theme-option[aria-checked="true"] {
  background: var(--cu-accent-soft);
  color: var(--cu-ink);
}

#cu-theme-switcher .cu-theme-option .swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
}

#cu-theme-switcher .cu-theme-option .label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#cu-theme-switcher .cu-theme-option .label small {
  color: var(--cu-muted);
  font-size: 11px;
  letter-spacing: 0.04em;
}

/* Portal-specific variable bridge (应用星图) */
.portal-shell {
  --ink: var(--cu-ink);
  --text: var(--cu-text);
  --muted-ink: var(--cu-muted);
  --paper: var(--cu-bg);
  --surface: var(--cu-surface-solid);
  --surface-soft: var(--cu-bg-soft);
  --line: var(--cu-line);
  --line-strong: var(--cu-line-strong);
  --mint: var(--cu-accent-soft);
  --sage: var(--cu-accent-2);
  --green: var(--cu-accent);
  --shadow-soft: var(--cu-shadow);
  color: var(--cu-text);
  background: transparent;
}

.portal-shell .topbar {
  background: var(--cu-topbar-bg) !important;
  border-bottom-color: var(--cu-line) !important;
}

.portal-shell .eyebrow,
.portal-shell .open-link,
.portal-shell .brand__word {
  color: var(--cu-accent) !important;
}

.portal-shell h1,
.portal-shell h2 {
  color: var(--cu-ink) !important;
  font-family: var(--cu-font-display) !important;
}

html[data-cu-theme="stellar"] .portal-shell h1 {
  color: var(--cu-accent) !important;
  text-shadow: 0 0 14px var(--cu-accent-glow);
}

.portal-shell .app-card,
.portal-shell .channel-card,
.portal-shell .search-box {
  background: var(--cu-surface) !important;
  border-color: var(--cu-line) !important;
  box-shadow: var(--cu-shadow) !important;
}

.portal-shell .filters button.active {
  background: var(--cu-accent) !important;
  color: var(--cu-btn-fg) !important;
}

@media (max-width: 720px) {
  #cu-theme-switcher { top: 10px; right: 10px; }
  #cu-theme-switcher .cu-theme-toggle span.name {
    max-width: 7.5em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
