:root {
  --d4-ink: #152f3d;
  --d4-ink-2: #244d5b;
  --d4-teal: #087f73;
  --d4-teal-dark: #075d3a;
  --d4-coral: #d75a45;
  --d4-gold: #dca73a;
  --d4-cream: #fffaf0;
  --d4-mist: #edf8d3;
  --d4-paper: #ffffff;
  --d4-line: #cfe0dc;
  --d4-good: #177a56;
  --d4-bad: #a63d35;
  --d4-shadow: 0 18px 44px rgba(18, 56, 65, .11);
  --d4-radius: 22px;
}

.p6-page { background: #fbfdfc; color: var(--d4-ink); }
.p6-page *, .p6-page *::before, .p6-page *::after { box-sizing: border-box; }
.p6-page button, .p6-page input, .p6-page select, .p6-page textarea { font: inherit; }
.p6-page button, .p6-page a, .p6-page input, .p6-page select, .p6-page textarea, .p6-page summary { outline-offset: 4px; }
.p6-page :focus-visible { outline: 3px solid #efb94e; }
.p6-container { width: min(1180px, calc(100% - 2rem)); margin-inline: auto; }
.p6-breadcrumbs { display: flex; flex-wrap: wrap; gap: .55rem; padding-block: 1rem; font-size: .92rem; color: #4b666c; }
.p6-breadcrumbs a { color: var(--d4-teal-dark); font-weight: 700; }

.p6-hero { position: relative; overflow: hidden; background: linear-gradient(135deg, #0b625f 0%, #153c4c 58%, #142c3a 100%); color: white; padding: clamp(3rem, 7vw, 6rem) 0; }
.p6-hero::before, .p6-hero::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; }
.p6-hero::before { width: 390px; height: 390px; right: -130px; top: -190px; border: 70px solid rgba(255,255,255,.055); }
.p6-hero::after { width: 250px; height: 250px; left: -95px; bottom: -150px; background: rgba(220,167,58,.09); }
.p6-hero__grid { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(270px, .65fr); gap: clamp(2rem, 5vw, 5rem); align-items: center; }
.p6-eyebrow, .p6-kicker { margin: 0 0 .55rem; text-transform: uppercase; letter-spacing: .13em; font-size: .76rem; font-weight: 900; color: #ffe09a; }
.p6-code-row { display: flex; align-items: center; gap: .7rem; margin-bottom: .85rem; }
.p6-code-row span:first-child { display: inline-flex; padding: .38rem .72rem; border: 1px solid rgba(255,255,255,.34); border-radius: 999px; font-weight: 900; letter-spacing: .08em; background: rgba(255,255,255,.09); }
.p6-code-row span:last-child { font-size: 1.7rem; }
.p6-hero h1 { margin: 0; max-width: 820px; font-size: clamp(2.25rem, 5vw, 4.85rem); line-height: 1.02; letter-spacing: -.045em; color: white; }
.p6-hero h1 span { display: block; margin-top: .7rem; font-size: clamp(2rem, 4.6vw, 4.3rem); line-height: 1.4; letter-spacing: 0; color: #ffdf91; }
.p6-lead { max-width: 780px; margin: 1.2rem 0 0; font-size: clamp(1rem, 1.8vw, 1.18rem); line-height: 1.75; color: #ead3f4; }
.p6-skill-pills { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: 1.35rem; }
.p6-skill-pills span { border: 1px solid rgba(255,255,255,.28); background: rgba(255,255,255,.08); border-radius: 999px; padding: .42rem .78rem; font-size: .84rem; font-weight: 800; }
.p6-hero-card { padding: 1.5rem; border: 1px solid rgba(255,255,255,.24); background: rgba(255,255,255,.1); backdrop-filter: blur(8px); border-radius: var(--d4-radius); box-shadow: 0 20px 50px rgba(0,0,0,.16); }
.p6-hero-card__icon { display: block; font-size: 3rem; margin-bottom: .55rem; }
.p6-hero-card strong { display: block; font-size: 1.2rem; }
.p6-hero-card p { color: #e8f7f4; line-height: 1.65; }
.p6-hero-card a { display: inline-flex; background: #ffda82; color: #153643; font-weight: 900; padding: .75rem 1rem; border-radius: 12px; text-decoration: none; }

.p6-jump { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--d4-line); box-shadow: 0 8px 24px rgba(20,55,63,.06); }
.p6-jump .p6-container { display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: thin; padding-block: .55rem; }
.p6-jump a { flex: 0 0 auto; color: var(--d4-ink-2); font-weight: 800; font-size: .86rem; text-decoration: none; border-radius: 9px; padding: .55rem .68rem; }
.p6-jump a:hover { background: var(--d4-mist); color: var(--d4-teal-dark); }

.p6-section { padding: clamp(3rem, 6vw, 5.6rem) 0; scroll-margin-top: 75px; }
.p6-section--soft { background: linear-gradient(180deg, #eff9d3 0%, #f8fcfb 100%); border-block: 1px solid #dcebe7; }
.p6-section--ink { background: linear-gradient(145deg, #173e49, #102d3b); color: white; }
.p6-section-heading { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: 1.8rem; }
.p6-section-heading > span { flex: 0 0 auto; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--d4-teal); color: white; font-weight: 950; box-shadow: 0 8px 20px rgba(8,127,115,.24); }
.p6-section-heading p { margin: 0 0 .3rem; color: var(--d4-teal-dark); font-weight: 900; text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; }
.p6-section-heading h2 { margin: 0; font-size: clamp(1.75rem, 3.4vw, 3rem); line-height: 1.12; letter-spacing: -.025em; color: var(--d4-ink); }
.p6-section-heading div > p:last-child { margin-top: .55rem; text-transform: none; letter-spacing: 0; font-size: 1rem; font-weight: 500; color: #4c696f; line-height: 1.6; }
.p6-section-heading--light h2, .p6-section-heading--light p { color: white; }
.p6-section-heading--light div > p:last-child { color: #d8eae9; }

.p6-two-col, .p6-speaking-grid, .p6-writing-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.p6-panel { background: white; border: 1px solid var(--d4-line); border-radius: var(--d4-radius); padding: clamp(1.2rem, 3vw, 1.8rem); box-shadow: var(--d4-shadow); }
.p6-panel h3 { margin-top: 0; font-size: 1.25rem; color: var(--d4-ink); }
.p6-panel ul { padding-left: 1.25rem; line-height: 1.7; }
.p6-panel--goal { border-top: 6px solid var(--d4-teal); }
.p6-panel--success { border-top: 6px solid var(--d4-gold); }
.p6-checklist { list-style: none; padding: 0 !important; }
.p6-checklist label { display: flex; gap: .7rem; align-items: flex-start; padding: .38rem 0; cursor: pointer; }
.p6-checklist input { width: 1.15rem; height: 1.15rem; margin-top: .18rem; accent-color: var(--d4-teal); }
.p6-mini-status { font-size: .88rem; color: #5b7378; }

.p6-retrieval { margin-top: 1.5rem; border: 1px solid #e7d4a8; background: linear-gradient(135deg, #fff8e7, #fffdfa); border-radius: var(--d4-radius); padding: clamp(1.2rem, 3vw, 2rem); }
.p6-retrieval h3, .p6-final h3 { margin: 0 0 .4rem; font-size: 1.45rem; }
.p6-question-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1.2rem; }
.p6-question { min-width: 0; margin: 0; border: 1px solid #d7e3df; border-radius: 16px; background: white; padding: 1rem; }
.p6-question legend { width: 100%; padding: 0; font-weight: 850; line-height: 1.45; color: var(--d4-ink); }
.p6-question legend span { display: inline-grid; place-items: center; width: 27px; height: 27px; margin-right: .45rem; border-radius: 8px; background: var(--d4-mist); color: var(--d4-teal-dark); font-size: .8rem; }
.p6-options { display: grid; gap: .5rem; margin-top: .8rem; }
.p6-options label { display: flex; align-items: flex-start; gap: .55rem; padding: .62rem .68rem; border: 1px solid #d8e4e1; border-radius: 10px; cursor: pointer; line-height: 1.45; }
.p6-options label:hover { background: #f4faf8; }
.p6-options input { margin-top: .18rem; accent-color: var(--d4-teal); }
.p6-question.is-correct { border-color: #70b79b; box-shadow: 0 0 0 2px rgba(23,122,86,.08); }
.p6-question.is-incorrect { border-color: #d99891; box-shadow: 0 0 0 2px rgba(166,61,53,.07); }
.p6-feedback { min-height: 1.2em; margin: .65rem 0 0; font-size: .88rem; font-weight: 700; }
.p6-question.is-correct .p6-feedback { color: var(--d4-good); }
.p6-question.is-incorrect .p6-feedback { color: var(--d4-bad); }
.p6-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; margin-top: 1rem; }
.p6-actions button, .p6-vocab-toolbar button, .p6-writing-tools button, .p6-exit button { border: 0; border-radius: 11px; padding: .72rem 1rem; background: var(--d4-teal); color: white; font-weight: 900; cursor: pointer; }
.p6-actions button:hover, .p6-vocab-toolbar button:hover, .p6-writing-tools button:hover, .p6-exit button:hover { background: var(--d4-teal-dark); }
.p6-button-secondary { background: #e7f2ef !important; color: var(--d4-ink) !important; }
.p6-actions [data-quiz-score], .p6-actions [data-sorter-score] { font-weight: 950; background: white; border: 1px solid var(--d4-line); border-radius: 10px; padding: .62rem .8rem; color: var(--d4-ink); }

.p6-vocab-toolbar { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; justify-content: space-between; margin-bottom: 1.4rem; padding: .8rem 1rem; background: white; border: 1px solid var(--d4-line); border-radius: 14px; }
.p6-vocab-toolbar span { font-weight: 800; color: #527078; }
.p6-vocab-group + .p6-vocab-group { margin-top: 2rem; }
.p6-vocab-group h3 { margin: 0 0 .8rem; font-size: 1.2rem; color: var(--d4-ink); }
.p6-vocab-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .85rem; }
.p6-vocab-card { min-width: 0; padding: 1rem; background: white; border: 1px solid var(--d4-line); border-radius: 16px; box-shadow: 0 8px 22px rgba(25,72,78,.06); }
.p6-vocab-ar { font-size: clamp(1.35rem, 2vw, 1.7rem); line-height: 1.8; color: var(--d4-teal-dark); font-weight: 800; }
.p6-vocab-en { margin-top: .25rem; font-weight: 800; color: #405d64; }
.p6-vocab-card p { margin: .35rem 0 0; color: #657a80; font-size: .86rem; }
.p6-page.is-meanings-hidden [data-vocab-meaning] { visibility: hidden; }

.p6-pattern-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.p6-pattern { border: 1px solid var(--d4-line); border-left: 6px solid var(--d4-teal); border-radius: 16px; background: white; padding: 1.2rem; box-shadow: 0 10px 26px rgba(18,61,68,.07); }
.p6-pattern > div { font-size: clamp(1.45rem, 2.7vw, 2rem); line-height: 1.9; color: var(--d4-teal-dark); font-weight: 800; }
.p6-pattern strong { display: block; margin-top: .3rem; }
.p6-pattern p { color: #5b7479; line-height: 1.55; }
.p6-teaching-notes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; }
.p6-teaching-notes article { display: flex; gap: .8rem; align-items: flex-start; background: #fff8e9; border: 1px solid #ead7aa; border-radius: 15px; padding: 1rem; }
.p6-teaching-notes span { display: grid; flex: 0 0 auto; place-items: center; width: 29px; height: 29px; border-radius: 50%; background: var(--d4-gold); color: #2d3a20; font-weight: 900; }
.p6-teaching-notes p { margin: 0; line-height: 1.65; }

.p6-sorter { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.16); border-radius: var(--d4-radius); padding: 1.2rem; }
.p6-sort-item { border-bottom: 1px solid rgba(255,255,255,.13); padding: .75rem 0; }
.p6-sort-item label { display: grid; grid-template-columns: minmax(0, 1fr) minmax(200px, .55fr); gap: 1rem; align-items: center; }
.p6-sort-item label span { font-size: 1.3rem; line-height: 1.7; font-weight: 750; }
.p6-sort-item select { width: 100%; border: 1px solid #acc6c4; border-radius: 10px; padding: .65rem; background: white; color: var(--d4-ink); }
.p6-sort-item.is-correct select { border-color: #7ee0b2; }
.p6-sort-item.is-incorrect select { border-color: #ff9d92; }
.p6-sort-feedback { display: block; min-height: 1.1em; margin-top: .25rem; font-size: .86rem; }
.p6-section--ink .p6-actions [data-sorter-score] { color: var(--d4-ink); }

.p6-audio-note { display: flex; gap: 1rem; align-items: center; padding: 1rem 1.2rem; margin-bottom: 1rem; background: #fff8e8; border: 1px solid #ebd6a2; border-radius: 15px; }
.p6-audio-note > span { font-size: 2rem; }
.p6-audio-note p { margin: .25rem 0 0; color: #5c6260; }
.p6-assessment-block { padding: 1.1rem; background: white; border: 1px solid var(--d4-line); border-radius: var(--d4-radius); box-shadow: var(--d4-shadow); }
.p6-teacher { margin-top: 1rem; border: 1px solid #d5e2df; border-radius: 14px; background: white; }
.p6-teacher summary { cursor: pointer; padding: 1rem; font-weight: 900; color: var(--d4-teal-dark); }
.p6-teacher > div { padding: 0 1rem 1rem; }
.p6-teacher blockquote { margin: .8rem 0 0; border-right: 5px solid var(--d4-teal); background: #f3faf8; border-radius: 12px; padding: 1rem 1.2rem; font-size: 1.35rem; line-height: 2.1; }
.p6-reading-text { margin-bottom: 1rem; background: white; border: 1px solid var(--d4-line); border-right: 7px solid var(--d4-coral); border-radius: var(--d4-radius); padding: clamp(1.25rem, 3vw, 2rem); font-size: clamp(1.25rem, 2.4vw, 1.65rem); line-height: 2.2; box-shadow: var(--d4-shadow); }

.p6-ar-list { font-size: 1.2rem; line-height: 2; padding-right: 1.5rem; }
.p6-dialogue { display: grid; gap: .7rem; }
.p6-dialogue > div { position: relative; padding: .8rem .9rem .8rem 3.1rem; background: #f2f8d3; border-radius: 12px; }
.p6-dialogue > div > span { position: absolute; left: .8rem; top: .8rem; display: grid; place-items: center; width: 30px; height: 30px; background: var(--d4-teal); color: white; border-radius: 50%; font-weight: 900; }
.p6-dialogue p { margin: 0; font-size: 1.22rem; line-height: 1.8; color: var(--d4-ink); }
.p6-dialogue small { display: block; color: #62777c; }
.p6-speaking-ladder { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .65rem; margin-top: 1rem; }
.p6-speaking-ladder label { display: flex; gap: .55rem; align-items: flex-start; padding: .8rem; border: 1px solid var(--d4-line); border-radius: 12px; background: white; font-weight: 700; }
.p6-speaking-ladder input { margin-top: .15rem; accent-color: var(--d4-teal); }

.p6-writing-box { background: #173d49; color: white; border-radius: var(--d4-radius); padding: 1.2rem; box-shadow: var(--d4-shadow); }
.p6-writing-box > label { display: block; margin-bottom: .55rem; font-weight: 900; }
.p6-writing-box textarea { width: 100%; resize: vertical; min-height: 300px; border: 2px solid transparent; border-radius: 14px; background: #fff; color: #17343d; padding: 1rem; font-size: 1.3rem; line-height: 2; }
.p6-writing-box textarea:focus { border-color: #ffcd39; }
.p6-writing-tools { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; margin-top: .7rem; }
.p6-writing-tools span { margin-right: auto; }
.p6-writing-tools .p6-button-secondary { background: rgba(255,255,255,.16) !important; color: white !important; }
.p6-writing-box [data-writing-status] { color: #d9ebe9; font-size: .86rem; }
.p6-writing-model { font-size: 1.25rem; line-height: 2; }
.p6-panel details { margin-top: 1rem; border-top: 1px solid var(--d4-line); padding-top: .8rem; }
.p6-panel summary { cursor: pointer; font-weight: 900; color: var(--d4-teal-dark); }

.p6-mistake-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.p6-mistake-grid article { border: 1px solid var(--d4-line); border-radius: 16px; padding: 1rem; background: white; }
.p6-wrong, .p6-right { font-size: 1.16rem; line-height: 1.8; border-radius: 10px; padding: .62rem .75rem; }
.p6-wrong { background: #fff0ee; color: #8d342e; text-decoration: line-through; text-decoration-thickness: 2px; }
.p6-right { background: #eaf8f1; color: #126946; font-weight: 800; }
.p6-diff-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin: 1.2rem 0; }
.p6-diff-grid article { border-radius: 16px; padding: 1.1rem; background: #edf8d3; border: 1px solid var(--d4-line); }
.p6-diff-grid article:nth-child(2) { background: #fff8e8; border-color: #e7d5a8; }
.p6-diff-grid article:nth-child(3) { background: #f2eefb; border-color: #d9cdef; }
.p6-diff-grid span { display: inline-block; font-weight: 950; text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; }
.p6-diff-grid p { margin-bottom: 0; line-height: 1.6; }
.p6-final { margin-top: 1.5rem; padding: clamp(1.25rem, 3vw, 2rem); border-radius: var(--d4-radius); background: linear-gradient(135deg, #153c48, #0d645f); color: white; box-shadow: var(--d4-shadow); }
.p6-final__header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.p6-final__header > span { border: 1px solid rgba(255,255,255,.25); border-radius: 999px; padding: .45rem .75rem; font-weight: 850; }
.p6-final .p6-question { color: var(--d4-ink); }
.p6-next-step { margin: 1rem 0 0; padding: .8rem 1rem; background: rgba(255,255,255,.12); border-radius: 12px; font-weight: 800; }
.p6-exit { display: grid; grid-template-columns: minmax(200px,.8fr) minmax(220px,1fr) minmax(220px,1fr) auto; gap: .8rem; align-items: end; margin: 1.25rem 0 2rem; padding: 1.1rem; border: 1px solid #e4d09a; background: #fff8e6; border-radius: 16px; }
.p6-exit h3 { margin: 0; }
.p6-exit p { margin: .25rem 0 0; font-size: .88rem; }
.p6-exit label { display: grid; gap: .35rem; font-weight: 800; font-size: .87rem; }
.p6-exit input { width: 100%; border: 1px solid #cbbd9a; border-radius: 9px; padding: .65rem; }
.p6-exit > span { grid-column: 1 / -1; font-size: .86rem; color: #536a6e; }

/* D4 assessment */
.p6-assessment-hero { background: linear-gradient(135deg, #123947, #712f33); }
.p6-scoreboard { display: grid; grid-template-columns: 230px minmax(0,1fr); gap: 1.3rem; align-items: center; background: #fff; border: 1px solid var(--d4-line); border-radius: var(--d4-radius); padding: 1.3rem; box-shadow: var(--d4-shadow); }
.p6-total-ring { width: 190px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; margin-inline: auto; background: conic-gradient(var(--d4-teal) calc(var(--score,0) * 1%), #dfecea 0); position: relative; }
.p6-total-ring::before { content: ""; position: absolute; inset: 15px; background: white; border-radius: 50%; }
.p6-total-ring > div { position: relative; text-align: center; }
.p6-total-ring strong { display: block; font-size: 2.5rem; color: var(--d4-ink); }
.p6-total-ring span { color: #597076; font-weight: 800; }
.p6-skill-bars { display: grid; gap: .8rem; }
.p6-skill-row { display: grid; grid-template-columns: 90px 1fr 55px; gap: .7rem; align-items: center; }
.p6-skill-row strong { font-size: .9rem; }
.p6-skill-track { height: 12px; background: #e2ecea; border-radius: 999px; overflow: hidden; }
.p6-skill-fill { width: calc(var(--skill,0) * 1%); height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--d4-teal), #44a78f); }
.p6-mark-entry { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1rem; }
.p6-mark-entry label { display: grid; gap: .45rem; font-weight: 850; }
.p6-mark-entry input { width: 100%; padding: .7rem; border: 1px solid var(--d4-line); border-radius: 10px; }
.p6-assessment-tools { display: flex; flex-wrap: wrap; gap: .7rem; margin: 1rem 0; }
.p6-assessment-tools button { border: 0; border-radius: 10px; padding: .7rem 1rem; font-weight: 900; cursor: pointer; }
.p6-mark-rubric { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .75rem; }
.p6-mark-rubric article { padding: .85rem; border: 1px solid var(--d4-line); border-radius: 12px; background: #f8fbfa; }

@media (max-width: 980px) {
  .p6-hero__grid, .p6-scoreboard { grid-template-columns: 1fr; }
  .p6-vocab-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .p6-speaking-ladder { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .p6-exit { grid-template-columns: 1fr 1fr; }
  .p6-exit > div, .p6-exit button { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .p6-container { width: min(100% - 1.1rem, 1180px); }
  .p6-hero { padding-block: 2.6rem; }
  .p6-hero__grid, .p6-two-col, .p6-speaking-grid, .p6-writing-layout, .p6-question-grid, .p6-pattern-grid, .p6-teaching-notes, .p6-mistake-grid, .p6-diff-grid, .p6-mark-entry, .p6-mark-rubric { grid-template-columns: 1fr; }
  .p6-vocab-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .p6-sort-item label { grid-template-columns: 1fr; gap: .25rem; }
  .p6-section-heading > span { width: 40px; height: 40px; }
  .p6-final__header { display: block; }
  .p6-final__header > span { display: inline-block; margin-top: .7rem; }
  .p6-exit { grid-template-columns: 1fr; }
  .p6-exit > * { grid-column: auto !important; }
}
@media (max-width: 440px) {
  .p6-vocab-grid, .p6-speaking-ladder { grid-template-columns: 1fr; }
  .p6-code-row { align-items: flex-start; }
  .p6-reading-text, .p6-teacher blockquote { font-size: 1.16rem; }
}
@media (prefers-reduced-motion: reduce) {
  .p6-page *, .p6-page *::before, .p6-page *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
@media print {
  .p6-jump, .p6-actions, .p6-vocab-toolbar, .p6-writing-tools, .p6-exit button, .site-header, .site-footer { display: none !important; }
  .p6-section { padding: 1rem 0; break-inside: avoid; }
  .p6-hero { background: white !important; color: #111 !important; padding: 1rem 0; }
  .p6-hero h1, .p6-hero h1 span, .p6-lead, .p6-eyebrow { color: #111 !important; }
  .p6-hero-card { border: 1px solid #aaa; box-shadow: none; }
  .p6-panel, .p6-assessment-block, .p6-reading-text, .p6-final { box-shadow: none; }
  .p6-final { background: white; color: #111; border: 1px solid #aaa; }
}

/* V58 consistency correction: align D4 with the established F1–F4 lesson shell. */
.p6-page {
  margin: 0;
  font-family: Nunito, "Segoe UI", Arial, sans-serif;
  line-height: 1.65;
  color: #263746;
  background: #fffaf2;
}
.p6-page [lang="ar"],
.p6-page .arabic,
.p6-page .p6-vocab-ar {
  font-family: Amiri, "Noto Naskh Arabic", "Traditional Arabic", serif;
}
.p6-page h1,
.p6-page h2,
.p6-page h3,
.p6-page h4,
.p6-page button,
.p6-page input,
.p6-page select,
.p6-page textarea,
.p6-page label,
.p6-page legend {
  font-family: Nunito, "Segoe UI", Arial, sans-serif;
}
.p6-page [lang="ar"] {
  font-family: Amiri, "Noto Naskh Arabic", "Traditional Arabic", serif;
}
.p6-lesson-nav {
  position: sticky;
  top: 72px;
  z-index: 1500;
  color: #fff;
  background: #17324d;
  border-bottom: 3px solid #f2b84b;
}
.p6-lesson-nav > .p6-container {
  min-height: 55px;
  display: flex;
  align-items: center;
  gap: 7px;
  overflow-x: auto;
  padding-block: 8px;
}
.p6-lesson-nav a {
  flex: 0 0 auto;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 6px 11px;
  color: #fff;
  border: 1px solid rgba(255,255,255,.34);
  border-radius: 999px;
  text-decoration: none;
  font-size: .8rem;
  font-weight: 800;
}
.p6-lesson-nav a:hover,
.p6-lesson-nav a:focus-visible {
  color: #17324d;
  background: #f2b84b;
  border-color: #f2b84b;
}
.p6-vocab-count {
  margin: 0 0 1.25rem;
  padding: .8rem 1rem;
  color: #405d64;
  background: #fff;
  border: 1px solid #cfe0dc;
  border-radius: 14px;
  font-weight: 700;
}
.p6-vocab-count strong { color: #17324d; }
.p6-language-notes {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.p6-language-notes article {
  display: flex;
  gap: .8rem;
  align-items: flex-start;
  padding: 1rem;
  color: #263746;
  background: #fff8e9;
  border: 1px solid #ead7aa;
  border-radius: 15px;
}
.p6-language-notes span {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 29px;
  height: 29px;
  color: #17324d;
  background: #f2b84b;
  border-radius: 50%;
  font-weight: 900;
}
.p6-language-notes p { margin: 0; color: #263746; }

/* Keep each prompt inside its own card; no fieldset legend overlaps the edge. */
.p6-question {
  display: block;
  min-inline-size: 0;
  margin: 0;
  padding: 1rem;
  color: #263746;
  background: #fff;
  border: 0;
  border-radius: 16px;
  box-shadow: inset 0 0 0 1px #cfdcdf, 0 7px 18px rgba(23,50,77,.06);
}
.p6-question legend {
  float: left;
  width: 100%;
  max-width: 100%;
  margin: 0 0 .8rem;
  padding: 0;
  color: #17324d;
  font-weight: 850;
  line-height: 1.5;
}
.p6-question legend + * { clear: both; }
.p6-options {
  clear: both;
  display: grid;
  gap: .55rem;
  margin-top: .2rem;
}
.p6-options label {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .7rem .8rem;
  color: #17324d;
  background: #fff;
  border: 2px solid #a8b8c4;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 750;
}
.p6-options label:hover,
.p6-options label:focus-within {
  background: #eef8d3;
  border-color: #45a995;
}
.p6-options input {
  flex: 0 0 auto;
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
}
.p6-question.is-correct { box-shadow: inset 0 0 0 2px #4c956c; }
.p6-question.is-incorrect { box-shadow: inset 0 0 0 2px #b65a52; }

/* Explicit contrast on dark practice and final-check areas. */
.p6-section--ink,
.p6-section--ink p,
.p6-section--ink label,
.p6-section--ink .p6-sort-item label span,
.p6-section--ink .p6-sort-feedback { color: #fff; }
.p6-section--ink .p6-section-heading h2,
.p6-section--ink .p6-section-heading p,
.p6-section--ink .p6-section-heading div > p:last-child { color: #fff; }
.p6-sorter { background: rgba(255,255,255,.11); border-color: rgba(255,255,255,.34); }
.p6-sort-item { border-bottom-color: rgba(255,255,255,.25); }
.p6-sort-item select { color: #17324d; background: #fff; border-color: #8ea8b2; }
.p6-final,
.p6-final p,
.p6-final h3 { color: #fff; }
.p6-final .p6-question,
.p6-final .p6-question legend,
.p6-final .p6-options label,
.p6-final .p6-feedback { color: #17324d; }
.p6-audio-note strong { color: #17324d; }
.p6-audio-note p { color: #4c5c63; }
.p6-panel,
.p6-assessment-block,
.p6-reading-text,
.p6-retrieval,
.p6-mistake-grid article,
.p6-diff-grid article { color: #263746; }

/* The three-route writing tool occupies the second column and completion spans both. */
#d4-writing-activity > .f1-writing-access { min-width: 0; margin: 0; }
#d4-writing-activity > .mu-manual-completion { grid-column: 1 / -1; }
#d4-writing-activity .p6-writing-box { margin: 0; }
#d4-writing-activity .f1-writing-access__panel { min-width: 0; }
.p6-exit > .mu-manual-completion { grid-column: 1 / -1; }

@media (max-width: 720px) {
  .p6-language-notes { grid-template-columns: 1fr; }
  .p6-question-grid { grid-template-columns: 1fr; }
  .p6-options label { border-radius: 14px; }
}

@media print {
}

/* D4-L12 three-route assessment writing and compact form layout. */
.p6-clinic-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .9rem;
}
.p6-clinic-fields label {
  min-width: 0;
  display: grid;
  gap: .4rem;
  color: #17324d;
  font-family: Amiri, "Noto Naskh Arabic", "Traditional Arabic", serif;
  font-size: 1.15rem;
  font-weight: 800;
}
.p6-clinic-fields label:last-child { grid-column: 1 / -1; }
.p6-clinic-fields input,
.p6-mark-entry input {
  min-width: 0;
  color: #17324d;
  background: #fff;
  border: 2px solid #a8b8c4;
}
#d4-clinic-form-activity > .f1-writing-access,
#d4-article-writing-activity > .f1-writing-access {
  min-width: 0;
}
#d4-clinic-form-activity .f1-writing-access__panel,
#d4-article-writing-activity .f1-writing-access__panel {
  min-width: 0;
}
#d4-article-writing-activity .p6-article-entry { margin: 0; }
#d4-clinic-form-activity > .mu-manual-completion,
#d4-article-writing-activity > .mu-manual-completion { margin-top: 1rem; }

@media (max-width: 720px) {
  .p6-clinic-fields { grid-template-columns: 1fr; }
  .p6-clinic-fields label:last-child { grid-column: auto; }
}

/* Preserve contrast for labels inside dark D4 writing panels. */
.p6-writing-box > label,
.p6-writing-box .p6-article-entry > label {
  color: #fff;
}

/* Final contrast corrections for dialogue captions and D4-L12 generated writing panels. */
.p6-dialogue small { color: #52676d; }
#d4-article-writing-activity .p6-article-entry > label { color: #17324d; }
#d4-article-writing-activity > .mu-manual-completion span { color: #e2f1ef; }

/* V59 — F3/F4-aligned pedagogical architecture */
.p6-heading-ar {
  margin: .35rem 0 .55rem;
  font-family: "Amiri", serif;
  font-size: clamp(1.6rem, 3.2vw, 2.35rem);
  line-height: 1.65;
  color: var(--d4-teal-dark);
  font-weight: 700;
}
.p6-pattern-grid--recap { margin-bottom: 1.4rem; }
.p6-grammar-rule-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.p6-grammar-rule {
  border: 1px solid var(--d4-line);
  border-radius: 18px;
  background: #fff;
  padding: 1.2rem;
  box-shadow: 0 12px 30px rgba(18,61,68,.07);
}
.p6-grammar-rule header {
  display: flex;
  align-items: flex-start;
  gap: .8rem;
  margin-bottom: .7rem;
}
.p6-grammar-rule header > span {
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--d4-gold);
  color: #173650;
  font-weight: 900;
}
.p6-grammar-rule h3 { margin: 0; color: var(--d4-ink); }
.p6-grammar-rule > p { color: #405d36; line-height: 1.65; }
.p6-grammar-formula {
  margin: .25rem 0 0;
  font-family: "Amiri", serif;
  font-size: 1.35rem;
  color: var(--d4-teal-dark);
  font-weight: 700;
}
.p6-example-stack { display: grid; gap: .45rem; margin-top: .8rem; }
.p6-example-stack span {
  display: block;
  border-radius: 10px;
  background: #eef8d3;
  border-right: 4px solid var(--d4-teal);
  padding: .62rem .78rem;
  font-family: "Amiri", serif;
  font-size: 1.25rem;
  line-height: 1.7;
  color: #123d42;
}
.p6-grammar-table-wrap {
  margin-top: 1.2rem;
  overflow-x: auto;
  border: 1px solid var(--d4-line);
  border-radius: 16px;
  background: #fff;
}
.p6-grammar-table { width: 100%; border-collapse: collapse; min-width: 620px; }
.p6-grammar-table th {
  background: #173a57;
  color: #fff;
  text-align: left;
  padding: .85rem 1rem;
  font-weight: 850;
}
.p6-grammar-table td {
  padding: .85rem 1rem;
  border-top: 1px solid #dce7e4;
  vertical-align: top;
  color: #244951;
}
.p6-grammar-table td[lang="ar"] {
  font-family: "Amiri", serif;
  font-size: 1.15rem;
  line-height: 1.6;
  text-align: right;
}
.p6-common-error {
  margin: 1rem 0 1.2rem;
  border: 1px solid #efc4b8;
  border-left: 6px solid #dc755f;
  border-radius: 14px;
  background: #fff4ef;
  padding: 1rem 1.1rem;
}
.p6-common-error strong { color: #8b342b; }
.p6-common-error p { margin: .3rem 0 0; color: #613f3a; line-height: 1.6; }
.p6-activity-intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .6rem;
}
.p6-activity-intro h3 { margin: .1rem 0 0; }
.p6-activity-intro > span {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #173a57;
  color: #fff;
  padding: .45rem .75rem;
  font-weight: 800;
}
.p6-builder-list { display: grid; gap: 1.15rem; }
.p6-builder-card {
  border: 1px solid var(--d4-line);
  border-radius: 18px;
  background: #fff;
  padding: 1.15rem;
  box-shadow: 0 12px 30px rgba(18,61,68,.07);
}
.p6-builder-card > header { display: flex; gap: .8rem; align-items: flex-start; }
.p6-builder-card > header > span {
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--d4-teal);
  color: #fff;
  font-weight: 900;
}
.p6-builder-card header strong { color: var(--d4-ink); }
.p6-builder-card header p { margin: .25rem 0 .8rem; color: #42646b; }
.p6-builder-groups {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .7rem;
}
.p6-builder-groups fieldset { min-width: 0; border: 0; padding: 0; margin: 0; }
.p6-builder-groups legend { font-size: .78rem; color: #5b757b; font-weight: 850; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .35rem; }
.p6-builder-options { display: grid; gap: .42rem; }
.p6-builder-options label { cursor: pointer; }
.p6-builder-options input { position: absolute; opacity: 0; pointer-events: none; }
.p6-builder-options span {
  display: grid;
  min-height: 58px;
  place-items: center;
  border: 1px solid #cbded8;
  border-radius: 12px;
  background: #f7fbfa;
  padding: .55rem;
  font-family: "Amiri", serif;
  font-size: 1.15rem;
  line-height: 1.55;
  color: #174d30;
  text-align: center;
}
.p6-builder-options input:checked + span {
  background: #dff4ed;
  border-color: var(--d4-teal);
  box-shadow: inset 0 0 0 2px rgba(18,137,117,.18);
}
.p6-builder-options input:focus-visible + span { outline: 3px solid rgba(242,183,61,.55); outline-offset: 2px; }
.p6-builder-preview {
  margin-top: .85rem;
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: #173a57;
  color: #fff;
  padding: .75rem 1rem;
  font-family: "Amiri", serif;
  font-size: 1.35rem;
  line-height: 1.8;
  text-align: center;
}
.p6-builder-card.is-correct { border-color: #57a786; box-shadow: inset 0 0 0 2px rgba(45,143,105,.16); }
.p6-builder-card.is-incorrect { border-color: #d98a7c; box-shadow: inset 0 0 0 2px rgba(183,72,61,.11); }
.p6-builder-total { margin: 0; font-weight: 850; color: var(--d4-teal-dark); }
.p6-script-disclosure {
  margin-top: 1rem;
  border: 1px solid var(--d4-line);
  border-radius: 15px;
  background: #fff;
  overflow: hidden;
}
.p6-script-disclosure summary {
  cursor: pointer;
  padding: 1rem 1.1rem;
  background: #173a57;
  color: #fff;
  font-weight: 850;
}
.p6-script-content { padding: 1.2rem; }
.p6-script-content p {
  margin: 0;
  font-family: "Amiri", serif;
  font-size: 1.35rem;
  line-height: 2;
  color: #173f45;
}
.p6-answer-key { margin: 0; padding: 1rem 2.2rem 1.2rem; }
.p6-answer-key li { padding: .4rem 0; line-height: 1.55; color: #284d55; }
.p6-answer-key li span { display: block; color: #60777c; font-size: .9rem; }

/* The shared lesson menu must remain available on small screens. */
@media (max-width: 760px) {
  .p6-grammar-rule-grid, .p6-builder-groups { grid-template-columns: 1fr; }
  .p6-activity-intro { display: block; }
  .p6-activity-intro > span { display: inline-block; margin-top: .55rem; }
}

/* Shared F2–F4 lesson-section menu, reused by D4 */
.n2-container { width: min(calc(100% - 32px), 1160px); margin-inline: auto; }
.n2-lesson-nav { position: sticky; top: 68px; z-index: 75; background: #17324d; border-bottom: 3px solid #f2b84b; }
.n2-nav-scroll { display: flex; gap: 7px; overflow-x: auto; padding: 10px 0; scrollbar-width: thin; }
.n2-nav-scroll a { display: inline-flex; align-items: center; min-height: 44px; padding: 5px 12px; border: 1px solid rgba(255,255,255,.25); border-radius: 999px; color: #fff; text-decoration: none; white-space: nowrap; font-size: .82rem; font-weight: 900; }
.n2-nav-scroll a:hover, .n2-nav-scroll a:focus-visible { background: #f2b84b; color: #17324d; outline: none; }
@media (max-width: 760px) { .n2-lesson-nav { top: 64px; } .n2-nav-scroll { padding-inline: 2px; } }
@media print { .n2-lesson-nav { display: none !important; } }


/* V60: restored F3/F4 pedagogical depth */
.p6-vocab-toolbar{display:flex;align-items:center;justify-content:space-between;gap:1rem;flex-wrap:wrap;margin-bottom:1rem}.p6-vocab-toolbar button,.p6-random-prompt button{border:0;border-radius:999px;background:#173a57;color:#fff;padding:.7rem 1rem;font:inherit;font-weight:850;cursor:pointer}.is-meanings-hidden [data-vocab-meaning]{filter:blur(7px);user-select:none}.p6-grammar-path,.p6-strategy-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:.85rem;margin:0 0 1.15rem}.p6-strategy-grid{grid-template-columns:repeat(3,minmax(0,1fr))}.p6-grammar-path article,.p6-strategy-grid article{border:1px solid var(--d4-line);border-radius:15px;background:#fff;padding:1rem;box-shadow:0 10px 22px rgba(18,61,68,.06)}.p6-grammar-path span,.p6-strategy-grid span{display:grid;place-items:center;width:30px;height:30px;border-radius:50%;background:var(--d4-gold);color:#173650;font-weight:900;margin-bottom:.5rem}.p6-grammar-path strong,.p6-strategy-grid strong{color:var(--d4-ink)}.p6-grammar-path p,.p6-strategy-grid p{margin:.3rem 0 0;color:#506c72;line-height:1.55}.p6-live-builder{display:grid;grid-template-columns:minmax(280px,.85fr) minmax(360px,1.25fr);gap:1rem;border:1px solid #d8e2df;border-radius:20px;background:linear-gradient(135deg,#fffdd3,#f4faf8);padding:1.2rem;margin-bottom:1.2rem;box-shadow:0 16px 36px rgba(18,61,68,.08)}.p6-live-builder__controls{display:grid;gap:.65rem}.p6-live-builder__controls h3{margin:.1rem 0 .4rem}.p6-live-builder__controls label{display:grid;gap:.35rem;font-weight:850;color:#173650}.p6-live-builder__controls select{width:100%;padding:.75rem;border:1px solid #cbdad7;border-radius:11px;background:#fff;font:inherit}.p6-live-builder__output{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:.75rem;min-height:300px;border:2px dashed #94b5be;border-radius:18px;background:#fff;padding:1.2rem;text-align:center}.p6-live-builder__output>span{border-radius:999px;background:#e2f2ed;color:#164a4d;padding:.4rem .7rem;font-weight:900;text-transform:uppercase;font-size:.75rem;letter-spacing:.04em}.p6-live-builder__output p{font-family:"Amiri",serif;font-size:clamp(1.5rem,3vw,2.1rem);line-height:1.9;color:#173a57}.p6-live-builder__output button{border:1px solid #173a57;border-radius:999px;background:#173a57;color:#fff;padding:.65rem 1rem;font:inherit;font-weight:850;cursor:pointer}.p6-live-builder__output .p6-button-secondary{background:#fff;color:#173a57}.p6-live-builder.is-correct{border-color:#4ca07f;box-shadow:inset 0 0 0 3px rgba(52,149,111,.12)}.p6-live-builder.is-incorrect{border-color:#d98778}.p6-inline-script{margin-top:.85rem;padding-top:.2rem}.p6-plan-strip{display:grid;grid-template-columns:repeat(3,1fr);gap:.55rem;margin:1rem 0}.p6-plan-strip span{border-radius:10px;background:#e9d3f1;padding:.75rem;text-align:center;color:#174d30;font-weight:850}.p6-random-prompt{margin-top:1rem;border-top:1px solid #d8e4e0;padding-top:1rem}.p6-random-prompt p{min-height:70px;border-radius:12px;background:#edf7f4;padding:1rem;font-family:"Amiri",serif;font-size:1.35rem;line-height:1.8;color:#174d30}.p6-section .p6-assessment-block{margin-top:1.2rem}.p6-question-grid{align-items:stretch}.p6-question{height:100%}.p6-question legend{width:100%}.p6-options label{border:1px solid #cfdbd8!important;background:#fff!important}.p6-options label:hover{border-color:#6a9d96!important;background:#f4faf8!important}.p6-writing-layout{gap:1.2rem}.p6-writing-box{min-height:100%}
@media(max-width:900px){.p6-grammar-path{grid-template-columns:repeat(2,minmax(0,1fr))}.p6-live-builder{grid-template-columns:1fr}.p6-strategy-grid{grid-template-columns:1fr}.p6-live-builder__output{min-height:230px}}@media(max-width:620px){.p6-grammar-path,.p6-plan-strip{grid-template-columns:1fr}}


/* V60 assessment enrichment and continuity with F3/F4 */
.p6-language-vault{display:grid;gap:.7rem}.p6-vault-group{border:1px solid var(--d4-line);border-radius:15px;background:#fff;overflow:hidden;box-shadow:0 8px 22px rgba(18,61,68,.05)}.p6-vault-group summary{display:flex;justify-content:space-between;gap:1rem;align-items:center;cursor:pointer;padding:.95rem 1rem;color:#173650;font-weight:850}.p6-vault-group summary strong{flex:0 0 auto;color:#21736a;font-size:.82rem}.p6-vault-content{padding:0 1rem 1rem}.p6-vault-content section+section{margin-top:1rem}.p6-vault-content h3{margin:.4rem 0 .55rem;color:#244b54;font-size:.95rem}.p6-vault-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:.55rem}.p6-vault-grid div{display:flex;flex-direction:column;gap:.2rem;border:1px solid #d7e4e0;border-radius:10px;background:#f8fbfa;padding:.65rem}.p6-vault-grid span{font-family:"Amiri",serif;font-size:1.15rem;color:#0d6a65}.p6-vault-grid small{color:#587177}.p6-subsection-heading{margin-top:1.7rem}.p6-assessment-page #grammar-review .p6-builder-list{margin-top:.8rem}
@media(max-width:900px){.p6-vault-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}@media(max-width:560px){.p6-vault-grid{grid-template-columns:1fr}.p6-vault-group summary{align-items:flex-start;flex-direction:column}}

/* D4 Development refinements: denser reading, longer Arabic texts, intermediate analysis. */
.p6-reading-text{font-size:1.34rem;line-height:2.15}.p6-grammar-rule p,.p6-panel p{max-width:80ch}.p6-hero-card strong{letter-spacing:.01em}.p6-vocab-card p{font-size:.82rem}

.p6-mission{background:linear-gradient(145deg,#fffaf0,#eefaf6);border:1px solid rgba(255,210,105,.6);border-radius:24px;padding:1.2rem;box-shadow:0 18px 46px rgba(5,34,58,.18);color:#102f4a}.p6-mission header{display:grid;grid-template-columns:auto 1fr auto;gap:1rem;align-items:center;border-bottom:1px solid #d9e5e3;padding-bottom:1rem}.p6-mission__icon{font-size:2.5rem}.p6-mission__stats{display:flex;gap:.5rem;flex-wrap:wrap;justify-content:flex-end}.p6-mission__stats span{background:#143a5a;color:white;border-radius:999px;padding:.35rem .65rem;font-weight:800}.p6-mission__stage{padding-top:1rem}.p6-mission__prompt{font-size:1.15rem;font-weight:850}.p6-mission__options{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:.7rem}.p6-mission__choice{background:white;color:#12334e;border:2px solid #aac2cf;border-radius:14px;padding:.9rem;font-weight:800;cursor:pointer}.p6-mission__choice:hover,.p6-mission__choice:focus{border-color:#f7b83b;transform:translateY(-1px)}.p6-mission__choice.is-correct{background:#daf6e9;border-color:#2aa77a}.p6-mission__choice.is-wrong{background:#ffe3de;border-color:#d86151}.p6-mission__feedback{min-height:2.3rem;font-weight:700;margin-top:.8rem}@media(max-width:680px){.p6-mission header{grid-template-columns:auto 1fr}.p6-mission__stats{grid-column:1/-1;justify-content:flex-start}}

/* V98 — D4 mission-game contrast and comprehension repair */
.p6-section--ink .p6-mission,
.p6-section--ink .p6-mission p,
.p6-section--ink .p6-mission label {
  color: #173650;
}

.p6-section--ink .p6-mission header strong {
  color: #12334e;
}

.p6-section--ink .p6-mission header p {
  color: #496571;
  margin: .25rem 0 0;
  line-height: 1.55;
}

.p6-section--ink .p6-mission__prompt {
  color: #102f4a;
  background: #fff7dc;
  border: 1px solid #ead08a;
  border-inline-start: 5px solid #f7b83b;
  border-radius: 14px;
  padding: .9rem 1rem;
  margin: 0 0 1rem;
  font-size: 1.15rem;
  font-weight: 850;
  line-height: 1.75;
}

.p6-section--ink .p6-mission__feedback {
  color: #173650;
  min-height: 0;
  margin-top: .85rem;
  border-radius: 12px;
  line-height: 1.55;
}

.p6-section--ink .p6-mission__feedback:not(:empty) {
  min-height: 2.3rem;
  padding: .75rem .9rem;
  border: 1px solid #bfd7d0;
  background: #eef8f5;
}

.p6-section--ink .p6-mission__feedback.is-correct {
  color: #14543f;
  background: #e1f6ec;
  border-color: #75b99e;
}

.p6-section--ink .p6-mission__feedback.is-wrong {
  color: #78342c;
  background: #fff0ed;
  border-color: #dda095;
}

.p6-section--ink .p6-mission__choice {
  color: #12334e;
  background: #fff;
}

.p6-section--ink .p6-mission__choice.is-correct {
  color: #124b39;
  background: #daf6e9;
}

.p6-section--ink .p6-mission__choice.is-wrong {
  color: #743229;
  background: #ffe3de;
}


/* V99 — full D4 contrast audit and Arabic-focused application challenges */
.p6-page { color: #20384a; }

/* Gold is decorative on dark heroes, never body text on white. */
.p6-kicker,
.p6-section:not(.p6-section--ink) .p6-kicker,
.p6-assessment-block .p6-kicker,
.p6-retrieval .p6-kicker {
  color: #6b4700 !important;
}
.p6-hero .p6-eyebrow,
.p6-final .p6-kicker,
.p6-section--ink > .p6-container > .p6-section-heading p {
  color: #ffe4a3 !important;
}

/* Dark, consistent teal/green text on all light surfaces. */
.p6-section:not(.p6-section--ink) .p6-section-heading p,
.p6-heading-ar,
.p6-vocab-ar,
.p6-grammar-formula,
.p6-panel summary,
.p6-builder-total,
.p6-vault-grid span,
.p6-vault-group summary strong {
  color: #075f5a !important;
}
.p6-section:not(.p6-section--ink) .p6-section-heading div > p:last-child,
.p6-vocab-card p,
.p6-vocab-en,
.p6-pattern p,
.p6-grammar-rule > p,
.p6-builder-card header p,
.p6-builder-groups legend,
.p6-dialogue small,
.p6-vault-grid small,
.p6-mini-status,
.p6-writing-box + p,
.mu-manual-completion > span,
#d4-article-writing-activity > .mu-manual-completion span {
  color: #455f68 !important;
}
.p6-builder-options span,
.p6-plan-strip span,
.p6-random-prompt p,
.p6-example-stack span {
  color: #17324d !important;
}

/* Keep controls and captions readable. */
.p6-button-secondary {
  color: #17324d !important;
  background: #edf4f2 !important;
  border: 1px solid #78929d !important;
}
.p6-writing-box .p6-button-secondary {
  color: #ffffff !important;
  background: #31586a !important;
  border-color: #ffffff !important;
}
.p6-writing-box [data-writing-status] { color: #e9f4f2 !important; }
.p6-options label,
.p6-builder-options span,
.p6-live-builder__controls label,
.p6-live-builder__output > span,
.p6-question legend,
.p6-assessment-block,
.p6-panel,
.p6-retrieval,
.p6-reading-text {
  color: #17324d;
}

/* Arabic application challenge: no inherited white text on the pale card. */
.p6-section--ink .p6-mission,
.p6-section--ink .p6-mission header,
.p6-section--ink .p6-mission header strong,
.p6-section--ink .p6-mission header p,
.p6-section--ink .p6-mission__stage,
.p6-section--ink .p6-mission__prompt,
.p6-section--ink .p6-mission__feedback,
.p6-section--ink .p6-mission label {
  color: #17324d !important;
}
.p6-mission {
  background: #fffdf7;
  border: 2px solid #d8bd73;
}
.p6-mission header p { color: #455f68 !important; }
.p6-mission__prompt {
  color: #102f4a !important;
  background: #fff4cf !important;
  border-color: #cda94e !important;
  border-inline-start-color: #a66b00 !important;
  font-size: 1.2rem;
  line-height: 1.85;
  unicode-bidi: plaintext;
}
.p6-mission__choice {
  color: #17324d !important;
  background: #ffffff !important;
  border-color: #6f8e9d !important;
  min-height: 58px;
  line-height: 1.65;
  unicode-bidi: plaintext;
}
.p6-mission__choice:hover,
.p6-mission__choice:focus-visible {
  color: #102f4a !important;
  background: #fff4cf !important;
  border-color: #9a6900 !important;
}
.p6-mission__choice:disabled { cursor: default; opacity: 1; }
.p6-mission__choice.is-correct {
  color: #124b39 !important;
  background: #dff4e9 !important;
  border-color: #257658 !important;
}
.p6-mission__choice.is-wrong {
  color: #742c25 !important;
  background: #fde4df !important;
  border-color: #a9473d !important;
}
.p6-mission__feedback.is-correct {
  color: #124b39 !important;
  background: #e3f5ec !important;
  border-color: #4f8e75 !important;
}
.p6-mission__feedback.is-wrong {
  color: #742c25 !important;
  background: #fff0ed !important;
  border-color: #b66a60 !important;
}

/* Avoid low-contrast gold and pale-green text in shared D4 badges. */
.p6-grammar-path span,
.p6-strategy-grid span,
.p6-teaching-notes span,
.p6-language-notes span {
  color: #17324d !important;
  background: #f2b84b !important;
}
.p6-vocab-toolbar span,
.p6-answer-key li span { color: #4a626a !important; }

@media (forced-colors: active) {
  .p6-mission, .p6-mission__prompt, .p6-mission__choice { border: 2px solid CanvasText; }
}

/* =========================================================
   V100 · D4-L12 full-width writing routes
   Keep every generated writing component inside the full
   available lesson container, including the reflection task.
   ========================================================= */
#d4-routine-form-activity > .f1-writing-access,
#d4-article-writing-activity > .f1-writing-access,
#d4-speaking-plan-activity > .f1-writing-access,
#d4-reflection-activity > .f1-writing-access {
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  min-width: 0;
  margin: 1.1rem 0;
}

#d4-routine-form-activity .f1-writing-access__panel,
#d4-article-writing-activity .f1-writing-access__panel,
#d4-speaking-plan-activity .f1-writing-access__panel,
#d4-reflection-activity .f1-writing-access__panel,
#d4-routine-form-activity [data-miftah-writing-type-content],
#d4-article-writing-activity [data-miftah-writing-type-content],
#d4-speaking-plan-activity [data-miftah-writing-type-content],
#d4-reflection-activity [data-miftah-writing-type-content],
#d4-routine-form-activity textarea,
#d4-routine-form-activity input,
#d4-article-writing-activity textarea,
#d4-article-writing-activity input,
#d4-speaking-plan-activity textarea,
#d4-speaking-plan-activity input,
#d4-reflection-activity textarea,
#d4-reflection-activity input,
#d4-routine-form-activity canvas,
#d4-article-writing-activity canvas,
#d4-speaking-plan-activity canvas,
#d4-reflection-activity canvas {
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  min-width: 0;
}

/* The reflection card previously used a four-column grid,
   which squeezed the generated writing interface into one cell. */
#d4-reflection-activity {
  display: block;
}

#d4-reflection-activity .p6-reflection-intro {
  margin-bottom: .9rem;
}

#d4-reflection-activity .p6-reflection-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  width: 100%;
  min-width: 0;
}

#d4-reflection-activity .p6-reflection-fields label {
  min-width: 0;
}

#d4-reflection-activity > [data-save-exit] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1rem;
}

#d4-reflection-activity > .mu-manual-completion {
  width: 100%;
  margin-top: 1rem;
}

#d4-routine-form-activity .f1-writing-access__tabs,
#d4-article-writing-activity .f1-writing-access__tabs,
#d4-speaking-plan-activity .f1-writing-access__tabs,
#d4-reflection-activity .f1-writing-access__tabs {
  width: 100%;
}

@media (max-width: 700px) {
  #d4-reflection-activity .p6-reflection-fields {
    grid-template-columns: 1fr;
  }

  #d4-routine-form-activity .f1-writing-access__tabs,
  #d4-article-writing-activity .f1-writing-access__tabs,
  #d4-speaking-plan-activity .f1-writing-access__tabs,
  #d4-reflection-activity .f1-writing-access__tabs {
    display: grid;
    grid-template-columns: 1fr;
  }

  #d4-routine-form-activity .f1-writing-access__tab,
  #d4-article-writing-activity .f1-writing-access__tab,
  #d4-speaking-plan-activity .f1-writing-access__tab,
  #d4-reflection-activity .f1-writing-access__tab {
    width: 100%;
  }
}

/* V112 D4 assessment writing routes */
#d4-profile-form-activity > .f1-writing-access,#d4-article-writing-activity > .f1-writing-access,#d4-speaking-plan-activity > .f1-writing-access,#d4-reflection-activity > .f1-writing-access{width:100%;max-width:none;min-width:0;box-sizing:border-box;grid-column:1/-1;margin-top:1rem}.p6-profile-fields,.p6-reflection-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:1rem;width:100%}.p6-profile-fields label,.p6-reflection-fields label{display:grid;gap:.35rem;font-weight:800}.p6-profile-fields input,.p6-reflection-fields input,.p6-article-entry textarea,.p6-speaking-plan textarea{width:100%;box-sizing:border-box}.p6-profile-fields label:last-child{grid-column:1/-1}@media(max-width:700px){.p6-profile-fields,.p6-reflection-fields{grid-template-columns:1fr}.p6-profile-fields label:last-child{grid-column:auto}}

/* V124 D4 assessment writing routes */
#d4-application-form-activity>.f1-writing-access,#d4-article-writing-activity>.f1-writing-access,#d4-speaking-plan-activity>.f1-writing-access,#d4-reflection-activity>.f1-writing-access{width:100%;max-width:none;min-width:0;box-sizing:border-box;grid-column:1/-1;margin-top:1rem}.p6-profile-fields,.p6-reflection-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:1rem;width:100%}.p6-profile-fields label,.p6-reflection-fields label{display:grid;gap:.35rem;font-weight:800}.p6-profile-fields input,.p6-reflection-fields input,.p6-article-entry textarea,.p6-speaking-plan textarea{width:100%;box-sizing:border-box}.p6-profile-fields label:last-child{grid-column:1/-1}@media(max-width:700px){.p6-profile-fields,.p6-reflection-fields{grid-template-columns:1fr}.p6-profile-fields label:last-child{grid-column:auto}}

/* D4 contrast hardening */
.p6-page .p6-panel,.p6-page .p6-question,.p6-page .p6-vocab-card,.p6-page .p6-builder-card,.p6-page .p6-assessment-block,.p6-page .p6-reading-text,.p6-page .p6-exit{color:#17324d;}
.p6-page .p6-section--soft,.p6-page .p6-section--soft *{--d4-text:#17324d;}
.p6-page .p6-vocab-en,.p6-page .p6-feedback,.p6-page .p6-panel p,.p6-page .p6-panel li,.p6-page .p6-question legend,.p6-page .p6-options span{color:#243b53;}
.p6-page .p6-section-heading p,.p6-page .p6-kicker{color:#8a4b08;}
.p6-page .p6-hero,.p6-page .p6-hero *{color:#fff;}
.p6-page .p6-hero h1 span{color:#ffdc8a;}
.p6-page .p6-hero-card{background:rgba(255,255,255,.13);border-color:rgba(255,255,255,.28);}
.p6-page .p6-hero-card a{background:#ffcc5c;color:#17324d;}
.p6-page .p6-script-content{background:#fff;color:#17324d;}
.p6-page .p6-script-content p{color:#17324d;}
.p6-page .p6-mission-card,.p6-page .p6-mission-card *{color:#17324d;}
.p6-page .p6-mission-feedback.is-correct{color:#0b6b4f;background:#e7f8f1;}
.p6-page .p6-mission-feedback.is-wrong{color:#9b2c2c;background:#fff0f0;}

/* V129: robust D4 grammar-schema and component contrast fixes. */
.p6-grammar-callouts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 1rem 0 1.25rem;
}
.p6-grammar-callouts .p6-common-error { margin: 0; }
.p6-stretch-note {
  border: 1px solid #c9d8a4;
  border-left: 6px solid #4f7f2f;
  border-radius: 14px;
  background: #f2f8df;
  padding: 1rem 1.1rem;
  color: #17324d;
}
.p6-stretch-note strong { color: #315f25; }
.p6-stretch-note p { margin: .3rem 0 0; color: #294236; line-height: 1.6; }
.p6-language-notes article > div { min-width: 0; }
.p6-language-notes strong { display: block; margin-bottom: .25rem; color: #17324d; }

/* Keep generated writing-route controls inside the full lesson container. */
#d4-writing-activity > .f1-writing-access {
  grid-column: 1 / -1;
  width: 100%;
  max-width: none;
  min-width: 0;
  box-sizing: border-box;
}
#d4-writing-activity .f1-writing-access__panel,
#d4-writing-activity [data-miftah-writing-type-content],
#d4-writing-activity canvas,
#d4-writing-activity textarea {
  width: 100%;
  max-width: none;
  min-width: 0;
  box-sizing: border-box;
}

@media (max-width: 720px) {
  .p6-grammar-callouts { grid-template-columns: 1fr; }
}


/* D4 V131 — combinatorial sentence-builder pedagogy */
.p6-builder-guidance,
.p6-builder-explanation,
.p6-builder-card header small,
.p6-builder-progress {
  color: #29465f;
  line-height: 1.6;
}
.p6-builder-guidance {
  margin: .6rem 0 1rem;
  padding: .75rem .9rem;
  border-left: 4px solid #d69300;
  background: #fff6d9;
  border-radius: .65rem;
}
.p6-builder-card header small {
  display: block;
  margin-top: .35rem;
  font-weight: 700;
}
.p6-builder-explanation {
  margin: .8rem 0 0;
  padding: .75rem .9rem;
  background: #eef8f5;
  border: 1px solid #9fcfc4;
  border-radius: .65rem;
}
.p6-builder-progress {
  margin: .7rem 0 0;
  font-weight: 800;
}


/* D4 V132 — purposeful builder sequence: transform, decide, produce */
.p6-builder-task > header { margin-bottom: 1rem; }
.p6-builder-task > header small { color: #29465f; line-height: 1.6; font-weight: 700; }
.p6-transform-source,
.p6-coherence-context {
  margin: 0 0 1rem;
  border: 1px solid #d6e2df;
  border-left: 5px solid #d69300;
  border-radius: 14px;
  background: #fff8df;
  padding: .9rem 1rem;
  color: #17324d;
}
.p6-transform-source > span,
.p6-coherence-context > span {
  display: block;
  margin-bottom: .35rem;
  color: #67500a;
  font-size: .76rem;
  font-weight: 900;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.p6-transform-source p {
  margin: .2rem 0 .55rem;
  font-family: "Amiri", serif;
  font-size: 1.45rem;
  line-height: 1.8;
  color: #173a57;
}
.p6-transform-source strong,
.p6-coherence-context p { color: #29465f; }
.p6-builder-choice-options { border: 0; padding: 0; margin: 0; }
.p6-builder-choice-options legend {
  margin-bottom: .65rem;
  color: #173650;
  font-weight: 900;
}
.p6-builder-choice-options label { display: block; margin: .5rem 0; cursor: pointer; }
.p6-builder-choice-options input { position: absolute; opacity: 0; pointer-events: none; }
.p6-builder-choice-options span {
  display: block;
  width: 100%;
  border: 1px solid #b8cdca;
  border-radius: 12px;
  background: #fff;
  padding: .8rem 1rem;
  color: #173a57;
  font-family: "Amiri", serif;
  font-size: 1.2rem;
  line-height: 1.75;
  text-align: right;
}
.p6-builder-choice-options input:checked + span {
  border-color: #087f70;
  background: #e3f5ef;
  box-shadow: inset 0 0 0 2px rgba(8,127,112,.16);
}
.p6-builder-choice-options input:focus-visible + span { outline: 3px solid rgba(214,147,0,.42); outline-offset: 2px; }
.p6-builder-choice-options label.is-answer span { border-color: #16815f; background: #ddf4e9; }
.p6-builder-task--transform { border-top: 5px solid #5a80bc; }
.p6-builder-task--coherence { border-top: 5px solid #d69300; }
.p6-builder-task--production { border-top: 5px solid #138a75; }
.p6-builder-task--production .p6-builder-groups { grid-template-columns: repeat(3,minmax(0,1fr)); }
@media (max-width: 880px) {
  .p6-builder-task--production .p6-builder-groups { grid-template-columns: 1fr; }
}


/* D4 V133 — reliable builder checking and explanation feedback */
.p6-builder-explanation[hidden] { display: none !important; }
.p6-builder-feedback {
  display: block;
  flex: 1 1 18rem;
  min-height: 1.5rem;
  padding: .55rem .7rem;
  border-radius: .6rem;
  color: #17324d;
  font-weight: 800;
  line-height: 1.45;
}
.p6-builder-task.is-correct .p6-builder-feedback {
  background: #dff4e9;
  border: 1px solid #55a985;
  color: #185b47;
}
.p6-builder-task.is-incorrect .p6-builder-feedback {
  background: #fff0ec;
  border: 1px solid #d68a7d;
  color: #7c2f28;
}
.p6-builder-choice-options label.is-selected-wrong span {
  border-color: #c45c50;
  background: #fff0ec;
  box-shadow: inset 0 0 0 2px rgba(196,92,80,.12);
}
.p6-builder-choice-options label.is-answer span {
  border-color: #16815f;
  background: #ddf4e9;
  box-shadow: inset 0 0 0 2px rgba(22,129,95,.13);
}


/* Contrast repair: the .p6-final panel carries its own dark gradient, but it
   sits inside a light section, so `.p6-section:not(.p6-section--ink) .p6-kicker`
   (0,3,0 !important) was overriding `.p6-final .p6-kicker` (0,2,0 !important)
   and painting a dark brown kicker onto a dark teal panel. These selectors match
   that specificity and come later, so the light text on dark surfaces wins. */
.p6-section .p6-final .p6-kicker,
.p6-page .p6-final .p6-kicker { color: #ffe4a3 !important; }
.p6-section .p6-final,
.p6-section .p6-final p,
.p6-section .p6-final h3,
.p6-page .p6-final .p6-next-step { color: #ffffff !important; }
.p6-section .p6-final .p6-final__header > span { color: #ffffff !important; }
