/* Scoped Chunking presentation adapter. Actual state comes from the existing flow/progress engines.
   Loaded after legacy theme rules; does not modify scores, APIs, or activity sequencing. */
#page-chunking {
  --pf16-canvas:#F8FAFC;--pf16-card:#FFFFFF;--pf16-inset:#F1F5F9;
  --pf16-line:#CBD5E1;--pf16-text:#0F172A;--pf16-muted:#475569;
  --pf16-accent:#1D4ED8;--pf16-pill:#ECFDF5;--pf16-pill-text:#065F46;
}
:root[data-pf-theme="dark"] #page-chunking {
  --pf16-canvas:#0F172A;--pf16-card:#1E293B;--pf16-inset:#111F33;
  --pf16-line:#334155;--pf16-text:#F8FAFC;--pf16-muted:#CBD5E1;
  --pf16-accent:#93C5FD;--pf16-pill:#123E38;--pf16-pill-text:#A7F3D0;
}
#page-chunking.pf-chunking {
  background:var(--pf16-canvas)!important;color:var(--pf16-text)!important;
}
/* Catalogue and chapter cards: high-specificity scoped adapter to avoid hardcoded white backgrounds. */
#page-chunking :is(.pf-ls-catalog-hero,.pf-ls-catalog-summary,.pf-i-chunk-browser,
 .pf-ch94-chapter,.pf-ch94-chapter-trigger,.pf-ch94-chapter-body,.pf-ch94-lesson,
 .pf-chunk-lesson,.pf-i-topic-card) {
  background:var(--pf16-card)!important;background-image:none!important;
  border-color:var(--pf16-line)!important;color:var(--pf16-text)!important;
}
#page-chunking :is(.pf-ch94-chapter-title,.pf-ch94-lesson h4,.pf-ch94-chapter-trigger strong,
 .pf-i-chunk-browser h2,.pf-ch94-chapter-copy,.pf-ch94-lesson-main) {
  color:var(--pf16-text)!important;
}
#page-chunking :is(.pf-ch94-chapter-desc,.pf-ch94-lesson p,.pf-ch94-lesson-meta) {
  color:var(--pf16-muted)!important;
}
#page-chunking :is(.pf-ch94-chapter-number,.pf-ch94-lesson-icon) {
  background:var(--pf16-inset)!important;border-color:var(--pf16-line)!important;color:var(--pf16-accent)!important;
}
#page-chunking .pf-ch94-chapter-trigger:hover {
  background:var(--pf16-inset)!important;
}
/* Active learning: two-column academic reading surface, no bright isolated cards. */
#page-chunking :is(.pf-ls-practice-column,.pf-ls-practice-column .pf-chunk-session-content,
 .pf-ls-practice-column .pf-chunk-session-actions,.pf-ls-context-panel,
 .pf-ls-context-section,.pf-chunk-knowledge,.pf-chunk-roleplay-brief,
 .pf-chunk-selfcheck,.pf-chunk-chat-bubble,.pf-chunk-decision,.pf-chunk-slot,
 .pf-chunk-practice-model,.pf-j-stage,.pf-j-check) {
  background:var(--pf16-card)!important;background-image:none!important;
  border-color:var(--pf16-line)!important;color:var(--pf16-text)!important;
  box-shadow:none!important;
}
#page-chunking .pf-ls-context-panel {position:sticky;top:18px;align-self:start;overflow:hidden;}
#page-chunking .pf-ls-context-section {padding:clamp(17px,2vw,23px)!important;}
#page-chunking .pf-ls-context-section + .pf-ls-context-section {border-top:1px solid var(--pf16-line)!important;}
#page-chunking :is(.pf-ls-heading h2,.pf-ls-context-section h3,.pf-chunk-instruction,
 .pf-chunk-slot strong,.pf-chunk-prompt,.pf-j-stage h3,.pf-j-check h3) {
  color:var(--pf16-text)!important;
}
#page-chunking :is(.pf-ls-context-section p,.pf-chunk-meaning,.pf-chunk-activity-tip,
 .pf-chunk-knowledge-line,.pf-chunk-slot span,.pf-chunk-chat-bubble small) {
  color:var(--pf16-muted)!important;
}
#page-chunking :is(.pf-chunk-practice-reference,.pf-chunk-fill-input,
 .pf-chunk-decision-option:not(.pf-selected),.pf-chunk-option:not(.correct):not(.incorrect):not(.is-selected),
 .pf-j-choice:not(.is-selected),.pf-chunk-practice-question) {
  background:var(--pf16-inset)!important;border-color:var(--pf16-line)!important;
  color:var(--pf16-text)!important;
}
#page-chunking :is(.pf-chunk-practice-reference,.pf-chunk-fill-input)::placeholder {color:var(--pf16-muted)!important;}
/* Lexical entry: render the actual authored target, never fabricated IPA or grammar. */
#page-chunking .pf16-lexical-entry {
  background:var(--pf16-inset);border:1px solid var(--pf16-line);
  border-left:4px solid var(--pf16-accent);border-radius:16px;
  padding:clamp(15px,2vw,22px);margin:17px 0 22px;min-width:0;
}
#page-chunking .pf16-lexical-kicker {
  display:block;margin-bottom:10px;font:750 11px/1.5 system-ui,sans-serif;
  color:var(--pf16-muted);letter-spacing:.08em;
}
#page-chunking .pf-ls-practice-column .pf16-lexical-entry .pf16-lexical-phrase {
  margin:0!important;max-width:none!important;padding:0!important;
  border:0!important;border-radius:0!important;background:transparent!important;
  box-shadow:none!important;color:var(--pf16-accent)!important;
  font-size:clamp(20px,2.6vw,30px);line-height:1.38;
  font-weight:780;overflow-wrap:anywhere;text-align:left!important;
}
/* Existing bare mainphrase cards not carrying English target (Vietnamese prompts, summary) */
#page-chunking .pf-ls-practice-column .pf-chunk-mainphrase:not(.pf16-lexical-phrase) {
  background:var(--pf16-inset)!important;border:1px solid var(--pf16-line)!important;
  color:var(--pf16-text)!important;
}
/* Chunking IPA is a plain, unboxed text line. Only the /phonemes API supplies it. */
#page-chunking .pf-chunk-ipa {
  display:block;
  min-width:0;
  width:auto;
  max-width:100%;
  margin:12px 0 14px;
  padding:0;
  border:0;
  border-radius:0;
  background:transparent;
  box-shadow:none;
  color:var(--pf16-text);
  font-family:inherit;
  font-size:14px;
  font-weight:400;
  line-height:1.55;
  letter-spacing:normal;
  overflow-wrap:anywhere;
  text-align:left;
}
/* Preserve existing microphone event handlers; style recording and processing states. */
#page-chunking .pf-chunk-mic-button {
  border-radius:999px!important;box-shadow:0 0 0 5px rgba(16,185,129,.12)!important;
  transition:background .2s,box-shadow .2s,transform .2s;
}
#page-chunking.pf-mic-recording .pf-chunk-mic-button {
  background:#E11D48!important;box-shadow:0 0 0 6px rgba(225,29,72,.21)!important;
}
#page-chunking.pf-mic-processing .pf-chunk-mic-button {background:#64748B!important;box-shadow:none!important;}
#page-chunking .pf-chunk-mic-button:focus-visible {outline:2px solid var(--pf16-accent)!important;outline-offset:5px;}
#page-chunking :is(.pf-chunk-mic-label,.pf-chunk-status) {color:var(--pf16-muted)!important;}
/* Notes and validated progress reside in the existing right sidebar. */
#page-chunking .pf16-grammar-note {display:grid;gap:13px;min-width:0;}
#page-chunking .pf16-knowledge-item {min-width:0;}
#page-chunking .pf16-knowledge-item strong {display:block;font-size:11px;line-height:1.5;letter-spacing:.06em;
 text-transform:uppercase;font-weight:750;color:var(--pf16-accent)!important;margin-bottom:4px;}
#page-chunking .pf16-knowledge-item p {margin:0;font-size:13px;line-height:1.6;
 color:var(--pf16-text)!important;overflow-wrap:anywhere;}
#page-chunking .pf16-source-note {margin:14px 0 0;font-size:11px;line-height:1.5;color:var(--pf16-muted)!important;}
#page-chunking .pf16-empty-note {margin:0;color:var(--pf16-muted)!important;font-size:13px;line-height:1.6;}
#page-chunking .pf16-progress-caption {margin:0 0 12px;padding:9px 12px;border:1px solid var(--pf16-line);
 border-radius:10px;background:var(--pf16-inset)!important;color:var(--pf16-text)!important;
 font-size:12px;line-height:1.6;}
#page-chunking .pf16-progress-caption[data-complete="true"] {
 color:var(--pf16-pill-text)!important;background:var(--pf16-pill)!important;border-color:#10B981!important;
}
#page-chunking .pf-ls-feedback-panel .pf-chunk-feedback:not([hidden]) {color:var(--pf16-text)!important;}
#page-chunking .pf-ls-context-section .pf16-knowledge-item p {color:var(--pf16-text)!important;}
@media (max-width:760px){
 #page-chunking .pf-ls-context-panel {position:static;top:auto;}
 #page-chunking .pf-ls-workspace-grid {grid-template-columns:minmax(0,1fr)!important;}
 #page-chunking .pf16-lexical-entry {margin:12px 0 16px;}
}
@media(prefers-reduced-motion:reduce){#page-chunking .pf-chunk-mic-button{transition:none!important;}}
/* The legacy session toolbar and heading are outside the two main cards. */
#page-chunking .pf-ls-sessionbar {
  background:var(--pf16-card)!important;border:1px solid var(--pf16-line)!important;
  color:var(--pf16-text)!important;border-radius:14px;padding:12px 15px;
}
#page-chunking .pf-ls-sessionbar .pf-chunk-phase {color:var(--pf16-muted)!important;}
#page-chunking .pf-ls-heading {background:transparent!important;}
#page-chunking .pf-ls-eyebrow {color:var(--pf16-accent)!important;}
#page-chunking .pf-ls-sessionbar .pf-chunk-counter {
  background:var(--pf16-inset)!important;color:var(--pf16-accent)!important;
}
/* Legacy !important rules target .pf-chunk-mainphrase; the lexical wrapper overrides them intentionally. */
:root[data-pf-theme="dark"] #page-chunking .pf-ls-practice-column .pf16-lexical-entry .pf16-lexical-phrase,
:root[data-pf-theme="light"] #page-chunking .pf-ls-practice-column .pf16-lexical-entry .pf16-lexical-phrase {
  background:transparent!important;background-image:none!important;
  border:0!important;padding:0!important;box-shadow:none!important;
  color:var(--pf16-accent)!important;
}
/* Final specificity adapter for V14/V15 nested :is() rules (same element in old themes). */
:root[data-pf-theme] body #page-chunking.pf-chunking .pf-ls-workspace-grid .pf-ls-practice-column .pf16-lexical-entry .pf-chunk-mainphrase.pf16-lexical-phrase {
  background:transparent!important;background-image:none!important;
  color:var(--pf16-accent)!important;border:0!important;padding:0!important;
}
:root[data-pf-theme] body #page-chunking.pf-chunking #chunk-workspace .pf-ls-heading {
  background:transparent!important;background-image:none!important;
}
