/* Mint App - Fancy UI Overhaul */

:root {
  /* --- Design System --- */
  --content-font-size: 16px;
  --content-line-height: 1.6;
  --content-font-family: "Inter", system-ui, -apple-system, sans-serif;
  --heading-font-family: "Outfit", system-ui, sans-serif;

  /* Colors */
  --primary-color: #3b82f6;
  --primary-gradient: linear-gradient(135deg, #2563eb 0%, #9333ea 100%);
  --secondary-gradient: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
  --accent-color: #10b981;
  --danger-color: #ef4444;

  --bg-color: #f3f4f6;
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: 1px solid rgba(255, 255, 255, 0.5);

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Radius */
  --radius-md: 12px;
  --radius-lg: 16px;

  /* Layout */
  --sidebar-w: 420px;
  --header-height: 0px;
}

/* --- Global --- */
html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at top left, #f0f9ff, #f3f4f6, #eef2ff);
  color: #1f2937;
  font-family: var(--content-font-family);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  /* App handles scrolling internally */
}

/* Explicit styling for textbf/textit result tags */
strong,
b {
  font-weight: bold;
}

em,
i {
  font-style: italic;
}

/* --- Layout Grid --- */
.app-split {
  display: grid;
  grid-template-columns: 2fr 5fr 5fr;
  gap: 24px;
  align-items: stretch;
  height: 100vh;
  padding: 24px;
  box-sizing: border-box;
}

/* Columns */
.column {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  box-sizing: border-box;

  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);

  transition: transform 0.3s ease, box-shadow 0.3s ease;
  animation: slideUpFade 0.8s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.list-column {
  animation-delay: 0.1s;
}

.task-column {
  animation-delay: 0.2s;
}

.sidebar-column {
  animation-delay: 0.3s;
}

@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Typography --- */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--heading-font-family);
  margin: 0;
  color: #111;
}

/* Task Title */
#task-area h2 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  width: fit-content;
  letter-spacing: -0.02em;
  animation: fadeIn 0.8s ease-out 0.4s backwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* --- List Panel (Left) --- */
.list-column {
  padding: 16px;
}

.list-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
  min-height: 0;
  /* Important for nested scroll */
}

.list-back-tile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: white;
  border: 1px solid rgba(0, 0, 0, 0.05);
  cursor: pointer;
  font-weight: 600;
  color: #4b5563;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.list-back-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  color: var(--primary-color);
}

.list-panel-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-title {
  font-size: 1.25rem;
  font-weight: 800;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  width: fit-content;
}

.list-progress-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.list-progress {
  flex: 1;
  height: 8px;
  background: #e5e7eb;
  border-radius: 99px;
  overflow: hidden;
}

.list-progress-bar {
  height: 100%;
  background: var(--primary-gradient);
  border-radius: 99px;
  width: 0%;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.4);
}

.list-progress-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #6b7280;
}

.list-items-wrap {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

.list-items {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-items li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.list-items li:hover {
  background: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.list-items li.active {
  background: var(--primary-gradient);
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.list-items li .title {
  font-weight: 600;
  color: #374151;
}

.list-items li.active .title,
.list-items li.active .meta {
  color: white;
  background: none;
  -webkit-background-clip: unset;
  background-clip: unset;
  -webkit-text-fill-color: white;
  font-weight: 700;
}

/* --- Task Area (Center) --- */
.task-column {
  padding: 0;
}

/* Layout: header and content inside columns */
.left-panel,
.collected-area {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.collected-area {
  padding: 16px;
  overflow-y: auto;
}

.left-panel>.task-header {
  flex: 0 0 auto;
}

.task-scroll {
  flex: 1 1 auto;
  min-height: 0;
  padding: 32px 40px;
  overflow-y: auto;
  height: 100%;
  position: relative;
  /* important for SVG absolute positioning */
}

.task-scroll p {
  margin-bottom: 1.2rem;
  font-size: 1.05rem;
  line-height: 1.7;
  color: #374151;
}

/* MathJax */
.math-display {
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-md);
  margin: 0.5rem 0;
  text-align: center;
}

/* Images */
.content-image {
  border-radius: 0;
  box-shadow: none;
  background-color: transparent;
  mix-blend-mode: multiply;
  margin: 2rem auto;
  max-width: 100%;
}

/* --- Concept Panel (Right) --- */
.sidebar-column {
  padding: 0;
}

.collected-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.collected-header h3 {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  width: fit-content;
}

.collected-concept-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 8px;
  background: white;
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
  color: #374151;
}

.collected-concept-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(59, 130, 246, 0.3);
}

.collected-concept-btn .origin-badge {
  background: #e0f2fe;
  color: #0369a1;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.collected-empty {
  padding: 24px 16px;
  text-align: center;
  color: #6b7280;
  font-size: 0.95rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.6);
  border: 2px dashed #d1d5db;
  border-radius: var(--radius-md);
  margin-top: 8px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

/* Concept Detail */
.concept-panel {
  /* background: white; removed */
  /* border-radius: var(--radius-lg); removed */
  padding: 0;
  height: 100%;
  /* box-shadow: var(--shadow-lg); removed */
  display: none;
  flex-direction: column;
  min-height: 0;
}

.concept-panel-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.concept-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 50;
  /* Add slight top padding in case of edge flushness */
  padding-top: 8px;
  margin-top: -8px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.concept-back-btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  background: white;
  color: var(--primary-color);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.concept-back-btn:hover {
  background: var(--primary-gradient);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.concept-panel-title {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  width: fit-content;
}


/* --- Interactive Elements --- */

/* Tokens */
.token-wrapper,
.interactive-token {
  display: inline-block;
  padding: 0 4px;
  border-radius: 6px;
  transition: all 0.2s ease;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.token-wrapper:hover,
.interactive-token:hover {
  background: rgba(59, 130, 246, 0.1);
  border-bottom-color: var(--primary-color);
  transform: translateY(-1px);
}

/* Fill-in-the-blank */
.fill-section,
.mcq-section,
.tf-section {
  margin-top: 2rem;
  background: white;
  padding: 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0, 0, 0, 0.03);
}

.fill-tile,
.mcq-tile,
.tf-tile {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 16px;
  border-radius: var(--radius-md);
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  transition: all 0.2s;
  margin-bottom: 12px;
}

.fill-tile:focus-within,
.mcq-tile:hover,
.tf-tile:hover {
  background: white;
  border-color: var(--primary-color);
  box-shadow: var(--shadow-md);
}

/* TF Option Buttons */
.tf-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 34px;
  border-radius: 6px;
  border: 1px solid #d0d0d0;
  background: #fafafa;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: background-color 160ms, border-color 160ms, transform 80ms;
}

.tf-option:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.03);
}

.tf-option.selected {
  border-color: #2b6cb0;
  background: #e6f0ff;
  color: #133f6b;
}

.fill-input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  font-size: 1rem;
  transition: all 0.2s;
  flex: 1;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.fill-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Layout for controls */
.tf-content {
  flex: 1;
}

.tf-controls {
  display: flex;
  align-items: center;
  gap: 12px;

  justify-content: flex-end;
}

.fill-left {
  flex: 1;
}

.fill-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 35%;
  min-width: 180px;

  justify-content: flex-end;
}

/* ... existing fill-controls-row ... */

/* Buttons */
/* ... */

.mcq-marker {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-right: 12px;
}

.fill-tile .mcq-marker,
.tf-tile .mcq-marker {
  margin-right: 0;
  margin-left: 0;
  align-self: center;
}

.fill-controls-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.list-nav-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: white;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.list-nav-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.fill-check-btn,
.tf-check-btn,
.btn-reset {
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--primary-gradient);
  font-weight: 600;
  color: white;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.fill-check-btn:hover,
.tf-check-btn:hover,
.btn-reset:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(139, 92, 246, 0.4);
  filter: brightness(1.05);
}

.mcq-result,
.tf-result,
.fill-result {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.9rem;
  margin-left: 8px;
}

.tf-result:empty,
.fill-result:empty {
  display: none;
}

.fill-correct,
.tf-correct {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.fill-wrong,
.tf-wrong {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

/* Paths Section */
#task-area ul,
#task-area ol,
.path-tile ul,
.path-tile ol {
  list-style-position: outside;
  margin: 0.4rem 0 0.8rem 1.2rem;
  padding-left: 1.5rem;
}

#task-area ul,
.path-tile ul {
  list-style: disc;
}

#task-area ol,
.path-tile ol {
  list-style: decimal;
}

#paths-section {
  margin-top: 2rem;
}

#paths-section h3 {
  font-family: var(--heading-font-family);
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 24px;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  width: fit-content;
  letter-spacing: -0.01em;
}

#paths-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.path-tile {
  padding: 16px;
  border-radius: var(--radius-md);
  background: white;
  border: 1px solid #e5e7eb;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.path-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-color);
}

.path-tile.path-locked {
  background: #f3f4f6;
  color: #9ca3af;
  cursor: not-allowed;
  box-shadow: none;
}

.path-title {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 4px;
}

.path-meta {
  font-size: 0.9rem;
  color: #6b7280;
}

/* Animations */
@keyframes flashGreen {

  0%,
  100% {
    background-color: transparent;
  }

  50% {
    background-color: rgba(16, 185, 129, 0.2);
  }
}

@keyframes flashRed {

  0%,
  100% {
    background-color: transparent;
  }

  50% {
    background-color: rgba(239, 68, 68, 0.2);
  }
}

.tile-flash-correct {
  animation: flashGreen 0.7s ease;
}

.tile-flash-wrong {
  animation: flashRed 0.7s ease;
}

.tile-correct-persistent {
  background-color: #f0fdf4 !important;
  border-color: #86efac !important;
}

/* Utilities */
.vspace {
  display: block;
  width: 100%;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Responsive */
@media (max-width: 1024px) {
  .app-split {
    grid-template-columns: 280px 1fr;
  }

  .sidebar-column {
    display: none;
    /* Or handle differently */
  }
}

/* --- Restored Functionality --- */

/* Group Highlighting */

[data-groups].group-dim,
.token-wrapper.group-dim,
.interactive-token.group-dim {
  opacity: 0.45;
}

/* Popover */
.popover {
  position: absolute;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(37, 99, 235, 0.15), 0 4px 12px rgba(0, 0, 0, 0.05);
  padding: 8px;
  z-index: 100;
  min-width: 180px;
  animation: popoverFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transform-origin: top center;
}

@keyframes popoverFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.popover ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.popover li {
  margin: 4px 0;
  opacity: 0;
  animation: popoverItemFade 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes popoverItemFade {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.popover li:nth-child(1) {
  animation-delay: 0.05s;
}

.popover li:nth-child(2) {
  animation-delay: 0.1s;
}

.popover li:nth-child(3) {
  animation-delay: 0.15s;
}

.popover li:nth-child(4) {
  animation-delay: 0.2s;
}

.popover li:nth-child(5) {
  animation-delay: 0.25s;
}

.popover li:nth-child(6) {
  animation-delay: 0.3s;
}

.popover button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: #374151;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.popover button:hover:not(:disabled) {
  background: var(--primary-gradient);
  color: white;
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.popover button:disabled {
  color: #9ca3af;
  cursor: default;
  background: transparent;
}

#collected-concepts-area.sidebar-concept-open #collected-list,
#collected-concepts-area.sidebar-concept-open .collected-header,
#collected-concepts-area.sidebar-concept-open .collected-separator {
  display: none !important;
}

#collected-concepts-area.sidebar-concept-open #concept-panel {
  display: block !important;
  animation: slideUpFade 0.3s ease-out;
}

/* Default state */
#collected-concepts-area:not(.sidebar-concept-open) #concept-panel {
  display: none !important;
}

#collected-concepts-area:not(.sidebar-concept-open) #collected-list {
  display: block;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* Path Tooltip */
.path-tooltip {
  position: absolute;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  padding: 12px;
  z-index: 1000;
  width: 280px;
  font-size: 0.9rem;
  pointer-events: none;
  /* Tooltip shouldn't block interaction */
  opacity: 0;
  transition: opacity 0.2s ease;
}

.path-tooltip.visible {
  opacity: 1;
}

.path-tooltip-header {
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 8px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.path-tooltip-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.path-tooltip-section-title {
  font-weight: 600;
  color: #374151;
}

.path-tooltip-list {
  list-style: disc;
  padding-left: 1.2rem;
  margin: 0;
  color: #4b5563;
}

.path-tooltip-list li {
  margin-bottom: 2px;
}

.path-tooltip-or {
  text-align: center;
  font-size: 0.85rem;
  color: #9ca3af;
  font-style: italic;
  margin: 4px 0;
  position: relative;
}

.path-tooltip-or::before,
.path-tooltip-or::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: #e5e7eb;
}

.tile-flash-wrong {
  animation: flashRed 0.7s ease;
}

.tile-correct-persistent {
  background-color: #f0fdf4 !important;
  border-color: #86efac !important;
}

/* Utilities */
.vspace {
  display: block;
  width: 100%;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Responsive */
@media (max-width: 1024px) {
  .app-split {
    grid-template-columns: 280px 1fr;
  }

  .sidebar-column {
    display: none;
    /* Or handle differently */
  }
}

/* --- Restored Functionality --- */

/* Group Highlighting */
/* Legacy yellow highlight removed */

[data-groups].inactive-dim,
.token-wrapper.inactive-dim,
.interactive-token.inactive-dim {
  opacity: 0.45;
}



/* Sidebar Toggle Logic */
/* When parent has .sidebar-concept-open */
#collected-concepts-area.sidebar-concept-open #collected-list,
#collected-concepts-area.sidebar-concept-open .collected-header,
#collected-concepts-area.sidebar-concept-open .collected-separator {
  display: none !important;
}

#collected-concepts-area.sidebar-concept-open #concept-panel {
  display: block !important;
  animation: slideUpFade 0.3s ease-out;
}

/* Default state */
#collected-concepts-area:not(.sidebar-concept-open) #concept-panel {
  display: none !important;
}

#collected-concepts-area:not(.sidebar-concept-open) #collected-list {
  display: block;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* Path Tooltip */
.path-tooltip {
  position: absolute;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  padding: 12px;
  z-index: 1000;
  width: 280px;
  font-size: 0.9rem;
  pointer-events: none;
  /* Tooltip shouldn't block interaction */
  opacity: 0;
  transition: opacity 0.2s ease;
}

.path-tooltip.visible {
  opacity: 1;
}

.path-tooltip-header {
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 8px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.path-tooltip-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.path-tooltip-section-title {
  font-weight: 600;
  color: #374151;
}

.path-tooltip-list {
  list-style: disc;
  padding-left: 1.2rem;
  margin: 0;
  color: #4b5563;
}

.path-tooltip-list li {
  margin-bottom: 2px;
}

.path-tooltip-or {
  text-align: center;
  font-size: 0.85rem;
  color: #9ca3af;
  font-style: italic;
  margin: 4px 0;
  position: relative;
}

.path-tooltip-or::before,
.path-tooltip-or::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: #e5e7eb;
}

.path-tooltip-or::before {
  left: 0;
}

.path-tooltip-or::after {
  right: 0;
}

/* Connective Map Highlights */
.source-highlight {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.35) 0%, rgba(139, 92, 246, 0.35) 100%) !important;
  color: inherit !important;
  border-radius: 6px;
  border: 1px solid rgba(99, 102, 241, 0.8) !important;
  border-bottom-color: transparent !important;
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
  z-index: 10;
  position: relative;
}

.target-highlight {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(139, 92, 246, 0.15) 100%) !important;
  color: inherit !important;
  border-radius: 6px;
  border: 1px solid rgba(139, 92, 246, 0.5) !important;
  border-bottom-color: transparent !important;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.2);
  z-index: 10;
  position: relative;
}

/* Fallback for active-highlight if used elsewhere */
.active-highlight {
  background-color: rgba(59, 130, 246, 0.2) !important;
  border-bottom-color: var(--primary-color) !important;
  transform: translateY(-1px);
}

/* SVG Connection Map overlay */
.connections-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* Beam Animation Path */
.beam-line {
  fill: none;
  stroke-width: 3;
  stroke: url(#beam-gradient);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 12, 12;
  animation: marchFlow 0.6s linear infinite;
  opacity: 0.85;
  filter: drop-shadow(0 0 6px rgba(139, 92, 246, 0.6));
}

@keyframes marchFlow {
  from {
    stroke-dashoffset: 24;
  }

  to {
    stroke-dashoffset: 0;
  }
}

/* --- MCQ Custom Radio --- */

/* Hide default radio */
.mcq-tile input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

/* Marker container */


/* The Dot (Custom Radio) */
.dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #d1d5db;
  background: white;

  .sidebar-column {
    display: none;
    /* Or handle differently */
  }
}

/* --- Restored Functionality --- */

/* Group Highlighting */
/* Legacy yellow highlight removed */

[data-groups].inactive-dim,
.token-wrapper.inactive-dim,
.interactive-token.inactive-dim {
  opacity: 0.45;
}

/* Popover */
.popover {
  position: absolute;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  z-index: 100;
  min-width: 160px;
  animation: fadeIn 0.15s ease-out;
}

.popover ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.popover li {
  margin: 4px 0;
}

.popover button {
  display: block;
  width: 100%;
  text-align: left;
  background: white;
  color: #374151;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.popover button:hover:not(:disabled) {
  background: #f3f4f6;
  color: var(--primary-color);
}

/* Sidebar Toggle Logic */
/* When parent has .sidebar-concept-open */
#collected-concepts-area.sidebar-concept-open #collected-list,
#collected-concepts-area.sidebar-concept-open .collected-header,
#collected-concepts-area.sidebar-concept-open .collected-separator {
  display: none !important;
}

#collected-concepts-area.sidebar-concept-open #concept-panel {
  display: block !important;
  animation: slideUpFade 0.3s ease-out;
}

/* Default state */
#collected-concepts-area:not(.sidebar-concept-open) #concept-panel {
  display: none !important;
}

#collected-concepts-area:not(.sidebar-concept-open) #collected-list {
  display: block;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* Path Tooltip */
.path-tooltip {
  position: absolute;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  padding: 12px;
  z-index: 1000;
  width: 280px;
  font-size: 0.9rem;
  pointer-events: none;
  /* Tooltip shouldn't block interaction */
  opacity: 0;
  transition: opacity 0.2s ease;
}

.path-tooltip.visible {
  opacity: 1;
}

.path-tooltip-header {
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 8px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.path-tooltip-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.path-tooltip-section-title {
  font-weight: 600;
  color: #374151;
}

.path-tooltip-list {
  list-style: disc;
  padding-left: 1.2rem;
  margin: 0;
  color: #4b5563;
}

.path-tooltip-list li {
  margin-bottom: 2px;
}

.path-tooltip-or {
  text-align: center;
  font-size: 0.85rem;
  color: #9ca3af;
  font-style: italic;
  margin: 4px 0;
  position: relative;
}

.path-tooltip-or::before,
.path-tooltip-or::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: #e5e7eb;
}

.path-tooltip-or::before {
  left: 0;
}

.path-tooltip-or::after {
  right: 0;
}

/* Group Highlighting */
.active-highlight {
  background-color: rgba(59, 130, 246, 0.2) !important;
  border-bottom-color: var(--primary-color) !important;
  transform: translateY(-1px);
}

/* --- MCQ Custom Radio --- */

/* Hide default radio */
.mcq-tile input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

/* Marker container */
.mcq-marker {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-right: 12px;
}

/* The Dot (Custom Radio) */
.dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #d1d5db;
  background: white;
  position: relative;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

/* Selected state */
.mcq-tile.selected .dot,
.tf-tile.selected .dot {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.mcq-tile.selected .dot::after,
.tf-tile.selected .dot::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary-color);
  animation: scaleIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes scaleIn {
  from {
    transform: translate(-50%, -50%) scale(0);
  }

  to {
    transform: translate(-50%, -50%) scale(1);
  }
}

/* Correct State (Green Checkmark) */
.mcq-tile.tile-correct-persistent .dot,
.mcq-tile.tile-flash-correct .dot,
.tf-tile.tile-correct-persistent .dot,
.tf-tile.tile-flash-correct .dot,
.fill-tile.tile-correct-persistent .dot,
.fill-tile.tile-flash-correct .dot {
  background: #10b981;
  /* accent-color */
  border-color: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2);
}

/* Remove the inner dot for correct/wrong states if present */
.mcq-tile.tile-correct-persistent .dot::after,
.mcq-tile.tile-flash-correct .dot::after,
.mcq-tile.tile-flash-wrong .dot::after,
.tf-tile.tile-correct-persistent .dot::after,
.tf-tile.tile-flash-correct .dot::after,
.tf-tile.tile-flash-wrong .dot::after,
.fill-tile.tile-correct-persistent .dot::after,
.fill-tile.tile-flash-correct .dot::after,
.fill-tile.tile-flash-wrong .dot::after {
  background: transparent;
  width: auto;
  height: auto;
  border-radius: 0;
  transform: none;
  animation: none;
}

/* Checkmark Icon */
.mcq-tile.tile-correct-persistent .dot::after,
.mcq-tile.tile-flash-correct .dot::after,
.tf-tile.tile-correct-persistent .dot::after,
.tf-tile.tile-flash-correct .dot::after,
.fill-tile.tile-correct-persistent .dot::after,
.fill-tile.tile-flash-correct .dot::after {
  content: '';
  position: absolute;
  top: 45%;
  left: 50%;
  width: 6px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -50%) rotate(45deg);
}

/* Wrong State (Red X) */
.mcq-tile.tile-flash-wrong .dot,
.tf-tile.tile-flash-wrong .dot,
.fill-tile.tile-flash-wrong .dot {
  background: #ef4444;
  /* danger-color */
  border-color: #ef4444;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.2);
}

/* X Icon */
.mcq-tile.tile-flash-wrong .dot::before,
.mcq-tile.tile-flash-wrong .dot::after,
.tf-tile.tile-flash-wrong .dot::before,
.tf-tile.tile-flash-wrong .dot::after,
.fill-tile.tile-flash-wrong .dot::before,
.fill-tile.tile-flash-wrong .dot::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 2px;
  background: white;
  border-radius: 1px;
}

.mcq-tile.tile-flash-wrong .dot::before,
.tf-tile.tile-flash-wrong .dot::before,
.fill-tile.tile-flash-wrong .dot::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.mcq-tile.tile-flash-wrong .dot::after,
.tf-tile.tile-flash-wrong .dot::after,
.fill-tile.tile-flash-wrong .dot::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.inactive-dim {
  opacity: 0.5;
  transition: opacity 0.2s;
}

@media (max-width: 768px) {
  .fill-tile {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .fill-left,
  .fill-right {
    width: 100%;
    justify-content: flex-start;
  }

  .fill-right {
    /* Ensure input takes full width if not already */
    display: flex;
  }

  .fill-input {
    width: 100%;
    flex: 1;
  }
}

/* Fix scroll behavior */
#collected-concepts-area.sidebar-concept-open {
  /* Stop outer scroll, let concept-panel handle it precisely */
  overflow-y: hidden;
  padding: 0;
}

#collected-concepts-area.sidebar-concept-open #concept-panel {
  /* Restore structural height so header can dock to the top */
  height: 100%;
  overflow: hidden;
}

#collected-concepts-area.sidebar-concept-open .concept-panel-body {
  /* Allow only the body to scroll */
  overflow-y: auto;
  height: 100%;
  padding: 16px;
}

#collected-concepts-area:not(.sidebar-concept-open) #collected-list {
  flex: none;
  overflow-y: visible;
  min-height: auto;
}

/* --- PDF Viewer Styles --- */
.pdf-page-wrapper {
  position: relative;
  /* margin-bottom handled by loop in JS or here? JS adds margin to canvas, but wrapper is better */
  margin-bottom: 2rem;
  background-color: white;
  /* Maintain aspect ratio / width handled by JS setting style on wrapper */
  width: 100%;
}

.pdf-page-wrapper canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* Text Layer */
.textLayer {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  opacity: 0.2;
  line-height: 1.0;
  pointer-events: none;
}

.textLayer>span {
  color: transparent;
  position: absolute;
  white-space: pre;
  cursor: text;
  transform-origin: 0% 0%;
  pointer-events: auto;
}

.textLayer ::selection {
  background: rgba(0, 0, 255, 0.3);
  color: transparent;
}

/* Annotation Layer (Links) */
.annotationLayer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

/* Fix: Target the A tag directly as it HAS the class linkAnnotation */
/* Fix: Target the A tag directly as it HAS the class linkAnnotation */
.annotationLayer a.linkAnnotation {
  position: absolute;
  display: block;
  font-size: 1em;
  pointer-events: auto;
  text-decoration: none;
  background: transparent;
  /* Match token-wrapper base styles */
  border-radius: 6px;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
}

/* Hover effect - match .token-wrapper:hover */
.annotationLayer a.linkAnnotation:hover {
  background: rgba(59, 130, 246, 0.1);
  border-bottom-color: var(--primary-color);
  /* Scale up slightly to avoid overlapping text tightly */
  transform: translateY(2px) scaleX(1.05) scaleY(1.3);
  box-shadow: none;
  cursor: pointer;
  z-index: 10;
  /* Ensure it floats above neighbors when scaled */
}

/* Badge for new concepts */
.new-badge {
  background: var(--primary-gradient);
  color: white;
  font-size: 0.7em;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
  font-weight: bold;
  vertical-align: middle;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}