/* Sovi PBL Interactive Learning Lab Design System
   Concentric radius, optical centering, subtle elevations, and accessible dark mode.
*/
.pbl-lab {
  margin: 20px 0;
  padding: 24px;
  border: 1px solid #e0e7ff;
  border-radius: 20px;
  background: var(--card, #ffffff);
  color: var(--ink, #0f172a);
  box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.04), 0 10px 25px -3px rgba(79, 70, 229, 0.08);
  max-width: 100%;
  overflow: hidden;
  transition-property: box-shadow, border-color;
  transition-duration: 200ms;
  transition-timing-function: ease-out;
}

.pbl-lab:hover {
  border-color: #c7d2fe;
  box-shadow: 0 6px 10px -2px rgba(79, 70, 229, 0.06), 0 16px 32px -4px rgba(79, 70, 229, 0.12);
}

.pbl-title {
  font-weight: 750;
  font-size: 18px;
  line-height: 1.35;
  margin: 0 0 8px;
  color: var(--ink, #0f172a);
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.pbl-instructions {
  font-size: 14px;
  line-height: 1.6;
  margin: 0 0 16px;
  color: var(--ink-soft, #475569);
  text-wrap: pretty;
}

.pbl-plot {
  display: block;
  width: 100%;
  height: auto;
  min-height: 260px;
  max-height: 380px;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.pbl-controls, .pbl-task {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.pbl-control-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.pbl-select {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 8px 14px;
  background: var(--card, #ffffff);
  color: var(--ink, #1e293b);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  min-height: 40px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition-property: border-color, box-shadow;
  transition-duration: 150ms;
}

.pbl-select:hover {
  border-color: #94a3b8;
}

.pbl-label {
  font-size: 13.5px;
  font-weight: 600;
  min-width: 110px;
  color: var(--ink, #334155);
  letter-spacing: -0.01em;
}

.pbl-slider {
  min-width: 140px;
  flex: 1;
  accent-color: #4f46e5;
  min-height: 40px;
  cursor: pointer;
}

.pbl-readout {
  font-variant-numeric: tabular-nums;
  font-size: 13.5px;
  font-weight: 600;
  min-width: 180px;
  color: var(--ink, #1e293b);
  background: #f1f5f9;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.pbl-guess {
  width: 130px;
  max-width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 9px 12px;
  background: var(--card, #ffffff);
  color: var(--ink, #0f172a);
  font-size: 14px;
  font-weight: 500;
  min-height: 40px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
  transition-property: border-color, box-shadow;
  transition-duration: 150ms;
}

.pbl-guess:hover {
  border-color: #94a3b8;
}

.pbl-check {
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  color: #ffffff;
  padding: 10px 18px;
  cursor: pointer;
  min-height: 42px;
  font-size: 13.5px;
  font-weight: 650;
  letter-spacing: 0.01em;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2), 0 4px 10px rgba(79, 70, 229, 0.15);
  transition-property: transform, box-shadow, background;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}

.pbl-check:hover {
  background: linear-gradient(135deg, #4338ca 0%, #3730a3 100%);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
  transform: translateY(-1px);
}

.pbl-check:active {
  transform: scale(0.97) translateY(0);
}

.pbl-check:focus-visible, .pbl-slider:focus-visible, .pbl-guess:focus-visible, .pbl-select:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

.pbl-feedback {
  width: 100%;
  font-size: 13.5px;
  margin: 6px 0 0;
  color: var(--ink-soft, #475569);
  line-height: 1.55;
  padding: 8px 12px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid transparent;
  transition-property: background-color, border-color, color;
  transition-duration: 200ms;
}

.pbl-feedback[data-result=correct] {
  color: #065f46;
  background: #ecfdf5;
  border-color: #a7f3d0;
  font-weight: 600;
}

.pbl-feedback[data-result=retry] {
  color: #9a3412;
  background: #fff7ed;
  border-color: #fed7aa;
}

.pbl-code {
  margin-top: 18px;
  font-size: 12px;
  color: var(--ink-soft, #64748b);
}

.pbl-code summary {
  cursor: pointer;
  min-height: 32px;
  user-select: none;
  font-weight: 500;
  transition-property: color;
  transition-duration: 150ms;
}

.pbl-code summary:hover {
  color: #4f46e5;
}

.pbl-code pre {
  overflow-x: auto;
  max-height: 220px;
  padding: 14px;
  border-radius: 10px;
  background: #0f172a;
  color: #f1f5f9;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid #1e293b;
}

/* Dark Mode / Night Reading Palette Harmony */
.dark .pbl-lab, [data-theme="dark"] .pbl-lab, .night-mode .pbl-lab {
  background: #18181b;
  border-color: #27272a;
  color: #f4f4f5;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.dark .pbl-plot, [data-theme="dark"] .pbl-plot, .night-mode .pbl-plot {
  background: #121214;
  border-color: #27272a;
}

.dark .pbl-readout, [data-theme="dark"] .pbl-readout, .night-mode .pbl-readout {
  background: #27272a;
  border-color: #3f3f46;
  color: #fafafa;
}

.dark .pbl-guess, [data-theme="dark"] .pbl-guess, .night-mode .pbl-guess,
.dark .pbl-select, [data-theme="dark"] .pbl-select, .night-mode .pbl-select {
  background: #27272a;
  border-color: #3f3f46;
  color: #f4f4f5;
}

/* ================= Aha Moment Recommendation Capsules ================= */
.aha-container {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed color-mix(in srgb, var(--purple, #7c3aed) 20%, var(--line, #e2e8f0));
}

/* Chat answers use the same even grid as solved problems (app-solve/v4-solution.css). */
.aha-container { container-type: inline-size; }
.aha-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.aha-grid > .aha-capsule:last-child:nth-child(odd) { grid-column: 1 / -1; }
@container (max-width: 520px) { .aha-grid { grid-template-columns: minmax(0, 1fr); } }
@supports not (container-type: inline-size) { @media (max-width: 600px) { .aha-grid { grid-template-columns: minmax(0, 1fr); } } }
.aha-grid .aha-capsule { width: 100%; min-width: 0; text-align: start; }
.aha-capsule-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow-wrap: anywhere;
}
.aha-capsule-arrow { flex: none; width: 14px; height: 14px; margin-inline-start: auto; }
[dir="rtl"] .aha-capsule-arrow { transform: scaleX(-1); }
.aha-capsule:focus { outline: none; }
.aha-capsule:focus-visible { outline: 2px solid var(--purple, #7c3aed); outline-offset: 2px; }

.aha-capsule {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink, #1e293b);
  background: color-mix(in srgb, var(--purple, #7c3aed) 5%, var(--card, #ffffff));
  border: 1px solid color-mix(in srgb, var(--purple, #7c3aed) 22%, transparent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  cursor: pointer;
  user-select: none;
  transition-property: transform, border-color, background-color, box-shadow;
  transition-duration: 160ms;
  transition-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
}

.aha-capsule:hover {
  transform: translateY(-1.5px);
  background: color-mix(in srgb, var(--purple, #7c3aed) 10%, var(--card, #ffffff));
  border-color: color-mix(in srgb, var(--purple, #7c3aed) 45%, transparent);
  box-shadow: 0 4px 10px rgba(124, 58, 237, 0.1);
}

.aha-capsule:active {
  transform: scale(0.97) translateY(0);
}

.aha-capsule-badge {
  font-family: inherit;
  white-space: nowrap;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--purple, #7c3aed) 14%, transparent);
  color: var(--purple, #6d28d9);
  flex-shrink: 0;
}

.dark .aha-capsule, [data-theme="dark"] .aha-capsule, .night-mode .aha-capsule {
  background: rgba(39, 39, 42, 0.65);
  border-color: rgba(124, 58, 237, 0.3);
  color: #f4f4f5;
}

.dark .aha-capsule:hover, [data-theme="dark"] .aha-capsule:hover, .night-mode .aha-capsule:hover {
  background: rgba(49, 46, 129, 0.25);
  border-color: rgba(167, 139, 250, 0.5);
}

@media(max-width: 540px) {
  .pbl-lab {
    padding: 16px;
    border-radius: 16px;
  }
  .aha-capsule {
    width: 100%;
    justify-content: space-between;
  }
}

@media(prefers-reduced-motion: reduce) {
  .pbl-lab, .pbl-check, .pbl-select, .pbl-guess, .pbl-feedback, .aha-capsule {
    transition: none !important;
    transform: none !important;
  }
}
