/* ============================================================
   NEXORA · Component / Lesson engine + learning widgets
   Built on the global theme — no new colour system.
   ============================================================ */

.le-block {
  margin-bottom: 1.6rem;
  scroll-margin-top: 120px;
}

.le-block h3 {
  font-size: 1.15rem;
  margin-bottom: 0.7rem;
}

.le-text p,
.le-note p {
  font-size: 0.97rem;
  line-height: 1.75;
  color: var(--text-2);
  margin-bottom: 0.8rem;
  max-width: 74ch;
}

.le-text p:last-child { margin-bottom: 0; }

.le-text ul,
.le-text ol,
.le-note ul {
  margin: 0 0 0.9rem 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.45rem;
}

.le-text li,
.le-note li {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-2);
}

.le-block code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  padding: 0.12em 0.4em;
  border-radius: 5px;
  background: rgba(106, 99, 255, 0.14);
  color: var(--accent-2);
}

/* ---------- note callouts ---------------------------------- */

.le-note {
  display: flex;
  gap: 0.85rem;
  padding: 1rem 1.15rem;
  border-radius: var(--radius-md);
  background: var(--glass-bg);
  box-shadow: var(--depth), var(--glass-edge);
  border-left: 3px solid var(--accent);
}

.le-note .icon { flex: none; margin-top: 0.2rem; color: var(--accent-2); }
.le-note p:last-child { margin-bottom: 0; }
.le-note.warn { border-left-color: var(--warning); }
.le-note.warn .icon { color: var(--warning); }
.le-note.tip { border-left-color: var(--success); }
.le-note.tip .icon { color: var(--success); }

/* ---------- diagram ----------------------------------------- */

.le-diagram pre {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--text-2);
  padding: 1.1rem 1.3rem;
  border-radius: var(--radius-md);
  background: rgba(3, 6, 16, 0.3);
  box-shadow: var(--depth), var(--glass-edge);
  overflow-x: auto;
  white-space: pre;
}

[data-theme="light"] .le-diagram pre { background: rgba(255, 255, 255, 0.6); }

/* ---------- static code ------------------------------------- */

.le-static {
  border-radius: var(--radius-md);
  overflow: hidden;
  background: rgba(3, 6, 16, 0.34);
  box-shadow: var(--depth), var(--glass-edge);
}

[data-theme="light"] .le-static { background: rgba(255, 255, 255, 0.6); }

.le-static-bar {
  padding: 0.45rem 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
}

.le-static pre {
  margin: 0;
  padding: 0.95rem 1.1rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-2);
}

.le-static pre code { background: none; padding: 0; font-size: inherit; color: inherit; }

.le-explain {
  margin-top: 0.8rem;
  display: grid;
  gap: 0.4rem;
}

.le-exp-title {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
}

.le-exp-row {
  display: grid;
  grid-template-columns: minmax(90px, auto) 1fr;
  gap: 0.9rem;
  align-items: baseline;
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
}

.le-exp-row code { white-space: nowrap; }
.le-exp-row span { font-size: 0.88rem; color: var(--text-2); line-height: 1.55; }

/* ---------- runner ------------------------------------------ */

.le-runner {
  --le-h: 220px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--glass-bg);
  box-shadow: var(--depth), var(--glass-edge);
}

.le-run-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.le-lang {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}

.le-lang .icon { width: 0.9em; height: 0.9em; color: var(--accent-2); }

.le-run-status {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-3);
}

.le-run-status.ok { color: var(--success); }
.le-run-status.err { color: var(--danger); }
.le-run-status.busy { color: var(--accent-2); }

.le-run-actions {
  margin-left: auto;
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.le-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: color var(--dur-fast), background var(--dur-fast), transform var(--dur-fast);
}

.le-btn .icon { width: 0.92em; height: 0.92em; }
.le-btn:hover { color: var(--text-1); background: rgba(255, 255, 255, 0.08); }
.le-btn:active { transform: translateY(1px); }

.le-btn.primary {
  color: #fff;
  background: var(--gradient-brand);
  box-shadow: 0 6px 16px -8px var(--glow-accent), inset 0 1px 0 rgba(255, 255, 255, 0.26);
}

.le-mini {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  color: var(--text-3);
}

.le-mini:hover { color: var(--text-1); background: rgba(255, 255, 255, 0.09); }

.le-run-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: var(--le-h);
}

.le-runner.compact .le-run-body { grid-template-columns: 1fr; }

.le-editor-host {
  position: relative;
  min-height: var(--le-h);
  border-right: 1px solid var(--border);
}

.le-runner.compact .le-editor-host {
  border-right: 0;
  border-bottom: 1px solid var(--border);
}

.le-editor { position: absolute; inset: 0; }

.le-output {
  display: flex;
  flex-direction: column;
  min-height: var(--le-h);
  min-width: 0;
}

.le-out-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
}

.le-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
  min-height: 140px;
}

.le-console {
  flex: 1;
  margin: 0;
  padding: 0.6rem 0.8rem;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-2);
  background: rgba(3, 6, 16, 0.26);
  min-height: 120px;
  white-space: pre-wrap;
  word-break: break-word;
}

[data-theme="light"] .le-console { background: rgba(255, 255, 255, 0.55); }

.le-line.err { color: var(--danger); }
.le-line.warn { color: var(--warning); }
.le-line.dim, .le-dim { color: var(--text-3); font-style: italic; }

/* fullscreen runner */
.le-runner.is-full {
  position: fixed;
  inset: 1.2rem;
  z-index: 200;
  --le-h: auto;
  background: var(--bg-elevated);
  box-shadow: var(--depth-lg);
}

.le-runner.is-full .le-run-body { height: calc(100% - 46px); }
body.le-fullscreen { overflow: hidden; }

/* ---------- interactive blocks -------------------------------- */

.le-inter {
  padding: 1.15rem 1.25rem;
  border-radius: var(--radius-lg);
  background: var(--glass-bg);
  box-shadow: var(--depth), var(--glass-edge);
}

.le-inter-head {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-bottom: 0.8rem;
}

.le-q, .le-task {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-1);
  line-height: 1.5;
  margin-bottom: 0.8rem;
}

.le-options {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 0.7rem;
}

.le-option {
  text-align: left;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  color: var(--text-2);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast), box-shadow var(--dur-fast);
}

.le-option:hover:not(:disabled) {
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.1);
}

.le-option.is-right {
  color: var(--success);
  background: rgba(61, 214, 140, 0.12);
  box-shadow: inset 0 0 0 1px rgba(61, 214, 140, 0.45);
}

.le-option.is-wrong {
  color: var(--danger);
  background: rgba(255, 107, 129, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 107, 129, 0.45);
}

.le-option:disabled { cursor: default; }

.le-feedback {
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-2);
  background: rgba(255, 255, 255, 0.05);
}

.le-feedback.good { color: var(--success); background: rgba(61, 214, 140, 0.1); }
.le-feedback.bad { color: var(--text-2); background: rgba(255, 201, 77, 0.1); }
.le-feedback b { color: inherit; }

.le-qz { margin-bottom: 1.1rem; }
.le-qz:last-of-type { margin-bottom: 0.6rem; }

.le-quiz-score {
  margin-top: 0.8rem;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-2);
  background: rgba(255, 255, 255, 0.06);
  text-align: center;
}

.le-quiz-score.good { color: var(--success); background: rgba(61, 214, 140, 0.12); }

.le-task-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.8rem;
}

.le-check-msg {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-3);
}

.le-check-msg.good { color: var(--success); }
.le-check-msg.bad { color: var(--warning); }

.le-hint {
  margin-top: 0.7rem;
  padding: 0.75rem 0.95rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-2);
  background: rgba(255, 201, 77, 0.1);
  border-left: 3px solid var(--warning);
}

.le-hint p { margin: 0; }
.le-after { margin-top: 0.8rem; }

/* fill in the blank */
.le-blank-code {
  margin: 0 0 0.5rem;
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-sm);
  background: rgba(3, 6, 16, 0.3);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 2;
  color: var(--text-2);
  white-space: pre-wrap;
  overflow-x: auto;
}

[data-theme="light"] .le-blank-code { background: rgba(255, 255, 255, 0.6); }

.le-blank-input {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 0.15rem 0.45rem;
  border: 0;
  border-radius: 5px;
  color: var(--text-1);
  background: rgba(106, 99, 255, 0.18);
  box-shadow: inset 0 0 0 1px var(--border-accent);
  outline: none;
}

.le-blank-input:focus { box-shadow: 0 0 0 2px var(--accent); }
.le-blank-input.is-right { background: rgba(61, 214, 140, 0.18); box-shadow: inset 0 0 0 1px var(--success); }
.le-blank-input.is-wrong { background: rgba(255, 107, 129, 0.16); box-shadow: inset 0 0 0 1px var(--danger); }

/* mistakes */
.le-mistakes { display: grid; gap: 0.7rem; }

.le-mistake {
  display: grid;
  gap: 0.4rem;
  padding: 0.9rem 1.05rem;
  border-radius: var(--radius-md);
  background: var(--glass-bg);
  box-shadow: var(--depth), var(--glass-edge);
}

.le-bad, .le-good {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.86rem;
}

.le-bad .icon { color: var(--danger); flex: none; margin-top: 0.15rem; }
.le-good .icon { color: var(--success); flex: none; margin-top: 0.15rem; }
.le-bad code { background: rgba(255, 107, 129, 0.12); color: var(--danger); }
.le-good code { background: rgba(61, 214, 140, 0.12); color: var(--success); }
.le-why { font-size: 0.84rem; color: var(--text-3); line-height: 1.55; padding-left: 1.5rem; }

/* key points */
.le-key {
  padding: 1.15rem 1.3rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(120deg, rgba(106, 99, 255, 0.1), rgba(47, 210, 242, 0.06));
  box-shadow: var(--depth), var(--glass-edge);
}

.le-key h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  margin-bottom: 0.8rem;
}

.le-key h3 .icon { color: var(--gold); }
.le-key ul { list-style: none; padding: 0; display: grid; gap: 0.55rem; }

.le-key li {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.93rem;
  line-height: 1.55;
  color: var(--text-2);
}

.le-key li .icon { color: var(--success); flex: none; margin-top: 0.2rem; width: 0.95em; height: 0.95em; }

/* lab handoff */
.le-lab {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1rem 1.15rem;
  border-radius: var(--radius-md);
  background: var(--glass-bg);
  box-shadow: var(--depth), var(--glass-edge);
  flex-wrap: wrap;
}

.le-lab .icon-tile { width: 42px; height: 42px; }
.le-lab div { flex: 1; min-width: 180px; }
.le-lab b { display: block; font-family: var(--font-display); color: var(--text-1); font-size: 0.95rem; }
.le-lab span { font-size: 0.82rem; color: var(--text-3); }

/* ============================================================
   WIDGETS
   ============================================================ */

.wg {
  padding: 1.1rem;
  border-radius: var(--radius-md);
  background: var(--glass-bg);
  box-shadow: var(--depth), var(--glass-edge);
}

.wg-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
  font-size: 0.85rem;
  color: var(--text-2);
}

.wg-spacer { flex: 1; }

.wg-row {
  display: grid;
  grid-template-columns: 74px 1fr 60px;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.wg-row label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.wg-row input[type="range"] { width: 100%; accent-color: var(--accent); }

.wg-row output,
.wg-row select {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--accent-2);
  text-align: right;
}

.wg-row select {
  background: rgba(255, 255, 255, 0.07);
  border: 0;
  border-radius: 6px;
  padding: 0.25rem 0.4rem;
  color: var(--text-1);
  text-align: left;
}

.wg-result, .wg-calc { margin-top: 0.9rem; }

.wg-big {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.03em;
  line-height: 1;
}

.wg-big i {
  font-size: 0.9rem;
  font-style: normal;
  color: var(--text-3);
  margin-left: 0.3rem;
}

.wg-meta {
  display: flex;
  gap: 1rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-3);
  margin: 0.4rem 0 0.6rem;
}

.wg-gauge {
  height: 8px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
}

.wg-gauge span {
  display: block;
  height: 100%;
  border-radius: 99px;
  transition: width var(--dur) var(--ease-out);
}

.wg-gauge .ok { background: linear-gradient(90deg, var(--success), var(--accent-2)); }
.wg-gauge .warn { background: linear-gradient(90deg, var(--warning), #ff9d5c); }
.wg-gauge .danger { background: linear-gradient(90deg, var(--danger), #ff3b30); }

.wg-verdict { margin-top: 0.6rem; font-size: 0.85rem; line-height: 1.5; color: var(--text-2); }
.wg-verdict.good { color: var(--success); }
.wg-verdict.warn { color: var(--warning); }
.wg-verdict.bad { color: var(--danger); }

.wg-hint { margin-top: 0.7rem; font-size: 0.8rem; line-height: 1.55; color: var(--text-3); }

.wg-formula {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.7;
  color: var(--text-2);
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  background: rgba(3, 6, 16, 0.26);
  margin-bottom: 0.7rem;
}

.wg-neuron { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.wg-neuron-viz { display: grid; place-items: center; height: 80px; }

.wg-fire {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-2), var(--accent));
  box-shadow: 0 0 30px var(--glow-cyan);
  transition: opacity var(--dur), transform var(--dur);
}

.wg-canvas {
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  background: rgba(3, 6, 16, 0.3);
  cursor: crosshair;
  display: block;
}

.wg-stats {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-3);
}

.wg-legend { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; }
.wg-legend i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.wg-legend .c0 { background: #6a63ff; }
.wg-legend .c1 { background: #2fd2f2; margin-left: 0.5rem; }

.wg-pixels { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.wg-pixels h5 { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-3); margin-bottom: 0.6rem; }

.wg-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
  aspect-ratio: 1;
  margin-bottom: 0.6rem;
}

.wg-cell {
  aspect-ratio: 1;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.09);
  cursor: crosshair;
}

.wg-matrix {
  font-family: var(--font-mono);
  font-size: 9.5px;
  line-height: 1.5;
  color: var(--accent-2);
  background: rgba(3, 6, 16, 0.3);
  padding: 0.7rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 0;
}

.wg-input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-1);
  font-size: 0.9rem;
  outline: none;
  margin-bottom: 0.8rem;
}

.wg-input:focus { box-shadow: 0 0 0 2px var(--accent); }

.wg-token-out { display: flex; flex-wrap: wrap; gap: 0.3rem; }

.wg-tok {
  display: inline-grid;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  background: hsl(calc(243 + var(--i) * 24) 70% 60% / 0.18);
  box-shadow: inset 0 0 0 1px hsl(calc(243 + var(--i) * 24) 70% 60% / 0.4);
  text-align: center;
}

.wg-tok b { font-family: var(--font-mono); font-size: 0.76rem; color: var(--text-1); font-weight: 500; }
.wg-tok i { font-family: var(--font-mono); font-size: 0.6rem; font-style: normal; color: var(--text-3); }

.wg-text {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.06);
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
}

.wg-temp { display: inline-flex; align-items: center; gap: 0.4rem; font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-3); }
.wg-temp input { width: 90px; accent-color: var(--accent); }

.wg-dist { display: grid; gap: 0.35rem; margin-top: 0.8rem; }

.wg-cand {
  display: grid;
  grid-template-columns: 110px 1fr 54px;
  align-items: center;
  gap: 0.6rem;
}

.wg-cand-tok { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-1); }
.wg-cand-bar { height: 10px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.wg-cand-bar i { display: block; height: 100%; background: var(--gradient-brand); }
.wg-cand-p { font-family: var(--font-mono); font-size: 0.72rem; color: var(--accent-2); text-align: right; }

.wg-toggles { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.9rem; }

.wg-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.8rem;
  color: var(--text-2);
  cursor: pointer;
}

.wg-toggle input { accent-color: var(--accent); }
.wg-toggle:has(input:checked) { color: var(--text-1); background: rgba(106, 99, 255, 0.2); }

.wg-prompt-out pre {
  margin: 0;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  background: rgba(3, 6, 16, 0.3);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.7;
  color: var(--text-2);
  white-space: pre-wrap;
}

.wg-prompt-out h5,
.wg-quality span {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 0.5rem;
}

.wg-quality {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.7rem;
  margin-top: 0.9rem;
}

.wg-quality b { font-family: var(--font-mono); font-size: 0.85rem; color: var(--accent-2); }

/* ---------- responsive -------------------------------------- */

@media (max-width: 860px) {
  .le-run-body { grid-template-columns: 1fr; }
  .le-editor-host { border-right: 0; border-bottom: 1px solid var(--border); }
  .wg-neuron, .wg-pixels { grid-template-columns: 1fr; }
  .le-exp-row { grid-template-columns: 1fr; gap: 0.3rem; }
  .wg-cand { grid-template-columns: 80px 1fr 48px; }
}
