/* Chat Interface Styles */
.chat-interface {
  margin-top: 1rem;
  border-top: 1px solid #9FA8B1; /* Nottingham Blue 40% tint for light mode */
  padding-top: 0.75rem;
  background: #CFD4D8; /* Match TOC and top bar in light mode */
  color: #10263B; /* Dark Nottingham Blue text */
}

/* Dark mode chat interface background to match TOC */
[data-theme="dark"] .chat-interface {
  background: #10263B; /* Match TOC and top bar */
  border-top: 1px solid #405162; /* Nottingham Blue 80% tint for border */
  color: #F3F4F5;
}

/* Chat interface at bottom of nav section */
.chat-interface.nav-bottom-chat {
  margin-top: auto;
  flex-shrink: 0;
}

/* Hide chat interface when TOC is collapsed */
.chat-interface.hide {
  display: none !important;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  padding: 0 0.25rem;
}

.chat-header h3 {
  margin: 0;
  margin-left: 0.5rem; /* Add space to the left */
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-color, #333333);
}

.chat-header-buttons {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.chat-toggle,
.chat-clear {
  background: none;
  border: none;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  border-radius: 6px;
  color: var(--text-color, #666666);
  transition: background-color 0.2s ease;
}

.chat-clear {
  width: 28px;
  height: 28px;
  padding: 0.4rem;
}

.chat-toggle:hover,
.chat-clear:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

/* Dark mode chat button hover */
[data-theme="dark"] .chat-toggle:hover,
[data-theme="dark"] .chat-clear:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.chat-body {
  display: flex;
  flex-direction: column;
  height: 320px; /* Increased from 250px to 320px */
  border: 1px solid #9FA8B1; /* Nottingham Blue 40% tint for light mode */
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff; /* White background for chat content area */
}

/* Dark mode chat body */
[data-theme="dark"] .chat-body {
  background: #1a1f26; /* Main dark background */
  border: 1px solid #405162; /* Nottingham Blue 80% tint */
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: #ffffff; /* White background for message area */
}

/* Dark mode chat messages */
[data-theme="dark"] .chat-messages {
  background: #1a1f26; /* Main dark background */
}

.chat-message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}

.chat-message.user {
  align-self: flex-end;
}

.chat-message.user .message-content {
  background: var(--link-text-color, #007bff);
  color: var(--background-color, #ffffff);
  border-radius: 12px 12px 4px 12px;
}

.chat-message.system {
  align-self: flex-start;
}

.chat-message.system .message-content {
  background: var(--note-highlight-color, #e9ecef);
  color: var(--text-color, #333333);
  border-radius: 12px 12px 12px 4px;
}

/* Light mode specific colors (prevent flickering) */
[data-theme="light"] .chat-message.user .message-content {
  background: #009BC1; /* Sky Blue */
  color: #FFFFFF; /* White text */
}

[data-theme="light"] .chat-message.system .message-content,
[data-theme="light"] .chat-message.assistant .message-content {
  background: #FFFFFF; /* Warm off-white to match page background */
  color: #333333; /* Dark text */
}

/* Dark mode specific colors */
[data-theme="dark"] .chat-message.user .message-content {
  background: #66C3DA; /* Sky Blue 60% tint */
  color: #10263B; /* Nottingham Blue for good contrast */
}

[data-theme="dark"] .chat-message.system .message-content,
[data-theme="dark"] .chat-message.assistant .message-content {
  background: #1a1f26; /* Main dark background */
  color: #F3F4F5; /* Light text */
}

.message-content {
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  line-height: 1.4;
  word-wrap: break-word;
}

.chat-input-container {
  display: flex;
  padding: 0.5rem;
  border-top: 1px solid #9FA8B1; /* Nottingham Blue 40% tint for light mode */
  background: #CFD4D8; /* Match TOC and top bar in light mode */
  gap: 0.5rem;
}

/* Dark mode chat input container */
[data-theme="dark"] .chat-input-container {
  background: #10263B; /* Match TOC and top bar */
  border-top: 1px solid #405162; /* Nottingham Blue 80% tint */
}

.chat-input {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border-light-color, #ddd);
  border-radius: 20px;
  font-size: 0.85rem;
  outline: none;
  background: var(--background-color, #ffffff);
  color: var(--text-color, #333333);
  transition: border-color 0.2s ease;
}

.chat-input:focus {
  border-color: var(--email-link-color, #007bff);
}

.chat-input::placeholder {
  color: var(--border-light-color, #999999);
}

.chat-send {
  padding: 0.5rem;
  background: #B91C2E; /* Official Jubilee Red for light mode too */
  color: #ffffff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
  min-width: 32px;
  height: 32px;
}

.chat-send svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  pointer-events: none;
  background-color: transparent !important;
  z-index: 1 !important;
  color: currentColor !important;
  filter: none !important;
}

.chat-send:hover {
  background: #C74958; /* Jubilee Red 80% tint for hover */
}

/* Dark mode specific overrides for chat send button */
[data-theme="dark"] .chat-send {
  background: #B91C2E; /* Official Jubilee Red */
  color: #F3F4F5; /* Light text for contrast */
}

[data-theme="dark"] .chat-send:hover {
  background: #C74958; /* Jubilee Red 80% tint */
}

.chat-send:disabled {
  background: #E3A4AB; /* Jubilee Red 40% tint - lighter for light mode */
  color: #B91C2E; /* Full Jubilee Red text for contrast */
  cursor: not-allowed;
}

/* Dark mode disabled send button */
[data-theme="dark"] .chat-send:disabled {
  background: #D57782; /* Jubilee Red 60% tint - lighter but still red */
  color: #F3F4F5; /* Light text for contrast */
}

/* Sticky custom headers */
.custom-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background-color: #CFD4D8; /* Official Nottingham Blue 20% tint for light mode */
  height: 3.5rem; /* Set explicit height to prevent layout shifts */
}

/* Darker background for headers in dark mode */
[data-theme="dark"] .custom-header {
  background-color: #10263B; /* Full Nottingham Blue for dark mode */
}

.custom-mobile-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background-color: #CFD4D8; /* Official Nottingham Blue 20% tint for light mode */
  height: 3.5rem; /* Match desktop header height */
}

/* Darker background for mobile header in dark mode */
[data-theme="dark"] .custom-mobile-header {
  background-color: #10263B; /* Full Nottingham Blue for dark mode */
}

/* Enhance header content styling */
.custom-header-content {
  max-width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  padding: 0.25rem 0.5rem;
  position: relative;
}

/* Left section with logo, module code, and TOC controls */
.custom-header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Right section with color scheme toggle */
.custom-header-right {
  margin-left: auto;
}

/* TOC toggle icons - visible even when TOC is collapsed */
nav.ltx_TOC .header-toc-controls {
  position: fixed;
  top: 4.5rem; /* Below header */
  left: 0.5rem;
  display: flex !important;
  gap: 0.25rem;
  align-items: center;
  z-index: 150;
  background: rgba(207, 212, 216, 0.95);
  border-radius: 6px;
  padding: 0.25rem;
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: left 0.3s ease;
}

/* When TOC is active, move controls to the top-right of TOC */
nav.ltx_TOC.active .header-toc-controls {
  left: auto;
  right: auto;
  position: absolute;
  top: 1rem;
  right: 0.75rem;
}

[data-theme="dark"] nav.ltx_TOC .header-toc-controls {
  background: rgba(16, 38, 59, 0.95);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.header-toc-controls #listIcon,
.header-toc-controls #arrowIcon {
  width: 28px;
  height: 28px;
  margin: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

/* Ensure hide class works for TOC icons */
.header-toc-controls #listIcon.hide,
.header-toc-controls #arrowIcon.hide {
  display: none !important;
}

.header-toc-controls #listIcon:hover,
.header-toc-controls #arrowIcon:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .header-toc-controls #listIcon:hover,
[data-theme="dark"] .header-toc-controls #arrowIcon:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Module code styling */
.module-code {
  display: flex;
  align-items: center;
}

.module-code-link {
  font-family: var(--text-font-family);
  font-size: 1.1rem;
  font-weight: 600;
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.1);
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  transition: all 0.2s ease;
  letter-spacing: 0.05em;
}

.module-code-link:hover {
  background-color: rgba(255, 255, 255, 0.2);
  color: #66C3DA; /* Sky blue tint */
  text-decoration: none;
  transform: translateY(-1px);
}

/* Light mode - pill badge in deeper teal with navy text */
[data-theme="light"] .module-code-link {
  color: #10263B;
  background-color: #B3DDE6;
  border-radius: 6px;
}

[data-theme="light"] .module-code-link:hover {
  background-color: #8CCDD9;
  color: #10263B;
}

/* Mobile module code adjustments */
.module-code.mobile .module-code-link {
  font-size: 1rem;
  padding: 0.4rem 0.6rem;
}

/* Hide TOC controls on mobile since TOC behavior is different */
@media (max-width: 768px) {
  nav.ltx_TOC .header-toc-controls {
    display: none;
  }
}

/* Jupyter Book-style orange accent for sections */
section.ltx_section > .ltx_title.ltx_title_section {
  background-color: rgba(249, 129, 9, 0.1);
  border-top: solid;
  border-right: solid;
  border-bottom: solid;
  border-color: #F98109;
  border-radius: 0 30px 30px 0;
  border-left: 4px solid #F98109;
  padding: 0.75rem 1.25rem;
  padding-left: 1rem;
  margin: 2rem 0 1.5rem 0;
  width: 75%;
  color: var(--text-color);
  font-weight: 600;
  font-size: 1.4rem;
  box-shadow: none;
}

/* Dark mode adjustments for section titles */
[data-theme="dark"] section.ltx_section > .ltx_title.ltx_title_section {
  background-color: rgba(249, 129, 9, 0.15);
  border-color: #F98109;
  border-left: 4px solid #F98109;
}

/* Ensure subsections don't get this styling */
section.ltx_subsection > .ltx_title.ltx_title_subsection {
  background: none;
  color: var(--text-color);
  padding: 0;
  margin: 1.5rem 0 1rem 0;
  border-radius: 0;
  font-weight: 500;
  box-shadow: none;
  border: none;
}

/* Improve toggle button styling in headers */
.custom-header .toggle-icon,
.custom-mobile-header .toggle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 4px;
  transition: background-color 0.2s ease;
  cursor: pointer;
}

.custom-header .toggle-icon:hover,
.custom-mobile-header .toggle-icon:hover {
  background-color: var(--border-light-color, #f5f5f5);
}

.custom-header .toggle-icon svg,
.custom-mobile-header .toggle-icon svg {
  width: 1.2rem;
  height: 1.2rem;
  fill: var(--text-color, #333333);
}

/* Sticky behavior for nav + chat - adjust for sticky header */
nav.ltx_TOC {
  position: sticky;
  top: 3.5rem; /* Account for header height - increased to match actual header size */
  max-height: calc(100vh - 3.5rem);
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

/* Make TOC content scrollable while keeping chat at bottom */
nav.ltx_TOC .ltx_toclist {
  flex: 1;
  overflow-y: auto;
  overflow-anchor: none;
}

/* Chat interface positioned at bottom of nav section */

/* Mobile: hide TOC sidebar, hamburger, and chat - use index page for navigation */
@media (max-width: 768px) {
  /* Hide TOC sidebar completely */
  nav.ltx_TOC,
  nav.ltx_TOC.mobile {
    display: none !important;
  }

  /* Hide hamburger menu button */
  .navbar-toggler,
  .custom-nav-button {
    display: none !important;
  }

  /* Hide chat interface on mobile */
  .chat-interface,
  #chat-interface {
    display: none !important;
  }

  /* Hide "Explain with AI" button on mobile */
  #small-report-button {
    display: none !important;
  }

  /* Hide desktop header on mobile */
  .custom-header {
    display: none;
  }

  /* Show mobile header */
  .custom-mobile-header {
    display: block;
  }
}

/* Hide mobile header on desktop */
@media (min-width: 769px) {
  .custom-mobile-header {
    display: none;
  }
  
  .custom-header {
    display: block;
  }
}

/* Prevent initial layout shift by ensuring body accounts for header space */
body {
  padding-top: 0; /* Reset any default padding */
}

/* Fix initial layout positioning to prevent shift on page load */
body[data-customized="1"] nav.ltx_TOC {
  /* Ensure TOC starts in correct position immediately */
  margin-top: 0;
  padding-top: 1vh; /* Match server-side setting */
}

/* Ensure page content accounts for header from the start */
body[data-customized="1"] .ltx_page_content {
  margin-top: 2.0rem !important;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
  .chat-body {
    height: 260px; /* Increased proportionally from 200px to 260px */
  }
  
  .chat-messages {
    padding: 0.375rem;
    gap: 0.375rem;
  }
  
  .message-content {
    padding: 0.375rem 0.5rem;
    font-size: 0.8rem;
  }
  
  .chat-input-container {
    padding: 0.375rem;
  }
  
  .chat-input {
    padding: 0.375rem 0.5rem;
    font-size: 0.8rem;
  }
  
  .chat-send {
    min-width: 28px;
    height: 28px;
  }
}

/* Collapsed state */
.chat-interface.collapsed .chat-body {
  display: none;
}

.chat-interface.collapsed .chat-toggle svg {
  transform: rotate(45deg);
}

/* Animation for smooth transitions */
.chat-body {
  transition: height 0.3s ease;
}

.chat-toggle svg,
.chat-clear svg {
  background-color: transparent !important;
  z-index: 1 !important;
  color: currentColor !important;
  filter: none !important;
}

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

.chat-clear svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

/* Scrollbar styling for chat messages */
.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border-light-color, #cccccc);
  border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--border-color, #999999);
}

/* Highlight current TOC item on split pages - Jupyter Book style */
nav.ltx_TOC .ltx_tocentry.current > a.ltx_ref {
  font-weight: 600;
  color: #009BC1;
}

nav.ltx_TOC .ltx_tocentry.current {
  border-left: 3px solid #009BC1;
  padding-left: 8px;
}

/* Dark mode - use lighter tint for visibility */
[data-theme="dark"] nav.ltx_TOC .ltx_tocentry.current > a.ltx_ref {
  color: #66C3DA;
}

[data-theme="dark"] nav.ltx_TOC .ltx_tocentry.current {
  border-left: 3px solid #009BC1; /* Full Sky Blue for the bar */
}

/* Active section highlighting during scroll (for full pages) */
nav.ltx_TOC .ltx_tocentry.active-scroll > a.ltx_ref {
  font-weight: 500;
  color: #009BC1;
  background-color: rgba(0, 155, 193, 0.08);
  border-radius: 4px;
}

nav.ltx_TOC .ltx_tocentry.active-scroll {
  position: relative;
}

nav.ltx_TOC .ltx_tocentry.active-scroll::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 70%;
  background-color: #009BC1;
  border-radius: 2px;
  transition: all 0.3s ease;
}

/* Dark mode active scroll highlighting */
[data-theme="dark"] nav.ltx_TOC .ltx_tocentry.active-scroll > a.ltx_ref {
  color: #66C3DA;
  background-color: rgba(102, 195, 218, 0.12);
}

[data-theme="dark"] nav.ltx_TOC .ltx_tocentry.active-scroll::before {
  background-color: #66C3DA;
}

/* Smooth transitions for active state changes */
nav.ltx_TOC .ltx_tocentry > a.ltx_ref {
  transition: background-color 0.3s ease, color 0.3s ease, font-weight 0.2s ease;
}

nav.ltx_TOC .ltx_tocentry::before {
  transition: all 0.3s ease;
}

/* Show subsections in the current section (for split mode) */
li.ltx_tocentry.current .ltx_toclist_section {
  display: block !important;
}

li.ltx_tocentry.current li.ltx_tocentry_subsection {
  display: list-item !important;
}

/* Ensure subsubsections stay hidden even in current section */
li.ltx_tocentry.current li.ltx_tocentry_subsubsection {
  display: none !important;
}

/* Section pagination styling to match article width */
.section-pagination {
  max-width: var(--main-width, 52rem);
  margin: 2rem auto;
}

.section-pagination > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 0;
}

.section-pagination a {
  color: var(--text-color, #333333);
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.section-pagination a:hover,
.section-pagination a:focus {
  background-color: var(--border-light-color, #f5f5f5);
  text-decoration: none;
}

[data-theme="dark"] .section-pagination a {
  color: var(--text-color, #e0e0e0);
}

[data-theme="dark"] .section-pagination a:hover,
[data-theme="dark"] .section-pagination a:focus {
  background-color: rgba(255, 255, 255, 0.1);
}

/* ================================================
   VISUAL IMPROVEMENTS
   ================================================ */

/* Light Mode Enhancements */
[data-theme="light"] body {
  background: #FFFFFF; /* Warm off-white instead of harsh white */
}

[data-theme="light"] article.ltx_document {
  background: #FFFFFF;
}

[data-theme="light"] .chat-messages,
[data-theme="light"] .chat-body {
  background: #FFFFFF;
}

[data-theme="light"] nav.ltx_TOC.active {
  background-color: #FFFFFF;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] nav.ltx_TOC .header-toc-controls {
  background: rgba(255, 255, 255, 0.95);
}

[data-theme="light"] .custom-header {
  background-color: #FFFFFF;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .custom-mobile-header {
  background-color: #FFFFFF;
}

[data-theme="light"] .chat-body {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  background: #FFFFFF;
}

[data-theme="light"] .chat-interface {
  background: #FFFFFF;
}

[data-theme="light"] .chat-input-container {
  background: #F5F5F5;
}

[data-theme="light"] .ltx_table {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .ltx_listing,
[data-theme="light"] .ltx_lstlisting,
[data-theme="light"] pre {
  background: #F7F6F3; /* Warmer beige instead of cool gray */
  border-left: 3px solid #005F36; /* Forest Green */
}

[data-theme="light"] table.ltx_tabular th {
  background: #F5F3F0; /* Warm beige */
  color: #10263B; /* Nottingham Blue for contrast */
}

[data-theme="light"] .ltx_theorem,
[data-theme="light"] .ltx_lemma,
[data-theme="light"] .ltx_corollary {
  background: rgba(0, 95, 54, 0.08); /* Stronger green tint */
  box-shadow: 0 1px 3px rgba(0, 95, 54, 0.08);
}

[data-theme="light"] .ltx_definition {
  background: rgba(0, 155, 193, 0.08);
  box-shadow: 0 1px 3px rgba(0, 155, 193, 0.08);
}

[data-theme="light"] a:focus-visible,
[data-theme="light"] button:focus-visible,
[data-theme="light"] input:focus-visible {
  outline-color: #005F36; /* Forest Green instead of bright blue */
  box-shadow: 0 0 0 3px rgba(0, 95, 54, 0.1);
}

[data-theme="light"] .ltx_page_content {
  background: #FFFFFF;
}

/* Improved readability - increase line height for main content */
.ltx_page_content p,
.ltx_page_content .ltx_para,
.ltx_page_content .ltx_p {
  line-height: 1.65;
}

.ltx_page_content li {
  line-height: 1.6;
}

/* 1. Improved Content Readability */
article.ltx_document {
  line-height: 1.7;
  font-size: 1.05rem;
}

article.ltx_document p {
  margin-bottom: 1.25rem;
}

article.ltx_document h1 {
  margin-top: 2rem;
  margin-bottom: 1.5rem;
  font-weight: 600;
  line-height: 1.2;
}

article.ltx_document h2 {
  margin-top: 1.75rem;
  margin-bottom: 1rem;
  font-weight: 600;
  line-height: 1.3;
}

article.ltx_document h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
}

/* 2. Subtle Shadows for Depth */
nav.ltx_TOC.active {
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] nav.ltx_TOC.active {
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.3);
}

.custom-header {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .custom-header {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.chat-body {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* 3. Better Code Block Styling */
.ltx_listing,
.ltx_lstlisting,
pre {
  background: #f8f9fa;
  border-left: 3px solid #009BC1;
  padding: 1rem;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 1rem 0;
}

[data-theme="dark"] .ltx_listing,
[data-theme="dark"] .ltx_lstlisting,
[data-theme="dark"] pre {
  background: #1e2530;
  border-left-color: #66C3DA;
}

/* Better equation display */
.ltx_equation,
.ltx_equationgroup {
  margin: 1.5rem 0;
  overflow-x: auto;
}

/* 4. Improved Table of Contents */
.ltx_TOC .ltx_tocentry a {
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  transition: all 0.2s ease;
  display: block;
}

.ltx_TOC .ltx_tocentry a:hover {
  background-color: rgba(0, 155, 193, 0.1);
  transform: translateX(2px);
}

[data-theme="dark"] .ltx_TOC .ltx_tocentry a:hover {
  background-color: rgba(102, 195, 218, 0.15);
}

/* Add subtle separator between top-level TOC items */
.ltx_TOC > .ltx_toclist > .ltx_tocentry {
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  padding-bottom: 0.3rem;
}

[data-theme="dark"] .ltx_TOC > .ltx_toclist > .ltx_tocentry {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* 5. Better Focus States for Accessibility */
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid #009BC1;
  outline-offset: 2px;
  border-radius: 2px;
}

[data-theme="dark"] a:focus-visible,
[data-theme="dark"] button:focus-visible,
[data-theme="dark"] input:focus-visible {
  outline-color: #66C3DA;
}

/* 6. Chat Message Styling with Animation */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-message {
  animation: slideIn 0.2s ease-out;
}

/* 7. Better Table Styling */
.ltx_table {
  margin: 1.5rem 0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

table.ltx_tabular {
  border-collapse: collapse;
  width: 100%;
}

table.ltx_tabular th {
  background: #f8f9fa;
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid #009BC1;
}

[data-theme="dark"] table.ltx_tabular th {
  background: #1e2530;
  border-bottom-color: #66C3DA;
}

table.ltx_tabular td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] table.ltx_tabular td {
  border-bottom-color: rgba(255, 255, 255, 0.05);
}

table.ltx_tabular tr:hover {
  background: rgba(0, 155, 193, 0.05);
}

[data-theme="dark"] table.ltx_tabular tr:hover {
  background: rgba(102, 195, 218, 0.08);
}

/* 8. Smooth Scroll Behavior */
html {
  scroll-behavior: smooth;
  scroll-padding-top: 4.5rem;
}

/* 9. Improved Link Hover Effects */
article.ltx_document a {
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease, color 0.2s ease;
}

article.ltx_document a:hover {
  border-bottom-color: currentColor;
}

/* 10. Better Blockquote/Abstract Styling */
.ltx_abstract {
  background: rgba(0, 155, 193, 0.05);
  border-left: 4px solid #009BC1;
  padding: 1.25rem 1.5rem;
  margin: 2rem 0;
  border-radius: 4px;
  font-style: italic;
}

[data-theme="dark"] .ltx_abstract {
  background: rgba(102, 195, 218, 0.08);
  border-left-color: #66C3DA;
}

/* 11. Better Figure & Caption Styling */
.ltx_figure {
  margin: 2rem auto;
  text-align: center;
  max-width: 100%;
}

.ltx_figure img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .ltx_figure img {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.ltx_caption {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--secondary-text-color);
  font-style: italic;
  line-height: 1.5;
}

.ltx_caption .ltx_tag {
  font-weight: 600;
  font-style: normal;
}

/* 12. Theorem/Proof/Definition Boxes */
.ltx_theorem,
.ltx_proof,
.ltx_definition,
.ltx_lemma,
.ltx_corollary {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border-radius: 6px;
  border-left: 4px solid;
}

.ltx_theorem,
.ltx_lemma,
.ltx_corollary {
  background: rgba(0, 95, 54, 0.05); /* Forest Green 5% opacity */
  border-left-color: #005F36; /* Forest Green */
}

.ltx_definition {
  background: rgba(0, 155, 193, 0.05);
  border-left-color: #009BC1;
}

.ltx_proof {
  background: rgba(0, 0, 0, 0.02);
  border-left-color: #9FA8B1;
}

[data-theme="dark"] .ltx_theorem,
[data-theme="dark"] .ltx_lemma,
[data-theme="dark"] .ltx_corollary {
  background: rgba(0, 95, 54, 0.12); /* Forest Green with higher opacity for dark mode */
  border-left-color: #669F86; /* Forest Green 60% tint for better visibility */
}

[data-theme="dark"] .ltx_definition {
  background: rgba(0, 155, 193, 0.08);
}

[data-theme="dark"] .ltx_proof {
  background: rgba(255, 255, 255, 0.03);
  border-left-color: #405162;
}

/* 13. Dark Mode - no transitions to prevent flickering */

/* 14. Better Bibliography Styling */
.ltx_bibitem {
  padding: 0.75rem 0.75rem 0.75rem 2.5rem;
  margin-bottom: 0.5rem;
  border-radius: 4px;
  transition: background-color 0.2s ease;
  position: relative;
}

.ltx_bibitem:hover {
  background: rgba(0, 155, 193, 0.03);
}

[data-theme="dark"] .ltx_bibitem:hover {
  background: rgba(102, 195, 218, 0.05);
}

.ltx_bibitem .ltx_tag_bibitem {
  position: absolute;
  left: 0.75rem;
  font-weight: 600;
  color: #009BC1;
}

[data-theme="dark"] .ltx_bibitem .ltx_tag_bibitem {
  color: #66C3DA;
}

/* 16. Definition Lists */
dt {
  font-weight: 600;
  color: var(--text-color);
  margin-top: 1rem;
  margin-bottom: 0.25rem;
}

dd {
  margin-left: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--text-color);
}

/* 17. Block Quotes */
blockquote,
.ltx_quote {
  border-left: 4px solid #9FA8B1;
  padding: 0.75rem 1.25rem;
  margin: 1.5rem 0;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 0 4px 4px 0;
  font-style: italic;
}

[data-theme="dark"] blockquote,
[data-theme="dark"] .ltx_quote {
  background: rgba(255, 255, 255, 0.02);
  border-left-color: #405162;
}

/* 18. Responsive Typography */
article.ltx_document {
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.1rem);
}

article.ltx_document h1 {
  font-size: clamp(1.8rem, 1.5rem + 1.5vw, 2.5rem);
}

article.ltx_document h2 {
  font-size: clamp(1.5rem, 1.3rem + 1vw, 2rem);
}

article.ltx_document h3 {
  font-size: clamp(1.25rem, 1.15rem + 0.5vw, 1.5rem);
}

/* Chat-specific background variable and border-light synced to it */
.chat-body {
  --chat-bg-color: #FFFFFF;
  background: var(--chat-bg-color) !important;
  --border-light-color: var(--chat-bg-color);
}

[data-theme="dark"] .chat-body {
  --chat-bg-color: #1a1f26;
  background: var(--chat-bg-color) !important;
  --border-light-color: var(--chat-bg-color);
}

/* Keep input visuals readable despite border-light sync */
.chat-body .chat-input {
  border-color: #9FA8B1 !important;
}

[data-theme="dark"] .chat-body .chat-input {
  border-color: #405162 !important;
}

.chat-body .chat-input::placeholder {
  color: #999999 !important;
}

[data-theme="dark"] .chat-body .chat-input::placeholder {
  color: #9FA8B1 !important;
}

/* Ensure chat content area and scrollbar visuals match chat body background */
.chat-body .chat-messages {
  background: inherit !important;
}

.chat-body .chat-messages::-webkit-scrollbar-track,
.chat-body .chat-messages::-webkit-scrollbar-corner {
  background: inherit !important;
}

/* ================================================
   Specific styling: Definition theorem (header bar)
   Targets both default LaTeXML class and amsthm variant
   ================================================ */
.ltx_theorem.ltx_theorem_definition,
.ltx_definition {
  background: rgba(121, 45, 133, 0.06); /* Civic Purple tint */
  border: 1px solid rgba(121, 45, 133, 0.35);
  border-left: 4px solid #792D85; /* Civic Purple */
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

/* Title bar inside Definition blocks */
.ltx_theorem.ltx_theorem_definition > .ltx_title.ltx_title_theorem,
.ltx_definition > .ltx_title {
  margin: -1rem -1.25rem 0.75rem -1.25rem; /* stretch header to container edges */
  background: #792D85; /* Civic Purple */
  color: #FFFFFF;
  font-weight: 600;
  padding: 0.6rem 0.9rem;
  border-radius: 6px 6px 0 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid #94579D; /* 80% tint */
}

/* Optional bell icon like the screenshot */
.ltx_theorem.ltx_theorem_definition > .ltx_title.ltx_title_theorem::before,
.ltx_definition > .ltx_title::before {
  content: "";
  display: inline-block;
  width: 1rem;
  height: 1rem;
  background-color: currentColor; /* monochrome icon */
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="black" d="M12 22a2 2 0 0 0 2-2H10a2 2 0 0 0 2 2zm6-6V11a6 6 0 1 0-12 0v5l-2 2v1h16v-1l-2-2z"/></svg>') no-repeat center / contain;
  mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="black" d="M12 22a2 2 0 0 0 2-2H10a2 2 0 0 0 2 2zm6-6V11a6 6 0 1 0-12 0v5l-2 2v1h16v-1l-2-2z"/></svg>') no-repeat center / contain;
}

/* Dark mode adjustments */
[data-theme="dark"] .ltx_theorem.ltx_theorem_definition,
[data-theme="dark"] .ltx_definition {
  background: rgba(175, 129, 182, 0.12); /* Civic Purple 60% tint */
  border-color: rgba(175, 129, 182, 0.45);
  border-left-color: #AF81B6; /* 60% tint for better visibility */
}

[data-theme="dark"] .ltx_theorem.ltx_theorem_definition > .ltx_title.ltx_title_theorem,
[data-theme="dark"] .ltx_definition > .ltx_title {
  background: #792D85; /* Keep brand purple header in dark mode */
  color: #F3F4F5;
  border-bottom-color: #AF81B6;
}

/* non-theorem alert box styles removed by request */

/* ================================================
   Theorem variants: Careful & Difficult (Jubilee Red)
   Structure mirrors .ltx_theorem_definition
   ================================================ */
.ltx_theorem.ltx_theorem_careful,
.ltx_theorem.ltx_theorem_difficult {
  background: rgba(185, 28, 46, 0.06);
  border: 1px solid rgba(185, 28, 46, 0.35);
  border-left: 4px solid #B91C2E;
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.ltx_theorem.ltx_theorem_careful > .ltx_title.ltx_title_theorem,
.ltx_theorem.ltx_theorem_difficult > .ltx_title.ltx_title_theorem {
  margin: -1rem -1.25rem 0.75rem -1.25rem;
  background: #B91C2E;
  color: #FFFFFF;
  font-weight: 600;
  padding: 0.6rem 0.9rem;
  border-radius: 6px 6px 0 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid #C74958;
}

/* Icons */
.ltx_theorem.ltx_theorem_careful > .ltx_title.ltx_title_theorem::before {
  content: "";
  display: inline-block;
  width: 1rem;
  height: 1rem;
  background-color: currentColor;
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2 L22 20 H2 Z"/><rect x="11" y="8" width="2" height="6"/><circle cx="12" cy="17.5" r="1"/></svg>') no-repeat center / contain;
  mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2 L22 20 H2 Z"/><rect x="11" y="8" width="2" height="6"/><circle cx="12" cy="17.5" r="1"/></svg>') no-repeat center / contain;
}

.ltx_theorem.ltx_theorem_difficult > .ltx_title.ltx_title_theorem::before {
  content: "";
  display: inline-block;
  width: 1rem;
  height: 1rem;
  background-color: currentColor;
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9 21h6v-1H9v1z"/><path d="M12 2a7 7 0 0 0-7 7c0 2.5 1.2 4.1 2.9 5.6.7.6 1.1 1.5 1.1 2.4h6c0-.9.4-1.8 1.1-2.4C17.8 13.1 19 11.5 19 9a7 7 0 0 0-7-7z"/></svg>') no-repeat center / contain;
  mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9 21h6v-1H9v1z"/><path d="M12 2a7 7 0 0 0-7 7c0 2.5 1.2 4.1 2.9 5.6.7.6 1.1 1.5 1.1 2.4h6c0-.9.4-1.8 1.1-2.4C17.8 13.1 19 11.5 19 9a7 7 0 0 0-7-7z"/></svg>') no-repeat center / contain;
}

[data-theme="dark"] .ltx_theorem.ltx_theorem_careful,
[data-theme="dark"] .ltx_theorem.ltx_theorem_difficult {
  background: rgba(213, 119, 130, 0.12);
  border-color: rgba(213, 119, 130, 0.45);
  border-left-color: #D57782;
}

[data-theme="dark"] .ltx_theorem.ltx_theorem_careful > .ltx_title.ltx_title_theorem,
[data-theme="dark"] .ltx_theorem.ltx_theorem_difficult > .ltx_title.ltx_title_theorem {
  background: #B91C2E;
  color: #F3F4F5;
  border-bottom-color: #D57782;
}

/* ================================================
   Theorem variants: Example & Solution (Malaysia Sky Blue)
   ================================================ */
.ltx_theorem.ltx_theorem_example,
.ltx_theorem.ltx_theorem_solution {
  background: rgba(0, 155, 193, 0.06);
  border: 1px solid rgba(0, 155, 193, 0.35);
  border-left: 4px solid #009BC1;
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.ltx_theorem.ltx_theorem_example > .ltx_title.ltx_title_theorem,
.ltx_theorem.ltx_theorem_solution > .ltx_title.ltx_title_theorem {
  margin: -1rem -1.25rem 0.75rem -1.25rem;
  background: #009BC1;
  color: #FFFFFF;
  font-weight: 600;
  padding: 0.6rem 0.9rem;
  border-radius: 6px 6px 0 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid #33AFCD; /* 80% tint */
}

/* Icons for example/solution */
.ltx_theorem.ltx_theorem_example > .ltx_title.ltx_title_theorem::before {
  content: "";
  display: inline-block;
  width: 1rem;
  height: 1rem;
  background-color: currentColor;
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9 21h6v-1H9v1z"/><path d="M12 2a7 7 0 0 0-5 12h10A7 7 0 0 0 12 2z"/></svg>') no-repeat center / contain;
  mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9 21h6v-1H9v1z"/><path d="M12 2a7 7 0 0 0-5 12h10A7 7 0 0 0 12 2z"/></svg>') no-repeat center / contain;
}

.ltx_theorem.ltx_theorem_solution > .ltx_title.ltx_title_theorem::before {
  content: "";
  display: inline-block;
  width: 1rem;
  height: 1rem;
  background-color: currentColor;
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z"/></svg>') no-repeat center / contain;
  mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z"/></svg>') no-repeat center / contain;
}

/* Collapsible behavior: Solution collapsed by default */
.ltx_theorem.ltx_theorem_solution > .ltx_title.ltx_title_theorem {
  cursor: pointer;
}

.ltx_theorem.ltx_theorem_solution:not([data-expanded="1"]):not(.js-solution-ready) > :not(.ltx_title) {
  display: none; /* Prevent flash before JS initializes */
}

/* Animated wrapper for solution content */
.ltx_theorem.ltx_theorem_solution .solution-content-wrap {
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.2s ease;
}

/* Chevron indicator on the right */
.ltx_theorem.ltx_theorem_solution > .ltx_title.ltx_title_theorem::after {
  content: "";
  margin-left: auto;
  width: 1.25rem;
  height: 1.25rem;
  background-color: currentColor;
  transition: transform 0.2s ease;
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M7 10l5 5 5-5"/></svg>') no-repeat center / contain;
  mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M7 10l5 5 5-5"/></svg>') no-repeat center / contain;
}

.ltx_theorem.ltx_theorem_solution[data-expanded="1"] > .ltx_title.ltx_title_theorem::after {
  transform: rotate(180deg);
}

/* Dark mode tints */
[data-theme="dark"] .ltx_theorem.ltx_theorem_example,
[data-theme="dark"] .ltx_theorem.ltx_theorem_solution {
  background: rgba(102, 195, 218, 0.12);
  border-color: rgba(102, 195, 218, 0.45);
  border-left-color: #66C3DA;
}

[data-theme="dark"] .ltx_theorem.ltx_theorem_example > .ltx_title.ltx_title_theorem,
[data-theme="dark"] .ltx_theorem.ltx_theorem_solution > .ltx_title.ltx_title_theorem {
  background: #009BC1; /* keep brand blue header in dark */
  color: #F3F4F5;
  border-bottom-color: #66C3DA;
}

/* ================================================
   Theorem variant: Background (Forest Green)
   ================================================ */
.ltx_theorem.ltx_theorem_background {
  background: rgba(0, 95, 54, 0.06);
  border: 1px solid rgba(0, 95, 54, 0.35);
  border-left: 4px solid #005F36; /* Forest Green */
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.ltx_theorem.ltx_theorem_background > .ltx_title.ltx_title_theorem {
  margin: -1rem -1.25rem 0.75rem -1.25rem;
  background: #005F36;
  color: #FFFFFF;
  font-weight: 600;
  padding: 0.6rem 0.9rem;
  border-radius: 6px 6px 0 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid #337F5E; /* 80% tint */
}

.ltx_theorem.ltx_theorem_background > .ltx_title.ltx_title_theorem::before {
  content: "";
  display: inline-block;
  width: 1rem;
  height: 1rem;
  background-color: currentColor;
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><rect x="11" y="7" width="2" height="7"/><rect x="11" y="15.5" width="2" height="2"/></svg>') no-repeat center / contain;
  mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><rect x="11" y="7" width="2" height="7"/><rect x="11" y="15.5" width="2" height="2"/></svg>') no-repeat center / contain;
}

[data-theme="dark"] .ltx_theorem.ltx_theorem_background {
  background: rgba(102, 159, 134, 0.12); /* Forest Green 60% tint */
  border-color: rgba(102, 159, 134, 0.45);
  border-left-color: #669F86;
}

[data-theme="dark"] .ltx_theorem.ltx_theorem_background > .ltx_title.ltx_title_theorem {
  background: #005F36;
  color: #F3F4F5;
  border-bottom-color: #669F86;
}

/* Fix: prevent list item numbers from being cut off inside Solution theorems */
.ltx_theorem.ltx_theorem_solution li.ltx_item > .ltx_tag {
  margin-left: -2rem; /* neutralize ar5iv negative margin */
}

/* ================================================
   Desktop image sizing overrides
   Prevent overly tall portrait/square images from
   filling the full container height on large screens
   ================================================ */
@media only screen and (min-width: 52.01rem) {
  /* Match ar5iv selectors and override max-height using viewport */
  :not(mtext):not(.ltx_flex_cell) > :not(mtext):not(.ltx_flex_cell) > .ltx_img_portrait {
    max-height: min(80vh, var(--main-width)) !important;
    height: auto !important;
    width: auto !important;
  }

  /* Square images: be more conservative on desktop */
  :not(mtext):not(.ltx_flex_cell) > :not(mtext):not(.ltx_flex_cell) > .ltx_img_square {
    max-height: min(60vh, calc(var(--main-width) / 1.6)) !important;
    max-width: calc(var(--main-width) / 1.6) !important;
    height: auto !important;
    width: auto !important;
  }

  /* Keep figures within the viewport height on desktop */
  .ltx_figure img {
    max-height: 80vh;
    height: auto;
  }
}

/* Push Hypothesis sidebar below sticky header */
.sidebar-container {
  top: 4rem !important;
}

/* Onboarding Modal */
#onboard-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.3s ease;
  padding: 1rem;
}

#onboard-overlay.fade-out {
  animation: fadeOut 0.3s ease forwards;
}

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

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

.onboard-modal {
  background: #ffffff;
  border-radius: 12px;
  padding: 2rem;
  max-width: 550px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
}

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

.onboard-modal h2 {
  margin: 0 0 1rem 0;
  font-size: 1.5rem;
  color: #10263B;
}

.onboard-modal p {
  margin: 0 0 1rem 0;
  color: #333;
  line-height: 1.5;
}

.onboard-image {
  width: 100%;
  border-radius: 8px;
  margin-bottom: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.onboard-features {
  margin: 0 0 1rem 0;
  padding-left: 1.25rem;
  color: #333;
}

.onboard-features li {
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

.onboard-tip {
  background: #E6F4F7;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  border-left: 3px solid #009BC1;
  font-size: 0.9rem;
}

.onboard-button {
  display: block;
  width: 100%;
  padding: 0.875rem 1.5rem;
  margin-top: 1.5rem;
  background: #009BC1;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.onboard-button:hover {
  background: #007a99;
}

/* Dark mode onboarding */
[data-theme="dark"] .onboard-modal {
  background: #1a2332;
}

[data-theme="dark"] .onboard-modal h2 {
  color: #F3F4F5;
}

[data-theme="dark"] .onboard-modal p,
[data-theme="dark"] .onboard-features {
  color: #c5c9ce;
}

[data-theme="dark"] .onboard-tip {
  background: rgba(0, 155, 193, 0.15);
  color: #c5c9ce;
}

[data-theme="dark"] .onboard-button {
  background: #10263B;
}

[data-theme="dark"] .onboard-button:hover {
  background: #1a3a55;
}

/* Back to Top Button */
#back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: #009BC1;
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease, background-color 0.2s ease;
  z-index: 999;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

#back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

#back-to-top:hover {
  background-color: #007a99;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

#back-to-top:active {
  transform: translateY(0);
}

/* Dark mode back to top */
[data-theme="dark"] #back-to-top {
  background-color: #10263B;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] #back-to-top:hover {
  background-color: #1a3a55;
}

/* Mobile positioning - move left to avoid Hypothesis sidebar */
@media only screen and (max-width: 52rem) {
  #back-to-top {
    bottom: 1.5rem;
    right: 1.5rem;
  }
}

/* Index page info box */
.index-info-box {
  background-color: #E6F4F7;
  border-left: 4px solid #009BC1;
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  font-size: 0.95rem;
  line-height: 1.6;
  color: #10263B;
}

.index-info-box p {
  margin: 0 0 0.5rem 0;
}

.index-info-box p:last-child {
  margin-bottom: 0;
}

.index-info-box a {
  color: #009BC1;
  text-decoration: none;
}

.index-info-box a:hover {
  text-decoration: underline;
}

/* Dark mode info box */
[data-theme="dark"] .index-info-box {
  background-color: rgba(0, 155, 193, 0.15);
  border-left-color: #009BC1;
  color: #F3F4F5;
}

[data-theme="dark"] .index-info-box a {
  color: #66C3DA;
}
