.research-session-item.pending-action {
    pointer-events: none;
    opacity: 0.6;
}
:root {
  --primary-bg-color: #fff; /*  Example primary color */
  --secondary-bg-color: #EEEEEE; /* Example secondary color */
  --tertiary-bg-color: #F5F5F5;
  --primary-text-color: #0d0d0d;/* Example success color */
  --secondary-text-color: #5d5d5d; /* Example danger color */
  --tertiary-text-color: #8f8f8f; /* Example tertiary color */
  --blood-orange: #f44336; /* Example blood orange color */
  --link-color: #1E90FF; /* Example link color */
  --visited-link-color: #9F7AEA; /* Example visited link color */
  /* References section links need stronger contrast on white */
  --references-link-color: #0D47A1;
  --references-visited-link-color: #4A148C;
  /* Sidebar links - same contrast treatment */
  --sidebar-link-color: #0D47A1;
  --sidebar-visited-link-color: #4A148C;
  --teal: #20C997;
  --dark-grey: #212121;
  --blue: #2979FF;
}

/* Force dark theme */
html.force-dark,
html[data-theme="dark"] {
  --primary-bg-color: #212121;
  --secondary-bg-color: #2E2E2E;
  --tertiary-bg-color: #2F2F2F;
  --primary-text-color: #fff;
  --secondary-text-color: #f3f3f3;
  --tertiary-text-color: #afafaf;
  --link-color: #63B3ED;
  --visited-link-color: #B794F4;
  --references-link-color: #93C5FD;
  --references-visited-link-color: #C4B5FD;
  --sidebar-link-color: #93C5FD;
  --sidebar-visited-link-color: #C4B5FD;
  --teal: #20C997;
  --dark-grey: #E0E0E0;
  --blue: #5393FF;
  color-scheme: dark;
}

/* Force light theme */
html.force-light,
html[data-theme="light"] {
  --primary-bg-color: #FFFFFF;
  --secondary-bg-color: #F5F5F5;
  --tertiary-bg-color: #EEEEEE;
  --primary-text-color: #212121;
  --secondary-text-color: #757575;
  --tertiary-text-color: #9E9E9E;
  --link-color: #1976D2;
  --visited-link-color: #7B1FA2;
  --references-link-color: #0D47A1;
  --references-visited-link-color: #4A148C;
  --sidebar-link-color: #0D47A1;
  --sidebar-visited-link-color: #4A148C;
  --teal: #20C997;
  --dark-grey: #212121;
  --blue: #2196F3;
  color-scheme: light;
}

/* System theme - use media query */
@media (prefers-color-scheme: dark) {
  html:not(.force-light):not([data-theme="light"]) {
    --primary-bg-color: #212121;
    --secondary-bg-color: #2E2E2E;
    --tertiary-bg-color: #2F2F2F;
    --primary-text-color: #fff;
    --secondary-text-color: #f3f3f3;
    --tertiary-text-color: #afafaf;
    --link-color: #63B3ED;
    --visited-link-color: #B794F4;
    --references-link-color: #93C5FD;
    --references-visited-link-color: #C4B5FD;
    --sidebar-link-color: #93C5FD;
    --sidebar-visited-link-color: #C4B5FD;
    --teal: #20C997;
    --dark-grey: #E0E0E0;
    --blue: #5393FF;
  }
}

body {
  margin: 0;
  font-family: 'Inter var', sans-serif;
  display: flex;
  align-items: flex-start;
  height: 100vh;
  overflow-x: hidden;
  background-color: var(--primary-bg-color);
  color: var(--primary-text-color);
}

/* Screen-reader-only text utility */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
/* Skip link: visible when focused (WCAG 2.4.1 Bypass Blocks) */
.sr-only-focusable:not(:focus) {
  clip: rect(0, 0, 0, 0) !important;
}
.sr-only-focusable:focus {
  position: fixed !important;
  top: 0.5rem !important;
  left: 0.5rem !important;
  z-index: 10000 !important;
  width: auto !important;
  height: auto !important;
  padding: 0.5rem 1rem !important;
  margin: 0 !important;
  overflow: visible !important;
  clip: auto !important;
  white-space: normal !important;
  background: var(--primary-bg-color) !important;
  color: var(--primary-text-color) !important;
  border: 2px solid var(--teal) !important;
  border-radius: 4px !important;
  font-size: 1rem !important;
}

/* Consistent keyboard focus indicator (some components remove outlines) */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid rgba(32, 201, 151, 0.75);
  outline-offset: 2px;
}

/* Share page: hide main content until loadSharedResearch runs (prevents flash) */
html.share-loading .sidebar,
html.share-loading .toggle-btn,
html.share-loading .container,
html.share-loading .scroll-to-bottom-btn,
html.share-loading .share-research-btn,
html.share-loading .modal-overlay {
  visibility: hidden;
}
html.share-loading .bms-share-loading {
  display: flex;
}

/* Share loading overlay - hidden by default, shown when html.share-loading */
.bms-share-loading {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--primary-bg-color);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.bms-share-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--tertiary-bg-color);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: bms-spin 0.8s linear infinite;
}
.bms-share-loading-text {
  font-size: 0.95rem;
  color: var(--secondary-text-color);
}
@keyframes bms-spin {
  to { transform: rotate(360deg); }
}

/* Sidebar Styles */
.sidebar {
  position: fixed;
  top: 0;
  left: -340px;
  width: 300px;
  height: 100%;
  background-color: var(--secondary-bg-color);
  color: var(--primary-text-color);
  padding: 20px;
  transition: left 0.3s ease;
  z-index: 1000;
  font-family: 'Inter var', sans-serif;
  overflow-y: auto;
}

/* Sidebar scrollbar styles for dark mode */
.sidebar::-webkit-scrollbar {
  width: 8px;
}

.sidebar::-webkit-scrollbar-track {
  background: var(--tertiary-bg-color);
  border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--secondary-text-color);
  border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--primary-text-color);
}

.sidebar.open {
  left: 0;
  box-shadow: 2px 0 10px rgba(0, 150, 136, 0.4); /* teal glow */
}

/* Sign In Accordion */
.signin-details {
  background-color: var(--primary-bg-color);
  border: 1px solid var(--teritiary-bg-color);
  border-radius: 10px;
  margin-bottom: 15px;
  padding: 10px 15px;
  font-size: 1rem;
  font-family: 'Inter var', sans-serif;
  line-height: 1.6;
  box-shadow: 0 2px 3px rgba(0, 150, 136, 0.4);
}

.signin-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-weight: 500;
  font-family: 'Inter var', sans-serif;
  font-size: 0.9rem;
  padding: 0.2rem 0.2rem;
  list-style: none;
  gap: 8px;
}

.signin-summary .material-symbols-rounded {
  font-size: 18px;
}

.signin-summary::-webkit-details-marker {
  display: none;
}

.signin-summary::marker {
  content: none;
}

.premium-label {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  padding: 4px 10px;
  border-radius: 8px;
  background: linear-gradient(to right, var(--teal), var(--blue));
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  margin: 0;
  text-align: left;
  width: fit-content;
}

.free-label {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--teal);
  color: black;
  font-size: 0.75rem;
  font-weight: 600;
  margin: 0;
  text-align: left;
  width: fit-content;
}

.signin-summary::after {
  content: '';
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--secondary-text-color);
  transition: transform 0.2s ease;
}

.signin-details[open] .signin-summary::after {
  transform: rotate(180deg);
}

.signin-details-content {
  padding: 10px 0 0 0;
}

.signin-action-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 15px;
  background: linear-gradient(to right, var(--teal), var(--blue));
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: 'Inter var', sans-serif;
  text-decoration: none;
}

.signin-action-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(32, 201, 151, 0.3);
}

/* User Account Accordion - uses same styles as other sidebar details */

.sidebar h1 {
  font-size: 1.5rem;
  margin-bottom: 30px;
  font-family: 'Inter var', sans-serif;
  text-align: center;
}

/* Accordion Details */
.sidebar details {
  background-color: var(--primary-bg-color);
  border: 1px solid var(--teritiary-bg-color);
  border-radius: 10px;
  margin-bottom: 15px;
  padding: 10px 15px;
  font-size: 1rem;
  font-family: 'Inter var', sans-serif;
  line-height: 1.6;
  box-shadow: 0 2px 3px rgba(0, 150, 136, 0.4); /* teal glow */
}

.sidebar details:first-of-type {
  margin-top: 12px; /* Extra space below hamburger menu */
}

.sidebar details:hover {
  transform: translateY(-1px); /* subtle lift */
}

/* Remove the native marker */
.sidebar summary::-webkit-details-marker {
  display: none;
}
.sidebar summary::marker {
  content: none;
}

/* Layout */
.sidebar summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-weight: 500;
  font-family: 'Inter var', sans-serif;
  font-size: 0.9rem;
  padding: 0.2rem 0.2rem;
}

/* Chevron on the right */
.sidebar summary::after {
  content: '';
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg); /* chevron pointing right */
  transition: transform 0.25s ease;
  margin-left: 0.5rem;
}

/* Rotate chevron when open */
.sidebar details[open] > summary::after {
  transform: rotate(135deg); /* chevron pointing down */
}

.sidebar p {
  margin: 10px 0 0;
  font-size: 0.9rem;
  font-family: 'Inter var', sans-serif;
}

.sidebar a {
  color: var(--sidebar-link-color, var(--link-color));
}

.sidebar a:visited {
  color: var(--sidebar-visited-link-color, var(--visited-link-color));
}

.sidebar img {
  align-items: center;
}

.sidebar img:hover {
  cursor: pointer;
}

/* Toggle Button */
.toggle-btn {
  position: fixed;
  top: 20px;
  left: 20px;
  font-size: 2rem;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 1100;
  color: var(--primary-text-color);
}

.toggle-btn:hover {
  transform: translateY(-1px); /* subtle lift */
}

/* Back link on legal pages (terms, privacy) */
.legal-back-link {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
  padding: 0.4rem 0;
  font-size: 0.95rem;
  text-decoration: none;
  color: var(--primary-text-color, #111);
  transition: opacity 0.15s ease;
}
.legal-back-link:hover {
  opacity: 0.8;
}

/* Main Container */
.container {
  margin: 80px auto;
  padding: 50px 20px 0 20px; /* Add 50px padding-top */
  width: 100%;           /* default: full width for mobile */
  max-width: 1200px; 
  flex-grow: 1;
  color: var(--primary-text-color);
  word-wrap: break-word;   /* older syntax */
  overflow-wrap: break-word;
  box-sizing: border-box;
  padding-bottom: 200px; /* ⬅ Adjust to match textarea-wrapper height */
}

/* Mobile container padding adjustment */
@media (max-width: 768px) {
  .container {
    padding: 20px 20px 200px 20px; /* 20px padding-top for mobile */
  }
}

/* Header Box */
.headerBox {
  z-index: 10;
  margin-bottom: 40px; /* Increased spacing between headerBox and searchBox */
  order: 1; /* Ensure headerBox comes first */
}

/* Center headerBox on page load */
.headerBox.centered {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -100%);
  width: 100%;
  max-width: 1200px;
}

/* Move headerBox to top when user searches */
.headerBox.top-positioned {
  position: fixed;
  top: 0;
  left: 0;
  transform: none;
  width: 100%;
  background: var(--primary-bg-color);
  z-index: 100;
  padding: 10px; /* Reduced padding for compact header */
  margin-bottom: 0; /* Remove margin when positioned at top */
  order: unset; /* Reset order when positioned */
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: none; /* Remove border, use pseudo-element for gradient */
}

/* Gradient horizontal line at bottom of headerBox when top-positioned */
.headerBox.top-positioned::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(to right, var(--teal), var(--blue));
}

/* Layout for headerBox when positioned at top - logo left, title/subtitle right */
.headerBox.top-positioned h1:first-child {
  margin-right: 15px;
  margin-bottom: 0;
}

.headerBox.top-positioned h1:first-child img {
  height: 50px;
}

/* Container for title and subtitle */
.headerBox.top-positioned .title-subtitle-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.headerBox.top-positioned .title-subtitle-container h1 {
  margin: 0 0 1px 0;
  font-size: 1.8rem;
}

.headerBox.top-positioned .subtitle {
  margin: 0;
  font-size: 0.9rem;
}

/* Move searchBox to bottom when user searches */
.search-box.bottom-positioned {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 1200px;
  z-index: 50; /* Lower than headerBox but above other content */
  order: unset; /* Reset order when positioned */
}

/* Center searchBox on page load */
.search-box.centered {
  position: fixed;
  top: 40%;
  left: 50%;
  width: 100%;
  max-width: 780px;
}

/* Default search-box styling */
.search-box {
  order: 2; /* Ensure searchBox comes after headerBox */
  width: 100%;
  max-width: 780px;
  margin-top: 20px; /* Additional spacing from headerBox */
}

.container h1 {
  font-size: 2.5rem;
  font-weight: bold;
  margin: 10px 0 1px;
  text-align: center;
}

/* Smaller header elements when positioned at top */
.headerBox.top-positioned h1 {
  font-size: 1.8rem;
  margin: 5px 0 1px;
}

.headerBox.top-positioned h1 img {
  height: 36px;
}

.headerBox.top-positioned .subtitle {
  font-size: 0.9rem;
}

/* Brand title gradient (Bio-Med-Search in headerBox) */
.brand-title {
  background: linear-gradient(to right, var(--teal), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.blue {
  color: var(--blue);
}

.teal {
  color: var(--teal);
}

.dark-grey {
  color: var(--dark-grey);
}

.subtitle {
  font-size: 1rem;
  color: var(--secondary-text-color);
  margin-bottom: 30px;
  font-weight: 400;
  margin-top: 1px;
  text-align: center;
}

.userQuery {
    font-size: 0.9rem;
    color: var(--primary-text-color);
    margin-bottom: 1px;
    margin-left: 5px;
    margin-top: 45px; /* Increased gap between response and next userQuery */
    font-weight: 700;
    text-align: left;
    padding-top: 20px; /* Additional padding for visual separation */
}

/* Horizontal line after userQuery */
.userQuery::after {
  content: '';
  display: block;
  width: 100%;
  height: 3px;
  background-color: var(--teal);
  margin: 15px 0 10px 0;
}

/* Additional spacing when headerBox is positioned at top */
.headerBox.top-positioned ~ .userQuery {
  margin-top: 60px; /* Extra gap when headerBox is at top */
}

.search-box {
  position: fixed;
  width: 100%;
  max-width: 1200px; 
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  gap: 20px;
  background: var(--primary-bg-color);
}







/* Move search box to bottom when user interacts */
.search-box.bottom-positioned {
  top: auto;
  bottom: 0;
  transform: translateX(-50%);
}

/* Ensure textarea maintains default height when search box is bottom-positioned */
.search-box.bottom-positioned .textarea-wrapper textarea {
  height: 100px !important;
  min-height: 100px !important;
}

.textarea-wrapper {
  position: relative;
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
}

/* Container that holds textarea and icon buttons */
.textarea-input-container {
  position: relative;
  display: flex;
  align-items: flex-end; /* keep icons pinned to bottom as textarea grows */
  width: 100%;
}

/* --- Textarea --- */
.textarea-wrapper textarea {
  position: relative;
  width: 100%;
  height: 120px !important;                 /* Default height 120px (accommodates 2 lines with increased bottom padding) */
  min-height: 120px !important;             /* Minimum height 120px */
  padding: 16px 16px 60px 16px !important;  /* Top, Right (same as left), Bottom (above buttons - increased), Left */
  margin: 0 !important;
  font-size: 1em;                      /* 1em font size */
  font-family: 'Inter var', sans-serif;
  border-radius: 25px;                  /* More rounded like modern textboxes */
  border: 1px solid var(--teal);
  background-color: var(--secondary-bg-color);
  color: var(--primary-text-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); /* subtle shadow */
  resize: none;
  overflow: hidden;                     /* Prevent overflow, controlled by JS */
  line-height: 1.5;                     /* Better line height for single line */
  transition: height 0.1s ease;
  box-sizing: border-box;
  word-wrap: break-word;                /* Break long words */
  white-space: pre-wrap;                /* Preserve line breaks but wrap text */
}

/* When bottom-positioned (for followups), use minimal collapsed height by default */
.search-box.bottom-positioned .textarea-wrapper textarea {
  height: 56px !important;                 /* Single-line pill height */
  min-height: 56px !important;
  padding: 14px 16px 14px 16px !important; /* single-line vertical rhythm */
}

/* When bottom-positioned textarea is focused, expand to normal size */
.search-box.bottom-positioned .textarea-wrapper textarea:focus {
  height: 56px !important;
  min-height: 56px !important;
}

.textarea-wrapper textarea:focus {
  outline: none;
  border: 1px solid var(--blue);
  box-shadow: 0 2px 8px rgba(41, 121, 255, 0.2); /* ChatGPT-like focus shadow */
}

/* --- Button Row (Filter on left, Search on right) --- */
.textarea-input-container .textarea-icons {
  position: absolute;
  bottom: 6px;
  left: 6px;
  right: 6px;
  display: flex;
  flex-direction: row;
  gap: 8px;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  pointer-events: none; /* Allow clicks to pass through to textarea when buttons aren't hovered */
}

.textarea-input-container .textarea-icons button {
  pointer-events: auto; /* Re-enable pointer events for buttons */
}

/* --- Search Button Container (below textarea, shown only on initial screen) --- */
.search-button-container {
  width: 100%;
  max-width: 780px;
  margin: 12px auto 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Hide search button container when bottom-positioned (followups use button inside textarea) */
.search-box.bottom-positioned .search-button-container {
  display: none;
}

.textarea-wrapper .filterBtn {
  color: white;
  border: none;
  padding: 4px 8px;
  border-radius: 25px;
  box-shadow: 0 0 6px var(--teal);
  cursor: pointer;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
  z-index: 10;
}

/* Hide search button in button-row on initial screen (only show when bottom-positioned) */
.textarea-input-container .textarea-icons .searchBtn {
  display: none !important;
  color: white;
  border: none;
  padding: 4px 8px;
  border-radius: 25px;
  box-shadow: 0 0 6px var(--teal);
  cursor: pointer;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
  z-index: 10;
}

/* Show search button in button-row ONLY when bottom-positioned (for followups) */
.search-box.bottom-positioned .textarea-input-container .textarea-icons .searchBtn {
  display: flex !important;
}

/* Only apply these styles when the button is visible (bottom-positioned) */
.search-box.bottom-positioned .textarea-input-container .textarea-icons .searchBtn {
  background: var(--secondary-bg-color);
  color: var(--primary-text-color);
  box-shadow: none;
}

.textarea-wrapper .filterBtn {
  background: var(--secondary-bg-color);
  box-shadow: none;
}

.textarea-wrapper .filterBtn .material-symbols-rounded {
  background: linear-gradient(to right, var(--teal), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Filter notification dot */
.filter-icon-wrapper {
  position: relative;
  display: inline-block;
}

.filter-notification-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  background-color: #ff4444;
  border-radius: 50%;
  border: 2px solid var(--primary-bg-color);
  display: block;
  z-index: 11;
}

.filter-notification-dot.hidden {
  display: none;
}

.textarea-wrapper .filterBtn:hover {
  transform: translateY(-1px);
  background: var(--secondary-bg-color);
}

.textarea-wrapper .filterBtn:hover .material-symbols-rounded {
  background: linear-gradient(to right, var(--teal), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.textarea-wrapper .filterBtn:hover .button-label {
  color: var(--primary-text-color);
}

/* Ensure notification dot is visible on hover */
.textarea-wrapper .filterBtn:hover .filter-notification-dot {
  border-color: var(--primary-bg-color);
}

/* Hover effect for search button inside textarea (when bottom-positioned) */
.search-box.bottom-positioned .textarea-input-container .textarea-icons .searchBtn:hover {
  transform: translateY(-1px);
}

/* Disabled state when search is in progress */
.searchBtn:disabled,
.searchBtn[aria-busy="true"] {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

#searchInput:disabled,
#searchInput[aria-busy="true"] {
  opacity: 0.7;
  cursor: not-allowed;
}

.textarea-wrapper .filterBtn .material-symbols-rounded,
.textarea-input-container .textarea-icons .searchBtn .material-symbols-rounded {
  font-size: 1.4rem;
  line-height: 1;
}

.textarea-wrapper .filterBtn .button-label,
.textarea-input-container .textarea-icons .searchBtn .button-label {
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1;
  color: var(--primary-text-color);
  white-space: nowrap;
}

/* Bottom-positioned: icon-only inside textarea */
.search-box.bottom-positioned .textarea-input-container .textarea-icons .button-label {
  display: none;
}

.search-box.bottom-positioned .textarea-input-container .textarea-icons .filterBtn,
.search-box.bottom-positioned .textarea-input-container .textarea-icons .searchBtn {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 9999px;
  background: transparent;
  box-shadow: none;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Bottom-positioned: primary action looks like a circular button (matches screenshot) */
.search-box.bottom-positioned .textarea-input-container .textarea-icons .searchBtn {
  background: var(--teal);
  color: black;
  border: 1px solid var(--teal);
}

.search-box.bottom-positioned .textarea-input-container .textarea-icons .searchBtn .material-symbols-rounded {
  color: black;
  -webkit-text-fill-color: black; /* override any gradient icon styles */
}

.search-box.bottom-positioned .textarea-input-container textarea {
  /* Reserve space so text never touches the icons */
  padding-left: 56px !important;
  padding-right: 72px !important; /* slightly more space on right for the circular search button */
  padding-bottom: 14px !important;
}

/* --- Responsive Tuning --- */
@media (max-width: 650px) {
  .textarea-wrapper {
    width: 98%;
    margin: 0 auto;
  }

  /* Textarea uses same styles as large screens - no overrides needed */
  /* The resize behavior is controlled by JavaScript and works the same on all screen sizes */
  
  .search-button-container {
    width: 98%;
    margin: 10px auto 0 auto;
  }
  
  .search-button-container .searchBtn {
    width: 100%;
    padding: 8px 16px;
    min-width: auto;
    font-size: 0.85rem;
  }
  
  .search-button-container .searchBtn .material-symbols-rounded {
    font-size: 1.1rem;
  }

  .textarea-input-container .textarea-icons {
    bottom: 6px;
    left: 6px;
    right: 6px;
    flex-direction: row;
    gap: 8px;
    justify-content: space-between;
    z-index: 10;
  }

  .textarea-wrapper .filterBtn,
  .textarea-input-container .textarea-icons .searchBtn {
    padding: 4px 8px;
  }
  
  .textarea-wrapper .filterBtn:hover,
  .textarea-input-container .textarea-icons .searchBtn:hover {
    transform: translateY(-1px);
  }

  .textarea-wrapper .filterBtn .material-symbols-rounded,
  .textarea-input-container .textarea-icons .searchBtn .material-symbols-rounded {
    font-size: 1.5rem;
  }
  
  .textarea-wrapper .filterBtn .button-label,
  .textarea-input-container .textarea-icons .searchBtn .button-label {
    font-size: 0.85rem;
  }
  
  /* Mobile adjustments for header elements */
  .headerBox.top-positioned h1:first-child img {
    height: 42px;
  }
  
  .headerBox.top-positioned .title-subtitle-container h1 {
    font-size: 1.5rem;
    margin: 0 0 1px 0;
  }
  
  .headerBox.top-positioned .subtitle {
    font-size: 0.8rem;
  }
  
  .headerBox.top-positioned {
    padding: 8px 15px; /* Even more compact on mobile */
  }
}

/* --- Fade animation for textarea wrapper --- */
#textareaWrapper {
  opacity: 1;
  transition: opacity 0.3s ease;
}

#textareaWrapper.hidden {
  opacity: 0;
  pointer-events: none;
}

.search-box textarea::placeholder {
  color: var(--secondary-text-color);
}

.search-box textarea:focus {
  outline: none;
  border: 1px solid var(--teal);
  box-shadow: 0 0 6px var(--blue);
}

.search-button-container .searchBtn {
  background: var(--teal);
  color: black;
  border: 1px solid var(--teal);
  padding: 10px 24px;
  border-radius: 25px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: 'Inter var', sans-serif;
  transition: all 0.2s ease;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
  min-width: 140px;
}

/* Hover state */
.search-button-container .searchBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 6px var(--blue);
  background: var(--teal);
  color: black;
}

.search-button-container .searchBtn .material-symbols-rounded {
  font-size: 1.2rem;
  color: black;
}

.search-button-container .searchBtn .button-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: black;
}

.sidebar-primary-btn,
.sidebar-filter-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 15px;
  border-radius: 25px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Inter var', sans-serif;
  border: none;
}

.sidebar-primary-btn:focus-visible,
.sidebar-filter-btn:focus-visible {
  outline: 2px solid rgba(32, 201, 151, 0.6);
  outline-offset: 2px;
}

.sidebar-filter-btn {
  background: var(--secondary-bg-color);
  color: var(--primary-text-color);
  border: 1px solid var(--tertiary-text-color);
  box-shadow: 0 0 3px rgba(32, 201, 151, 0.45);
}

.sidebar-filter-btn .material-symbols-rounded {
  font-size: 1.2rem;
  background: linear-gradient(to right, var(--teal), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-filter-btn:hover {
  transform: translateY(-1px);
  background: linear-gradient(to right, var(--teal), var(--blue));
  color: #fff;
  box-shadow: 0 0 3px var(--blue);
}

.sidebar-filter-btn:hover .material-symbols-rounded {
  -webkit-text-fill-color: initial;
  background: none;
  color: #fff;
}

#upgradeToProBtn {
  border: 1px solid var(--teal);
  background: transparent;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
  border-radius: 25px;
  color: var(--primary-text-color);
}

#upgradeToProBtn .material-symbols-rounded {
  font-size: 1.2rem;
  background: linear-gradient(to right, var(--teal), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#upgradeToProBtn > span:not(.material-symbols-rounded) {
  background: linear-gradient(to right, var(--teal), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#upgradeToProBtn:hover {
  background: var(--secondary-bg-color);
  transform: translateY(-1px);
  box-shadow: 0 0 6px var(--blue);
  color: var(--primary-text-color);
}

#upgradeToProBtn:hover .material-symbols-rounded {
  background: linear-gradient(to right, var(--teal), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#upgradeToProBtn:hover > span:not(.material-symbols-rounded) {
  background: linear-gradient(to right, var(--teal), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#researchHistoryBtn {
  border: 1px solid var(--teal);
  background: transparent;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
  border-radius: 25px;
  color: var(--primary-text-color);
}

#researchHistoryBtn .material-symbols-rounded {
  font-size: 1.2rem;
  background: linear-gradient(to right, var(--teal), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#researchHistoryBtn > span:not(.material-symbols-rounded) {
  color: var(--primary-text-color);
}

#researchHistoryBtn:hover {
  background: var(--secondary-bg-color);
  transform: translateY(-1px);
  box-shadow: 0 0 6px var(--blue);
  color: var(--primary-text-color);
}

#researchHistoryBtn:hover .material-symbols-rounded {
  background: linear-gradient(to right, var(--teal), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#researchHistoryBtn:hover > span:not(.material-symbols-rounded) {
  -webkit-text-fill-color: initial;
  background: none;
  color: var(--primary-text-color);
}

#preferencesBtn {
  border: 1px solid var(--teal);
  background: transparent;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
  border-radius: 25px;
}

#preferencesBtn .material-symbols-rounded {
  color: var(--primary-text-color);
  font-size: 1.2rem;
  background: none;
  -webkit-background-clip: initial;
  -webkit-text-fill-color: initial;
  background-clip: initial;
}

#manageSubscriptionBtn {
  border: 1px solid var(--teal);
  background: transparent;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
  border-radius: 25px;
}

#manageSubscriptionBtn .material-symbols-rounded {
  font-size: 1.2rem;
  color: var(--primary-text-color);
  background: none;
  -webkit-background-clip: initial;
  -webkit-text-fill-color: initial;
  background-clip: initial;
}

#signinActionBtn {
  border: 1px solid var(--teal);
  background: transparent;
  color: var(--primary-text-color);
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
  border-radius: 25px;
}

#signinActionBtn .material-symbols-rounded {
  color: var(--primary-text-color);
  font-size: 1.2rem;
}

#signinActionBtn:hover {
  background: var(--secondary-bg-color);
  color: var(--primary-text-color);
  transform: translateY(-1px);
  box-shadow: 0 0 6px var(--blue);
}

#signinActionBtn:hover .material-symbols-rounded {
  color: var(--primary-text-color);
}

/* Sign-in modal button - match sidebar sign-in button style */
#cognitoSignInBtn {
  border: 1px solid var(--teal);
  background: var(--teal);
  color: black;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
  border-radius: 25px;
}

#cognitoSignInBtn .material-symbols-rounded {
  color: black;
  font-size: 1.2rem;
}

#cognitoSignInBtn:hover {
  background: var(--teal);
  color: black;
  transform: translateY(-1px);
  box-shadow: 0 0 6px var(--blue);
  opacity: 0.9;
}

#cognitoSignInBtn:hover .material-symbols-rounded {
  color: black;
}

#continueWithoutSignInBtn {
  background: var(--primary-bg-color);
  color: var(--primary-text-color);
  border: 1px solid var(--tertiary-text-color);
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
}

#continueWithoutSignInBtn:hover {
  background: var(--secondary-bg-color);
  transform: translateY(-1px);
  box-shadow: 0 0 6px var(--blue);
}

#pricingCognitoSignInBtn {
  border: 1px solid var(--teal);
  background: var(--teal);
  color: black;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
  border-radius: 25px;
}

#pricingCognitoSignInBtn .material-symbols-rounded {
  color: black;
  font-size: 1.2rem;
}

#pricingCognitoSignInBtn:hover {
  background: var(--teal);
  color: black;
  transform: translateY(-1px);
  box-shadow: 0 0 6px var(--blue);
  opacity: 0.9;
}

#pricingCognitoSignInBtn:hover .material-symbols-rounded {
  color: black;
}

#logoutBtn {
  border: 1px solid var(--teal);
  background: transparent;
  color: var(--primary-text-color);
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
  border-radius: 25px;
}

#logoutBtn .material-symbols-rounded {
  color: var(--primary-text-color);
  font-size: 1.2rem;
}

#logoutBtn:hover {
  background: var(--secondary-bg-color);
  color: var(--primary-text-color);
  transform: translateY(-1px);
  box-shadow: 0 0 6px var(--blue);
}

#logoutBtn:hover .material-symbols-rounded {
  color: var(--primary-text-color);
}


#preferencesBtn:hover {
  background: var(--secondary-bg-color);
  transform: translateY(-1px);
  box-shadow: 0 0 6px var(--blue);
  color: var(--primary-text-color);
}

#preferencesBtn:hover .material-symbols-rounded {
  color: var(--primary-text-color);
}

#manageSubscriptionBtn:hover {
  background: var(--secondary-bg-color);
  transform: translateY(-1px);
  box-shadow: 0 0 6px var(--blue);
  color: var(--primary-text-color);
}

#manageSubscriptionBtn:hover .material-symbols-rounded {
  color: var(--primary-text-color);
}

#manageSubscriptionBtn:hover {
  background: var(--secondary-bg-color);
  transform: translateY(-1px);
  box-shadow: 0 0 6px var(--blue);
  color: var(--primary-text-color);
}

#manageSubscriptionBtn:hover .material-symbols-rounded {
  color: var(--primary-text-color);
}

/* --- Sample Topics Section --- */
.example-strip {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  margin-top: 5px;
  width: 100%;
  box-sizing: border-box;
  padding-top: 20px;
}

.example-strip {
  overflow: visible; /* allow chip tooltips to extend past edges */
  max-height: 400px; /* must be >= its real content height */
  opacity: 1;
  transition: max-height 0.5s ease, opacity 0.4s ease;
}

.example-strip.hidden {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}


.example-label {
  font-size: 0.9rem;
  color: var(--secondary-text-color);
}

.example-scroll {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 769px;
  margin: 0 auto;
  padding: 5px 10px;
  box-sizing: border-box;
}

.example-scroll::-webkit-scrollbar {
  height: 6px;
}
.example-scroll::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}

@media (min-width: 769px) {
  .example-scroll {
    justify-content: center;   /* center chips on desktop */
    flex-wrap: wrap;           /* wrap nicely for wide screens */
  }
}

/* --- Chip Buttons --- */
.chip {
  flex: 0 1 auto;
  border: 1px solid var(--teal);
  border-radius: 9999px;
  background: transparent;
  color: var(--primary-text-color);
  padding: 7px 14px;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 6px var(--blue);
  background: var(--secondary-bg-color);
}

/* --- Responsive Tweaks --- */
@media (max-width:650px) {

  .example-strip {
    align-items: center;
    padding: 20px 10px 0 10px;
  }

  .example-label {
    font-size: 0.9rem;
    font-weight: 500;
  }

  .example-scroll {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 chips per row */
    gap: 10px;
    justify-items: center;
    padding: 10px 12px;
  }

  .chip {
    width: 100%;              /* fill the grid cell */
    max-width: 160px;         /* keeps good balance */
    font-size: 0.85rem;
    padding: 8px 10px;
  }

  .example-label {
    font-size: 0.85rem;
  }

  .chip {
    font-size: 0.8rem;
    padding: 7px 12px;
  }
}

.response-body {
  display: flex;
  flex-direction: column;
  text-align: left;
  word-wrap: break-word;   /* older syntax */
  overflow-wrap: break-word;
  gap: 0;
}

.response-body button {
  background-color: var(--primary-bg-color);
  color: var(--primary-text-color);
  font-size: 0.7rem;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  align-items: start;
  gap: 8px;
  font-weight: 500;
}

.material-symbols-rounded {
  font-variation-settings:
  'FILL' 0,
  'wght' 400,
  'GRAD' 0,
  'opsz' 24
}

.material-symbols-rounded-fill {
  font-variation-settings:
  'FILL' 1,
  'wght' 400,
  'GRAD' 0,
  'opsz' 24
}

.hidden {
    display: none;
}

.visible {
    display: flex;
    align-items: start;
}

/* Toolbar spacing */
[id^="toolbar-"] {
    margin-top: 15px;
    margin-bottom: 15px;
}

/* Modal toolbar (download button inside modal body, right below content, above scrollbar) */
.modal-body-content {
    flex: 1;
}
.modal-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 15px;
    flex-shrink: 0;
    overflow: visible;
}
.modal-toolbar.hidden {
    display: none;
}
.modal-toolbar.visible {
    display: flex;
}


/* Response Container with its own border */
#response-wrapper {
  border: 1px solid var(--tertiary-text-color);
  border-radius: 15px;
  padding: 20px;
  padding-bottom: 15px;
  margin-top: 25px;
  margin-bottom: 25px; /* Increased margin for better separation */
  background-color: var(--primary-bg-color);
  box-shadow: 0 2px 3px #20C997;
  display: none; /* optional: hide until content is injected */
  font-family: 'Inter var', sans-serif;
}

#response-wrapper.show {
  display: block;
}

/* Markdown inside response */
.markdown-body h3,
.markdown-body h2 {
  margin-top: 0;
  margin-bottom: 0;
  font-size: 1.5rem;
  color: var(--primary-text-color);
}

.markdown-body p, li {
  line-height: 1.5 !important;

}

.markdown-body a:link {
  color: var(--link-color)
}

.markdown-body a:visited {
  color: var(--visited-link-color);
}

.references-section.hidden {
  display: none;
}

.references-section.visible {
  display: block;
}

.references-section h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--primary-text-color);
}

.references-section ol {
  margin: 0;
  margin-top: 0.5rem;
  padding-left: 2rem;
  list-style-position: outside;
}

.references-section li {
  margin-bottom: 0.75rem;
  line-height: 1.6;
  color: var(--primary-text-color);
}

.references-section a {
  color: var(--references-link-color, var(--link-color));
  text-decoration: none;
}

.references-section a:hover {
  text-decoration: underline;
}

.references-section a:visited {
  color: var(--references-visited-link-color, var(--visited-link-color));
}

/* Footer note: "X results found" (left) and search date (right) */
[id^="footer-note-"] {
  width: 100%;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}
[id^="footer-note-"] .footer-note-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin: 0;
  width: 100%;
}
[id^="footer-note-"] .footer-note-date {
  flex-shrink: 0;
  margin-left: auto;
  color: var(--primary-text-color);
}

.markdown-body table {
  border-collapse: collapse; /* Ensures borders are collapsed for a clean look */
  width: 100%;
  max-width: 100%;
  display: table;
  table-layout: auto;
}

.markdown-body th, td {
  border: 1px solid var(--secondary-text-color); /* Adds a 1px solid light gray border to cells */
  padding: 8px; /* Adds padding inside cells for readability */
  text-align: left; /* Optional: Aligns text to the left */
}

.markdown-body th {
  background-color: var(--secondary-bg-color); /* Optional: Different background for headers */
  color: var(--primary-text-color) !important;
}

@media (max-width: 750px) {
  .icon-btn::after {
    content: attr(data-tooltip);
    display: block;
    font-size: 0.50rem;
    color: var(--tertiary-text-color);
    margin-top: 3px;
    text-align: center;
  }

  /* Allow Citation Styles button to shrink so label wraps like other toolbar buttons */
  [id^="toolbar-"] .citation-format-actions {
    flex-shrink: 1;
    min-width: 0;
  }

  /* Modal toolbar buttons: stack icon and label like toolbar buttons */
  .modal-toolbar button[id^="modal-copy-"],
  .modal-toolbar button[id^="modal-download-"] {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 1;
    min-width: 0;
    max-width: 90px;
  }
  .modal-toolbar button[id^="modal-copy-"] {
    max-width: 72px;
  }
  .modal-toolbar button[id^="modal-copy-"]::after,
  .modal-toolbar button[id^="modal-download-"]::after {
    max-width: 90px;
    white-space: normal;
    text-align: center;
  }
  .modal-toolbar button[id^="modal-copy-"]::after {
    max-width: 72px;
  }
}

small .material-symbols-rounded {
  font-size: 1.25em;   /* makes it scale with <small> */
  vertical-align: middle; /* optional: align with text */
}

.icon-btn {
  position: relative;
  background: none;       /* remove default button background */
  border: none;           /* remove default border */
  cursor: pointer;        /* show hand cursor on hover */
  border-radius: 10px;
  padding: 4px 8px;
  color: var(--primary-text-color); /* Use CSS variable for proper dark mode support */
}

/* Custom tooltip - appears quickly (100ms) vs native title (~1s) */
@media (min-width: 751px) {
  .icon-btn::before {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 10px;
    background: var(--primary-text-color);
    color: var(--primary-bg-color);
    font-size: 0.75rem;
    font-family: 'Inter var', sans-serif;
    white-space: nowrap;
    border-radius: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease;
    transition-delay: 0.05s;
    z-index: 100;
  }
  .icon-btn:hover::before {
    opacity: 1;
  }

  /* userQuery-actions (more_vert): same tooltip style as toolbar icon buttons */
  .userQuery-actions-btn::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px); /* show tooltip above button */
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 10px;
    background: var(--primary-text-color);
    color: var(--primary-bg-color);
    font-size: 0.75rem;
    font-family: 'Inter var', sans-serif;
    white-space: nowrap;
    border-radius: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease;
    transition-delay: 0.05s;
    z-index: 100;
  }
  .userQuery-actions-btn:hover::before {
    opacity: 1;
  }

  /* Share Research Topic button: tooltip above button */
  .share-research-btn::before {
    content: attr(data-tooltip);
    position: absolute;
    top: auto;
    bottom: calc(100% + 8px);
    right: 0;
    left: auto;
    transform: none;
    padding: 6px 10px;
    background: var(--primary-text-color);
    color: var(--primary-bg-color);
    font-size: 0.75rem;
    font-family: 'Inter var', sans-serif;
    white-space: nowrap;
    border-radius: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease;
    transition-delay: 0.05s;
    z-index: 100;
  }
  .share-research-btn:hover::before {
    opacity: 1;
  }
  /* Scroll to bottom button: same tooltip style, shown above button (button is at bottom of viewport) */
  .scroll-to-bottom-btn::before {
    content: attr(data-tooltip);
    position: absolute;
    top: auto;
    bottom: calc(100% + 8px);
    right: 0;
    left: auto;
    transform: none;
    padding: 6px 10px;
    background: var(--primary-text-color);
    color: var(--primary-bg-color);
    font-size: 0.75rem;
    font-family: 'Inter var', sans-serif;
    white-space: nowrap;
    border-radius: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease;
    transition-delay: 0.05s;
    z-index: 100;
  }
  .scroll-to-bottom-btn:hover::before {
    opacity: 1;
  }

  /* Example strip chips: same tooltip style as toolbar buttons */
  .example-strip {
    padding-bottom: 56px; /* room for tooltip below chips (avoid overflow clip) */
  }
  .example-chip {
    position: relative;
  }
  .example-chip::before {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 10px;
    background: var(--primary-text-color);
    color: var(--primary-bg-color);
    font-size: 0.75rem;
    font-family: 'Inter var', sans-serif;
    white-space: normal;
    max-width: 280px;
    width: max-content;
    text-align: center;
    border-radius: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease;
    transition-delay: 0.05s;
    z-index: 100;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .example-chip:hover::before {
    opacity: 1;
  }

  /* Modal toolbar buttons: position tooltip above and left-align to avoid clipping */
  .modal-toolbar button[id^="modal-copy-"]::before,
  .modal-toolbar button[id^="modal-download-"]::before {
    top: auto;
    bottom: calc(100% + 8px);
    left: 0;
    transform: none;
  }
}

/* Hover state - match suggestion buttons */
.icon-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 6px var(--blue);
  background: var(--secondary-bg-color);
}

/* Ensure material icons inherit proper color */
.icon-btn .material-symbols-rounded {
  color: inherit;
  font-size: 1.5rem;
}

/* PubMed and Compare buttons with gradient icon color */
button[id^="pubmedbtn-"] .material-symbols-rounded,
button[id^="comparebtn-"] .material-symbols-rounded,
button[id^="modal-download-"] .material-symbols-rounded,
button[id^="modal-copy-"] .material-symbols-rounded {
  background: linear-gradient(to right, var(--teal), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Enhanced hover for gradient buttons (keep elevation, no gradient background, icon keeps gradient) */
button[id^="pubmedbtn-"]:hover,
button[id^="comparebtn-"]:hover,
button[id^="modal-download-"]:hover,
button[id^="modal-copy-"]:hover {
  transform: translateY(-1px);
}

button[id^="pubmedbtn-"]:hover .material-symbols-rounded,
button[id^="comparebtn-"]:hover .material-symbols-rounded,
button[id^="modal-download-"]:hover .material-symbols-rounded,
button[id^="modal-copy-"]:hover .material-symbols-rounded {
  background: linear-gradient(to right, var(--teal), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* FAQ section headers (General Information, Usage & Features) */
#FAQ h4 {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--primary-text-color);
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}
#FAQ h4:first-child {
  margin-top: 0;
}

/* FAQ question lines (bold at start of each Q&A block) – slightly larger */
#FAQ p > strong:first-child {
  font-size: 1.1em;
}

/* FAQ inline icons: match toolbar icon styling */
#FAQ .faq-inline-icon {
  font-size: 1.25em;
  vertical-align: middle;
  background: linear-gradient(to right, var(--teal), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
/* more_vert icon in FAQ: use primary text color instead of gradient */
#FAQ .faq-inline-icon.faq-icon-primary {
  color: var(--primary-text-color);
  background: none;
  -webkit-background-clip: unset;
  -webkit-text-fill-color: unset;
  background-clip: unset;
}

.footer {
  flex-shrink: 0; /* Prevent the footer from shrinking */
  text-align: center;
  font-size: 0.85rem;
  display: none;
}

.footer.show {
  display: block;
}

/* Site-wide footer (index search-footer and legal pages) */
.site-footer {
  display: block;
  flex-shrink: 0;
  text-align: center;
  font-size: 0.85rem;
  margin-top: 1.5rem;
  padding: 0.75rem 10px 1.5rem;
  color: var(--primary-text-color, #333);
}
.site-footer a {
  color: var(--primary-text-color, #333);
  text-decoration: underline;
}
.site-footer a:hover {
  opacity: 0.85;
}

/* Search footer styling (index page) - fixed at bottom of viewport */
#search-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 0.5rem 10px 0.75rem;
  background: var(--primary-bg-color);
  z-index: 50;
  font-size: 0.85rem;
  color: var(--secondary-text-color);
}
#search-footer p {
  margin: 0;
}

/* When search box is bottom-positioned, make footer part of search box (below textarea) */
.search-box.bottom-positioned #search-footer {
  position: static;
  bottom: auto;
  left: auto;
  right: auto;
  width: auto;
  margin-top: 0;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}
.search-box.bottom-positioned #search-footer p {
  margin: 0;
}

/* Legal pages (pricing, terms, privacy): fix footer at bottom of viewport */
footer.site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 0.5rem 10px 0.75rem;
  background: var(--primary-bg-color);
  z-index: 50;
}
footer.site-footer p {
  margin: 0;
}
/* Reserve space at bottom so content isn't hidden behind fixed footer */
.container:has(> footer.site-footer) {
  padding-bottom: 4rem;
}

/* Free plan remaining message (when 7–9 or 10 searches used), shown above textarea */
.free-plan-remaining-msg {
  text-align: center;
  font-size: 0.85rem;
  color: var(--primary-text-color);
  font-weight: 600;
  margin: 0;
  padding: 0;
}
.free-plan-remaining-msg a {
  background: linear-gradient(to right, var(--teal), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: underline;
}
.free-plan-remaining-msg a:hover {
  background: linear-gradient(to right, var(--blue), var(--teal));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
/* When 3 or fewer searches left (same primary text color) */
.free-plan-remaining-msg.free-plan-remaining-msg--low {
  color: var(--primary-text-color);
}

.fair-use-threshold-msg {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--secondary-text-color, #666);
  font-weight: 600;
  margin: 0 0 0.35rem 0;
  padding: 0;
}
.fair-use-threshold-msg .fair-use-threshold-icon {
  font-size: 1.1rem;
}

.footer img:hover {
  cursor: pointer;
  transform: translateY(-1px); /* subtle lift */
}

#loader {
      display: flex;
      align-items: center;
      justify-content: left;
      gap: 8px; /* space between spinner and text */
      font-family: 'Inter var', sans-serif;
      font-size: 0.9rem;
      font-weight: 500;
      color: var(--secondary-text-color);
    }

.spinner {
      width: 1em;   /* scale with text size */
      height: 1em;  /* ensure circle */
      border: 0.2em solid var(--secondary-bg-color);
      border-top: 0.2em solid #20C997;
      border-radius: 50%;
      box-sizing: border-box; /* keeps proportions consistent */
      animation: spin 1s linear infinite;
      flex-shrink: 0; /* don’t let flexbox distort it */
    }

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

/* Suggested chips styles */
.suggested-chips-container {
    margin-top: 20px;
    margin-bottom: 30px;
    padding: 15px 0;
    max-width: 100%;
    box-sizing: border-box;
}

.suggested-chips-title {
    font-size: 0.9rem;
    color: var(--secondary-text-color);
    margin-bottom: 20px;
    font-weight: 600;
}

.suggested-chips-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    max-width: 100%;
    box-sizing: border-box;
}

.suggested-chip {
    background: transparent;
    color: var(--primary-text-color);
    border: 1px solid var(--teal);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
    max-width: calc(50% - 7.5px);
    flex: 1 1 auto;
    min-width: 0;
    min-height: auto;
    height: auto;
    line-height: 1.4;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.suggested-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 6px var(--blue);
    background: var(--secondary-bg-color);
}

@media (max-width: 650px) {
    .suggested-chips-container {
        margin-top: 15px;
        margin-bottom: 25px;
        padding: 10px 0;
    }
    
    .suggested-chips-title {
        font-size: 0.85rem;
        margin-bottom: 8px;
    }
    
    .suggested-chip {
        font-size: 0.8rem;
        padding: 6px 12px;
        max-width: 100%;
        flex: 1 1 100%;
    }
}

/* Edit functionality styles */
.userQuery-container {
    display: flex;
    align-items: center;
    width: 100%;
    padding-bottom: 15px;
}

.userQuery-container:not(:first-of-type) {
    padding-top: 20px;
}

.userQuery-container .userQuery {
    flex: 1;
    margin: 0;
    margin-right: 10px;
}

.edit-icon-btn {
    flex-shrink: 0;
}

/* UserQuery actions menu (more_vert button) */
.userQuery-actions {
    position: relative;
    flex-shrink: 0;
}

.userQuery-actions-btn {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    color: var(--secondary-text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.userQuery-actions-btn:hover {
    background: var(--secondary-bg-color);
    color: var(--primary-text-color);
}

.userQuery-actions-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--primary-bg-color);
    border: 1px solid var(--tertiary-text-color);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
    display: none;
    min-width: 160px;
    z-index: 10;
    padding: 6px 0;
}

/* On small screens, ensure menu stays within viewport */
@media (max-width: 768px) {
    .userQuery-actions-menu {
        right: 0;
        max-width: calc(100vw - 20px);
        transform: translateX(0);
    }
}

.userQuery-actions-menu.open {
    display: block;
    pointer-events: auto;
}

.userQuery-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    font-size: 0.9rem;
    color: var(--primary-text-color);
    cursor: pointer;
    font-family: 'Inter var', sans-serif;
}

.userQuery-menu-item:hover {
    background: var(--secondary-bg-color);
}

.userQuery-menu-item .material-symbols-rounded {
    font-size: 1.2rem;
    color: var(--primary-text-color);
}

.citation-format-actions .userQuery-menu-item {
    justify-content: space-between;
}
.citation-format-actions .citation-format-check {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.edit-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.edit-textarea {
    width: 100%;
    height: auto;
    min-height: 1.5em !important;
    max-height: 120px;
    padding: 0.75em 1em !important;
    font-size: 1em;
    font-family: 'Inter var', sans-serif;
    border-radius: 25px;
    border: 1px solid var(--teal);
    background-color: var(--secondary-bg-color);
    color: var(--primary-text-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    resize: none;
    overflow: hidden;
    line-height: 1.5;
    transition: all 0.2s ease-out;
    box-sizing: border-box;
}

.edit-textarea:focus {
    outline: none;
    border: 1px solid var(--teal);
    box-shadow: 0 0 6px var(--blue);
}

.edit-button-container {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
}

.edit-search-btn {
    background: var(--teal);
    color: black;
    border: 1px solid var(--teal);
    padding: 10px 24px;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: 'Inter var', sans-serif;
    transition: all 0.2s ease;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
}

.edit-search-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 6px var(--blue);
    background: var(--teal);
    color: black;
}

.edit-cancel-btn {
    padding: 10px 24px;
    border-radius: 25px;
    border: 1px solid var(--teal);
    background: transparent;
    color: var(--primary-text-color);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
}

.edit-cancel-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 6px var(--blue);
    background: var(--secondary-bg-color);
}

@media (max-width: 650px) {
    .edit-textarea {
        min-height: 1.5em !important;
        height: auto;
        font-size: 1em;
        width: 100%;
        padding: 0.75em 1em !important;
        max-height: 100px;
        min-width: 0;
    }

    .edit-search-btn,
    .edit-cancel-btn {
        padding: 10px 16px;
        font-size: 0.9rem;
        min-height: 44px;
        box-sizing: border-box;
    }
}

/* New search button styles */
.new-search-button-container {
    display: flex;
    justify-content: center;
    margin-top: 20px;
    margin-bottom: 10px;
}

.new-search-button {
    background: var(--teal);
    color: black;
    border: 1px solid var(--teal);
    padding: 10px 24px;
    border-radius: 25px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
}

.new-search-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 6px var(--blue);
    background: var(--teal);
    color: black;
}

.new-search-button .material-symbols-rounded {
    font-size: 1.2rem;
    color: black;
}

@media (max-width: 650px) {
    .new-search-button {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
    
    .new-search-button .material-symbols-rounded {
        font-size: 1.1rem;
    }
}

/* Compare Studies Modal Styles */
/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1100;
    padding: 20px;
    box-sizing: border-box;
    animation: fadeIn 0.3s ease;
}

.modal-overlay.hidden {
    display: none;
}

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

/* Modal Content */
.modal-content {
    background: var(--primary-bg-color);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
    overflow: hidden;
}

/* Increase modal size for large screens */
@media (min-width: 1200px) {
    .modal-content {
        max-width: 1200px;
        width: 95%;
        max-height: 95vh;
    }
    
    /* Filter modal - keep smaller size on large screens */
    #filterModal .modal-content {
        max-width: 600px;
        width: 90%;
    }
    
    .modal-body table {
        font-size: 1rem;
    }
    
    .modal-body table th,
    .modal-body table td {
        padding: 14px 18px;
    }
}

@media (min-width: 1600px) {
    .modal-content {
        max-width: 1400px;
        width: 95%;
    }
    
    /* Filter modal - keep smaller size on very large screens */
    #filterModal .modal-content {
        max-width: 600px;
        width: 90%;
    }
    
    .modal-body table {
        font-size: 1.05rem;
    }
    
    .modal-body table th,
    .modal-body table td {
        padding: 16px 20px;
    }
}

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

/* Modal Header */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: none; /* Remove border, use pseudo-element for gradient */
    background: var(--secondary-bg-color);
    position: relative; /* Ensure pseudo-element positioning works */
}

/* Gradient horizontal line at bottom of modal header */
.modal-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(to right, var(--teal), var(--blue));
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-text-color);
}

.modal-close-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--primary-text-color);
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.modal-close-btn:hover {
    background: var(--tertiary-text-color);
    color: var(--primary-bg-color);
}

.modal-close-btn .material-symbols-rounded {
    font-size: 1.5rem;
}

/* Modal Body */
.modal-body {
    padding: 24px;
    color: var(--primary-text-color);
    font-family: 'Inter var', sans-serif;
    overflow-y: auto;
    flex: 1;
}

.modal-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 0.9rem;
    table-layout: auto;
    word-wrap: break-word;
    overflow-wrap: break-word;
    background: var(--primary-bg-color);
}

.summary-table-modal-body table {
    box-shadow: 0 2px 8px color-mix(in srgb, var(--blue) 25%, transparent);
}

.modal-body table th,
.modal-body table td {
    padding: 12px 16px;
    text-align: left;
    border: 1px solid var(--teal);
    vertical-align: top;
    word-wrap: break-word;
    overflow-wrap: break-word;
    color: var(--primary-text-color);
}

.modal-body table th {
    font-weight: 700;
    background: var(--secondary-bg-color);
    white-space: nowrap;
}

.modal-body table td {
    font-weight: 400;
    background: var(--primary-bg-color);
    line-height: 1.5;
    white-space: normal;
    word-break: break-word;
}

.modal-body table thead {
    background: var(--primary-bg-color);
}

.modal-body table tbody {
    background: var(--primary-bg-color);
}

.modal-body p {
    margin: 15px 0;
    line-height: 1.6;
}

.compare-loading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    justify-content: center;
}

.compare-loading .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--tertiary-text-color);
    border-top-color: var(--teal);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.compare-error {
    color: var(--primary-text-color);
    padding: 20px;
    background: var(--secondary-bg-color);
    border-radius: 8px;
    border: 1px solid var(--tertiary-text-color);
    font-size: 1rem;
    line-height: 1.6;
    text-align: center;
    margin: 20px 0;
}

/* Sign In Modal Styles */
.signin-modal-content {
    max-width: 450px;
}

.signin-modal-body {
    padding: 30px 20px;
}

.signin-modal-body > p {
    text-align: center;
    margin-bottom: 25px;
    color: var(--secondary-text-color);
    font-size: 0.95rem;
}

.signin-modal-body > p a {
    color: var(--link-color);
    text-decoration: underline;
    transition: color 0.2s ease;
}

.signin-modal-body > p a:hover {
    color: var(--visited-link-color);
    text-decoration: underline;
}

.gradient-text {
    background: linear-gradient(to right, var(--teal), var(--blue));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    font-weight: 600;
}

.signin-buttons {
    display: flex;
    flex-direction: row;
    gap: 12px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

/* Google Sign-In container to center and stretch the rendered button */
.google-signin-container {
  width: 100%;
  min-height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Ensure the rendered iframe/button fills the container nicely */
#googleSignInBtn > div,
#googleSignInBtn iframe {
  width: 100% !important;
  max-width: 100% !important;
}

/* Loading placeholder for Google button */
.google-signin-container:empty::before {
  content: '';
  display: block;
  width: 40px;
  height: 40px;
  border: 4px solid var(--secondary-bg-color);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.signin-provider-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 14px 20px;
    border: 2px solid var(--tertiary-text-color);
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Inter var', sans-serif;
    background: var(--primary-bg-color);
    color: var(--primary-text-color);
}

.signin-provider-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: var(--teal);
}

.google-signin:hover {
    border-color: var(--blue);
}

.apple-signin {
    background: var(--primary-text-color);
    color: var(--primary-bg-color);
    border-color: var(--primary-text-color);
}

.apple-signin:hover {
    background: var(--secondary-text-color);
    border-color: var(--secondary-text-color);
}

.signin-provider-btn svg {
    flex-shrink: 0;
}

.signin-provider-btn span {
    font-size: 1rem;
    font-weight: 500;
}

/* Filter Modal Styles */
.filter-section {
    margin-bottom: 20px;
}

.filter-section.with-divider {
    padding-bottom: 20px;
    border-bottom: 1px solid var(--tertiary-text-color);
    margin-bottom: 25px;
}

.filter-section h4 {
    margin: 0 0 15px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-text-color);
}

.pub-type-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.pub-type-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--primary-text-color);
    background: var(--secondary-bg-color);
    border: 1px solid transparent;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.pub-type-chip:hover {
    background: var(--secondary-bg-color);
    border-color: var(--teal);
    color: var(--teal);
}

.pub-type-chip input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.pub-type-chip:has(input:checked) {
    background: var(--teal);
    color: black;
    border-color: var(--teal);
}

.pub-type-chip:has(input:checked):hover {
    background: var(--teal);
    color: black;
    opacity: 0.92;
}

.publication-year-wrap {
    margin-bottom: 20px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--secondary-bg-color);
}

.publication-year-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
    overflow-x: auto;
    overflow-y: hidden;
}

.pub-year-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--primary-text-color);
    background: var(--secondary-bg-color);
    border: 1px solid transparent;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.pub-year-pill:hover {
    background: var(--secondary-bg-color);
    border-color: var(--teal);
    color: var(--teal);
}

.pub-year-pill input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.pub-year-pill:has(input:checked) {
    background: var(--teal);
    color: black;
    border-color: var(--teal);
}

.pub-year-pill:has(input:checked):hover {
    background: var(--teal);
    color: black;
    opacity: 0.92;
}

.pub-year-custom {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

@media (min-width: 600px) {
    .pub-year-custom {
        gap: 24px;
    }
}

.pub-year-custom.hidden {
    display: none;
}

.pub-year-sep {
    font-size: 0.95rem;
    color: var(--primary-text-color);
    font-weight: 500;
}

.pub-year-custom input[type="number"] {
    width: 100px;
    padding: 6px 10px;
    font-size: 0.95rem;
    border: 1px solid var(--secondary-bg-color);
    border-radius: 6px;
    background: var(--primary-bg-color);
    color: var(--primary-text-color);
}

.pub-year-custom input[type="number"]:focus {
    outline: none;
    border-color: var(--teal);
}

.publication-year-slider {
    width: 100%;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--secondary-bg-color);
}

.year-range-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 400;
    font-size: 0.95rem;
    color: var(--primary-text-color);
    margin-bottom: 12px;
}

.year-range-header span {
    display: flex;
    gap: 4px;
}

.year-range-header #pubYearStartLabel,
.year-range-header #pubYearEndLabel {
    min-width: 3ch;
    text-align: right;
    font-weight: 600;
}

.year-range-container {
    position: relative;
    width: 100%;
    padding: 16px 0 24px;
}

.year-range-track {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 6px;
    background: var(--secondary-bg-color);
    border-radius: 999px;
    transform: translateY(-50%);
}

.year-range-fill {
    position: absolute;
    top: 50%;
    height: 6px;
    background: linear-gradient(to right, var(--teal), var(--blue));
    border-radius: 999px;
    transform: translateY(-50%);
}

.year-range-input {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    height: 100%;
    margin: 0;
    background: none;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
}

.year-range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-bg-color);
    border: 2px solid var(--primary-text-color);
    box-shadow: 0 0 10px rgba(13, 13, 13, 0.4);
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.year-range-input::-moz-range-thumb,
.year-range-input::-ms-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-bg-color);
    border: 2px solid var(--primary-text-color);
    box-shadow: 0 0 10px rgba(13, 13, 13, 0.4);
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.year-range-input::-webkit-slider-thumb:hover,
.year-range-input::-moz-range-thumb:hover,
.year-range-input::-ms-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 0 12px rgba(13, 13, 13, 0.45);
}

.year-range-input::-webkit-slider-runnable-track,
.year-range-input::-moz-range-track,
.year-range-input::-ms-track {
    width: 100%;
    height: 6px;
    background: transparent;
    border-color: transparent;
    color: transparent;
}

.year-range-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary-text-color);
    background: var(--primary-bg-color);
    padding: 4px 10px;
    border-radius: 6px;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.12);
    position: absolute;
    top: 12px;
    transform: translate(-50%, -100%);
    pointer-events: none;
}

@media (max-width: 650px) {
    .year-range-container {
        padding: 20px 0 20px;
    }

    .year-range-header {
        font-size: 0.9rem;
    }
}

.filter-error-msg {
    color: #ff4444;
    font-size: 0.9rem;
    margin: -10px 0 15px 0;
    padding: 10px;
    background-color: rgba(255, 68, 68, 0.1);
    border: 1px solid rgba(255, 68, 68, 0.3);
    border-radius: 6px;
}

.filter-error-msg.hidden {
    display: none;
}

.filter-actions-section {
    margin-top: 20px;
    padding-top: 0;
    border-top: 1px solid var(--secondary-bg-color);
}

.filter-modal-note {
    font-size: 0.75rem;
    color: var(--secondary-text-color);
    margin: 0 0 12px 0;
    line-height: 1.35;
}

.filter-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.apply-filter-btn {
    padding: 10px 24px;
    border-radius: 25px;
    border: 1px solid var(--teal);
    background: var(--teal);
    color: black;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
}

.apply-filter-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 6px var(--blue);
    background: var(--teal);
    color: black;
}

.reset-filter-btn {
    padding: 10px 24px;
    border-radius: 25px;
    border: 1px solid var(--teal);
    background: transparent;
    color: var(--primary-text-color);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
}

.reset-filter-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 6px var(--blue);
    background: var(--secondary-bg-color);
}

/* Filter Modal - Blurred state for non-Pro users */
.modal-content.blurred {
    filter: blur(4px);
    pointer-events: none;
    user-select: none;
}

.filter-upgrade-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1001;
    text-align: center;
}

.filter-upgrade-message a {
    display: inline-block;
    padding: 10px 24px;
    border-radius: 25px;
    background: linear-gradient(135deg, var(--teal), var(--blue));
    color: white;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
}

.filter-upgrade-message a:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 6px var(--blue);
}

/* Summary Table Modal - Blurred state for non-Pro users */
.summary-table-preview-blurred table th,
.summary-table-preview-blurred table td {
    border-color: var(--teal) !important;
}

.summary-table-preview-blurred {
    filter: blur(4px);
    pointer-events: none;
    user-select: none;
}

.modal-body:has(.summary-table-preview-blurred) {
    position: relative;
}

.summary-table-upgrade-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1001;
    text-align: center;
}

.summary-table-upgrade-message a {
    display: inline-block;
    padding: 10px 24px;
    border-radius: 25px;
    background: linear-gradient(135deg, var(--teal), var(--blue));
    color: white;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
}

.summary-table-upgrade-message a:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 6px var(--blue);
}

/* PubMed Results Upgrade Overlay */
.pubmed-upgrade-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

html.force-light .pubmed-upgrade-overlay,
html[data-theme="light"] .pubmed-upgrade-overlay {
    background: rgba(255, 255, 255, 0.9);
}

@media (prefers-color-scheme: light) {
    html:not(.force-dark):not([data-theme="dark"]) .pubmed-upgrade-overlay {
        background: rgba(255, 255, 255, 0.9);
    }
}

.pubmed-upgrade-overlay.hidden {
    display: none;
}

.pubmed-upgrade-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    text-align: center;
}

.pubmed-upgrade-subtext {
    color: var(--primary-text-color);
    font-size: 1.1rem;
    margin: 0;
    font-weight: 500;
}

.pubmed-upgrade-button {
    display: inline-block;
    padding: 12px 32px;
    border-radius: 25px;
    background: linear-gradient(135deg, var(--teal), var(--blue));
    color: white;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
}

.pubmed-upgrade-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 6px var(--blue);
}

/* Search Limit Overlay */
.search-limit-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
    padding: 20px;
    box-sizing: border-box;
}

html.force-light .search-limit-overlay,
html[data-theme="light"] .search-limit-overlay {
    background: rgba(255, 255, 255, 0.9);
}

@media (prefers-color-scheme: light) {
    html:not(.force-dark):not([data-theme="dark"]) .search-limit-overlay {
        background: rgba(255, 255, 255, 0.9);
    }
}

.search-limit-overlay.hidden {
    display: none;
}

.search-limit-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    text-align: center;
    padding: 20px;
    max-width: 90%;
    width: 100%;
    box-sizing: border-box;
}

.search-limit-subtext {
    color: var(--primary-text-color);
    font-size: 1.1rem;
    margin: 0;
    font-weight: 500;
    line-height: 1.5;
}

.search-limit-button {
    display: inline-block;
    padding: 12px 32px;
    border-radius: 25px;
    background: linear-gradient(135deg, var(--teal), var(--blue));
    color: white;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
}

.search-limit-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 6px var(--blue);
}

@media (max-width: 650px) {
    .search-limit-overlay {
        padding: 20px;
        box-sizing: border-box;
    }
    
    .search-limit-container {
        padding: 20px;
        max-width: 100%;
        width: 100%;
        gap: 16px;
        box-sizing: border-box;
    }
    
    .search-limit-subtext {
        font-size: 1rem;
        padding: 0 10px;
        width: 100%;
        box-sizing: border-box;
    }
    
    .search-limit-button {
        padding: 10px 24px;
        font-size: 0.95rem;
        width: 100%;
        max-width: 280px;
        box-sizing: border-box;
    }
}

/* Research Limit Overlay */
.research-limit-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
    padding: 20px;
    box-sizing: border-box;
}

html.force-light .research-limit-overlay,
html[data-theme="light"] .research-limit-overlay {
    background: rgba(255, 255, 255, 0.9);
}

@media (prefers-color-scheme: light) {
    html:not(.force-dark):not([data-theme="dark"]) .research-limit-overlay {
        background: rgba(255, 255, 255, 0.9);
    }
}

.research-limit-overlay.hidden {
    display: none;
}

.research-limit-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    text-align: center;
    padding: 20px;
    max-width: 90%;
    width: 100%;
    box-sizing: border-box;
}

.research-limit-subtext {
    color: var(--primary-text-color);
    font-size: 1.1rem;
    margin: 0;
    font-weight: 500;
    line-height: 1.5;
}

.research-limit-button {
    display: inline-block;
    padding: 12px 32px;
    border-radius: 25px;
    background: linear-gradient(135deg, var(--teal), var(--blue));
    color: white;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
}

.research-limit-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 6px var(--blue);
}

@media (max-width: 650px) {
    .research-limit-overlay {
        padding: 20px;
        box-sizing: border-box;
    }
    
    .research-limit-container {
        padding: 20px;
        max-width: 100%;
        width: 100%;
        gap: 16px;
        box-sizing: border-box;
    }
    
    .research-limit-subtext {
        font-size: 1rem;
        padding: 0 10px;
        width: 100%;
        box-sizing: border-box;
    }
    
    .research-limit-button {
        padding: 10px 24px;
        font-size: 0.95rem;
        width: 100%;
        max-width: 280px;
        box-sizing: border-box;
    }
}

@media (max-width: 650px) {
    .modal-overlay {
        padding: 10px;
    }
    
    .modal-content {
        max-width: 100%;
        max-height: 95vh;
        border-radius: 8px;
    }
    
    .modal-header {
        padding: 16px 20px;
    }
    
    .modal-header h3 {
        font-size: 1rem;
    }
    
    .modal-body {
        padding: 16px;
        overflow-x: auto;
    }
    
    
    /* Summary table modal: card-style stack on small screens */
    .summary-table-modal-body table {
        display: block;
        border: none;
        box-shadow: none;
    }
    
    .summary-table-modal-body table thead {
        display: none;
    }
    
    .summary-table-modal-body table tbody tr.summary-table-header-row {
        display: none;
    }
    
    .summary-table-modal-body table tbody {
        display: block;
    }
    
    .summary-table-modal-body table tbody tr {
        display: block;
        margin-bottom: 16px;
        padding: 16px;
        border: 1px solid var(--teal);
        border-radius: 8px;
        background: transparent;
        box-shadow: 0 2px 8px color-mix(in srgb, var(--blue) 25%, transparent);
    }
    
    .summary-table-modal-body table tbody tr:last-child {
        margin-bottom: 0;
    }
    
    .summary-table-modal-body table tbody td {
        display: block;
        padding: 8px 0;
        border: none;
        border-bottom: 1px solid var(--teal);
    }
    
    .summary-table-modal-body table tbody td:last-child {
        border-bottom: none;
    }
    
    .summary-table-modal-body table tbody td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-weight: 700;
        font-size: 0.85rem;
        color: var(--primary-text-color);
        margin-bottom: 4px;
    }
    
    /* Ensure tables in response fit within container on mobile */
    .markdown-body table {
        max-width: 100%;
        width: 100%;
        table-layout: fixed;
        font-size: small;
    }
    
    .markdown-body th,
    .markdown-body td {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    @supports (-webkit-touch-callout: none) {
      .textarea-wrapper textarea {
        font-size: 16px !important;
        line-height: 1.5 !important;
        box-sizing: border-box !important;
        appearance: none;
        -webkit-appearance: none;
      }
    }
}

/* Research History Sidebar Styles */
.research-history-sidebar {
    left: -340px;
    z-index: 1001; /* Above main sidebar */
}

.research-history-sidebar.open {
    left: 0;
}

.research-history-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 50px;
    padding-bottom: 20px;
    margin-bottom: 20px;
    position: relative;
}

.research-history-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(to right, var(--teal), var(--blue));
}

.research-history-header h2 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--primary-text-color);
}

.research-history-pro-banner {
    padding: 0;
    margin: 0 20px 20px 20px;
    background: var(--secondary-bg-color);
    border-radius: 8px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.research-history-pro-banner-icon {
    font-size: 1.25rem;
    color: var(--teal);
    flex-shrink: 0;
}

.research-history-pro-banner.hidden {
    display: none;
}

.research-history-pro-banner p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--primary-text-color);
    line-height: 1.5;
    flex: 1;
}

.research-history-pro-banner-link {
    background: linear-gradient(to right, var(--teal), var(--blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: underline;
    font-weight: 500;
}

.research-history-pro-banner-link:hover {
    background: linear-gradient(to right, var(--blue), var(--teal));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.research-history-load-more {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px;
    font-size: 0.9rem;
    color: var(--secondary-text-color);
}

.research-history-load-more:not(.loading) .spinner,
.research-history-load-more:not(.loading) span {
    display: none;
}

.research-history-load-more:not(.loading) {
    padding: 8px;
    min-height: 20px;
}

.research-history-load-more.hidden {
    display: none;
}

.research-history-load-more .spinner {
    width: 20px;
    height: 20px;
}

.close-research-history-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--primary-text-color);
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.close-research-history-btn:hover {
    background: var(--secondary-bg-color);
    transform: translateX(-2px);
}

.close-research-history-btn .material-symbols-rounded {
    font-size: 1.5rem;
}

.research-history-content {
    width: 100%;
}

/* Preferences Sidebar */
.preferences-sidebar {
    left: -340px;
    z-index: 1001; /* Above main sidebar */
}

.preferences-sidebar.open {
    left: 0;
}

.preferences-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 50px;
    padding-bottom: 20px;
    margin-bottom: 20px;
    position: relative;
}

.preferences-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(to right, var(--teal), var(--blue));
}

.preferences-header h2 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--primary-text-color);
}

.close-preferences-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--primary-text-color);
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.close-preferences-btn:hover {
    background: var(--secondary-bg-color);
    transform: translateX(-2px);
}

.close-preferences-btn .material-symbols-rounded {
    font-size: 1.5rem;
}

.preferences-content {
    width: 100%;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.preference-chip {
    background: var(--primary-bg-color);
    border: 1px solid var(--teal);
    border-radius: 10px;
    padding: 15px;
    transition: all 0.2s ease;
    box-shadow: none;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.preference-chip:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 6px var(--blue);
    border-color: var(--teal);
}

.preference-chip-header {
    margin-bottom: 12px;
}

.preference-chip-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-text-color);
}

.preference-chip-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-start;
}

.preference-option-chip {
    flex: 0 1 auto;
    border: 1px solid var(--teal);
    border-radius: 9999px;
    background: transparent;
    color: var(--primary-text-color);
    padding: 7px 14px;
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    box-shadow: none;
    text-align: center;
    font-family: 'Inter var', sans-serif;
    font-weight: 500;
    margin: 0;
}

.preference-option-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 6px var(--blue);
    background: var(--secondary-bg-color);
}

.preference-option-chip.active {
    background: var(--teal);
    color: black;
    border-color: var(--teal);
    box-shadow: none;
}

.preference-option-chip.active:hover {
    background: var(--teal);
    color: black;
    transform: translateY(-1px);
    box-shadow: 0 0 6px var(--blue);
}

.preferences-actions {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--secondary-bg-color);
}

.research-history-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 40px 20px;
    color: var(--secondary-text-color);
}

.research-history-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--secondary-text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.research-history-empty.hidden {
    display: none !important;
    padding: 0;
    margin: 0;
}

.research-history-empty p {
    margin: 0;
    color: var(--primary-text-color);
}

.research-history-upgrade-btn {
    display: inline-block;
    padding: 12px 20px;
    border-radius: 25px;
    background: linear-gradient(135deg, var(--teal), var(--blue));
    color: #fff !important;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    width: fit-content;
}

.research-history-upgrade-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 6px var(--blue);
}

.research-sessions-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 128px;
}

.research-session-item {
    background: var(--primary-bg-color);
    border: 1px solid var(--teal);
    border-radius: 10px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 3px rgba(0, 150, 136, 0.2);
    position: relative;
    overflow: visible;
}

.research-session-item.menu-open {
    z-index: 20;
}

.research-session-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 6px var(--blue);
    border-color: var(--teal);
}

.research-session-item.pinned {
    border-color: var(--teal);
    box-shadow: 0 4px 10px rgba(32, 201, 151, 0.25);
}

.research-session-item.pinned:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 6px var(--blue);
    border-color: var(--teal);
}

.research-session-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.research-session-left {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    flex: 1;
}

.research-session-title-container {
    flex: 1;
}

.research-session-rename-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.research-session-rename-input {
    flex: 1;
    border: 1px solid var(--tertiary-text-color);
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 0.9rem;
    background: var(--primary-bg-color);
    color: var(--primary-text-color);
    resize: vertical;
    min-height: 48px;
}

.research-session-rename-input:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 3px var(--shadow-teal);
}

.research-session-rename-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.research-session-rename-controls .icon-btn {
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: var(--secondary-bg-color);
    color: var(--primary-text-color);
    transition: background 0.2s ease, color 0.2s ease;
}

.research-session-rename-controls .icon-btn .material-symbols-rounded {
    font-size: 1rem;
    line-height: 1;
}

.research-session-rename-controls .icon-btn:hover {
    background: var(--teal);
    color: var(--primary-bg-color);
}

.research-session-pin-indicator {
    display: none;
    color: var(--blue);
    font-size: 1rem;
    margin-right: 6px;
    margin-top: 2px;
}

.research-session-item.pinned .research-session-pin-indicator {
    display: inline-flex;
}

.research-session-pin-indicator .material-symbols-rounded {
    font-size: 1rem;
}

.research-session-actions {
    position: relative;
}

.research-session-actions-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    color: var(--secondary-text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.research-session-actions-btn:hover {
    background: var(--secondary-bg-color);
    color: var(--primary-text-color);
}

.research-session-actions-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--primary-bg-color);
    border: 1px solid var(--tertiary-text-color);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
    display: none;
    min-width: 160px;
    z-index: 10;
    padding: 6px 0;
}

/* Citation styles dropdown uses the userQuery menu styling, but enforce the same heavier shadow */
.citation-format-actions .userQuery-actions-menu {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.research-session-actions-menu.open {
    display: block;
    pointer-events: auto;
}

.research-session-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    font-size: 0.9rem;
    color: var(--primary-text-color);
    cursor: pointer;
}

.research-session-menu-item:hover {
    background: var(--secondary-bg-color);
}

.research-session-menu-item .material-symbols-rounded {
    font-size: 1.2rem;
    color: var(--secondary-text-color);
}

.research-session-menu-item:hover .material-symbols-rounded {
    color: var(--primary-text-color);
}

/* Share Research Modal */
.share-modal-content {
    max-width: 480px;
}

.share-modal-description {
    margin: 0 0 12px 0;
    font-size: 0.95rem;
    color: var(--secondary-text-color);
}

.share-modal-url-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.share-modal-url-input {
    flex: 1;
    padding: 10px 14px;
    font-size: 0.9rem;
    border: 1px solid var(--tertiary-text-color);
    border-radius: 8px;
    background: var(--secondary-bg-color);
    color: var(--primary-text-color);
}

.share-modal-copy-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

@media (max-width: 480px) {
    .share-modal-url-row {
        flex-direction: column;
        align-items: stretch;
    }

    .share-modal-copy-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Share and Delete modals: above sidebars on mobile */
#shareResearchModal,
#deleteConfirmModal {
    z-index: 1100;
}

/* Delete Confirm Modal */
.delete-confirm-modal-content {
    max-width: 420px;
}

.delete-confirm-description {
    margin: 0 0 20px 0;
    font-size: 0.95rem;
    color: var(--primary-text-color);
}

.delete-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.delete-confirm-delete-btn {
    background: #d32f2f;
    border-color: #d32f2f;
    color: #fff;
}

.delete-confirm-delete-btn:hover {
    background: #b71c1c;
    border-color: #b71c1c;
}

.research-session-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-text-color);
    margin-bottom: 8px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.research-session-meta {
    font-size: 0.85rem;
    color: var(--secondary-text-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

.research-session-search-count {
    display: flex;
    align-items: center;
    gap: 5px;
}

.research-session-date {
    font-size: 0.8rem;
}

.bms-snackbar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 0.9rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1002;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bms-snackbar .snackbar-icon {
    font-size: 1rem;
    line-height: 1;
}

.bms-snackbar .snackbar-text {
    line-height: 1.2;
    white-space: pre-line;
}

.bms-snackbar[data-type="error"] {
    background: rgba(220, 53, 69, 0.9);
    bottom: auto;
    top: 24px;
}

.bms-snackbar[data-type="error"].show {
    transform: translate(-50%, 8px);
}

.bms-snackbar.show {
    opacity: 1;
    transform: translate(-50%, -8px);
}

/* Share Research Topic floating button (Pro gradient) – above scroll-to-bottom, Pro only; visible only when scroll-to-bottom would show */
.share-research-btn {
    position: fixed;
    bottom: 84px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(to right, var(--teal), var(--blue));
    color: white;
    border: none;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    display: none; /* Shown only for Pro users via auth.js (set to flex when isPro) */
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
    z-index: 1001;
}
.share-research-btn.show {
    opacity: 1;
    pointer-events: all;
}
.share-research-btn:hover {
    box-shadow: 0 0 6px var(--blue);
    transform: translateY(-2px);
}
.share-research-btn .material-symbols-rounded {
    font-size: 1.5rem;
}

@media (max-width: 650px) {
    .share-research-btn {
        bottom: 80px;
        right: 10px;
        width: 44px;
        height: 44px;
    }
    .share-research-btn .material-symbols-rounded {
        font-size: 1.3rem;
    }
}

/* Scroll to bottom button */
.scroll-to-bottom-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--teal);
    color: white;
    border: 1px solid var(--teal);
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
    z-index: 1001;
}

.scroll-to-bottom-btn.show {
    opacity: 1;
    pointer-events: all;
}

.scroll-to-bottom-btn:hover {
    background: var(--teal);
    box-shadow: 0 0 6px var(--blue);
    transform: translateY(-2px);
}

.scroll-to-bottom-btn .material-symbols-rounded {
    font-size: 1.5rem;
    color: black;
}

@media (max-width: 650px) {
    .scroll-to-bottom-btn {
        /* Position will be set dynamically by JavaScript relative to search box */
        right: 10px;
        width: 44px;
        height: 44px;
    }
    
    .scroll-to-bottom-btn .material-symbols-rounded {
        font-size: 1.3rem;
    }
}

/* Pricing Page Styles */
.pricing-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 60px 20px;
    min-height: calc(100vh - 200px);
    background-color: var(--primary-bg-color);
}

body:has(.pricing-container) .container {
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100%;
}

body:has(.pricing-container) .headerBox.top-positioned {
    position: fixed;
    top: 0;
    left: 0;
    transform: none;
    width: 100%;
    background: var(--primary-bg-color);
    z-index: 100;
    padding: 10px;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: none;
}

body:has(.pricing-container) .headerBox.top-positioned::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(to right, var(--teal), var(--blue));
}

body:has(.pricing-container) .pricing-container {
    margin-top: 80px;
    padding-top: 0;
}

.pricing-header {
    text-align: center;
    margin-top: 24px;
    margin-bottom: 10px;
}

.pricing-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-text-color);
    margin-bottom: 0;
}

.pricing-header-pro {
    background: linear-gradient(to right, var(--teal), var(--blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.pricing-subtext {
    font-size: 1rem;
    color: var(--secondary-text-color);
    margin: 0;
}

.pricing-taglines {
    padding-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    text-align: center;
}

.pricing-tagline {
    font-size: 0.9rem;
    color: var(--primary-text-color);
    margin: 0;
    font-style: italic;
    font-weight: 500;
}

.pricing-plans {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 32px;
    max-width: 900px;
    margin: 0 auto;
}

.pricing-plan {
    background: var(--secondary-bg-color);
    border-radius: 12px;
    padding: 32px;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--teal);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--blue) 25%, transparent);
    transition: all 0.3s ease;
}

.pro-plan {
    border-color: var(--teal);
    background: var(--secondary-bg-color);
}

.plan-header {
    margin-bottom: 0;
}

.plan-badge {
    font-size: 1.1rem;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 8px;
    display: inline-block;
}

.free-badge {
    background: var(--teal);
    color: black;
}

.pro-badge {
    background: linear-gradient(to right, var(--teal), var(--blue));
    color: #fff;
}

.plan-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.plan-section {
    margin-bottom: 0;
}

.plan-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-text-color);
    margin-bottom: 16px;
}

.plan-divider {
    border: 0;
    height: 1px;
    margin: 0 0 16px 0;
}

.free-plan .plan-divider {
    background: #14b8a6;
    opacity: 0.85;
}

.pro-plan .plan-divider {
    background: linear-gradient(90deg, #14b8a6 0%, #2563eb 100%);
    opacity: 0.9;
}

.plan-features,
.plan-limits {
    list-style: none;
    padding: 0;
    margin: 0;
}

.plan-features li {
    display: flex;
    align-items: flex-start;
    margin-bottom: 12px;
    color: var(--primary-text-color);
    font-size: 0.95rem;
}

.plan-features li .material-symbols-rounded {
    font-size: 1.2rem;
    color: var(--primary-text-color);
    margin-right: 12px;
    flex-shrink: 0;
    margin-top: 2px;
}

.pro-plan .plan-features li .material-symbols-rounded {
    color: var(--primary-text-color);
}

.plan-features li .inline-icon {
    font-size: 1rem !important;
    vertical-align: middle;
    margin-left: 6px;
    margin-right: 10px;
    margin-top: 2px;
    background: linear-gradient(to right, var(--teal), var(--blue));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    display: inline-block !important;
    flex-shrink: 0;
    font-family: 'Material Symbols Rounded' !important;
    font-weight: normal;
    font-style: normal;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
}

.pro-plan .plan-features li .inline-icon {
    background: linear-gradient(to right, var(--teal), var(--blue));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.plan-limits li {
    color: var(--primary-text-color);
    font-size: 0.95rem;
    margin-bottom: 8px;
    padding-left: 24px;
    position: relative;
}

.plan-limits li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--primary-text-color);
}

.plan-button {
    width: 100%;
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: auto;
    font-family: 'Inter var', sans-serif;
}

.plan-button-neutral {
    background: transparent;
    color: var(--primary-text-color);
    border: 1px solid var(--teal);
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
}

.plan-button-neutral:hover {
    background: var(--secondary-bg-color);
    color: var(--primary-text-color);
    transform: translateY(-1px);
    box-shadow: 0 0 6px var(--blue);
}

.plan-button-primary {
    background: linear-gradient(to right, var(--teal), var(--blue));
    color: white;
}

.plan-button-primary:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(41, 121, 255, 0.3);
}

.plan-pricing-note {
    text-align: center;
    font-size: 0.85rem;
    color: var(--primary-text-color);
    margin-top: 12px;
    margin-bottom: 0;
}

.student-discount-note {
    margin: 20px 0 0;
    font-size: 0.85rem;
    color: var(--primary-text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-align: center;
}

.student-discount-note .material-symbols-rounded {
    font-size: 1rem;
    font-variation-settings: 'wght' 700;
    line-height: 1;
    color: var(--teal);
}

.student-discount-note .student-verify-link {
    display: inline;
    padding: 0;
    margin: 0;
    border: none;
    background: none;
    font: inherit;
    font-size: inherit;
    color: var(--link-color);
    text-decoration: underline;
    cursor: pointer;
}

.student-discount-note .student-verify-link:hover {
    color: var(--visited-link-color);
}

.verification-modal-content {
    max-width: 520px;
}

.verification-modal-body {
    padding: 20px 24px 28px;
    text-align: left;
}

.verification-modal-body p {
    margin: 0 0 1rem;
    color: var(--primary-text-color);
    font-size: 0.95rem;
    line-height: 1.5;
}

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

.verification-modal-body a {
    color: var(--link-color);
    text-decoration: underline;
}

.verification-modal-body a:hover {
    color: var(--visited-link-color);
}

@media (max-width: 768px) {
    .pricing-plans {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    
    .pricing-header h1 {
        font-size: 2rem;
    }
    
    .pricing-subtext {
        font-size: 1rem;
    }
    
    .pricing-tagline {
        font-size: 0.9rem;
    }
    
    .pricing-plan {
        padding: 24px;
    }
}