/* Scope variables to the study panel directly using your main theme tokens */
#notesPanel {
  --note-border: var(--line);
  --note-text: var(--ink);
  --note-bg-light: var(--panel);
  --note-heading: var(--ink);

  font-family: 'Inter', sans-serif;
  line-height: 1.6;
  color: var(--note-text);
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  background-color: var(--note-bg-light);
  border: 1px solid var(--note-border);
  border-radius: 8px;
}

/* Headings scoped inside notes */
#notesPanel h1, 
#notesPanel h2, 
#notesPanel h3, 
#notesPanel h4 {
  color: var(--note-heading);
  font-family: 'Fraunces', serif;
  text-align: center;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

#notesPanel h1 { font-size: 1.75rem; }
#notesPanel h2 { font-size: 1.5rem; }
#notesPanel h3 { font-size: 1.25rem; }

/* Scoped Lists */
#notesPanel ul, 
#notesPanel ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

#notesPanel li {
  margin-bottom: 0.35rem;
}

/* Scoped Responsive Images */
#notesPanel img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem auto;
  border-radius: 4px;
  border: 1px solid var(--line);
}

/* Scoped Tables */
#notesPanel .table-container,
#notesPanel .table-wrapper {
  width: 100%;
  overflow-x: auto;
  margin: 1.5rem 0;
}

#notesPanel table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
  font-size: 0.95rem;
  background: var(--panel);
}

#notesPanel th, 
#notesPanel td {
  color: var(--ink); /* Removed hardcoded black */
  border: 1px solid var(--note-border);
  padding: 0.6rem 0.8rem;
  text-align: left;
  vertical-align: top;
}

#notesPanel th {
  background-color: var(--bg);
  font-weight: bold;
  text-align: center;
}

/* 
   Theme-Adaptive Table Highlights 
   Uses low-opacity tinting so text stays legible in Light & Dark mode
*/
#notesPanel .bg-primary { 
  background-color: var(--ink); 
  color: var(--panel); 
}
#notesPanel .bg-yellow { 
  background-color: var(--amber-bg); 
  color: var(--ink); 
}
#notesPanel .bg-red { 
  background-color: var(--coral-bg); 
  color: var(--ink); 
}
#notesPanel .bg-blue { 
  background-color: rgba(0, 112, 192, 0.15); 
  color: var(--ink); 
}
#notesPanel .bg-green { 
  background-color: var(--moss-bg); 
  color: var(--ink); 
}

/* Desktop Tweaks */
@media (min-width: 768px) {
  #notesPanel {
    padding: 2rem;
  }
  #notesPanel table {
    font-size: 1rem;
  }
}