/* Reuse the Selected Work segmented control for interactive case-study views. */
body.console-page--case #console-content :is(
  [role="tablist"], .ww8-demo-tabs, .kfx-lab-tabs, .kfw-layout-switch,
  .wa-case-wireframe-controls, .wi-case-wireframe-controls, .kfi-case-wireframe-controls,
  .uxa-compare-actions, .ww30-compare-ends, .gcb-stages
):has(> button):not([hidden]) {
  box-sizing: border-box;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: flex-start;
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  gap: 4px !important;
  padding: 4px !important;
  border: 1px solid #d6dfe9 !important;
  border-radius: 12px !important;
  background: #f5f7fa !important;
  box-shadow: 0 2px 6px #20355a12 !important;

  > button {
    box-sizing: border-box;
    flex: 0 1 auto;
    width: auto;
    min-width: 0;
    max-width: 100%;
    min-height: 44px;
    height: auto;
    margin: 0 !important;
    padding: 9px 14px !important;
    border: 1px solid transparent !important;
    border-radius: 8px !important;
    background: transparent !important;
    color: #455a79 !important;
    box-shadow: none !important;
    text-decoration: none !important;
    white-space: normal;
    overflow-wrap: anywhere;
    cursor: pointer;
  }

  > button:is([aria-selected="true"], [aria-pressed="true"]) {
    border-color: #d6dfe9 !important;
    background: #fff !important;
    color: #20355a !important;
    box-shadow: 0 2px 5px #20355a18 !important;
  }

  > button:focus-visible {
    outline: 2px solid #087f7b !important;
    outline-offset: 1px;
  }

  @media (hover: hover) {
    > button:not([aria-selected="true"], [aria-pressed="true"]):hover {
      background: #e7edf3 !important;
      color: #20355a !important;
    }
  }
}

/* Leave the mobile-only planner switch under its original visibility rules. */
body.console-page--case #console-content :is(
  [role="tablist"]:not(.uwp-mobile-views, .uwp-dialog-views), .ww8-demo-tabs,
  .kfx-lab-tabs, .kfw-layout-switch, .wa-case-wireframe-controls,
  .wi-case-wireframe-controls, .kfi-case-wireframe-controls,
  .uxa-compare-actions, .ww30-compare-ends, .gcb-stages
):has(> button):not([hidden]) {
  display: flex;
}

/* Text lists wrap naturally, independent of the linked card diagrams. */
#console-content :is(.wa-voices__outputs, .wi-voices__outputs, .ktd-voices__outputs, .kfi-voices__outputs) {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin-block: 16px;
  padding: 0 !important;
  border: 0 !important;
}

/* Chapter prompts retain their live status region for completed interactions. */
#console-content .guided-task:has(.task-state:empty) {
  min-height: 0 !important;
  padding-block: 0 !important;
}
#console-content .guided-task-main:has(.task-state:empty) {
  min-height: 0;
  padding-block: clamp(16px, 2vw, 20px) !important;
}
#console-content .guided-task-main:has(.task-state:empty) > p {
  margin-block-end: 0 !important;
}
#console-content .guided-task-main > .task-state:empty {
  display: none !important;
}

#console-content .kfh-state-explainer {
  display: grid;
  gap: 16px;
}
#console-content .kfh-state-explainer > h3,
#console-content .kfh-state-explainer > div > h4 {
  margin-block: 0 !important;
}
#console-content .kfh-state-explainer > div > p {
  margin-block: 6px 0 !important;
}
#console-content .kfh-state-explainer + div {
  margin-block-start: 20px;
}

/* External space between narrative copy and a card, control or divider. */
#console-content :is(
  .kfd-intro + .kfd-comparison, .ktd-case-overview + .ktdf-origin,
  .wa-case-section-head > h2 + .case-copy-v2,
  .wi-before-heatmaps__story + .wi-before-heatmaps__capture,
  .kfi-original-captures > p + .kfi-source-links, .uwp-pane-label + .ww24-phone-shell,
  .gcf-heading + .gcf-steps, .gcb-system-heading + .gcb-pipeline,
  .gbt-flow-panel > dl + button, .kfp-status + figcaption
) {
  margin-block-start: clamp(16px, 2vw, 24px) !important;
}
body.console-page--case #console-content .kfi-case-disclosure__content > .kfi-report-support + p.protected-case-story-copy {
  margin-top: 16px !important;
}
@media (max-width: 760px) {
  #selected-work .section-heading + .uxa-project-deck {
    margin-block-start: 16px;
  }
}
#console-content :is(
  .ktd-case-section-head > h2 + .ktd-case-lead,
  .ktd-case-section-head > .ktd-case-lead + .ktd-case-lead
) {
  margin-block-start: 16px !important;
}
#console-content :is(
  .gbt-flow-heading, .gbt-flow-panel, .gbt-journey-track > li, .wpg-track-question,
  .wi-case-journey-step, .wi-case-pipeline-step, .ktd-case-journey-step, .kfi-case-journey-step,
  .resume-project
) > :is(h3,h4) + p {
  margin-block-start: 10px !important;
}
#console-content :is(.gbt-project-frame-note + a, .wi-before-heatmaps__label + a, .uab-copy + .uab-link) {
  display: inline-flex;
  margin-block-start: 12px;
}
#console-content :is(.support-copy > .body-copy + .support-foot, blockquote + figcaption) {
  margin-block-start: 16px;
}
