/* Cause & Effect Chains: the Why Desk inside the practice shell's stage (about 1066 x 628 at 1366 x 768).
 * Track F (Foundations): every word in the play area is 18 px or more; every tap target is 48 px or more.
 * Labels inside a picture (.lbl) hide when the picture is drawn under 196 px wide, so picture words never fall under 18 px. */
.cec { position: absolute; inset: 0; overflow: hidden; display: flex; flex-direction: column; gap: 8px; padding: 10px 14px 8px; color: #1f2933; font-size: 18px; line-height: 1.3;
  container-type: inline-size; container-name: cec;
  background: linear-gradient(#eef3ef, #dfe9e3);
  --cec-panel: rgba(255, 255, 255, .94); --cec-line: #9fb5aa; --cec-soft: #3f544b; --cec-accent: #2e6b5e; --cec-accent-bg: #e1f0eb;
  --cec-ok: #17663a; --cec-ok-bg: #e3f6e8; --cec-bad: #a3241f; --cec-bad-bg: #fde7e4; --cec-board: #24433c; --cec-board-ink: #f1f6f3; --cec-card: #ffffff; }
html[data-theme="dark"] .cec { color: #eef2f6; background: linear-gradient(#18221f, #111916);
  --cec-panel: rgba(30, 40, 37, .96); --cec-line: #4f6a60; --cec-soft: #c4d6ce; --cec-accent: #8fd3bf; --cec-accent-bg: #1d3a33;
  --cec-ok: #7fdca0; --cec-ok-bg: #173d27; --cec-bad: #ffb4a8; --cec-bad-bg: #4a1e1a; --cec-board: #0e1a17; --cec-card: #23302c; }
.cec *, .cec *::before, .cec *::after { box-sizing: border-box; }
.cec p, .cec ol, .cec figure { margin: 0; padding: 0; }
.cec ol { list-style: none; }
.cec button { font: inherit; color: inherit; }
.cec-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* pictures: the same in light and dark (each has its own background) */
.cec-slide { display: block; aspect-ratio: 3 / 2; border-radius: 8px; overflow: hidden; background: #fff; box-shadow: inset 0 0 0 1px rgba(30, 40, 36, .3), 0 1px 3px rgba(0, 0, 0, .14); flex: none; container-type: inline-size; }
.cec-pic { display: block; width: 100%; height: 100%; }
@container (max-width: 195.5px) { .cec-pic .lbl, .cec-pic text { display: none; } .cec-pic text.big { display: inline; } }
@container (max-width: 143.5px) { .cec-pic text.big { display: none; } }

/* ── header row ── */
.cec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.cec p.cec-title { min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; padding: 6px 14px; border-radius: 12px; background: var(--cec-panel); border: 1.5px solid var(--cec-line); }
.cec-title b { font-size: 20px; }
.cec-title span { color: var(--cec-soft); }
html .cec-say { flex: none; min-height: 48px; padding: 8px 14px; border-radius: 999px; border: 2px solid var(--cec-line); background: var(--cec-panel); font-weight: 700; cursor: pointer; white-space: nowrap; }
.cec-say[aria-pressed="true"] { border-color: var(--cec-accent); }
.cec-say:hover { background: var(--cec-accent-bg); }

.cec-main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.cec-k { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; margin-bottom: 6px; }
.cec-k b { font-size: 18px; }
.cec-k span { color: var(--cec-soft); }
.cec-msg { font-weight: 700; color: var(--cec-bad); }
.cec-msg:empty { display: none; }

/* ── the chain board ── */
.cec-board { padding: 8px 12px 12px; border-radius: 14px; background: var(--cec-board); color: var(--cec-board-ink); box-shadow: 0 6px 16px rgba(0, 0, 0, .2); }
.cec-board .cec-k span { color: #c9dcd4; }
.cec-chain { display: grid; column-gap: 0; row-gap: 10px; align-items: start; }
.cec-slot { position: relative; min-width: 0; display: flex; flex-direction: column; align-items: center; }
.cec-kick { align-self: center; margin-bottom: 4px; padding: 0 10px; border-radius: 999px; background: #ffd54a; color: #14161c; font-size: 18px; font-weight: 800; font-style: italic; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); pointer-events: none; }
.cec-hole { width: 100%; max-width: 250px; aspect-ratio: 3 / 2; display: grid; place-items: center; border: 3px dashed rgba(241, 246, 243, .6); border-radius: 10px; background: rgba(255, 255, 255, .06); }
.cec-hole > span[aria-hidden], .cec-hole > span:first-child { font-size: 30px; font-weight: 800; color: #c9dcd4; }
.cec-hole--q { border-color: #ffd54a; }
.cec-hole--q > span:first-child { font-size: 44px; color: #ffd54a; }
html .cec-placed { position: relative; display: flex; flex-direction: column; align-items: center; gap: 5px; width: 100%; padding: 0; border: 0; background: none; text-align: center; cursor: grab; }
.cec-placed.cec-fixed { cursor: default; }
.cec-placed .cec-slide { width: 100%; max-width: 250px; }
.cec-name { display: block; font-size: 18px; font-weight: 700; line-height: 1.2; overflow-wrap: break-word; }
.cec-num { display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 6px; margin-right: 2px; vertical-align: middle; border-radius: 999px; background: #ffd54a; color: #14161c; font-size: 18px; font-weight: 800; border: 1.5px solid #14161c; }
.cec-join { align-self: start; display: grid; place-items: center; height: 0; padding-top: 0; }
.cec-join span { display: block; margin-top: calc(31px + var(--cec-pic-h, 110px) / 2); font-size: 28px; font-weight: 800; color: #ffd54a; line-height: 1; transform: translateY(-50%); }
.cec-slot.is-over .cec-hole, .cec-slot.is-over .cec-slide { outline: 4px solid #ffd54a; outline-offset: 2px; }
.cec-placed:focus-visible, .cec-card:focus-visible, .cec-choice:focus-visible, .cec-say:focus-visible { outline: 4px solid #ffb000; outline-offset: 2px; }
.cec-mark { display: none; }
.cec-tagrow { display: flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: 4px; min-height: 28px; }
.cec-tagrow .cec-kick { margin-bottom: 0; }
.cec-tagrow .cec-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-size: 18px; font-weight: 800; color: #fff; border: 2px solid #fff; }
.cec-mark--ok { background: #17663a; }
.cec-mark--bad { background: #a3241f; }
.cec-slot.is-ok .cec-slide { box-shadow: 0 0 0 3.5px #5fd08a; }
.cec-slot.is-bad .cec-slide { box-shadow: 0 0 0 3.5px #ff8c80; }
.cec-slot.is-fixed .cec-slide { box-shadow: 0 0 0 3.5px #ffd54a; }
.cec.is-locked .cec-placed { cursor: default; }

/* the because boxes (after Check): each sits under its arrow, pointing up at it */
.cec-because { position: relative; margin: 6px 4px 0; padding: 8px 10px; border-radius: 10px; background: #fff7d6; color: #2b2410; font-size: 18px; line-height: 1.25; text-align: left; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.cec-because b { color: #7a4a00; }
.cec-because-tip { position: absolute; left: 50%; top: -9px; width: 18px; height: 18px; margin-left: -9px; background: #fff7d6; transform: rotate(45deg); border-radius: 3px; }
html[data-theme="dark"] .cec-because, html[data-theme="dark"] .cec-because-tip { background: #3b3416; color: #fbefc4; }
html[data-theme="dark"] .cec-because b { color: #ffd54a; }
.cec-loop { display: flex; gap: 10px; align-items: flex-start; margin-top: 10px; padding: 8px 12px; border-radius: 10px; border: 2px dashed #ffd54a; color: var(--cec-board-ink); font-size: 18px; }
.cec-loop-ico { flex: none; font-size: 28px; line-height: 1; color: #ffd54a; }

/* ── picture cards (the tray) ── */
.cec-table { flex: 1 1 auto; min-height: 0; padding: 8px 12px 10px; border-radius: 14px; background: var(--cec-panel); border: 1.5px solid var(--cec-line); display: flex; flex-direction: column; }
.cec-tray { display: grid; grid-template-columns: repeat(var(--cec-n, 4), minmax(0, 1fr)); gap: 10px; align-items: start; }
.cec--n3 { --cec-n: 3; }
/* four cards: slightly smaller pictures so the chain and the tray fit the stage at 1366 x 768 with three-line names */
.cec--n4 .cec-placed .cec-slide, .cec--n4 .cec-card .cec-slide, .cec--n4 .cec-hole { max-width: 198px; }
.cec--n4 .cec-card { padding: 5px 5px 6px; }
html .cec-card, html .cec-choice { position: relative; display: flex; flex-direction: column; align-items: center; gap: 5px; min-height: 48px; padding: 7px 7px 8px; text-align: center; border-radius: 12px; border: 2px solid var(--cec-line); background: var(--cec-card); cursor: pointer; }
.cec-card .cec-slide, .cec-choice .cec-slide { width: 100%; max-width: 230px; }
.cec-card:hover:not(:disabled), .cec-choice:hover:not(:disabled) { border-color: var(--cec-accent); background: var(--cec-accent-bg); }
.cec-card.is-placed { border-style: dashed; }
.cec-card.is-placed .cec-slide { opacity: .4; }
.cec-card.is-placed .cec-name { color: var(--cec-soft); }
.cec-card.is-dragging, .cec-placed.is-dragging { opacity: .4; }
.cec-ghost { position: fixed; z-index: 2147483600; width: 150px; transform: translate(-50%, -50%) rotate(-3deg); pointer-events: none; filter: drop-shadow(0 8px 14px rgba(0, 0, 0, .35)); }
.cec-ghost .cec-slide { width: 100%; }
@media (pointer: fine), (min-width: 901px) { html .cec-card:not(:disabled), html .cec-placed:not(.cec-fixed) { touch-action: none; } }

/* ── link: picture choices ── */
.cec-pick { flex: none; padding: 8px 12px 10px; border-radius: 14px; background: var(--cec-panel); border: 1.5px solid var(--cec-line); }
.cec-pick .cec-k b { font-size: 20px; }
.cec-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.cec-choice .cec-slide { max-width: 210px; }
.cec-choice[aria-checked="true"] { border-color: var(--cec-accent); border-width: 4px; padding: 5px 5px 6px; background: var(--cec-accent-bg); }
.cec-choice.is-right { border-color: #2f9e55; border-width: 4px; padding: 5px 5px 6px; background: var(--cec-ok-bg); }
.cec-choice.is-wrong { border-color: #c62828; border-width: 4px; padding: 5px 5px 6px; background: var(--cec-bad-bg); }
.cec-choice.is-right .cec-mark, .cec-choice.is-wrong .cec-mark { display: grid; place-items: center; flex: none; order: -1; width: 28px; height: 28px; border-radius: 50%; color: #fff; font-weight: 800; font-size: 18px; }
.cec-wrongidea { display: inline-block; margin-left: 4px; padding: 0 8px; border-radius: 999px; background: #a3241f; color: #fff; font-size: 18px; font-weight: 800; }
.cec-choice.is-right .cec-mark { background: #17663a; }
.cec-choice.is-wrong .cec-mark { background: #a3241f; }
.cec button:disabled { cursor: default; opacity: 1; }
/* after Check the choices shrink to a row (small picture + name) to make room for the because boxes */
.cec--link.is-revealed .cec-choice { flex-direction: row; text-align: left; gap: 10px; padding-left: 10px; }
.cec--link.is-revealed .cec-choice .cec-slide { width: 96px; }
.cec--link.is-revealed .cec-choice.is-right, .cec--link.is-revealed .cec-choice.is-wrong { padding-left: 8px; }
.cec--link.is-revealed .cec-pick .cec-k { display: none; }

/* ── Briefing example ── */
.cec-example { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px; }
.cec-example figure { flex: 1 1 0; min-width: 120px; margin: 0; font-size: 16px; }
.cec-example .cec-slide { width: 100%; }
.cec-example figcaption { margin-top: 4px; line-height: 1.2; }
.cec-ex-arrow { align-self: center; font-size: 22px; font-weight: 800; margin-bottom: 30px; }
.ps-brief--drawer .cec-example figure { flex-basis: 40%; }
.ps-brief--drawer .cec-ex-arrow { display: none; }

/* ── Foundations: 18 px for the shell's words beside the play area too ── */
body[data-activity="cause-effect-chains"] .ps-bubble, body[data-activity="cause-effect-chains"] .ps-cust-detail, body[data-activity="cause-effect-chains"] .ps-feedback,
body[data-activity="cause-effect-chains"] .ps-hint, body[data-activity="cause-effect-chains"] .ps-gloss, body[data-activity="cause-effect-chains"] .ps-cust-who,
body[data-activity="cause-effect-chains"] .ps-nudge { font-size: 18px; line-height: 1.3; }
body[data-activity="cause-effect-chains"] .ps-cust-detail { color: var(--tlg-text); }
body[data-activity="cause-effect-chains"] .ps-say { width: 48px; height: 48px; font-size: 22px; margin: -2px -4px 4px 8px; }
body[data-activity="cause-effect-chains"] .ps-hint-btn { min-height: 48px; }
body[data-activity="cause-effect-chains"] .ps-hint .ps-hint-note { font-size: 16px; }
/* after Check the how-to line and the used hint are no longer needed: give their room to the feedback */
body[data-activity="cause-effect-chains"] .ps-side:has(.ps-feedback:not([hidden])) .ps-cust-detail,
body[data-activity="cause-effect-chains"] .ps-side:has(.ps-feedback:not([hidden])) .ps-hint { display: none; }

/* ── a narrower stage (1024 wide): the play area may scroll inside the stage instead of squeezing the pictures ── */
@media (max-width: 1180px) and (min-width: 901px) { .cec { overflow-y: auto; } .cec-main { flex: none; } }

/* ── a mid-width play area (1024 wide): after Check the shrunk choices stack in one column ── */
@container cec (max-width: 960px) { .cec--link.is-revealed .cec-choices { grid-template-columns: minmax(0, 1fr); gap: 8px; } }

/* ── narrow play area: the chain runs top to bottom; each because sits right under its arrow ── */
@container cec (max-width: 640px) {
  .cec-chain { grid-template-columns: minmax(0, 1fr) !important; row-gap: 4px; }
  .cec-chain > * { grid-column: 1 / -1 !important; grid-row: auto !important; }
  .cec-slot { flex-direction: row; flex-wrap: wrap; }
  .cec-kick { align-self: flex-start; }
  .cec-slot > .cec-placed, .cec-slot > .cec-hole { flex: 1 1 100%; }
  .cec-placed, .cec-placed.cec-fixed { flex-direction: row; align-items: center; text-align: left; gap: 10px; }
  .cec-placed .cec-slide { width: 46%; max-width: 200px; }
  .cec-slot > .cec-hole { flex: 0 0 46%; max-width: 200px; }
  .cec-slot .cec-name { flex: 1 1 0; min-width: 0; }
  .cec-join { height: auto; }
  .cec-join span { margin: 0; transform: rotate(90deg); font-size: 26px; }
  .cec-because { margin: 0 0 4px; }
  .cec-because-tip { left: 24px; }
  .cec-tagrow { flex: 1 1 100%; justify-content: flex-start; }
  .cec-tray, .cec--n3 .cec-tray { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cec-choices { grid-template-columns: minmax(0, 1fr); }
  .cec-choice { flex-direction: row !important; text-align: left !important; gap: 10px; }
  .cec-choice .cec-slide { width: 46%; max-width: 200px; }
  .cec-choice .cec-name { flex: 1 1 0; min-width: 0; }
  .cec--link.is-revealed .cec-choice .cec-slide { width: 96px; }
}
@media (max-width: 900px) {
  .cec { position: relative; inset: auto; overflow: visible; padding: 10px 10px 16px; }
  .cec-head { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: no-preference) {
  .cec-card, .cec-choice { transition: border-color .12s, background-color .12s; }
  .cec.is-revealed .cec-because { animation: cec-in .45s ease-out both; }
  .cec.is-revealed .cec-because:nth-of-type(2) { animation-delay: .15s; }
  .cec.is-revealed .cec-because:nth-of-type(3) { animation-delay: .3s; }
  @keyframes cec-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
}

/* badges are at least 24 px tall */
.cec-kick, .cec-wrongidea { min-height: 26px; line-height: 26px; }
/* three cards: pictures capped a little smaller so a full tray (numbered captions) still fits at 1366 x 768 */
.cec--n3 .cec-placed .cec-slide, .cec--n3 .cec-card .cec-slide, .cec--n3 .cec-hole { max-width: 226px; }
