/* Nexus V80 · stable global dark/light theme layer */

html{
  background:var(--bg-soft);
}

html,body,.app-body,.public-body,.auth-body{
  background-color:var(--bg-soft);
  color:var(--text);
}

body,
.app-sidebar,
.app-topbar,
.card,
.modal-card,
.toast,
input,
textarea,
select,
button,
a{
  transition:background-color .18s ease,border-color .18s ease,color .18s ease,box-shadow .18s ease;
}

.theme-toggle-button{
  color:var(--text-soft);
}
.theme-toggle-button:hover{
  color:var(--text);
  border-color:rgba(139,92,246,.35);
  background:var(--primary-soft);
}

/* Core surfaces */
.app-sidebar{background:var(--sidebar-bg)!important;border-color:var(--border-soft)!important}
.app-topbar{background:var(--topbar-bg)!important;border-color:var(--border-soft)!important;backdrop-filter:blur(16px)}
.page-shell{color:var(--text)}
.card,.modal-card,.toast,.identity-current,.identity-menu,.search-results,.notification-dropdown{
  background:var(--surface)!important;
  border-color:var(--border-soft)!important;
  color:var(--text);
}
input,textarea,select{
  background:var(--input-bg)!important;
  border-color:var(--border)!important;
  color:var(--text)!important;
}
input:focus,textarea:focus,select:focus{
  border-color:rgba(139,92,246,.58)!important;
  box-shadow:0 0 0 3px rgba(139,92,246,.11)!important;
}
.icon-button,.button-ghost{
  background:var(--surface)!important;
  border-color:var(--border)!important;
  color:var(--text-soft)!important;
}
.icon-button:hover,.button-ghost:hover{
  background:var(--surface-2)!important;
  color:var(--text)!important;
}
.button-primary,.brand-mark,.forge-button-accent-v68,.forge-releases-accent-v67,.gh-repositories-cta-v61{
  color:var(--primary-contrast)!important;
}
.sidebar-link:hover,.sidebar-link.active,.identity-option:hover,.identity-option.active,.conversation.active,.filter-chip:hover,.filter-chip.active,.dashboard-tabs a.active{
  background:var(--surface-2)!important;
  color:var(--text)!important;
}
.sidebar-link{color:var(--muted)}
.sidebar-link.active i,.sidebar-link:hover i{color:#9b6cff}

/* Public and authentication */
.public-header,.public-nav,.public-footer{
  background:var(--surface-glass)!important;
  border-color:var(--border-soft)!important;
}
.auth-card,.public-card,.feature-card,.final-cta,.legal-content,.floating-card,.hero-product,.mini-feed,.mini-sidebar{
  background:var(--surface)!important;
  border-color:var(--border-soft)!important;
  color:var(--text)!important;
  box-shadow:var(--shadow-soft);
}
.public-links,.auth-switch,.hero-copy p,.feature-card p,.legal-content p{color:var(--text-soft)!important}
.public-links a:hover{color:var(--text)!important}

/* Feed and social */
.composer,.post-card,.rail-card,.story-strip,.feed-mode-tabs,.feed-right-rail,.post-comments-panel,.clip-card,.clip-form-panel,.clip-preview-panel,.explore-toolbar,.explore-card,.messages-shell,.messages-sidebar,.chat-panel,.conversation-menu{
  background:var(--surface)!important;
  border-color:var(--border-soft)!important;
  color:var(--text)!important;
}
.composer-placeholder,.comment>div,.message-bubble,.conversation-item:hover,.messages-search,.chat-composer,.feed-mode-tabs a,.feed-mode-tabs button{
  background:var(--surface-2)!important;
  border-color:var(--border-soft)!important;
  color:var(--text-soft)!important;
}
.post-copy,.comment p,.clip-copy small,.feed-rail-person small,.feed-rail-server small,.chat-person small,.message-bubble,.explore-card p{
  color:var(--text-soft)!important;
}
.post-media,.clip-visual,.clip-preview,.explore-card-media,.story-view>a{
  background:var(--surface-4)!important;
}
.post-actions button:hover,.post-actions button.active{
  background:var(--surface-2)!important;
  color:var(--text)!important;
}

/* Notifications and messages */
.notification-dropdown-header,.notification-item-live,.notification-item,.conversation-row,.chat-header,.chat-composer{
  border-color:var(--border-soft)!important;
}
.notification-item-live:hover,.conversation-row:hover{
  background:var(--surface-2)!important;
}
.conversation-menu{box-shadow:var(--shadow)!important}

/* Profiles, identities and settings */
.profile-hero,.profile-about-card,.relationship-card,.profile-actions-popover,.server-profile,.server-about-card,.server-info-card,.server-review-card,.server-review-form,.identity-manager-shell,.identity-orbit-card,.identity-manager-hint,.identity-settings-form,.identity-preview-card,.identity-save-bar,.identity-nav-profile,.identity-danger-zone,.discord-linked-card,.discord-server-card,.identity-create-modal,.identity-create-preview,.identity-preview-card{
  background:var(--surface)!important;
  border-color:var(--border-soft)!important;
  color:var(--text)!important;
  box-shadow:var(--shadow-soft);
}
.profile-description,.profile-bio,.profile-about-card p,.server-description,.server-about-card p,.relationship-copy p,.identity-preview-bio,.identity-settings-header p,.identity-section-heading p{
  color:var(--text-soft)!important;
}
.profile-actions-popover a:hover,.identity-node-actions button:hover,.identity-nav-profile:hover{
  background:var(--surface-2)!important;
}
.identity-preview-banner,.profile-banner,.server-hero-banner,.server-profile-cover{
  background-color:var(--surface-2)!important;
}

/* Server directory and public server page */
.server-browser-row,.server-directory-card,.server-hero,.server-tabs,.server-content-layout,.server-review-summary-v76,.server-stat-row-v76,.server-about-grid-v76,.server-clips-grid-v76{
  background:var(--surface)!important;
  border-color:var(--border-soft)!important;
  color:var(--text)!important;
}
.server-browser-row:hover,.server-tabs a:hover,.server-tabs a.active{
  background:var(--surface-2)!important;
}
.server-browser-copy p,.server-browser-tags,.server-description,.server-stat-row-v76 span{
  color:var(--text-soft)!important;
}

/* Marketplace */
.marketplace-controls,.marketplace-categories,.market-product-card,.market-product-actionbar,.marketplace-buy-card,.market-product-comments,.market-product-comment,.market-modal,.market-product-preview-panel,.market-product-form-fields{
  background:var(--surface)!important;
  border-color:var(--border-soft)!important;
  color:var(--text)!important;
}
.market-product-card:hover,.marketplace-categories a:hover,.marketplace-categories a.active{
  background:var(--surface-2)!important;
}
.market-product-content p,.market-product-comment p,.market-product-preview-copy p{
  color:var(--text-soft)!important;
}

/* Studio global */
.studio-page,.studio-page--developer,.server-studio-page-v76,.server-posts-page{color:var(--text)}
.sidebar-context,.sidebar-context--developer,.gh-sidebar-context,.studio-hero,.studio-metric,.studio-section,.studio-empty,.studio-project-card,.studio-v43-card,.studio-v43-panel,.gh-repositories-panel-v61,.gh-repository-row-v61,.forge-releases-library-v67,.forge-library-v68,.forge-summary-strip-v68 article,.forge-toolbar-v68,.forge-license-row-v68,.forge-sale-row-v68,.forge-issue-row-v68,.forge-insight-row-v68,.server-overview-kpi,.server-overview-panel,.server-overview-feed-card,.server-overview-event-card,.server-overview-recruitment-card,.server-overview-action,.server-posts-hero,.server-posts-toolbar,.server-post-card{
  background:var(--surface)!important;
  border-color:var(--border-soft)!important;
  color:var(--text)!important;
  box-shadow:var(--shadow-soft);
}
.studio-custom-select__button,.studio-custom-select__menu,.studio-custom-select__option,.gh-input,.gh-select,.gh-search,.forge-search-v68 input,.forge-filter-v68 select{
  background:var(--input-bg)!important;
  border-color:var(--border)!important;
  color:var(--text)!important;
}
.studio-custom-select__option:hover,.studio-custom-select__option.is-selected{
  background:var(--primary-soft)!important;
  color:var(--text)!important;
}
.gh-repositories-overview-v61 strong,.forge-row-title-v68 strong,.forge-sale-value-v68>strong,.forge-modal-summary-v68 article>strong,.forge-insight-metrics-v68 strong,.forge-products-no-results-v56 strong{
  color:var(--text)!important;
}
.forge-button-secondary-v68,.forge-releases-ghost-v67,.gh-repositories-page .gh-repository-row-v61 .button.button-ghost,.gh-repositories-page .gh-repository-row-v61 .icon-button{
  background:var(--surface-2)!important;
  border-color:var(--border)!important;
  color:var(--text-soft)!important;
}
.forge-button-secondary-v68:hover,.forge-releases-ghost-v67:hover,.gh-repositories-page .gh-repository-row-v61 .icon-button:hover{
  color:var(--text)!important;
}
.forge-segmented-v68 button:hover,.forge-segmented-v68 button.is-active{
  color:var(--text)!important;
}

/* GitHub-like Forge palette */
.gh-repository-page,.gh-project-header,.gh-repo-header,.gh-repo-code-area,.gh-file-table,.gh-readme-card,.gh-sidebar-panel,.gh-tab-panel,.gh-action-panel{
  background:var(--forge-bg)!important;
  border-color:var(--forge-border)!important;
  color:var(--forge-text)!important;
}
.gh-file-row,.gh-repo-toolbar,.gh-commit-row,.gh-repo-tabs,.gh-repo-summary,.gh-code-toolbar{
  background:var(--forge-surface)!important;
  border-color:var(--forge-border)!important;
  color:var(--forge-text)!important;
}
.gh-file-row:hover,.gh-repo-tabs a:hover,.gh-repo-tabs a.active{
  background:var(--forge-surface-2)!important;
}

/* Server publications */
.server-post-card-media{background:var(--surface-4)!important}
.server-post-card-body p{color:var(--text-soft)!important}
.server-posts-toolbar-stat,.mention-helper,.mention-chip,.media-preview-card,.custom-file-upload{
  background:var(--surface-2)!important;
  border-color:var(--border)!important;
}
.mention-chip:hover{background:var(--primary-soft)!important}

/* Modals, stories and overlays */
.modal-backdrop,.story-creator-backdrop,.story-viewer-backdrop,.clip-modal-backdrop,.market-modal-backdrop,.identity-create-backdrop,.post-comments-backdrop{
  background:var(--overlay)!important;
}
.story-creator-dialog,.story-editor-panel,.story-preview-panel,.clip-modal,.market-modal,.identity-create-modal,.post-comments-modal{
  background:var(--surface)!important;
  border-color:var(--border)!important;
  color:var(--text)!important;
}
.story-dropzone,.clip-upload-zone,.story-preview-empty,.clip-preview-empty{
  background:var(--surface-2)!important;
  border-color:var(--border)!important;
}

/* Light-mode only contrast repairs */
html[data-theme="light"] .avatar,
html[data-theme="light"] .brand-mark,
html[data-theme="light"] .clip-play i,
html[data-theme="light"] .story-viewer-media,
html[data-theme="light"] .story-viewer-header,
html[data-theme="light"] .story-viewer-footer,
html[data-theme="light"] .server-hero-overlay,
html[data-theme="light"] .profile-banner-shade,
html[data-theme="light"] .explore-card-shade,
html[data-theme="light"] .market-product-overlay{
  color:var(--on-dark)!important;
}
html[data-theme="light"] .story-viewer-dialog{
  background:#050507!important;
  color:#fff!important;
}
html[data-theme="light"] .story-viewer-dialog .icon-button,
html[data-theme="light"] .story-viewer-dialog input{
  background:rgba(255,255,255,.10)!important;
  color:#fff!important;
  border-color:rgba(255,255,255,.18)!important;
}
html[data-theme="light"] .text-link:hover{color:var(--primary)!important}
html[data-theme="light"] .status-pill,html[data-theme="light"] .game-badge{border-color:var(--border)!important}
html[data-theme="light"] .empty-state{background:var(--surface-2)!important;border-color:var(--border)!important}
html[data-theme="light"] .check-row input[type=checkbox],
html[data-theme="light"] .toggle-row input[type=checkbox]{background:#d8deea}

@media(max-width:860px){
  .theme-toggle-floating{top:12px;right:12px}
}


@media (prefers-reduced-motion: reduce){
  *,*::before,*::after{scroll-behavior:auto!important;transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}
}

/* Nexus V81 · strict light/dark compliance repairs */
html[data-theme="light"] body,
body[data-theme="light"]{
  background:var(--bg-soft)!important;
  color:var(--text)!important;
}

/* Floating menus, dropdowns and popovers must never keep the dark palette in light mode. */
html[data-theme="light"] body .identity-menu,
html[data-theme="light"] body .notification-dropdown,
html[data-theme="light"] body .search-results,
html[data-theme="light"] body .conversation-menu,
html[data-theme="light"] body .profile-actions-popover,
html[data-theme="light"] body .identity-node-actions,
html[data-theme="light"] body .studio-custom-select__menu,
html[data-theme="light"] body .market-modal,
html[data-theme="light"] body .modal-card{
  background:#ffffff!important;
  border-color:var(--border)!important;
  color:var(--text)!important;
  box-shadow:0 22px 58px rgba(15,23,42,.16)!important;
}

html[data-theme="light"] body .identity-menu-heading{
  color:#667085!important;
}

html[data-theme="light"] body .identity-menu form,
html[data-theme="light"] body .identity-menu button,
html[data-theme="light"] body .identity-menu a{
  color:var(--text)!important;
}

html[data-theme="light"] body .identity-option{
  background:transparent!important;
  color:var(--text)!important;
}

html[data-theme="light"] body .identity-option:hover{
  background:#f3f0ff!important;
  color:#4c1d95!important;
}

html[data-theme="light"] body .identity-option.active{
  background:linear-gradient(135deg,#ede9fe,#f5f3ff)!important;
  color:#4c1d95!important;
  box-shadow:inset 0 0 0 1px rgba(124,58,237,.15)!important;
}

html[data-theme="light"] body .identity-option small,
html[data-theme="light"] body .identity-menu-actions a,
html[data-theme="light"] body .identity-menu-actions button{
  color:#667085!important;
}

html[data-theme="light"] body .identity-menu-actions{
  border-top-color:var(--border-soft)!important;
}

html[data-theme="light"] body .identity-menu .avatar{
  background:linear-gradient(145deg,#ffffff,#e9edf6)!important;
  border-color:#d5dbea!important;
  color:#252b3a!important;
}

/* Identity orbit manager: light canvas while preserving the premium purple visual language. */
html[data-theme="light"] body .identity-manager-page{
  background:transparent!important;
}

html[data-theme="light"] body .identity-manager-shell{
  background:
    radial-gradient(circle at 50% 44%,rgba(124,58,237,.09),transparent 28%),
    radial-gradient(circle at 22% 15%,rgba(59,130,246,.065),transparent 24%),
    linear-gradient(180deg,#ffffff,#f6f8fd 76%)!important;
  border-color:#dfe5ef!important;
  box-shadow:0 22px 58px rgba(15,23,42,.10)!important;
  color:var(--text)!important;
}

html[data-theme="light"] body .identity-manager-header h1,
html[data-theme="light"] body .identity-account-core h2,
html[data-theme="light"] body .identity-node-copy strong{
  color:#111827!important;
}

html[data-theme="light"] body .identity-manager-header p,
html[data-theme="light"] body .identity-account-core p,
html[data-theme="light"] body .identity-node-copy em,
html[data-theme="light"] body .identity-manager-footer,
html[data-theme="light"] body .identity-manager-footer small,
html[data-theme="light"] body .identity-manager-legend span{
  color:#667085!important;
}

html[data-theme="light"] body .identity-manager-hint{
  background:rgba(255,255,255,.92)!important;
  border-color:#dde3ee!important;
  color:#111827!important;
  box-shadow:0 14px 36px rgba(15,23,42,.10)!important;
  backdrop-filter:blur(14px);
}

html[data-theme="light"] body .identity-space-grid{
  opacity:.42!important;
  background-image:
    linear-gradient(rgba(76,29,149,.045) 1px,transparent 1px),
    linear-gradient(90deg,rgba(76,29,149,.045) 1px,transparent 1px)!important;
}

html[data-theme="light"] body .identity-particles span{
  opacity:.24!important;
}

html[data-theme="light"] body .identity-orbit-ring{
  border-color:rgba(124,58,237,.16)!important;
}

html[data-theme="light"] body .identity-orbit-ring::before{
  border-top-color:rgba(59,130,246,.26)!important;
}

html[data-theme="light"] body .identity-orbit-ring::after{
  border-top-color:rgba(168,85,247,.24)!important;
}

html[data-theme="light"] body .identity-account-core{
  background:
    radial-gradient(circle at 50% 28%,rgba(124,58,237,.12),transparent 48%),
    rgba(255,255,255,.96)!important;
  border-color:rgba(124,58,237,.28)!important;
  box-shadow:
    0 0 0 10px rgba(124,58,237,.035),
    0 0 0 28px rgba(59,130,246,.025),
    0 28px 68px rgba(15,23,42,.14),
    inset 0 1px 0 rgba(255,255,255,.9)!important;
}

html[data-theme="light"] body .identity-account-avatar{
  background:linear-gradient(145deg,#ffffff,#e9e7f7)!important;
  border-color:#ffffff!important;
  color:#252b3a!important;
  box-shadow:0 0 0 2px #7c3aed,0 16px 34px rgba(124,58,237,.18)!important;
}

html[data-theme="light"] body .identity-account-avatar i{
  border-color:#ffffff!important;
}

html[data-theme="light"] body .identity-account-stats strong{
  color:#111827!important;
}

html[data-theme="light"] body .identity-online-pill{
  background:rgba(22,163,74,.08)!important;
  border-color:rgba(22,163,74,.18)!important;
  color:#15803d!important;
}

html[data-theme="light"] body .identity-orbit-card{
  background:linear-gradient(145deg,rgba(255,255,255,.98),rgba(247,248,253,.98))!important;
  border-color:color-mix(in srgb,var(--accent) 34%,#d9dfeb)!important;
  color:#111827!important;
  box-shadow:0 16px 34px rgba(15,23,42,.11),inset 0 1px 0 rgba(255,255,255,.9)!important;
}

html[data-theme="light"] body .identity-orbit-card:hover,
html[data-theme="light"] body .identity-orbit-node.is-previewing .identity-orbit-card{
  border-color:var(--accent)!important;
  box-shadow:0 20px 44px rgba(15,23,42,.14),0 0 24px color-mix(in srgb,var(--accent) 16%,transparent)!important;
}

html[data-theme="light"] body .identity-node-avatar{
  background:#f4f5fa!important;
  color:#252b3a!important;
  border-color:color-mix(in srgb,var(--accent) 48%,#d9dfeb)!important;
}

html[data-theme="light"] body .identity-node-avatar > i{
  border-color:#ffffff!important;
}

html[data-theme="light"] body .identity-active-mark,
html[data-theme="light"] body .identity-primary-badge{
  color:#ffffff!important;
}

html[data-theme="light"] body .identity-node-actions a,
html[data-theme="light"] body .identity-node-actions button{
  color:#667085!important;
}

html[data-theme="light"] body .identity-node-actions a:hover,
html[data-theme="light"] body .identity-node-actions button:hover{
  background:#f3f0ff!important;
  color:#6d28d9!important;
}

/* Keep the dark design explicit when dark mode is active. */
html[data-theme="dark"] body .identity-menu{
  background:var(--surface-elevated)!important;
  color:var(--text)!important;
}

html[data-theme="dark"] body .identity-manager-shell{
  background:
    radial-gradient(circle at 50% 42%,rgba(76,29,149,.16),transparent 25%),
    radial-gradient(circle at 25% 15%,rgba(37,99,235,.08),transparent 24%),
    linear-gradient(180deg,#0b0b12,#08080d 72%)!important;
}

/* A few remaining shared components with legacy hard-coded dark fills. */
html[data-theme="light"] body .avatar:not(.story-viewer-dialog .avatar),
html[data-theme="light"] body .identity-current,
html[data-theme="light"] body .global-search input,
html[data-theme="light"] body .composer-placeholder,
html[data-theme="light"] body .comment > div,
html[data-theme="light"] body .message-bubble,
html[data-theme="light"] body .notification-item-live,
html[data-theme="light"] body .conversation-row,
html[data-theme="light"] body .filter-chip,
html[data-theme="light"] body .dashboard-tabs a{
  background-color:var(--surface)!important;
  border-color:var(--border-soft)!important;
  color:var(--text)!important;
}

html[data-theme="light"] body .sidebar-link:hover,
html[data-theme="light"] body .sidebar-link.active{
  background:#f0edf9!important;
  color:#312e81!important;
}

html[data-theme="light"] body .sidebar-link.active i,
html[data-theme="light"] body .sidebar-link:hover i{
  color:#7c3aed!important;
}
