/* Theme Support - Force light color-scheme by default to prevent
   browser dark form controls when user has light theme but OS is dark */
:root {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

/* ═══════════════════════════════════════════════════════════════
   SPA Navigation Progress Bar
   ═══════════════════════════════════════════════════════════════ */
#spa-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 99999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

#spa-progress.active {
  opacity: 1;
}

#spa-progress.complete {
  opacity: 0;
}

#spa-progress.hidden {
  display: none;
}

#spa-progress .spa-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--text-color, #333333);
  border-radius: 0 1px 1px 0;
  transition: width 0.1s ease-out;
}

#spa-progress.error .spa-progress-bar {
  background: var(--error-color, #dc3545);
}

/* Dark mode - use lighter color for visibility */
[data-theme="dark"] #spa-progress .spa-progress-bar {
  background: var(--color-text-primary, #e5e7eb);
}

[data-theme="dark"] #spa-progress.error .spa-progress-bar {
  background: var(--error-color, #ef4444);
}

/* Text Selection Highlight */
::selection {
  background-color: var(--color-primary);
  color: var(--color-text-inverse);
}

::-moz-selection {
  background-color: var(--color-primary);
  color: var(--color-text-inverse);
}

/* Dark mode selection (inverted) */
[data-theme="dark"] ::selection {
  background-color: #eee;
  color: #1a1a1a;
}

[data-theme="dark"] ::-moz-selection {
  background-color: #eee;
  color: #1a1a1a;
}

/* MathJax SVG rendering - ensure proper display */
mjx-container {
  display: inline !important;
}

mjx-container svg {
  display: inline !important;
  visibility: visible !important;
}

/* Hide assistive MML (screen reader fallback) from visual display */
mjx-assistive-mml {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  clip: rect(1px, 1px, 1px, 1px) !important;
  -webkit-clip-path: inset(50%) !important;
  clip-path: inset(50%) !important;
  padding: 0 !important;
  border: 0 !important;
  height: 1px !important;
  width: 1px !important;
  overflow: hidden !important;
  white-space: nowrap !important;
}

/* Base Styles - colors defined in design-tokens.css */
:root {
  /* Color variables are now managed in design-tokens.css (neutral default + cool/warm overrides).
     Only NON-color layout variables and unique vars that aren't in design-tokens.css belong here. */
  --content-padding-x: 64px;
  --content-max-width: 1200px;
  --slider-track-color: #ddd;
  --slider-thumb-color: var(--text-color);
}

*, *::before, *::after {
  box-sizing: border-box;
}

ol {
  padding-left: 40px;
}

html {
  overflow-x: clip;
  max-width: 100vw;
}

body {
  font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
  line-height: 1.6;
  color: var(--color-text-primary, var(--text-color));
  margin: 0;
  padding: 0;
  background: var(--color-bg-primary, var(--white));
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
  overflow-x: clip; /* Prevent horizontal scrolling without breaking sticky */
  max-width: 100vw;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.full-page {
  width: var(--content-width-percent, 90%);
  max-width: var(--max-width);
  min-width: min(var(--min-width-fixed, 320px), 100%);
  margin: 0 auto;
  padding: 0 var(--content-padding-x, 64px);
}
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem;
}

/* Responsive width adjustments */
@media (max-width: 1024px) {
  .full-page {
    padding: 0 32px;
  }
}

@media (max-width: 768px) {
  .full-page {
    width: 100%;
    padding: 0 16px;
  }
}

a {
  color: var(--primary-color);
  text-decoration: none;
}


/* Main content links should underline on hover, but not navigation or buttons */


h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  font-family: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
  margin-bottom: 10px;
  margin-top: 10px;
}

h1 {
  font-size: 2.5rem;
  line-height: 1.1;
  letter-spacing: -0.02em;
   color: var(--color-text-primary);
}

h2 {
  font-size: 1.75rem;
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: var(--color-text-primary);
}

h3 {
  font-size: 1.4rem;
  line-height: 1.3;
   color: var(--color-text-primary);
}

.wiki-page h1 {
  color: var(--text-color);
  margin-bottom: 0.8rem;
}

p {
  font-size: 0.975rem;
  color: var(--color-text-primary);
  font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
}

ul {
  list-style-position: inside;
  margin-bottom: 1rem;
}

/* Header */
header {
  background-color: var(--color-bg-primary);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

/* Opt-in border — enabled per-page via headerBorder variable */
header.header-bordered {
  border-bottom: 1px solid var(--color-border-primary);
}

:root[data-theme="dark"] header {
  background-color: rgba(26, 26, 26, 0.95);
}

:root[data-theme="dark"] header.header-bordered {
  border-bottom: 1px solid #333;
}

header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  max-width: var(--max-width);
  margin: 0 auto;
  height: var(--header-height);
   box-sizing: border-box;
}

.header-left {
  display: flex;
  align-items: center;
}

header h1 {
  margin: 0;
  font-size: 1.2rem;
}

header h1 a {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--dark);
  font-weight: 600;
}

.logo {
  display: flex;
  align-items: center;
  margin-right: 0.5rem;
}

.logo svg {
  width: 45px;
  height: 45px;
  stroke: var(--color-text-secondary);
}

.page-title-header {
  font-size: 20px;
  font-weight: bold;
  color: var(--text-color);
  margin-left: 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-title-link {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
  display: inline-block; /* Make sure the entire area is clickable */
  max-width: 100%;      /* Ensure it doesn't overflow container */
}

.page-title-link:hover {
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
}

/* Styles for mobile page title if needed */
.mobile-page-title {
  display: none;
  padding: 10px 15px;
  font-size: 18px;
  font-weight: bold;
  border-bottom: 1px solid var(--color-border-secondary);
  max-width: 300px;
}

.search-box {
  position: relative;
  margin: 0 1rem;
  flex-grow: 0.5;
  max-width: 400px;
  display: flex;
  align-items: center;
  height: 100%;
}

.search-box form {
  display: flex;
  align-items: center;
  position: relative;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 10px;
  width: 16px;
  height: 16px;
  stroke: var(--color-text-tertiary);
  stroke-width: 2px;
  pointer-events: none;
  transition: stroke 0.2s ease;
}

.search-box:hover .search-icon,
.search-box:focus-within .search-icon {
  stroke: var(--color-text-primary);
}

.search-box input {
  width: 100%;
  padding: 0.5rem 0.5rem 0.5rem 2rem;
  border: none;
  border-radius: 16px;
  background-color: var(--color-bg-secondary);
  color: var(--color-text-primary);
  font-size: 0.9rem;
  transition: background-color 0.2s ease;
}

.search-box input::placeholder {
  color: var(--color-text-tertiary);
}

.search-box input:focus {
  outline: none;
  background-color: var(--color-bg-tertiary);
}

.nav-links {
  display: flex;
  align-items: center;
  margin-left: auto;
  height: 100%;
}

.nav-links a {
  margin-left: 20px;
  text-decoration: none;
  color: var(--text-color);
  font-weight: 500;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  height: 100%;
}

.nav-links a:hover {
  color: var(--primary-color);
}

.nav-links .btn {
  padding: 8px 16px;
  background-color: var(--primary-color);
  color: var(--color-text-inverse);
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: background-color 0.2s;
}

.nav-links .btn:hover {
  background-color: var(--color-primary-hover);
  color: var(--color-text-inverse);
  text-decoration: none;
}

/* Main Content */
main {
  min-height: calc(100vh - 110px);
  margin-bottom: 2rem;
  display: flex;
  padding-top: calc(var(--header-height) + 0rem);
}

/* On mobile, header is hidden — remove its reserved padding */
@media (max-width: 768px) {
  main {
    padding-top: 0 !important;
  }
}

/* Wiki Layout */
.wiki-layout {
  display: flex;
  width: 100%;
  position: relative;
  max-width: none;
  margin: 0 auto;
}

.content-wrapper {
  max-width: none;
  padding: 2rem;
  margin: 0;
  width: 100%;
  padding-top: 0;
}

.sidebar {
  width: var(--sidebar-width);
  position: fixed;
  left: 20px;
  top: calc(var(--header-height) + 20px);
  max-height: calc(100vh - var(--header-height) - 40px);
  background: var(--white);
  border: none;
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  overflow-y: auto;
  transition: transform 0.3s ease, opacity 0.3s ease, left 0.3s ease;
  z-index: 100;
  box-shadow: none;
}

/* Offset sidebar when chat-dock is present */
body:has(.chat-dock) .sidebar {
  left: 80px;
}

.sidebar.collapsed {
  transform: translateX(calc(-1 * var(--sidebar-width) - 40px));
  opacity: 0;
  pointer-events: none;
}

.wiki-content.full-width {
  margin-left: 0;
}

.page-header {
  margin-bottom: 0rem;
  width: 100%;
}

.page-title-section {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 0.75rem;
}

.page-title-section h1 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-size: 2rem;
  font-weight: 600;
  flex: 0 1 auto;
  min-width: 0;
}

.page-title-text {
  flex: 1 1 0%;
  min-width: 0;
}

.page-title-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.page-meta-counters {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: auto;
}

/* TOC Toggle Button - Minimal Design */
.toc-toggle-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-color);
  cursor: pointer;
  transition: opacity 0.2s ease;
  position: relative;
}

.toc-toggle-btn:hover {
  opacity: 0.7;
}

.toc-toggle-btn:active {
  opacity: 0.5;
}

.toc-toggle-btn svg {
  width: 24px;
  height: 24px;
  stroke-width: 2;
}

.toc-toggle-btn.visible {
  display: flex;
}

/* TOC Close Button - Modern Design */
.toc-close-btn {
  position: absolute;
  top: -0.75rem;
  right: 0.75rem;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  transition: all 0.2s ease;
  z-index: 10;
}

.toc-close-btn:hover {
  background: none;
  color: var(--primary-color);
  transform: rotate(90deg);
}

.toc-close-btn:active {
  transform: rotate(90deg) scale(0.9);
}

.toc-close-btn svg {
  width: 18px;
  height: 18px;
  transition: transform 0.2s ease;
}

/* Sidebar toggle button */
.toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  border: none;
  background: none;
  color: var(--text-color);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.toggle-btn:hover {
  background-color: var(--light-gray);
  color: var(--accent-color);
}

.toggle-btn svg {
  width: 20px;
  height: 20px;
  transition: transform 0.3s ease;
}


.counter-link {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  text-decoration: none;
  color: var(--text-color);
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  transition: background-color 0.2s ease;
}

.counter-link:hover {
  background-color: var(--light-gray);
  text-decoration: none;
}

.counter {
  font-weight: 600;
  color: var(--text-color);
}

.counter-label {
  color: var(--text-muted);
}
/* Proof Environment Styles — matches proof-citation-box styling */
.proof-environment {
  border: 1px solid var(--color-border-primary);
  border-radius: var(--radius-lg);
  margin: 1.5rem 0;
  background: var(--color-bg-secondary);
  overflow: hidden;
}

.proof-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  cursor: pointer;
  background: var(--color-bg-tertiary, var(--color-bg-secondary));
  border-bottom: 1px solid var(--border-color);
  transition: background 0.2s ease;
}

.proof-header:hover {
  background: var(--color-bg-hover, var(--color-bg-secondary));
}

.proof-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: var(--font-size-md);
  color: var(--text-primary);
}

.proof-icon {
  font-size: 1.2rem;
  transition: transform 0.25s ease;
  color: var(--text-secondary);
}

.proof-toggle {
  display: flex;
  align-items: center;
}

.toggle-icon {
  font-size: 1rem;
  color: var(--text-secondary);
  transition: transform 0.25s ease;
  display: inline-block;
}

/* Rotate the icon based on state */
.proof-toggle.collapsed .toggle-icon {
  transform: rotate(0deg);
}

.proof-toggle.expanded .toggle-icon {
  transform: rotate(90deg);
}

/* Collapsible content styling */
.proof-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease, padding 0.35s ease;
  background: var(--color-bg-primary);
}

.proof-content.collapsed {
  max-height: 0;
  padding: 0 20px;
}

.proof-content.expanded {
  max-height: 2000px;
  padding: 20px;
}

.proof-body {
  font-size: var(--font-size-md);
  line-height: 1.7;
  color: var(--text-primary);
}

.proof-body p {
  margin-bottom: 1em;
}

.proof-body p:last-child {
  margin-bottom: 0;
}

.proof-end {
  text-align: right;
  font-size: 18px;
  color: var(--text-secondary);
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

/* Dark mode support */

/* Dark mode styles */

/* Footer */
footer {
  background-color: var(--white);
  border-top: 1px solid var(--border-color);
  padding: 20px;
  text-align: center;
  color: var(--light-text);
  font-size: 0.9rem;
}

/* Site Footer - Apple Style */

.footer-container {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 22px;
}

.footer-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border-color, #ddd);
}

.footer-column h4 {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-color, #1a1a1a);
  margin: 0 0 0.5rem;
  letter-spacing: -0.01em;
}

.footer-column ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-column li {
  margin-bottom: 0.375rem;
}

.footer-column a {
  color: var(--light-text, #999);
  text-decoration: none;
  font-size: 0.75rem;
  line-height: 1.33337;
  transition: color 0.15s ease;
}

.footer-column a:hover {
  color: var(--text-color, #1a1a1a);
  text-decoration: underline;
}

.footer-divider {
  height: 1px;
  background: var(--border-color, #ddd);
}

.footer-bottom {
  padding: 1rem 0;
}

.footer-tagline {
  font-size: 0.75rem;
  color: var(--light-text, #999);
  margin: 0 0 0.75rem;
  line-height: 1.33337;
}

.footer-tagline a {
  color: var(--color-accent, #5A7A6A);
  text-decoration: none;
}

.footer-tagline a:hover {
  text-decoration: underline;
}

.footer-legal {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-color, #ddd);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.footer-links a {
  color: var(--light-text, #999);
  text-decoration: none;
  font-size: 0.75rem;
  padding: 0 0.5rem;
  border-right: 1px solid var(--border-color, #ddd);
}

.footer-links a:last-child {
  border-right: none;
  padding-right: 0;
}

.footer-links a:first-child {
  padding-left: 0;
}

.footer-links a:hover {
  color: var(--text-color, #1a1a1a);
  text-decoration: underline;
}

/* Footer Responsive */
@media (max-width: 833px) {
  .footer-nav {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 600px) {
  .footer-nav {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }
  
  .footer-legal {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  
  .footer-links {
    flex-wrap: wrap;
  }
}

.actions {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.actions .btn {
  margin-right: 0.5rem;
}

/* Forms */
.form {
  background-color: var(--white);
  border: 1px solid var(--border-color);
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  width: 100%;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 1rem;
}

.form-group.checkbox {
  display: flex;
  align-items: center;
}

.form-group.checkbox input {
  width: auto;
  margin-right: 0.5rem;
}

.form-group.checkbox label {
  margin-bottom: 0;
}

.form-actions {
  margin-top: 1rem;
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}

.data-table th,
.data-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--medium-gray);
  text-align: left;
}

.data-table th {
  background-color: var(--light-gray);
  font-weight: bold;
}

.data-table tr:hover {
  background-color: var(--light-gray);
}

.data-table .actions {
  margin-top: 0;
  white-space: nowrap;
}

.inline-form {
  display: inline;
}

/* Wiki Pages */
.wiki-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 180px;
}

/* Responsive wiki layout - reduce padding at intermediate widths */
@media (max-width: 1400px) {
  .wiki-container {
    padding: 0 80px;
  }
}

@media (max-width: 1200px) {
  .wiki-container {
    padding: 0 40px;
  }
  
  /* Show toggle button at intermediate widths */
  .toc-toggle-btn {
    display: flex;
  }
}

.wiki-content {
  display: flex;
  flex-direction: column;
  gap: 15px;
  width: 100%;
  position: relative;
  flex: 1;
  min-width: 0;
  margin-left: calc(var(--sidebar-width, 280px) - 150px);
  transition: margin-left 0.3s ease;
}


.wiki-page {
  background-color: var(--white);
  padding: 0px 30px 30px 30px;
  border-radius: 0;
  margin-bottom: 30px;
  position: relative;
  flex: 1;
  box-shadow: none;
  border: none;
}


.page-title-row {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--color-border-primary);
  position: relative;
}

.title-with-button {
  display: flex;
  align-items: center;
  width: 100%;
}

.settings-icon {
  width: 32px;
  height: 32px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--dark-gray);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  margin-left: 12px;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.settings-icon:hover {
  color: var(--primary-color);
  background-color: var(--light-gray);
}

.settings-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
}

.page-title {
  margin: 0 !important;
  color: var(--text-color);
  font-size: 48px;
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: -0.5px;
}

.page-meta {
  display: none;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--light-text, #5E6978);
  font-size: 0.85rem;
  margin-bottom: 15px;
}

.page-actions {
  display: none;
  gap: 10px;
  margin-top: 15px;
}

.page-actions.visible {
  display: flex;
}

/* Table of Contents */
.page-toc {
  font-size: var(--font-size-md);
  line-height: 1.4;
  position: relative;
  overflow-y: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.toc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding: 0;
}

.toc-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-color);
  letter-spacing: -0.01em;
}

.toc-toggle {
  background: none;
  border: 1px solid var(--border-color);
  padding: 4px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.3s ease;
  color: var(--text-color);
  background-color: var(--secondary-color);
  position: relative;
  z-index: 10;
  margin-left: 20px;
  flex-shrink: 0;
}

.toc-toggle:hover {
  background-color: var(--light-gray);
}

.toc-toggle svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  transition: transform 0.3s ease;
}

.sidebar-hidden .toc-toggle svg {
  transform: rotate(180deg);
}

.page-toc h3 {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin-bottom: 0;
  color: var(--text-color);
}

.page-toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.page-toc .toc-item {
  margin-bottom: 8px;
}

.page-toc .toc-link {
  display: block;
  padding: 6px 8px;
  color: var(--text-color);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  line-height: 1.3;
  position: relative;
}

.page-toc .toc-link:hover {
  color: var(--text-color);
  background-color: rgba(0, 0, 0, 0.04);
}

.page-toc .toc-link.active {
  color: var(--text-color);
  background-color: rgba(0, 0, 0, 0.04);
  font-weight: 500;
}

/* Vertical progress indicator on left side of active link */
.page-toc .toc-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 6px 0 0 6px;
  will-change: background;
}

/* Horizontal progress bar at bottom of active link */
.page-toc .toc-link.active::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  border-radius: 0 0 6px 6px;
  will-change: background;
}

/* TOC level indentation */
.page-toc .toc-level-1 {
  font-weight: 600;
  margin-top: 4px;
}

.page-toc .toc-level-2 {
  padding-left: 0;
}

.page-toc .toc-level-3 {
  padding-left: 12px;
}

.page-toc .toc-level-4 {
  padding-left: 24px;
}

.page-toc .toc-level-5 {
  padding-left: 36px;
}

.page-toc .toc-level-6 {
  padding-left: 48px;
}

/* ---- Collapsible TOC ---- */

/* Row container: arrow + link on the same line */
.toc-item-row {
  display: flex;
  align-items: center;
  gap: 0;
}

.toc-item-row .toc-link {
  flex: 1;
  min-width: 0;
}

/* Toggle arrow button */
.toc-toggle-arrow {
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px 2px 3px 0;
  color: var(--light-text, #999);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  transition: color 0.2s ease;
}

.toc-toggle-arrow:hover {
  color: var(--text-color, #333);
}

/* Arrow icon — rotates when expanded */
.toc-arrow-icon {
  width: 12px;
  height: 12px;
  transition: transform 0.2s ease;
}

.toc-toggle-arrow.toc-arrow-open .toc-arrow-icon {
  transform: rotate(90deg);
}

/* Children list — collapsed by default when collapsing is active */
.toc-children {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

/* Expanded children */
.toc-children.toc-expanded {
  max-height: 2000px;
}

/* Nested indentation — children inherit parent padding and add their own */
.toc-children .toc-item {
  padding-left: 10px;
}

/* Progress indicator for TOC */
.toc-link-progress {
  position: relative;
  overflow: hidden;
}

.toc-link-progress::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background-color: var(--primary-color);
  transition: width 0.2s ease;
}

.toc-link.active .toc-link-progress::after {
  width: var(--scroll-progress, 0%);
}

/* Scrollbar styles for the TOC */
.page-toc::-webkit-scrollbar {
  width: 4px;
}

.page-toc::-webkit-scrollbar-track {
  background: transparent;
}

.page-toc::-webkit-scrollbar-thumb {
  background: var(--medium-gray);
  border-radius: var(--radius-sm);
}

.page-toc::-webkit-scrollbar-thumb:hover {
  background: var(--dark-gray);
}

/* Dark mode adjustments for the TOC */

/* Markdown Content Styles */
.markdown-content h1, .markdown-content h2, .markdown-content h3, 
.markdown-content h4, .markdown-content h5, .markdown-content h6 {
  margin-top: 1.5em;
  margin-bottom: 0.75em;
  line-height: 1.3;
  color: var(--text-color);
  font-family: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
}

.markdown-content h1:first-child, .markdown-content h2:first-child, 
.markdown-content h3:first-child, .markdown-content h4:first-child, 
.markdown-content h5:first-child, .markdown-content h6:first-child {
  margin-top: 0;
}

.markdown-content h1 { 
  font-size: 48px; 
  line-height: 1.375; 
  font-weight: 500; 
  padding: 0px; 
  margin: 0px; 
  letter-spacing: 0.004em;
}

.markdown-content h2 { 
  font-size: 32px; 
  line-height: 1.125; 
  font-weight: 500; 
  letter-spacing: 0.004em;
}

.markdown-content h3 { 
  font-size: 28px; 
  line-height: 1.125; 
  font-weight: 400; 
  letter-spacing: 0.004em;
}

.markdown-content h4 { font-size: 24px; font-weight: 500; }
.markdown-content h5 { font-size: 20px; font-weight: 500; }

/* Ensure spacing between consecutive paragraphs */
.markdown-content p + p {
  margin-top: 1.2em;
}

/* Handle standalone <br> tags between paragraphs for extra spacing */
.rendered-markdown-content > br {
  display: block;
  margin: 0.6em 0;
  content: "";
}

/* Ensure multiple consecutive <br> tags create visible spacing */
.rendered-markdown-content > br + br {
  margin-top: 0.6em;
}

.markdown-content a {
  color: var(--primary-color);
  text-decoration: none;
}

.markdown-content a:hover {
  text-decoration: underline;
}

/* Internal wiki links (pages, theorems, definitions) get dotted underline */
a.internal-wiki-link {
  text-decoration: none;
  border-bottom: 1.5px dotted var(--color-text-primary);
  color: var(--primary-color);
  transition: all 0.2s ease;
}

a.internal-wiki-link:hover {
  text-decoration: none;
  border-bottom-style: solid;
  background: rgba(51, 51, 51, 0.1);
}

/* Dark mode: white dotted underline for wiki links */
:root[data-theme="dark"] a.internal-wiki-link {
  border-bottom-color: rgba(255, 255, 255, 0.7);
  color: var(--primary-color);
}

:root[data-theme="dark"] a.internal-wiki-link:hover {
  border-bottom-color: white;
  background: rgba(255, 255, 255, 0.1);
}

.markdown-content code {
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  background-color: var(--secondary-color);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-size: 0.9em;
}

.markdown-content pre {
  background-color: var(--secondary-color);
  padding: 16px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-size: 0.9rem;
  margin: 1em 0;
}

.markdown-content pre code {
  background-color: transparent;
  padding: 0;
  font-size: inherit;
}

.markdown-content blockquote {
  border-left: 4px solid var(--primary-color);
  margin: 1.5em 0;
  padding: 0.5em 1em;
  background-color: var(--secondary-color);
  border-radius: 0 6px 6px 0;
  color: var(--medium-gray);
}

.markdown-content ul, .markdown-content ol {
  margin: 1em 0;
  padding-left: 2em;
}

.markdown-content img {
  max-width: 100%;
  border-radius: var(--radius-md);
  margin: 1em 0;
}

.markdown-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
}

.markdown-content th, .markdown-content td {
  padding: 8px 12px;
  border: 1px solid var(--light-gray);
}

.markdown-content th {
  background-color: var(--secondary-color);
  font-weight: 600;
  text-align: left;
}

.markdown-content tr:nth-child(even) {
  background-color: var(--secondary-color);
}

/* Math styling */
.markdown-content .math {
  overflow-x: auto;
  padding: 10px 0;
}

.markdown-content .math-block {
  display: block;
  text-align: center;
  margin: 1.5em 0;
  padding: 0.8em 0;
}

.markdown-content .katex-display {
  margin: 1.5em 0;
  overflow-x: auto;
  overflow-y: hidden;
}

/* Definition styling */
.markdown-content dl {
  background-color: var(--light-gray);
  padding: 15px;
  border-radius: 5px;
  border-left: 4px solid var(--primary-color);
  margin-bottom: 1.5em;
}

.markdown-content dt {
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 0.5em;
}

.markdown-content dd {
  margin-bottom: 1em;
  margin-left: 0;
}

.markdown-content dd:last-child {
  margin-bottom: 0;
}


.search-results {
  list-style-type: none;
}

.search-results li {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--medium-gray);
}

.search-results li:last-child {
  border-bottom: none;
}

.result-excerpt {
  color: var(--dark-gray);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* Alerts */
.error {
  background-color: #f8d7da;
  color: #721c24;
  padding: 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid #f5c6cb;
  border-radius: 3px;
}

.info {
  background-color: #d1ecf1;
  color: #0c5460;
  padding: 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid #bee5eb;
  border-radius: 3px;
}

/* Editor Styles */
.editor-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 20px;
}

.editor-col {
  flex: 1;
}

.editor-label {
  font-weight: 600;
  margin-bottom: 10px;
}

.editor-input {
  width: 100%;
  min-height: 400px;
  padding: 15px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: 'Source Code Pro', monospace;
  font-size: 0.9rem;
  resize: vertical;
}

.editor-preview {
  min-height: 400px;
  padding: 15px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--color-bg-primary);
  overflow-y: auto;
}

/* Form Styles */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
}

.form-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 1rem;
}

.form-input:focus {
  border-color: var(--primary-color);
  outline: none;
}

/* Alerts and Notifications */
.alert {
  padding: 15px;
  margin-bottom: 20px;
  border-radius: var(--radius-sm);
}

.alert-error {
  background-color: #ffebee;
  color: var(--error-color);
  border: 1px solid #ffcdd2;
}

.alert-success {
  background-color: #e8f5e9;
  color: var(--success-color);
  border: 1px solid #c8e6c9;
}

.alert-warning {
  background-color: #fff8e1;
  color: var(--warning-color);
  border: 1px solid #ffecb3;
}

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mb-0 { margin-bottom: 0; }
.mt-0 { margin-top: 0; }
.hidden { display: none; }


/* Responsive Styles */
@media (max-width: 1000px) {
  .wiki-container {
    flex-direction: column;
    padding: 0 6px !important;
  }
  
  .wiki-content {
    margin-left: 0 !important;
  }
  
  /* Mobile TOC overlay — matches hamburger navigation pattern */
  .sidebar,
  .sidebar.collapsed {
    display: flex !important;
    flex-direction: column;
    width: 100% !important;
    max-width: 100% !important;
    position: fixed !important;
    top: var(--header-height, 50px) !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    transform: none !important;
    background: var(--white, #fff);
    z-index: 99999;
    padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
  }

  [data-theme="dark"] .sidebar,
  [data-theme="dark"] .sidebar.collapsed {
    background: var(--color-bg-primary, #1a1a1a);
  }

  /* Show sidebar overlay when toggled open (overrides .collapsed too) */
  .sidebar.mobile-visible,
  .sidebar.collapsed.mobile-visible {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  /* Show the toggle button at small widths */
  .toc-toggle-btn {
    display: flex;
  }

  .sidebar-hidden .sidebar {
    display: none;
  }

  /* Mobile close button — circular, matches hamburger menu close */
  .toc-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    background: var(--bg-secondary, #f5f5f7);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
  }
  .toc-close-btn:hover {
    background: var(--color-border-primary, #e0e0e0);
  }
}

.delete-form {
  display: inline;
}

/* Navigation Styles */
nav {
  margin-left: auto;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0;
}

.nav-menu a {
  color: var(--text-color);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.nav-menu a:hover {
  background-color: var(--light-gray);
  color: var(--primary);
  text-decoration: none;
}

.nav-menu .button {
  background-color: var(--primary);
  color: var(--color-text-inverse);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.nav-menu .button:hover {
  background-color: var(--primary-dark);
  color: var(--color-text-inverse);
  text-decoration: none;
}

.mobile-menu-button {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
}

.mobile-menu-button svg {
  width: 24px;
  height: 24px;
  stroke: var(--text-color);
}

/* Dark mode navigation adjustments */


/* Issue Detail Styles */
.issue-detail-container {
  max-width: 850px;
  margin: 0 auto;
}


.issue-status svg {
  margin-right: 4px;
}

.issue-status.open {
  background-color: rgba(40, 167, 69, 0.1);
  color: #28a745;
}

.issue-status.closed {
  background-color: rgba(203, 36, 49, 0.1);
  color: #cb2431;
}


.issue-author {
  font-weight: 500;
}

.issue-actions {
  margin-top: 15px;
}

.issue-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.issue-description, .comment {
  background-color: var(--white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.comment-header {
  background-color: var(--light-gray);
  padding: 10px 15px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
}

.comment-author {
  font-weight: 500;
}

.comment-date {
  color: var(--light-text);
  font-size: 0.85rem;
}

.comment-content {
  padding: 15px;
}

.comments-section h3 {
  margin-top: 30px;
  margin-bottom: 15px;
  font-size: 1.2rem;
}

.comments-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.new-comment {
  margin-top: 30px;
}

.btn-danger {
  background-color: #cb2431;
  color: var(--color-text-inverse);
}

.btn-danger:hover {
  background-color: #a91e2a;
}

/* Responsive design for wiki pages */

/* Add additional styling to ensure wiki pages have minimal gaps and better spacing */

.welcome-section {
  margin-bottom: 30px;
}

.pages-section {
  margin-bottom: 30px;
}

.page-list {
  list-style: none;
  padding-left: 0;
  margin-top: 15px;
}

.page-list li {
  margin-bottom: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--light-gray);
}

.page-list li:last-child {
  border-bottom: none;
}

.page-list a {
  color: var(--primary-color);
  text-decoration: none;
  display: block;
  padding: 5px 0;
}

.page-list a:hover {
  color: var(--primary-color);
  text-decoration: underline;
}

.markdown-content p {
  line-height: 1.6;
}

.markdown-content h1, 
.markdown-content h2, 
.markdown-content h3, 
.markdown-content h4,
.markdown-content h5,

@media (max-width: 900px) {
  .page-title {
    font-size: 2.5rem;
  }
  
  .page-meta {
    flex-direction: column;
    gap: 5px;
  }
  
  .page-actions {
    flex-wrap: wrap;
    gap: 10px;
  }
}

/* Make content area more centered and spacious */
.markdown-content {
  max-width: 100%;
  margin: 0 auto;
}

.page-content {
  margin-top: 20px;
}

/* Ensure proper spacing for headers in markdown content */
.markdown-content h1, 
.markdown-content h2, 
.markdown-content h3, 
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
  margin-top: 1.5em;
  margin-bottom: 0.75em;
}

.markdown-content > :first-child {
  margin-top: 0;
}

/* Hide sidebar styles */
.sidebar-hidden .sidebar {
  transform: translateX(-100%);
  opacity: 0;
  width: 0;
  padding: 0;
  overflow: hidden;
  transition: all 0.3s ease;
}

.sidebar-hidden .wiki-content {
  padding-left: 30px;
  max-width: 100%;
  margin-left: 0 !important;
}

/* When sidebar hidden but chat-dock present */
body:has(.chat-dock).sidebar-hidden .wiki-content {
  margin-left: 60px !important;
}

.sidebar-hidden .toc-toggle {
  transform: translateX(30px);
  position: fixed;
  left: 0;
  top: 80px;
  z-index: 100;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  display: none; /* Hide this button when sidebar is hidden */
}

/* Image Upload Styles */
.image-upload-info {
  display: flex;
  align-items: center;
  margin-top: 10px;
  font-size: 0.9rem;
  color: var(--light-text);
  gap: 8px;
  flex-wrap: wrap;
}

.paste-instruction {
  margin-right: 5px;
}

.upload-label {
  color: var(--primary-color);
  cursor: pointer;
  text-decoration: underline;
}

.upload-label:hover {
  text-decoration: none;
}

.syntax-hint {
  margin-left: 8px;
  font-size: 0.85rem;
  color: var(--light-text);
  font-style: italic;
}

.syntax-hint code {
  background: var(--color-bg-tertiary);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: #d73a49;
}

.size-label {
  margin-left: 8px;
  font-weight: 500;
  color: var(--text-color);
}

.image-scale-select {
  padding: 4px 8px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--color-bg-primary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.2s;
}

.image-scale-select:hover {
  border-color: var(--primary-color);
}

.image-scale-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

.hidden-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.uploading-indicator {
  margin-top: 10px;
  padding: 8px;
  background-color: var(--light-gray);
  border-radius: var(--radius-sm);
  display: inline-block;
  font-size: 0.9rem;
}

/* Textarea Styles */
textarea.form-control {
  width: 100%;
  min-height: 100px;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
}

textarea.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(0, 112, 243, 0.1);
}

/* Issue Comment Styles */
.issue-comment-form {
  flex: 1;
}

.tab-nav {
  display: flex;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.tab-nav-item {
  padding: 8px 12px;
  margin-right: 10px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-color);
}

.tab-nav-item:hover {
  color: var(--primary-color);
}

.tab-nav-item.active {
  border-bottom-color: var(--primary-color);
  color: var(--primary-color);
  font-weight: 500;
}

.tab-content {
  margin-bottom: 15px;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Dark mode adjustments */

/* Theorems Styles */
.theorems-header {
  text-align: center;
  margin-bottom: 2rem;
}

.theorems-header h1 {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  font-weight: 700;
}

.theorems-header .subtitle {
  color: var(--light-text);
  font-size: 1.2rem;
}

.theorem-search-form .search-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.theorems-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 2rem;
  background-color: var(--white);
}

.theorems-table th {
  background-color: var(--light-gray);
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
}

.theorems-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
}

.theorems-table tr:last-child td {
  border-bottom: none;
}

.theorem-row {
  cursor: pointer;
  transition: background-color 0.2s;
}

.theorem-row:hover {
  background-color: var(--lighter-gray);
}

.theorem-id {
  color: var(--light-text);
  font-weight: 500;
  white-space: nowrap;
}

.theorem-name {
  font-weight: 600;
  color: var(--primary-color);
}


/* Theorem Detail Styles */
.theorem-breadcrumb {
  margin-bottom: 1.5rem;
  color: var(--light-text);
  font-size: 0.9rem;
}

.theorem-breadcrumb a {
  color: var(--primary-color);
  text-decoration: none;
}

.theorem-breadcrumb a:hover {
  text-decoration: underline;
}


.theorem-header {
  border-bottom: 1px solid var(--border-color);
}


.theorem-categories {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.theorem-area, .theorem-subarea {
  background-color: var(--lighter-gray);
  color: var(--text-color);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
}

.theorem-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.tag {
  background-color: var(--light-gray);
  color: var(--text-color);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
}

.theorem-meta {
  color: var(--light-text);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.theorem-actions {
  display: flex;
  gap: 0.5rem;
}


.theorem-section {
  margin-bottom: 2rem;
}

.theorem-section h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

/* Theorem Form Styles */
.theorem-form-header {
  margin-bottom: 1.5rem;
}

.theorem-form {
  background-color: var(--white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 2rem;
  padding: 1.5rem;
}

.form-section {
  margin-bottom: 2rem;
}

.form-section h2 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.editor-tab-container {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.editor-tabs {
  display: flex;
  background-color: var(--light-gray);
  border-bottom: 1px solid var(--border-color);
}

.editor-tab {
  padding: 0.5rem 1rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-color);
}

.editor-tab.active {
  background-color: var(--white);
  border-bottom: 2px solid var(--primary-color);
  color: var(--primary-color);
}

.editor-pane {
  display: none;
}

.editor-pane.active {
  display: block;
}

.editor-textarea {
  width: 100%;
  padding: 1rem;
  border: none;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
}

.editor-textarea:focus {
  outline: none;
}

.preview-content {
  padding: 1rem;
  min-height: 100px;
}

/* Dark mode adjustments */

/* Theorem Preview Styles */
.theorem-preview-tooltip {
  background-color: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  max-width: 400px;
  padding: 15px;
  font-size: 0.9rem;
  line-height: 1.5;
  border: 1px solid var(--border-color);
  transition: opacity 0.2s;
  overflow: hidden;
}

.theorem-preview-tooltip .theorem-preview-header {
  margin-bottom: 10px;
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
}

.theorem-preview-tooltip h3 {
  font-size: 1.2rem;
  margin: 0 0 8px 0;
  color: var(--primary-color);
  flex-basis: 100%;
}

.theorem-preview-controls {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  gap: 4px;
}

.theorem-preview-close-btn,
.theorem-preview-collapse-btn,
.theorem-preview-pin-btn {
  background: none;
  border: none;
  color: var(--light-text);
  font-size: 1.2rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.theorem-preview-close-btn:hover,
.theorem-preview-collapse-btn:hover,
.theorem-preview-pin-btn:hover {
  opacity: 1;
  background-color: var(--lighter-gray);
}

.theorem-preview-pin-hint {
  font-size: 0.7rem;
  text-align: center;
  margin-top: 8px;
  color: var(--light-text);
  font-style: italic;
}

.theorem-preview-area,
.theorem-preview-subarea {
  background-color: var(--lighter-gray);
  color: var(--text-color);
  padding: 2px 8px;
  border-radius: var(--radius-xl);
  font-size: 0.75rem;
  font-weight: 500;
  margin-right: 6px;
  display: inline-block;
}

.theorem-preview-tags {
  margin-bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.theorem-preview-tag {
  background-color: var(--light-gray);
  color: var(--text-color);
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 400;
}

.theorem-preview-statement {
  margin-bottom: 12px;
  max-height: 150px;
  overflow-y: auto;
  padding-right: 5px;
}

.theorem-preview-statement * {
  margin-top: 0.5em;
  margin-bottom: 0.5em;
}

.theorem-preview-statement *:first-child {
  margin-top: 0;
}

.theorem-preview-statement *:last-child {
  margin-bottom: 0;
}

.theorem-preview-link {
  display: block;
  text-align: right;
  font-size: 0.8rem;
  color: var(--primary-color);
  text-decoration: none;
  margin-top: 8px;
}

.theorem-preview-link:hover {
  text-decoration: underline;
}

.theorem-preview-loading {
  padding: 15px;
  text-align: center;
  color: var(--light-text);
  font-style: italic;
}

.theorem-preview-error {
  padding: 15px;
  text-align: center;
  color: var(--danger-color);
  font-style: italic;
}

/* Dark mode adjustments for theorem preview */

/* Theorem Reference Styles */
a.theorem-reference {
  color: var(--primary-color);
  text-decoration: none;
  background-color: rgba(0, 112, 243, 0.1);
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: background-color 0.2s;
}

a.theorem-reference:hover {
  background-color: rgba(0, 112, 243, 0.2);
  text-decoration: none;
}

/* Dark mode adjustments for theorem references */


/* Theorem Environment Styles */
.theorem-box {
  padding: 20px;
  margin: 16px 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}

.definition-box {
  border-left: 6px solid var(--color-primary);
  background-color: rgb(0 0 0 / 3%);
  padding: 12px 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  margin: 10px 0;
}

.definition-box .definition-title {
  font-weight: 600;
}

.definition-box p {
  display: inline;
  margin: 0;
}

.definition-box p + p {
  display: block;
  margin-top: 8px;
}

.theorem-content p:last-child {
  margin-bottom: 0;
}

/* Remark Box — subtle amber-tinted callout */
.remark-box {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background-color: var(--color-remark-bg);
  border-radius: var(--radius-lg, 8px);
  padding: 14px 18px;
  margin: 16px 0;
}

.remark-box .remark-icon {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--color-remark-accent);
}

.remark-box .remark-icon svg {
  display: block;
}

.remark-box .remark-body {
  flex: 1;
  min-width: 0;
}

.remark-box .remark-title {
  display: none;
}

.remark-box .remark-content {
  font-size: var(--font-size-lg, 14px);
  line-height: 1.6;
  color: var(--color-remark-text);
}

.remark-box .remark-content,
.remark-box .remark-content p,
.remark-box .remark-content span,
.remark-box .remark-content a,
.remark-box .remark-content mjx-container {
  color: var(--color-remark-text);
}

.remark-box .remark-content p {
  margin: 0;
}

.remark-box .remark-content p + p {
  margin-top: 8px;
}

/* Remark with explicit title */
.remark-box.remark-has-title .remark-title {
  display: block;
  font-weight: var(--font-weight-semibold, 600);
  font-size: var(--font-size-lg, 14px);
  color: var(--color-remark-accent);
  margin-bottom: 4px;
}

/* Dark mode overrides for remark box — needed to beat the high-specificity
   dark-mode catch-all div:not(...) { color: inherit } and MathJax !important rules */
:root[data-theme="dark"] .remark-box .remark-icon {
  color: var(--color-remark-accent) !important;
}

:root[data-theme="dark"] .remark-box .remark-content,
:root[data-theme="dark"] .remark-box .remark-content p,
:root[data-theme="dark"] .remark-box .remark-content span,
:root[data-theme="dark"] .remark-box .remark-content a,
:root[data-theme="dark"] .remark-box .remark-content mjx-container,
:root[data-theme="dark"] .remark-box .remark-content mjx-container svg {
  color: var(--color-remark-text) !important;
}

:root[data-theme="dark"] .remark-box.remark-has-title .remark-title {
  color: var(--color-remark-accent) !important;
}

/* Dark mode adjustments for theorems */

/* Theorem Citation Styles */
.theorem-citation-box {
  margin: 20px 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--color-bg-primary);
}

/* Theorem box header styling */
.theorem-box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.theorem-header-actions {
  display: flex;
  gap: 8px;
}

.theorem-citation-placeholder {
  padding: 20px;
  text-align: center;
  background: var(--color-bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin: 20px 0;
}

.loading-theorem-citation {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px 16px;
}

.loading-theorem-citation p {
  margin: 0;
  font-size: var(--font-size-sm, 13px);
  color: var(--text-secondary, #666);
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--border-color, #e0e0e0);
  border-top-color: var(--text-color, #333);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.proof-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px 16px;
}

.proof-loading p {
  margin: 0;
  font-size: var(--font-size-sm, 13px);
  color: var(--text-secondary, #666);
}

.theorem-citation-error {
  padding: 20px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-lg);
  margin: 20px 0;
}

.theorem-citation-error .error-message {
  color: #dc2626;
  font-weight: 500;
}

/* ===== Proof Citation Box [citeproof:id] ===== */
.proof-citation-box {
  margin: 20px 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--color-bg-secondary);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.proof-citation-box:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.proof-citation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  cursor: pointer;
  background: var(--color-bg-tertiary, var(--color-bg-secondary));
  border-bottom: 1px solid var(--border-color);
  transition: background 0.2s ease;
}

.proof-citation-header:hover {
  background: var(--color-bg-hover, var(--color-bg-secondary));
}

.proof-citation-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: var(--font-size-md);
  color: var(--text-primary);
}

.proof-citation-icon {
  transition: transform 0.25s ease;
  color: var(--text-secondary);
}

.proof-citation-box.expanded .proof-citation-icon {
  transform: rotate(90deg);
}

.proof-citation-link {
  font-size: var(--font-size-sm);
  color: var(--primary-color);
  text-decoration: none;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.proof-citation-link:hover {
  opacity: 1;
  text-decoration: underline;
}

.proof-citation-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease, padding 0.35s ease;
  background: var(--color-bg-primary);
}

.proof-citation-box.expanded .proof-citation-content {
  max-height: 2000px;
  padding: 20px;
}

/* After expand transition completes, remove height cap so nested
   collapsible elements (e.g. expandable proofs) can grow freely */
.proof-citation-box.expand-complete .proof-citation-content {
  max-height: none;
  overflow: visible;
}

.proof-citation-body {
  font-size: var(--font-size-md);
  line-height: 1.7;
  color: var(--text-primary);
}

.proof-citation-body p {
  margin-bottom: 1em;
}

.proof-citation-body p:last-child {
  margin-bottom: 0;
}

.proof-citation-qed {
  text-align: right;
  font-size: 18px;
  color: var(--text-secondary);
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

.proof-citation-error,
.proof-citation-empty {
  padding: 16px 20px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-lg);
  margin: 20px 0;
  color: #b91c1c;
  font-size: var(--font-size-md);
}

.proof-citation-empty {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

/* Dark mode */
:root[data-theme="dark"] .proof-citation-box:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

:root[data-theme="dark"] .proof-citation-error,
:root[data-theme="dark"] .proof-citation-empty {
  background: rgba(185, 28, 28, 0.1);
  border-color: rgba(185, 28, 28, 0.3);
  color: #fca5a5;
}

:root[data-theme="dark"] .proof-citation-empty {
  background: rgba(146, 64, 14, 0.1);
  border-color: rgba(146, 64, 14, 0.3);
  color: #fcd34d;
}

/* Ensure theorem citation content gets properly styled */
.theorem-citation-content {
  margin: 12px 0;
}

/* Theorem citation actions - similar to statement-actions */
.theorem-citation-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border-primary);
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
}

.theorem-citation-actions .left-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.theorem-citation-actions .right-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-left: auto;
}

/* ========== Definition Citation Box [citedefinition:reference] ========== */
.definition-citation-box {
  margin: 20px 0;
  border: 1px solid var(--border-color);
  border-left: 6px solid var(--color-primary);
  border-radius: var(--radius-lg);
  background: var(--color-bg-secondary, rgb(0 0 0 / 3%));
  padding: 20px;
}

.definition-citation-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  gap: 12px;
}

.definition-citation-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}

.definition-citation-title-row .tags-section {
  margin: 0;
}

.definition-citation-title-row .tag-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.definition-citation-title-row a {
  text-decoration: none;
  color: inherit;
}

.definition-citation-title-row a:hover {
  text-decoration: underline;
}

.definition-header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.definition-citation-content {
  margin: 12px 0;
  font-size: var(--font-size-md);
  line-height: 1.7;
  color: var(--text-primary);
}

.definition-citation-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border-primary);
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
}

.definition-citation-actions .left-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.definition-citation-actions .right-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-left: auto;
}

.definition-citation-brain-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.definition-citation-brain-icon {
  cursor: pointer;
  transition: color 0.2s ease, transform 0.15s ease;
}

.definition-citation-brain-icon:hover {
  transform: scale(1.1);
}

.definition-citation-brain-icon.known {
  color: #28a745;
}

.definition-citation-brain-icon.unknown {
  color: var(--color-text-secondary);
}

.definition-citation-generality-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--white, #fff);
  border: 1px solid var(--border, #d0d7de);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  min-width: 220px;
  z-index: 200;
  overflow: hidden;
  padding: 8px 0;
}

.definition-citation-generality-dropdown .knowledge-dropdown-header {
  padding: 6px 12px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-tertiary);
  border-bottom: 1px solid var(--color-border-secondary);
  margin-bottom: 4px;
}

.definition-citation-generality-dropdown .knowledge-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s ease;
}

.definition-citation-generality-dropdown .knowledge-dropdown-item:hover {
  background: var(--color-bg-hover, #f6f8fa);
}

.definition-citation-generality-dropdown .knowledge-level-check {
  margin-left: auto;
  color: #28a745;
  font-weight: 600;
}

.definition-citation-knowledge-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.definition-citation-placeholder {
  padding: 24px 20px;
  text-align: center;
  background: var(--color-bg-secondary, #f9f9f9);
  border: 1px solid var(--border-color);
  border-left: 6px solid var(--color-primary);
  border-radius: var(--radius-lg);
  margin: 20px 0;
}

.loading-definition-citation {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.loading-definition-citation p {
  margin: 0;
  font-size: var(--font-size-sm, 13px);
  color: var(--text-secondary, #666);
}

.definition-citation-error {
  padding: 16px 20px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-left: 6px solid #dc3545;
  border-radius: var(--radius-lg);
  margin: 20px 0;
  color: #dc2626;
  font-weight: 500;
}

:root[data-theme="dark"] .definition-citation-box {
  border-left-color: #aaa;
  background: var(--color-bg-secondary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

:root[data-theme="dark"] .definition-citation-actions {
  border-top-color: #444;
}

:root[data-theme="dark"] .definition-citation-placeholder {
  background: var(--color-bg-secondary);
  border-left-color: #aaa;
}

:root[data-theme="dark"] .definition-citation-generality-dropdown {
  background: var(--color-bg-secondary, #2a2a2a);
  border-color: var(--border-color, #444);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

:root[data-theme="dark"] .definition-citation-generality-dropdown .knowledge-dropdown-header {
  border-bottom-color: #444;
  color: #999;
}

:root[data-theme="dark"] .definition-citation-generality-dropdown .knowledge-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

:root[data-theme="dark"] .definition-citation-error {
  background: rgba(185, 28, 28, 0.1);
}

/* Prerequisite status styling */
.prerequisite-status-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
}

.prerequisite-status-text.ready-to-learn {
  color: var(--color-accent-dark);
  background: rgba(90, 122, 106, 0.1);
}

.prerequisite-status-text.knowledge-gaps {
  color: var(--color-warning);
  background: rgba(196, 152, 64, 0.1);
}

/* Knowledge gaps hover tooltip */
.knowledge-gaps-wrapper {
  position: relative;
  display: inline-flex;
  cursor: pointer;
}

.knowledge-gaps-tooltip {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  padding-top: 0;
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border-primary);
  border-radius: 10px;
  padding: 14px 16px;
  min-width: 240px;
  max-width: 340px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  z-index: 1000;
  font-size: 13px;
  font-weight: 400;
  color: var(--color-text-primary);
  line-height: 1.5;
}

.knowledge-gaps-tooltip::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 16px;
  width: 10px;
  height: 10px;
  background: var(--color-bg-primary);
  border-left: 1px solid var(--color-border-primary);
  border-top: 1px solid var(--color-border-primary);
  transform: rotate(45deg);
}

/* Invisible bridge to keep tooltip open when moving mouse from trigger to tooltip */
.knowledge-gaps-tooltip::after {
  content: '';
  position: absolute;
  top: -12px;
  left: 0;
  width: 100%;
  height: 12px;
}

.knowledge-gaps-wrapper:hover .knowledge-gaps-tooltip {
  display: block;
}

.knowledge-gaps-tooltip .tooltip-section {
  margin-bottom: 0;
}

.knowledge-gaps-tooltip .tooltip-section + .tooltip-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--color-border-secondary);
}

.knowledge-gaps-tooltip .tooltip-section-title {
  margin: 0 0 6px 0;
  font-size: var(--font-size-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-tertiary);
}

.knowledge-gaps-tooltip .tooltip-prereq-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.knowledge-gaps-tooltip .tooltip-prereq-list li {
  padding: 3px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.knowledge-gaps-tooltip .tooltip-prereq-list li::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #dc3545;
  flex-shrink: 0;
}

.knowledge-gaps-tooltip .tooltip-prereq-list li a {
  color: #dc3545;
  text-decoration: none;
  font-weight: 500;
}

.knowledge-gaps-tooltip .tooltip-prereq-list li a:hover {
  text-decoration: underline;
}

/* Dark mode for knowledge gaps tooltip */
:root[data-theme="dark"] .knowledge-gaps-tooltip {
  background: #2a2a2a;
  border-color: #444;
  color: #e0e0e0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

:root[data-theme="dark"] .knowledge-gaps-tooltip::before {
  background: #2a2a2a;
  border-color: #444;
}

:root[data-theme="dark"] .knowledge-gaps-tooltip .tooltip-section + .tooltip-section {
  border-top-color: #444;
}

:root[data-theme="dark"] .knowledge-gaps-tooltip .tooltip-section-title {
  color: #999;
}

:root[data-theme="dark"] .knowledge-gaps-tooltip .tooltip-prereq-list li a {
  color: #ff6b6b;
}

/* Statement actions layout for theorem citation boxes */
.statement-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
}

.statement-actions .left-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.statement-actions .right-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-left: auto;
}

/* ===== Add to Deck Modal ===== */
.add-to-deck-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: addToDeckFadeIn 0.15s ease;
}

@keyframes addToDeckFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.add-to-deck-modal {
  background: var(--color-bg-primary, #fff);
  border-radius: var(--radius-lg, 12px);
  width: 90%;
  max-width: 440px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: addToDeckSlideUp 0.2s ease;
}

@keyframes addToDeckSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.add-to-deck-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border-primary, #e5e7eb);
}

.add-to-deck-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.add-to-deck-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--color-text-secondary, #6b7280);
  padding: 0 4px;
  line-height: 1;
}

.add-to-deck-close:hover {
  color: var(--color-text-primary, #111);
}

.add-to-deck-subtitle {
  margin: 0 0 14px 0;
  font-size: 13px;
  color: var(--color-text-secondary, #6b7280);
  padding: 16px 20px 0;
}

.add-to-deck-options {
  padding: 0 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.add-to-deck-option {
  background: var(--color-bg-secondary, #f9fafb);
  border: 1px solid var(--color-border-primary, #e5e7eb);
  border-radius: var(--radius-md, 8px);
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.add-to-deck-option:hover {
  border-color: var(--color-primary, #6366f1);
  background: var(--color-bg-tertiary, #f3f4f6);
}

.add-to-deck-option-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
  color: var(--color-text-primary, #111);
}

.add-to-deck-option-desc {
  font-size: 12px;
  color: var(--color-text-secondary, #6b7280);
}

.add-to-deck-deck-list {
  padding: 0 20px 20px;
  max-height: 50vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.add-to-deck-deck-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--color-bg-secondary, #f9fafb);
  border: 1px solid var(--color-border-primary, #e5e7eb);
  border-radius: var(--radius-md, 8px);
  padding: 12px 16px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  width: 100%;
  text-align: left;
}

.add-to-deck-deck-item:hover {
  border-color: var(--color-primary, #6366f1);
  background: var(--color-bg-tertiary, #f3f4f6);
}

.add-to-deck-deck-name {
  font-weight: 500;
  font-size: 14px;
  color: var(--color-text-primary, #111);
}

.add-to-deck-deck-count {
  font-size: 12px;
  color: var(--color-text-secondary, #6b7280);
  white-space: nowrap;
}

.add-to-deck-loading,
.add-to-deck-empty,
.add-to-deck-error {
  text-align: center;
  padding: 20px;
  font-size: 13px;
  color: var(--color-text-secondary, #6b7280);
}

.add-to-deck-error {
  color: var(--color-danger, #ef4444);
}

.add-to-deck-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px 20px;
  text-align: center;
}

.add-to-deck-success p {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  color: var(--color-text-primary, #111);
}

/* ===== Share Modal ===== */
.share-link-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.share-link-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--color-border-primary, #e5e7eb);
  border-radius: var(--radius-md, 8px);
  font-size: 13px;
  color: var(--color-text-primary, #111);
  background: var(--color-bg-secondary, #f9fafb);
  outline: none;
  min-width: 0;
}

.share-link-input:focus {
  border-color: var(--color-primary, #6366f1);
}

.share-copy-btn {
  padding: 10px 18px;
  border: 1px solid var(--color-border-primary, #e5e7eb);
  border-radius: var(--radius-md, 8px);
  background: var(--color-bg-primary, #fff);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.share-copy-btn:hover {
  background: var(--color-bg-tertiary, #f3f4f6);
}

.share-copy-btn.copied {
  background: var(--color-success, #22c55e);
  color: #fff;
  border-color: var(--color-success, #22c55e);
}

.share-socials {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.share-social-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: transform 0.15s, opacity 0.15s;
}

.share-social-btn:hover {
  transform: scale(1.1);
  opacity: 0.85;
}

.share-twitter { background: #000; color: #fff; }
.share-facebook { background: #1877f2; color: #fff; }
.share-linkedin { background: #0a66c2; color: #fff; }
.share-reddit { background: #ff4500; color: #fff; }
.share-email { background: var(--color-text-secondary, #6b7280); color: #fff; }

/* ===== Definition Citation Box [citedefinition:reference] ===== */
.definition-citation-box {
  margin: 20px 0;
  border: 1px solid var(--border-color);
  border-left: 6px solid var(--color-primary);
  border-radius: var(--radius-lg);
  background: var(--color-bg-secondary, rgb(0 0 0 / 3%));
  padding: 20px;
}

.definition-citation-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  gap: 12px;
}

.definition-citation-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}

.definition-citation-title-row .tags-section {
  margin: 0;
}

.definition-citation-title-row .tag-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.definition-citation-title-row a {
  text-decoration: none;
  color: inherit;
}

.definition-citation-title-row a:hover {
  text-decoration: underline;
}

.definition-header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.definition-citation-content {
  margin: 12px 0;
  font-size: var(--font-size-md);
  line-height: 1.7;
  color: var(--text-primary);
}

.definition-citation-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border-primary);
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
}

.definition-citation-actions .left-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.definition-citation-actions .right-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-left: auto;
}

/* Brain icon inside definition citation */
.definition-citation-brain-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.definition-citation-brain-icon {
  cursor: pointer;
  transition: color 0.2s ease, transform 0.15s ease;
}

.definition-citation-brain-icon:hover {
  transform: scale(1.1);
}

.definition-citation-brain-icon.known {
  color: #28a745;
}

.definition-citation-brain-icon.unknown {
  color: var(--color-text-secondary);
}

/* Generality dropdown inside definition citation */
.definition-citation-generality-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--white, #fff);
  border: 1px solid var(--border, #d0d7de);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  min-width: 220px;
  z-index: 200;
  overflow: hidden;
  padding: 8px 0;
}

.definition-citation-generality-dropdown .knowledge-dropdown-header {
  padding: 6px 12px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-tertiary);
  border-bottom: 1px solid var(--color-border-secondary);
  margin-bottom: 4px;
}

.definition-citation-generality-dropdown .knowledge-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s ease;
}

.definition-citation-generality-dropdown .knowledge-dropdown-item:hover {
  background: var(--color-bg-hover, #f6f8fa);
}

.definition-citation-generality-dropdown .knowledge-level-check {
  margin-left: auto;
  color: #28a745;
  font-weight: 600;
}

/* Knowledge button in definition citation */
.definition-citation-knowledge-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Placeholder / loading state */
.definition-citation-placeholder {
  padding: 24px 20px;
  text-align: center;
  background: var(--color-bg-secondary, #f9f9f9);
  border: 1px solid var(--border-color);
  border-left: 6px solid var(--color-primary);
  border-radius: var(--radius-lg);
  margin: 20px 0;
}

.loading-definition-citation {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.loading-definition-citation p {
  margin: 0;
  font-size: var(--font-size-sm, 13px);
  color: var(--text-secondary, #666);
}

/* Error state */
.definition-citation-error {
  padding: 16px 20px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-left: 6px solid #dc3545;
  border-radius: var(--radius-lg);
  margin: 20px 0;
  color: #dc2626;
  font-weight: 500;
}

/* Dark mode */
:root[data-theme="dark"] .definition-citation-box {
  border-left-color: #aaa;
  background: var(--color-bg-secondary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

:root[data-theme="dark"] .definition-citation-actions {
  border-top-color: #444;
}

:root[data-theme="dark"] .definition-citation-placeholder {
  background: var(--color-bg-secondary);
  border-left-color: #aaa;
}

:root[data-theme="dark"] .definition-citation-generality-dropdown {
  background: var(--color-bg-secondary, #2a2a2a);
  border-color: var(--border-color, #444);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

:root[data-theme="dark"] .definition-citation-generality-dropdown .knowledge-dropdown-header {
  border-bottom-color: #444;
  color: #999;
}

:root[data-theme="dark"] .definition-citation-generality-dropdown .knowledge-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

:root[data-theme="dark"] .definition-citation-error {
  background: rgba(185, 28, 28, 0.1);
  border-color: rgba(185, 28, 28, 0.3);
}

b, strong {
  font-weight: 600;
  color: var(--color-text-primary);
}

/* Live Search Dropdown */
/*.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background-color: var(--white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  margin-top: 5px;
  z-index: 1000;
  max-height: 350px;
  overflow-y: auto;
}
  */

.search-result-item {
  padding: 10px 15px;
  cursor: pointer;
  border-bottom: 1px solid var(--light-gray);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover,
.search-result-item.active {
  background-color: var(--light-gray);
}

.result-title {
  font-weight: 600;
  margin-bottom: 3px;
  color: var(--primary-color);
}

.result-snippet {
  font-size: 0.85rem;
  color: var(--dark-gray);
  line-height: 1.4;
  max-height: 2.8em; /* ~2 lines */
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.result-snippet code {
  background: rgba(0, 0, 0, 0.05);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.9em;
}

.result-snippet strong {
  font-weight: 600;
}

.result-snippet em {
  font-style: italic;
}

/* Dark mode adjustments for search dropdown */

/* Show sidebar button */
.show-sidebar-btn {
  display: flex;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--color-primary);
  color: var(--color-text-inverse);
  border: none;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  margin-right: 15px;
  transition: transform 0.3s ease, background-color 0.3s ease;
}

.show-sidebar-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
}

.show-sidebar-btn:hover {
  background-color: var(--text-color);
  transform: scale(1.05);
}

.sidebar-hidden .show-sidebar-btn {
  display: flex;
}

/* Notifications Styles */
.notifications-container {
  position: relative;
  display: flex;
  align-items: center;
}

.messages-nav-item {
  position: relative;
  display: flex;
  align-items: center;
}
.messages-nav-item .nav-icon-link {
  position: relative;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.messages-badge {
  /* Ensure consistent positioning with notifications badge */
  position: absolute;
  top: 0;
  right: 0;
  background-color: var(--primary-color, #333);
  color: var(--color-text-inverse);
  font-size: 10px;
  font-weight: bold;
  min-width: 16px;
  height: 16px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  transform: translate(10%, -20%);
}

.notifications-button {
  background: none;
  border: none;
  color: var(--text-color);
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius-lg);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.notifications-button:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.notification-badge {
  position: absolute;
  top: 0;
  right: 0;
  background-color: var(--color-accent, #5A7A6A);
  color: var(--color-text-inverse);
  font-size: 10px;
  font-weight: bold;
  min-width: 16px;
  height: 16px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  transform: translate(10%, -20%);
}

.notifications-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  width: 300px;
  background-color: var(--color-bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.notifications-dropdown.active {
  display: block;
}

.notifications-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--light-gray);
}

.notifications-header h3 {
  margin: 0;
  font-size: var(--font-size-lg);
  font-weight: 600;
}

.mark-all-read {
  background: none;
  border: none;
  color: var(--primary-color);
  font-size: var(--font-size-sm);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.mark-all-read:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.notifications-list {
  max-height: 350px;
  overflow-y: auto;
}

.notification-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--light-gray);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.notification-item:hover {
  background-color: var(--light-gray);
}

.notification-item.unread {
  background-color: rgba(0, 122, 255, 0.05);
}

.notification-content {
  margin-bottom: 4px;
  font-size: var(--font-size-md);
}

.notification-time {
  font-size: var(--font-size-sm);
  color: var(--light-text);
}

.notification-empty {
  padding: 10px;
  color: var(--text-light);
  text-align: center;
  font-style: italic;
}

.notifications-footer {
  padding: 8px;
  border-top: 1px solid var(--border-color);
  text-align: center;
}

.view-all-link {
  color: var(--primary-color);
  font-size: 0.9rem;
  text-decoration: none;
}

.view-all-link:hover {
  text-decoration: underline;
}

/* Dark mode styles for notifications */
:root[data-theme="dark"] .notifications-dropdown {
  background-color: var(--bg-dark, #1a1a1a);
  border-color: #374151;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

:root[data-theme="dark"] .notifications-header {
  border-bottom-color: #374151;
}

:root[data-theme="dark"] .notifications-header h3 {
  color: #ffffff;
}

:root[data-theme="dark"] .notification-item {
  border-bottom-color: #374151;
  color: #e5e7eb;
}

:root[data-theme="dark"] .notification-item:hover {
  background-color: #2d2d2d;
}

:root[data-theme="dark"] .notification-item.unread {
  background-color: rgba(59, 130, 246, 0.15);
}

:root[data-theme="dark"] .notification-content {
  color: #e5e7eb;
}

:root[data-theme="dark"] .notification-time {
  color: #9ca3af;
}

:root[data-theme="dark"] .notification-empty {
  color: #9ca3af;
}

:root[data-theme="dark"] .notifications-footer {
  border-top-color: #374151;
}

:root[data-theme="dark"] .mark-all-read:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Notifications in nav menu */
.nav-menu .notifications-container {
  position: relative;
  margin: 0 10px;
  display: flex;
  align-items: center;
}

.nav-menu .notifications-button {
  background: none;
  border: none;
  color: var(--text-color);
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius-lg);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.nav-menu .notifications-button:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.nav-menu .notifications-dropdown {
  top: 40px;
  z-index: 1001;
}

/* User mention styling */
.user-mention {
  background-color: rgba(0, 122, 255, 0.1);
  color: #0070cc;
  border-radius: 3px;
  padding: 2px 4px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 0.2s ease;
}

.user-mention:hover {
  background-color: rgba(0, 122, 255, 0.2);
  cursor: pointer;
}

/* Dark mode for user mentions */


.notifications-page-list .notification-item {
  padding: 15px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  transition: background-color 0.2s ease;
  cursor: pointer;
}

.notifications-page-list .notification-item:hover {
  background-color: var(--light-gray);
}

.notifications-page-list .notification-item.unread {
  background-color: rgba(0, 122, 255, 0.05);
  border-left: 4px solid var(--primary-color);
}

.notifications-page-list .notification-content {
  margin-bottom: 8px;
  font-size: var(--font-size-lg);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.notification-link:hover {
  background-color: #0051a5;
  text-decoration: none;
  color: var(--color-text-inverse);
}

.notification-info {
  display: flex;
  justify-content: space-between;
  color: var(--light-text);
  font-size: var(--font-size-md);
}

.notification-actions {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.notification-empty-state {
  padding: 40px;
  text-align: center;
  color: var(--light-text);
  background-color: var(--light-gray);
  border-radius: var(--radius-lg);
  margin-top: 20px;
}

/* Dark mode for notifications page */


/* Profile Icon Link */
.profile-icon-link {
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 50%;
  transition: background-color 0.2s ease;
}

.profile-icon-link:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.profile-icon-link svg {
  color: var(--text-color);
}

/* Notification Item Link - New wrapper link for notifications */
.notification-item-link {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.notification-item-link:hover {
  text-decoration: none;
  color: inherit;
}

/* Remove the old notification-link styles since they're no longer needed */
.notification-link {
  display: none;
}

/* Notifications Page Styles */
.notifications-page-list {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 800px;
} 

/* User page sections */
.user-page-section {
  background-color: var(--white);
  padding: 20px;
  margin-bottom: 20px;
  border-radius: var(--radius-lg);
}

.user-page-section h2 {
  font-size: 1.8rem;
  margin-top: 0;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--light-gray);
}

.user-description {
  line-height: 1.6;
  color: var(--text-color);
  margin-bottom: 20px;
}

.publications-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.publication-item {
  padding: 15px;
  margin-bottom: 15px;
  border-left: 4px solid var(--primary-color);
  background-color: rgba(0, 0, 0, 0.02);
}

.publication-title {
  font-weight: 600;
  font-size: 1.2rem;
  margin-bottom: 5px;
  color: var(--text-color);
}

.publication-authors {
  font-style: italic;
  margin-bottom: 5px;
  color: var(--medium-gray);
}

.publication-venue {
  font-weight: 500;
  margin-bottom: 5px;
  color: var(--text-color);
}

.publication-categories {
  color: var(--medium-gray);
  font-style: italic;
  font-size: 0.9em;
}

.publication-summary {
  margin: 10px 0;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text-color);
}

.publication-links {
  margin-top: 10px;
  display: flex;
  gap: 15px;
}

.publication-link {
  display: inline-block;
  color: var(--primary-color);
  text-decoration: none;
  font-size: 0.9rem;
}

.publication-link:hover {
  text-decoration: underline;
}

.recent-activity {
  margin-top: 20px;
}

.activity-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--light-gray);
  display: flex;
  justify-content: space-between;
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-content {
  display: flex;
  flex-direction: column;
}

.activity-title {
  font-weight: 500;
  margin-bottom: 4px;
}

.activity-date {
  font-size: 0.9rem;
  color: var(--medium-gray);
}

/* Dark mode support for user page sections */


.research-group-members,

.research-group-members .icon,
.research-group-areas .icon {
  margin-right: 0.5rem;
  flex-shrink: 0;
}

.filter-section {
  margin: 1.5rem 0;
}

/* Create Research Group Form Styles */
.areas-container {
  margin-top: 0.5rem;
}

.areas-input-wrapper {
  position: relative;
}

.areas-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background-color: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #ddd);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 10;
  max-height: 200px;
  overflow-y: auto;
  display: none;
}

.area-suggestion {
  padding: 0.5rem 1rem;
  cursor: pointer;
}

.area-suggestion:hover {
  background-color: var(--hover-bg, #f5f5f5);
}

.area-suggestion.custom {
  font-style: italic;
  color: var(--primary-color, #666);
}

.selected-areas {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.area-tag {
  display: flex;
  align-items: center;
  background-color: var(--primary-light, #666);
  color: var(--color-text-inverse);
  border-radius: 16px;
  padding: 0.25rem 0.5rem 0.25rem 0.75rem;
  font-size: 0.875rem;
}

.area-remove {
  background: none;
  border: none;
  color: var(--color-text-inverse);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.25rem;
  padding: 2px;
}

.area-remove:hover {
  color: var(--danger-light, #fc8181);
}

/* Responsive styles */

/* Dark mode support */

/* Research Group Detail Styles */
.page-header-nav {
  margin-bottom: 1rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  color: var(--primary-color, #666);
  text-decoration: none;
  font-weight: 500;
}

.back-link svg {
  margin-right: 0.5rem;
}

.back-link:hover {
  color: var(--primary-dark, #333);
  text-decoration: underline;
}

.research-group-section {
  margin-top: 2rem;
}

.research-group-section h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border-color, #ddd);
}

.research-areas-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.members-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-color, #ddd);
  padding-bottom: 0.5rem;
}

.members-tab {
  background: none;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  color: var(--text-color, #333);
}

.members-tab:hover {
  background-color: var(--hover-bg, #f5f5f5);
}

.members-tab.active {
  background-color: var(--primary-color, #666);
  color: var(--color-text-inverse);
}

.members-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}

.member-card {
  display: flex;
  padding: 1rem;
  background-color: var(--card-bg, #fff);
  border-radius: var(--radius-md);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.member-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.member-info {
  flex-grow: 1;
}

.member-name {
  color: var(--primary-color, #666);
  text-decoration: none;
}

.member-name:hover {
  text-decoration: underline;
}

.member-info h3 {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
}

.member-role {
  font-weight: 500;
  color: var(--text-color, #333);
  margin-bottom: 0.25rem;
}

.member-duration {
  font-size: 0.875rem;
  color: var(--text-muted, #666);
}

.research-group-actions {
  margin-top: 2rem;
  display: flex;
  gap: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color, #ddd);
}

.empty-state.small {
  padding: 1.5rem;
  text-align: center;
}

/* Dark mode support */

/* Research Groups Styles */
.title-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.page-title.text-3xl {
  font-size: 1.875rem;
  font-weight: 700;
  margin: 0;
}

.create-group-btn {
  display: flex;
  align-items: center;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  transition: background-color 0.2s, transform 0.1s;
  margin-left: 0.5rem;
}

.create-group-btn:hover {
  transform: translateY(-1px);
}

.create-group-btn .icon {
  margin-right: 0.5rem;
}

.page-description {
  color: var(--text-muted, #666);
  margin-bottom: 2rem;
  max-width: 800px;
}

.text-muted {
  color: var(--text-muted, #666);
}

.search-and-filter-section {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  align-items: center;
}

.search-container {
  flex: 1;
  position: relative;
  min-width: 250px;
}

.search-container .search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted, #666);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.75rem 2.5rem 0.75rem 2.5rem;
  border: 1px solid var(--border-color, #ddd);
  border-radius: 0.375rem;
  font-size: 1rem;
  background-color: var(--input-bg, #fff);
  color: var(--text-color, #333);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary-color, #666);
  box-shadow: 0 0 0 2px rgba(74, 85, 104, 0.2);
}

.search-clear {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted, #666);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
  border-radius: 9999px;
}

.search-clear:hover {
  color: var(--danger-color, #e53e3e);
  background-color: rgba(0, 0, 0, 0.05);
}

.filter-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.filter-btn {
  display: flex;
  align-items: center;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color, #ddd);
  border-radius: 0.375rem;
  background: var(--btn-outline-bg, #fff);
  color: var(--text-color, #333);
  cursor: pointer;
  transition: background-color 0.2s;
  height: 2.25rem;
}

.filter-btn:hover {
  background-color: var(--hover-bg, #f5f5f5);
}

.filter-btn .icon {
  margin-right: 0.5rem;
}

.sort-select {
  position: relative;
}

.select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.sort-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted, #666);
  pointer-events: none;
}

.sort-dropdown {
  padding: 0.5rem 1rem 0.5rem 2.5rem;
  border: 1px solid var(--border-color, #ddd);
  border-radius: 0.375rem;
  background-color: var(--input-bg, #fff);
  color: var(--text-color, #333);
  cursor: pointer;
  height: 2.25rem;
  font-size: 0.875rem;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.sort-dropdown:focus {
  outline: none;
  border-color: var(--primary-color, #666);
  box-shadow: 0 0 0 2px rgba(74, 85, 104, 0.2);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.category-tabs {
  margin-bottom: 2rem;
}

.tabs-list {
  display: flex;
  border-bottom: 1px solid var(--border-color, #ddd);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.tabs-list::-webkit-scrollbar {
  display: none;
}

.tab-trigger {
  padding: 0.75rem 1rem;
  margin-right: 0.5rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted, #666);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-trigger:hover {
  color: var(--primary-color, #666);
}

.tab-trigger.active {
  color: var(--primary-color, #666);
  border-bottom-color: var(--primary-color, #666);
}

.research-groups-container {
  margin-top: 1.5rem;
}

.research-groups-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-top: 1rem;
}

.research-group-card {
  display: flex;
  flex-direction: column;
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  background-color: var(--card-bg, #fff);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  height: 100%;
}

.research-group-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.research-group-card-header {
  padding: 1.25rem;
  position: relative;
  border-bottom: 1px solid var(--border-color, #ddd);
}
.group-badge {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.group-badge.new {
  background-color: #84cc16;
  color: var(--color-text-inverse);
}

.group-badge.featured {
  background-color: #8b5cf6;
  color: var(--color-text-inverse);
}

.group-badge.popular {
  background-color: #f97316;
  color: var(--color-text-inverse);
}

.research-group-name {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.4;
}

.research-group-name a {
  color: var(--heading-color, #1a1a1a);
  text-decoration: none;
}

.research-group-name a:hover {
  text-decoration: underline;
}

.research-group-members {
  display: flex;
  align-items: center;
  color: var(--text-muted, #666);
  font-size: 0.875rem;
}

.research-group-members .icon {
  margin-right: 0.5rem;
  flex-shrink: 0;
}

.research-group-card-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  gap: 1rem;
}

.group-description {
  margin: 0;
  color: var(--text-color, #333);
  line-height: 1.5;
}

.group-discussions {
  display: flex;
  align-items: center;
  color: var(--text-muted, #666);
  font-size: 0.875rem;
}

.group-discussions .icon {
  margin-right: 0.5rem;
  flex-shrink: 0;
}

.group-avatars {
  margin-top: 0.5rem;
}

.avatar-list {
  display: flex;
  align-items: center;
}

.avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  background-color: var(--primary-light, #999);
  color: var(--text-color-inverse, #fff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  margin-right: -0.5rem;
  border: 2px solid var(--card-bg, #fff);
}

.avatar-more {
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  background-color: var(--primary-color, #666);
  color: var(--color-text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 0.25rem;
  border: 2px solid var(--card-bg, #fff);
}

.research-group-areas {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: auto;
}

.area-badge {
  background-color: var(--badge-bg, #ddd);
  color: var(--text-color, #333);
  border-radius: 9999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
}

.area-badge.more {
  background-color: transparent;
  border: 1px dashed var(--border-color, #ddd);
  color: var(--text-muted, #666);
}

.join-group-btn,
.view-group-btn {
  margin-top: 0.5rem;
  padding: 0.5rem 1rem;
  text-align: center;
  background-color: var(--primary-color, #666);
  color: var(--color-text-inverse);
  text-decoration: none;
  border-radius: 0.375rem;
  transition: background-color 0.2s;
  font-weight: 500;
  display: inline-block;
  margin-top: auto;
}

.join-group-btn:hover,
.view-group-btn:hover {
  background-color: var(--primary-dark, #333);
  text-decoration: none;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  background-color: var(--card-bg, #fff);
  border-radius: 0.5rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  text-align: center;
}

.empty-state h3 {
  margin: 0 0 0.5rem;
  color: var(--heading-color, #1a1a1a);
  font-weight: 600;
}

.empty-state p {
  margin: 0;
  color: var(--text-muted, #666);
  max-width: 500px;
}

.site-footer {
  margin-top: 4rem;
  padding: 1.5rem 0;
  background-color: var(--footer-bg, #f5f5f5);
  border-top: 1px solid var(--border-color, #ddd);
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-brand {
  font-weight: 600;
  font-size: 1.125rem;
  color: var(--primary-color, #666);
}

.footer-copyright {
  color: var(--text-muted, #666);
  font-size: 0.875rem;
}

/* Responsive styles */
@media (max-width: 1024px) {
  .research-groups-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Dark mode support */

/* Add these styles after the existing join-group-btn styles */
.join-group-btn.already-joined {
  background-color: var(--success-color, #38a169);
  cursor: default;
  opacity: 0.9;
}

.join-group-btn.already-joined:hover {
  background-color: var(--success-color, #38a169);
}

/* ##### Messaging System Styles ##### */

.messages-container {
  padding: 2rem;
  max-width: 900px;
  margin: 0;
}

.conversation-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.conversation-item {
  border: 1px solid var(--border-color, #ddd);
  border-radius: var(--radius-lg);
  margin-bottom: 1rem;
  transition: background-color 0.2s ease;
}

.conversation-item.unread {
  border-left: 4px solid var(--primary-color);
  background-color: rgba(0, 122, 255, 0.05);
}

.conversation-link {
  display: flex;
  padding: 1rem;
  text-decoration: none;
  color: inherit;
  justify-content: space-between;
  align-items: center;
}

.conversation-item:hover {
  background-color: var(--light-gray, #f5f5f5);
}

.conversation-info {
  display: flex;
  align-items: center;
  flex-grow: 1;
  margin-right: 1rem;
}

.conversation-username {
  font-weight: 600;
  margin-right: 0.5rem;
}

.unread-badge {
  background-color: var(--error-color, #F44336);
  color: var(--color-text-inverse);
  font-size: 0.75rem;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 10px;
}

.conversation-preview {
  flex-basis: 60%;
  color: var(--light-text, #666);
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.last-message-indicator {
  font-weight: 500;
}

.last-message-text.italic {
  font-style: italic;
}

.conversation-timestamp {
  font-size: 0.8rem;
  color: var(--light-text, #666);
  white-space: nowrap;
  margin-left: 1rem;
}

.conversation-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-height) - 2rem); /* Adjust based on footer height if necessary */
  max-width: 800px;
  margin: 1rem auto;
  border: 1px solid var(--border-color, #ddd);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background-color: var(--white);
}

.conversation-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color, #ddd);
  display: flex;
  align-items: center;
  background-color: var(--light-gray, #f5f5f5);
}

.conversation-header h2 {
  margin: 0;
  font-size: 1.2rem;
  margin-left: 1rem;
}

.conversation-header h2 a {
  color: var(--primary-color);
}

.message-list {
  flex-grow: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.message-item {
  display: flex;
  max-width: 75%;
}

.message-item.sent {
  align-self: flex-end;
}

.message-item.received {
  align-self: flex-start;
}

.message-bubble {
  padding: 0.75rem 1rem;
  border-radius: 18px;
  word-wrap: break-word;
}

.message-item.sent .message-bubble {
  background-color: var(--primary-color, #007bff);
  color: var(--color-text-inverse);
  border-bottom-right-radius: 4px;
}

.message-item.received .message-bubble {
  background-color: var(--light-gray, #eee);
  color: var(--text-color, #1a1a1a);
  border-bottom-left-radius: 4px;
}

.message-content {
  line-height: 1.4;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-timestamp {
  font-size: 0.7rem;
  margin-top: 0.25rem;
  text-align: right;
  opacity: 0.7;
}

.message-item.sent .message-timestamp {
  color: rgba(255, 255, 255, 0.7);
}

.message-item.received .message-timestamp {
  color: var(--light-text, #666);
}

.message-form-container {
  padding: 1rem;
  border-top: 1px solid var(--border-color, #ddd);
  background-color: var(--light-gray, #f5f5f5);
}

.message-form {
  display: flex;
  gap: 0.5rem;
}

.message-input {
  flex-grow: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color, #ddd);
  border-radius: 18px;
  resize: none;
  font-size: 1rem;
  font-family: inherit;
  min-height: 40px;
  max-height: 150px;
}

.message-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(0, 112, 243, 0.1);
}

.send-button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
}

/* Dark mode messaging */

header ul {
  margin-bottom: 0;
  list-style-type: none;
}

/* Global rule to prevent any button-like elements from showing underlines */
a[class*="btn"]:hover,
a.button:hover,
.button:hover,
button a:hover,
a button:hover,
.nav-links a:hover,
.action-link:hover,
.tab-trigger:hover,
header a:hover {
  text-decoration: none !important;
}

/* Style for centering profile action buttons */
.profile-buttons-container {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
}

.profile-action-btn {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  text-align: center !important;
  min-width: 100px;
}

/* Target specific profile action buttons */
.profile-page .btn-secondary,
.profile-page .btn-primary,
.profile-page .btn-outline,
form[action*="follow"] .btn,
form[action*="unfollow"] .btn,
a[href*="/messages/"] {
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  margin: 0 auto;
}

.btn-outline {
  background-color: transparent;
  color: var(--color-text-primary, #1D2433);
  border: 1px solid var(--color-border-primary, #d1d5db);
  padding: 8px 16px;
  border-radius: var(--radius-md, 6px);
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-outline:hover {
  background-color: var(--color-bg-secondary, #f5f5f7);
  text-decoration: none;
}

/* Page Tags Styling */
.page-tags {
  margin: 10px 0 15px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.tags-label {
  font-weight: 500;
  color: var(--light-text);
  margin-right: 8px;
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-badge {
  display: inline-block;
  padding: 4px 10px;
  background-color: #f0f5ff;
  color: #3b5bdb;
  border: 1px solid #d0dbff;
  border-radius: 20px;
  font-size: 0.85rem;
  text-decoration: none;
  transition: all 0.2s ease;
}

.tag-badge:hover {
  background-color: #dbe4ff;
  color: #364fc7;
  text-decoration: none;
}

/* Tag Search UI Styling */
.tag-search-container {
  position: relative;
  margin-bottom: 10px;
}

.tag-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 10;
  background-color: var(--white);
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  max-height: 200px;
  overflow-y: auto;
  display: none;
}

.tag-suggestion {
  padding: 8px 12px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.tag-suggestion:hover,
.tag-suggestion.active {
  background-color: #f0f5ff;
}

.selected-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.selected-tag {
  display: inline-flex;
  align-items: center;
  background-color: #f0f5ff;
  color: #3b5bdb;
  border: 1px solid #d0dbff;
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 0.85rem;
  margin-right: 4px;
  margin-bottom: 4px;
}

.remove-tag {
  margin-left: 6px;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.remove-tag:hover {
  background-color: rgba(59, 91, 219, 0.1);
}

/* Generality Switcher Styles */
.generality-switcher {
  position: fixed;
  right: 1.5rem;
  top: 88px;
  z-index: 100;
  background: var(--white);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.25rem;
  width: auto;
}

.generality-tab {
  cursor: pointer;
  color: var(--light-text);
  transition: all 0.2s ease;
  font-size: 0.7rem;
  padding: 0.25rem 0.5rem;
  border-radius: 3px;
  user-select: none;
  background: transparent;
  display: flex;
  align-items: center;
  text-decoration: none;
  white-space: nowrap;
}

.generality-tab:hover {
  background: var(--hover-bg);
  color: var(--text);
  text-decoration: none;
}

.generality-tab.active {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  text-decoration: none;
}

/* Section Slider Styles */
.section-slider {
  position: fixed;
  right: 1.5rem;
  top: 50px;
  z-index: 100;
  background: var(--white);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  width: auto;
}

.slider-labels {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.slider-label {
  cursor: pointer;
  color: var(--light-text);
  transition: all 0.2s ease;
  font-size: 0.7rem;
  padding: 0.25rem;
  border-radius: 3px;
  user-select: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-width: 24px;
}

.section-icon {
  width: 14px;
  height: 14px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.label-text {
  display: none;
  opacity: 0;
  transform: translateX(-5px);
  transition: all 0.3s ease;
}

.slider-label:hover {
  background: var(--hover-bg);
  color: var(--text);
}

.slider-label:hover .section-icon {
  transform: scale(1.1);
}

.slider-label.active {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  padding: 0.25rem 0.5rem;
}

.slider-label.active .section-icon {
  transform: scale(1.1);
}

.slider-label.active .label-text {
  display: inline;
  opacity: 1;
  transform: translateX(0);
}

/* view-tags-btn defined in page meta actions section below */

.page-tags-display {
  position: relative;
  display: none;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  background: var(--white);
  padding: 0.25rem;
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  z-index: 1;
}

.no-tags {
  color: var(--light-text);
  font-size: 0.75rem;
  font-style: italic;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translate(0, -2px);
  }
  to {
    opacity: 1;
    transform: translate(0, 0);
  }
}

/* MathJax Display Math Centering */
mjx-container[display="true"] {
  display: block !important;
  text-align: center;
  margin: 1em 0;
  overflow-x: auto;
  overflow-y: hidden;
}

mjx-container[display="true"] svg {
  max-width: 100%;
}

/* Ensure display math in definition/theorem blocks is centered */
.definition-box mjx-container[display="true"],
.theorem-content mjx-container[display="true"],
.remark-content mjx-container[display="true"],
.example-content mjx-container[display="true"],
.solution-body mjx-container[display="true"],
.proof-body mjx-container[display="true"],
.problem-content mjx-container[display="true"],
.motivation-content mjx-container[display="true"],
.claim-content mjx-container[display="true"] {
  display: block !important;
  text-align: center;
  margin: 1em 0;
}

/* Clickable math areas */
.MathJax {
  transition: filter 0.2s ease-in-out;
  border-radius: var(--radius-sm);
  padding: 0 4px;
}

.MathJax:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .MathJax:hover,
:root[data-theme="dark"] .MathJax:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Tooltip for clickable math */
.MathJax[data-original]::after {
  content: 'Click to search';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background-color: rgba(0, 0, 0, 0.8);
  color: var(--color-text-inverse);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
  pointer-events: none;
  white-space: nowrap;
}

.MathJax[data-original]:hover::after {
  opacity: 1;
}

[data-theme="dark"] .MathJax[data-original]::after,
:root[data-theme="dark"] .MathJax[data-original]::after {
  background-color: rgba(255, 255, 255, 0.9);
  color: black;
}

/* Progressive Math Loading States */
body.math-loading {
  /* Page is usable immediately, just math is rendering */
}

/* Style unrendered math nicely while loading */
body.math-loading mjx-container,
body:not(.math-ready) mjx-container {
  opacity: 1;
}

/* Smooth fade-in for rendered math */
mjx-container {
  transition: opacity 0.15s ease-in;
}

/* Raw math source styling before MathJax processes it */
body:not(.math-ready) .wiki-content > p,
body:not(.math-ready) .theorem-content,
body:not(.math-ready) .proof-content {
  /* Ensure text is readable even with raw LaTeX */
  word-break: break-word;
}

/* Loading indicator for math-heavy pages */
body.math-loading::after {
  content: '';
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 24px;
  height: 24px;
  border: 2px solid var(--color-border-secondary);
  border-top-color: #3498db;
  border-radius: 50%;
  animation: mathSpinner 0.8s linear infinite;
  z-index: 9999;
  opacity: 0.7;
}

@keyframes mathSpinner {
  to {
    transform: rotate(360deg);
  }
}

/* Hide spinner when math is ready */
body.math-ready::after {
  display: none;
}

/* Section lazy-load bottom notification bar */
.section-render-notice {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 16px;
  background: #f0f5ff;
  border-top: 1px solid #d0dff5;
  color: #3b6cb5;
  font-size: 13px;
  font-weight: 500;
  transform: translateY(100%);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  pointer-events: none;
}

.section-render-notice.visible {
  transform: translateY(0);
  opacity: 1;
}

.section-render-notice .notice-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #c4d5ef;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: mathSpinner 0.7s linear infinite;
  flex-shrink: 0;
}

.close-tags-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0.15rem;
  cursor: pointer;
  color: var(--light-text);
  border-radius: 3px;
  transition: all 0.2s ease;
}

.close-tags-btn:hover {
  background: var(--hover-bg);
  color: var(--text);
}

.page-tag {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  background: var(--hover-bg);
  color: var(--text);
  font-size: 0.75rem;
  border-radius: 3px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.page-tag:hover {
  background: var(--dark-hover-bg);
  color: var(--text);
  text-decoration: none;
}

/* Section content transitions */
.section-content {
  display: none;
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
}

.section-content.active {
  display: block;
  opacity: 1;
}

/* Empty state section styles */
.empty-state-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 800px;
  margin: 0 auto;
}

.empty-state-icon {
  margin-bottom: 0 !important;
  color: var(--text-muted);
}

.empty-state-section h2 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
}

.empty-state-section p {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  max-width: 600px;
}

.submit-box {
  background: var(--bg-alt);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 2rem;
  width: 100%;
  max-width: 600px;
  border: 1px dashed;
  border-color: rgb(229, 231, 235);
}

.submit-box h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.submit-box p {
  font-size: 1rem;
  margin-bottom: 1.25rem;
}

.github-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--primary-color);
  color: var(--color-text-inverse);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: background-color 0.2s ease;
}

.github-link:hover {
  background: var(--primary-hover);
  color: var(--color-text-inverse);
  text-decoration: none;
}

.github-link svg {
  color: var(--color-text-inverse);
}

.guidelines-box {
  background: var(--bg-alt);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  width: 100%;
  max-width: 600px;
}

.guidelines-box h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
}

.guidelines-box ul {
  list-style-type: none;
  padding: 0;
  margin: 0;
  text-align: left;
}

.guidelines-box li {
  display: flex;
  align-items: center;
  padding: 0.5rem 0;
  color: var(--text-muted);
  font-size: 1rem;
}

.guidelines-box li::before {
  content: "•";
  color: var(--primary-color);
  font-weight: bold;
  margin-right: 0.75rem;
}

/* Dark mode styles */

.page-meta-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.view-tags-btn {
  display: inline-flex;
  align-items: center;
  background: var(--white, #fff);
  color: var(--text, #1f2328);
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
  margin-left: 0.35rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: var(--radius-md);
  white-space: nowrap;
  text-decoration: none;
  gap: 0.3rem;
  font-weight: 500;
  border-style: none;
}

.view-tags-btn:hover {
  color: var(--text);
  background: var(--hover-bg, #f6f8fa);
  border-color: var(--text, #1f2328);
  text-decoration: none;
}

.view-tags-btn .counter {
  font-weight: 600;
  color: var(--text-color);
  background: var(--hover-bg, #f0f0f0);
  padding: 0.05rem 0.35rem;
  border-radius: 10px;
  font-size: 0.75rem;
}

.follow-form {
  display: inline-block;
  position: relative;
}

.follow-btn {
  background: none;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.follow-btn:hover {
  background-color: var(--hover-bg);
}

.follow-btn svg {
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
}

.follow-btn:hover svg {
  transform: scale(1.1);
}

.follow-btn.following {
  color: var(--text-color);
}

.follow-tooltip {
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: var(--color-text-inverse);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  pointer-events: none;
  z-index: 100;
}

.follow-btn:hover .follow-tooltip {
  opacity: 1;
  visibility: visible;
  bottom: -25px;
}

.verification-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  transition: background-color 0.2s ease;
}

.verification-status:hover {
  background-color: var(--hover-bg);
}

.verification-status.verified {
  color: var(--success);
}

.verification-status.unverified {
  color: var(--warning);
}

/* Full-width layout (no sidebar) */
.wiki-layout.full-width {
  display: block;
  padding: 0;
}

.content-wrapper.full-width {
  margin-left: 0;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

/* Pull request pages full width */
body[data-page*="pull-requests"] main,
body[data-page*="new-pull-request"] main {
  width: 100%;
  max-width: 100%;
}

body[data-page*="pull-requests"] .content-wrapper,
body[data-page*="new-pull-request"] .content-wrapper {
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  padding: 0;
}

body[data-page*="pull-requests"] .wiki-layout,
body[data-page*="new-pull-request"] .wiki-layout {
  display: block;
  padding: 0;
}

/* Pull request detail pages specific styling */
.pull-request-detail-container {
  width: 100%;
  max-width: 100%;
  padding: 0 2rem;
}

/* Remove footer from pull request pages */
body[data-page*="pull-requests"] footer,
body[data-page*="new-pull-request"] footer {
  display: none;
}


.testbox:hover {
  background: hsl(0, 0%, 100%);
  padding: 16px 24px;
  position: relative;
  border-radius: var(--radius-lg);
  box-shadow: 0 0 0 1px rgba(0,0,0,.01);

  &::after {
    position: absolute;
    content: "";
    top: 0px;
    left: 0;
    right: 0;
    z-index: -1;
    height: 100%;
    width: 100%;
    transform: scale(1) translateZ(0);
    filter: blur(15px);
    background: linear-gradient(
      to left,
      #ff5770,
      #e4428d,
      #c42da8,
      #9e16c3,
      #6501de,
      #9e16c3,
      #c42da8,
      #e4428d,
      #ff5770
    );
    background-size: 200% 200%;
    animation: animateGlow 1.25s linear infinite;
  }
}

@keyframes animateGlow {
  0% {
    background-position: 0% 50%;
  }
  100% {
    background-position: 200% 50%;
  }
}

/* Add at the end of the file - Chat Menu Layout Adjustments */

/* Override for specific layouts that shouldn't have the chat menu margin */
body.no-chat-menu {
  margin-left: 0;
}

/* Mobile responsiveness - hide chat menu on small screens */

@media (max-width: 480px) {
  body {
    margin-left: 0; /* Ensure no chat menu margin on small mobile */
  }
}

/* Solution Environment Styles (Collapsible like proofs) */
.solution-environment {
  background: var(--light-gray);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin: 20px 0;
}

.solution-header {
  background: var(--color-bg-tertiary);
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  border-radius: 8px 8px 0 0;
}

.solution-header:hover {
  background: var(--color-bg-active);
}

.solution-title {
  font-weight: bold;
  color: var(--color-text-secondary);
  font-size: var(--font-size-lg);
}

.solution-content {
  overflow: hidden;
  transition: max-height 0.3s ease-in-out, opacity 0.2s ease;
}

.solution-content.collapsed {
  max-height: 0;
  opacity: 0;
}

.solution-content.expanded {
  max-height: none;
  opacity: 1;
}

.solution-body {
  padding: 16px;
  color: var(--color-text-secondary);
  line-height: 1.6;
}

/* Problem Environment Styles (Non-collapsible like theorems) */
.problem-box {
  padding: 20px;
  margin: 10px 0;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.problem-title {
  font-size: 15px;
  font-weight: bold;
  color: var(--color-warning);
}

.problem-content {
  line-height: 1.6;
}

/* Problem Difficulty Rating Styles */
.problem-title {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.problem-difficulty-wrapper {
  position: relative;
  display: inline-flex;
}

.problem-difficulty {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg-secondary, #f8f9fa);
  border-radius: 20px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.problem-difficulty:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.difficulty-stars {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.difficulty-star {
  flex-shrink: 0;
}

.difficulty-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Difficulty Tooltip */
.difficulty-tooltip {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border-primary);
  border-radius: 10px;
  padding: 14px 18px;
  min-width: 260px;
  max-width: 320px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  z-index: 1000;
  font-size: 13px;
  font-weight: 400;
  color: var(--color-text-primary);
  line-height: 1.5;
}

/* Tooltip arrow */
.difficulty-tooltip::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 10px;
  height: 10px;
  background: var(--color-bg-primary);
  border-left: 1px solid var(--color-border-primary);
  border-top: 1px solid var(--color-border-primary);
}

/* Invisible bridge to keep tooltip open when moving mouse */
.difficulty-tooltip::after {
  content: '';
  position: absolute;
  top: -12px;
  left: 0;
  width: 100%;
  height: 12px;
}

.problem-difficulty-wrapper:hover .difficulty-tooltip {
  display: block;
}

.difficulty-tooltip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-weight: 600;
}

.difficulty-tooltip-level {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.8;
}

.difficulty-tooltip-label {
  font-size: 14px;
}

.difficulty-tooltip-description {
  margin: 0;
  font-size: 13px;
  color: var(--color-text-secondary);
  line-height: 1.5;
}

/* Dark mode support for problem difficulty */
:root[data-theme="dark"] .problem-difficulty {
  background: rgba(255, 255, 255, 0.08);
}

:root[data-theme="dark"] .problem-difficulty:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

:root[data-theme="dark"] .difficulty-tooltip {
  background: #2a2a2a;
  border-color: #444;
  color: #e0e0e0;
}

:root[data-theme="dark"] .difficulty-tooltip::before {
  background: #2a2a2a;
  border-color: #444;
}

:root[data-theme="dark"] .difficulty-tooltip-description {
  color: #bbb;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .solution-environment,
  .problem-box {
    margin: 15px 0;
    border-radius: var(--radius-md);
  }
  
  .solution-header,
  .solution-body {
    padding: 12px;
  }
  
  .problem-box {
    padding: 15px;
  }
  
  .solution-title,
  .problem-title {
    font-size: var(--font-size-md);
  }
}

/* Ensure math rendering works properly in solution and problem environments */
.solution-body .MathJax,
.problem-content .MathJax {
  display: inline-block;
}

.solution-body .MathJax_Display,
.problem-content .MathJax_Display {
  margin: 1em 0;
}

.claim-box {
  margin: 1.5rem 0;
  padding: 0;
  border: 1px solid var(--color-border-primary);
  border-radius: var(--radius-lg);
  background-color: transparent;
  overflow: hidden;
}

.claim-box .claim-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-size-md);
  font-weight: 600;
  line-height: 18px;
  color: var(--color-text-primary);
  padding: 12px 16px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--color-border-primary);
  background-color: var(--color-bg-secondary);
}

.claim-box .claim-title {
  font-size: var(--font-size-md);
}

.claim-box .claim-content {
  color: var(--color-text-primary);
  padding: 16px 20px;
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.65;
}

.claim-box .claim-body {
  margin: 0;
}

/* ===================
   COMPREHENSIVE DARK MODE SUPPORT
   Site-wide dark mode fixes for elements with hardcoded colors
   =================== */

/* Main content areas */
:root[data-theme="dark"] main {
  background-color: #1a1a1a;
}

:root[data-theme="dark"] .sidebar {
  background: #2a2a2a;
  border-color: #444;
}

:root[data-theme="dark"] .content-wrapper {
  background-color: transparent;
}

/* Navigation links */
:root[data-theme="dark"] nav a,
:root[data-theme="dark"] .nav-link {
  color: #cccccc;
}

:root[data-theme="dark"] nav a:hover,
:root[data-theme="dark"] .nav-link:hover {
  color: #ffffff;
}

/* Page title in header */
:root[data-theme="dark"] .page-title-header {
  color: #ffffff;
}

/* Logo and header links */
:root[data-theme="dark"] header h1 a {
  color: #ffffff;
}

:root[data-theme="dark"] .logo svg {
  stroke: #ffffff;
}

/* Logo image for dark mode - use dark variant */
:root[data-theme="dark"] .logo img,
:root[data-theme="dark"] .logo-link img {
  content: url('/images/favicon-dark.svg');
}

:root[data-theme="dark"] .landing-logo-svg {
  filter: invert(1);
}

/* Navigation icons in dark mode - use filter for img tags */
/* Exclude profile avatar (profile-dropdown-avatar) and user-avatar from inversion */
:root[data-theme="dark"] header img:not(.logo img):not(.logo-link img):not([alt="admin"]):not(.profile-dropdown-avatar img):not(.user-avatar img):not(.nav-profile-avatar) {
  filter: brightness(0) invert(1);
}

/* Explicitly keep profile/user avatar images un-inverted in dark mode */
:root[data-theme="dark"] .profile-dropdown-avatar img,
:root[data-theme="dark"] header .user-avatar img,
:root[data-theme="dark"] .nav-profile-avatar {
  filter: none !important;
}

:root[data-theme="dark"] .nav-icon-link img:not(.nav-profile-avatar),
:root[data-theme="dark"] .notifications-button img,
:root[data-theme="dark"] .mobile-menu-btn img,
:root[data-theme="dark"] header button img:not(.nav-profile-avatar) {
  filter: brightness(0) invert(1);
}

/* SVG fallback for inline SVGs */
:root[data-theme="dark"] .nav-icon-link svg,
:root[data-theme="dark"] .notifications-button svg,
:root[data-theme="dark"] .profile-dropdown-trigger svg,
:root[data-theme="dark"] .mobile-menu-btn svg,
:root[data-theme="dark"] header svg {
  stroke: #ffffff !important;
}

/* Page content icons in dark mode */
:root[data-theme="dark"] .page-meta-actions .view-tags-btn,
:root[data-theme="dark"] .page-meta-actions a,
:root[data-theme="dark"] .toc-toggle-btn,
:root[data-theme="dark"] .follow-btn,
:root[data-theme="dark"] .slider-label,
:root[data-theme="dark"] .section-icon,
:root[data-theme="dark"] .brain-icon {
  color: #cccccc;
}

:root[data-theme="dark"] .page-meta-actions .view-tags-btn svg,
:root[data-theme="dark"] .page-meta-actions a svg,
:root[data-theme="dark"] .toc-toggle-btn svg,
:root[data-theme="dark"] .follow-btn svg,
:root[data-theme="dark"] .slider-label svg,
:root[data-theme="dark"] .section-icon {
  stroke: #cccccc;
}

:root[data-theme="dark"] .page-meta-actions .view-tags-btn:hover,
:root[data-theme="dark"] .page-meta-actions a:hover,
:root[data-theme="dark"] .toc-toggle-btn:hover,
:root[data-theme="dark"] .follow-btn:hover,
:root[data-theme="dark"] .slider-label:hover {
  color: #ffffff;
}

:root[data-theme="dark"] .page-meta-actions .view-tags-btn:hover svg,
:root[data-theme="dark"] .page-meta-actions a:hover svg,
:root[data-theme="dark"] .toc-toggle-btn:hover svg,
:root[data-theme="dark"] .follow-btn:hover svg,
:root[data-theme="dark"] .slider-label:hover svg {
  stroke: #ffffff;
}

/* Page title icons - use filter for img tags with dark icons */
:root[data-theme="dark"] .toc-toggle-btn img,
:root[data-theme="dark"] .follow-btn img,
:root[data-theme="dark"] .page-meta-actions img {
  filter: brightness(0) invert(0.8);
}

:root[data-theme="dark"] .toc-toggle-btn:hover img,
:root[data-theme="dark"] .follow-btn:hover img,
:root[data-theme="dark"] .page-meta-actions:hover img {
  filter: brightness(0) invert(1);
}

/* Form elements */
:root[data-theme="dark"] input,
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] select {
  background-color: #333333;
  color: #ffffff;
  border-color: #444444;
}

:root[data-theme="dark"] input::placeholder,
:root[data-theme="dark"] textarea::placeholder {
  color: #888888;
}

:root[data-theme="dark"] input:focus,
:root[data-theme="dark"] textarea:focus,
:root[data-theme="dark"] select:focus {
  border-color: #666666;
  outline-color: #666666;
}

/* Buttons */
:root[data-theme="dark"] .btn-secondary {
  background-color: #333333;
  color: #ffffff;
  border-color: #444444;
}

:root[data-theme="dark"] .btn-secondary:hover {
  background-color: #444444;
}

/* Cards and boxes */
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .box,
:root[data-theme="dark"] .panel {
  background-color: #2a2a2a;
  border-color: #444444;
}

/* Tables */
:root[data-theme="dark"] table {
  border-color: #444444;
}

:root[data-theme="dark"] th {
  background-color: #333333;
  border-color: #444444;
}

:root[data-theme="dark"] td {
  border-color: #444444;
}

:root[data-theme="dark"] tr:nth-child(even) {
  background-color: #2a2a2a;
}

:root[data-theme="dark"] tr:hover {
  background-color: #333333;
}

/* Code blocks and syntax highlighting */
:root[data-theme="dark"] pre,
:root[data-theme="dark"] code {
  background-color: #333333;
  color: #e0e0e0;
}

:root[data-theme="dark"] .hljs {
  background-color: #333333 !important;
  color: #e0e0e0 !important;
}

/* Claim boxes and special containers */
:root[data-theme="dark"] .claim-box {
  border-color: rgba(255, 255, 255, 0.15);
}

:root[data-theme="dark"] .claim-box .claim-header {
  color: var(--color-text-primary);
  border-color: rgba(255, 255, 255, 0.15);
  background-color: rgba(255, 255, 255, 0.05);
}

/* Modal and dropdown overlays */
:root[data-theme="dark"] .modal-backdrop {
  background-color: rgba(0, 0, 0, 0.7);
}

:root[data-theme="dark"] .modal-content,
:root[data-theme="dark"] .modal-dialog {
  background-color: #2a2a2a;
  border-color: #444444;
  color: #ffffff;
}

/* Tooltips */
:root[data-theme="dark"] .tooltip {
  background-color: #444444;
  color: #ffffff;
}

/* Borders and dividers */
:root[data-theme="dark"] hr {
  border-color: #444444;
}

:root[data-theme="dark"] .divider {
  background-color: #444444;
}

/* Text selection in dark mode */
:root[data-theme="dark"] ::selection {
  background-color: #666666;
  color: #ffffff;
}

:root[data-theme="dark"] ::-moz-selection {
  background-color: #666666;
  color: #ffffff;
}

/* Link colors for dark mode - blue tint for visibility */
:root[data-theme="dark"] a {
  color: #90caf9;
}

:root[data-theme="dark"] a:hover {
  color: #bbdefb;
}

/* Preserve button and nav link colors */
:root[data-theme="dark"] .btn-primary {
  background-color: #ffffff;
  color: #1a1a1a;
}

:root[data-theme="dark"] .btn-primary:hover {
  background-color: #e0e0e0;
}

/* Chat dock dark mode */
:root[data-theme="dark"] .chat-dock {
  background-color: transparent;
}

:root[data-theme="dark"] .chat-dock-rail {
  background-color: #2a2a2a;
  border-color: #444444;
}

:root[data-theme="dark"] .chat-dock-item {
  background-color: #333333;
  color: #cccccc;
}

:root[data-theme="dark"] .chat-dock-item:hover {
  background-color: #444444;
}

:root[data-theme="dark"] .chat-float-window {
  background-color: #2a2a2a;
  border-color: #444444;
}

:root[data-theme="dark"] .chat-float-header {
  background-color: #333333;
  border-color: #444444;
}

:root[data-theme="dark"] .chat-channel-panel {
  background-color: #2a2a2a;
  border-color: #444444;
}

/* Messages area dark mode */
:root[data-theme="dark"] .cfm-messages {
  background-color: #1a1a1a;
}

:root[data-theme="dark"] .cfm-message {
  background-color: transparent;
}

:root[data-theme="dark"] .cfm-message:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

:root[data-theme="dark"] .cfm-composer {
  background-color: #2a2a2a;
  border-color: #444444;
}

:root[data-theme="dark"] .cfm-input {
  background-color: #333333;
  color: #ffffff;
  border-color: #444444;
}

/* Thread panel dark mode */
:root[data-theme="dark"] .chat-float-thread {
  background-color: #242424;
  border-color: #444444;
}

/* Mention toast dark mode */
:root[data-theme="dark"] .chat-mention-toast {
  background-color: #2a2a2a;
  border-color: #444444;
}

/* Scrollbars in dark mode */
:root[data-theme="dark"] ::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

:root[data-theme="dark"] ::-webkit-scrollbar-track {
  background: #2a2a2a;
}

:root[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: #555555;
  border-radius: var(--radius-sm);
}

:root[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: #666666;
}