/* Word Part Builder: the Word Workshop 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.
 * Chip colors carry the part's place (prefix blue, root amber, suffix green) and the hyphen in its form says the same. */
.wpb { 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;
  background: linear-gradient(180deg, #f6f1e6, #efe6d3); }
.wpb, .wpb-example {
  --wpb-panel: rgba(255, 253, 248, .96); --wpb-line: #c3b393; --wpb-soft: #54493a; --wpb-accent: #2f6a5a; --wpb-accent-bg: #e1f1ec;
  --wpb-ok: #17663a; --wpb-ok-bg: #e3f6e8; --wpb-bad: #a3241f; --wpb-bad-bg: #fde7e4; --wpb-slide: #fffaf0;
  --wpb-pre: #dcecff; --wpb-pre-line: #2f6fb3; --wpb-root: #fff0c8; --wpb-root-line: #a87a00; --wpb-suf: #ddf3e4; --wpb-suf-line: #2e7d4a; --wpb-ink: #16202a; }
html[data-theme="dark"] .wpb { color: #eef2f6; background: linear-gradient(180deg, #1c2129, #161a20); }
html[data-theme="dark"] .wpb, html[data-theme="dark"] .wpb-example {
  --wpb-panel: rgba(32, 38, 48, .96); --wpb-line: #5a6678; --wpb-soft: #c9d3de; --wpb-accent: #8fd3bf; --wpb-accent-bg: #1d3a33;
  --wpb-ok: #7fdca0; --wpb-ok-bg: #173d27; --wpb-bad: #ffb4a8; --wpb-bad-bg: #4a1e1a;
  --wpb-pre: #1d3550; --wpb-pre-line: #7fb6f0; --wpb-root: #3d3317; --wpb-root-line: #e4c25c; --wpb-suf: #1b3a27; --wpb-suf-line: #7fd19b; --wpb-ink: #f2f5f8; }
.wpb *, .wpb *::before, .wpb *::after { box-sizing: border-box; }
.wpb p, .wpb ol, .wpb ul { margin: 0; padding: 0; }
.wpb ol, .wpb ul { list-style: none; }
.wpb button { font: inherit; color: inherit; }
.wpb-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

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

/* ── panels ── */
.wpb-step1, .wpb-step2, .wpb-reveal { padding: 8px 12px 10px; border-radius: 14px; background: var(--wpb-panel); border: 1.5px solid var(--wpb-line); }
.wpb-step2 { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.wpb-field { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.wpb-k { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; margin-bottom: 8px; }
.wpb-k b { font-size: 19px; }
.wpb-k > span:not(.wpb-step-n) { color: var(--wpb-soft); }
.wpb-step-n { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--wpb-accent); color: #fff; font-weight: 800; font-size: 18px; }
html[data-theme="dark"] .wpb-step-n { color: #10201b; }
.wpb-msg { font-weight: 700; color: var(--wpb-bad); }
.wpb-msg:empty { display: none; }

/* ── chips (tray, slots, key, reveal) ── */
.wpb-chip { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 56px; padding: 5px 12px 5px 6px; border-radius: 14px; text-align: left;
  background: var(--wpb-pre); border: 2.5px solid var(--wpb-pre-line); color: var(--wpb-ink); }
.wpb-chip--root { background: var(--wpb-root); border-color: var(--wpb-root-line); }
.wpb-chip--suffix { background: var(--wpb-suf); border-color: var(--wpb-suf-line); }
.wpb-chip-ic { flex: none; width: 42px; height: 42px; border-radius: 10px; background: #fffdf7; display: grid; place-items: center; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.wpb-chip-ic svg { width: 36px; height: 36px; display: block; }
.wpb-chip-t { display: flex; flex-direction: column; min-width: 0; line-height: 1.12; }
.wpb-chip-t b { font-size: 24px; letter-spacing: .01em; }
.wpb-chip-t span { font-size: 18px; color: inherit; opacity: .9; }
button.wpb-chip { cursor: pointer; }
button.wpb-chip:hover:not(:disabled) { box-shadow: 0 0 0 3px var(--wpb-accent); }
.wpb-chip:focus-visible, .wpb-letter:focus-visible, .wpb-choice:focus-visible, .wpb-say:focus-visible { outline: 4px solid #ffb000; outline-offset: 2px; }
.wpb-chip.is-placed { border-style: dashed; opacity: .55; }
.wpb-num { position: absolute; right: -8px; top: -10px; min-width: 28px; height: 28px; padding: 0 6px; display: grid; place-items: center; border-radius: 999px; background: #ffd54a; color: #14161c; font-size: 18px; font-weight: 800; box-shadow: 0 1px 3px rgba(0, 0, 0, .4); }
.wpb-chip.is-dragging { opacity: .35; }
@media (pointer: fine), (min-width: 901px) { html .wpb-tray .wpb-chip:not(:disabled), html .wpb-chip--in { touch-action: none; } }
html .wpb-ghost { position: fixed; z-index: 1000; pointer-events: none; transform: translate(-50%, -50%) rotate(-3deg); box-shadow: 0 10px 24px rgba(0, 0, 0, .35); }

/* ── build: the rail of slots, then the tray ── */
.wpb-rail { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.wpb-slot { min-width: 168px; min-height: 64px; display: flex; align-items: center; justify-content: center; border-radius: 16px; }
.wpb-slot.is-empty { border: 3px dashed var(--wpb-line); background: rgba(255, 255, 255, .35); }
html[data-theme="dark"] .wpb-slot.is-empty { background: rgba(255, 255, 255, .04); }
.wpb-slot-n { font-size: 22px; font-weight: 800; color: var(--wpb-soft); }
.wpb-slot.is-over { outline: 4px solid #ffb000; outline-offset: 2px; }
.wpb-slot .wpb-chip { width: 100%; min-height: 64px; }
.wpb-join { font-size: 30px; font-weight: 800; color: var(--wpb-soft); padding: 0 2px; }
.wpb-target { display: inline-flex; align-items: center; min-height: 56px; padding: 4px 16px; border-radius: 14px; background: #fffaf0; border: 2px solid var(--wpb-line); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .06); }
html[data-theme="dark"] .wpb-target { background: #2a303b; }
.wpb-target-w { font-size: 28px; font-weight: 800; letter-spacing: .02em; overflow-wrap: anywhere; }
.wpb-tray { display: flex; flex-wrap: wrap; gap: 10px 12px; }
.wpb-tray .wpb-chip { min-width: 168px; }

/* ── split: the letters, cut marks and the word part key ── */
.wpb-letters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 0; margin-bottom: 10px; }
.wpb-piece { display: inline-flex; flex-wrap: wrap; gap: 3px; padding: 4px; border-radius: 14px; background: rgba(47, 106, 90, .08); border: 2px solid rgba(47, 106, 90, .25); }
html[data-theme="dark"] .wpb-piece { background: rgba(143, 211, 191, .08); border-color: rgba(143, 211, 191, .3); }
.wpb-cut { width: 6px; height: 64px; margin: 0 7px; border-radius: 3px; background: #c0392b; box-shadow: 0 0 0 2px rgba(255, 255, 255, .7); }
html .wpb-letter { width: 48px; height: 56px; padding: 0; border-radius: 10px; border: 2px solid var(--wpb-line); background: #fffaf0; color: #16202a; font-size: 30px; font-weight: 800; cursor: pointer; }
html[data-theme="dark"] .wpb-letter { background: #2a303b; color: #f2f5f8; }
.wpb-letter:hover:not(:disabled) { border-color: var(--wpb-accent); background: var(--wpb-accent-bg); }
.wpb-letter.is-first { cursor: default; }
.wpb-letter.is-cut { border-color: #c0392b; border-width: 3px; }
.wpb-letter:disabled { opacity: 1; cursor: default; }
.wpb-key { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding-top: 8px; border-top: 1.5px dashed var(--wpb-line); }
.wpb-key-h { font-weight: 800; color: var(--wpb-soft); }
.wpb-key-list { display: flex; flex-wrap: wrap; gap: 8px 10px; }
.wpb-chip--key { min-height: 52px; }
.wpb-chip--key .wpb-chip-t b { font-size: 21px; }

/* ── step 2: picture cards ── */
.wpb-choices { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
html .wpb-choice { position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 6px; min-height: 48px; min-width: 0; padding: 6px 6px 8px; text-align: left; border-radius: 14px; border: 2.5px solid var(--wpb-line); background: var(--tlg-surface, #fff); cursor: pointer; }
html[data-theme="dark"] .wpb-choice { background: #252c38; }
.wpb-slide { display: block; flex: 1 1 auto; min-height: 0; background: var(--wpb-slide); border-radius: 10px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(60, 50, 36, .25); }
.wpb-slide svg { display: block; width: 100%; height: 100%; max-height: 210px; }
.wpb-choice-t { flex: none; font-size: 18px; font-weight: 700; line-height: 1.22; padding: 0 30px 0 4px; overflow-wrap: break-word; }
.wpb-choice:hover:not(:disabled) { border-color: var(--wpb-accent); }
.wpb-choice[aria-checked="true"] { border-color: var(--wpb-accent); background: var(--wpb-accent-bg); box-shadow: 0 0 0 3px var(--wpb-accent); }
.wpb-choice[aria-checked="true"]::after { content: "●"; position: absolute; right: 10px; bottom: 8px; font-size: 20px; line-height: 1; color: var(--wpb-accent); }
.wpb-choice:disabled { cursor: default; opacity: 1; }
.wpb-mark { display: none; }
.wpb-choice.is-right, .wpb-choice.is-wrong { box-shadow: none; }
.wpb-choice.is-right::after, .wpb-choice.is-wrong::after { content: none; }
.wpb-choice.is-right { border-color: var(--wpb-ok); background: var(--wpb-ok-bg); border-width: 3.5px; }
.wpb-choice.is-wrong { border-color: var(--wpb-bad); background: var(--wpb-bad-bg); border-style: dashed; }
.wpb-choice.is-right .wpb-mark, .wpb-choice.is-wrong .wpb-mark { display: grid; place-items: center; position: absolute; right: 8px; bottom: 8px; width: 30px; height: 30px; border-radius: 50%; font-size: 20px; font-weight: 800; color: #fff; }
.wpb-choice.is-right .wpb-mark { background: #17663a; }
.wpb-choice.is-wrong .wpb-mark { background: #a3241f; }

/* ── reveal ── */
.wpb-reveal { display: grid; grid-template-columns: minmax(0, 40%) minmax(0, 1fr); gap: 14px; align-items: start; }
.wpb-big { background: var(--wpb-slide); border-radius: 10px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(60, 50, 36, .25); }
.wpb-big svg { display: block; width: 100%; height: auto; }
.wpb-why { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.wpb-why .wpb-k { margin: 0; }
.wpb-eq { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.wpb-chip--eq { min-height: 52px; }
.wpb-chip--eq .wpb-chip-t b { font-size: 21px; }
.wpb-mean { font-size: 20px; }
.wpb-fact { color: var(--wpb-soft); }
.wpb-yours { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.wpb-yours-m { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: #fff; font-size: 18px; flex: none; }
.wpb-yours.is-ok .wpb-yours-m { background: #17663a; }
.wpb-yours.is-bad .wpb-yours-m { background: #a3241f; }
.wpb.is-revealed .wpb-slide svg { max-height: 150px; }

/* ── Briefing example ── */
.wpb-example { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.wpb-example .wpb-chip { font-size: 18px; }
.wpb-example .wpb-target { color: var(--wpb-ink); }
.wpb-example .wpb-target-w { font-size: 24px; }
.wpb-example .wpb-chip-t b { font-size: 21px; }
.wpb-example-pic { width: 100%; max-width: 440px; background: #fffaf0; border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(60, 50, 36, .25); }
.wpb-example-pic svg { display: block; width: 100%; height: auto; }
.ps-brief--drawer .wpb-example .wpb-eq { justify-content: center; }

/* ── Foundations: 18 px for the shell's words beside the play area too ── */
body[data-activity="word-part-builder"] .ps-bubble, body[data-activity="word-part-builder"] .ps-cust-detail, body[data-activity="word-part-builder"] .ps-feedback,
body[data-activity="word-part-builder"] .ps-hint, body[data-activity="word-part-builder"] .ps-gloss, body[data-activity="word-part-builder"] .ps-cust-who,
body[data-activity="word-part-builder"] .ps-nudge { font-size: 18px; line-height: 1.3; }
body[data-activity="word-part-builder"] .ps-cust-detail { color: var(--tlg-text); }
body[data-activity="word-part-builder"] .ps-say { width: 48px; height: 48px; font-size: 22px; margin: -2px -4px 4px 8px; }
body[data-activity="word-part-builder"] .ps-hint-btn { min-height: 48px; }
body[data-activity="word-part-builder"] .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="word-part-builder"] .ps-side:has(.ps-feedback:not([hidden])) .ps-cust-detail,
body[data-activity="word-part-builder"] .ps-side:has(.ps-feedback:not([hidden])) .ps-hint { display: none; }

/* ── narrower stage (901-1180 px): the play area may scroll inside the stage ── */
@media (max-width: 1180px) and (min-width: 901px) {
  .wpb { overflow-y: auto; }
  .wpb-step2 { flex: none; }
  .wpb-slide svg { max-height: 150px; }
  .wpb-reveal { grid-template-columns: 350px minmax(0, 1fr); }
  .wpb-tray .wpb-chip, .wpb-slot { min-width: 150px; }
}
/* ── phones and tablets: the shell stacks the page; the stage flows ── */
@media (max-width: 900px) {
  .wpb { position: relative; inset: auto; overflow: visible; padding: 10px 10px 16px; }
  .wpb-head { flex-wrap: wrap; }
  .wpb-step2 { flex: none; }
  .wpb-choices { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .wpb-reveal { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .wpb-choices { grid-template-columns: minmax(0, 1fr); }
  html .wpb-choice { flex-direction: row; align-items: center; }
  .wpb-choice .wpb-slide { flex: 0 0 46%; }
  .wpb-choice-t { flex: 1 1 0; }
  .wpb-tray .wpb-chip { min-width: auto; flex: 1 1 auto; }
  .wpb-slot { min-width: 120px; flex: 1 1 auto; }
  .wpb-slot .wpb-chip { width: auto; flex: 1 1 auto; }
  .wpb-chip-t b { font-size: 22px; }
  .wpb-rail .wpb-target { flex: 1 1 100%; justify-content: center; }
  .wpb-target-w { font-size: 24px; }
  .wpb-letters { justify-content: flex-start; }
}
@media (prefers-reduced-motion: no-preference) {
  .wpb-chip, .wpb-choice, .wpb-letter { transition: border-color .12s, background-color .12s, box-shadow .12s; }
  .wpb.is-revealed .wpb-reveal { animation: wpb-in .35s ease-out; }
  @keyframes wpb-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}
