/* Shared readability scale. Load after each app's existing visual theme. */
body:is(.dashboard-page, [data-ui-upgrade]) {
  --edx-type-body: 0.9375rem;
  --edx-type-ui: 0.875rem;
  --edx-type-label: 0.8125rem;
  --edx-type-chart: 0.75rem;
  font-size: var(--edx-type-body);
  line-height: 1.5;
}

/* Explicit utilities also occur in portals, drawers and mobile navigation. */
body:is(.dashboard-page, [data-ui-upgrade]) :is(
  .text-xs, [class~="text-[8px]"], [class~="text-[9px]"],
  [class~="text-[10px]"], [class~="!text-[10px]"], [class~="text-[10.5px]"],
  [class~="text-[11px]"], [class~="text-[12px]"], [class~="md:text-xs"],
  small, .eyebrow, .crumb, .card-subtitle, .chart-caption, .chart-note,
  .edx-caption, .edx-metric-change, .edx-count, .edx-pagination, .edx-log-hash,
  .edx-log-trigger time, .edx-data-table time, .edx-log-detail dt,
  .edx-notification-body time, .edx-command-result small, [cmdk-group-heading],
  .rel-count, .rel-kind, .rel-explorer footer, .rel-node small,
  .pill, .pill-sm, .pill-dense, .pill-caps, .edx-status, .tab-count,
  .truth, .truth-chip, .truth-detail, .workspace-footer, .workspace-chip small,
  .pipeline-sub, .pipeline-foot, .chart-card-footer, .chart-legend,
  .table-tools, .filter-chip-count, .palette-item-meta, .palette-footer,
  .palette-more, .app-switcher-app, .app-switcher-footer,
  .ticker-label, .ticker-value, .ticker-line, .phase-name, .legend-item,
  .network-context, .network-feed-status, .network-source, .network-window,
  .chip-count, .seg-count, .timeline-day, .ov-kicker, .ov-eyebrow,
  .local-pill, .zone-current, .mesh-legend-rows, .bottom-tab
) {
  font-size: var(--edx-type-label) !important;
  line-height: 1.5 !important;
  letter-spacing: 0;
}

body:is(.dashboard-page, [data-ui-upgrade]) :is(
  [class~="text-[13px]"], p, label, summary, input, select, textarea,
  button, [role="button"], [role="tab"], [role="menuitem"],
  .nav-link, .hash-link, .hash-text, .hash-display, .entity-link,
  .edx-id-link, .edx-record-link, .edx-data-table, .edx-table, .rel-list,
  .rel-open, .rel-inspector strong, .rel-node strong, .edx-log-trigger strong,
  .edx-log-detail dd, .edx-field, .edx-metric-head, .edx-chart-legend,
  .edx-chart-tooltip, .chart-tooltip-mini, .edx-tooltip, .edx-reading, .reading,
  .palette-item-title, .kv dt, .kv dd, .sheet-body, .empty, .rel-empty
) {
  font-size: var(--edx-type-ui) !important;
  line-height: 1.5 !important;
}

body:is(.dashboard-page, [data-ui-upgrade]) :is(.answer, .page-heading > p) {
  font-size: var(--edx-type-body) !important;
  line-height: 1.55 !important;
}

body:is(.dashboard-page, [data-ui-upgrade]) :is(table td, .edx-table .hash, .edx-numeric) {
  font-size: var(--edx-type-ui) !important;
  line-height: 1.5 !important;
}
body:is(.dashboard-page, [data-ui-upgrade]) :is(table th, table th button) {
  font-size: var(--edx-type-label) !important;
  line-height: 1.5 !important;
}
body:is(.dashboard-page, [data-ui-upgrade]) :is(.pill, .edx-status, .tab-count, .truth-chip) {
  height: auto;
  min-height: 22px;
}
body:is(.dashboard-page, [data-ui-upgrade]) :is(.pill-caps, .pill-dense) {
  padding-block: 2px;
}

/* Chart labels retain a compact, distinct scale; the data tables remain larger. */
body:is(.dashboard-page, [data-ui-upgrade]) :is(
  svg text, svg tspan, .recharts-cartesian-axis-tick-value,
  .edx-river__index, .edx-river__tick, .edx-river__ford-label,
  .direct-label, .edx-direct-label, .matrix-head,
  .gantt-tick, .gantt-now-chip, .hz-now-chip, .mesh-node-label,
  .mesh-caption, .mesh-highlight-note, .dot-plot-axis, .dot-plot-ref-label,
  .ledger-head-label, .ledger-major, svg foreignObject > div,
  .react-flow__attribution, .react-flow__attribution a, .stepper-label, kbd, .kbd
) {
  font-size: var(--edx-type-chart) !important;
  line-height: 1.5 !important;
  letter-spacing: 0;
}
body:is(.dashboard-page, [data-ui-upgrade]) .edx-donut-value {
  font-size: 24px !important;
}
body:is(.dashboard-page, [data-ui-upgrade]) .hz-now-chip {
  transform: translateX(-100%);
}
body:is(.dashboard-page, [data-ui-upgrade]) :is(.gantt-ref, .gantt-value-col, .mesh-node-id) {
  font-size: var(--edx-type-label) !important;
  line-height: 1.5 !important;
}
body:is(.dashboard-page, [data-ui-upgrade]) .react-flow__attribution a {
  color: #586c7e;
}

/* Placeholder-like search buttons are active controls, not disabled content. */
body:is(.dashboard-page, [data-ui-upgrade]) :is(.search-trigger, .text-ink-4, .palette-input::placeholder),
body:is(.dashboard-page, [data-ui-upgrade]) input::placeholder {
  color: #586c7e !important;
  opacity: 1;
}
body:is(.dashboard-page, [data-ui-upgrade]) .rel-kind { color: #17533f; }
body:is(.dashboard-page, [data-ui-upgrade]) :is(.seg-count, .crumb-stage.is-dim) {
  color: #586c7e;
}

body:is(.dashboard-page, [data-ui-upgrade]) .edx-record-code pre {
  font-size: var(--edx-type-ui) !important;
  line-height: 1.65 !important;
}
body:is(.dashboard-page, [data-ui-upgrade]) .edx-record-code code { font: inherit; }
body:is(.dashboard-page, [data-ui-upgrade]) .edx-record-code figcaption {
  font-size: var(--edx-type-label) !important;
  line-height: 1.5;
}

/* Keep text containers flexible when labels wrap or users enlarge text. */
body:is(.dashboard-page, [data-ui-upgrade]) :is(
  .rel-header, .rel-inspector, .edx-section-head, .edx-pagination, .table-tools,
  .edx-notification-footer, .chart-card-footer, .palette-footer, .workspace-footer
) { flex-wrap: wrap; }
body:is(.dashboard-page, [data-ui-upgrade]) :is(.rel-node strong, .rel-node small) {
  flex-shrink: 0;
}
body:is(.dashboard-page, [data-ui-upgrade]) :is(p, .card-subtitle, .pipeline-sub, .empty) {
  overflow-wrap: anywhere;
}
body.dashboard-page .edx-metric-change { min-height: 39px; }
body.dashboard-page #header.site-header .brand .original-brand-logo {
  width: 44px;
  height: 44px;
  max-height: 44px;
}
body.dashboard-page .workspace-chip { height: auto !important; min-height: 52px; padding-block: 6px !important; }
body.dashboard-page .workspace-chip strong { font-size: 14px; line-height: 1.5; }
body.dashboard-page .workspace-chip > span { min-width: 0; }
body.dashboard-page .workspace-chip small { white-space: normal; overflow-wrap: anywhere; }
body.dashboard-page .edx-log-trigger {
  grid-template-columns: 18px minmax(0, 1fr) auto;
  grid-template-areas: "toggle operation status" "toggle time status" "toggle hash status";
  gap: 4px 12px;
  padding-block: 12px;
}
body.dashboard-page .edx-log-trigger > svg { grid-area: toggle; width: 16px; height: 16px; }
body.dashboard-page .edx-log-trigger > strong { grid-area: operation; min-width: 0; overflow-wrap: anywhere; }
body.dashboard-page .edx-log-trigger > time { grid-area: time; min-width: 0; }
body.dashboard-page .edx-log-trigger > .edx-status { grid-area: status; }
body.dashboard-page .edx-log-trigger > .edx-log-hash { grid-area: hash; display: block; min-width: 0; overflow-wrap: anywhere; }
@media (min-width: 1280px) {
  body.dashboard-page .edx-log-trigger {
    grid-template-columns: 18px 160px minmax(180px, 1fr) minmax(150px, 180px) auto;
    grid-template-areas: "toggle time operation hash status";
    gap: 12px;
  }
}
@media (max-width: 600px) {
  body.dashboard-page .site-header { padding-inline: 12px; gap: 6px; }
  body.dashboard-page #header.site-header .brand { width: 44px; min-width: 44px; height: 44px; }
  body.dashboard-page .site-header .header-actions { gap: 6px; }
  body.dashboard-page .site-header .header-actions .button { padding-inline: 8px; font-size: 11px; }
  body.dashboard-page .site-header .header-actions .button svg { display: none; }
}

@media (max-width: 767px), (max-height: 480px) and (max-width: 1023px) {
  body:is(.dashboard-page, [data-ui-upgrade]):is(.dashboard-page, [data-ui-upgrade]) :is(input, select, textarea, [cmdk-input]) {
    font-size: 16px !important;
    line-height: 1.5 !important;
  }
  body:is(.dashboard-page, [data-ui-upgrade]) :is(.rel-search, .rel-toolbar select) {
    height: 44px;
    min-height: 44px;
  }
  body:is(.dashboard-page, [data-ui-upgrade]) :is(.card-subtitle, .pipeline-sub) {
    height: auto;
  }
}

/* Phone touch areas retain the existing glyphs and data presentation. */
@media (max-width: 767px), (max-height: 480px) and (max-width: 1023px) {
  body.dashboard-page .edx-skyline [aria-label="Chart view"] > button {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }
  body.dashboard-page .edx-skyline [aria-label="Chart view"] > span[aria-hidden] { width: 44px; }
  body.dashboard-page .edx-skyline div:has(> button[aria-label^="Highlight "]) { gap: 0; }
  body.dashboard-page .edx-skyline button[aria-label^="Highlight "] {
    box-sizing: border-box;
    width: 40px;
    min-width: 40px;
    height: 44px;
    padding: 16.5px 14.5px;
    background-clip: content-box !important;
    transform: none;
    flex: none;
  }
  body.dashboard-page .edx-skyline button[aria-label^="Highlight "][aria-pressed="true"] {
    outline-style: solid;
    outline-width: 2px;
    outline-offset: -2px;
  }
  body.dashboard-page .edx-skyline .flex-1:empty { display: none; }
  body.dashboard-page .edx-skyline .truncate {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  body.dashboard-page .edx-data-table th button {
    min-width: 44px;
    min-height: 44px;
    margin-block: -10px;
  }
  body.dashboard-page .edx-data-table td .edx-record-link {
    min-height: 44px;
    margin-block: -8px;
  }
  body.dashboard-page .edx-log-detail .edx-record-link { min-height: 44px; }
  body.dashboard-page .edx-chart-details > summary {
    min-height: 44px;
    padding-block: 11px;
  }
  body.dashboard-page .enerdex-dashboard .platform-table .sort-button {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-block: -11.5px;
  }
  body.dashboard-page .enerdex-dashboard .platform-table :is(.expand-button, .copy-button),
  body.dashboard-page .enerdex-dashboard .hash-chip > .copy-button,
  body.dashboard-page .drawer .copy-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }
  body.dashboard-page .edx-code-caption { min-height: 44px; }
  body.dashboard-page .edx-code-actions > button { width: 44px; min-width: 44px; height: 44px; }
}
@media (max-width: 360px) {
  body.dashboard-page .enerdex-dashboard .console-bar .workspace-chip-host { flex: 1 1 0; }
  body.dashboard-page .enerdex-dashboard .console-bar .workspace-chip { max-width: 100%; }
  body.dashboard-page .enerdex-dashboard .console-bar .workspace-chip small { text-wrap: balance; }
  body.dashboard-page .enerdex-dashboard .console-bar .topbar { flex: 0 0 100%; }
}
