/* Chat course builder: the course takes shape on the left while the conversation runs on the right. */
body[data-page="builder-prompt"] {overflow:hidden; height:100dvh; min-height:0; display:flex; flex-direction:column}
body[data-page="builder-prompt"] > .site-header {flex:none}
body[data-page="builder-prompt"] .site-footer,
body[data-page="builder-prompt"] .page-heading {position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap}
body[data-page="builder-prompt"] main.page {flex:1; min-height:0; width:100%; max-width:none; margin:0; padding:0}
body[data-page="builder-prompt"] #app {height:100%}

.chat-builder {
  --cb-panel:384px; --cb-ease:cubic-bezier(.22,.8,.24,1);
  height:100%; display:grid; grid-template-columns:var(--cb-panel) minmax(0,1fr); background:#fbfaff;
}

/* ---- course panel: the course drawn as a diagram of blocks ---- */
.cb-course {display:flex; flex-direction:column; min-height:0; border-right:1px solid var(--line); background:#fff}
.cb-course-head {display:none}
.cb-icon {width:16px; height:16px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; flex:none}
.cb-close {display:none}
.cb-course-body {flex:1; overflow-y:auto; padding:18px 16px 28px; scrollbar-width:thin; background:radial-gradient(#efe8f8 1px,transparent 1.5px) 0 0/16px 16px}
.cb-empty {margin:28px 4px; font-size:.84rem; line-height:1.6; color:var(--muted)}
/* Tiers stack top to bottom; a short connector joins each tier to the one above it. */
.cb-tier {position:relative}
.cb-tier + .cb-tier {margin-top:28px}
.cb-tier + .cb-tier::before {content:""; position:absolute; left:50%; top:-24px; width:2px; height:20px; margin-left:-1px; border-radius:2px; background:#dccdf0}
.cb-tier + .cb-tier::after {content:""; position:absolute; left:50%; top:-8px; width:8px; height:8px; margin-left:-4px; border-radius:50%; border:2px solid #c9a6f3; background:#fff}
.cb-tier-head {display:flex; align-items:center; justify-content:space-between; gap:8px; min-height:26px; margin:0 2px 6px}
.cb-tier-head h2 {margin:0; font-size:.78rem; font-weight:600; letter-spacing:0; color:var(--muted)}
.cb-add {min-height:26px; padding:2px 8px; border:0; border-radius:6px; background:transparent; color:var(--dark-purple); font-size:.76rem; font-weight:600}
.cb-add:hover {background:var(--lavender)}
.cb-grid {display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px}
/* A block is one part of the course. It is a button; pressed, it becomes its own editor. */
.cb-block {position:relative; display:flex; flex-direction:column; align-items:stretch; justify-content:flex-start; gap:3px; min-width:0; min-height:58px; margin:0; padding:10px 12px;
  border:1px solid #e6dcf3; border-radius:12px; background:#fff; box-shadow:0 1px 2px #17141c0a; color:var(--ink); font:inherit; font-size:.82rem; font-weight:400; line-height:1.45; text-align:left; overflow-wrap:anywhere;
  transition:border-color .18s, box-shadow .18s, transform .18s var(--cb-ease)}
.cb-block[data-span="full"] {grid-column:1/-1}
button.cb-block {cursor:pointer}
button.cb-block:hover {border-color:#c4a3ee; background:#fff; box-shadow:0 10px 22px -16px #7e22cecc; transform:translateY(-1px)}
button.cb-block:active {transform:scale(.985)}
.cb-block-label {display:block; font-size:.7rem; font-weight:600; line-height:1.4; color:var(--muted)}
.cb-block-value {display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:5; overflow:hidden}
.cb-block-badge {align-self:flex-start; display:inline-grid; place-items:center; min-width:20px; height:20px; margin-bottom:2px; padding:0 6px; border-radius:6px; background:var(--lavender); color:var(--dark-purple); font-size:.68rem; font-weight:700}
.cb-block[data-auto="true"] {border-style:dashed; background:#fdfcff; box-shadow:none}
.cb-block[data-auto="true"] .cb-block-value, .cb-block[data-auto="true"] .cb-count-value {color:var(--muted); font-style:italic; font-weight:400}
.cb-block[data-fresh="true"] {animation:cb-glow 1.6s var(--cb-ease)}
.cb-block[data-open="true"] {gap:8px; border-style:solid; border-color:#c4a3ee; background:#fff; box-shadow:0 0 0 4px #f3e8ff}
.cb-block[data-kind="course"]:not([data-open]) {padding:14px 14px 12px; border-color:transparent; background:linear-gradient(140deg,#a855f7,#7e22ce); color:#fff; box-shadow:0 16px 30px -20px #7e22ce}
button.cb-block[data-kind="course"]:hover {border-color:transparent; background:linear-gradient(140deg,#b267f9,#8b2bd8)}
.cb-block[data-kind="course"]:not([data-open]) .cb-block-label {color:#f1e4ff}
.cb-block-title {font-size:1.04rem; font-weight:650; letter-spacing:-.02em; line-height:1.3}
.cb-block-meta {display:flex; flex-wrap:wrap; gap:6px; margin-top:7px}
.cb-block-meta span {padding:2px 9px; border-radius:999px; background:#ffffff2e; font-size:.7rem; font-weight:550}
.cb-block[data-kind="source"] .cb-block-value {-webkit-line-clamp:2}
/* Lessons of a level: one tile per lesson, one dot per concept it teaches. */
.cb-lessons {display:grid; grid-template-columns:repeat(6,minmax(0,1fr)); gap:6px; margin-top:6px}
.cb-lesson {display:flex; flex-direction:column; align-items:center; justify-content:center; gap:4px; min-height:44px; padding:5px 3px; border:1px solid #e3d0f8; border-radius:9px; background:#faf5ff}
.cb-lesson[data-auto="true"] {border-style:dashed; background:transparent}
.cb-lesson-number {font-size:.74rem; font-weight:700; line-height:1; color:var(--dark-purple)}
.cb-concepts {display:flex; flex-wrap:wrap; justify-content:center; gap:2px; max-width:34px}
.cb-concepts span {width:4px; height:4px; border-radius:50%; background:#b98ae8}
/* Editors inside an open block */
.cb-field {width:100%; min-height:0; padding:8px 10px; border:1px solid #cdb6ee; border-radius:10px; font:inherit; font-size:.82rem; line-height:1.5; color:var(--ink); background:#fff; resize:none}
.cb-field:focus-visible {outline:none; border-color:#b88be8}
.cb-block-tools {display:flex; align-items:center; justify-content:space-between; gap:8px}
.cb-hint {font-size:.72rem; color:var(--muted)}
.cb-remove {min-height:28px; margin-left:auto; padding:3px 10px; border:0; border-radius:8px; background:transparent; color:#b3261e; font-size:.76rem; font-weight:600}
.cb-remove:hover {background:#fdecec}
.cb-options {display:grid; gap:6px}
.cb-option {justify-content:flex-start; min-height:34px; padding:6px 10px; border:1px solid #e6dcf3; border-radius:9px; background:#fff; font-size:.8rem; font-weight:500; text-align:left}
.cb-option[aria-pressed="true"] {border-color:#b88be8; background:var(--lavender); color:var(--dark-purple); font-weight:650}
.cb-count-value {font-size:1.25rem; font-weight:650; letter-spacing:-.02em; line-height:1.2; font-variant-numeric:tabular-nums}
.cb-block[data-auto="true"] .cb-count-value {font-size:.82rem; letter-spacing:0; line-height:1.45}
.cb-count-row {display:flex; align-items:center; gap:10px}
.cb-count-row .cb-count-value {min-width:1.6em; text-align:center}
.cb-block[data-auto="true"] .cb-count-row .cb-count-value {flex:1; min-width:0; text-align:left}
.cb-step {flex:none; width:30px; height:30px; min-height:0; padding:0; border-radius:9px; border:1px solid #e6dcf3; background:#fff; color:var(--dark-purple); font-size:1rem; font-weight:600; line-height:1; transition:background .15s, transform .12s var(--cb-ease)}
.cb-step:hover:not(:disabled) {background:var(--lavender)}
.cb-step:active:not(:disabled) {transform:scale(.9)}
.cb-step:disabled {opacity:.35; cursor:default}
.cb-reset {margin-left:auto; min-height:0; padding:3px 8px; border:0; border-radius:6px; background:transparent; color:var(--muted); font-size:.72rem; font-weight:550}
.cb-reset:hover {background:#f6eefe; color:var(--dark-purple)}

/* ---- conversation ---- */
.cb-chat {position:relative; display:flex; flex-direction:column; min-width:0; min-height:0}
.cb-topbar {display:flex; align-items:center; gap:10px; padding:10px 20px; min-height:52px}
.cb-topbar-title {flex:1; min-width:0; margin:0; font-size:.86rem; font-weight:600; color:var(--ink); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; transition:opacity .25s}
.cb-open-course {display:none; min-height:34px; padding:6px 12px; border-radius:999px; font-size:.78rem}
.cb-count {display:inline-grid; place-items:center; min-width:18px; height:18px; padding:0 5px; border-radius:999px; background:var(--purple); color:#fff; font-size:.68rem}
.cb-new {min-height:34px; padding:6px 12px; border-radius:999px; font-size:.78rem; background:#fff}
.cb-scroll {flex:1; overflow-y:auto; overscroll-behavior:contain; scroll-behavior:smooth; scrollbar-width:thin}
.cb-thread {list-style:none; max-width:740px; margin:0 auto; padding:18px 24px 40px; display:flex; flex-direction:column; gap:22px}
.cb-msg {display:flex; gap:12px; font-size:.95rem; line-height:1.68; color:var(--ink); overflow-wrap:anywhere}
.cb-msg[data-enter="true"] {animation:cb-rise .45s var(--cb-ease) both}
.cb-msg p {margin:0 0 10px; max-width:none; color:inherit; font-size:inherit; line-height:inherit}
.cb-msg p:last-child {margin-bottom:0}
.cb-avatar {flex:none; width:28px; height:28px; margin-top:1px; border-radius:9px; display:grid; place-items:center;
  background:linear-gradient(140deg,#a855f7,#7e22ce); color:#fff; font-size:.72rem; font-weight:700; letter-spacing:-.02em}
.cb-body {flex:1; min-width:0; padding-top:2px}
.cb-msg[data-role="user"] {justify-content:flex-end}
.cb-msg[data-role="user"] .cb-body {flex:0 1 auto; max-width:min(82%,560px); padding:10px 16px; border-radius:18px 18px 6px 18px; background:var(--lavender); color:#2a1840}
.cb-msg[data-role="note"] .cb-body {color:var(--muted); font-size:.88rem}
.cb-msg[data-tone="error"] .cb-body {color:#8a1f1f}
.cb-msg[data-tone="error"] .cb-avatar {background:linear-gradient(140deg,#e57373,#b3261e)}
.cb-msg[data-revealing="true"] .cb-body::after {content:""; display:inline-block; width:7px; height:1em; margin-left:2px; vertical-align:-2px; border-radius:2px; background:var(--purple); animation:cb-caret .9s steps(2) infinite}
.cb-typing {display:flex; align-items:center; gap:10px; color:var(--muted); font-size:.86rem}
.cb-dots {display:inline-flex; gap:4px; padding:10px 12px; border-radius:14px; background:#fff; border:1px solid #efe9f7}
.cb-dots span {width:6px; height:6px; border-radius:50%; background:#b98ae8; animation:cb-bounce 1.2s ease-in-out infinite}
.cb-dots span:nth-child(2) {animation-delay:.15s}
.cb-dots span:nth-child(3) {animation-delay:.3s}

/* Fresh conversation: greeting sits in the middle of the page, like a new chat. */
.cb-hello {max-width:740px; margin:auto; padding:0 24px 8px; text-align:left}
.cb-hello h2 {margin:0 0 10px; font-size:clamp(1.5rem,3.2vw,2.1rem); letter-spacing:-.04em; line-height:1.15; color:var(--ink)}
.cb-hello p {margin:0; font-size:.95rem; color:var(--muted)}
.chat-builder[data-fresh="true"] .cb-scroll {display:flex; flex-direction:column; justify-content:center}
.chat-builder[data-fresh="true"] .cb-thread {display:none}
.chat-builder:not([data-fresh="true"]) .cb-hello {display:none}
.chat-builder[data-fresh="true"] .cb-new {visibility:hidden}

/* Cards inside the conversation */
.cb-card {border:1px solid #e9def7; border-radius:16px; background:#fff; padding:16px 18px; box-shadow:0 10px 30px -18px #7e22ce55}
.cb-card h3 {margin:0 0 10px; font-size:.95rem}
.cb-card dl {margin:0 0 14px; display:grid; grid-template-columns:max-content 1fr; gap:6px 16px; font-size:.84rem; line-height:1.5}
.cb-card dt {color:var(--muted)}
.cb-card dd {margin:0}
.cb-card p {margin:0 0 12px; font-size:.88rem; color:var(--muted)}
.cb-card .button {border-radius:999px}

/* ---- composer ---- */
.cb-composer-wrap {padding:6px 24px 18px; background:linear-gradient(#fbfaff00,#fbfaff 36%)}
.cb-composer {position:relative; max-width:740px; margin:0 auto; border:1px solid #e1d5f1; border-radius:22px; background:#fff; box-shadow:0 12px 32px -20px #5b21b680, 0 1px 2px #17141c0d;
  transition:border-color .2s, box-shadow .2s}
.cb-composer:focus-within {border-color:#c4a3ee; box-shadow:0 14px 36px -18px #7e22ce80, 0 0 0 4px #f3e8ff}
.cb-chips {list-style:none; margin:0; padding:10px 12px 0; display:flex; flex-wrap:wrap; gap:6px}
.cb-chip {display:inline-flex; align-items:center; gap:6px; max-width:100%; padding:5px 6px 5px 10px; border-radius:999px; background:#f6f1fd; font-size:.76rem; color:#3b2a52; animation:cb-rise .3s var(--cb-ease) both}
.cb-chip span {overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.cb-chip button {width:20px; height:20px; min-height:0; padding:0; border:0; border-radius:50%; background:transparent; color:#8b7aa3}
.cb-chip button:hover {background:#ebdffb; color:var(--dark-purple)}
.cb-input {display:block; width:100%; max-height:min(320px,40dvh); min-height:52px; overflow-y:auto; padding:15px 18px 6px; border:0; border-radius:22px; background:transparent; font:inherit; font-size:.95rem; line-height:1.55; color:var(--ink); resize:none}
.cb-input:focus-visible {outline:none}
.cb-input::placeholder {color:#a69db2}
.cb-actions {display:flex; align-items:center; justify-content:space-between; padding:4px 8px 8px 10px}
.cb-attach {display:inline-flex; align-items:center; gap:6px; min-height:34px; padding:6px 10px; border-radius:999px; color:var(--muted); font-size:.78rem; font-weight:550; cursor:pointer; transition:background .15s, color .15s}
.cb-attach:hover {background:#f6f1fd; color:var(--dark-purple)}
.cb-attach[aria-disabled="true"] {opacity:.45; pointer-events:none}
.cb-file-input {position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap}
.cb-send {width:36px; height:36px; min-height:0; padding:0; border-radius:50%; border:0; background:var(--purple); color:#fff; transition:transform .15s var(--cb-ease), background .15s, opacity .15s}
.cb-send:hover {background:var(--dark-purple)}
.cb-send:active {transform:scale(.92)}
.cb-send:disabled {opacity:.35; cursor:default; background:var(--purple)}
.cb-send svg {width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:2.2; stroke-linecap:round; stroke-linejoin:round}
.cb-stop svg {fill:currentColor}
.cb-fineprint {max-width:740px; margin:8px auto 0; text-align:center; font-size:.72rem; color:#a29aae}
.cb-fineprint[data-over="true"] {display:block; color:#8a1f1f}
/* A file dragged over the builder: the composer shows where it will land. */
.cb-drop-hint {display:none; position:absolute; inset:0; z-index:2; margin:0; align-items:center; justify-content:center; border-radius:22px; background:#faf5fff2; color:var(--dark-purple); font-size:.9rem; font-weight:600; pointer-events:none}
.chat-builder[data-drop="true"] .cb-composer {border-color:var(--purple); border-style:dashed; box-shadow:0 0 0 4px #f3e8ff}
.chat-builder[data-drop="true"] .cb-drop-hint {display:flex}

.cb-scrim {display:none}

@keyframes cb-rise {from {opacity:0; transform:translateY(10px)} to {opacity:1; transform:none}}
@keyframes cb-glow {0% {box-shadow:0 0 0 5px #e4cdfb} 100% {box-shadow:0 0 0 0 #e4cdfb00}}
@keyframes cb-bounce {0%,60%,100% {transform:translateY(0); opacity:.5} 30% {transform:translateY(-4px); opacity:1}}
@keyframes cb-caret {50% {opacity:0}}

/* ---- tablet and phone: the course panel becomes a drawer ---- */
@media (max-width:900px) {
  .chat-builder {grid-template-columns:minmax(0,1fr)}
  .cb-course {position:fixed; z-index:30; top:0; bottom:0; left:0; width:min(90vw,384px); transform:translateX(-102%); transition:transform .32s var(--cb-ease); box-shadow:24px 0 60px -30px #2a184066}
  .chat-builder[data-drawer="open"] .cb-course {transform:none}
  .cb-scrim {display:block; position:fixed; inset:0; z-index:29; background:#17141c40; opacity:0; pointer-events:none; transition:opacity .3s}
  .chat-builder[data-drawer="open"] .cb-scrim {opacity:1; pointer-events:auto}
  .cb-course-head {display:flex; justify-content:flex-end; padding:8px 10px 0}
  .cb-course-body {padding-top:6px}
  .cb-close {display:inline-flex; width:32px; height:32px; min-height:0; padding:0; border:0; border-radius:8px; background:transparent}
  .cb-open-course {display:inline-flex}
}
@media (max-width:560px) {
  .cb-topbar {padding:8px 12px}
  .cb-thread {padding:14px 14px 32px; gap:18px}
  .cb-hello {padding:0 16px 8px}
  .cb-composer-wrap {padding:4px 10px 10px}
  .cb-msg {font-size:.92rem}
  .cb-msg[data-role="user"] .cb-body {max-width:88%}
  .cb-avatar {width:24px; height:24px; border-radius:8px; font-size:.66rem}
  .cb-new span {display:none}
  .cb-fineprint:not([data-over="true"]) {display:none}
}
@media (prefers-reduced-motion: reduce) {
  .chat-builder *, .chat-builder *::before, .chat-builder *::after {animation-duration:1ms!important; animation-iteration-count:1!important; transition-duration:1ms!important}
  .cb-scroll {scroll-behavior:auto}
}
