/* ChordWalk Learning System — pilot component layer
   First used by Scale Discovery. The component names are intentionally generic
   so approved patterns can be migrated to other lesson families later. */

html.cwLearningSystem {
  color-scheme: dark;
  --cw-bg: #05070b;
  --cw-surface: #0b0f16;
  --cw-surface-raised: #101620;
  --cw-surface-soft: #141b27;
  --cw-border: rgba(174, 193, 219, 0.14);
  --cw-border-strong: rgba(166, 194, 235, 0.28);
  --cw-text: #f5f7fb;
  --cw-text-soft: #c6d0de;
  --cw-muted: #8d9aae;
  --cw-blue: #8fc5ff;
  --cw-violet: #b6a5ff;
  --cw-yellow: #f5d863;
  --cw-green: #77dea0;
  --cw-orange: #ffb36a;
  --cw-radius: 10px;
  --cw-shadow: 0 18px 60px rgba(0, 0, 0, 0.24);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--cw-bg);
}

html.cwLearningSystem *,
html.cwLearningSystem *::before,
html.cwLearningSystem *::after { box-sizing: border-box; }

html.cwLearningSystem body {
  margin: 0;
  min-width: 0 !important;
  overflow-x: hidden !important;
  background:
    radial-gradient(circle at 62% -15%, rgba(77, 101, 155, 0.15), transparent 35rem),
    var(--cw-bg) !important;
  color: var(--cw-text);
  font-family: inherit !important;
}

html.cwLearningSystem button,
html.cwLearningSystem input,
html.cwLearningSystem summary { font: inherit; }

html.cwLearningSystem .app {
  min-width: 0 !important;
  min-height: 100vh !important;
  height: auto !important;
  overflow: visible !important;
}

@media (min-width: 901px) {
  html.cwLearningSystem .app {
    display: grid !important;
    grid-template-columns: 248px minmax(0, 1fr) !important;
    align-items: start !important;
  }
  html.cwLearningSystem .side {
    position: sticky !important;
    top: 0 !important;
    align-self: start !important;
    width: 248px !important;
    height: 100vh !important;
    max-height: 100vh !important;
    overflow-y: auto !important;
  }
}

/* The first-paint stylesheet hides seed-brand children before shared navigation loads. */
html.cwLearningSystem body .side .cwAcademyBrandLockup > img {
  display: block !important;
}

html.cwLearningSystem .main {
  min-width: 0 !important;
  width: auto !important;
  max-width: none !important;
  height: auto !important;
  padding: 0 !important;
  overflow: visible !important;
  background: transparent !important;
}

/* The shared Academy runtime owns these. This layer only makes its lesson
   header deliberately compact for the pilot. */
html.cwLearningSystem .main > .cwUnifiedLessonBar,
html.cwLearningSystem .main > .cwLessonOrientation {
  width: min(1320px, calc(100% - 48px)) !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

html.cwLearningSystem .main > .cwUnifiedLessonBar {
  min-height: 52px !important;
  margin-top: 18px !important;
  margin-bottom: 12px !important;
  border-color: var(--cw-border) !important;
  border-radius: var(--cw-radius) !important;
  background: rgba(8, 11, 17, 0.92) !important;
  box-shadow: none !important;
}

html.cwLearningSystem .main > .cwLessonOrientation {
  min-height: 0 !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  padding: 11px 14px !important;
  border-color: var(--cw-border) !important;
  border-radius: var(--cw-radius) !important;
  background: rgba(9, 13, 20, 0.8) !important;
  box-shadow: none !important;
}

html.cwLearningSystem .cwLessonOrientationMeta {
  margin-bottom: 5px !important;
  color: var(--cw-muted) !important;
  font-size: 0.7rem !important;
}

html.cwLearningSystem .cwLessonOrientationOutcome small {
  background: linear-gradient(90deg, var(--cw-blue), var(--cw-violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent !important;
}

html.cwLearningSystem .cwLessonOrientationOutcome strong {
  color: var(--cw-text-soft) !important;
  font-size: 0.88rem !important;
  line-height: 1.35 !important;
}

.cwLessonPage {
  width: min(1320px, calc(100% - 48px));
  margin: 0 auto;
  padding: 24px 0 64px;
}

.cwLessonHeader {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin: 0 0 18px;
}

.cwLessonEyebrow,
.cwSectionLabel {
  margin: 0 0 7px;
  color: var(--cw-blue);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.cwLessonHeader h1 {
  margin: 0;
  color: var(--cw-text);
  font-size: clamp(2rem, 3.4vw, 3.35rem);
  font-weight: 720;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.cwLessonHeader p {
  max-width: 650px;
  margin: 9px 0 0;
  color: var(--cw-text-soft);
  font-size: 1rem;
  line-height: 1.5;
}

.cwLessonProgress {
  min-width: 170px;
  padding: 10px 12px;
  border: 1px solid var(--cw-border);
  border-radius: 8px;
  background: rgba(12, 17, 25, 0.72);
}

.cwLessonProgress span {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--cw-muted);
  font-size: 0.72rem;
}

.cwLessonProgress span b { color: var(--cw-text-soft); font-weight: 700; }
.cwLessonProgressTrack { height: 3px; margin-top: 8px; overflow: hidden; border-radius: 99px; background: #222b38; }
.cwLessonProgressTrack i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--cw-blue), var(--cw-violet)); transition: width 220ms ease; }

.cwStartBar {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto auto;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid var(--cw-border);
  border-radius: var(--cw-radius);
  background: var(--cw-surface);
}

.cwStartInstruction { display: flex; align-items: center; gap: 11px; min-width: 0; }
.cwStartNumber {
  width: 28px; height: 28px; flex: 0 0 28px; display: grid; place-items: center;
  border: 1px solid rgba(143, 197, 255, 0.44); border-radius: 8px;
  background: linear-gradient(145deg, rgba(90, 138, 199, 0.26), rgba(145, 113, 208, 0.19));
  color: #dbeaff; font-size: 0.75rem; font-weight: 800;
}
.cwStartInstruction strong { display: block; color: var(--cw-text); font-size: 0.84rem; }
.cwStartInstruction p { margin: 2px 0 0; color: var(--cw-muted); font-size: 0.76rem; line-height: 1.35; }

.cwSegmented {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--cw-border);
  border-radius: 8px;
  background: #080c12;
}

.cwSegmented button,
.cwSecondaryButton,
.cwPrimaryButton,
.cwTextButton {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--cw-text-soft);
  background: transparent;
  font-size: 0.79rem;
  font-weight: 720;
  cursor: pointer;
}

.cwSegmented button:hover,
.cwSegmented button:focus-visible,
.cwSecondaryButton:hover,
.cwSecondaryButton:focus-visible,
.cwTextButton:hover,
.cwTextButton:focus-visible { color: white; background: var(--cw-surface-soft); outline: none; }

.cwSegmented button.active {
  color: white;
  background: linear-gradient(135deg, rgba(79, 122, 180, 0.62), rgba(104, 82, 159, 0.52));
  box-shadow: inset 0 0 0 1px rgba(177, 206, 248, 0.25);
}

.cwActionGroup { display: flex; align-items: center; gap: 6px; }
.cwPrimaryButton {
  color: #09101b;
  background: #f1f4f9;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}
.cwPrimaryButton:hover,.cwPrimaryButton:focus-visible { background: white; outline: 2px solid var(--cw-blue); outline-offset: 2px; }
.cwSecondaryButton { border: 1px solid var(--cw-border); background: #0c1119; }
.cwTextButton { color: var(--cw-muted); }

.cwCompareButton {
  width: 100%;
  min-height: 38px;
  margin-top: 10px;
  border: 1px solid var(--cw-border);
  border-radius: 6px;
  background: transparent;
  color: var(--cw-muted);
  font: inherit;
  font-size: .76rem;
  font-weight: 700;
  cursor: pointer;
}
.cwCompareButton:hover,.cwCompareButton:focus-visible { border-color: var(--cw-border-strong); color: var(--cw-text); outline: none; }

.cwActivity {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.72fr);
  grid-template-areas: "keyboard feedback";
  gap: 12px;
  align-items: stretch;
}

.cwKeyboardCard,
.cwFeedbackPanel,
.cwDisclosure,
.cwCompletion {
  min-width: 0;
  border: 1px solid var(--cw-border);
  border-radius: var(--cw-radius);
  background: var(--cw-surface);
  box-shadow: var(--cw-shadow);
}

.cwKeyboardCard { grid-area: keyboard; padding: 16px; }
.cwFeedbackPanel { grid-area: feedback; display: flex; flex-direction: column; padding: 16px; }

.cwPanelHeading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.cwPanelHeading h2 { margin: 0; color: var(--cw-text); font-size: 1rem; font-weight: 700; letter-spacing: -0.015em; }
.cwPanelHeading p { margin: 3px 0 0; color: var(--cw-muted); font-size: 0.76rem; }
.cwPanelTag { flex: 0 0 auto; padding: 5px 7px; border: 1px solid var(--cw-border); border-radius: 6px; color: var(--cw-muted); font-size: 0.68rem; font-weight: 700; }

.keyboard {
  --cwkBlackW: 7.5%;
  --cwkBlackH: 57%;
  position: relative;
  height: clamp(245px, 25vw, 330px);
  min-height: 245px;
  overflow: hidden;
  padding: 10px;
  border: 1px solid rgba(143, 197, 255, 0.38);
  border-radius: 9px;
  background: #050911;
}

.whiteRow { display: flex; height: 100%; }
.w {
  position: relative;
  display: flex;
  flex: 1 1 0;
  align-items: flex-end;
  justify-content: center;
  min-width: 0;
  padding: 0 3px 36px;
  border: 1px solid #b4bdc8;
  border-radius: 0 0 5px 5px;
  background: linear-gradient(90deg, #dce3eb, #fbfdff 48%, #d4dce6);
  color: #10151d;
  font-size: clamp(1rem, 1.35vw, 1.35rem);
  font-weight: 800;
  text-align: center;
}
.w.selected,.w.target { z-index: 5; outline: 3px solid var(--cw-yellow); outline-offset: -3px; box-shadow: inset 0 0 0 999px rgba(245, 216, 99, 0.26); }
.w.completed { z-index: 2; box-shadow: inset 0 0 0 999px rgba(143, 197, 255, 0.30); }
.w.next { z-index: 4; outline: 3px solid var(--cw-blue); outline-offset: -3px; }
.w.target { outline-color: var(--cw-green); box-shadow: inset 0 0 0 999px rgba(119, 222, 160, 0.33); }
.b {
  position: absolute;
  top: 10px !important;
  z-index: 7;
  width: var(--cwkBlackW) !important;
  height: var(--cwkBlackH) !important;
  transform: translateX(-50%) !important;
  padding-top: 22px !important;
  border-radius: 0 0 6px 6px !important;
  background: linear-gradient(90deg, #0a0d12, #252b34 47%, #080a0e);
  box-shadow: 0 10px 18px rgba(0,0,0,.48) !important;
  color: #e8edf5;
  font-size: 0.72rem;
  font-weight: 750;
  text-align: center;
}
.b.unused { opacity: .62; }
.b.skip { outline: 3px solid var(--cw-orange); outline-offset: -2px; background: linear-gradient(#e9a860,#7c4216); color: #fff; opacity: 1; }
.badge { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); min-width: 20px; padding: 3px 6px; border-radius: 99px; background: #111a26; color: white; font-size: 0.66rem; }
.arrowLayer { position: absolute; inset: 0; z-index: 9; pointer-events: none; }
.jump { position: absolute; top: 7px; display: flex; align-items: flex-start; justify-content: center; height: 58px; padding-top: 1px; border-top: 3px solid var(--cw-yellow); border-radius: 50% 50% 0 0; color: var(--cw-yellow); font-size: 0.72rem; font-weight: 800; }
.jump.semi { border-color: var(--cw-green); color: var(--cw-green); }
.cwKeyboardCaption { display: flex; justify-content: space-between; gap: 14px; margin-top: 10px; color: var(--cw-muted); font-size: 0.76rem; line-height: 1.4; }
.cwKeyboardLegend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.cwKeyboardLegend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.cwKeyboardLegend i { width: 7px; height: 7px; border-radius: 50%; background: var(--cw-blue); }
.cwKeyboardLegend span:nth-child(2) i { background: var(--cw-yellow); }
.cwKeyboardLegend span:nth-child(3) i { background: var(--cw-green); }

.cwCurrentMove {
  min-height: 108px;
  padding: 14px;
  border: 1px solid var(--cw-border);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(45, 68, 101, .2), rgba(73, 53, 105, .12));
}
.cwCurrentMove span { display: block; color: var(--cw-muted); font-size: .7rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.cwCurrentMove p { margin: 8px 0 0; color: var(--cw-text); font-size: 1rem; line-height: 1.46; }
.cwCurrentMove p b { color: var(--cw-blue); }

.formulaStrip { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 5px; margin: 12px 0; min-width: 0; }
.token { min-width: 0; min-height: 72px; overflow: hidden; padding: 8px 3px 6px; border: 1px solid var(--cw-border); border-radius: 7px; background: #090e15; text-align: center; }
.token b,.token span,.token small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.token b { min-height: 18px; color: var(--cw-text); font-size: .75rem; }
.token span { margin-top: 4px; color: var(--cw-muted); font-size: .67rem; font-weight: 800; }
.token small { margin-top: 5px; color: var(--cw-muted); font-size: .62rem; }
.token.pending { opacity: .38; }
.token.tone b { color: var(--cw-blue); }
.token.semi b { color: var(--cw-yellow); }
.token.current { border-color: rgba(182,165,255,.72); background: rgba(104,82,159,.14); box-shadow: inset 0 2px 0 var(--cw-violet); }

.cwResultBlock { margin-top: auto; padding-top: 4px; }
.status { margin: 0; color: var(--cw-text-soft); font-size: .82rem; font-weight: 700; }
.notesResult { min-height: 24px; margin-top: 7px; color: var(--cw-text-soft); font-size: 1rem; font-weight: 720; letter-spacing: .08em; }
.result { min-height: 35px; margin-top: 3px; color: var(--cw-yellow); font-size: clamp(1.35rem, 2.2vw, 2rem); font-weight: 760; letter-spacing: .11em; }

.cwDisclosure { margin-top: 12px; box-shadow: none; }
.cwDisclosure summary { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 15px 16px; color: var(--cw-text-soft); font-size: .88rem; font-weight: 720; cursor: pointer; list-style: none; }
.cwDisclosure summary::-webkit-details-marker { display: none; }
.cwDisclosure summary::after { content: "+"; color: var(--cw-muted); font-size: 1.1rem; font-weight: 400; }
.cwDisclosure[open] summary::after { content: "−"; }
.cwDisclosure summary span { display: block; margin-top: 3px; color: var(--cw-muted); font-size: .74rem; font-weight: 500; }
.cwDisclosureContent { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 16px 16px; }
.cwTheoryCard { padding: 14px; border: 1px solid var(--cw-border); border-radius: 8px; background: #090e15; }
.cwTheoryCard h3 { margin: 0 0 7px; color: var(--cw-blue); font-size: .86rem; }
.cwTheoryCard p { margin: 0; color: var(--cw-text-soft); font-size: .88rem; line-height: 1.58; }
.cwTheoryTakeaway { grid-column: 1/-1; padding: 12px 14px; border-left: 2px solid var(--cw-violet); border-radius: 7px; background: linear-gradient(90deg, rgba(111,92,164,.12), rgba(9,14,21,.45)); color: var(--cw-text-soft); font-size: .87rem; line-height: 1.5; }

.cwCompletion { margin-top: 12px; padding: 18px; box-shadow: none; }
.cwCompletion.hidden { display: none; }
.cwCompletion h2 { margin: 0; color: var(--cw-green); font-size: 1.1rem; }
.cwCompletionLead { margin: 6px 0 14px; color: var(--cw-text); font-size: 1rem; font-weight: 650; }
.cwSummaryTable { width: 100%; border-spacing: 0; overflow: hidden; border: 1px solid var(--cw-border); border-radius: 8px; }
.cwSummaryTable th,.cwSummaryTable td { padding: 11px 12px; border-bottom: 1px solid var(--cw-border); color: var(--cw-text-soft); font-size: .83rem; text-align: left; }
.cwSummaryTable tr:last-child td { border-bottom: 0; }
.cwSummaryTable th { color: var(--cw-muted); background: #090e15; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; }
.cwSummaryTable td:last-child { color: var(--cw-yellow); font-weight: 750; letter-spacing: .08em; }

@media (max-width: 1120px) {
  .cwStartBar { grid-template-columns: 1fr auto; }
  .cwStartInstruction { grid-column: 1/-1; }
  .cwActivity { grid-template-columns: minmax(0,1fr) minmax(330px,.72fr); }
  .formulaStrip { grid-template-columns: repeat(4,minmax(0,1fr)); }
}

@media (max-width: 900px) {
  html.cwLearningSystem .main > .cwUnifiedLessonBar,
  html.cwLearningSystem .main > .cwLessonOrientation,
  .cwLessonPage { width: min(100% - 28px, 760px) !important; }
  .cwLessonHeader { align-items: flex-start; flex-direction: column; }
  .cwLessonProgress { width: 100%; }
  .cwActivity { grid-template-columns: 1fr; grid-template-areas: "feedback" "keyboard"; }
  .cwFeedbackPanel { min-height: 0; }
  .formulaStrip { grid-template-columns: repeat(7,minmax(0,1fr)); }
  .keyboard { height: 280px; }
}

@media (max-width: 640px) {
  .cwLessonPage { padding-top: 18px; }
  .cwLessonHeader h1 { font-size: 2.15rem; }
  .cwStartBar { display: block; }
  .cwSegmented { margin: 12px 0 8px; }
  .cwSegmented button { flex: 1; }
  .cwActionGroup { display: grid; grid-template-columns: 1fr 1fr; }
  .cwPrimaryButton { grid-column: 1/-1; }
  .formulaStrip { grid-template-columns: repeat(4,minmax(0,1fr)); }
  .keyboard { min-height: 220px; height: 56vw; padding: 7px; }
  .b { top: 7px !important; }
  .cwKeyboardCaption { display: block; }
  .cwKeyboardLegend { justify-content: flex-start; margin-top: 7px; }
  .cwDisclosureContent { grid-template-columns: 1fr; }
  .cwTheoryTakeaway { grid-column: auto; }
  .cwSummaryTable { display: block; overflow-x: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
