/* Official LEGENDA dashboard dark theme: Obsidian.
   Load last on Campus and admin, after shared controls and component styles.
   Light mode, brand artwork and hero backgrounds remain unchanged.
   Forced-color users retain the existing system-color treatment. */

@media (forced-colors:none) {
  html[data-theme="dark"] {
    --ui-canvas:#08090b;
    --ui-surface:#111216;
    --ui-surface-raised:#181a1f;
    --ui-surface-floating:#202229;
    --ui-surface-floating-hover:#2a2d35;
    --ui-surface-hover:#202229;
    --ui-surface-muted:#15171b;
    --ui-input:#0d0f12;
    --ui-border:#343740;
    --ui-border-strong:#535966;
    --ui-text:#f4f5f7;
    --ui-text-secondary:#b8bbc5;
    --ui-text-muted:#9297a5;
    --dashboard-dark-accent:#cf35ff;
    --dashboard-dark-accent-soft:#27122f;
    --dashboard-dark-accent-hover:#2b1233;
    --ui-focus:#cf35ff99;
    --dashboard-dark-light-before:radial-gradient(ellipse 64% 52% at 50% 10%,rgb(255 255 255 / .022),transparent 75%);
    --dashboard-dark-light-after:none;
    --dashboard-dark-depth-soft:none;
    --dashboard-dark-depth-raised:none;
    --ui-accent:var(--dashboard-dark-accent);
    --ui-accent-soft:var(--dashboard-dark-accent-soft);
    --ui-accent-hover:var(--dashboard-dark-accent-hover);
    --campus-accent:var(--ui-accent);
    --bg:var(--ui-canvas);
    --ink:var(--ui-text);
    --muted:var(--ui-text-muted);
    --line:var(--ui-border);
    --scrollbar-thumb:var(--ui-border);
    --scrollbar-thumb-hover:var(--ui-border-strong);
    --scrollbar-arrow-hover:var(--ui-text-muted);
    --ui-button-secondary:var(--ui-accent-soft);
    --ui-button-secondary-hover:var(--ui-accent-hover);
    --ui-button-on-secondary:var(--ui-accent);
    /* Primary actions retain their canonical #be00fd background and white text. */
    background:var(--ui-canvas);
    color:var(--ui-text);
  }

  /* The coaching hero owns local accent tokens. Override only those tokens,
     leaving its artwork and white body text intact. Opaque secondary surfaces
     ensure 4.62:1 text contrast, or 4.53:1 on hover, regardless of the hero glow. */
  html[data-theme="dark"] #campus-app .coaching-view .coaching-session-panel {
    --ui-accent:var(--dashboard-dark-accent);
    --ui-accent-soft:var(--dashboard-dark-accent-soft);
    --ui-accent-hover:var(--dashboard-dark-accent-hover);
    --campus-accent:var(--dashboard-dark-accent);
  }

  /* Dark elevation uses surface tones instead of decorative shadows. */
  html[data-theme="dark"] :is(#campus-app,#campus-dialog,#app,#dialog-root) {
    --surface-depth-soft:var(--dashboard-dark-depth-soft);
    --surface-depth-raised:var(--dashboard-dark-depth-raised);
  }

  /* This plane paints inline shadows independently of the cards themselves. */
  html[data-theme="dark"] .surface-depth-plane { display:none; }

  html[data-theme="dark"] :is(#campus-app,#campus-dialog,#app,#dialog-root) :is(
    .campus-card,.campus-auth-card,.course-content-card,.course-video-preview,
    .course-detail-outline,.campus-sidebar,.campus-navigation,
    .campus-home-thumbnail,.campus-home-thumbnail-play,.coaching-coach-avatar,
    .auth-card,.analytics-metric,.analytics-panel,.split-panel,.brand-section,
    .brand-color-card,.support-admin-inbox,.support-admin-thread,.coaching-panel,
    .workspace>.sidebar,.sidebar>nav,.task-card,.board-panel,.dialog,.campus-dialog
  ),
  html[data-theme="dark"] :is(.admin-mobile-navigation,.support-chat-panel,.support-chat-notification),
  html[data-theme="dark"] .support-chat-launcher .support-chat-avatar,
  html[data-theme="dark"] .dashboard-theme-toggle :is(.dashboard-theme-track,.dashboard-theme-thumb) {
    box-shadow:none;
  }

  /* Preserve inset keyboard rings on split controls and calendar choices. */
  html[data-theme="dark"] :is(#campus-app,#campus-dialog,#app,#dialog-root) :is(.campus-button,.button),
  html[data-theme="dark"] :is(.split-button,.calendar-apply,.calendar-day.is-selected):not(:focus-visible) {
    box-shadow:none;
  }

  html[data-theme="dark"] #app .split-page .button:focus-visible {
    box-shadow:inset 0 0 0 2px var(--ui-accent);
  }

  /* Non-modal overlays sit one tone above raised cards. Modals keep their
     existing surface and blurred backdrop; focus/selection rings are untouched. */
  html[data-theme="dark"] :is(#campus-app,#campus-dialog,#app,#dialog-root) :is(
    .single-options,.assignee-options,.tag-dropdown,.tag-options,
    .split-picker-options,.analytics-period-custom.reporting-custom-panel
  ),
  html[data-theme="dark"] :is(.calendar-picker,.toast-item,.support-chat-panel,.support-chat-notification),
  html[data-theme="dark"] #campus-toast {
    --ui-surface-hover:var(--ui-surface-floating-hover);
    background:var(--ui-surface-floating);
    box-shadow:none;
  }

  /* Small pink links need a little more light on the floating surface. */
  html[data-theme="dark"] :is(.support-chat-text-button,.support-chat-notification-cta) {
    color:color-mix(in srgb,var(--ui-accent) 92%,white);
  }

  html[data-theme="dark"] .support-chat-header {
    background:var(--ui-surface-floating);
  }

  html[data-theme="dark"] .support-chat-panel .support-chat-avatar img,
  html[data-theme="dark"] .coaching-coach-avatar-inner {
    border-color:var(--ui-canvas);
  }

  /* Remove only structural hairlines. Keep field and menu boundaries, choices,
     drop targets and keyboard outlines. Explicit app IDs beat component rules
     without important declarations; transparent borders preserve dimensions. */
  html[data-theme="dark"] #campus-app :is(.campus-sidebar,.campus-card,.campus-auth-card,.course-content-card,.course-detail-outline),
  html[data-theme="dark"] #campus-dialog .campus-dialog,
  html[data-theme="dark"] #app :is(.workspace > .sidebar,.auth-card,.analytics-metric,.analytics-panel,.split-panel,.brand-section,.brand-asset-card,.support-admin-inbox,.support-admin-thread,.coaching-panel),
  html[data-theme="dark"] #app .workspace-planning .column:not(.is-drop-target),
  html[data-theme="dark"] #app .workspace-planning .task-card:not(.is-dragging):not(.is-drag-source):not(.task-drag-image),
  html[data-theme="dark"] #dialog-root .dialog,
  html[data-theme="dark"] .support-chat-panel {
    border-color:transparent;
  }

  /* Supporting panels stay neutral. Selected navigation, tabs and secondary
     actions retain their pink accent through the shared semantic tokens. */
  html[data-theme="dark"] #campus-app .coaching-view .coaching-prep-panel {
    background:linear-gradient(120deg,var(--ui-surface),var(--ui-surface-muted));
  }

  html[data-theme="dark"] #app .live-analytics {
    background:var(--ui-surface);
  }

  /* A quiet neutral light source replaces the colored wash and grain. Only the
     decorative ambient layer changes; no content or artwork is filtered. */
  html[data-theme="dark"] .dashboard-atmosphere {
    opacity:1;
    background-color:var(--ui-canvas);
    background-image:none;
  }

  html[data-theme="dark"] .dashboard-atmosphere::before,
  html[data-theme="dark"] .dashboard-atmosphere::after {
    animation:none;
    transform:none;
    will-change:auto;
  }

  html[data-theme="dark"] .dashboard-atmosphere::before {
    background:var(--dashboard-dark-light-before);
  }

  html[data-theme="dark"] .dashboard-atmosphere::after {
    background:var(--dashboard-dark-light-after);
  }
}
