/* Shared dark surfaces for public pages, forms, student accounts and workspaces.
   Home-page tokens and controls are defined in home-theme.css. The existing
   light palette is preserved when the visitor chooses light mode. */
html[data-theme="dark"], html[data-theme="dark"] body.cerebras-theme {
    --navy: var(--text-navy);
    --tw-slate: var(--text-navy);
    --tw-dark-btn: var(--surface-2);
    --tw-dark-btn-hover: var(--surface-secondary);
    --color-border-subtle: var(--line);
    --color-dribbble-dark: var(--text-navy);
    --color-pill-bg: var(--surface-2);
    --color-pill-border: var(--line);
    --btn-light: var(--surface-2);
    --btn-light-text: var(--text-navy);
    --btn-navy-bg: var(--surface-2);
    --btn-navy-text: var(--text-navy);
    --btn-navy-border: var(--control-border);
    --btn-navy-hover: var(--surface-secondary);
    --line-focus: var(--brand-accent);
    --accent-mint-text: #77dfae !important;
    --tag-green: #77dfae;
    --danger: #ff9c9c;
    --shadow-xs: none !important;
    --shadow-sm: none !important;
    --shadow-md: 0 8px 24px #0006 !important;
    --shadow-lg: 0 16px 40px #0008 !important;
}

/* Workspace menus use the same mobile drawer without squeezing header actions. */
/* Public sections flow without horizontal rules. Only the footer has a divider. */
body.cerebras-theme :is(.section, .bg-surface-bordered, .home-cta-section, .page-hero) {
    border-top: 0 !important;
    border-bottom: 0 !important;
}
body.cerebras-theme header.site-header,
body.cerebras-theme .site-header:has(#admin-user-email) { border-bottom: 0 !important; }
body.cerebras-theme .site-footer {
    border-top: 1px solid var(--line) !important;
    padding: 36px 0 28px !important;
}
body.cerebras-theme .footer-inner {
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center !important;
    gap: 24px 40px !important;
}
body.cerebras-theme .footer-inner > .brand {
    order: 0 !important;
    justify-self: start;
    margin: 0 !important;
}
body.cerebras-theme .footer-nav {
    justify-content: flex-end !important;
    gap: 12px 24px !important;
    min-width: 0;
}
body.cerebras-theme .footer-copy {
    border: 0 !important;
    color: var(--text-muted) !important;
    margin-top: 24px !important;
    padding-top: 0 !important;
    line-height: 1.65;
    text-wrap: pretty;
}
@media (max-width: 768px) {
    body.cerebras-theme .site-footer > .container { width: calc(100% - 40px) !important; }
    body.cerebras-theme .footer-inner { grid-template-columns: minmax(0, 1fr); gap: 22px !important; }
    body.cerebras-theme .footer-nav {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start !important;
        gap: 4px 20px !important;
        width: 100%;
    }
    body.cerebras-theme .footer-link { display: flex; align-items: center; min-height: 28px !important; white-space: normal !important; }
    body.cerebras-theme .footer-copy { font-size: 0.78rem !important; margin-top: 22px !important; }
}
@media (min-width: 993px) {
    body.cerebras-theme .header-inner > .theme-toggle { order: 3; }
}
/* Let tab strips scroll within their account column, not widen the page. */
body.cerebras-theme .account-layout > * { min-width: 0; }
body.cerebras-theme .account-layout .tab-list { max-width: 100%; overflow-x: auto; }
@media (max-width: 992px) {
    body.cerebras-theme .site-header .header-actions { display: none !important; }
}

/* Page hierarchy and descriptive copy. */
html[data-theme="dark"] body.cerebras-theme :is(
    .page-title, .page-hero-title, .section-title, .section-heading,
    .auth-title, .card-title, .team-name, .announcement-title,
    .account-user-name, .notice-title, .admin-page-title, .admin-section-title,
    .admin-action-card-title, .admin-row-title, .admin-stat-value,
    .admin-event-card-mobile-title, .admin-card-title, .admin-name,
    .filter-dialog-heading, .signup-context-note strong, .empty-state-title,
    .about-heading, .content-heading, .registration-title,
    .public-event-title, .detail-value, .learning-point-title
) { color: var(--text-navy) !important; }
html[data-theme="dark"] body.cerebras-theme :is(
    .page-hero-desc, .body-text, .auth-subtitle, .auth-foot, .form-label,
    .form-check-label, .checkbox-label, .filter-field-label,
    .team-bio, .team-desc, .announcement-body, .announcement-content,
    .admin-page-desc, .admin-action-card-desc, .admin-row-desc, .admin-stat-label,
    .admin-event-card-mobile-meta, .admin-card-meta, .account-menu-link,
    .notice-item, .empty-state-desc, .empty-state-text,
    .tab-btn, .my-sessions-tab, .auth-role-tab, .admin-stepper-btn,
    .catalogue-results-meta, .learning-point-item
) { color: var(--text-body) !important; }
html[data-theme="dark"] body.cerebras-theme :is(
    .form-help, .form-hint, .form-description, .account-user-email,
    .team-role, .announcement-date, .announcement-meta, .filter-dialog-sub,
    .signup-context-note span, .application-detail-row > span:first-child,
    .admin-row-meta, .search-icon, .admin-search-icon, .auth-divider,
    .breadcrumb, .breadcrumb a, .breadcrumb-item, .text-light, .auth-footer-copy
) { color: var(--text-muted) !important; }
html[data-theme="dark"] body.cerebras-theme :is(
    .auth-foot a, .forgot-password-link, .admin-action-card-link,
    .team-social-link, .point-check, .password-toggle-btn
) { color: var(--brand-accent) !important; }

/* Cards and panels, including content created after authentication. */
html[data-theme="dark"] body.cerebras-theme :is(
    .auth-card, .account-card, .account-sidebar, .profile-sidebar, .card-bordered,
    .team-card, .announcement-card, .registration-card, .notice-item,
    .session-card, .overview-session-row, .profile-avatar-section,
    .admin-card-section, .admin-stat-card, .admin-row-card, .admin-action-card,
    .admin-event-card-mobile, .admin-card, .admin-table-wrap,
    .org-context-bar, .organizer-empty-panel, .metric-card,
    .public-event-hero, .public-event-section, .public-event-host,
    .organizer-photo-card, .content-notice, .event-team-picker,
    .platform-org-mobile-card, .platform-event-row, .platform-admin-intro,
    .admin-org-panel, .admin-org-panel-header, .admin-org-summary-card,
    .admin-org-panel-section, .admin-access-row,
    .filter-dialog-modal, .modal-card, .modal-content,
    .catalogue-filter-bar, .signup-context-note, .auth-role-tabs, .organization-picker-list
) {
    background: var(--surface) !important;
    border-color: var(--line) !important;
    color: var(--text-body) !important;
    box-shadow: none !important;
}
html[data-theme="dark"] body.cerebras-theme :is(.team-card, .announcement-card, .admin-action-card, .admin-row-card, .platform-org-mobile-card):hover {
    border-color: var(--card-hover-border) !important;
}
html[data-theme="dark"] body.cerebras-theme :is(.admin-main, .admin-layout, .auth-container, .account-layout, .page-hero) { background: #000 !important; }
html[data-theme="dark"] body.cerebras-theme :is(.admin-sidebar, .admin-sticky-actions) { background: #080808 !important; border-color: var(--line) !important; box-shadow: none !important; }
html[data-theme="dark"] body.cerebras-theme :is(
    .admin-sidebar-brand, .admin-section-title, .admin-page-header,
    .auth-foot, .account-user-info, .account-menu, .tab-list,
    .notice-item, .application-detail-row, .filter-dialog-header,
    .filter-dialog-footer, .modal-header, .modal-footer,
    .registration-divider, .content-list-item, .admin-org-panel-section,
    .admin-table th, .admin-table td, .admin-toolbar
) { border-color: var(--line) !important; }
html[data-theme="dark"] body.cerebras-theme :is(.admin-sidebar-brand, .admin-nav-item) { color: var(--text-body) !important; }
html[data-theme="dark"] body.cerebras-theme :is(.admin-nav-item, .account-menu-link):hover {
    background: var(--surface-secondary) !important;
    color: var(--text-navy) !important;
    border-color: var(--control-hover-border) !important;
}
html[data-theme="dark"] body.cerebras-theme :is(.admin-nav-item.active, .account-menu-link.active, .tab-btn.active, .my-sessions-tab.active, .auth-role-tab.active, .admin-stepper-btn.active) {
    background: #291a12 !important;
    border-color: #533724 !important;
    color: var(--brand-accent) !important;
    box-shadow: none !important;
}
html[data-theme="dark"] body.cerebras-theme :is(.admin-nav-item:not(.active), .admin-stepper-btn:not(.active)) { background: var(--surface) !important; border-color: var(--line) !important; }

/* Forms: clear text, subtle idle borders, unmistakable focus and error states. */
html[data-theme="dark"] body.cerebras-theme :is(
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    textarea, select, .form-control, .search-control, .filter-select,
    .filter-select-modal, .catalogue-search-box, .admin-search-box
) {
    background-color: #141414 !important;
    color: var(--text-navy) !important;
    border-color: var(--control-border) !important;
    caret-color: var(--brand-accent);
    color-scheme: dark;
    box-shadow: none !important;
}
html[data-theme="dark"] body.cerebras-theme :is(input, textarea)::placeholder { color: #92929a !important; opacity: 1; }
html[data-theme="dark"] body.cerebras-theme :is(input, textarea, select):focus {
    border-color: var(--brand-accent) !important;
    outline: 2px solid var(--brand-accent) !important;
    outline-offset: 2px !important;
}
html[data-theme="dark"] body.cerebras-theme :is(input, textarea, select):disabled { background: #0c0c0c !important; color: #96969d !important; }
html[data-theme="dark"] body.cerebras-theme :is(input[type="checkbox"], input[type="radio"], input[type="range"]) { accent-color: var(--brand-accent); }
html[data-theme="dark"] body.cerebras-theme input::file-selector-button { background: #252525; color: var(--text-navy); border: 1px solid var(--control-border); border-radius: 4px; }
html[data-theme="dark"] body.cerebras-theme input:autofill { -webkit-text-fill-color: var(--text-navy); box-shadow: 0 0 0 1000px #141414 inset !important; }
html[data-theme="dark"] body.cerebras-theme :is(.form-control.is-invalid, .form-control[aria-invalid="true"], input.has-error) { border-color: var(--color-danger) !important; }

/* Buttons with dedicated workspace rules in the legacy styles. */
html[data-theme="dark"] body.cerebras-theme :is(.site-header, .drawer-actions, .admin-main) :is(.btn-secondary, .btn-navy) {
    background: var(--surface) !important;
    color: var(--text-navy) !important;
    border-color: var(--control-border) !important;
    box-shadow: none !important;
}
html[data-theme="dark"] body.cerebras-theme :is(.site-header, .drawer-actions, .admin-main) :is(.btn-secondary, .btn-navy):hover {
    background: var(--surface-secondary) !important;
    border-color: var(--control-hover-border) !important;
}
html[data-theme="dark"] body.cerebras-theme :is(.icon-button, .admin-org-panel-close, .close-btn, .filter-dialog-close, .announcement-filter-btn) {
    background: var(--surface) !important;
    color: var(--text-body) !important;
    border-color: var(--control-border) !important;
}
html[data-theme="dark"] body.cerebras-theme :is(.announcement-filter-btn.active, .filter-count-badge, .admin-sidebar-badge) { background: var(--brand-accent) !important; color: var(--brand-on-accent) !important; border-color: var(--brand-accent) !important; }
html[data-theme="dark"] body.cerebras-theme .password-toggle-btn { background: transparent !important; border-color: var(--control-border) !important; }
html[data-theme="dark"] body.cerebras-theme .organization-picker-list button { color: var(--text-body); }
html[data-theme="dark"] body.cerebras-theme .organization-picker-list button:is(:hover, [aria-current="true"]) { background: var(--surface-secondary); color: var(--brand-accent); }

/* Tables, editor rows and chart baselines. */
html[data-theme="dark"] body.cerebras-theme :is(.admin-table, .admin-table tbody, .admin-table td) { background: var(--surface) !important; color: var(--text-body) !important; border-color: var(--line) !important; }
html[data-theme="dark"] body.cerebras-theme :is(.admin-table thead, .admin-table th) { background: #1b1b1b !important; color: var(--text-navy) !important; border-color: var(--line) !important; }
html[data-theme="dark"] body.cerebras-theme .admin-table tbody tr:hover td { background: #1b1b1b !important; }
html[data-theme="dark"] body.cerebras-theme :is(.repeater-row, .platform-governance-note, .platform-org-governance, .admin-org-event-item:hover, .admin-upload-zone) { background: var(--surface-2) !important; color: var(--text-body) !important; border-color: var(--line) !important; }
html[data-theme="dark"] body.cerebras-theme :is(.chart-shell, .metric-progress, .event-performance-row, .platform-org-details) { border-color: var(--line) !important; }

/* Semantic feedback retains its meaning in both text and tinted surfaces. */
html[data-theme="dark"] body.cerebras-theme :is(.status-draft, .badge-draft) { color: var(--text-body) !important; background: #232323 !important; }
html[data-theme="dark"] body.cerebras-theme :is(
    .status-published, .status-registration_open, .status-registered, .status-approved,
    .application-status-badge.approved, .profile-complete-banner:not(.warning),
    .registration-state.is-open, .alert-success, .badge-success
) { color: var(--color-success) !important; background: var(--color-success-bg) !important; border-color: #244333 !important; }
html[data-theme="dark"] body.cerebras-theme :is(
    .status-pending, .status-upcoming, .status-waitlisted, .application-status-badge.pending,
    .profile-complete-banner.warning, .alert-warning, .badge-warning
) { color: var(--color-warning) !important; background: var(--color-warning-bg) !important; border-color: #514124 !important; }
html[data-theme="dark"] body.cerebras-theme :is(
    .status-registration_closed, .status-cancelled, .status-rejected,
    .application-status-badge.rejected, .form-error-summary, .alert-danger,
    .platform-admin-alert-error, .registration-state.is-closed, .badge-danger
) { color: var(--color-danger) !important; background: var(--color-danger-bg) !important; border-color: #573030 !important; }
html[data-theme="dark"] body.cerebras-theme :is(.status-ongoing, .alert-info, .badge-info, .platform-admin-alert:not(.platform-admin-alert-error)) { color: var(--color-info) !important; background: var(--color-info-bg) !important; border-color: #2c3c55 !important; }
html[data-theme="dark"] body.cerebras-theme :is(.status-completed, .status-attended) { color: #c6a7f5 !important; background: #241934 !important; border-color: #41304f !important; }
html[data-theme="dark"] body.cerebras-theme :is(.text-danger, .form-error, .field-error, .required, .content-status[role="alert"]) { color: var(--color-danger) !important; }
html[data-theme="dark"] body.cerebras-theme :is(.btn-danger, .logout-menu-btn, .account-menu button.account-menu-link) { color: var(--color-danger) !important; background: #301617 !important; border-color: #573030 !important; }
html[data-theme="dark"] body.cerebras-theme :is(.btn-danger, .logout-menu-btn):hover { background: #431e20 !important; }
html[data-theme="dark"] body.cerebras-theme .profile-complete-banner :is(strong, .text-xs, .banner-icon) { color: inherit !important; }
html[data-theme="dark"] body.cerebras-theme :is(.event-team-avatar, .platform-org-logo-fallback, .account-user-avatar) { background: #291a12 !important; color: var(--brand-accent) !important; }
html[data-theme="dark"] body.cerebras-theme .icon-button { color: var(--color-danger) !important; }
html[data-theme="dark"] body.cerebras-theme .platform-org-mark { background: #291a12 !important; color: var(--brand-accent) !important; }
html[data-theme="dark"] body.cerebras-theme :is(.photo-preview-item, .event-hero-banner) { background: var(--surface-2) !important; border-color: var(--line) !important; }
html[data-theme="dark"] body.cerebras-theme :is(.view-full-album-btn, .btn-login-pill) { background: var(--surface) !important; color: var(--text-navy) !important; border-color: var(--control-border) !important; }
html[data-theme="dark"] body.cerebras-theme :is(.view-full-album-btn, .btn-login-pill):hover { background: var(--surface-secondary) !important; border-color: var(--control-hover-border) !important; }
html[data-theme="dark"] body.cerebras-theme :is(.btn.btn-disabled-state, .btn[disabled], button[disabled]) { background: #151515 !important; color: #96969d !important; border-color: var(--line) !important; box-shadow: none !important; }
html[data-theme="dark"] body.cerebras-theme .site-header:has(#admin-user-email) { background: #000 !important; border-color: var(--line) !important; }

/* Muted image placeholders and loading states avoid white flashes. */
html[data-theme="dark"] body.cerebras-theme :is(.team-photo, .team-avatar, .profile-avatar-preview-wrap, .account-user-avatar, .photo-item, .public-event-host-fallback) { background-color: var(--surface-2) !important; border-color: var(--line) !important; color: var(--brand-accent) !important; }
html[data-theme="dark"] body.cerebras-theme .skeleton { background: linear-gradient(90deg, #151515, #252525, #151515) !important; background-size: 200% 100% !important; }
html[data-theme="dark"] body.cerebras-theme :is(.auth-divider::before, .auth-divider::after) { background: var(--line) !important; }

@media (prefers-reduced-motion: reduce) {
    body.cerebras-theme :is(.theme-toggle, .mobile-drawer, .site-header) { transition: none !important; }
}
