:root {
  /* Default theme colors (Light Mode) */
  --primary-color: #c2410c; /* Orange/terra cotta for light mode */
  --secondary-color: #9a3412; /* Darker orange */
  --text-color: #000000;
  --light-gray: #f5f5f5;
  --border-color: #e5e5e5;
  --hover-color: #f0f0f0;
  --icon-color: #666666;
  --bg-color: #fafafa;
  --bubble-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  --ai-bar-height: 48px;
  --ai-bar-expanded-height: 345px;
  --ai-gradient: linear-gradient(135deg, #c2410c, #9a3412);
  --ai-gradient-hover: linear-gradient(135deg, #9a3412, #c2410c);
  
  
  /* Neumorphism variables */
  --neumorph-bg: #f3eeea;
  --neumorph-light-shadow: rgba(255, 255, 255, 0.8);
  --neumorph-dark-shadow: rgba(0, 0, 0, 0.1);
  --neumorph-flat-shadow: 6px 6px 12px var(--neumorph-dark-shadow), 
                        -6px -6px 12px var(--neumorph-light-shadow);
  --neumorph-inset-shadow: inset 4px 4px 8px var(--neumorph-dark-shadow), 
                         inset -4px -4px 8px var(--neumorph-light-shadow);
  --neumorph-radius: 12px;
}

/* Remove light mode section since light is now the default */

/* Dark mode variables */
body.dark-mode {
  --primary-color: #ffffff;
  --secondary-color: #e0e0e0;
  --text-color: #ffffff;
  --light-gray: #1a1a1a;
  --border-color: #333333;
  --hover-color: #2a2a2a;
  --icon-color: #aaaaaa;
  --bg-color: #000000;
  --ai-gradient: linear-gradient(135deg, #ffffff, #e0e0e0);
  --ai-gradient-hover: linear-gradient(135deg, #e0e0e0, #ffffff);
  --neumorph-bg: #1a1a1a;
  --neumorph-light-shadow: rgba(50, 50, 50, 0.5);
  --neumorph-dark-shadow: rgba(0, 0, 0, 0.5);
}

/* Remove desert mode variables section since it's now the default */

/* Update theme toggle button styles */
.theme-toggle, .font-toggle, .summarizer-button, .bionic-toggle {
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.08);
  padding: 8px 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-color);
  transition: all 0.15s ease;
}

.theme-toggle:hover, .font-toggle:hover, .summarizer-button:hover, .bionic-toggle:hover {
  background-color: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.12);
}

.theme-toggle:active, .font-toggle:active, .summarizer-button:active, .bionic-toggle:active {
  box-shadow: none;
  transform: none;
  background-color: var(--hover-color);
}

/* Header controls container */
.header-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.header-controls button {
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-color);
  transition: all 0.15s ease;
  cursor: pointer;
}

body.dark-mode .header-controls button {
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.header-controls button:hover {
  background-color: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.12);
}

body.dark-mode .header-controls button:hover {
  background-color: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
}

/* Mobile menu toggle */
.menu-toggle {
  display: none;
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text-color);
}

@media (max-width: 700px) {
  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .header-controls {
    display: none;
  }
  .header-right[aria-expanded="true"] .header-controls,
  .header-right.menu-open .header-controls {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    width: 100%;
    margin-top: 8px;
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.5;
  color: var(--text-color);
  background-color: var(--bg-color);
  margin: 0;
  padding: 0;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  font-size: 16px; /* Ensuring base font size is 16px */
}

/* Serif font mode */
body.serif-font {
  font-family: 'Merriweather', serif;
}

body.serif-font h1, 
body.serif-font h2, 
body.serif-font h3, 
body.serif-font h4, 
body.serif-font h5, 
body.serif-font h6 {
  font-family: 'Inter', sans-serif;
}

/* Chirp font mode */
body.chirp-font {
  font-family: 'Chirp', -apple-system, BlinkMacSystemFont, sans-serif;
}

body.chirp-font h1, 
body.chirp-font h2, 
body.chirp-font h3, 
body.chirp-font h4, 
body.chirp-font h5, 
body.chirp-font h6 {
  font-family: 'Chirp', sans-serif;
  font-weight: 700;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  position: relative;
}

header {
  padding: 1rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  background-color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  position: sticky;
  top: 0;
  z-index: 1000;
  transition: all 0.2s ease;
}

/* Update dark mode header */
body.dark-mode header {
  background-color: rgba(0, 0, 0, 0.95);
  border-bottom-color: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* Add a subtle gradient overlay to enhance the frosted glass effect */
header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    120deg,
    rgba(255, 255, 255, 0.2) 0%,
    rgba(255, 255, 255, 0.05) 50%,
    rgba(255, 255, 255, 0.1) 100%
  );
  z-index: -1;
  pointer-events: none;
}

body.dark-mode header::before {
  background: linear-gradient(
    120deg,
    rgba(30, 30, 50, 0.2) 0%,
    rgba(11, 10, 15, 0.05) 50%,
    rgba(30, 30, 50, 0.1) 100%
  );
}

/* Add subtle animation to the header on hover */
@keyframes headerShimmer {
  0% {
    background-position: -100% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

header:hover::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  background-size: 200% 100%;
  animation: headerShimmer 3s ease-in-out infinite;
  z-index: -1;
  pointer-events: none;
}

body.dark-mode header:hover::after {
  background: linear-gradient(
    90deg,
    rgba(11, 10, 15, 0) 0%,
    rgba(50, 50, 80, 0.1) 50%,
    rgba(11, 10, 15, 0) 100%
  );
  background-size: 200% 100%;
  animation: headerShimmer 3s ease-in-out infinite;
}

/* Add some spacing after the header */
header + .container {
  padding-top: 1rem;
}

.header-content {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  width: 100%;
  min-height: 60px;
  gap: 20px;
}

/* Create a container for title and subtitle */
.header-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* Header search container */
.header-search {
  display: flex;
  align-items: center;
  flex: 1;
  max-width: none;
  width: 100%;
  margin-right: 0;
  margin-left: 0;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--neumorph-radius);
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

body.dark-mode .header-search {
  background: rgba(11, 10, 15, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

#headerSearchQuery {
  flex: 1;
  padding: 8px 12px;
  font-size: 0.9rem;
  border: none;
  border-radius: var(--neumorph-radius);
  outline: none;
  transition: all 0.3s ease;
  background-color: rgba(243, 238, 234, 0.6);
  font-family: 'Inter', sans-serif;
  min-width: 0;
}

body.dark-mode #headerSearchQuery {
  background-color: rgba(42, 42, 42, 0.6);
  color: var(--text-color);
}

#headerSearchButton {
  background-color: rgba(243, 238, 234, 0.6);
  color: var(--text-color);
  border: none;
  padding: 8px 12px;
  margin-left: 4px;
  cursor: pointer;
  border-radius: var(--neumorph-radius);
  font-weight: 500;
  transition: all 0.3s ease;
  font-family: 'Inter', sans-serif;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
}

body.dark-mode #headerSearchButton {
  background-color: rgba(42, 42, 42, 0.6);
}

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

body.dark-mode #headerSearchButton:hover {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Header right section containing search and controls */
.header-right {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-left: auto;
}

/* Accessible focus outlines */
:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

h1 {
  font-size: 1.75rem;
  margin: 0;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text-color);
}

/* Make h1 link look like regular h1 */
h1 a {
  color: inherit;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

h1 a:hover {
  opacity: 0.8;
  cursor: pointer;
}

/* Breadcrumbs Navigation */
.breadcrumbs {
  margin: 1.5rem 0 0.5rem;
  font-size: 0.9rem;
  background-color: transparent;
  padding: 0;
  border-radius: 0;
  border: none;
}

#breadcrumbsList {
  display: flex;
  list-style: none;
  flex-wrap: wrap;
  padding: 8px 12px;
  margin: 0;
}

#breadcrumbsList li {
  display: flex;
  align-items: center;
  padding: 0 2px;
}

#breadcrumbsList li:not(:last-child)::after {
  content: "/";
  margin: 0 8px;
  color: var(--icon-color);
}

#breadcrumbsList a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color 0.2s;
  padding: 2px 4px;
}

#breadcrumbsList a i {
  color: var(--icon-color);
  margin-right: 4px;
}

#breadcrumbsList a:hover {
  color: var(--secondary-color);
  text-decoration: underline;
}

#breadcrumbsList a:hover i {
  color: var(--secondary-color);
}

#breadcrumbsList li:last-child a {
  color: var(--text-color);
  font-weight: 500;
  pointer-events: none;
  background-color: var(--light-gray);
  padding: 4px 10px;
  border-radius: 4px;
}

.search-container {
  width: 100%;
  max-width: 680px;
  margin: 3rem auto 2rem;
  display: flex;
  gap: 12px;
  position: relative;
}

#searchQuery {
  flex: 1;
  padding: 16px 20px;
  font-size: 1rem;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  outline: none;
  transition: all 0.15s ease;
  background-color: rgba(255, 255, 255, 0.8);
  font-family: 'Inter', sans-serif;
  color: var(--text-color);
}

#searchQuery:focus {
  border-color: rgba(0, 0, 0, 0.2);
  background-color: rgba(255, 255, 255, 1);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

#searchButton {
  background: linear-gradient(135deg, #000 0%, #333 100%);
  color: #ffffff !important;
  border: none;
  padding: 16px 24px;
  cursor: pointer;
  border-radius: 12px;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.15s ease;
  font-family: 'Inter', sans-serif;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
  justify-content: center;
}

#searchButton:hover {
  background: linear-gradient(135deg, #333 0%, #000 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#searchButton:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

body.dark-mode #searchQuery {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--text-color);
}

body.dark-mode #searchQuery:focus {
  background-color: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
}

body.dark-mode #searchButton {
  background: linear-gradient(135deg, #fff 0%, #e5e5e5 100%);
  color: #000000 !important;
}

body.dark-mode #searchButton:hover {
  background: linear-gradient(135deg, #e5e5e5 0%, #fff 100%);
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
}

.content-container {
  margin-bottom: 2rem;
}

.content-section {
  background-color: var(--bg-color);
  border-radius: 3px;
  box-shadow: rgba(15, 15, 15, 0.05) 0px 0px 0px 1px, 
              rgba(15, 15, 15, 0.1) 0px 3px 6px, 
              rgba(15, 15, 15, 0.2) 0px 9px 24px;
  overflow: hidden;
  margin-bottom: 24px;
}

/* Content wrapper layout */
.content-wrapper {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  margin: 0 auto;
  width: 100%;
  max-width: 100%;
  padding-top: 0px;
  align-items: start;
}

#contentContainer {
  grid-column: 2;
  width: 100%;
  max-width: 100%;
  border: none;
  padding: 32px 40px;
  border-radius: 0;
  min-height: 300px;
  background-color: transparent;
  position: relative;
}

/* AI Sidebar removed */

/* Collapsible AI sidebar removed */

/* .ai-sidebar-header removed */

/* .ai-title removed */

/* .ai-sidebar .ai-input-container removed */

.button-container {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
  position: relative;
}

/* .ai-sidebar #userQuestion removed */

/* .ai-sidebar #userQuestion:focus removed */

/* .ai-sidebar #askAIButton removed */

/* .ai-sidebar #askAIButton:hover removed */

/* .ai-sidebar #askAIButton:active removed */

/* .ai-sidebar .ai-response-container removed */

/* .ai-sidebar .ai-response-text removed */

/* .ai-sidebar #askAIButton.summarize-button removed */

/* .ai-sidebar #askAIButton.summarize-button:hover removed */

/* Ensure AI text is white in dark mode */
/* dark mode .ai-sidebar .ai-response-text removed */

/* Add custom scrollbar styling for the response container */
/* .ai-sidebar .ai-response-container::-webkit-scrollbar removed */

/* .ai-sidebar .ai-response-container::-webkit-scrollbar-track removed */

/* .ai-sidebar .ai-response-container::-webkit-scrollbar-thumb removed */

/* .ai-sidebar .ai-response-container::-webkit-scrollbar-thumb:hover removed */

/* Responsive adjustments */
@media (max-width: 1200px) {
  .content-wrapper {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 0 20px;
  }

  /* ai-sidebar responsive rules removed */

  #contentContainer {
    width: 100%;
    height: auto;
    margin-top: 0;
    padding: 24px 20px;
    border: none;
    background-color: transparent;
    grid-column: 1;
  }

  .article-index {
    display: none;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 0 16px;
  }

  .search-container {
    margin: 2rem auto 1.5rem;
    flex-direction: column;
    gap: 12px;
  }

  #searchButton {
    width: 100%;
    padding: 16px;
  }

  #contentContainer {
    padding: 20px 16px;
    grid-column: 1;
  }

  #content {
    font-size: 16px;
  }

  #content p {
    max-width: 100%;
  }

  /* ai-sidebar mobile rules removed */

  .article-index {
    display: none;
  }
}

.loader {
  display: none;
  text-align: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.loader.visible {
  opacity: 1;
}

.loader-spinner {
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-left-color: var(--primary-color);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  animation: spin 1s linear infinite;
  margin: 0 auto 10px;
}

.loader p {
  font-size: 14px;
  color: var(--text-color);
  opacity: 0.7;
  font-weight: 500;
}

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

/* Main content area - flex grow to push footer down */
header + .container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Footer - Flat design */
footer {
  padding: 20px 0;
  background-color: var(--bg-color);
  text-align: center;
  border-top: 1px solid #d5cdc6;
}

body.dark-mode footer {
  background-color: #121212;
  border-color: #333;
  color: #aaa;
}

.alert {
  padding: 12px 16px;
  border-radius: 3px;
  margin-bottom: 1rem;
  display: none;
  font-size: 14px;
}

.alert-error {
  background-color: #fee2e2;
  color: #b91c1c;
  border: 1px solid #f87171;
}

/* Wikipedia Content Styling */
#content {
  max-width: 100%;
  padding: 24px 0;
  font-size: 17px;
  line-height: 1.6;
  color: var(--text-color);
  /* Add smooth transitions to reduce flickering */
  opacity: 1;
  transition: opacity 0.2s ease-in-out;
}

/* Add loading state for content */
#content.loading {
  opacity: 0.3;
}

/* Ensure smooth content transitions */
#content.updating {
  opacity: 0.7;
}

#content h1, #content h2, #content h3, #content h4, #content h5, #content h6 {
  margin-top: 2.5em;
  margin-bottom: 1em;
  font-weight: 600;
  color: var(--text-color);
  line-height: 1.25;
  letter-spacing: -0.02em;
}

#content h1 {
  font-size: 2.2em;
  margin-top: 0;
  margin-bottom: 1.2em;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  padding-bottom: 0.5em;
  font-weight: 700;
}

#content h2 {
  font-size: 1.6em;
  margin-top: 2em;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  padding-bottom: 0.3em;
}

/* Large-screen typography tuning */
@media (min-width: 1600px) {
  #content {
    font-size: 18.5px;
    line-height: 1.7;
  }
  #content h1 { font-size: 2.6em; }
  #content h2 { font-size: 1.9em; }
  .container { max-width: 1600px; }
}

#content h3 {
  font-size: 1.3em;
  margin-top: 1.8em;
}

#content h4 {
  font-size: 1.1em; /* Ensuring h4 size is 1.1em */
}

#content p {
  margin-bottom: 1.4em;
  max-width: 75ch;
}

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

#content li {
  margin-bottom: 0.5em;
}

#content a {
  color: var(--secondary-color);
  text-decoration: none;
  border-bottom: 1px dotted var(--secondary-color);
}

#content a:hover {
  border-bottom: 1px solid var(--secondary-color);
}

#content blockquote {
  margin: 1em 0;
  padding: 0.5em 1em;
  border-left: 4px solid var(--border-color);
  background-color: var(--light-gray);
  font-style: italic;
}

#content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  background-color: #f8f9fa;
  color: #202122;
  font-size: 0.875em;
  line-height: 1.5;
  border: 1px solid #a2a9b1;
}

#content table, #content th, #content td {
  border: 1px solid #a2a9b1;
}

#content th, #content td {
  padding: 0.2em 0.4em;
  text-align: left;
}

#content th {
  background-color: #eaecf0;
  font-weight: 600;
}

#content img {
  max-width: 100%;
  height: auto;
  float: right;
  margin: 0 0 1em 1em;
  display: block;
}

#content sup, #content sub {
  font-size: 0.75em;
}

#content hr {
  margin: 1.5em 0;
  border: none;
  border-bottom: 1px solid var(--border-color);
}

/* Dark mode adjustments for Wiki content */
body.dark-mode #content h1, 
body.dark-mode #content h2, 
body.dark-mode #content h3, 
body.dark-mode #content h4, 
body.dark-mode #content h5, 
body.dark-mode #content h6 {
  color: #ffffff;
}

body.dark-mode #content h1 {
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

body.dark-mode #content h2 {
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

body.dark-mode #content a {
  color: #3498db;
  border-bottom: 1px dotted #3498db;
}

body.dark-mode #content a:hover {
  border-bottom: 1px solid #3498db;
}

body.dark-mode #content blockquote {
  background-color: #2a2a2a;
}

body.dark-mode #content th {
  background-color: #2a2a2a;
  border-color: #444444;
}

/* Search results styling */
ol { 
  padding-left: 30px; 
  list-style-type: decimal;
  margin-bottom: 1rem;
}

ol li {
  padding-left: 10px;
  margin-bottom: 0.5rem;
  position: relative;
}

.search-result {
  background-color: #f3eeea;
  margin-bottom: 20px;
  padding: 15px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  transition: background-color 0.2s ease;
  cursor: pointer;
}

.search-result:hover {
  background-color: var(--hover-color);
}

.search-result:active {
  background-color: var(--hover-color);
}

.search-result h3 { 
  margin-top: 0; 
  margin-bottom: 12px; 
  font-weight: 600;
  font-size: 18px;
  color: var(--primary-color);
}

/* Add special styling for dark mode search results */
body.dark-mode .search-result {
  background-color: transparent;
  border: 1px solid var(--border-color);
}

body.dark-mode .search-result:hover {
  background-color: var(--hover-color);
}

.view-button { 
  background-color: transparent;
  color: var(--text-color); 
  border: 1px solid var(--border-color);
  padding: 10px 16px; 
  cursor: pointer; 
  border-radius: 4px;
  font-size: 14px;
  margin-top: 12px;
  font-weight: 500;
  transition: background-color 0.3s ease;
  font-family: 'Inter', sans-serif;
  box-shadow: none;
}

.view-button:hover { 
  background-color: var(--hover-color);
  box-shadow: none;
  transform: none;
}

.view-button:active { 
  background-color: var(--hover-color);
  box-shadow: none;
  transform: none;
}

/* Additional Wikipedia styling classes */
.wiki-table {
  overflow-x: auto;
  margin: 1.5em 0;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.8);
  box-shadow: var(--bubble-shadow);
}

body.dark-mode .wiki-table {
  background: rgba(20, 20, 20, 0.85);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: none;
}

.wiki-table table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
}

.wiki-table th,
.wiki-table td {
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  padding: 0.65em 0.9em;
  vertical-align: top;
}

.wiki-table th {
  background: rgba(0, 0, 0, 0.04);
  font-weight: 600;
  text-align: left;
}

body.dark-mode .wiki-table th,
body.dark-mode .wiki-table td {
  border-color: rgba(255, 255, 255, 0.08);
}

body.dark-mode .wiki-table th {
  background: rgba(255, 255, 255, 0.05);
}

.wiki-infobox {
  width: 100%;
  max-width: 420px;
  margin: 0 auto 2em;
  border-radius: 18px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.85);
  box-shadow: var(--bubble-shadow);
  font-size: 0.9em;
  line-height: 1.6;
  overflow: hidden;
  padding: 500px;
}

body.dark-mode .wiki-infobox {
  background: rgba(18, 18, 18, 0.85);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: none;
}

.wiki-infobox th,
.wiki-infobox td {
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  padding: 0.85em 1.2em;
  vertical-align: top;
}

body.dark-mode .wiki-infobox th,
body.dark-mode .wiki-infobox td {
  border-color: rgba(255, 255, 255, 0.08);
}

.wiki-infobox th {
  background: rgba(0, 0, 0, 0.04);
  font-weight: 600;
  text-align: left;
}

body.dark-mode .wiki-infobox th {
  background: rgba(255, 255, 255, 0.05);
}

.wiki-infobox .infobox-image,
.wiki-infobox .infobox-full-data,
.wiki-infobox .infobox-above,
.wiki-infobox .infobox-title {
  text-align: center;
}

.wiki-infobox :is(.infobox-above,
                  .infobox-title,
                  .infobox-header,
                  .infobox-subheader,
                  .infobox-subcaption,
                  .infobox-full-data,
                  .infobox-caption) {
  padding: 0.85em 1.2em;
}

.wiki-infobox .infobox-caption {
  font-size: 0.85em;
  color: rgba(0, 0, 0, 0.65);
  margin-top: 0.75em;
}

body.dark-mode .wiki-infobox .infobox-caption {
  color: rgba(255, 255, 255, 0.65);
}

.wiki-infobox img.wiki-image,
.wiki-infobox img.wiki-infobox-image {
  margin: 0 auto;
  max-width: 100%;
  border-radius: 14px;
  box-shadow: none;
}

.wiki-list {
  margin-left: 0.5em;
}

.wiki-list li {
  padding: 0.2em 0;
}

.wiki-image {
  display: block;
  margin: 1.5em auto;
  max-width: min(100%, 420px);
  width: 100%;
  height: auto;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--bubble-shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.wiki-image:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
}

body.dark-mode .wiki-image {
  background: rgba(18, 18, 18, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

body.dark-mode .wiki-image:hover {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.wiki-inline-image {
  display: inline-block;
  vertical-align: middle;
  margin: 0 4px;
  border-radius: 4px;
  box-shadow: none;
}

figure.wiki-figure {
  margin: 1.8em auto;
  max-width: min(100%, 460px);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 20px;
  padding: 1.2em 1.3em;
  box-shadow: var(--bubble-shadow);
  text-align: center;
}

body.dark-mode figure.wiki-figure {
  background: rgba(20, 20, 20, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

figure.wiki-figure > a,
figure.wiki-figure > img {
  display: block;
}

figure.wiki-figure img.wiki-image {
  margin: 0 auto;
  max-width: 100%;
}

.wiki-figcaption,
figure.wiki-figure figcaption {
  margin-top: 0.9em;
  font-size: 0.9em;
  line-height: 1.5;
  color: rgba(0, 0, 0, 0.65);
}

body.dark-mode .wiki-figcaption,
body.dark-mode figure.wiki-figure figcaption {
  color: rgba(255, 255, 255, 0.7);
}

@media (min-width: 1100px) {
  .wiki-infobox {
    float: right;
    margin-left: 150px;
    margin-right: 0;
    margin-bottom: 2em;
  }
}

.reference {
  color: var(--secondary-color);
  cursor: pointer;
  font-weight: bold;
  padding: 0 2px;
}

.section-divider {
  margin: 2em 0 1em;
  border: none;
  border-bottom: 1px solid var(--border-color);
}

/* Add more space between elements */
#content p + h2,
#content p + h3,
#content ul + h2,
#content ul + h3,
#content ol + h2,
#content ol + h3 {
  margin-top: 2em;
}

/* Enhance inline elements */
#content code {
  background-color: var(--light-gray);
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 0.9em;
  font-family: monospace;
}

body.dark-mode #content code {
  background-color: #2a2a2a;
}

body.serif-font #content {
  font-family: 'Merriweather', serif;
  line-height: 1.8;
}

body.serif-font #content h1, 
body.serif-font #content h2, 
body.serif-font #content h3, 
body.serif-font #content h4, 
body.serif-font #content h5, 
body.serif-font #content h6 {
  font-family: 'Inter', sans-serif;
}

body.chirp-font #content {
  font-family: 'Chirp', sans-serif;
  line-height: 1.6;
}

body.chirp-font #content h1, 
body.chirp-font #content h2, 
body.chirp-font #content h3, 
body.chirp-font #content h4, 
body.chirp-font #content h5, 
body.chirp-font #content h6 {
  font-family: 'Chirp', sans-serif;
  font-weight: 700;
}

.stop-generation-button {
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-color);
  border-radius: 4px;
  padding: 10px 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.3s ease;
  box-shadow: none;
  opacity: 0;
  visibility: hidden;
}

.stop-generation-button:hover {
  box-shadow: none;
  background-color: var(--hover-color);
}

.stop-generation-button.visible {
  display: inline-flex;
}

/* AI specific dark mode overrides removed */

/* Article Index Sidebar Styles */
.article-index {
  grid-column: 1;
  width: 200px;
  min-width: 200px;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
  padding: 16px 12px;
  position: sticky;
  top: 140px;
  font-size: 13px;
  background-color: var(--bg-color);
  z-index: 100;
  
  /* Hide scrollbar but keep functionality */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

/* Hide scrollbar for Chrome, Safari and Opera */
.article-index::-webkit-scrollbar {
  display: none;
}

.article-index.empty {
  display: none;
}

.article-index-header {
  margin-bottom: 15px;
  padding-bottom: 8px;
}

.article-index-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-color);
  margin: 0;
}

#articleIndexList {
  list-style: none;
  padding: 0;
  margin: 0;
}

#articleIndexList li {
  margin-bottom: 8px;
  line-height: 1.3;
}

#articleIndexList a {
  color: var(--text-color);
  text-decoration: none;
  display: block;
  padding: 3px 0;
  transition: color 0.2s ease;
}

#articleIndexList a:hover {
  color: var(--primary-color);
}

/* Indentation for different heading levels */
.index-level-h1 {
  font-weight: 600;
}

.index-level-h2 {
  padding-left: 10px;
}

.index-level-h3 {
  padding-left: 20px;
  font-size: 13px;
}

.index-level-h4 {
  padding-left: 30px;
  font-size: 12px;
}

.index-placeholder {
  color: var(--icon-color);
  font-style: italic;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .content-wrapper {
    grid-template-columns: 1fr;
    padding: 0 16px;
  }
  .article-index {
    display: none;
  }
  /* ai-sidebar tablet rules removed */
}

@media (max-width: 768px) {
  .article-index {
    display: none;
  }
}

/* Summarizer response container */
.summarizer-response-container {
  width: 100%;
  margin: 20px 0;
  padding: 20px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: var(--bg-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  position: relative;
}

.ai-response-text {
  font-size: 16px;
  line-height: 1.6;
  white-space: pre-wrap; /* Ensure proper wrapping of text */
  word-break: break-word; /* Prevent overflow of long words */
  color: var(--text-color);
  padding-bottom: 16px;
  opacity: 1;
  transition: opacity 1s ease-in-out;
}

/* Ensure the response text is visible in dark mode */
body.dark-mode .ai-response-text {
  color: #ffffff;
}

/* Stop generation button */
.stop-generation-button {
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-color);
  border-radius: 4px;
  padding: 10px 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.3s ease;
  box-shadow: none;
  opacity: 0;
  visibility: hidden;
}

.stop-generation-button:hover {
  box-shadow: none;
  background-color: var(--hover-color);
}

.stop-generation-button.visible {
  display: inline-flex;
}

/* Close summary button */
.close-summary-button {
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-color);
  border-radius: 4px;
  padding: 10px 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.3s ease;
  box-shadow: none;
}

.close-summary-button:hover {
  box-shadow: none;
  background-color: var(--hover-color);
}

.close-summary-button:active {
  box-shadow: none;
  background-color: var(--hover-color);
}

/* Summary styles */
.summary-content {
  width: 100%;
  opacity: 1;
  transition: opacity 1s ease-in-out;
}

.summary-content h1 {
  margin-bottom: 20px;
  font-size: 1.8em;
  font-weight: 600;
  color: var(--primary-color);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.3em;
}

.return-to-article-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  padding: 10px 16px;
  background-color: transparent;
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  box-shadow: none;
}

.return-to-article-button:hover {
  background-color: var(--hover-color);
  box-shadow: none;
  transform: none;
}

.return-to-article-button:active {
  background-color: var(--hover-color);
  box-shadow: none;
  transform: none;
}

.ai-disclaimer {
  margin-top: 30px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
  color: var(--icon-color);
  font-style: italic;
}

/* Active summarizer button */
.summarizer-button.active-summarizer {
  background-color: var(--light-gray);
  border-color: var(--primary-color);
}

/* Error message styles */
.error-message {
  padding: 20px;
  margin: 20px 0;
  background-color: #fee2e2;
  color: #b91c1c;
  border: 1px solid #f87171;
  border-radius: 6px;
}

body.dark-mode .error-message {
  background-color: rgba(185, 28, 28, 0.1);
  color: #ef4444;
  border-color: #b91c1c;
}

/* Dark mode styles for summary elements */
body.dark-mode .return-to-article-button {
  background-color: var(--light-gray);
  color: var(--text-color);
}

body.dark-mode .ai-disclaimer {
  color: var(--icon-color);
}

/* Ensure neumorphism works in dark mode */
body.dark-mode .theme-toggle, 
body.dark-mode .font-toggle, 
body.dark-mode .summarizer-button, 
body.dark-mode .bionic-toggle {
  border: 1px solid rgba(255, 255, 255, 0.08);
}

body.dark-mode #searchButton,
body.dark-mode .view-button,
body.dark-mode .return-to-article-button {
  background-color: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

body.dark-mode .theme-toggle:hover, 
body.dark-mode .font-toggle:hover, 
body.dark-mode .summarizer-button:hover, 
body.dark-mode .bionic-toggle:hover {
  background-color: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
}

body.dark-mode #searchButton:hover,
body.dark-mode .view-button:hover,
body.dark-mode .return-to-article-button:hover {
  background-color: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
}

/* AI sidebar button neumorphism removed */

/* Close summary button neumorphism */
.close-summary-button {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--neumorph-bg);
  border: none;
  color: var(--icon-color);
  font-size: 16px;
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: all 0.3s ease;
  border-radius: var(--neumorph-radius);
  box-shadow: var(--neumorph-flat-shadow);
}

.close-summary-button:hover {
  color: var(--text-color);
  box-shadow: var(--neumorph-inset-shadow);
}

.close-summary-button:active {
  transform: translateY(1px);
}

/* Stop generation button with neumorphism */
.stop-generation-button {
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-color);
  border-radius: 4px;
  padding: 10px 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.3s ease;
  box-shadow: none;
  opacity: 0;
  visibility: hidden;
}

.stop-generation-button:hover {
  box-shadow: none;
  background-color: var(--hover-color);
}

/* Input field styling with subtle neumorphism */
#searchQuery {
  flex: 1;
  padding: 12px 16px;
  font-size: 1rem;
  border: none;
  border-radius: var(--neumorph-radius);
  outline: none;
  transition: all 0.3s ease;
  background-color: var(--neumorph-bg);
  font-family: 'Inter', sans-serif;
  box-shadow: var(--neumorph-inset-shadow);
}

#searchQuery:focus {
  box-shadow: inset 4px 4px 8px var(--neumorph-dark-shadow), 
              inset -2px -2px 4px var(--neumorph-light-shadow);
}

/* Make sure dark mode input text is visible */
body.dark-mode #searchQuery {
  color: var(--text-color);
}

/* Active states for toggleable buttons */
body.bionic-mode .bionic-toggle,
body.serif-font .font-toggle,
body.dark-mode .theme-toggle,
body.dark-mode .summarizer-button,
body.dark-mode .bionic-toggle,
.summarizer-button.active-summarizer {
  box-shadow: none;
  transform: none;
  background-color: var(--hover-color);
  border-color: var(--primary-color);
}

/* Dark mode active states */
body.dark-mode.bionic-mode .bionic-toggle,
body.dark-mode.serif-font .font-toggle {
  box-shadow: none;
  background-color: var(--hover-color);
  border-color: var(--primary-color);
}

/* Remove special dark+bionic mode styling that has neumorphic effects */
body.dark-mode.bionic-mode .bionic-toggle,
body.dark-mode.bionic-mode .bionic-toggle:hover {
  background-color: var(--hover-color);
  color: #ffffff;
  box-shadow: none;
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .header-search {
    display: none; /* Hide header search on smaller screens */
  }
}

/* Additional mobile optimizations */
@media (max-width: 480px) {
  .header-content {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .header-right {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    position: relative;
  }

  .header-search {
    width: 100%;
    order: -1;
  }

  .header-controls {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    width: 100%;
  }

  .header-controls button {
    width: 100%;
    padding: 12px 8px;
    font-size: 0.8rem;
  }

  .header-controls button span {
    display: none;
  }

  .header-controls button i {
    font-size: 1.1rem;
  }

  #contentContainer {
    padding: 20px 12px;
  }

  #content {
    font-size: 15px;
    line-height: 1.6;
  }

  #content h1 {
    font-size: 1.8em;
  }

  #content h2 {
    font-size: 1.4em;
  }

  .breadcrumbs {
    font-size: 0.8rem;
    margin: 1rem 0 0.5rem;
  }

  /* ai-sidebar tiny mobile rules removed */
}

/* Link preview tooltip */
.link-preview {
  position: absolute;
  max-width: 260px;
  font-size: 0.9rem;
  background-color: var(--bg-color);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  box-shadow: var(--bubble-shadow);
  padding: 8px 10px;
  border-radius: 8px;
  z-index: 1000;
  display: none;
}

/* Add loading indicator for content */
#content.loading::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-left-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 10;
}

body.dark-mode #content.loading::before {
  border-color: rgba(255, 255, 255, 0.1);
  border-left-color: var(--primary-color);
}

/* Position content container relatively for loading indicator */
#contentContainer {
  position: relative;
}


