@import url('https://fonts.googleapis.com/css2?family=Russo+One&family=Quantico:wght@400;700&family=Black+Ops+One&display=swap');

:root{
  /* Dark theme (single UI) */
  --bg: linear-gradient(180deg,#071025 0%, #091426 100%);
  --card: #0b1220;
  --muted: #9aa4b2;
  --accent: #00d1b2;
  --glass: rgba(255,255,255,0.03);
  --text: #e6eef6;
  /* footer height available for layout calculations */
  --footer-height: 48px;
  --footer-bg: rgba(4,10,18,0.9);

  /* chat bubble defaults for dark theme */
  --bot-bg: linear-gradient(90deg,#071028,#0b1830);
  --bot-border: rgba(255,255,255,0.02);
  --bot-text: #cfeef0;
  --user-bg: linear-gradient(90deg,#092534,#06343a);
  --user-text: #bfece2;
}


/* Light theme variables when .light is set on documentElement */
:root.light{
  --bg: #f6f7f9;
  --card: #ffffff;
  --muted: #3a4a56;
  --accent: #0366d6;
  --glass: rgba(2,6,23,0.02);
  --text: #0b1b2b;
  --footer-bg: rgba(246,247,249,0.9);

  /* chat bubble values for light theme - more subtle backgrounds */
  --bot-bg: #ffffff;
  --bot-border: rgba(0,0,0,0.08);
  --bot-text: #1a2834;
  --user-bg: linear-gradient(90deg,#e8f4ff,#dceeff);
  --user-text: var(--text);
}
*{box-sizing:border-box}

body{
  font-family: 'Russo One', system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  /* Reduce bottom padding since we're optimizing space usage */
  padding: 8px 24px calc(var(--footer-height,48px) + 8px);
  overflow-x: clip;
  max-width: 100vw;
}

/* Minimal auth gate CSS - positioned to not interfere with main layout */
.auth-gate {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.auth-gate-content {
  background: var(--card);
  border: 1px solid var(--glass);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  max-width: 400px;
  margin: 1rem;
}

.auth-gate-content h2 {
  color: var(--text);
  margin-bottom: 1rem;
}

.auth-gate-content p {
  color: var(--muted);
  margin-bottom: 2rem;
}

header.site-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:18px;
  background: var(--glass);
  border-radius:12px;
  margin-bottom:18px;
  flex-wrap:wrap;
  gap:12px;
}

/* Global theme toggle position: place above header and not inside header containers */
.global-theme-toggle{display:flex;justify-content:space-between;align-items:center;padding:4px 18px 0 18px;gap:12px}
.global-theme-toggle .user-section{display:flex;align-items:center;gap:8px}
.global-theme-toggle .theme-switch-wrapper{background:transparent;padding:6px;border-radius:8px;display:flex;align-items:center;gap:10px}
.global-theme-toggle .theme-note{color:var(--muted);margin-left:8px;font-size:13px}

/* Top-level user badge placed next to the theme toggle */
.top-user-info{display:inline-flex;align-items:center;gap:8px;padding:6px 10px;border-radius:10px;background:transparent;border:1px solid rgba(255,255,255,0.02);color:var(--text);font-weight:600;transition:all 0.3s ease;cursor:pointer}
.top-user-info:hover{background:var(--glass);border-color:var(--accent);transform:translateY(-1px)}
.top-user-info .tier{color:#ff8c00;margin-left:6px;font-weight:700}

/* Sign out button */
.sign-out-btn{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;border:1px solid rgba(255,255,255,0.1);background:transparent;border-radius:8px;color:var(--muted);cursor:pointer;transition:all 0.2s ease}
.sign-out-btn:hover{background:var(--glass);border-color:var(--accent);color:var(--accent);transform:translateY(-1px)}
.sign-out-btn svg{width:16px;height:16px}

/* On very narrow screens, collapse the user info to save space and keep toggle accessible */
@media (max-width:600px){
  .global-theme-toggle{
    padding:6px 10px 0 10px;
    flex-wrap:wrap;
    justify-content:center;
    gap:8px;
  }
  
  .global-theme-toggle .user-section{
    flex:1 1 100%;
    justify-content:center;
    order:1;
  }
  
  .global-theme-toggle .theme-switch-wrapper{
    flex:1 1 100%;
    justify-content:center;
    order:2;
  }
  
  .top-user-info{
    font-size:12px;
    padding:6px 10px;
  }
  
  .sign-out-btn{
    width:28px;
    height:28px;
  }
  
  .sign-out-btn svg{
    width:14px;
    height:14px;
  }
  
  .theme-switch-wrapper .theme-note{
    font-size:11px;
  }
}

header .brand{display:flex;align-items:center;gap:12px}
header .brand h1{
  margin: 0;
  font-size: 26px;
  color: var(--accent);
  font-family: 'Black Ops One', 'Russo One', sans-serif;
  font-weight: 400;
  letter-spacing: 0.12em;
  background: linear-gradient(135deg, #00f5d4 0%, var(--accent) 50%, #00a693 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 0 30px rgba(0, 245, 212, 0.4);
  position: relative;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 12px rgba(0, 209, 178, 0.3));
  transform: skewX(-2deg);
  transition: all 0.3s ease;
  word-break: keep-all;
  white-space: nowrap;
}

/* Add aggressive motorsport glow effect on hover */
header .brand h1:hover {
  text-shadow: 0 0 35px rgba(0, 245, 212, 0.6), 0 0 20px rgba(0, 209, 178, 0.4);
  transform: skewX(-2deg) scale(1.03);
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.6)) drop-shadow(0 0 16px rgba(0, 209, 178, 0.5));
}

/* Light mode overrides for better visibility */
:root.light header .brand h1 {
  background: linear-gradient(135deg, #0366d6 0%, #0550ae 50%, #044289 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 0 20px rgba(3, 102, 214, 0.3);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2)) drop-shadow(0 0 8px rgba(3, 102, 214, 0.2));
}

:root.light header .brand h1:hover {
  text-shadow: 0 0 25px rgba(3, 102, 214, 0.4), 0 0 15px rgba(5, 80, 174, 0.3);
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.3)) drop-shadow(0 0 12px rgba(3, 102, 214, 0.3));
}

header .brand small{display:block;color:var(--muted)}
header .cta{color:var(--muted)}
header .brand .brand-sub{color:var(--muted);font-size:13px;margin-top:6px}
.theme-note{margin-left:8px;color:var(--muted);font-size:13px}

/* Beta banner styles */
.beta-banner {
  background: linear-gradient(90deg, #fef3c7, #fde68a);
  color: #92400e;
  padding: 10px 20px;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  border-bottom: 1px solid #fbbf24;
  position: relative;
  z-index: 1000;
}

.beta-banner a {
  color: #92400e;
  text-decoration: underline;
  font-weight: 600;
}

.beta-banner a:hover {
  color: #78350f;
}

:root.light .beta-banner {
  background: linear-gradient(90deg, #fef3c7, #fde68a);
  color: #92400e;
  border-bottom: 1px solid #fbbf24;
}

/* When theme switch is placed inline with the brand, make it compact and aligned */

/* Site logo in header */
.site-logo{height:88px;width:88px;object-fit:cover;border-radius:12px;margin-right:14px;padding:8px;background:var(--glass);box-shadow:0 8px 22px rgba(2,8,20,0.55);border:1px solid rgba(255,255,255,0.04)}
.logo-link{display:inline-flex;align-items:center;text-decoration:none}
.logo-link img{display:block}

.container{
  display:flex !important;
  gap:18px;
  flex-direction:row !important;
  max-width: 100%;
}
section.left{
  flex:0 0 420px !important;
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Add a visual indicator when collapsed */
section.left::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

section.left.collapsed::before {
  opacity: 0.6;
}

/* Sidebar collapsed state */
section.left.collapsed {
  flex: 0 0 60px !important;
  overflow: hidden;
}

section.left.collapsed > *:not(.sidebar-toggle) {
  opacity: 0;
  pointer-events: none;
}

/* Hover expanded state - temporarily show sidebar on hover */
section.left.collapsed.hover-expanded {
  flex: 0 0 420px !important;
  overflow-y: auto;
}

section.left.collapsed.hover-expanded > *:not(.sidebar-toggle) {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.2s ease 0.1s;
}

/* Hamburger menu for mobile */
.hamburger-menu {
  display: none;
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 1001;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.1);
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.hamburger-menu:active {
  transform: scale(0.95);
}

.hamburger-menu span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  transition: all 0.3s ease;
  border-radius: 2px;
}

.hamburger-menu.active span:nth-child(1) {
  transform: rotate(45deg) translate(6px, 6px);
}

.hamburger-menu.active span:nth-child(2) {
  opacity: 0;
}

.hamburger-menu.active span:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
}

/* Mobile sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 999;
  backdrop-filter: blur(4px);
}

.sidebar-overlay.active {
  display: block;
}

/* Light theme mobile elements */
:root.light .hamburger-menu {
  background: var(--card);
  border: 1px solid rgba(0,0,0,0.15);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

:root.light .hamburger-menu span {
  background: var(--text);
}

:root.light .param-table-modal {
  background: var(--bg);
}

:root.light .param-table-modal-header {
  background: var(--card);
  border-bottom: 2px solid var(--accent);
}

:root.light .param-table-modal-close {
  border: 1px solid rgba(0,0,0,0.2);
}

:root.light .view-params-btn {
  box-shadow: 0 4px 12px rgba(3,102,214,0.3);
}

:root.light .view-params-btn:hover {
  box-shadow: 0 6px 16px rgba(3,102,214,0.4);
}

/* Sidebar toggle button */
.sidebar-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  background: var(--glass);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

/* When collapsed, make toggle button more prominent and centered */
section.left.collapsed .sidebar-toggle {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  width: 40px;
  height: 40px;
  background: var(--accent);
  color: #042024;
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(0, 209, 178, 0.3);
}

.sidebar-toggle:hover {
  background: rgba(255,255,255,0.08);
  border-color: var(--accent);
  transform: scale(1.05);
}

section.left.collapsed .sidebar-toggle:hover {
  transform: translateX(-50%) scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 209, 178, 0.4);
}

.sidebar-toggle:active {
  transform: scale(0.95);
}

section.left.collapsed .sidebar-toggle:active {
  transform: translateX(-50%) scale(0.95);
}

.sidebar-toggle .toggle-icon {
  transition: transform 0.3s ease;
}

section.left.collapsed .sidebar-toggle .toggle-icon {
  transform: rotate(180deg);
}

section.right{flex:1 !important; min-width:0;}

/* Mod configuration card */
.mods-card {
  background: var(--card);
  padding: 16px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.06);
  margin-bottom: 16px;
}

.mods-card h2 {
  margin-top: 0;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mods-status {
  font-size: 12px;
  color: var(--muted);
  font-weight: normal;
}

.mods-status.saved {
  color: var(--accent);
}

.mods-display {
  padding: 12px;
  background: var(--glass);
  border-radius: 8px;
  margin-bottom: 12px;
}

.mods-summary {
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 12px;
}

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

.mods-form {
  margin-bottom: 12px;
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 13px;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.1);
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0,209,178,0.1);
}

.form-group textarea {
  resize: vertical;
  min-height: 60px;
}

.form-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mods-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

/* Log History Card (Premium Feature) */
.log-history-card {
  background: var(--card);
  padding: 16px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.06);
  margin-bottom: 16px;
}

.log-history-card h2 {
  margin-top: 0;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
}

.log-history-list {
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.loading-logs {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.log-entry {
  background: var(--glass);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.log-entry:hover {
  background: rgba(0,209,178,0.05);
  border-color: var(--accent);
}

.log-entry.selected {
  background: rgba(0,209,178,0.1);
  border-color: var(--accent);
  border-width: 2px;
}

.log-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.log-entry-title {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
  margin: 0;
  flex: 1;
  word-break: break-word;
}

.log-entry-actions {
  display: flex;
  gap: 4px;
  margin-left: 8px;
  flex-shrink: 0;
}

.log-entry-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.log-entry-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.log-entry-date {
  font-size: 11px;
  color: var(--muted);
  opacity: 0.7;
}

.log-action-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  transition: all 0.2s ease;
}

.log-action-btn:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text);
}

.log-action-btn.compare-btn {
  color: var(--accent);
}

.log-action-btn.compare-btn:hover {
  background: rgba(0,209,178,0.1);
}

.log-action-btn.delete-btn {
  color: #ff6b6b;
}

.log-action-btn.delete-btn:hover {
  background: rgba(255,107,107,0.1);
}

.log-history-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.05);
}

.no-logs-message {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.comparison-indicator {
  position: fixed;
  top: 80px;
  right: 24px;
  background: rgba(0,209,178,0.1);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 100;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.comparison-indicator-text {
  color: var(--text);
  font-size: 13px;
}

.comparison-indicator-text strong {
  color: var(--accent);
}

.comparison-close-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.comparison-close-btn:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text);
}

/* Button styles for mod configuration */
.btn-primary,
.btn-secondary,
.btn-danger {
  padding: 8px 12px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--accent);
  color: #042024;
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.2);
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.05);
}

.btn-danger {
  background: #e74c3c;
  color: white;
}

.btn-danger:hover {
  background: #c0392b;
}

/* Old chat input section styles removed - checkbox moved to header */

/* Light theme overrides for forms */
:root.light .form-group input,
:root.light .form-group textarea {
  border: 1px solid rgba(0,0,0,0.2);
}

:root.light .btn-secondary {
  border: 1px solid rgba(0,0,0,0.2);
}

/* Light theme message input */
:root.light #messageInput {
  border: 1px solid rgba(0,0,0,0.2);
}

.upload-card, .chat-card, .instructions{
  background: var(--card);
  padding: 16px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.06);
}

/* Add proper spacing between cards in left sidebar */
.upload-card, .mods-card, .instructions {
  margin-bottom: 16px;
}

.instructions {
  margin-bottom: 0; /* Last item doesn't need bottom margin */
}

.upload-card h2{margin-top:0}
#fileInput{width:100%;margin:8px 0}
#uploadBtn{background:var(--accent);border:none;color:#042024;padding:10px 12px;border-radius:8px;cursor:pointer}

.upload-hint{margin-top:8px;color:var(--muted);font-size:13px}

/* Analysis mode selector */
.analysis-mode-selector {
  margin: 12px 0 16px 0;
  padding: 12px;
  background: var(--glass);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.radio-group {
  display: flex;
  gap: 12px;
}

.radio-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 16px;
  background: var(--card);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 1;
}

.radio-label:hover {
  background: var(--glass);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.radio-label input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-label input[type="radio"]:checked + span {
  color: var(--accent);
  font-weight: 600;
}

.radio-label input[type="radio"]:checked ~ .radio-hint {
  color: var(--accent);
}

.radio-label input[type="radio"]:checked ~ * {
  color: var(--text);
}

.radio-label:has(input[type="radio"]:checked) {
  background: var(--glass);
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(0, 209, 178, 0.2);
}

.radio-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  text-align: center;
}

/* Light mode adjustments */
:root.light .radio-label {
  border-color: rgba(0, 0, 0, 0.12);
}

:root.light .radio-label:hover {
  border-color: var(--accent);
}

:root.light .radio-label:has(input[type="radio"]:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(3, 102, 214, 0.15);
}


/* CSV preview that wraps and doesn't blow out layout */
#csvPreview{
  max-height:240px;
  overflow:auto;
  background:transparent;
  padding:0;
  border-radius:8px;
  margin-top:12px;
  color:var(--muted);
  white-space:pre-wrap;
  word-break:break-word;
  font-family: monospace;
  font-size: 12px;
}

/* Dataframe table preview styling */
.csv-preview-header {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 10px;
  margin-left: 12px;
  margin-top: 12px;
  font-family: 'Inter', sans-serif;
}

#csvPreview .csv-dataframe-preview {
  width: 100%;
  font-size: 11px;
  border-collapse: collapse;
  font-family: monospace;
  background: transparent;
}

#csvPreview .csv-dataframe-preview thead {
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#csvPreview .csv-dataframe-preview th {
  padding: 8px 6px;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid rgba(0,0,0,0.1);
  white-space: nowrap;
  color: var(--text);
  font-size: 10px;
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 10;
}

#csvPreview .csv-dataframe-preview td {
  padding: 6px 6px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
  font-size: 10px;
}

#csvPreview .csv-dataframe-preview tbody tr:first-child td {
  padding-top: 8px;
}

#csvPreview .csv-dataframe-preview tr:hover {
  background: rgba(0,0,0,0.02);
}

#csvPreview .csv-dataframe-preview tbody tr:last-child td {
  border-bottom: none;
  padding-bottom: 12px;
}

.csv-status{margin-left:12px;color:var(--muted);font-weight:400;font-size:13px}
.selectors{display:inline-flex;align-items:center;gap:8px;margin-left:18px;flex-wrap:wrap}
.selectors label{color:var(--muted);font-size:13px;white-space:nowrap}
.selectors select{background:transparent;border:1px solid rgba(0,0,0,0.06);color:inherit;padding:6px 8px;border-radius:6px;min-width:80px}

.header-controls{display:flex;align-items:center;gap:12px}

/* Top navigation inside header */
.top-nav{display:flex;gap:12px;align-items:center}
.top-nav .nav-link{color:var(--muted);text-decoration:none;padding:8px 12px;border-radius:8px;font-weight:600}
.top-nav .nav-link:hover{background:rgba(255,255,255,0.02);color:var(--accent)}
.top-nav .nav-link.active{background:var(--accent);color:#042024}

/* Ensure header controls layout remains normal (toggle moved elsewhere) */
.header-controls{display:flex;align-items:center;gap:12px;margin-left:auto}

/* Make the theme switch sit to the right and small label removed on narrow screens */
.theme-switch-wrapper{display:flex;align-items:center;gap:8px}
.theme-switch-wrapper .theme-note{display:none}
@media (min-width:900px){
  .theme-switch-wrapper .theme-note{display:inline-block}
}

/* Slide switch */
.switch{position:relative;display:inline-block;width:46px;height:26px}
.switch input{display:none}
.slider{position:absolute;cursor:pointer;top:0;left:0;right:0;bottom:0;background:#ccc;transition:.4s;border-radius:26px}
.slider:before{position:absolute;content:'';height:20px;width:20px;left:3px;bottom:3px;background:white;transition:.4s;border-radius:50%}
.switch input:checked + .slider{background:var(--accent)}
.switch input:checked + .slider:before{transform:translateX(20px)}
.csv-preview-mini{font-size:12px;color:var(--muted);max-height:80px;overflow:auto;white-space:pre-wrap;word-break:break-word;background:transparent;border-radius:6px;padding:6px}

/* Small inline spinner used in upload button and loading indicator */
.spinner{
  display:inline-block;
  width:18px;height:18px;border-radius:50%;margin-right:8px;vertical-align:middle;
  box-sizing:border-box;border:3px solid rgba(255,255,255,0.08);border-top-color:var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}

.loading-dots{display:inline-flex;align-items:center;gap:4px;margin-right:6px}
.loading-dot{display:inline-block;width:6px;height:6px;background:var(--muted);border-radius:50%;opacity:0.5;transform:translateY(0);animation: dots 1s infinite linear}
.loading-dot:nth-child(2){animation-delay:0.15s}
.loading-dot:nth-child(3){animation-delay:0.3s}
@keyframes dots{0%{opacity:0.2;transform:translateY(0)}50%{opacity:1;transform:translateY(-6px)}100%{opacity:0.2;transform:translateY(0)}}

.instructions ul{margin:0;padding-left:18px;color:var(--muted)}

.chat-card{
  display:flex;
  flex-direction:column;
  min-height:680px;
  max-height:calc(100vh - 160px - var(--footer-height,48px) - 20px);
  height:auto;
  overflow-x:visible; /* Prevent buttons from being clipped */
}
.chat-header{padding:12px;border-bottom:1px solid rgba(0,0,0,0.06);font-weight:600;color:var(--accent);display:flex;align-items:center;justify-content:space-between;gap:12px}
.chat-header-left{display:flex;align-items:center;gap:12px;flex:1;min-width:0}
.chat-title{font-weight:700;color:var(--accent);margin:0}

/* Desktop selector styling */
.selectors{display:inline-flex;align-items:center;gap:8px;margin-left:18px;flex-wrap:wrap}
.selectors > div{display:inline-flex;align-items:center;gap:6px}
.selectors label{color:var(--muted);font-size:13px;white-space:nowrap}
.selectors select{
  background:transparent;
  border:1px solid rgba(255,255,255,0.1);
  color:inherit;
  padding:6px 8px;
  border-radius:6px;
  min-width:80px;
  transition:border-color 0.2s ease;
}
.selectors select:focus{
  outline:none;
  border-color:var(--accent);
}

/* Style the use mods selector to match the dropdown selectors */
.use-mods-selector {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.use-mods-selector .use-mods-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background-color 0.2s ease;
}

.use-mods-selector .use-mods-checkbox:hover {
  background: rgba(255,255,255,0.05);
}

.use-mods-selector input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}

/* Light theme select styling */
:root.light .selectors select{
  border:1px solid rgba(0,0,0,0.2);
}

:root.light .use-mods-selector .use-mods-checkbox:hover {
  background: rgba(0,0,0,0.05);
}

/* Light mode sidebar toggle */
:root.light .sidebar-toggle {
  border: 1px solid rgba(0,0,0,0.15);
  background: rgba(255,255,255,0.8);
}

:root.light .sidebar-toggle:hover {
  background: rgba(255,255,255,0.95);
  border-color: var(--accent);
}

/* Light mode dataframe table styling */
:root.light #csvPreview .csv-dataframe-preview thead {
  background: var(--card);
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

:root.light #csvPreview .csv-dataframe-preview th {
  border-bottom: 2px solid rgba(0,0,0,0.15);
  background: var(--card);
}

:root.light #csvPreview .csv-dataframe-preview td {
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

:root.light #csvPreview .csv-dataframe-preview tr:hover {
  background: rgba(0,0,0,0.04);
}

.messages{
  flex:1 1 auto;
  min-height:0;
  overflow-y:auto;
  padding:12px;
  display:flex;
  flex-direction:column;
  gap:16px;
  /* Reduce bottom padding since input form is now positioned better */
  padding-bottom:16px;
  /* Add scroll margin to prevent content from hiding behind footer */
  scroll-padding-bottom:calc(var(--footer-height,48px) + 20px);
}
.msg{max-width:78%;padding:10px 12px;border-radius:10px;word-wrap:break-word;word-break:break-word;overflow-wrap:break-word;hyphens:auto}
.msg.user{align-self:flex-end;background:var(--user-bg);color:var(--user-text)}
.msg.bot{align-self:flex-start;background:var(--bot-bg);border:1px solid var(--bot-border);color:var(--bot-text)}

/* System info message - displayed outside chat bubbles */
.system-info{
  align-self:center;
  max-width:90%;
  padding:8px 12px;
  margin:8px 0;
  border-radius:8px;
  background:rgba(0,209,178,0.08);
  border:1px solid rgba(0,209,178,0.2);
  color:var(--muted);
  font-size:0.9em;
  text-align:center;
}
:root.light .system-info{
  background:rgba(3,102,214,0.08);
  border:1px solid rgba(3,102,214,0.2);
}

/* Upgrade prompt styling - more prominent for standard tier */
.system-info.upgrade-prompt{
  background:rgba(255,165,0,0.12);
  border:1px solid rgba(255,165,0,0.3);
  color:var(--text);
  font-weight:600;
  padding:12px 16px;
  margin:12px 0;
  font-size:0.95em;
}
:root.light .system-info.upgrade-prompt{
  background:rgba(255,140,0,0.15);
  border:1px solid rgba(255,140,0,0.4);
}

.msg.bot.typing{opacity:0.95;filter:brightness(1.02);}
.msg.bot.typing .loading-dots{gap:6px}
.msg.bot.typing .loading-dot{width:8px;height:8px;background:var(--bot-text);opacity:0.9}

/* Streaming message styles */
.msg.bot.streaming{position:relative}
.msg.bot.streaming::after{
  content:"";
  position:absolute;
  bottom:8px;
  right:8px;
  width:6px;
  height:6px;
  background:var(--accent);
  border-radius:50%;
  animation:pulse 1.5s ease-in-out infinite;
}
@keyframes pulse{
  0%, 100%{opacity:0.3;transform:scale(1)}
  50%{opacity:1;transform:scale(1.2)}
}

/* Streaming cursor effect */
.msg.bot.streaming .msg-content::after{
  content:"▋";
  color:var(--accent);
  animation:blink 1s step-end infinite;
  margin-left:2px;
}
@keyframes blink{
  0%, 50%{opacity:1}
  51%, 100%{opacity:0}
}
/* Chat form layout */
.chat-form{
  display:flex;
  gap:8px;
  padding:12px;
  align-items:flex-end; /* Align buttons to bottom when textarea grows */
  /* Reduce bottom margin to use more of the available space */
  margin-bottom:8px;
  /* Keep form closer to the bottom of the chat container */
  margin-top:auto;
  flex-wrap:nowrap; /* Prevent wrapping */
  overflow:visible; /* Ensure buttons are visible */
  box-sizing:border-box; /* Include padding in width calculation */
}

.chat-form button{
  white-space:nowrap;
  flex-shrink:0; /* Prevent buttons from shrinking */
}

/* Flexible message input that can shrink/grow and not force overflow */
#messageInput{
  flex:1 1 auto;
  padding:10px 12px;
  border-radius:10px;
  border:1px solid rgba(255,255,255,0.04);
  background:transparent;
  color:inherit;
  min-width:0;
  width:auto;
  font-size:16px; /* Prevent iOS zoom on focus */
  outline:none;
  transition:border-color 0.2s ease, height 0.1s ease;
  resize:none; /* Disable manual resize handle */
  overflow-y:hidden; /* Hide scrollbar initially */
  height:40px; /* Fixed initial height to match original input */
  max-height:120px; /* Maximum height before scrolling */
  line-height:1.4; /* Comfortable line height for multi-line */
  font-family:inherit; /* Use the same font as other inputs */
  box-sizing:border-box; /* Include padding and border in height calculation */
}

#messageInput:focus{
  border-color:var(--accent);
  box-shadow:0 0 0 2px rgba(0,209,178,0.1);
}

#messageInput::placeholder{
  color:var(--muted);
  opacity:0.7;
}

/* Ensure Send and New Chat buttons have the same visual width */
#sendBtn, .btn-new{
  min-width:96px;
  line-height:1;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}
/* Send status indicator */
.send-status{
  display:inline-flex;
  align-items:center;
  margin-right:6px;
  min-width:28px;
  justify-content:center;
}

.send-status .loading-dots{
  margin:0;
}

.send-status.hidden{
  display:none;
}
/* Send button style */
button[type=submit]{
  background:#1f6feb;
  border:none;
  color:white;
  padding:10px 14px;
  border-radius:10px;
  cursor:pointer;
  font-size:14px;
}

button[type=submit]:hover{
  background:#1a5fd6;
  transform:translateY(-1px);
}

button[type=submit]:active{
  transform:translateY(0);
}

button[type=submit]:disabled{
  background:#555;
  cursor:not-allowed;
  transform:none;
}
.site-footer{
  /* height is exposed as a CSS variable so pages can reserve space */
  position:fixed;
  left:0;right:0;bottom:0;
  text-align:center;
  color:var(--muted);
  /* Give footer a solid background with slight blur for visual separation */
  background: var(--footer-bg);
  backdrop-filter: blur(8px);
  border-top: 1px solid rgba(255,255,255,0.04);
  padding:10px 12px;
  height:var(--footer-height);
  line-height:var(--footer-height);
  z-index:999;
  margin:0;
  pointer-events:none; /* non-interactive label */
}
/* New chat button style */
.btn-new{
  background:#ffb020;
  border:none;
  color:#071426;
  padding:10px 14px;
  border-radius:10px;
  cursor:pointer;
  margin-left:8px;
  box-shadow:0 2px 6px rgba(0,0,0,0.18);
  font-size:14px;
  font-weight:500;
  transition:transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-new:hover{
  transform:translateY(-1px);
  box-shadow:0 6px 14px rgba(0,0,0,0.28);
}

.btn-new:active{
  transform:translateY(0);
}

/* Markdown-rendered content in bot messages */
.msg.bot h2, .msg.bot h3, .msg.bot h4{color:var(--accent);margin:6px 0}
.msg.bot p{color:var(--muted);margin:6px 0}
.msg.bot ul, .msg.bot ol{margin:6px 0 6px 18px;color:var(--muted)}
.msg.bot pre{background:#021023;padding:10px;border-radius:8px;overflow:auto;color:#cfeef0}
.msg.bot code{background:rgba(255,255,255,0.03);padding:2px 6px;border-radius:4px}
.msg.bot hr{border:none;border-top:1px solid rgba(255,255,255,0.04);margin:12px 0}

/* Table wrapper for horizontal scrolling - only when tables are wide */
.msg.bot .msg-content{
  overflow-x:auto;
  overflow-y:visible;
  -webkit-overflow-scrolling:touch; /* Smooth scrolling on iOS */
  max-width:100%; /* Prevent overflow on mobile */
}

.msg.bot table{
  border-collapse:collapse;
  margin:12px 0;
  font-size:14px;
  border:1px solid rgba(255,255,255,0.1);
  border-radius:6px;
  min-width:100%;
  width:max-content;
}

.msg.bot thead{
  background:rgba(0,0,0,0.2);
}

.msg.bot th{
  padding:10px 12px;
  text-align:left;
  font-weight:600;
  border-bottom:2px solid rgba(255,255,255,0.15);
  white-space:nowrap;
  color:var(--accent);
  background:rgba(0,0,0,0.2);
}

.msg.bot td{
  padding:8px 12px;
  border-bottom:1px solid rgba(255,255,255,0.05);
  white-space:nowrap;
  color:var(--bot-text);
}

.msg.bot tbody tr:hover{
  background:rgba(255,255,255,0.02);
}

.msg.bot tbody tr:last-child td{
  border-bottom:none;
}

/* Mobile table adjustments - entire table scrolls horizontally together */
@media (max-width: 640px) {
  .msg.bot .msg-content {
    /* Ensure smooth horizontal scrolling on mobile */
    overflow-x:auto;
    overflow-y:visible;
    -webkit-overflow-scrolling:touch;
    scrollbar-width:thin;
  }
  
  .msg.bot table {
    /* Force table to be wider than container so it scrolls */
    width:max-content;
    min-width:100%;
    /* Remove any display overrides */
    display:table;
  }
  
  .msg.bot th,
  .msg.bot td {
    /* Slightly reduce padding on mobile */
    padding:8px 10px;
    /* Ensure text doesn't wrap */
    white-space:nowrap;
    /* Remove any sticky positioning */
    position:static;
  }
}

/* Light theme table styling */
:root.light .msg.bot table{
  border:1px solid rgba(0,0,0,0.15);
}

:root.light .msg.bot thead{
  background:rgba(0,0,0,0.04);
}

:root.light .msg.bot th{
  border-bottom:2px solid rgba(0,0,0,0.2);
  background:rgba(0,0,0,0.04);
}

:root.light .msg.bot td{
  border-bottom:1px solid rgba(0,0,0,0.08);
  color:var(--bot-text);
}

:root.light .msg.bot tbody tr:hover{
  background:rgba(0,0,0,0.02);
}

/* Feedback controls placed outside the message bubble */
.feedback-wrapper{display:inline-flex;align-items:center;gap:8px;margin-top:4px;margin-left:6px;flex-wrap:wrap}
.feedback-prompt{color:var(--muted);font-size:12px;margin-right:6px}
.feedback{display:inline-flex;align-items:center;gap:4px}
.feedback .thumb{background:transparent;border:none;padding:4px 6px;border-radius:6px;cursor:pointer;font-size:16px;line-height:1}
.feedback .thumb + .thumb{margin-left:4px}
.feedback .thumb:hover{background:rgba(255,255,255,0.02)}
.feedback .thumb.selected{background:var(--accent);color:#042024}
.feedback-note{color:var(--muted);font-size:12px;margin-left:6px}

/* Suggested prompts styles for CSV uploads */
.suggested-prompts-container {
  margin: 8px 0;
  padding: 12px;
  background: var(--glass);
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.04);
}

.suggested-prompts-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
}

.suggested-prompts-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.suggested-prompt-btn {
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  text-align: left;
  transition: all 0.2s ease;
}

.suggested-prompt-btn:hover {
  background: rgba(255,255,255,0.05);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.suggested-prompt-btn:active {
  transform: translateY(0);
}

/* Light theme adjustments for suggested prompts */
:root.light .suggested-prompts-container {
  background: rgba(0,0,0,0.02);
  border-color: rgba(0,0,0,0.06);
}

:root.light .suggested-prompt-btn {
  background: var(--card);
  border-color: rgba(0,0,0,0.08);
  color: var(--text);
}

:root.light .suggested-prompt-btn:hover {
  background: rgba(0,0,0,0.02);
  border-color: var(--accent);
}

/* Mobile responsive adjustments */
@media (max-width: 640px) {
  .suggested-prompts-container {
    margin: 6px 0;
    padding: 10px;
  }
  
  .suggested-prompt-btn {
    padding: 12px;
    font-size: 14px;
  }
}

/* Feedback popup modal styles */
.feedback-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.feedback-modal {
  background: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
}

.feedback-modal-header {
  padding: 20px 20px 0 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  margin-bottom: 20px;
}

.feedback-modal-title {
  font-size: 18px;
  font-weight: 600;
  color: #ffffff;
  margin: 0 0 8px 0;
}

.feedback-modal-subtitle {
  font-size: 14px;
  color: #cccccc;
  margin: 0;
}

.feedback-modal-content {
  padding: 0 20px 20px 20px;
}

.feedback-modal-textarea {
  width: 100%;
  min-height: 100px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: #2a2a2a;
  color: #ffffff;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  resize: vertical;
  box-sizing: border-box;
}

.feedback-modal-textarea:focus {
  outline: none;
  border-color: #00d4aa;
  box-shadow: 0 0 0 2px rgba(0, 212, 170, 0.3);
}

.feedback-modal-textarea::placeholder {
  color: #999999;
}

.feedback-modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 20px;
}

.feedback-modal-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.feedback-modal-btn-cancel {
  background: transparent;
  color: #cccccc;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.feedback-modal-btn-cancel:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.feedback-modal-btn-submit {
  background: #00d4aa;
  color: #042024;
}

.feedback-modal-btn-submit:hover {
  background: #00c499;
  transform: translateY(-1px);
}

.feedback-modal-btn-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Light mode adjustments for feedback modal */
.light .feedback-modal {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.2);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.light .feedback-modal-title {
  color: #333333;
}

.light .feedback-modal-subtitle {
  color: #666666;
}

.light .feedback-modal-textarea {
  background: #f8f9fa;
  color: #333333;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.light .feedback-modal-textarea::placeholder {
  color: #666666;
}

.light .feedback-modal-btn-cancel {
  color: #666666;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.light .feedback-modal-btn-cancel:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #333333;
}

/* Mobile responsive adjustments */
@media (max-width: 600px) {
  .feedback-modal-overlay {
    padding: 10px;
  }
  
  .feedback-modal {
    max-height: 90vh;
  }
  
  .feedback-modal-header,
  .feedback-modal-content {
    padding-left: 15px;
    padding-right: 15px;
  }
  
  .feedback-modal-actions {
    flex-direction: column-reverse;
  }
  
  .feedback-modal-btn {
    width: 100%;
  }
}

/* Remove the duplicate padding-bottom since it's now handled in main .messages rule */

@media (max-width:600px){
  /* hide verbose feedback prompt on phones to save vertical space */
  .feedback-prompt{display:none}
  .feedback-wrapper{margin-left:4px;margin-top:4px}
  .feedback .thumb{padding:6px;font-size:14px}
  /* Mobile messages already have padding from main .messages rule */
}

/* Layout overrides: make the app fill more of the viewport height */
/* container min-height accounts for header + footer + padding */
.container{min-height:calc(100vh - 120px - var(--footer-height,48px))}

/* Reserve explicit bottom spacing so a fixed footer cannot overlap page content */
.container{padding-bottom:calc(var(--footer-height,48px) + 6px)}

/* left column (upload area) scrolls if content exceeds viewport */
section.left{
  max-height:calc(100vh - 140px - var(--footer-height,48px));
  overflow-y:auto;
  padding-right:4px; /* Account for scrollbar */
}

/* Ensure proper scrolling on medium and large screens */
@media (min-width:481px){
  section.left{
    max-height:calc(100vh - 140px - var(--footer-height,48px));
    overflow-y:auto;
    padding-bottom:20px; /* Extra bottom padding to ensure all content is accessible */
  }
  
  /* Style the scrollbar for better appearance */
  section.left::-webkit-scrollbar {
    width: 6px;
  }
  
  section.left::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
    border-radius: 3px;
  }
  
  section.left::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
  }
  
  section.left::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.3);
  }
  
  /* Light theme scrollbar */
  :root.light section.left::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.05);
  }
  
  :root.light section.left::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.2);
  }
  
  :root.light section.left::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.3);
  }
}

.chat-card{min-height:680px;max-height:calc(100vh - 160px - var(--footer-height,48px));display:flex;flex-direction:column}
.messages{flex:1 1 auto;min-height:0;overflow-y:auto}

/* tighten margins slightly on small screens */
@media (max-width:600px){
  /* Prevent any horizontal overflow */
  body{
    overflow-x:hidden;
    max-width:100vw;
    padding-left: 10px;
    padding-right: 10px;
  }
  
  header.site-header{
    flex-direction:column;
    align-items:center;
    gap:10px;
  }
  
  header .brand{
    width:100%;
    justify-content:center;
  }
  
  .top-nav{
    width:100%;
    display:flex;
    justify-content:center;
    gap:10px;
  }
  
  .top-nav .nav-link{
    flex:1;
    text-align:center;
    padding:10px;
    white-space:nowrap;
  }
  
  .header-controls{
    width:100%;
    justify-content:center;
  }
  
  /* Show hamburger menu on mobile */
  .hamburger-menu {
    display: flex;
  }
  
  /* Hide desktop sidebar toggle on mobile */
  .sidebar-toggle {
    display: none;
  }
  
  /* Mobile sidebar styling */
  section.left {
    position: fixed;
    top: 0;
    left: -100%;
    width: 85%;
    max-width: 340px;
    height: 100vh;
    max-height: 100vh;
    z-index: 1000;
    background: var(--card);
    overflow-y: scroll;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    transition: left 0.3s ease;
    box-shadow: 4px 0 12px rgba(0,0,0,0.3);
    padding: 80px 16px 40px 16px;
  }
  
  section.left.mobile-open {
    left: 0;
  }
  
  /* Ensure right section takes full width on mobile */
  section.right {
    width: 100%;
    order: 1;
  }
  
  section.left {
    order: 2;
  }
  
  section.left.mobile-open {
    left: 0;
  }
  
  /* Stack columns on narrow screens and show chat first for immediate access */
  .container{flex-direction:column-reverse;gap:12px;overflow-x:hidden}
  
  /* Improve mobile chat header layout */
  .chat-header{
    padding:10px 12px;
    flex-direction:column;
    align-items:stretch;
    gap:8px;
  }
  
  .chat-header-left{
    display:flex;
    flex-direction:column;
    align-items:stretch;
    gap:6px;
  }
  
  .chat-title{
    font-size:16px;
    text-align:center;
    margin:0;
  }
  
  /* Make selectors mobile-friendly */
  .selectors{
    display:flex;
    justify-content:space-around;
    gap:12px;
    margin:0;
    flex-wrap:wrap;
  }
  
  .selectors > div{
    display:flex;
    flex-direction:column;
    align-items:center;
    gap:4px;
    flex:1;
    min-width:70px;
  }
  
  .selectors label{
    font-size:11px;
    text-align:center;
    margin:0;
  }
  
  .selectors select{
    padding:8px 6px;
    font-size:12px;
    width:100%;
    text-align:center;
    border-radius:8px;
  }
  
  /* Ensure the saved mods checkbox fits well in mobile header */
  .use-mods-selector {
    font-size: 11px;
    gap: 4px;
    width:100%;
    justify-content:center;
  }
  
  .use-mods-selector .use-mods-checkbox {
    padding: 4px 6px;
    font-size: 11px;
    gap: 4px;
    white-space: normal;
    text-align: center;
  }
  
  .use-mods-selector .use-mods-checkbox span {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
  /* Icon-only buttons on mobile: hide text and show compact SVG icons via background-image */
  #sendBtn, .btn-new{position:relative;padding:8px;width:40px;height:36px;min-width:40px}
  #sendBtn{background-color:#1f6feb;border-radius:8px}
  .btn-new{background-color:#ffb020;border-radius:8px}
  /* hide the textual label but keep it for screen readers */
  #sendBtn::after, .btn-new::after{content:'';position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:18px;height:18px;background-repeat:no-repeat;background-size:18px 18px}
  /* paper-plane icon for send (SVG data URI) */
  #sendBtn::after{background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ffffff'><path d='M2 21l21-9L2 3v7l15 2-15 2v7z'/></svg>")}
  /* plus/chat icon for new chat */
  .btn-new::after{background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff'><path d='M12 5v14M5 12h14' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>")}
  /* hide visible text while keeping accessible label for screen readers */
  #sendBtn, .btn-new{color:transparent}
  section.left{flex:0 0 auto;order:2}
  section.right{order:1}
  .site-logo{height:64px;width:64px}
  body{padding:16px 12px calc(var(--footer-height,48px) + 16px)}
  /* Allow chat to expand more and prioritize it as the main mobile interface */
  .container{min-height:auto}
  .chat-card{height:auto;min-height:500px;max-height:none}
  .messages{
    padding:8px;
    gap:6px;
    /* Reduce bottom padding on mobile for better space utilization */
    padding-bottom:12px;
    max-height:60vh;
  }
  /* Mobile layout is now handled by more comprehensive rules above */
  .header-controls{flex-wrap:wrap}
}

/* Mobile: avoid nested scroll areas except for the chat messages pane - only on very small screens */
@media (max-width:480px){
  body {
    overflow-x: hidden;
    max-width: 100vw;
  }
  
  /* Mobile sidebar remains fixed with proper containment - don't override */
  /* The sidebar is position:fixed, so it needs to maintain scroll containment */
  section.left.mobile-open {
    /* Ensure proper containment when sidebar is open */
    max-height: 100vh;
    overflow-y: scroll;
    overflow-x: hidden;
  }
  
  /* When sidebar is closed (not mobile-open), ensure it's completely hidden */
  section.left:not(.mobile-open) {
    /* Force complete hiding */
    visibility: hidden;
    pointer-events: none;
  }
  
  .upload-card, .instructions{max-height:none;overflow:visible}
  /* CSV preview should expand and let the page scroll rather than scrolling internally */
  #csvPreview{max-height:none;overflow:visible}
  /* Ensure the main container doesn't hide overflow so the page scroll handles everything */
  .container{overflow:visible;width:100%;max-width:100%}
  /* Keep the chat messages internal scrolling only */
  .messages{overflow-y:auto}

  /* Make chat input use all available horizontal space and keep action buttons very compact */
  .chat-form{
    gap:6px;
    margin-bottom:0;
    padding:8px 12px;
  }
  #messageInput{flex:1 1 auto;min-width:0;width:auto;padding:8px 10px;font-size:16px;height:36px;max-height:100px} /* Prevent iOS zoom */
  /* Even smaller fixed-size icon buttons so they don't consume flexible space */
  #sendBtn, .btn-new{flex:0 0 32px;min-width:32px;width:32px;height:32px;padding:3px;border-radius:6px}
  /* reduce spacing between input and new-chat button */
  .btn-new{margin-left:2px}
  
  /* Further reduce checkbox text on very small screens to prevent overflow */
  .use-mods-selector .use-mods-checkbox {
    font-size: 10px;
    padding: 3px 4px;
    white-space: normal;
    text-align: center;
  }
  
  .use-mods-selector .use-mods-checkbox span {
    font-size: 10px;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
  
  /* Improve touch targets for buttons */
  .btn-primary, .btn-secondary, .btn-danger {
    min-height: 44px;
    padding: 12px;
  }
  
  #uploadBtn {
    min-height: 44px;
    width: 100%;
    touch-action: manipulation;
  }
}

/* Extra small screens (phones) */
@media (max-width:600px){
  body{
    padding:12px 10px 2px;
    overflow-x:hidden;
  }
  
  /* Ensure full-width containers */
  .container, section.left, section.right {
    width: 100%;
    max-width: 100%;
  }
  
  /* slightly smaller logo and tighter header */
  .site-logo{height:64px;width:64px;margin-right:10px}
  header.site-header{padding:14px 12px;gap:12px}
  header .brand{gap:10px}
  header .brand h1{font-size:22px;letter-spacing:0.08em} /* Larger, more emphasis */
  header .brand .brand-sub{font-size:11px;margin-top:4px;letter-spacing:0.03em} /* Visible slogan */
  
  /* Navigation styling for mobile */
  .top-nav{gap:12px}
  .top-nav .nav-link{
    padding:10px 14px;
    font-size:14px;
    font-weight:500;
  }
  .upload-card, .mods-card, .chat-card, .instructions{padding:12px}
  /* Slightly smaller input text and padding so the input retains space */
  #messageInput{padding:10px;border-radius:8px;font-size:16px;height:40px;max-height:100px} /* Prevent iOS zoom */
  /* Reduce button size on phones so they don't dominate the input area */
  button[type=submit], #uploadBtn, .btn-new{padding:8px 10px;font-size:14px}
  /* Override desktop min-width for send/new buttons so they remain compact on mobile */
  #sendBtn, .btn-new{min-width:32px}
  /* Slightly tighter gap to allow more input room */
  .chat-form{
    gap:6px;
    margin-bottom:8px;
    padding:8px 10px;
  }
  /* Slightly reduce new button left margin */
  .btn-new{margin-left:6px}
  .msg{font-size:15px;max-width:92%;word-wrap:break-word;word-break:break-word;overflow-wrap:break-word;white-space:pre-wrap}
  .msg.bot, .msg.user{padding:10px}
  .chat-card{min-height:calc(100vh - 100px);margin-bottom:4px}

  .site-footer{bottom:0;--footer-height:42px;padding:6px 10px;margin-top:4px}

  /* Keep the theme label visible on narrow screens but reduce its size to avoid clutter */
  .theme-switch-wrapper .theme-note{display:inline-block;font-size:12px}

  /* Make send-status compact on phones */
  .send-status{min-width:20px;margin-right:4px}

  /* Keep the chat title on a single line on mobile; truncate with ellipsis if needed */
  /* Mobile layout is now handled by the main mobile section above */

  /* Slightly reduce the user badge size on mobile */
  .chat-header .user-info{font-size:12px;padding:4px 6px}

  /* Limit the chat messages height on mobile so the chat pane becomes the primary scroll area
    and the page doesn't create awkward double-scroll behavior. This is conservative and avoids
    truncation while keeping the rest of the page accessible. */
  .messages{max-height:calc(100vh - 200px);overflow-y:auto}
}

/* On very small screens, make footer part of document flow to avoid overlap */
@media (max-width:600px){
  .site-footer{position:static;pointer-events:auto;}
  
  /* Remove bottom padding from body since footer is now in document flow */
  body{
    padding-bottom: 8px;
  }
  
  /* Ensure no extra space is created when textarea expands */
  .container{
    padding-bottom: 0;
  }
  
  /* Keep footer tight to content */
  .site-footer{
    margin-top: 8px;
  }
}

@media (max-width:420px){
  /* Make header fully responsive on very small screens */
  header.site-header{
    flex-direction:column;
    align-items:stretch;
    padding:12px 10px;
  }
  
  header .brand{
    justify-content:center;
    width:100%;
    gap:8px;
  }
  
  .site-logo{height:56px;width:56px;margin-right:8px}
  header .brand h1{font-size:20px;letter-spacing:0.06em}
  header .brand .brand-sub{font-size:10px;margin-top:3px}
  
  .top-nav{
    display:flex;
    width:100%;
    justify-content:center;
    gap:8px;
  }
  
  .top-nav .nav-link{
    flex:1;
    text-align:center;
    padding:10px 8px;
    font-size:13px;
  }

  .header-controls{gap:6px;width:100%;justify-content:center}
  
  /* Extra compact selectors for very narrow screens */
  .selectors{
    gap:8px;
  }
  
  .selectors label{
    font-size:10px;
  }
  
  .selectors select{
    padding:6px 4px;
    font-size:11px;
    min-width:60px;
  }
}
/* Updated template asset versions */

/* Place the user info badge at the far right of the chat card (near restore/banner actions) */
.chat-card{position:relative}
.chat-card .user-info{position:absolute;top:12px;right:12px;z-index:20;white-space:nowrap}

/* Ensure the messages pane leaves room at the top so the first message isn't obscured
   by any overlapping banners or absolute-positioned controls when users scroll to top. */
.chat-card .messages{
  padding-top:20px; /* extra breathing room so the first message is visible */
  padding-bottom:16px; /* reduced space for better utilization */
  scroll-padding-top:80px; /* helps scrollIntoView and anchor behaviors */
  overscroll-behavior:contain;
}

/* When user-info is inside the chat header use a static inline layout */
.chat-header .user-info{position:static;top:auto;right:auto;margin:0;padding:6px 8px;border-radius:6px;background:transparent;border:1px solid rgba(255,255,255,0.02)}

/* header placement for user badge (top-right area) */
.header-controls .user-info{
  position:relative;
  top:0;
  right:0;
  margin-left:12px;
  background:transparent;
  padding:4px 8px;
  border-radius:12px;
  font-size:13px;
  color:var(--text);
  display:flex;
  align-items:center;
  transition:all 0.3s ease;
  cursor:pointer;
}
.header-controls .user-info:hover{
  background:var(--glass);
  transform:translateY(-1px);
}

.header-controls .user-info .user-email{ font-weight:600; margin-right:6px; }
.header-controls .user-info .tier{ opacity: 0.95; color:#ff8c00; font-weight:600; }

/* When moved into the restore banner, make the badge inline and proportionate */
.user-info.in-banner{position:static;top:auto;right:auto;margin:0;padding:6px 8px;border-radius:6px;background:transparent;border:1px solid rgba(0,0,0,0.04);font-size:13px;color:var(--muted)}
.user-info.in-banner .tier{color:#ff8c00}


/* Emergency: ensure any leftover mobile FAB elements are hidden (covers cached DOM remnants) */
.mobile-fab-wrapper, .fab, #fabUpload, #fabNewChatMobile { display: none !important; visibility: hidden !important; pointer-events: none !important; }

/* Broader coverage: hide any legacy buttons left over that reference upload/new chat via title or aria-label
   NOTE: exclude the intentional .btn-new control so it remains visible and accessible. */
button[title*="Upload"], button[title*="upload"], button[aria-label*="Upload"], button[aria-label*="upload"],
button[title*="New"]:not(.btn-new), button[title*="new"]:not(.btn-new), button[aria-label*="New"]:not(.btn-new), button[aria-label*="new"]:not(.btn-new) {
  display: none !important; visibility: hidden !important; pointer-events: none !important;
}

/* Enhanced Markdown Rendering Styles with Color-Coded Heading Levels */
.msg.bot h2, .msg.bot h3, .msg.bot h4, .msg.bot h5, .msg.bot h6 {
  margin: 8px 0 4px 0;
  font-weight: 600;
  line-height: 1.3;
}

/* Heading Level Colors - Different shades of blue/green/orange */
.msg.bot h2 { 
  color: #00d1b2; /* Main accent - bright teal for h2 (##) */
  font-size: 1.35em; 
  border-bottom: 1px solid rgba(0,209,178,0.3); 
  padding-bottom: 4px; 
}

.msg.bot h3 { 
  color: #4fc3f7; /* Light blue for h3 (###) */
  font-size: 1.2em; 
}

.msg.bot h4 { 
  color: #ffb74d; /* Orange for h4 (####) */
  font-size: 1.1em; 
}

.msg.bot h5 { 
  color: #81c784; /* Light green for h5 (#####) */
  font-size: 1em; 
}

.msg.bot h6 { 
  color: #ba68c8; /* Light purple for h6 (######) */
  font-size: 1em; 
}

/* Code blocks and inline code */
.msg.bot code {
  background: rgba(255,255,255,0.05);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.9em;
  border: 1px solid rgba(255,255,255,0.1);
}

.msg.bot pre {
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 12px;
  margin: 12px 0;
  overflow-x: auto;
  line-height: 1.4;
}

.msg.bot pre code {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 0.85em;
  white-space: pre;
}

/* Lists */
.msg.bot ul, .msg.bot ol {
  margin: 4px 0;
  padding-left: 20px;
}

.msg.bot li {
  margin: 4px 0;
  line-height: 1.5;
}

.msg.bot ul li {
  list-style-type: disc;
}

.msg.bot ol li {
  list-style-type: decimal;
}

/* Nested list styling for better visual hierarchy */
.msg.bot li[style*="margin-left"] {
  border-left: 1px solid rgba(0,209,178,0.2);
  padding-left: 12px;
  margin-top: 4px;
  margin-bottom: 4px;
}

/* Indented bullet points under numbered items */
.msg.bot ol li[style*="list-style-type: disc"] {
  list-style-type: disc !important;
  margin-left: 20px;
  font-size: 0.95em;
  /* Use normal text color instead of muted - removed: color: rgba(207, 238, 240, 0.9); */
}

/* Nested lists within lists */
.msg.bot ul ul, .msg.bot ol ol, .msg.bot ul ol, .msg.bot ol ul {
  margin: 4px 0;
  padding-left: 16px;
}

.msg.bot ul ul li, .msg.bot ol ol li, .msg.bot ul ol li, .msg.bot ol ul li {
  margin: 3px 0;
  font-size: 0.95em;
}

/* Different bullet styles for nested unordered lists */
.msg.bot ul ul li {
  list-style-type: circle;
}

.msg.bot ul ul ul li {
  list-style-type: square;
}

/* Text formatting */
.msg.bot strong {
  font-weight: 700;
  color: #00d1b2; /* Same as main accent - bright teal for emphasis */
  text-shadow: 0 0 4px rgba(0,209,178,0.2); /* Subtle glow effect */
}

.msg.bot em {
  font-style: italic;
  opacity: 0.9;
}

/* Links */
.msg.bot a {
  color: var(--accent);
  text-decoration: underline;
  opacity: 0.9;
}

.msg.bot a:hover {
  opacity: 1;
  text-decoration: none;
}

/* Horizontal rules */
.msg.bot hr {
  border: none;
  height: 1px;
  background: rgba(255,255,255,0.1);
  margin: 20px 0;
}

/* Paragraphs */
.msg.bot p {
  margin: 4px 0;
  line-height: 1.6;
}

/* Checkboxes */
.msg.bot input[type="checkbox"] {
  margin-right: 8px;
  accent-color: var(--accent);
}

/* Light theme adjustments */
:root.light .msg.bot code {
  background: rgba(0,0,0,0.05);
  border: 1px solid rgba(0,0,0,0.1);
}

:root.light .msg.bot pre {
  background: rgba(0,0,0,0.02);
  border: 1px solid rgba(0,0,0,0.1);
}

:root.light .msg.bot hr {
  background: rgba(0,0,0,0.1);
}

/* Light theme heading colors - slightly darker for better contrast */
:root.light .msg.bot h2 { 
  color: #00a693; /* Darker teal for light theme */
  border-bottom: 1px solid rgba(0,166,147,0.3); 
}

:root.light .msg.bot h3 { 
  color: #0288d1; /* Darker blue for light theme */
}

:root.light .msg.bot h4 { 
  color: #f57c00; /* Darker orange for light theme */
}

:root.light .msg.bot h5 { 
  color: #388e3c; /* Darker green for light theme */
}

:root.light .msg.bot h6 { 
  color: #7b1fa2; /* Darker purple for light theme */
}

/* Light theme bold text */
:root.light .msg.bot strong {
  color: #00a693; /* Darker teal for better contrast in light theme */
  text-shadow: 0 0 4px rgba(0,166,147,0.15); /* Subtle glow effect */
}

/* Removed duplicate table styles - consolidated above at line 1141 */

.msg.bot tr:last-child td {
  border-bottom: none;
}

/* Striped rows for better readability */
.msg.bot tr:nth-child(even) td {
  background: rgba(255,255,255,0.02);
}

/* Light theme table adjustments */
:root.light .msg.bot table {
  border: 1px solid rgba(0,0,0,0.15);
  background: rgba(0,0,0,0.02);
}

:root.light .msg.bot td, 
:root.light .msg.bot th {
  border-bottom: 1px solid rgba(0,0,0,0.1);
  border-right: 1px solid rgba(0,0,0,0.1);
  color: var(--bot-text);
}

:root.light .msg.bot th {
  background: rgba(0,166,147,0.1);
  color: #00a693;
}

:root.light .msg.bot tr:nth-child(even) td {
  background: rgba(0,0,0,0.03);
}

/* Responsive table handling for mobile */
@media (max-width: 768px) {
  .msg.bot table, .parameter-table {
    font-size: 11px;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    max-width: 100%;
  }
  
  .msg.bot td, .msg.bot th, .parameter-table td, .parameter-table th {
    padding: 6px 8px;
    min-width: 80px;
  }
  
  /* Wrapper for tables to show scroll indicator */
  .parameter-table {
    position: relative;
  }
  
  .parameter-table::after {
    content: '← Swipe to see all columns →';
    display: block;
    text-align: center;
    padding: 8px;
    font-size: 11px;
    color: var(--muted);
    background: var(--hover);
    border-radius: 0 0 8px 8px;
    margin-top: -8px;
  }
}

@media (max-width: 480px) {
  .msg.bot table, .parameter-table {
    font-size: 9px;
    border-radius: 6px;
  }
  
  .msg.bot td, .msg.bot th, .parameter-table td, .parameter-table th {
    padding: 4px 6px;
    min-width: 70px;
  }
  
  /* All columns scroll together - no sticky first column */
  .msg.bot td:first-child, 
  .msg.bot th:first-child,
  .parameter-table td:first-child,
  .parameter-table th:first-child {
    min-width: 70px;
    position: static;
  }
}

/* Image and Graph Styles for AI-generated visualizations */
.msg.bot img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  margin: 12px 0;
  display: block;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  background: rgba(0,0,0,0.15);
  padding: 8px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.msg.bot img:hover {
  transform: scale(1.02);
  box-shadow: 0 6px 20px rgba(0,209,178,0.15);
  border-color: rgba(0,209,178,0.3);
}

/* Special styling for data visualizations and graphs */
.msg.bot img[alt*="graph" i],
.msg.bot img[alt*="chart" i],
.msg.bot img[alt*="plot" i],
.msg.bot img[alt*="visualization" i],
.msg.bot img[src*="graph"],
.msg.bot img[src*="chart"],
.msg.bot img[src*="plot"] {
  border: 2px solid rgba(0,209,178,0.2);
  padding: 12px;
  background: rgba(0,0,0,0.2);
  box-shadow: 0 4px 16px rgba(0,209,178,0.1);
}

.msg.bot img[alt*="graph" i]:hover,
.msg.bot img[alt*="chart" i]:hover,
.msg.bot img[alt*="plot" i]:hover,
.msg.bot img[alt*="visualization" i]:hover {
  border-color: rgba(0,209,178,0.4);
  box-shadow: 0 6px 24px rgba(0,209,178,0.2);
}

/* Figure captions for graphs */
.msg.bot figure {
  margin: 16px 0;
  padding: 0;
}

.msg.bot figcaption {
  color: var(--muted);
  font-size: 0.9em;
  text-align: center;
  padding: 8px;
  font-style: italic;
  background: rgba(0,209,178,0.05);
  border-radius: 0 0 6px 6px;
  margin-top: -8px;
}

/* Light theme adjustments for images and graphs */
:root.light .msg.bot img {
  border: 1px solid rgba(0,0,0,0.15);
  background: rgba(0,0,0,0.02);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

:root.light .msg.bot img:hover {
  box-shadow: 0 6px 20px rgba(0,166,147,0.15);
  border-color: rgba(0,166,147,0.3);
}

:root.light .msg.bot img[alt*="graph" i],
:root.light .msg.bot img[alt*="chart" i],
:root.light .msg.bot img[alt*="plot" i],
:root.light .msg.bot img[alt*="visualization" i] {
  border: 2px solid rgba(0,166,147,0.2);
  background: rgba(0,166,147,0.03);
  box-shadow: 0 4px 16px rgba(0,166,147,0.1);
}

:root.light .msg.bot img[alt*="graph" i]:hover,
:root.light .msg.bot img[alt*="chart" i]:hover,
:root.light .msg.bot img[alt*="plot" i]:hover,
:root.light .msg.bot img[alt*="visualization" i]:hover {
  border-color: rgba(0,166,147,0.4);
  box-shadow: 0 6px 24px rgba(0,166,147,0.2);
}

:root.light .msg.bot figcaption {
  background: rgba(0,166,147,0.05);
}

/* Responsive image handling for mobile */
@media (max-width: 768px) {
  .msg.bot img {
    padding: 6px;
    margin: 10px 0;
  }
  
  .msg.bot img[alt*="graph" i],
  .msg.bot img[alt*="chart" i],
  .msg.bot img[alt*="plot" i],
  .msg.bot img[alt*="visualization" i] {
    padding: 10px;
  }
  
  .msg.bot figcaption {
    font-size: 0.85em;
    padding: 6px;
  }
}

@media (max-width: 480px) {
  .msg.bot img {
    padding: 4px;
    margin: 8px 0;
    border-radius: 6px;
  }
  
  .msg.bot img[alt*="graph" i],
  .msg.bot img[alt*="chart" i],
  .msg.bot img[alt*="plot" i],
  .msg.bot img[alt*="visualization" i] {
    padding: 8px;
  }
  
  .msg.bot figcaption {
    font-size: 0.8em;
    padding: 4px;
  }
}

/* Welcome Page Styles */
.welcome-page {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.hero-section {
  text-align: center;
  margin-bottom: 3rem;
}

.hero-content {
  max-width: 600px;
  margin: 0 auto;
}

.hero-logo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin-bottom: 1.5rem;
  object-fit: cover;
  box-shadow: 0 4px 20px rgba(0, 209, 178, 0.2);
}

.hero-title {
  font-size: 2.5rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #00a693);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 1.3rem;
  color: var(--muted);
  margin-bottom: 1rem;
  font-weight: 600;
}

.hero-description {
  font-size: 1.1rem;
  color: var(--text);
  line-height: 1.6;
  opacity: 0.9;
}

.features-section {
  margin-bottom: 3rem;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.feature-card {
  background: var(--card);
  padding: 1.5rem;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.06);
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.feature-card h3 {
  font-size: 1.1rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.feature-card p {
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

.pricing-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 2rem;
  justify-content: center;
  margin-bottom: 3rem;
  max-width: 1000px;
  margin-left: auto;
  margin-right: auto;
}

.pricing-card {
  background: var(--card);
  border: 2px solid var(--accent);
  border-radius: 16px;
  padding: 2rem;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 209, 178, 0.1);
  transition: transform 0.3s ease;
}

.pricing-card:hover {
  transform: translateY(-4px);
}

.premium-card {
  border: 3px solid #ffd700;
  box-shadow: 0 8px 30px rgba(255, 215, 0, 0.2);
  position: relative;
}

.premium-badge {
  display: inline-block;
  background: linear-gradient(135deg, #ffd700, #ffed4e);
  color: #000;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.3rem 0.7rem;
  border-radius: 12px;
  letter-spacing: 0.5px;
  margin-left: 0.5rem;
  vertical-align: middle;
}

.price-header h3 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--text);
}

.price-header {
  margin-bottom: 1.5rem;
}

.price-amount {
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.price-period {
  font-size: 1.1rem;
  color: var(--muted);
  font-weight: 500;
}

.feature-list {
  list-style: none;
  padding: 0;
  margin: 0 0 2rem 0;
  text-align: left;
}

.feature-list li {
  padding: 0.5rem 0;
  color: var(--text);
  font-size: 0.95rem;
}

.feature-list li:before {
  content: attr(data-check);
  margin-right: 0.75rem;
  color: var(--accent);
  font-weight: 600;
}

.cta-button {
  display: inline-block;
  background: linear-gradient(135deg, var(--accent), #00a693);
  color: white;
  font-size: 1.2rem;
  font-weight: 600;
  padding: 1rem 2rem;
  border-radius: 10px;
  text-decoration: none;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 209, 178, 0.3);
  margin-bottom: 1rem;
}

.cta-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 209, 178, 0.4);
  color: white;
  text-decoration: none;
}

.premium-button {
  background: linear-gradient(135deg, #ffd700, #ffed4e);
  color: #000;
  box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
}

.premium-button:hover {
  box-shadow: 0 6px 20px rgba(255, 215, 0, 0.5);
  color: #000;
}

.learn-more-section {
  text-align: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.learn-more-button {
  display: inline-block;
  background: linear-gradient(135deg, #4a5568, #2d3748);
  color: white;
  font-size: 1rem;
  font-weight: 500;
  padding: 0.8rem 1.5rem;
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.3s ease;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  margin-bottom: 0.5rem;
}

.learn-more-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  color: white;
  text-decoration: none;
  background: linear-gradient(135deg, #5a6578, #3d4758);
}

.learn-more-note {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
  opacity: 0.8;
}

.payment-note {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.4;
  margin: 0;
}

.payment-note small {
  font-size: 0.8rem;
  opacity: 0.8;
}

.error-message {
  color: #e74c3c;
  font-weight: 600;
  padding: 1rem;
  background: rgba(231, 76, 60, 0.1);
  border-radius: 8px;
  margin-bottom: 1rem;
}

.steps-section {
  background: var(--glass);
  border-radius: 16px;
  padding: 2rem;
  margin-bottom: 2rem;
  text-align: center;
}

.steps-section h3 {
  color: var(--accent);
  font-size: 1.5rem;
  margin-bottom: 2rem;
  font-weight: 600;
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
}

.step {
  text-align: center;
}

.step-number {
  width: 40px;
  height: 40px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  margin: 0 auto 1rem;
  font-size: 1.2rem;
}

.step p {
  color: var(--text);
  line-height: 1.5;
  margin: 0;
}

.status-section {
  text-align: center;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--glass);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 25px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .welcome-page {
    padding: 1rem 0.5rem;
  }
  
  .hero-title {
    font-size: 2rem;
  }
  
  .hero-subtitle {
    font-size: 1.1rem;
  }
  
  .features-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .feature-card {
    padding: 1rem;
  }
  
  .pricing-card {
    margin: 0 0.5rem;
    padding: 1.5rem;
  }
  
  .price-amount {
    font-size: 2.5rem;
  }
  
  .cta-button {
    font-size: 1.1rem;
    padding: 0.875rem 1.5rem;
  }
  
  .steps-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .steps-section {
    padding: 1.5rem;
  }
}

@media (max-width: 480px) {
  .hero-logo {
    width: 60px;
    height: 60px;
  }
  
  .hero-title {
    font-size: 1.75rem;
  }
  
  .hero-description {
    font-size: 1rem;
  }
  
  .pricing-card {
    padding: 1rem;
  }
  
  .price-amount {
    font-size: 2rem;
  }
}

/* Auth-related CSS removed to restore original layout */

/* CSV Input Security Warning Styles */
.csv-input-warning {
  background: linear-gradient(135deg, rgba(255, 59, 48, 0.15), rgba(255, 149, 0, 0.15));
  border: 2px solid rgba(255, 59, 48, 0.4);
  border-radius: 12px;
  padding: 12px 16px;
  margin: 0 12px 12px 12px;
  animation: slideDown 0.3s ease-out, shake 0.5s ease-in-out;
  box-shadow: 0 4px 12px rgba(255, 59, 48, 0.2);
}

.csv-warning-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.csv-warning-icon {
  font-size: 24px;
  flex-shrink: 0;
  animation: pulse 2s ease-in-out infinite;
}

.csv-warning-text {
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
}

/* Error state for input field */
#messageInput.csv-error {
  border-color: rgba(255, 59, 48, 0.6) !important;
  box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.15) !important;
  animation: shake 0.5s ease-in-out;
}

/* Animations */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
  20%, 40%, 60%, 80% { transform: translateX(4px); }
}

@keyframes pulse {
  0%, 100% { 
    opacity: 1;
    transform: scale(1);
  }
  50% { 
    opacity: 0.7;
    transform: scale(1.1);
  }
}

/* Light theme adjustments for CSV warning */
:root.light .csv-input-warning {
  background: linear-gradient(135deg, rgba(255, 59, 48, 0.08), rgba(255, 149, 0, 0.08));
  border-color: rgba(255, 59, 48, 0.3);
}

:root.light .csv-warning-text {
  color: #8b0000;
}

/* Interactive Graph Styles */
.plotly-graph-container {
  transition: transform 0.2s ease;
  overflow: hidden !important;
  padding-bottom: 80px !important;
  margin-bottom: 20px;
  min-height: 450px;
  width: 100%;
  position: relative;
  cursor: pointer;
}

.plotly-graph-container:hover {
  transform: scale(1.01);
}

/* Remove pointer cursor on mobile */
@media (max-width: 640px) {
  .plotly-graph-container {
    cursor: default;
  }
  
  .plotly-graph-container:hover {
    transform: none;
  }
}

/* Graph Modal Overlay */
.graph-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.9);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
  cursor: pointer;
}

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

@keyframes fadeInOut {
  0% { opacity: 0; }
  5% { opacity: 1; }
  90% { opacity: 1; }
  100% { opacity: 0; }
}

.graph-modal-content {
  background: var(--card);
  border-radius: 12px;
  width: 95vw;
  height: 90vh;
  max-width: 1600px;
  padding: 20px;
  position: relative;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  cursor: default;
  overflow: hidden;
}

.graph-modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text);
  font-size: 28px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 10001;
}

.graph-modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.graph-modal-container {
  width: 100%;
  height: 100%;
}

@media (max-width: 640px) {
  .graph-modal-content {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    padding: 15px;
  }
  
  .graph-modal-close {
    top: 10px;
    right: 10px;
  }
}

/* Mobile-specific graph styles */
@media (max-width: 640px) {
  .msg {
    max-width: 100% !important;
  }

  .msg.bot {
    max-width: 96% !important;
  }

  .plotly-graph-container {
    min-height: 550px !important;
    max-height: 650px !important;
    padding: 2px !important;
    padding-bottom: 8px !important;
    margin: 16px -6px !important; /* Negative margin to extend to bubble edges */
    width: calc(100% + 12px) !important; /* Compensate for negative margins */
    transform: none !important; /* Disable hover effect on mobile */
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  }
  
  .plotly-graph-container:hover {
    transform: none;
  }
  
  /* Make sure graph fills container on mobile */
  .plotly-graph-container > div {
    width: 100% !important;
    height: 100% !important;
    min-height: 500px !important;
  }
  
  /* Hide modebar completely on mobile */
  .plotly-graph-container .modebar,
  .plotly-graph-container .modebar-container {
    display: none !important;
  }
  
  /* Increase font sizes for mobile readability */
  .plotly-graph-container .xtick text,
  .plotly-graph-container .ytick text {
    font-size: 11px !important;
  }
  
  .plotly-graph-container .xtitle,
  .plotly-graph-container .ytitle {
    font-size: 13px !important;
  }
  
  /* Make graph title larger on mobile */
  .plotly-graph-container .g-gtitle text {
    font-size: 14px !important;
  }
  
  /* Legend adjustments for mobile */
  .plotly-graph-container .legend {
    font-size: 11px !important;
  }
  
  /* Reduce bot message padding on mobile to let graphs breathe */
  .msg.bot {
    padding: 8px 6px !important;
  }
}

/* Ensure message containers don't clip graph content */
.msg.bot {
  overflow: visible !important;
}

/* Force black text in light mode for Plotly graphs */
:root.light .plotly-graph-container .gtitle,
:root.light .plotly-graph-container .xtitle,
:root.light .plotly-graph-container .ytitle,
:root.light .plotly-graph-container .xtick text,
:root.light .plotly-graph-container .ytick text,
:root.light .plotly-graph-container text {
  fill: #000000 !important;
  color: #000000 !important;
}

/* Force white background in light mode */
:root.light .plotly-graph-container .bg {
  fill: #FFFFFF !important;
}

:root.light .plotly-graph-container .plot,
:root.light .plotly-graph-container .subplot {
  background: #FFFFFF !important;
}

.graph-error {
  background: rgba(255, 68, 68, 0.1);
  border: 1px solid rgba(255, 68, 68, 0.3);
  border-radius: 8px;
  padding: 16px;
  margin: 12px 0;
  color: var(--text);
}

.graph-placeholder {
  min-height: 450px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border-radius: 8px;
  margin: 16px 0;
}

.graph-placeholder::after {
  content: 'Loading graph...';
  color: var(--muted);
  font-size: 14px;
}

/* Clickable prompt suggestion buttons */
.prompt-suggestion {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  margin: 4px 4px 4px 0;
  background: linear-gradient(135deg, rgba(0, 209, 178, 0.12), rgba(0, 209, 178, 0.08));
  border: 1px solid rgba(0, 209, 178, 0.3);
  border-radius: 20px;
  color: var(--accent);
  font-family: 'Quantico', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.prompt-suggestion:hover {
  background: linear-gradient(135deg, rgba(0, 209, 178, 0.22), rgba(0, 209, 178, 0.15));
  border-color: rgba(0, 209, 178, 0.5);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 209, 178, 0.2);
}

.prompt-suggestion:active {
  transform: translateY(0);
}

.prompt-icon {
  font-size: 16px;
  line-height: 1;
}

.prompt-text {
  line-height: 1.3;
}

/* Light theme adjustments for prompt buttons */
:root.light .prompt-suggestion {
  background: linear-gradient(135deg, rgba(3, 102, 214, 0.1), rgba(3, 102, 214, 0.06));
  border-color: rgba(3, 102, 214, 0.3);
  color: var(--accent);
}

:root.light .prompt-suggestion:hover {
  background: linear-gradient(135deg, rgba(3, 102, 214, 0.18), rgba(3, 102, 214, 0.12));
  border-color: rgba(3, 102, 214, 0.5);
  box-shadow: 0 4px 12px rgba(3, 102, 214, 0.15);
}