body {
  background-color: var(--app-surface) !important;
  color: var(--app-on-surface) !important;
}
#header {
  background-color: var(--app-surface) !important;
  color: var(--app-on-surface) !important;
  box-shadow: 0 1px 3px 0 var(--app-shadow), 0 1px 2px -1px var(--app-shadow) !important;
}
#progress {
  background: linear-gradient(
    to right,
    var(--app-primary) var(--scroll),
    transparent 0
  ) !important;
}
a {
  color: var(--app-primary) !important;
}
a.text-green-500,
.text-green-500 {
  color: var(--app-primary) !important;
}
#header a.text-green-500 {
  color: var(--app-primary) !important;
}
nav ul a {
  color: var(--app-on-surface-variant) !important;
}
nav ul a:hover {
  color: var(--app-on-surface) !important;
}
button.bg-green-500,
button.bg-blue-500,
button.bg-blue-800 {
  background-color: var(--app-primary) !important;
  color: var(--app-on-primary) !important;
}
button.bg-green-500:hover,
button.bg-blue-500:hover,
button.bg-blue-800:hover {
  filter: brightness(1.1);
}
button.bg-green-500 a,
.dark button.bg-green-500 a {
  color: var(--app-on-primary) !important;
}
button#openProblemModal {
  background-color: var(--app-error) !important;
  color: var(--app-on-error) !important;
}
button#openProblemModal:hover {
  background-color: var(--app-error-container) !important;
  color: var(--app-on-error-container) !important;
}
button.bg-red-400 {
  background-color: var(--app-error) !important;
  color: var(--app-on-error) !important;
}
button.bg-blue-400 {
  background-color: var(--app-secondary) !important;
  color: var(--app-on-secondary) !important;
}
button.bg-yellow-400 {
  background-color: var(--app-tertiary) !important;
  color: var(--app-on-tertiary) !important;
}
button.bg-gray-300 {
  background-color: var(--app-surface-container-high) !important;
  color: var(--app-on-surface-variant) !important;
}
button.bg-gray-700 {
  background-color: var(--app-surface-variant) !important;
  color: var(--app-on-surface-variant) !important;
}
button.bg-gray-300:hover,
button.bg-gray-700:hover {
  filter: brightness(0.9);
}
button.bg-red-400,
button.bg-blue-400,
button.bg-yellow-400,
button.bg-green-500,
button.bg-blue-500,
button.bg-blue-800,
button.bg-gray-700 {
  /* Re-apply specific on-colors if needed, overriding .text-white */
  /* Patreon button */
  &.bg-red-400 {
    color: var(--app-on-error) !important;
  }
  /* Ko-fi button */
  &.bg-blue-400 {
    color: var(--app-on-secondary) !important;
  }
  /* Liberapay button */
  &.bg-yellow-400 {
    color: var(--app-on-tertiary) !important;
  }
  /* Primary buttons */
  &.bg-green-500,
  &.bg-blue-500,
  &.bg-blue-800 {
    color: var(--app-on-primary) !important;
  }
  /* GitHub button */
  &.bg-gray-700 {
    color: var(--app-on-surface-variant) !important;
  }
}
button.text-gray-800 {
  color: var(--app-on-surface-variant) !important;
}
#nav-toggle {
  color: var(--app-on-surface-variant) !important;
  border-color: var(--app-outline) !important;
}
#nav-toggle:hover {
  color: var(--app-on-surface) !important;
  border-color: var(--app-primary) !important;
}
.text-gray-900,
.text-gray-800,
.text-black {
  color: var(--app-on-surface) !important;
}
.dark .text-gray-100,
.dark .text-gray-200,
.dark .text-white {
  color: var(--app-on-surface) !important;
}
.text-gray-500,
.text-gray-600 {
  color: var(--app-on-surface-variant) !important;
}
.dark .text-gray-500,
.dark .text-gray-400 {
  color: var(--app-on-surface-variant) !important;
}
.bg-white {
  background-color: var(--app-surface) !important;
}
.dark .bg-gray-800 {
  background-color: var(--app-surface) !important;
}
.bg-gray-100 {
  background-color: var(--app-surface-container-low) !important;
}
.dark .bg-gray-600 {
  background-color: var(--app-surface-container) !important;
}
.text-yellow-500,
.dark .text-yellow-400 {
  color: var(--app-tertiary) !important;
}
.border,
.border-gray-300,
.dark .border-gray-700,
.border-gray-600 {
  border-color: var(--app-outline-variant) !important;
}
/* Code block container styling - aggressive overrides */
pre,
pre.flex,
pre.flex-col,
.flex.flex-col.justify-center.border,
pre[class*="flex"],
pre[class*="border"] {
  background-color: var(--app-surface-container-high) !important;
  border-color: var(--app-outline) !important;
  border-width: 2px !important;
  color: var(--app-on-surface) !important;
  padding: 16px !important;
  border-radius: 8px !important;
  overflow-x: auto !important;
  margin: 1em 0 !important;
}

/* Code element inside pre */
pre code,
pre code.p-2,
pre code[class*="bg-gray"],
code.p-2.bg-gray-100,
code.p-2.overflow-x-auto,
.p-2.bg-gray-100.dark\:bg-gray-900 {
  background-color: var(--app-surface-container-highest) !important;
  color: var(--app-on-surface) !important;
  display: block !important;
  padding: 12px !important;
  border-radius: 4px !important;
}

/* Override any Tailwind/Freedium gray backgrounds */
.bg-gray-100,
.dark\:bg-gray-900,
pre .bg-gray-100,
.dark pre .bg-gray-900 {
  background-color: var(--app-surface-container-highest) !important;
}
p code,
ul code,
li code,
code:not(pre *) {
  background-color: var(--app-surface-container-highest) !important;
  color: var(--app-primary) !important;
  padding: 0.2em 0.4em !important;
  border-radius: 4px !important;
  font-weight: 500 !important;
}
.hljs-copy {
  background-color: var(--app-primary-container) !important;
  color: var(--app-on-primary-container) !important;
  border: 1px solid var(--app-outline) !important;
  border-radius: 4px;
  padding: 4px 8px !important;
  margin: 4px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
}
.hljs-copy:hover {
  background-color: var(--app-primary) !important;
  color: var(--app-on-primary) !important;
  filter: brightness(1.1) !important;
}
.bg-green-100,
.dark .bg-green-800 {
  color: var(--app-on-primary-container) !important;
  background-color: var(--app-primary-container) !important;
  padding: 0.25em 0.5em !important;
  border-radius: 9999px !important;
  font-size: 0.8rem !important;
}
.bg-green-100 span,
.dark .bg-green-800 span {
  color: var(--app-on-primary-container) !important;
}

.modal-content {
  background-color: var(--app-surface-container) !important;
  color: var(--app-on-surface) !important;
}
#problem-description {
  background-color: var(--app-surface-container) !important;
  color: var(--app-on-surface) !important;
  border: 1px solid var(--app-outline) !important;
  border-radius: 4px;
}
#problem-description::placeholder {
  color: var(--app-on-surface-variant) !important;
}
figcaption {
  color: var(--app-on-surface-variant) !important;
}
svg {
  fill: currentColor !important;
}
#openProblemModal svg {
  fill: var(--app-on-error) !important;
}
#darkModeToggle svg {
  fill: var(--app-on-primary) !important;
}
.notification-container > div {
  background-color: var(--app-surface-container-low) !important;
  border-color: var(--app-outline-variant) !important;
  color: var(--app-on-surface) !important;
}
#darkModeToggle {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  width: 0 !important;
  height: 0 !important;
  opacity: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
}

/* Dynamic font size support */
.main-content,
.main-content p,
.main-content li,
.main-content span,
.main-content div {
  font-size: var(--app-font-size, 18px) !important;
}

.main-content h1 {
  font-size: calc(var(--app-font-size, 18px) * 2) !important;
}

.main-content h2 {
  font-size: calc(var(--app-font-size, 18px) * 1.5) !important;
}

.main-content h3,
.main-content h4 {
  font-size: calc(var(--app-font-size, 18px) * 1.25) !important;
}

.main-content code,
.main-content pre {
  font-size: calc(var(--app-font-size, 18px) * 0.875) !important;
}

/* Additional code block improvements */
.main-content pre code {
  display: block !important;
  padding: 12px !important;
  line-height: 1.6 !important;
  background-color: var(--app-surface-container-highest) !important;
  border-radius: 4px !important;
}

/* Ensure code blocks are distinguishable from content */
.main-content pre {
  margin: 1.5em 0 !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
  background-color: var(--app-surface-container-high) !important;
}

/* Syntax highlighting adjustments for better contrast */
.main-content pre .hljs {
  background-color: transparent !important;
}

/* Universal override for all code block related classes */
*[class*="bg-gray-100"],
*[class*="bg-gray-900"],
.p-2[class*="bg-"],
code[class*="bg-"],
pre code[class*="bg-"] {
  background-color: var(--app-surface-container-highest) !important;
  color: var(--app-on-surface) !important;
}

/* Specific overrides for common Freedium patterns */
.overflow-x-auto[class*="bg-gray"],
.p-2.overflow-x-auto {
  background-color: var(--app-surface-container-highest) !important;
}
