:root {
  --bfr-canvas: #f6f8fa;
  --bfr-surface: #ffffff;
  --bfr-border: #d0d7de;
  --bfr-border-muted: #d8dee4;
  --bfr-text: #1f2328;
  --bfr-muted: #57606a;
  --bfr-link: #0969da;
  --bfr-green: #1f883d;
  --bfr-green-hover: #1a7f37;
  --bfr-danger: #cf222e;
  --bfr-radius: 6px;
  --bfr-shadow: 0 8px 24px rgba(140, 149, 159, .18);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bfr-canvas: #0d1117;
  --bfr-surface: #161b22;
  --bfr-border: #30363d;
  --bfr-border-muted: #21262d;
  --bfr-text: #e6edf3;
  --bfr-muted: #8b949e;
  --bfr-link: #58a6ff;
  --bfr-green: #238636;
  --bfr-green-hover: #2ea043;
  --bfr-danger: #f85149;
  --bfr-shadow: 0 8px 24px rgba(0,0,0,.35);
}

html { color-scheme: light; max-width: 100%; overflow-x: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
  color: var(--bfr-text) !important;
  background: var(--bfr-canvas) !important;
  background-image: none !important;
  overflow-x: hidden;
  max-width: 100%;
}
::selection { background: #b6e3ff; color: var(--bfr-text); }
:focus-visible { outline: 2px solid var(--bfr-link); outline-offset: 2px; }

nav, .glass-nav, .navbar {
  background: rgba(255,255,255,.97) !important;
  border-bottom: 1px solid var(--bfr-border) !important;
  box-shadow: none !important;
  backdrop-filter: blur(8px);
}
html[data-theme="dark"] nav, html[data-theme="dark"] .glass-nav, html[data-theme="dark"] .navbar { background: rgba(22,27,34,.97) !important; }
html[data-theme="dark"] .bg-white, html[data-theme="dark"] .bg-white\/95, html[data-theme="dark"] .bg-white\/50 { background-color: var(--bfr-surface) !important; }
html[data-theme="dark"] .bg-gray-50, html[data-theme="dark"] .bg-gray-50\/50, html[data-theme="dark"] .bg-gray-100 { background-color: #21262d !important; }
html[data-theme="dark"] .bg-gray-200 { background-color: #30363d !important; }
html[data-theme="dark"] .border-white { border-color: var(--bfr-surface) !important; }
html[data-theme="dark"] .text-gray-900, html[data-theme="dark"] .text-gray-800, html[data-theme="dark"] .text-gray-700 { color: var(--bfr-text) !important; }
html[data-theme="dark"] .text-gray-600, html[data-theme="dark"] .text-gray-500, html[data-theme="dark"] .text-gray-400 { color: var(--bfr-muted) !important; }
html[data-theme="dark"] .border-gray-50, html[data-theme="dark"] .border-gray-100, html[data-theme="dark"] .border-gray-200 { border-color: var(--bfr-border) !important; }
html[data-theme="dark"] input, html[data-theme="dark"] textarea, html[data-theme="dark"] select { background-color: #0d1117 !important; color: var(--bfr-text) !important; }
html[data-theme="dark"] .bfr-icon-box { background: #1f2937; border-color: #30363d; }
nav { height: 64px !important; }
nav [class*="bg-gradient-to-br"][class*="from-teal"], .bfr-brand-mark {
  background: #24292f !important;
  border: 0 !important;
  border-radius: var(--bfr-radius) !important;
  box-shadow: none !important;
  ring: 0 !important;
}
nav a, nav button { font-size: 14px !important; }
nav a:hover { color: var(--bfr-link) !important; }

.gradient-text {
  color: var(--bfr-text) !important;
  background: none !important;
  -webkit-text-fill-color: currentColor !important;
}
.blob { display: none !important; }
.hover-lift:hover { transform: none !important; box-shadow: none !important; }

button, a, input, textarea, select { transition-duration: .15s !important; }
input, textarea, select {
  border-color: var(--bfr-border) !important;
  border-radius: var(--bfr-radius) !important;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--bfr-link) !important;
  box-shadow: 0 0 0 3px rgba(9,105,218,.12) !important;
  outline: none !important;
}
button:disabled, [aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

.bfr-primary,
button[class*="from-teal"], a[class*="from-teal"],
button[class*="bg-teal-600"], a[class*="bg-teal-600"] {
  color: #fff !important;
  background: var(--bfr-green) !important;
  border: 1px solid rgba(31,35,40,.15) !important;
  border-radius: var(--bfr-radius) !important;
  box-shadow: 0 1px 0 rgba(31,35,40,.1) !important;
}
.bfr-primary:hover,
button[class*="from-teal"]:hover, a[class*="from-teal"]:hover,
button[class*="bg-teal-600"]:hover, a[class*="bg-teal-600"]:hover { background: var(--bfr-green-hover) !important; }

.bfr-card,
main [class*="bg-white"][class*="rounded-2xl"],
section [class*="bg-white"][class*="rounded-2xl"] {
  border: 1px solid var(--bfr-border) !important;
  border-radius: var(--bfr-radius) !important;
  box-shadow: none !important;
}
.rounded-xl { border-radius: var(--bfr-radius) !important; }
.shadow-lg, .shadow-xl, .shadow-2xl, .shadow-md { box-shadow: none !important; }

.bfr-icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  flex: 0 0 auto;
  vertical-align: -3px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.bfr-icon-lg { width: 28px; height: 28px; }
.bfr-icon-box {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--bfr-link);
  background: #ddf4ff;
  border: 1px solid #b6e3ff;
  border-radius: var(--bfr-radius);
}
.bfr-theme-toggle {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 2000;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--bfr-text);
  background: var(--bfr-surface);
  border: 1px solid var(--bfr-border);
  border-radius: 50%;
  box-shadow: var(--bfr-shadow);
  cursor: pointer;
}
.bfr-theme-toggle:hover { background: var(--bfr-canvas); }

/* Avatars are consistently circular across profiles and discussions. */
#userInitial, #authorInitial, #avatarPlaceholder, #avatarImage,
.admin-avatar, .reply-avatar,
[class*="avatar"] img, [id*="avatar"] img {
  border-radius: 9999px !important;
}
.admin-avatar, .reply-avatar, #authorInitial { overflow: hidden !important; }
html[data-theme="dark"] #posts { background: var(--bfr-surface) !important; border-color: var(--bfr-border) !important; }
html[data-theme="dark"] #posts .post-card { background: var(--bfr-surface) !important; border-color: var(--bfr-border) !important; }
html[data-theme="dark"] #posts .post-card:hover { background: #1c2128 !important; }
html[data-theme="dark"] #searchDropdown,
html[data-theme="dark"] .search-container > div:first-child,
html[data-theme="dark"] #posts .post-card > div:last-child > div:first-child,
html[data-theme="dark"] #posts .post-card > div:last-child > div:last-child > div {
  color: var(--bfr-text) !important;
  background: #21262d !important;
  border-color: var(--bfr-border) !important;
}
html[data-theme="dark"] .search-container input { color: var(--bfr-text) !important; background: transparent !important; }
html[data-theme="dark"] .search-container input::placeholder { color: var(--bfr-muted) !important; }
html[data-theme="dark"] #posts h3 { color: var(--bfr-text) !important; }
html[data-theme="dark"] #posts p { color: var(--bfr-muted) !important; }
html[data-theme="dark"] #posts [id^="score-"] { color: var(--bfr-text) !important; }
html[data-theme="dark"] #posts button[id^="upvote-btn-"]:not(.bg-teal-500),
html[data-theme="dark"] #posts button[id^="downvote-btn-"]:not(.bg-blue-500) { color: var(--bfr-muted) !important; background: transparent !important; }
html[data-theme="dark"] #posts button.bg-teal-500 { color: #fff !important; background: var(--bfr-green) !important; }
html[data-theme="dark"] #posts button.bg-blue-500 { color: #fff !important; background: #1f6feb !important; }
html[data-theme="light"] #posts h3 { color: var(--bfr-text) !important; }
html[data-theme="light"] #posts p { color: var(--bfr-muted) !important; }
html[data-theme="dark"] .reply-card,
html[data-theme="dark"] #replySection > div:first-child {
  color: var(--bfr-text) !important;
  background: var(--bfr-surface) !important;
  border-color: var(--bfr-border) !important;
}
html[data-theme="dark"] .reply-card .reply-author,
html[data-theme="dark"] .reply-card .reply-content { color: var(--bfr-text) !important; }
html[data-theme="dark"] .reply-card .reply-timestamp,
html[data-theme="dark"] .reply-card .reply-edited { color: var(--bfr-muted) !important; }
.star { display: inline-flex !important; cursor: pointer; color: #afb8c1 !important; }
.star .bfr-icon { width: 28px; height: 28px; }
.star.active, .star:hover { color: #bf8700 !important; }

footer { border-top: 1px solid var(--bfr-border) !important; background: #fff !important; color: var(--bfr-muted) !important; }

/* Compatibility for the retired standalone homepage */
.navbar { color: var(--bfr-text) !important; padding: 12px 30px !important; }
.navbar h1, .navbar a { color: var(--bfr-text) !important; }
.hero { background: var(--bfr-surface) !important; color: var(--bfr-text) !important; border-bottom: 1px solid var(--bfr-border); }
.hero p { color: var(--bfr-muted); }
.hero button, .cta a { color: #fff !important; background: var(--bfr-green) !important; border: 1px solid rgba(31,35,40,.15) !important; border-radius: var(--bfr-radius) !important; }
.features { max-width: 1100px; margin: auto; }
.feature-card { border: 1px solid var(--bfr-border); border-radius: var(--bfr-radius) !important; box-shadow: none !important; text-align: left !important; }
.feature-card h3 { color: var(--bfr-text) !important; }

@media (max-width: 767px) {
  nav { height: 64px !important; }
  nav [class*="top-20"] { top: 64px !important; }
  header { padding-top: 7rem !important; }
  h1 { overflow-wrap: anywhere; }
}
