/* The same role follows a handoff from its diagram node to its connector and record. */
:root {
  --wf-canvas: #fff;
  --wf-panel: #fafbfc;
  --wf-card: #fff;
  --wf-inset: #f0f3f5;
  --wf-line: #dce1e5;
  --wf-control: #89969c;
  --wf-ink: #24262a;
  --wf-muted: #626970;
  --wf-focus: #306e99;
  --wf-trail-base: #bfcacc;
  --wf-booking-line: #5996bd;
  --wf-booking-paper: #e6f2fc;
  --wf-booking-ink: #295975;
  --wf-pending-line: #bf5861;
  --wf-pending-paper: #fff0f1;
  --wf-pending-ink: #983941;
  --wf-automation-line: #328966;
  --wf-automation-paper: #e5f5ec;
  --wf-automation-ink: #176144;
  --wf-neutral-line: #788890;
  --wf-neutral-paper: #edf1f3;
  --wf-neutral-ink: #334853;
}

:root[data-theme="dark"] {
  --wf-canvas: #191e21;
  --wf-panel: #1d2428;
  --wf-card: #283035;
  --wf-inset: #323c42;
  --wf-line: #455158;
  --wf-control: #728188;
  --wf-ink: #edf2f3;
  --wf-muted: #b4c2c8;
  --wf-focus: #aedbfa;
  --wf-trail-base: #73858d;
  --wf-theatre: radial-gradient(ellipse at 73% 15%, #34403e, transparent 68%),
    linear-gradient(145deg, #243239, #20282c 74%);
  --wf-booking-line: #86bbde;
  --wf-booking-paper: #283e50;
  --wf-booking-ink: #c2e6ff;
  --wf-pending-line: #e38c94;
  --wf-pending-paper: #492f35;
  --wf-pending-ink: #ffbcc2;
  --wf-automation-line: #80c5a6;
  --wf-automation-paper: #253e34;
  --wf-automation-ink: #ade8c9;
  --wf-neutral-line: #a3b6c1;
  --wf-neutral-paper: #364149;
  --wf-neutral-ink: #e2edf3;
}

/* Visit prep uses its own clinician chart, phone, and mail chrome. */
:root[data-theme="dark"] #px-intake-review {
  color-scheme: dark;
  --ink: var(--wf-ink);
  --mut: var(--wf-muted);
  --line: var(--wf-line);
  --page: var(--wf-panel);
  --silver: var(--wf-control);
  --route: var(--wf-automation-line);
  --warm: var(--wf-automation-paper);
  --coral: var(--wf-automation-ink);
  --device: #161c1f;
  --device-raised: #252d31;
  background: var(--wf-canvas);

  .scroll-pin, .px-foot { background: var(--wf-canvas); }
  .px-map { background: var(--wf-panel); }
  .phase, .px-foot .intake-skip { color: var(--wf-muted); }
  .px-demo, .px-demohead, .px-caption { background: var(--wf-card); }
  .px-theatre, .px-theatre:has(.motion-layer:not([hidden]) .six-device) {
    background: var(--wf-theatre);
  }
  .px-pager button, .px-toggle {
    background: var(--wf-card);
    border-color: var(--wf-control);
    color: var(--wf-ink);
  }
  .px-pager button:enabled:hover, .px-toggle:hover { background: var(--wf-inset); }
  button:focus-visible, .px-foot .intake-skip:focus-visible {
    outline: 2px solid var(--wf-focus);
    outline-offset: 2px;
  }

  .px-stage .px-node:not(.px-diamond) {
    color: color-mix(in srgb, var(--wf-ink), var(--node-ink) var(--heat, 0%));
    background: color-mix(in srgb, var(--wf-card), var(--node-paper) var(--heat, 0%));
    border-color: color-mix(in srgb, var(--wf-control), var(--node-color) var(--heat, 0%));
  }
  .px-stage .px-diamond polygon {
    fill: color-mix(in srgb, var(--wf-card), var(--node-paper) var(--heat, 0%));
    stroke: color-mix(in srgb, var(--wf-control), var(--node-color) var(--heat, 0%));
  }
  .px-stage .px-node:not(.sel):hover { border-color: var(--wf-muted); }
  .px-stage .px-diamond:not(.sel):hover polygon { stroke: var(--wf-muted); }
  .px-wire, #px-arrow path { stroke: var(--wf-trail-base); }
  .px-fork[data-route=missing].active { color: var(--wf-pending-ink); }
  .px-fork[data-route=file].active { color: var(--wf-automation-ink); }
  .px-mark { filter: brightness(0) invert(.86); }
  .automation-mark::before { background: var(--wf-automation-paper); }
  .automation-mark::after { background: var(--wf-automation-line); }
  .px-actor { background: var(--wf-inset); color: var(--wf-neutral-ink); }
  .px-caption[data-owner=automation] .px-actor {
    color: var(--wf-automation-ink);
    background: var(--wf-automation-paper);
    border-color: #4f7764;
  }
  .px-caption[data-owner=automation] .px-mark {
    filter: brightness(0) saturate(100%) invert(86%) sepia(21%) saturate(549%) hue-rotate(90deg);
  }

  /* The scene controller also supplies inline icon colors. */
  .px-appname .px-appico {
    background: var(--wf-inset) !important;
    color: var(--wf-neutral-ink) !important;
  }
  .px-appico:has([data-lucide="message-circle"]) {
    background: var(--wf-automation-paper) !important;
    color: var(--wf-automation-ink) !important;
  }
  .px-appico:has(.six-gmail) { background: transparent !important; }

  .px-paper {
    color: var(--wf-ink);
    background: var(--wf-card);
    border-color: #536067;
    box-shadow: 0 12px 32px -18px #060b10;
  }
  .px-paper-head { background: #2d373b; }
  .px-paper-head .px-icon { color: var(--wf-automation-line); }
  .px-paper-body p, .derm-chart-hpi dt, .derm-original-list dt { color: var(--wf-muted); }
  .px-meta-row, .derm-section-heading { border-color: var(--wf-line); }
  .six-initial, .sender-monogram { background: #354851; color: #d0e5ee; }
  .six-status.pending {
    color: var(--wf-pending-ink);
    background: var(--wf-pending-paper);
    outline-color: #8c555f;
    box-shadow: none;
  }
  .six-status.confirmed, .derm-chart-identity span {
    color: var(--wf-automation-ink);
    background: var(--wf-automation-paper);
  }
  .status-check { background: #355e4c; }
  .status-check::after { border-color: #ceffe3; }
  .derm-section-heading { color: #bdcdd2; }
  .six-summary blockquote { color: var(--wf-ink); }
  .chart-source, .chart-back {
    color: var(--wf-neutral-ink);
    border-color: var(--wf-control);
    background: var(--wf-inset);
  }

  .six-device {
    background: var(--device);
    border-color: #12181b;
    box-shadow: 0 0 0 1px #77858a, inset 0 0 0 1px #3a4549, 0 12px 24px -12px #090d11;
    color: #eef2f3;
  }
  .six-device .px-statusbar { color: #eef2f3; }
  .six-device .px-island { background: #050708; }
  .six-device .px-home { background: #e1e9ea; }
  .six-device .six-lock-screen {
    color: #e6f1ec;
    background: radial-gradient(ellipse at 5% 22%, #334c48, transparent 65%),
      linear-gradient(145deg, #233c3e, #394049 64%, #2f353e);
  }
  .six-notice {
    background: #303a40;
    color: var(--wf-ink);
    box-shadow: 0 6px 20px #0a111a45, inset 0 0 0 1px #5c696d;
  }
  .six-notice-meta, .px-stamp, .px-compose, .px-compose span { color: var(--wf-muted); }
  .six-notice-meta .px-icon { color: #14281b; background: #8bdb9e; }
  .px-contact {
    background: linear-gradient(var(--device), #1d2427);
    border-color: #374348;
  }
  .px-avatar { background: linear-gradient(145deg, #5c727c, #445963); color: #fff; }
  .px-bubble { background: #343d42; color: #f4f6f6; }
  .six-device .px-inline-link { color: #a4d8ff; }
  .px-compose span { border-color: #56636a; }
  .touch-spot { border-color: #f0b494; background: #f2b28b2e; }

  .derm-brand { color: #e4f1e8; border-color: #37483f; }
  .derm-brand-mark, .derm-success-mark { background: #2b4337; color: #b2dfbe; }
  .derm-brand-mark svg { color: #b2dfbe; }
  .derm-page-stack, .derm-page h3 { color: #e4f1e8; }
  .derm-progress, .derm-review-list dt, .six-success p { color: #b5c7bc; }
  .derm-progress i { background: #38443e; }
  .derm-progress .filled { background: #9acba8; }
  .derm-option, [data-sample-answer] {
    color: #e5efe7;
    background: var(--device-raised);
    border-color: #728479;
  }
  [data-sample-answer] {
    background: color-mix(in srgb, var(--device-raised), #314d3c var(--chosen, 0%));
    border-color: color-mix(in srgb, #728479, #a1d3ad var(--chosen, 0%));
  }
  .derm-radio { border-color: #93a69a; }
  .is-selected .derm-radio { border-color: #aedfba; }
  .is-selected .derm-radio::after { background: #aedfba; }
  .derm-free-text { color: #e5efe7; background: var(--device-raised); border-color: #728479; }
  .six-caret { background: #b2d8bf; }
  .derm-next { color: #d4e0d7; background: #3f4c44; }
  .derm-next.is-ready, .derm-next.six-submit { color: #14291c; background: #aed5b8; }
  .derm-review-list > div { border-color: #36463d; }
  .derm-page.six-success { color: #b9e6c5; }
  .derm-safari { color: #ced8da; background: var(--device-raised); }

  .mail-toolbar { background: #303a43; color: #e5eaf1; border-color: #49555e; }
  .mail-toolbar small, .mail-sender small, .attachment-header small { color: #b8c6d0; }
  .attachment { background: #252e34; border-color: #53606a; }
  .attachment-header { background: #34404a; color: #e3ebf1; }
  .attachment-header svg { color: #f5ad9a; }
  .attachment ul { color: #c7d3db; }
}

@media (max-width: 720px) {
  :root[data-theme="dark"] #px-intake-review .px-paper { box-shadow: none; }
}

/* Keep the diagram, clinical workspace, and mobile apps consistent across stories. */
:root[data-theme="dark"] [data-clinic-workflow] {
  .cw-theatre { background: var(--wf-theatre); }
  .cw-diagram .cw-node:not([aria-current], .cw-decision),
  .cw-pager button, .cw-slots > span:not(.cw-picked) { border-color: var(--wf-control); }
  .cw-diagram .cw-node:not([aria-current], .cw-decision):hover { border-color: var(--wf-muted); }
  .cw-wire { stroke: var(--wf-trail-base); opacity: 1; }
  .cw-arrow { stroke: var(--wf-trail-base); }
  .cw-map-head .cw-mark, .cw-node:not([aria-current]) .cw-mark { filter: brightness(0) invert(.86); }
  .cw-node[aria-current][data-role=automation] .cw-mark {
    filter: brightness(0) saturate(100%) invert(88%) sepia(25%) saturate(460%) hue-rotate(91deg);
  }
  .cw-app-title svg { color: var(--wf-neutral-ink); background: var(--wf-inset); }
  .cw-app-title [data-lucide="message-circle"] { color: var(--wf-automation-ink); background: var(--wf-automation-paper); }
  .cw-window { border-color: #536067; box-shadow: 0 12px 32px -18px #060b10; }
  .cw-window-bar { background: #2d373b; }
  .cw-phone {
    color: var(--wf-ink);
    background: #161c1f;
    border-color: #12181b;
    box-shadow: 0 0 0 1px #77858a, inset 0 0 0 1px #3a4549, 0 12px 24px -12px #090d11;
  }
  .cw-status > i { background: #050708; }
  .cw-contact { background: linear-gradient(#161c1f, #1d2427); border-color: #374348; }
  .cw-contact span { background: linear-gradient(145deg, #5c727c, #445963); }
  .cw-bubble { background: #343d42; color: #f4f6f6; }
  .cw-link { color: #a4d8ff; }
  .cw-compose span { border-color: #56636a; }
  .cw-url { color: #ced8da; background: #252d31; }
  .cw-web-head { color: #e4f1e8; border-color: #37483f; }
  .cw-slots > span { background: #252d31; }
  .cw-selected-slot .cw-picked { background: var(--wf-automation-paper); }
}
