/**
 * EKM Safe Dark — reversible readability override (stabilization only).
 * Active when html has class ekm-safe-dark (toggle: EKM_SAFE_DARK_OVERRIDE in index.html).
 * Forces known-good dark baseline tokens; does not replace appearance engine.
 */

html.ekm-safe-dark {
  color-scheme: dark;

  /* Page + semantic surfaces (dark_glow baseline) */
  --c-bg: #1a1a18 !important;
  --c-box: #2a2a27 !important;
  --c-box-border: #38362f !important;
  --c-rule: #36352f !important;

  /* Text */
  --c-ink: #ece9e3 !important;
  --c-ink2: #b8b3a8 !important;
  --c-muted: #a39c8f !important;
  --c-muted2: #8a857c !important;
  --c-label: #b8b3a8 !important;

  /* Aliases used across dashboard */
  --surface: #2a2a27 !important;
  --surface2: #2a2a27 !important;
  --surface3: #36352f !important;
  --text: #ece9e3 !important;
  --muted: #a39c8f !important;
  --border: #38362f !important;
  --dark: #ece9e3 !important;

  /* Home / dashboard tokens */
  --hp-bg: #1a1a18 !important;
  --hp-card: #2a2a27 !important;
  --hp-cardborder: #38362f !important;
  --hp-head: #ece9e3 !important;
  --hp-muted: #b8b3a8 !important;
  --hp-muted2: #8a857c !important;
  --hp-muted3: #b8b3a8 !important;

  /* Elevated / queue surfaces */
  --pq-surface: #2a2a27 !important;
  --pq-surface-muted: #36352f !important;
  --pq-surface-border: #38362f !important;
  --pq-surface-text: #ece9e3 !important;

  /* Theme glass fallbacks → solid readable surfaces */
  --modern-surface-glass: #2a2a27 !important;
  --modern-surface-soft: #36352f !important;
  --modern-border-tint: #38362f !important;
  --modern-border-tint-soft: #38362f !important;
  --knicks-surface-glass: #2a2a27 !important;
  --knicks-border-tint: #38362f !important;
  --knicks-border-soft: #38362f !important;
  --nyc-surface-glass: #2a2a27 !important;
  --nyc-border-tint: #38362f !important;
  --nyc-border-soft: #38362f !important;
}

html.ekm-safe-dark body,
html.ekm-safe-dark body.hp-active {
  background: var(--c-bg) !important;
  color: var(--c-ink) !important;
}

/* Header / nav */
html.ekm-safe-dark .hp-topnav,
html.ekm-safe-dark .hp-nav-rail {
  background: var(--c-bg) !important;
  border-color: var(--c-rule) !important;
  color: var(--c-ink) !important;
}

html.ekm-safe-dark .hp-navitem,
html.ekm-safe-dark .tab-btn,
html.ekm-safe-dark .hp-nav-rail-item {
  color: var(--c-muted) !important;
}

html.ekm-safe-dark .hp-navitem:hover,
html.ekm-safe-dark .tab-btn:hover,
html.ekm-safe-dark .hp-nav-rail-item:hover {
  color: var(--c-ink) !important;
}

html.ekm-safe-dark .hp-navitem.active,
html.ekm-safe-dark .tab-btn.active,
html.ekm-safe-dark .hp-nav-rail-item.active {
  color: var(--c-ink) !important;
}

html.ekm-safe-dark .hp-navdiv {
  background: var(--c-rule) !important;
}

/* Dashboard card surfaces */
html.ekm-safe-dark body.hp-active .hp-wrap .hp-softbox,
html.ekm-safe-dark body.hp-active .hp-wrap .hp-card,
html.ekm-safe-dark body.hp-active .hp-wrap .hp-attention,
html.ekm-safe-dark body.hp-active .hp-wrap .hp-wf-preview-card,
html.ekm-safe-dark body.hp-active .hp-wrap #home-announcements-zone .hp-softbox,
html.ekm-safe-dark body.hp-active .hp-wrap #home-announcements-zone .hp-card,
html.ekm-safe-dark body.hp-active .hp-wrap .home-dash-modules .os-kpi,
html.ekm-safe-dark body.hp-active .hp-wrap #home-action-box,
html.ekm-safe-dark .hp-awareness-row .hp-flank-panel,
html.ekm-safe-dark .card,
html.ekm-safe-dark .pds-card,
html.ekm-safe-dark .os-collapsible,
html.ekm-safe-dark .wf-lane,
html.ekm-safe-dark .wf-bottleneck,
html.ekm-safe-dark .wf-dash-banner,
html.ekm-safe-dark .notif-panel {
  background: var(--c-box) !important;
  border-color: var(--c-box-border) !important;
  color: var(--c-ink) !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* Inbox + Updates flank text */
html.ekm-safe-dark .hp-awareness-row .hp-flank-label,
html.ekm-safe-dark .hp-flank-label {
  color: var(--c-muted) !important;
}

html.ekm-safe-dark .hp-awareness-row .hp-flank-title,
html.ekm-safe-dark .hp-awareness-row .hp-updates-summary .hp-flank-title,
html.ekm-safe-dark .hp-awareness-row .hp-inbox-summary .hp-flank-title,
html.ekm-safe-dark .hp-flank-title {
  color: var(--c-ink2) !important;
}

html.ekm-safe-dark .hp-awareness-row .hp-flank-meta,
html.ekm-safe-dark .hp-awareness-row .hp-updates-summary .hp-flank-meta,
html.ekm-safe-dark .hp-awareness-row .hp-inbox-summary .hp-flank-meta,
html.ekm-safe-dark .hp-flank-meta {
  color: var(--c-muted2) !important;
}

html.ekm-safe-dark .hp-awareness-row .hp-flank-empty,
html.ekm-safe-dark .hp-flank-empty {
  color: var(--c-muted) !important;
}

html.ekm-safe-dark .hp-flank-link {
  color: var(--c-ink2) !important;
}

/* Needs Your Attention */
html.ekm-safe-dark .hp-attention .hp-seclabel,
html.ekm-safe-dark .hp-attention .os-section-head,
html.ekm-safe-dark .hp-attention .hp-wf-pill {
  color: var(--c-ink2) !important;
  background: var(--c-bg) !important;
  border-color: var(--c-box-border) !important;
}

html.ekm-safe-dark .hp-attention .hp-wf-pill strong {
  color: var(--c-ink) !important;
}

html.ekm-safe-dark .hp-attention .hp-att-ack {
  color: var(--c-muted) !important;
  border-color: var(--c-box-border) !important;
}

/* Workflow Today preview + page */
html.ekm-safe-dark .hp-wf-preview-card .hp-seclabel,
html.ekm-safe-dark .hp-wf-preview-card .hp-wf-preview-title,
html.ekm-safe-dark .wf-lane-head,
html.ekm-safe-dark .wf-day-prov-head,
html.ekm-safe-dark .wf-subtitle {
  color: var(--c-ink) !important;
}

html.ekm-safe-dark .hp-wf-preview-card .hp-wf-preview-meta,
html.ekm-safe-dark .hp-wf-preview-card .hp-wf-preview-empty,
html.ekm-safe-dark #home-wf-preview-body,
html.ekm-safe-dark .wf-empty-hint,
html.ekm-safe-dark .wf-day-cat-head {
  color: var(--c-ink2) !important;
}

html.ekm-safe-dark .hp-wf-preview-card .hp-wf-preview-time {
  color: var(--c-muted) !important;
}

/* Announcements */
html.ekm-safe-dark .hp-announce-title,
html.ekm-safe-dark .os-dash-title,
html.ekm-safe-dark .os-kpi-val,
html.ekm-safe-dark .card-header h3,
html.ekm-safe-dark .pds-page-title {
  color: var(--c-ink) !important;
}

html.ekm-safe-dark .hp-announce-body,
html.ekm-safe-dark .card-body,
html.ekm-safe-dark .pds-card-body,
html.ekm-safe-dark .os-kpi-sub {
  color: var(--c-ink2) !important;
}

html.ekm-safe-dark .hp-announce-date,
html.ekm-safe-dark .hp-seclabel,
html.ekm-safe-dark .os-section-head,
html.ekm-safe-dark .os-kpi-lbl,
html.ekm-safe-dark .pds-section-title,
html.ekm-safe-dark .pds-label {
  color: var(--c-label) !important;
}

/* Inbox drawer / notifications */
html.ekm-safe-dark .notif-header h3,
html.ekm-safe-dark .notif-item,
html.ekm-safe-dark .notif-item .notif-msg {
  color: var(--c-ink) !important;
}

html.ekm-safe-dark .notif-item.unread {
  background: var(--c-box) !important;
}

html.ekm-safe-dark .notif-btn {
  color: var(--c-muted) !important;
  border-color: var(--c-box-border) !important;
}

/* KPI / section headers on home */
html.ekm-safe-dark body.hp-active .hp-wrap .home-dash-modules .os-kpi-val,
html.ekm-safe-dark body.hp-active .hp-wrap .home-dash-modules .os-kpi-lbl {
  color: var(--c-ink) !important;
}

html.ekm-safe-dark body.hp-active .hp-wrap .home-dash-modules .os-kpi-sub {
  color: var(--c-ink2) !important;
}
