:root {
  --glass-bg: rgba(255,255,255,0.75);
  --glass-border: rgba(0,0,0,0.08);
}

.panel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.14);
}

.input {
  width: 100%;
  background: rgba(255,255,255,0.9);
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
  color: #0f172a;
}
.input:focus {
  border-color: rgba(99,102,241,0.6);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
}

.btn-primary {
  padding: 10px 16px;
  border-radius: 12px;
  background: linear-gradient(135deg, #5c67ff, #d946ef);
  color: white;
  font-weight: 600;
  box-shadow: 0 10px 20px rgba(217,70,239,0.18);
}
.btn-primary:hover { filter: brightness(1.05); }

.btn-secondary {
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(0,0,0,0.04);
  color: #0f172a;
  border: 1px solid rgba(0,0,0,0.12);
}
.btn-secondary:hover { background: rgba(0,0,0,0.06); }

.chunk-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 18px 18px 12px 18px; /* slightly less bottom padding */
  display: grid;
  grid-template-rows: auto 1fr;
  box-shadow: 0 20px 60px rgba(0,0,0,0.14);
  overflow-y: auto; /* allow vertical scroll for tall content */
}

/* Central column now flexible to allow equal-width layout */
main {
  max-width: calc(800px + 800px + 1.5rem) !important; /* two columns + gap-6 */
  margin-left: auto;
  margin-right: auto;
}

#central, aside {
  max-width: 800px;
}

.chunk-title {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  margin-bottom: 28px;
}
.prereq-inline-card {
  margin-top: 0;
  margin-bottom: 32px;
}
.prereq-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.chunk-body {
  margin-top: 0;
  line-height: 1.7;
  color: #0f172a;
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
  box-sizing: border-box;
}
.chunk-body * { max-width: 100%; }
.chunk-body *, .chunk-card { box-sizing: border-box; }

/* Markdown content styling */
.chunk-body h1, .chunk-body h2, .chunk-body h3 {
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
}
.chunk-body h1 { font-size: 1.5rem; }
.chunk-body h2 { font-size: 1.25rem; }
.chunk-body h3 { font-size: 1.1rem; }
.chunk-body p { margin: 0.4rem 0; }
.chunk-body ul { list-style: disc; padding-left: 1.25rem; margin: 0.4rem 0; }
.chunk-body ol { list-style: decimal; padding-left: 1.25rem; margin: 0.4rem 0; }
.chunk-body code {
  background: rgba(0,0,0,0.035);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 6px;
  padding: 0.1rem 0.35rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.95rem;
}
.chunk-body pre { overflow-x: auto; white-space: pre-wrap; word-break: break-word; background: rgba(0,0,0,0.035); border: 1px solid rgba(0,0,0,0.08); border-radius: 8px; }
.chunk-body pre code { display: block; padding: 0.75rem; white-space: inherit; font-size: 0.95rem; }
.chunk-body blockquote {
  border-left: 3px solid rgba(92, 103, 255, 0.4);
  padding-left: 0.75rem;
  color: rgba(15,23,42,0.75);
}
.chunk-body a { color: #3f47f6; text-decoration: underline; }

/* Tables */
.chunk-body table { width: 100%; display: block; overflow-x: auto; border-collapse: collapse; }
.chunk-body th, .chunk-body td { border: 1px solid rgba(0,0,0,0.08); padding: 0.35rem 0.5rem; }

/* Responsive media inside markdown */
.chunk-body img,
.chunk-body svg,
.chunk-body video,
.chunk-body canvas {
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  max-inline-size: 100%;
  block-size: auto;
  display: block;
  margin: 0.5rem auto;
  border-radius: 8px;
  object-fit: contain;
  float: none !important;
  position: static !important;
  transform: none !important;
}
.chunk-body img { display: none !important; }
.chunk-body figure { margin: 0.75rem 0; max-width: 100%; }
.chunk-body figcaption { font-size: 0.8rem; color: rgba(15,23,42,0.7); margin-top: 0.25rem; }
.chunk-body > * { max-width: 100%; }

/* Thumbnail images in central column */
.chunk-body img.thumb {
  width: 96px !important;
  max-width: 96px !important;
  height: auto !important;
  display: block !important;
  margin: 8px auto !important;
  object-fit: contain !important;
}

/* Truncated code snippet in central column */
.chunk-body pre.code-snippet {
  max-height: 8.5rem; /* ~5-6 lines typically */
  overflow: hidden;
  position: relative;
}
.chunk-body pre.code-snippet::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2.5rem;
  background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,0.85));
}
.chunk-body .code-more {
  font-size: 0.8rem;
  color: #3f47f6;
  cursor: pointer;
  margin-top: 4px;
  user-select: none;
}
.chunk-body .code-more:hover { text-decoration: underline; }

/* Visible anchor badge for removed code listings in central column */
.chunk-body .code-anchor {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 9999px;
  font-size: 0.8rem;
  line-height: 1;
  background: rgba(99,102,241,0.10);
  color: #343ad1;
  border: 1px solid rgba(99,102,241,0.35);
  cursor: pointer;
  user-select: none;
}
.chunk-body .code-anchor::before {
  content: "</>";
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.8rem;
}
.chunk-body .code-anchor:hover {
  background: rgba(99,102,241,0.18);
  border-color: rgba(99,102,241,0.55);
}

/* Make code larger in the right-side preview */
#artifactContent pre,
#artifactContent code {
  font-size: 0.95rem !important;
}

/* Make code larger in inline prerequisite/primer panels */
.prereq-inline pre code {
  font-size: 0.95rem;
}

/* Prereq list layout - one per line */
.prereq-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 50px;
}
.prereq-pill {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 8px 0;
  border-radius: 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.prereq-pill:last-child {
  border-bottom: none;
}
.prereq-pill .title {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 600;
  font-size: 0.9rem;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.5;
}
.prereq-pill .actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.prereq-pill .btn-primary,
.prereq-pill .btn-secondary {
  padding: 6px 10px;
  border-radius: 9999px;
  font-size: 0.8rem;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Animations */
@keyframes cardInLeft {
  from { opacity: 0; transform: translate3d(-28px, 0, 0) scale(0.98); }
  to   { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}
@keyframes cardOutLeft {
  from { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
  to   { opacity: 0; transform: translate3d(-28px, 0, 0) scale(0.98); }
}
@keyframes cardInRight {
  from { opacity: 0; transform: translate3d(28px, 0, 0) scale(0.98); }
  to   { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}
@keyframes cardOutRight {
  from { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
  to   { opacity: 0; transform: translate3d(28px, 0, 0) scale(0.98); }
}

.enter-left { animation: cardInLeft 420ms cubic-bezier(.2,.7,.2,1) both; }
.leave-left { animation: cardOutLeft 360ms cubic-bezier(.2,.7,.2,1) both; }
.enter-right { animation: cardInRight 420ms cubic-bezier(.2,.7,.2,1) both; }
.leave-right { animation: cardOutRight 360ms cubic-bezier(.2,.7,.2,1) both; }

/* Spinner */
@keyframes spin { to { transform: rotate(360deg); } }

.btn-primary.is-loading,
.btn-secondary.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn-primary.is-loading::after,
.btn-secondary.is-loading::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  margin-top: -8px;
  border-radius: 9999px;
  border: 2px solid rgba(15,23,42,0.35);
  border-top-color: rgba(99,102,241,0.9);
  animation: spin 0.8s linear infinite;
}

.answer-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: box-shadow .18s ease, border-color .18s ease, background .18s ease;
}
.answer-option:hover { background: #fafafa; border-color: rgba(99,102,241,0.35); box-shadow: 0 4px 14px rgba(0,0,0,0.08); }
.answer-option:focus { outline: none; }
.answer-option:focus-visible { box-shadow: 0 0 0 3px rgba(99,102,241,0.25); border-color: rgba(99,102,241,0.55); }

.answer-bullet {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 9999px;
  background: rgba(99,102,241,0.10);
  color: #343ad1;
  border: 1px solid rgba(99,102,241,0.25);
  font-weight: 700;
  font-size: 0.85rem;
}

.answer-option.is-loading {
  position: relative;
  opacity: 0.8;
  pointer-events: none;
}
.answer-option.is-loading::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border-radius: 9999px;
  border: 2px solid rgba(15,23,42,0.25);
  border-top-color: rgba(99,102,241,0.9);
  animation: spin 0.8s linear infinite;
}

.answer-correct { border-color: rgba(34,197,94,0.5) !important; background: rgba(34,197,94,0.08) !important; }
.answer-wrong { border-color: rgba(239,68,68,0.5) !important; background: rgba(239,68,68,0.08) !important; }
.answer-correct .answer-bullet { background: rgba(34,197,94,0.12); color: #047857; border-color: rgba(34,197,94,0.35); }
.answer-wrong .answer-bullet { background: rgba(239,68,68,0.12); color: #b91c1c; border-color: rgba(239,68,68,0.35); }

/* Preview panel: figure captions under images */
#artifactContent .figure-caption {
  margin-top: 6px;
  font-size: 0.85rem;
  color: rgba(15,23,42,0.7);
  font-style: italic;
}

/* Underlined figure references inside central text */
.chunk-body .figure-ref {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-decoration-style: solid;
  text-underline-offset: 3px;
  cursor: pointer;
  text-decoration-color: rgba(63,71,246,0.85);
}
.chunk-body .figure-ref:hover {
  color: #3f47f6;
  text-decoration-thickness: 3px;
}

