:root {
  --bs-body-font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ct-bg: #eff1f5;
  --ct-surface: #e6e9ef;
  --ct-card: #ffffff;
  --ct-text: #4c4f69;
  --ct-muted: #6c6f85;
  --ct-heading: #8839ef;
  --ct-accent: #1e66f5;
  --ct-border: #ccd0da;
  --ct-link: #1e66f5;
  --ct-link-hover: #8839ef;
  --ct-code-bg: #dce0e8;
}

html[data-theme="catppuccin-dark"] {
  --ct-bg: #1e1e2e;
  --ct-surface: #313244;
  --ct-card: #181825;
  --ct-text: #cdd6f4;
  --ct-muted: #a6adc8;
  --ct-heading: #cba6f7;
  --ct-accent: #89b4fa;
  --ct-border: #45475a;
  --ct-link: #89b4fa;
  --ct-link-hover: #b4befe;
  --ct-code-bg: #313244;
}

html[data-theme="gruvbox-light"] {
  --ct-bg: #fbf1c7;
  --ct-surface: #ebdbb2;
  --ct-card: #f9f5d7;
  --ct-text: #3c3836;
  --ct-muted: #665c54;
  --ct-heading: #b16286;
  --ct-accent: #d79921;
  --ct-border: #d5c4a1;
  --ct-link: #076678;
  --ct-link-hover: #b16286;
  --ct-code-bg: #ebdbb2;
}

html[data-theme="gruvbox-dark"] {
  --ct-bg: #282828;
  --ct-surface: #3c3836;
  --ct-card: #1d2021;
  --ct-text: #ebdbb2;
  --ct-muted: #a89984;
  --ct-heading: #fabd2f;
  --ct-accent: #fe8019;
  --ct-border: #504945;
  --ct-link: #83a598;
  --ct-link-hover: #fabd2f;
  --ct-code-bg: #3c3836;
}

html {
  color-scheme: light;
  background: var(--ct-bg);
}

html[data-theme$="-dark"] {
  color-scheme: dark;
}

body {
  font-family: var(--bs-body-font-family), sans-serif;
  line-height: 1.6;
}

button,
input,
select,
textarea {
  font: inherit;
}

body {
  background: var(--ct-bg);
  color: var(--ct-text);
  letter-spacing: 0.3px;
}

.bg-body-tertiary {
  background-color: var(--ct-surface) !important;
}

.text-secondary {
  color: var(--ct-muted) !important;
}

.border-bottom,
.border,
.table,
.table > :not(caption) > * > * {
  border-color: var(--ct-border) !important;
}

.card {
  background: var(--ct-card);
  color: var(--ct-text);
  border-color: var(--ct-border);
}

.btn-outline-secondary {
  --bs-btn-color: var(--ct-text);
  --bs-btn-border-color: var(--ct-border);
  --bs-btn-hover-bg: var(--ct-accent);
  --bs-btn-hover-border-color: var(--ct-accent);
  --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: var(--ct-accent);
  --bs-btn-active-border-color: var(--ct-accent);
  --bs-btn-active-color: #fff;
  transition: all 0.15s ease;
}

.btn-outline-primary {
  --bs-btn-color: var(--ct-link);
  --bs-btn-border-color: var(--ct-link);
  --bs-btn-hover-bg: var(--ct-link);
  --bs-btn-hover-border-color: var(--ct-link);
  --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: var(--ct-link);
  --bs-btn-active-border-color: var(--ct-link);
  --bs-btn-active-color: #fff;
  transition: all 0.15s ease;
}

a {
  color: var(--ct-link);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--ct-link-hover);
  text-decoration: underline;
}

/* Improve heading hierarchy contrast */
h1, h2, h3, h4, h5, h6 {
  line-height: 1.3;
}

.h5 {
  font-weight: 600;
}

.h6 {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.form-control {
  background: var(--ct-card);
  color: var(--ct-text);
  border-color: var(--ct-border);
}

.form-control:focus {
  background: var(--ct-card);
  color: var(--ct-text);
  border-color: var(--ct-link);
  box-shadow: 0 0 0 0.2rem rgba(137, 180, 250, 0.2);
}

/* Improve placeholder text visibility in dark mode */
.form-control::placeholder {
  color: var(--ct-muted);
  opacity: 0.8;
}

/* Style autofill/autocomplete suggestions for better dark mode contrast */
.form-control:-webkit-autofill,
.form-control:-webkit-autofill:hover,
.form-control:-webkit-autofill:focus,
.form-control:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 30px var(--ct-card) inset !important;
  box-shadow: 0 0 0 30px var(--ct-card) inset !important;
}

.form-control:-webkit-autofill {
  -webkit-text-fill-color: var(--ct-text) !important;
  caret-color: var(--ct-text) !important;
}

/* Ensure suggested text is visible in dark mode */
html[data-theme$="-dark"] .form-control::placeholder {
  color: var(--ct-muted);
  opacity: 1;
}

/* Better contrast for input text in dark mode */
html[data-theme$="-dark"] .form-control {
  background-color: var(--ct-card);
  color: var(--ct-text);
}

.badge.text-bg-dark {
  background: var(--ct-accent) !important;
  color: #fff !important;
  font-weight: 600;
  padding: 0.4rem 0.6rem;
}

.small {
  font-size: 0.875rem;
  line-height: 1.5;
}

/* Improve form labels contrast */
.form-label {
  font-weight: 500;
}

.table {
  --bs-table-color: var(--ct-text);
  --bs-table-bg: var(--ct-card);
  --bs-table-striped-bg: rgba(137, 180, 250, 0.07);
  --bs-table-hover-bg: rgba(137, 180, 250, 0.11);
  --bs-table-border-color: var(--ct-border);
}

.table thead th {
  color: var(--ct-heading);
  font-weight: 600;
  padding: 0.875rem 0.75rem;
}

.table td {
  padding: 0.875rem 0.75rem;
  line-height: 1.5;
}

.table tbody tr {
  transition: background-color 0.15s ease;
}

.table tbody tr:hover {
  background-color: var(--bs-table-hover-bg);
}

.header-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  align-items: end;
}

.search-wrap {
  width: min(420px, 100%);
}

.search-wrap label {
  font-weight: 500;
}

.plain-english {
  margin-top: -0.2rem;
  margin-bottom: 0.85rem;
}

.quiz-likely-badge {
  background: var(--ct-accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.01em;
  vertical-align: middle;
}

html[data-theme$="-dark"] .quiz-likely-badge {
  background: var(--ct-heading);
  color: #1d2021;
}

.theme-wrap {
  min-width: 240px;
}

.theme-controls {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.theme-btn.active {
  --bs-btn-bg: var(--ct-accent);
  --bs-btn-color: #fff;
  --bs-btn-border-color: var(--ct-accent);
}

.nav-card {
  top: 1rem;
}

.nav-card a {
  color: var(--ct-link);
  text-decoration: none;
  display: inline-block;
  padding-bottom: 0.15rem;
  transition: all 0.15s ease;
}

.nav-card a:hover {
  text-decoration: underline;
  color: var(--ct-link-hover);
}

/* Compact nav list for better page fit */
.nav-card .list-unstyled li {
  padding: 0;
}

.nav-card .list-unstyled li a {
  font-size: 0.875rem;
  line-height: 1.3;
}

.content-entry {
  border: 0;
}

.content-entry h2 {
  color: var(--ct-heading);
  margin-bottom: 0.875rem;
}

.content-entry p {
  line-height: 1.65;
  margin-bottom: 1rem;
}

.content-entry ul,
.content-entry ol {
  line-height: 1.75;
}

.content-entry li {
  margin-bottom: 0.625rem;
}

.content-entry li:last-child {
  margin-bottom: 0;
}

.topic-image {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  background: var(--ct-card);
  border-color: var(--ct-border);
}

.image-zoom-trigger {
  display: block;
  width: 100%;
  cursor: zoom-in;
}

.image-zoom-trigger:focus-visible {
  outline: 2px solid var(--ct-accent);
  outline-offset: 2px;
}

#imageZoomModalImg {
  max-height: 75vh;
  object-fit: contain;
}

.hidden-match {
  display: none !important;
}

hr {
  border-color: var(--ct-border);
}

/* Glossary link tooltips and interactions */
.glossary-link {
  position: relative;
  cursor: help;
  border-bottom: 1px dotted var(--ct-accent);
  text-decoration: none;
  transition: border-color 0.15s ease;
}

.glossary-link:hover {
  border-bottom-style: solid;
  color: var(--ct-link-hover);
}

.glossary-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ct-card);
  color: var(--ct-text);
  border: 2px solid var(--ct-accent);
  border-radius: 0.375rem;
  padding: 0.875rem;
  margin-bottom: 0.5rem;
  font-size: 0.9375rem;
  line-height: 1.5;
  max-width: 280px;
  white-space: normal;
  word-wrap: break-word;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-in-out;
}

.glossary-tooltip.show {
  opacity: 1;
  pointer-events: auto;
}

.glossary-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--ct-accent);
}

/* Highlight animation for glossary rows */
@keyframes glossary-highlight {
  0% {
    background: transparent;
  }
  20% {
    background: rgba(137, 180, 250, 0.3);
  }
  100% {
    background: transparent;
  }
}

.glossary-row-highlight {
  animation: glossary-highlight 2s ease-in-out;
}

/* Persistent highlight for active glossary row */
.glossary-row-active {
  background: var(--ct-accent) !important;
  color: #fff !important;
}

.glossary-row-active td {
  background: var(--ct-accent) !important;
  color: #fff !important;
  border-color: var(--ct-accent) !important;
}

/* Better contrast in dark themes */
html[data-theme$="-dark"] .glossary-row-active,
html[data-theme$="-dark"] .glossary-row-active td {
  color: #1e1e2e !important;
}

html[data-theme$="-dark"] .glossary-row-active .glossary-term-link {
  color: #1e1e2e;
}

/* Glossary term links */
.glossary-term-link {
  color: var(--ct-link);
  text-decoration: underline;
  cursor: pointer;
  font-weight: 500;
  transition: opacity 0.2s ease;
}

.glossary-term-link:hover {
  opacity: 0.8;
}

/* Glossary term links visible when row is highlighted */
.glossary-row-active .glossary-term-link {
  color: #fff;
  text-decoration: underline;
  font-weight: 600;
}

.glossary-row-active .glossary-term-link:hover {
  opacity: 0.9;
}
.glossary-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.glossary-modal.show {
  opacity: 1;
  pointer-events: auto;
}

.glossary-modal-content {
  background: var(--ct-card);
  color: var(--ct-text);
  border: 2px solid var(--ct-border);
  border-radius: 0.5rem;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.glossary-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 2px solid var(--ct-border);
}

.glossary-modal-title {
  margin: 0;
  font-size: 1.25rem;
  color: var(--ct-heading);
  font-weight: 600;
}

.glossary-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--ct-text);
  cursor: pointer;
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
  opacity: 0.8;
}

.glossary-modal-close:hover {
  color: var(--ct-accent);
  opacity: 1;
}

.glossary-modal-body {
  padding: 1.5rem;
  line-height: 1.7;
}

.glossary-modal-body p {
  margin: 0;
  font-size: 1rem;
}

@media (max-width: 991.98px) {
  .nav-card {
    position: static !important;
  }
}



