/* Learning features: walkthrough player, practice, study plan, skill lessons, settings, word lookup. */

/* The planning conversation keeps questions and the ordered build visible on narrow screens. */
.chat-status { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 20px; }
.chat-status span { color: var(--muted); }
.chat-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; align-items: start; }
.chat-sidebar { position: sticky; top: 20px; display: grid; gap: 14px; }
.chat-list { display: grid; gap: 4px; max-height: 65vh; overflow-y: auto; }
.chat-list-row { display: flex; align-items: center; min-width: 0; border-radius: 8px; }
.chat-list-row:has(.active) { background: rgba(124,58,237,0.18); }
.chat-select, .chat-delete { border: 0; background: transparent; color: var(--text); cursor: pointer; font: inherit; }
.chat-select { flex: 1; min-width: 0; padding: 9px; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-delete { padding: 5px 9px; font-size: 20px; color: var(--muted); }
.chat-delete:hover { color: var(--text); }
.chat-main { min-width: 0; }
.chat-main h1 { margin-top: 0; }
.chat-main .planner-messages { min-height: 360px; max-height: 55vh; }
#chat-built-links { margin-bottom: 0; }
@media (max-width: 700px) { .chat-layout { grid-template-columns: 1fr; } .chat-sidebar { position: static; } .chat-list { max-height: 160px; } }
.lesson-planner { align-items: start; }
.planner-messages { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; padding: 4px 2px 14px; }
.planner-message { max-width: 85%; padding: 10px 14px; border-radius: 14px; white-space: pre-line; line-height: 1.5; }
.planner-message.tutor { align-self: flex-start; background: rgba(124,58,237,0.18); border: 1px solid rgba(124,58,237,0.35); }
.planner-message.student { align-self: flex-end; background: rgba(255,255,255,0.1); }
.planner-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 14px; }
.planner-compose-row { display: flex; gap: 8px; }
.planner-compose-row .input { min-width: 0; flex: 1; }
.planner-proposal { margin-top: 16px; }
.planner-proposal li { padding: 8px 0; }
.planner-proposal li p { margin: 4px 0; }
.course-head { display: grid; justify-items: start; gap: 8px; }
.course-head h1, .course-head p { margin: 0; }
.course-progress { width: 100%; height: 9px; border-radius: 99px; overflow: hidden; background: rgba(255,255,255,0.1); }
.course-progress span { display: block; height: 100%; background: var(--primary); transition: width .2s ease; }
.course-list { display: grid; gap: 12px; margin: 16px 0; }
.course-lesson { display: flex; gap: 18px; align-items: flex-start; }
.course-number { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: rgba(124,58,237,.22); color: var(--text); font-weight: 700; }
.course-lesson-main { flex: 1; min-width: 0; }
.course-lesson-heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.course-lesson-heading h2 { margin: 0; }
.course-lesson p { margin: 8px 0; }
.course-lesson .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.course-check-choices { display: grid; gap: 8px; margin: 14px 0; }
.course-check [data-course-check-result] { margin-top: 16px; }
.course-check .pq-result { overflow-wrap: anywhere; }
@media (max-width: 600px) { .course-lesson { gap: 12px; } .course-number { width: 30px; height: 30px; } }
@media (max-width: 600px) { .planner-compose-row { flex-direction: column; } .planner-message { max-width: 95%; } }

:root {
  --warn: #f59e0b;
  --board-bg: #0f2a24;
  --board-ink: #eef7f1;
  --board-accent: #fde68a;
  --radius: 14px;
}

/* ---------- shared bits ---------- */

[hidden] { display: none !important; }
.practice-stage, .wt, .wt-step { scroll-margin-top: 84px; }

.topbar-tools { display: flex; align-items: center; gap: 10px; }
.topbar-icon { padding: 6px 9px; border-radius: 10px; color: var(--muted); font-size: 18px; line-height: 1; }
.topbar-icon:hover, .topbar-icon.active { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.nav a.active { background: rgba(124, 58, 237, 0.18); color: var(--text); }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button {
  background: transparent; color: var(--muted); border: 0; padding: 6px 10px; cursor: pointer; font: inherit; font-size: 13px;
}
.seg button + button { border-inline-start: 1px solid var(--border); }
.seg button:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.seg button[aria-pressed="true"] { background: rgba(124, 58, 237, 0.35); color: #fff; }
.seg-mini button { padding: 4px 8px; font-size: 12px; }
.seg-large button { padding: 10px 18px; font-size: 15px; }

.btn.small { padding: 6px 10px; font-size: 13px; }
.linkish { background: none; border: 0; padding: 0; color: #c4b5fd; cursor: pointer; font: inherit; font-size: 13px; }
.linkish:hover { text-decoration: underline; }
.badge.warn { border-color: rgba(245, 158, 11, 0.6); color: rgba(245, 158, 11, 0.95); }
.count-pill { display: inline-block; min-width: 22px; padding: 0 6px; margin-inline-start: 6px; border-radius: 999px; background: rgba(255,255,255,0.14); font-size: 12px; text-align: center; }

:focus-visible { outline: 2px solid #a78bfa; outline-offset: 2px; }

[lang="ar"] { font-family: "Segoe UI", "Noto Naskh Arabic", "Noto Sans Arabic", Tahoma, sans-serif; line-height: 1.8; }
bdi[dir="ltr"] { unicode-bidi: isolate; }

/* ---------- practice question ---------- */

.practice-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.practice-head h1 { margin: 6px 0 4px; }
.practice-progress { min-width: 220px; display: grid; gap: 4px; font-size: 13px; }
.practice-progress .bar { height: 6px; border-radius: 99px; background: rgba(255,255,255,0.08); overflow: hidden; }
.practice-progress .bar div { height: 100%; background: var(--primary); transition: width 0.4s ease; }
.practice-stage { display: grid; gap: 16px; }
.practice-next { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.practice-summary h2 { margin-top: 0; }

.pq { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.pq-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; }
.pq-passage { max-height: 60vh; overflow: auto; padding-inline-end: 8px; line-height: 1.65; }
.pq-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.pq-diff { font-size: 12px; color: var(--muted); }
.pq-diff-hard { color: #fca5a5; }
.pq-diff-medium { color: #fcd34d; }
.pq-diff-easy { color: #86efac; }
.pq-note { font-size: 14px; background: rgba(124,58,237,0.14); border: 1px solid rgba(124,58,237,0.35); border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; }
.pq-stem { line-height: 1.6; }
.pq-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.pq-choice.is-correct { border-color: rgba(34,197,94,0.75); background: rgba(34,197,94,0.12); }
.pq-choice.is-wrong { border-color: rgba(239,68,68,0.75); background: rgba(239,68,68,0.10); }
.pq-result { margin-top: 12px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); }
.pq-result.is-correct { border-color: rgba(34,197,94,0.6); background: rgba(34,197,94,0.10); }
.pq-result.is-wrong { border-color: rgba(239,68,68,0.55); background: rgba(239,68,68,0.08); }
.pq-result.is-hint { border-color: rgba(245,158,11,0.55); }

/* ---------- walkthrough player ---------- */

.wt-host:empty { display: none; }
.wt { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.wt-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.wt-kicker { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.wt-strategy { font-size: 20px; font-weight: 700; margin-top: 2px; }
.wt-ar-inline { font-weight: 500; color: var(--muted); font-size: 17px; }
.wt-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.wt-body { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }

.wt-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.wt-step { border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; transition: border-color 0.2s, background 0.2s, opacity 0.2s; }
.wt-step.is-current { border-color: rgba(167,139,250,0.8); background: rgba(124,58,237,0.12); }
.wt-step.is-todo { opacity: 0.55; }
.wt-step-title { display: flex; gap: 10px; align-items: center; width: 100%; background: none; border: 0; color: inherit; font: inherit; font-weight: 600; cursor: pointer; text-align: start; padding: 2px 0; }
.wt-step-num { flex: none; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: rgba(255,255,255,0.1); font-size: 13px; }
.wt-step.is-current .wt-step-num { background: var(--primary); }
.wt-step.is-done .wt-step-num { background: rgba(34,197,94,0.35); }
.wt-step-body p { margin: 6px 0; line-height: 1.6; }
.wt-step-body .wt-ar { color: #e9e3ff; }
.wt-step-tools { display: flex; gap: 14px; margin-top: 2px; }

.wt-board {
  position: sticky; top: 76px;
  min-height: 220px; max-height: 60vh; overflow: auto;
  background: radial-gradient(120% 90% at 30% 10%, #173f35, var(--board-bg));
  border: 8px solid #3b2f22; border-radius: 12px;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.35), 0 10px 30px rgba(0,0,0,0.3);
  padding: 16px 18px; color: var(--board-ink);
  font-family: "Kalam", "Caveat", "Patrick Hand", "Segoe Print", "Comic Sans MS", cursive;
  font-size: 21px; line-height: 1.5;
}
.wt-board-empty { color: rgba(238,247,241,0.45); font-size: 16px; }
.wt-board-group { padding: 4px 0 8px; border-bottom: 1px dashed rgba(238,247,241,0.12); opacity: 0.6; transition: opacity 0.3s; }
.wt-board-group:last-child { border-bottom: 0; }
.wt-board-group.is-current { opacity: 1; }
.wt-board-group.is-current .wt-board-line { color: #fff; animation: wt-write 0.7s ease-out both; animation-delay: var(--delay, 0s); }
.wt-board-group.is-current .wt-board-line:last-child { color: var(--board-accent); }
.wt-board-line { white-space: pre-wrap; overflow-wrap: anywhere; }
@keyframes wt-write {
  from { clip-path: inset(0 100% 0 0); opacity: 0.2; }
  to { clip-path: inset(0 0 0 0); opacity: 1; }
}
[dir="rtl"] .wt-board-group.is-current .wt-board-line { animation-name: wt-write-rtl; }
@keyframes wt-write-rtl {
  from { clip-path: inset(0 0 0 100%); opacity: 0.2; }
  to { clip-path: inset(0 0 0 0); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .wt-board-group.is-current .wt-board-line { animation: none; }
}

.wt-after { display: grid; gap: 10px; margin-top: 14px; }
.wt-card { border-radius: 12px; padding: 10px 14px; border: 1px solid var(--border); }
.wt-card p { margin: 4px 0 0; line-height: 1.6; }
.wt-card-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.wt-card-wrong { border-color: rgba(239,68,68,0.5); background: rgba(239,68,68,0.07); }
.wt-card-wrong .wt-card-label { color: #fca5a5; }
.wt-card-trap { border-color: rgba(245,158,11,0.5); background: rgba(245,158,11,0.07); }
.wt-card-trap .wt-card-label { color: #fcd34d; }
.wt-card-takeaway { border-color: rgba(34,197,94,0.5); background: rgba(34,197,94,0.07); }
.wt-card-takeaway .wt-card-label { color: #86efac; }
.wt-others summary { cursor: pointer; color: var(--muted); }
.wt-others ul { margin: 8px 0 0; padding-inline-start: 18px; line-height: 1.6; }
.wt-selfexplain { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }

.sat-result-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.sat-result .wt-host { margin-top: 12px; }

/* ---------- study plan ---------- */

.plan-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.plan-head h1 { margin-bottom: 4px; }
.plan-head-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.plan-empty { margin-top: 16px; }
.plan-next h2 { margin: 22px 0 10px; }
.plan-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.plan-card h3 { margin: 8px 0; }
.plan-card .actions { margin-top: 10px; }

.mastery { position: relative; height: 10px; border-radius: 99px; background: linear-gradient(90deg, rgba(239,68,68,0.25), rgba(245,158,11,0.25) 55%, rgba(34,197,94,0.28)); }
.mastery-range { position: absolute; top: 0; bottom: 0; border-radius: 99px; background: rgba(255,255,255,0.22); }
.mastery-dot { position: absolute; top: 50%; width: 14px; height: 14px; margin-left: -7px; margin-top: -7px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(124,58,237,0.6); }

.plan-section-title { margin-top: 18px; }
.plan-domain { margin: 10px 0 14px; }
.plan-domain-name { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.plan-skill { display: grid; grid-template-columns: minmax(180px, 2fr) minmax(120px, 2fr) 60px auto; gap: 14px; align-items: center; padding: 8px 0; border-top: 1px solid rgba(255,255,255,0.06); }
.plan-skill-name { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.plan-skill-actions { display: flex; gap: 12px; font-size: 14px; }
.plan-skill-actions a, .plan-test-actions a { color: #c4b5fd; }
.plan-skill-actions a:hover, .plan-test-actions a:hover { text-decoration: underline; }
.plan-tests { width: 100%; border-collapse: collapse; }
.plan-tests th, .plan-tests td { text-align: start; padding: 8px 6px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.plan-test-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.plan-howto summary { cursor: pointer; font-weight: 600; }
.plan-howto li { margin: 6px 0; line-height: 1.55; }

/* ---------- skill lesson ---------- */

.lesson-page { display: grid; gap: 16px; }
.lesson-page h1 { margin: 4px 0; }
.lesson-summary { font-size: 17px; line-height: 1.6; margin-top: 0; }
.lesson-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; margin: 12px 0 6px; }
.lesson-bigidea { border-inline-start: 4px solid var(--primary); background: rgba(124,58,237,0.12); border-radius: 10px; padding: 8px 14px 10px; }
.lesson-bigidea .lesson-label { margin-top: 4px; }
.lesson-bigidea p { font-size: 18px; font-weight: 600; margin: 4px 0; }
.lesson-strategy li { margin: 6px 0; line-height: 1.55; }
.lesson-concept-grid, .lesson-trap-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.lesson-concept-name { font-weight: 700; margin-bottom: 4px; }
.lesson-concept p { margin: 6px 0; line-height: 1.55; }
.lesson-example { background: rgba(0,0,0,0.18); border-radius: 8px; padding: 6px 8px; }
.lesson-trap-what { color: #fcd34d; margin-bottom: 6px; line-height: 1.5; }
.lesson-trap-fix { color: #86efac; line-height: 1.5; }
.lesson-desmos { margin-top: 12px; }
.lesson-worked .btn { margin: 12px 0; }
.lesson-scaffold li { margin: 6px 0; line-height: 1.5; }
.lesson-scaffold li.is-yours { font-weight: 700; color: #c4b5fd; }
.lesson-quickcheck { display: grid; gap: 12px; }
.lesson-quickcheck h2 { margin-bottom: 0; }

/* ---------- settings ---------- */

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.settings-row { display: flex; gap: 8px; align-items: center; }
.settings-row .input { flex: 1; }
.settings-check { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.settings-status { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.settings-status dt { color: var(--muted); }
.settings-status dd { margin: 0; }
select.input { appearance: auto; }
input[type="range"] { width: 100%; accent-color: var(--primary); }

/* ---------- word lookup popover ---------- */

.lk-pop {
  position: absolute; z-index: 200;
  background: #151b33; color: var(--text);
  border: 1px solid rgba(167,139,250,0.45); border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.5); padding: 12px 14px;
  font-size: 14px; line-height: 1.5;
}
.lk-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.lk-word { font-size: 18px; font-weight: 700; }
.lk-pos { color: var(--muted); font-style: italic; }
.lk-tools { display: flex; gap: 4px; }
.lk-btn { background: rgba(255,255,255,0.06); border: 1px solid var(--border); color: inherit; border-radius: 8px; cursor: pointer; padding: 2px 8px; font-size: 15px; }
.lk-def { margin: 8px 0 6px; }
.lk-ar { margin: 6px 0; font-size: 18px; color: #e9e3ff; }
.lk-ar-note { display: block; font-size: 14px; color: var(--muted); }
.lk-tip { background: rgba(245,158,11,0.1); border-radius: 8px; padding: 6px 8px; margin: 6px 0; }
.lk-example { color: var(--muted); font-style: italic; margin: 6px 0; }
.lk-more summary { cursor: pointer; color: var(--muted); }
.lk-more ol { margin: 6px 0 0; padding-inline-start: 18px; }
.lk-actions { display: flex; gap: 8px; margin-top: 8px; }

/* ---------- words page ---------- */

.words-list { display: grid; gap: 10px; }
.word-card { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: start; }
.word-card .lk-ar { margin: 0; }

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .pq-split, .wt-body { grid-template-columns: 1fr; }
  .wt-board { position: static; order: -1; min-height: 140px; }
  .plan-skill { grid-template-columns: 1fr; gap: 6px; }
  .topbar-inner { height: auto; flex-wrap: wrap; gap: 8px; padding-top: 8px; padding-bottom: 8px; }
  .nav { flex-wrap: wrap; gap: 4px; }
}

/* ---------- home ---------- */

.home-hero { align-items: stretch; }
.home-status h2 { margin-top: 0; }
.home-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 0 14px; }
.home-stats div { background: rgba(255,255,255,0.04); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.home-stats dt { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.home-stats dd { margin: 4px 0 0; font-size: 24px; font-weight: 700; }
.home-loop { padding-inline-start: 20px; line-height: 1.6; }
.home-loop li { margin: 6px 0; }
.home-tile { display: block; transition: transform 0.15s ease, border-color 0.15s ease; }
.home-tile:hover { transform: translateY(-2px); border-color: rgba(167,139,250,0.55); }
.home-tile h3 { margin-top: 0; }
.home-tip { margin-top: 18px; }
.home-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* ---------- ask the tutor ---------- */

.wt-ask { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); display: grid; gap: 8px; }
.wt-ask label { font-size: 14px; color: var(--muted); }
.wt-ask-row { display: flex; gap: 8px; }
.wt-ask-row .input { flex: 1; }
.wt-ask-bubble { background: rgba(124,58,237,0.12); border: 1px solid rgba(124,58,237,0.35); border-radius: 12px; padding: 10px 14px; line-height: 1.65; }

/* ---------- board test lab ---------- */

.lab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; margin-bottom: 20px; }
.lab-card { display: grid; gap: 8px; }
.lab-card.is-fail { border-color: rgba(239,68,68,0.6); }
.lab-card-head { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.lab-canvas { width: 100%; height: auto; border-radius: 8px; background: #fafaf7; }
.lab-checks { list-style: none; margin: 0; padding: 0; font-size: 13px; line-height: 1.5; }
.lab-checks .ok { color: #86efac; }
.lab-checks .no { color: #fca5a5; }
.lab-summary.is-pass { border-color: rgba(34,197,94,0.6); }
.lab-summary.is-fail { border-color: rgba(239,68,68,0.6); }

/* ---------- pacing (results) ---------- */

.pacing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 8px; }
.pacing-card { border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; background: rgba(255,255,255,0.03); }
.pacing-big { font-size: 26px; font-weight: 700; margin: 4px 0; }
.pacing-tip { margin-top: 6px; color: #fcd34d; line-height: 1.5; }
.pacing-slow { margin: 0; padding-inline-start: 20px; line-height: 1.9; }

/* ---------- board-v2 lesson player (Khan-style board) ---------- */

.lb { display: grid; gap: 12px; }
.lb-head h1 { margin: 6px 0 4px; }
.lb-stage {
  --lb-font: 26px;
  position: relative; aspect-ratio: 16 / 9; width: 100%;
  background: #121212; border-radius: 14px; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08); box-shadow: var(--shadow);
}
.lb-stage:fullscreen { border-radius: 0; }
.lb-stage [hidden] { display: none; }
.lb-board {
  position: absolute; inset: 3.5% 3% 4.5% 3%;
  display: grid; grid-template-columns: 1fr 1fr; column-gap: 5%;
  font-family: "Kalam", "Caveat", "Segoe Print", cursive; font-size: var(--lb-font); line-height: 1.32;
  color: #9be49b;
}
.lb-col { min-width: 0; overflow: hidden; display: flex; flex-direction: column; gap: 0.12em; }
.lb-heading { color: #f2f2f2; font-weight: 700; font-size: 0.9em; border-bottom: 2px solid rgba(242,242,242,0.35); padding-bottom: 0.1em; margin-bottom: 0.2em; align-self: flex-start; }
.lb-problem { color: #f3e37c; font-family: "Segoe UI", system-ui, sans-serif; font-size: 0.72em; line-height: 1.4; margin: 0.15em 0 0.35em; }
.lb-line { display: grid; grid-template-columns: 1fr auto 1fr; column-gap: 0.35em; align-items: baseline; position: relative; white-space: nowrap; }
.lb-line .lb-l { text-align: right; overflow: hidden; text-overflow: clip; }
.lb-line .lb-r { text-align: left; overflow: hidden; }
.lb-line.lb-expr { display: block; text-align: center; white-space: normal; }
/* Operations sit under the middle of each side, each side underlined separately (Khan style). */
.lb-op { color: #ff9ecf; font-size: 0.82em; margin-bottom: 0.1em; }
.lb-op .lb-l, .lb-op .lb-r { text-align: center; border-bottom: 2px solid rgba(255,158,207,0.7); padding-bottom: 0.02em; }
.lb-op .lb-l { margin-left: 18%; }
.lb-op .lb-r { margin-right: 18%; }
.lb-check { color: #7cc7ff; }
.lb-answer-wrap { text-align: center; margin: 0.2em 0 0.3em; }
.lb-answer { display: inline-block; color: #ff6fd8; border: 2px solid #ff6fd8; border-radius: 6px; padding: 0.02em 0.45em; }
.lb-note { color: #aab4c0; font-size: 0.66em; text-align: center; }
.lb-note-inline { position: absolute; right: 0; top: 0.35em; max-width: 30%; color: #aab4c0; font-size: 0.6em; line-height: 1.15; white-space: normal; text-align: right; }
.lb-figure { display: flex; justify-content: center; margin: 0.2em 0; }
.lb-figure canvas { max-width: 100%; }
.lb-tri { width: 80%; max-height: 9em; }
.lb-tri-t { fill: #f3e37c; font-family: "Kalam", cursive; font-size: 18px; }
.lb-tri-a { fill: #ff9ecf; }
.is-latest { filter: drop-shadow(0 0 6px rgba(255,255,255,0.18)); }
.is-writing { animation: lb-write var(--write-ms, 900ms) linear var(--write-delay, 0ms) both; }
@keyframes lb-write { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@media (prefers-reduced-motion: reduce) { .is-writing { animation: none; } }

.lb-start { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; background: rgba(0,0,0,0.35); }
.lb-bigplay { width: 84px; height: 84px; border-radius: 50%; border: 0; background: var(--primary); color: #fff; font-size: 34px; cursor: pointer; box-shadow: 0 10px 30px rgba(124,58,237,0.45); }
.lb-pause { position: absolute; top: 4%; left: 3%; z-index: 2; width: min(300px, 42%); background: rgba(20,20,20,0.88); border: 1px solid rgba(243,227,124,0.5); border-radius: 12px; padding: 10px 14px; text-align: center; display: grid; gap: 8px; }
.lb-pause-title { color: #f3e37c; font-weight: 700; }
.lb-pause-instruction { color: #fff; font-size: 14px; line-height: 1.35; }
.lb-notice { position: absolute; top: 4%; right: 3%; z-index: 3; width: min(260px, 38%); max-height: 45%; overflow: auto; display: grid; gap: 7px; padding: 10px 32px 10px 12px; border: 1px solid rgba(167,139,250,0.55); border-radius: 10px; background: rgba(20,20,20,0.84); color: #fff; font: 13px/1.35 system-ui, sans-serif; box-shadow: 0 6px 20px rgba(0,0,0,0.3); }
.lb-notice-text { overflow-wrap: anywhere; }
.lb-notice .btn { justify-self: start; }
.lb-overlay-close { position: absolute; top: 5px; right: 7px; border: 0; background: transparent; color: #fff; font-size: 22px; line-height: 1; cursor: pointer; }
.lb-end { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; background: rgba(0,0,0,0.5); }
.lb-end-card { position: relative; display: grid; gap: 14px; justify-items: center; max-width: min(90%, 440px); padding: 25px 38px; border: 1px solid rgba(167,139,250,0.55); border-radius: 14px; background: rgba(20,20,20,0.94); color: #fff; text-align: center; }
.lb-end-title { font-size: 20px; font-weight: 700; }
.lb-checkpoint { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; padding: 16px; background: rgba(0,0,0,.74); overflow: auto; }
.lb-checkpoint-card { width: min(100%, 560px); max-height: 100%; overflow: auto; display: grid; gap: 12px; padding: 20px; border-radius: 14px; background: var(--surface, #202027); color: var(--text, #fff); }
.lb-checkpoint-stem { font-size: 18px; font-weight: 650; }
.lb-checkpoint-card [data-lb-checkpoint-choices] { display: grid; gap: 7px; }
.lb-checkpoint-card .pq-result .btn, .pq-result .btn { margin: 10px 0 0 10px; }
.lb-caption { position: absolute; left: 50%; bottom: 3%; transform: translateX(-50%); max-width: 86%; background: rgba(0,0,0,0.78); color: #fff; font: 500 clamp(13px, calc(var(--lb-font) * 0.62), 22px)/1.4 system-ui, sans-serif; padding: 4px 10px; border-radius: 4px; text-align: center; }

.lb-controls { display: flex; gap: 8px; align-items: center; }
.lb-progress { position: relative; flex: 1; min-width: 60px; height: 10px; border-radius: 99px; background: rgba(255,255,255,0.1); cursor: pointer; touch-action: none; }
.lb-progress:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }
.lb-progress-fill { height: 100%; width: 0; border-radius: inherit; background: var(--primary); }
/* Markers sit above the scrubber without taking its drag surface away. */
.lb-progress-markers { position: absolute; inset: 0; pointer-events: none; }
.lb-marker { position: absolute; top: 50%; width: 12px; height: 12px; padding: 0; transform: translate(-50%, -50%); border: 2px solid #fff; border-radius: 50%; background: #f3e37c; cursor: pointer; pointer-events: auto; }
.lb-marker:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.lb-question, .lb-marker-panel { margin-top: 10px; }
.lb-question-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: center; }
.lb-question-row input { flex: 1; min-width: 220px; }
.lb-question [data-lb-question-result] { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.lb-question [hidden], .lb-marker-panel[hidden] { display: none; }
.lb-marker-panel { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.lb-return { display: block; margin-top: 6px; }
/* The tooltip stays outside the track so it remains visible in fullscreen controls. */
.lb-progress-tip { position: absolute; bottom: calc(100% + 9px); transform: translateX(-50%); padding: 3px 6px; border-radius: 4px; background: rgba(0,0,0,0.9); color: #fff; font-size: 12px; white-space: nowrap; pointer-events: none; }
.lb-step { white-space: nowrap; text-align: center; font-variant-numeric: tabular-nums; }
@media (max-width: 700px) { .lb-controls { flex-wrap: wrap; } .lb-progress { order: -1; flex-basis: 100%; } }
.lb-cc[aria-pressed="true"] { background: rgba(124,58,237,0.35); color: #fff; }
.lb-transcript summary { cursor: pointer; font-weight: 600; }
.lb-transcript ol { margin: 10px 0 0; padding-inline-start: 22px; line-height: 1.6; max-height: 320px; overflow: auto; }
.lb-transcript li { cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.lb-transcript li:hover { background: rgba(255,255,255,0.05); }
.lb-transcript li.is-current { background: rgba(124,58,237,0.2); }
@media (max-width: 700px) { .lb-board { grid-template-columns: 1fr; } }
.lb-wrong { color: #ff7b72; }
.lb-wrong .lb-l, .lb-wrong .lb-r, .lb-wrong.lb-expr { text-decoration: line-through; text-decoration-thickness: 2px; }
.lb-wrong::after { content: "✗"; position: absolute; right: 0; top: 0; color: #ff7b72; font-weight: 700; }

/* Long equations shrink to fit their column instead of being clipped at the board edge. */
.lb-line, .lb-problem, .lb-answer-wrap, .lb-heading { font-size: calc(1em * var(--fit, 1)); }
.lb-wrapped, .lb-wrapped .lb-l, .lb-wrapped .lb-r { white-space: normal; overflow-wrap: anywhere; }

/* Fullscreen: the controls travel with the board and reveal on hover, like a video player. */
.lb:fullscreen { background: #121212; display: flex; flex-direction: column; gap: 0; }
.lb:fullscreen .lb-head, .lb:fullscreen .lb-transcript { display: none; }
.lb:fullscreen .lb-stage { flex: 1; aspect-ratio: auto; border: 0; border-radius: 0; }
.lb:fullscreen .lb-controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 14px 18px; margin: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85), rgba(0,0,0,0));
  opacity: 0; transition: opacity 0.2s ease; pointer-events: none;
}
.lb:fullscreen:hover .lb-controls,
.lb:fullscreen .lb-controls:focus-within { opacity: 1; pointer-events: auto; }
.lb:fullscreen .lb-progress { height: 10px; }

/* Sign-in and registration */
.auth-card { max-width: 26rem; margin: 3rem auto; }
.auth-form { display: grid; gap: .35rem; margin-top: 1rem; }
.auth-form label { font-weight: 600; font-size: .9rem; margin-top: .6rem; }
.auth-form input { padding: .6rem .7rem; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-2); color: inherit; }
.auth-form .btn { margin-top: 1.1rem; justify-self: start; }
.auth-errors { color: var(--bad); font-size: .9rem; }
.auth-errors ul { margin: 0; padding-left: 1.1rem; }
.topbar-account { display: flex; align-items: center; gap: .5rem; }
