:root {
  --paper: #f4f1ea;
  --paper-raised: #ffffff;
  --ink: #2b2620;
  --ink-soft: #5b5349;
  --rule: #e2dcd0;
  --maroon: #800000; 
  --good: #4a5d23;
  --warn: #a67220;
  --radius: 8px;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --shadow-sm: 0 1px 3px rgba(43, 38, 32, 0.05), 0 1px 2px rgba(43, 38, 32, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(43, 38, 32, 0.1), 0 2px 4px -1px rgba(43, 38, 32, 0.06);
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.6;
}

a { color: var(--maroon); text-decoration: none; transition: color 0.2s ease; }
a:hover { color: #500000; text-decoration: underline; }

.site-header {
  padding: 4rem 1.5rem 2rem;
  margin: 0 auto;
  width: 100%;
  max-width: 960px;
}

.site-header h1 {
  font-size: clamp(2.25rem, 5vw, 3.25rem);
  font-weight: 700;
  margin: 0 0 1rem;
  letter-spacing: -0.02em;
  display: inline-block;
  border-bottom: 4px solid var(--maroon);
  padding-bottom: 0.35rem;
  line-height: 1.1;
}

.tagline {
  color: var(--ink-soft);
  font-size: 1.1rem;
  max-width: 55ch;
  margin: 0;
}

main {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

/* --------------------
   Search & Layout 
-------------------- */
.search-section { margin-top: 1.5rem; }

.search-label {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.5rem;
}

.search-controls {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  width: 100%;
}

.search-wrapper { 
  flex: 1; 
  position: relative; 
}

#course-search {
  width: 100%;
  font-family: var(--mono);
  font-size: 1.15rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--rule);
  background: var(--paper-raised);
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

#course-search:focus-visible {
  outline: none;
  border-color: var(--maroon);
  box-shadow: 0 0 0 3px rgba(128, 0, 0, 0.15);
}

.search-status {
  font-size: 0.95rem;
  color: var(--ink-soft);
  min-height: 1.5em;
  margin: 0.75rem 0 0;
  font-weight: 500;
}

/* --------------------
   Filter Modal System 
-------------------- */
.filter-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 600;
  padding: 0 1.25rem;
  border: 1px solid #767676;
  background: var(--paper-raised);
  color: var(--ink);
  border-radius: 30px;
  cursor: pointer;
  height: 3.5rem;
  white-space: nowrap;
  transition: background-color 0.15s ease, box-shadow 0.2s ease;
}

.filter-pill-btn:hover { background: #faf8f5; }
.filter-pill-btn:focus-visible { outline: 2px solid var(--maroon); outline-offset: 2px; }

.filter-count {
  background: var(--maroon);
  color: #fff;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  border-radius: 12px;
}

.filter-modal {
  padding: 0;
  border: none;
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  box-shadow: var(--shadow-md);
  background: var(--paper-raised);
  color: var(--ink);
}

.filter-modal::backdrop { background: rgba(0, 0, 0, 0.4); }

.modal-header {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1.25rem;
  position: relative;
  border-bottom: 1px solid var(--rule);
}

.modal-header h2 { margin: 0; font-size: 1.25rem; font-weight: 700; }

.close-btn {
  position: absolute;
  right: 1.25rem;
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--ink);
  cursor: pointer;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.close-btn:hover { background: rgba(0,0,0,0.05); }

.modal-body {
  padding: 0 1.5rem;
  max-height: 60vh;
  overflow-y: auto;
}

.filter-accordion { border-bottom: 1px solid var(--rule); }
.filter-accordion:last-child { border-bottom: none; }

.filter-accordion summary {
  font-weight: 700;
  font-size: 1.1rem;
  padding: 1.5rem 0;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.filter-accordion summary::-webkit-details-marker { display: none; }
.filter-accordion summary::after { content: '\2304'; font-size: 1.5rem; font-weight: 400; line-height: 0; }
.filter-accordion[open] summary::after { content: '\2303'; }

.accordion-content { padding-bottom: 1.5rem; }

.modal-footer {
  display: flex;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--rule);
  background: var(--paper-raised);
}

.clear-btn {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  border-radius: 30px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  font-family: var(--serif);
}

.apply-btn {
  flex: 2;
  padding: 0.75rem;
  border: none;
  background: #0071dc;
  color: white;
  border-radius: 30px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  font-family: var(--serif);
}

/* Radios */
.radio-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.95rem;
  margin-bottom: 0.6rem;
  cursor: pointer;
  user-select: none;
}
.radio-label:last-child { margin-bottom: 0; }
.radio-label input { width: 1.1rem; height: 1.1rem; cursor: pointer; accent-color: var(--maroon); }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.95rem;
  margin-bottom: 0.6rem;
  cursor: pointer;
  user-select: none;
}
.checkbox-label:last-child { margin-bottom: 0; }
.checkbox-label input { width: 1.1rem; height: 1.1rem; cursor: pointer; accent-color: var(--maroon); }


/* --------------------
   Search Results
-------------------- */
.results-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  background: var(--paper-raised);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border: none;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.result-row:last-child { border-bottom: none; }
.result-row:disabled { cursor: default; opacity: 0.6; background: var(--paper); }
.result-row:not(:disabled):hover, .result-row:not(:disabled):focus-visible { background: rgba(128, 0, 0, 0.04); }
.result-row:focus-visible { outline: 2px solid var(--maroon); outline-offset: -2px; }

.result-code { font-family: var(--mono); font-weight: 600; font-size: 1.1rem; letter-spacing: 0.02em; white-space: nowrap; }
.result-status { font-size: 0.9rem; color: var(--ink-soft); white-space: nowrap; }
.result-status.pending { color: var(--warn); }
.more-results { padding: 1rem 1.25rem; font-size: 0.9rem; color: var(--ink-soft); background: var(--paper); text-align: center; border-top: 1px solid var(--rule); }


/* --------------------
   Course Details & Table 
-------------------- */
.course-detail {
  margin-top: 3rem;
  animation: fadeIn 0.3s ease-out forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.detail-animate-wrapper {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s ease-out;
}

.detail-row.is-open .detail-animate-wrapper {
  grid-template-rows: 1fr;
}

.detail-animate-inner {
  overflow: hidden;
  opacity: 0;
  transform: translateY(-15px);
  transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.detail-row.is-open .detail-animate-inner {
  opacity: 1;
  transform: translateY(0);
}

/* Removes extra table borders when the row is collapsed */
.detail-row:not(.is-open) td {
  border-bottom: none;
}
.course-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--ink);
}

.course-detail-header h2 { font-family: var(--mono); font-size: 1.75rem; margin: 0; }

.back-link {
  font-family: var(--mono);
  font-size: 0.95rem;
  background: rgba(128, 0, 0, 0.08);
  border: none;
  color: var(--maroon);
  cursor: pointer;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-weight: 600;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.back-link:hover { background: var(--maroon); color: #fff; }
.back-link:focus-visible { outline: 2px solid var(--maroon); outline-offset: 2px; }

.instructor-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--paper-raised);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.instructor-table thead th {
  position: sticky;
  top: 0;
  text-align: left;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink-soft);
  padding: 1rem;
  border-bottom: 2px solid var(--rule);
  background: #faf8f5;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background-color 0.2s ease;
  z-index: 10;
}
.instructor-table thead th:hover { background: #f0ebe1; color: var(--ink); }
.instructor-table thead th:focus-visible { outline: 2px solid var(--maroon); outline-offset: -2px; }

.instructor-table th.numeric, .instructor-table td.numeric {
  text-align: right;
  font-family: var(--mono);
  white-space: nowrap; 
}

/* Push numeric columns to the right */
.instructor-table th:nth-child(2), .instructor-table td:nth-child(2) { width: 100%; }

.instructor-table tbody tr.instructor-row { cursor: pointer; transition: background-color 0.15s ease; }

@keyframes flash-highlight {
  0% { background-color: rgba(128, 0, 0, 0.2); }
  100% { background-color: transparent; }
}
.instructor-row.just-opened-flash {
  animation: flash-highlight 1.6s ease-out;
}
.instructor-row:hover, .instructor-row:focus-visible { background: rgba(128, 0, 0, 0.03); }

.instructor-table td { padding: 1rem; border-bottom: 1px solid var(--rule); vertical-align: baseline; }

.rank-badge {
  font-family: var(--mono);
  font-weight: 600;
  background: var(--paper);
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.9rem;
}
.rank-badge.rank-1 { background: rgba(128, 0, 0, 0.1); color: var(--maroon); }

.detail-row td { padding: 0; border-bottom: 1px solid var(--rule); background: #faf8f5; }


/* --------------------
   Scores & Badges 
-------------------- */
.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  font-family: var(--mono);
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  min-width: 3.5rem;
}
.score-badge .star-icon { font-size: 0.9em; line-height: 1; }

.score-high { background: #e6f4ea; color: #137333; }
.score-mid { background: #fef7e0; color: #b06000; }
.score-low { background: #fce8e6; color: #c5221f; }


/* --------------------
   Detail Grid 
-------------------- */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  padding: 1.5rem;
}

.detail-block {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  padding: 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.detail-block h3 {
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin: 0 0 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.5rem;
}

.stat-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  font-family: var(--mono);
  font-size: 0.95rem;
  margin: 0.5rem 0;
}

/* Values never wrap or shrink - so when a label runs to two lines the number
   stays pinned to the first line's baseline instead of drifting to the
   vertical middle of the row. */
.stat-line > strong,
.stat-line > .score-badge {
  flex-shrink: 0;
  white-space: nowrap;
}

.meter {
  height: 8px;
  background: var(--rule);
  border-radius: 4px;
  overflow: hidden;
  margin: 0.25rem 0 1rem;
}
.meter-fill {
  height: 100%;
  background: var(--maroon);
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Grade Distribution */
.grade-dist { margin: 0.4rem 0 1rem; }

.grade-dist-bar {
  display: flex;
  height: 12px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--rule);
  margin-top: 0.35rem;
}

.grade-dist-segment { height: 100%; min-width: 2px; }
.grade-dist-segment.grade-a { background: #2f6f4e; }
.grade-dist-segment.grade-b { background: #7a9c3f; }
.grade-dist-segment.grade-c { background: var(--warn); }
.grade-dist-segment.grade-d { background: #c9701f; }
.grade-dist-segment.grade-f { background: #a63232; }

.grade-dist-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.1rem 0.7rem;
  margin-top: 0.5rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.grade-dist-legend-item { display: inline-flex; align-items: center; gap: 0.3rem; white-space: nowrap; }

.grade-dist-dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.grade-dist-dot.grade-a { background: #2f6f4e; }
.grade-dist-dot.grade-b { background: #7a9c3f; }
.grade-dist-dot.grade-c { background: var(--warn); }
.grade-dist-dot.grade-d { background: #c9701f; }
.grade-dist-dot.grade-f { background: #a63232; }

.confidence-note {
  font-size: 0.9rem;
  color: var(--ink-soft);
  font-style: italic;
  margin: 1rem 0 0;
  line-height: 1.5;
  background: var(--paper);
  padding: 0.75rem;
  border-radius: var(--radius);
  border-left: 3px solid var(--maroon);
}

.low-review-flag {
  display: inline-block;
  margin-left: 0.4rem;
  font-size: 0.85rem;
  cursor: help;
}

.low-review-warning {
  background: #fef7e0;
  border: 1px solid #f0d896;
  border-left: 4px solid var(--warn);
  color: #7a4f0a;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0 0 1.25rem;
}

/* Semester Tags */
.tag-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
  max-width: 65%;
  margin-top: 0.3rem; 
}
.semester-tag {
  background: rgba(43, 38, 32, 0.06);
  border: 1px solid var(--rule);
  color: var(--ink);
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
}

/* Keyword/trait tags - same rounded-rectangle format as semester-tag,
   maroon-tinted so the two tag categories are visually distinguishable */
.keyword-tag {
  background: rgba(128, 0, 0, 0.08);
  border: 1px solid rgba(128, 0, 0, 0.25);
  color: var(--maroon);
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}


/* --------------------
   Misc Layout 
-------------------- */
.data-freshness {
  margin-top: 4rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
  text-align: center;
  font-family: var(--mono);
}

.site-footer {
  border-top: 1px solid var(--rule);
  padding: 2rem 1.5rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--ink-soft);
  background: #e8e2d5;
}

.empty-state { padding: 2rem; color: var(--ink-soft); text-align: center; font-weight: 500; }

@media (max-width: 600px) {
  .search-controls { flex-direction: column; gap: 0.75rem; }
  .filter-pill-btn { width: 100%; justify-content: center; }
  
  .instructor-table thead { display: none; }
  .instructor-table, .instructor-table tbody, .instructor-table tr, .instructor-table td { display: block; width: 100%; }
  .instructor-row { padding: 1rem 0; border-bottom: 2px solid var(--rule); }
  .instructor-table td { padding: 0.35rem 1rem; border-bottom: none; }
  .instructor-table td.numeric { text-align: left; }
  .instructor-table td[data-label]::before { content: attr(data-label); display: inline-block; width: 100px; color: var(--ink-soft); font-family: var(--mono); font-size: 0.8rem; text-transform: uppercase; font-weight: 600; }
}


/* RateMyProfessors Pill Button */
.rmp-link, .syllabus-link {
  position: absolute;
  bottom: 1.25rem;
  right: 1.25rem;
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.35rem 0.75rem;
  border-radius: 16px;
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.rmp-link {
  background: rgba(128, 0, 0, 0.08);
  color: var(--maroon);
}

.rmp-link:hover {
  background: var(--maroon);
  color: #fff;
}

.rmp-link:focus-visible {
  outline: 2px solid var(--maroon);
  outline-offset: 2px;
}

.syllabus-link {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  color: var(--ink-soft);
}

.syllabus-link:hover {
  background: #faf8f5;
  color: var(--ink);
  border-color: var(--ink-soft);
}

.syllabus-link:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* --------------------
   Skeleton Loading UI 
-------------------- */
@keyframes skeletonPulse {
  0% { opacity: 0.6; }
  50% { opacity: 0.25; }
  100% { opacity: 0.6; }
}

.skeleton-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--rule);
}

.skeleton-title {
  width: 140px;
  height: 2.25rem;
  background: var(--rule);
  border-radius: var(--radius);
  animation: skeletonPulse 1.2s infinite ease-in-out;
}

.skeleton-btn {
  width: 120px;
  height: 2.25rem;
  background: var(--rule);
  border-radius: 20px;
  animation: skeletonPulse 1.2s infinite ease-in-out;
}

.skeleton-table {
  background: var(--paper-raised);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--rule);
}

.skeleton-row {
  height: 52px;
  background: var(--paper-raised);
  animation: skeletonPulse 1.2s infinite ease-in-out;
}

/* --------------------
   Header Actions & Buttons
-------------------- */
.course-detail-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.expand-toggle-btn {
  font-family: var(--mono);
  font-size: 0.85rem;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0.5rem 0.85rem;
  border-radius: 20px;
  font-weight: 600;
  transition: all 0.15s ease;
}

.expand-toggle-btn:hover {
  background: #faf8f5;
  color: var(--ink);
  border-color: var(--ink-soft);
}

.expand-toggle-btn:focus-visible {
  outline: 2px solid var(--maroon);
  outline-offset: 2px;
}
/* Header alignment fix */
.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

/* Dark Mode Color Palette */
body.dark-mode {
  --paper: #161513;
  --paper-raised: #22201c;
  --ink: #ece7df;
  --ink-soft: #b0a89e;
  --rule: #36322b;
  --maroon: #e56b6b; /* Lighter maroon tint for readability on dark backgrounds */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
}

body.dark-mode .instructor-table thead th {
  background: #1c1a17;
}

body.dark-mode .detail-row td {
  background: #1a1816;
}

/* Toggle Button Styling */
.theme-toggle-btn {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  color: var(--ink);
  padding: 0.5rem 0.75rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.theme-toggle-btn:hover {
  border-color: var(--ink-soft);
  transform: scale(1.05);
}
/* --------------------
   Dark Mode Color Overrides
-------------------- */

/* 1. Fix Warning Callout Boxes */
body.dark-mode .low-review-warning {
  background: #2a2218;
  border-color: #544122;
  border-left-color: #d99b2b;
  color: #f0d496;
}

/* 2. Fix Trait / Keyword Tags */
body.dark-mode .keyword-tag {
  background: rgba(229, 107, 107, 0.15);
  border-color: rgba(229, 107, 107, 0.35);
  color: #ffa3a3;
}

body.dark-mode .semester-tag {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--rule);
  color: var(--ink);
}

/* 3. Invert Score Badges for Dark Mode */
body.dark-mode .score-high {
  background: #193322;
  color: #81c995;
}

body.dark-mode .score-mid {
  background: #332712;
  color: #fdd663;
}

body.dark-mode .score-low {
  background: #361a1a;
  color: #f28b82;
}

body.dark-mode .rank-badge {
  background: #2b2823;
  color: var(--ink);
}

body.dark-mode .rank-badge.rank-1 {
  background: rgba(229, 107, 107, 0.2);
  color: #ffa3a3;
}
/* --------------------
   Bottom Footer & Traits Dark Mode Fixes
-------------------- */

/* 1. Fix Light-Mode Footer Banner */
body.dark-mode footer,
body.dark-mode .site-footer {
  background: var(--paper); /* Matches page background */
  color: var(--ink-soft);  /* Soft grey text for readability */
  border-top: 1px solid var(--rule);
}

body.dark-mode footer p,
body.dark-mode .site-footer p {
  color: var(--ink-soft);
}

/* 2. Fix Trait Pills (Tough Grader, Hard Exams, etc.) */
body.dark-mode .trait-pill,
body.dark-mode .trait-tag {
  background: rgba(229, 107, 107, 0.15);
  border: 1px solid rgba(229, 107, 107, 0.35);
  color: #ffa3a3;
}

/* 3. Fix Quote Accent Line & Italic Text */
body.dark-mode blockquote,
body.dark-mode .quote-box {
  border-left-color: #e56b6b;
  color: var(--ink-soft);
}
/* ----------------------------------
   1. Question Mark (?) Tooltip Badge
---------------------------------- */
.info-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--rule, #dcd7ce);
  color: var(--ink-soft, #666);
  font-size: 10px;
  font-weight: bold;
  margin-left: 4px;
  cursor: help;
  position: relative;
  vertical-align: middle;
}

.info-badge .tooltip-box {
  visibility: hidden;
  opacity: 0;
  width: 210px;
  background-color: var(--paper-raised, #ffffff);
  color: var(--ink, #222);
  text-align: left;
  border-radius: 6px;
  padding: 8px 10px;
  position: absolute;
  z-index: 100;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border: 1px solid var(--rule, #ddd);
  font-size: 11px;
  font-weight: normal;
  line-height: 1.4;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  pointer-events: none;
}

/* Tooltip arrow */
/* ----------------------------------
   Fixed Question Mark (?) & Tooltip
---------------------------------- */
/* Allow table containers to display floating popovers without clipping */
.instructor-table,
.instructor-table thead,
.instructor-table th {
  overflow: visible !important;
}

/* Question Mark Badge (Inlined tight to header text) */
.info-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--rule, #dcd7ce);
  color: var(--ink-soft, #666);
  font-size: 9px;
  font-weight: bold;
  margin-left: 5px;
  cursor: help;
  position: relative;
  vertical-align: 1px;
  line-height: 1;
}

/* Hover Tooltip Popup */
.info-badge .tooltip-box {
  visibility: hidden;
  opacity: 0;
  width: 220px;
  background-color: var(--paper-raised, #ffffff);
  color: var(--ink, #222);
  text-align: left;
  border-radius: 6px;
  padding: 8px 10px;
  position: absolute;
  z-index: 999;
  bottom: 140%;
  right: -8px;
  left: auto;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
  border: 1px solid var(--rule, #ddd);
  font-size: 11px;
  font-weight: normal;
  line-height: 1.4;
  white-space: normal;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  pointer-events: none;
}

/* Tooltip Arrow */
.info-badge .tooltip-box::after {
  content: "";
  position: absolute;
  top: 100%;
  right: 9px;
  border-width: 5px;
  border-style: solid;
  border-color: var(--paper-raised, #ffffff) transparent transparent transparent;
}

.info-badge:hover .tooltip-box,
.info-badge:focus .tooltip-box {
  visibility: visible;
  opacity: 1;
}

/* Dark Mode Adjustments */
body.dark-mode .info-badge {
  background: #332f2a;
  color: #c5beaf;
}

body.dark-mode .info-badge .tooltip-box {
  background-color: #24211d;
  color: #ece7df;
  border-color: #3d3831;
}

body.dark-mode .info-badge .tooltip-box::after {
  border-color: #24211d transparent transparent transparent;
}

/* --------------------
   Search Mode Toggle (Courses / Professors)
-------------------- */
.search-mode-toggle {
  display: inline-flex;
  gap: 0.25rem;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: 30px;
  padding: 0.25rem;
  margin-bottom: 0.75rem;
}

.mode-btn {
  font-family: var(--serif);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.4rem 1rem;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  border-radius: 20px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.mode-btn.active { background: var(--maroon); color: #fff; }
.mode-btn:hover:not(.active) { background: rgba(128, 0, 0, 0.06); color: var(--ink); }
.mode-btn:focus-visible { outline: 2px solid var(--maroon); outline-offset: 2px; }

/* --------------------
   Report a Wrong Match
-------------------- */
.report-match-btn {
  position: absolute;
  bottom: 1.25rem;
  left: 1.25rem;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 1px solid var(--rule);
  background: var(--paper-raised);
  color: var(--ink-soft);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.report-match-btn:hover { background: #fef7e0; color: var(--warn); border-color: var(--warn); }

.report-match-btn .flag-icon {
  display: inline-block;
  transform: translate(2px, -0.5px);
}
.report-match-btn:focus-visible { outline: 2px solid var(--maroon); outline-offset: 2px; }

.report-context {
  font-size: 0.9rem;
  color: var(--ink-soft);
  background: var(--paper);
  padding: 0.75rem;
  border-radius: var(--radius);
  margin: 1.25rem 0 1rem;
  line-height: 1.5;
}

.report-label { display: block; font-size: 0.9rem; font-weight: 600; margin: 1rem 0 0.4rem; }

#report-correct-url, #report-notes {
  width: 100%;
  font-family: var(--mono);
  font-size: 0.9rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--rule);
  background: var(--paper-raised);
  color: var(--ink);
  border-radius: var(--radius);
  resize: vertical;
}

#report-correct-url:focus-visible, #report-notes:focus-visible {
  outline: none;
  border-color: var(--maroon);
  box-shadow: 0 0 0 3px rgba(128, 0, 0, 0.15);
}

body.dark-mode .report-match-btn { background: var(--paper-raised); border-color: var(--rule); color: var(--ink-soft); }



/* --------------------
   Professor Page Layout
-------------------- */
.professor-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
  align-items: start;
  padding: 0 1.5rem 1.5rem;
}

@media (max-width: 820px) {
  .professor-layout { grid-template-columns: 1fr; }
}

.professor-courses-panel {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}

.professor-courses-panel .panel-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  font-weight: 700;
  margin: 0;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--rule);
}

.professor-rmp-panel {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
}

.rating-gauge-wrap {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 1.25rem;
}

.rating-gauge { width: 100%; height: 100%; }
.gauge-track { fill: none; stroke: var(--rule); stroke-width: 10; }
.gauge-fill {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dashoffset 0.6s ease;
}
.gauge-fill.gauge-high { stroke: #137333; }
.gauge-fill.gauge-mid { stroke: #b06000; }
.gauge-fill.gauge-low { stroke: #c5221f; }

.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.gauge-value { font-family: var(--serif); font-size: 1.8rem; font-weight: 700; color: var(--ink); line-height: 1; }
.gauge-max { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-soft); margin-top: 0.15rem; }

.rmp-stat-list { text-align: left; }

.rmp-panel-link {
  position: static;
  display: inline-block;
  margin: 1rem auto 0;
}