:root {
  /* Primary brand colors */
  --primary-purple: #6B4C9A;
  --primary-purple-light: #8B6CB0;
  --primary-purple-dark: #4A3470;

  /* Text colors */
  --text-primary: #FFFFFF;
  --text-secondary: #A8A0B8;
  --text-muted: #6B6280;

  /* Status colors */
  --success: #4CAF50;
  --error: #E57373;
  --warning: #FFB74D;

  /* Accent (used for links) */
  --accent-yellow: #F5C142;
}

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

/* Smooth scrolling globally */
html {
  scroll-behavior: smooth;
  /* Prevent overscroll bounce */
  overscroll-behavior: none;
}

/* Mobile viewport fixes */
html, body {
  /* Prevent pull-to-refresh and overscroll */
  overscroll-behavior-y: none;
  /* Use full viewport on iOS */
  height: 100%;
  height: -webkit-fill-available;
}

body {
  /* Prevent text size adjustment */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Prevent touch callouts */
  -webkit-touch-callout: none;
}

/* Message entrance animation */
@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(
    145deg,
    #110a15 0%,
    #180f20 15%,
    #22162e 35%,
    #2c1d3c 55%,
    #352448 75%,
    #261a32 100%
  );
  min-height: 100vh;
  color: var(--text-primary);
  display: flex;
}

/* Sidebar */
.sidebar {
  width: 300px;
  min-width: 300px;
  background: linear-gradient(180deg, #1a1024 0%, #150c1c 50%, #120a18 100%);
  border-right: 1px solid rgba(107, 76, 154, 0.15);
  display: flex;
  flex-direction: column;
  height: 100vh;
  transition: width 0.3s ease, min-width 0.3s ease, border 0.3s ease, opacity 0.3s ease;
  overflow: hidden;
}

.sidebar.hidden {
  width: 0;
  min-width: 0;
  border-right: none;
}

.sidebar.hidden > * {
  opacity: 0;
  pointer-events: none;
}

/* Sidebar toggle button */
.sidebar-toggle {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 100;
  width: 36px;
  height: 36px;
  background: rgba(107, 76, 154, 0.15);
  border: 1px solid rgba(107, 76, 154, 0.25);
  border-radius: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  opacity: 0;
  pointer-events: none;
}

.sidebar-toggle:hover {
  background: rgba(107, 76, 154, 0.3);
  border-color: rgba(107, 76, 154, 0.4);
  color: var(--text-primary);
}

.sidebar.hidden ~ .main-content .sidebar-toggle,
body:has(.sidebar.hidden) .sidebar-toggle {
  opacity: 1;
  pointer-events: auto;
}

/* Hide sidebar button */
.hide-sidebar-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}

.hide-sidebar-btn:hover {
  background: rgba(107, 76, 154, 0.2);
  color: var(--text-primary);
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(107, 76, 154, 0.2);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.logo span {
  flex: 1;
}

.logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  overflow: hidden;
  background: white;
  padding: 4px;
}
.logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.new-chat-btn {
  width: 100%;
  margin-top: 16px;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--primary-purple) 0%, var(--primary-purple-light) 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.new-chat-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(107, 76, 154, 0.5);
}

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

/* Conversation List */
.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.conversation-list::-webkit-scrollbar {
  width: 6px;
}

.conversation-list::-webkit-scrollbar-track {
  background: transparent;
}

.conversation-list::-webkit-scrollbar-thumb {
  background: rgba(107, 76, 154, 0.3);
  border-radius: 3px;
}

.conversation-item {
  padding: 14px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 4px;
  border: 1px solid transparent;
}

.conversation-item:hover {
  background: rgba(107, 76, 154, 0.2);
  transform: translateX(4px);
}

.conversation-item.active {
  background: linear-gradient(135deg, rgba(107, 76, 154, 0.3) 0%, rgba(139, 108, 176, 0.2) 100%);
  border: 1px solid var(--primary-purple);
  box-shadow: 0 0 20px rgba(107, 76, 154, 0.2);
}

.conversation-item .title {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
}

.conversation-item .date {
  font-size: 12px;
  color: var(--text-muted);
}

.no-conversations {
  padding: 30px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* Auth Section */
.auth-section {
  padding: 20px;
  border-top: 1px solid rgba(107, 76, 154, 0.2);
  background: rgba(107, 76, 154, 0.1);
}

.auth-btn {
  width: 100%;
  padding: 10px;
  background: rgba(107, 76, 154, 0.2);
  color: var(--text-primary);
  border: 1px solid rgba(107, 76, 154, 0.3);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-btn:hover {
  background: rgba(107, 76, 154, 0.35);
  border-color: rgba(107, 76, 154, 0.5);
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.chat-header {
  padding: 20px 30px;
  border-bottom: 1px solid rgba(107, 76, 154, 0.15);
  background: linear-gradient(90deg, rgba(26, 16, 36, 0.95) 0%, rgba(20, 12, 28, 0.95) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.chat-header-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.chat-header-left h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.chat-header-left .subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* WebSocket Status Indicator */
.ws-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 12px;
  background: rgba(107, 76, 154, 0.15);
  border-radius: 10px;
  border: 1px solid rgba(107, 76, 154, 0.25);
  transition: opacity 0.3s ease, visibility 0.3s ease;
  width: 110px;
}


.ws-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--error);
  transition: all 0.3s ease;
}

.ws-status.connected .ws-dot {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.ws-status.streaming .ws-dot {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: streamPulse 1s ease-in-out infinite;
}

.ws-status.streaming .ws-label {
  color: var(--success);
}

@keyframes streamPulse {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 8px var(--success);
  }
  50% {
    opacity: 0.6;
    box-shadow: 0 0 16px var(--success);
  }
}

.ws-status.connecting .ws-dot {
  background: var(--warning);
  animation: pulse 1s infinite;
}

.ws-status.ready .ws-dot {
  background: var(--primary-purple-light);
  box-shadow: 0 0 8px var(--primary-purple-light);
}

.ws-status.polling .ws-dot {
  background: var(--text-muted);
  animation: pulse 1.5s ease-in-out infinite;
}

.ws-status.polling .ws-label {
  color: var(--text-muted);
}

.ws-status.connected .ws-label {
  color: var(--success);
}

.ws-status.connecting .ws-label {
  color: var(--warning);
}

.ws-status.ready .ws-label {
  color: var(--primary-purple-light);
}

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

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

/* Chat Container */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  position: relative;
}

#active-conversation {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

#active-conversation.hidden {
  display: none !important;
}

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 40px 50px 140px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 0;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  /* Hide scrollbar */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

.chat-container::-webkit-scrollbar {
  display: none; /* Chrome/Safari/Opera */
}

/* Messages */
.message {
  max-width: 80%;
  padding: 18px 22px;
  border-radius: 18px;
  line-height: 1.7;
  font-size: 15px;
  animation: messageSlideIn 0.3s ease-out forwards;
}

.message.user {
  background: linear-gradient(135deg, var(--primary-purple) 0%, var(--primary-purple-light) 100%);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 6px;
  box-shadow: 0 4px 16px rgba(107, 76, 154, 0.3);
}

.message.assistant {
  background: transparent;
  color: var(--text-primary);
  align-self: flex-start;
  border: none;
  padding: 18px 0;
}

.message.assistant:has(.tool-item.expanded) {
  max-width: 100%;
}

/* Typing indicator for streaming messages waiting for first token */
.message.streaming .streaming-pending {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.message.streaming .streaming-pending span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary-purple-light);
  animation: typing 1.4s infinite ease-in-out both;
}

.message.streaming .streaming-pending span:nth-child(1) { animation-delay: -0.32s; }
.message.streaming .streaming-pending span:nth-child(2) { animation-delay: -0.16s; }
.message.streaming .streaming-pending span:nth-child(3) { animation-delay: 0s; }

.message .role {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.7;
  margin-bottom: 8px;
  font-weight: 600;
}

/* Markdown in messages */
.message p { margin: 0 0 12px 0; }
.message p:last-child { margin-bottom: 0; }
.message ul, .message ol { margin: 12px 0; padding-left: 24px; }
.message li { margin: 6px 0; }
.message code {
  background: rgba(255,255,255,0.1);
  padding: 3px 8px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
}
.message pre {
  background: rgba(0,0,0,0.3);
  padding: 16px;
  border-radius: 12px;
  overflow-x: auto;
  margin: 12px 0;
}
.message pre code {
  background: none;
  padding: 0;
}
.message.user code { background: rgba(255,255,255,0.2); }
.message.user pre { background: rgba(0,0,0,0.2); }
.message h1, .message h2, .message h3, .message h4 {
  margin: 16px 0 10px 0;
  font-weight: 600;
}
.message h1:first-child, .message h2:first-child, .message h3:first-child {
  margin-top: 0;
}
.message blockquote {
  border-left: 3px solid var(--primary-purple);
  margin: 12px 0;
  padding-left: 16px;
  color: var(--text-secondary);
}
.message a { color: var(--accent-yellow); }

/* Tool calls styling */
.tool-calls, .tool-results {
  margin-bottom: 12px;
  max-width: 300px;
  transition: max-width 0.2s ease;
}

.tool-calls:has(.tool-item.expanded),
.tool-results:has(.tool-item.expanded) {
  max-width: 100%;
}
.tool-item {
  background: rgba(107, 76, 154, 0.15);
  border: 1px solid rgba(107, 76, 154, 0.3);
  border-radius: 10px;
  margin-bottom: 8px;
  font-size: 13px;
  overflow: hidden;
  transition: all 0.2s ease;
}

.tool-item:hover {
  background: rgba(107, 76, 154, 0.2);
}
.tool-item:last-child {
  margin-bottom: 0;
}
.tool-item.result {
  background: rgba(76, 175, 80, 0.1);
  border-color: rgba(76, 175, 80, 0.3);
}
.tool-item.error {
  background: rgba(229, 115, 115, 0.1);
  border-color: rgba(229, 115, 115, 0.3);
}
.tool-item.pending {
  border-color: var(--warning);
  background: rgba(255, 183, 77, 0.1);
}
.tool-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.tool-header:hover {
  background: rgba(255, 255, 255, 0.05);
}
.tool-icon {
  font-size: 14px;
  opacity: 0.8;
}
.tool-item.result .tool-icon {
  color: var(--success);
}
.tool-item.error .tool-icon {
  color: var(--error);
}
.tool-item.pending .tool-icon {
  color: var(--warning);
  animation: spin 1s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.tool-name {
  font-weight: 600;
  color: var(--primary-purple-light);
  flex: 1;
}
.tool-item.result .tool-name {
  color: var(--success);
}
.tool-item.error .tool-name {
  color: var(--error);
}
.tool-item.pending .tool-name {
  color: var(--warning);
}
.tool-chevron {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s;
}
.tool-item.expanded .tool-chevron {
  transform: rotate(90deg);
}
.tool-details {
  display: none;
  padding: 0 14px 12px;
}
.tool-item.expanded .tool-details {
  display: block;
}
.tool-args, .tool-output {
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
}
.tool-args-label, .tool-output-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.tool-output {
  max-height: 120px;
  overflow-y: auto;
}

.tool-item.expanded .tool-output {
  max-height: 300px;
}

.tool-output::-webkit-scrollbar {
  width: 6px;
}

.tool-output::-webkit-scrollbar-track {
  background: transparent;
}

.tool-output::-webkit-scrollbar-thumb {
  background: rgba(107, 76, 154, 0.3);
  border-radius: 3px;
}

.tool-output::-webkit-scrollbar-thumb:hover {
  background: rgba(107, 76, 154, 0.5);
}

.tool-see-more {
  display: block;
  margin-top: 8px;
  padding: 6px 10px;
  background: rgba(107, 76, 154, 0.2);
  border: 1px solid rgba(107, 76, 154, 0.3);
  border-radius: 6px;
  color: var(--primary-purple-light);
  font-size: 11px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.tool-see-more:hover {
  background: rgba(107, 76, 154, 0.3);
}

/* Tool Result Modal */
@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalScaleIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 40px;
  animation: modalFadeIn 0.2s ease-out;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: linear-gradient(145deg, rgba(26, 16, 36, 0.98) 0%, rgba(18, 10, 24, 0.98) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(107, 76, 154, 0.2);
  border-radius: 20px;
  max-width: 800px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  animation: modalScaleIn 0.3s ease-out;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(107, 76, 154, 0.2);
}

.modal-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

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

.modal-close:hover {
  background: rgba(107, 76, 154, 0.2);
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-body pre {
  background: rgba(8, 5, 12, 0.6);
  padding: 16px;
  border-radius: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

/* Streaming cursor */
.streaming-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--primary-purple-light);
  margin-left: 2px;
  animation: blink 1s step-end infinite;
  vertical-align: text-bottom;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Typing indicator for HTTP polling mode */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
.typing-indicator span:nth-child(3) { animation-delay: 0s; }

@keyframes typing {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

.message.pending {
  opacity: 0.7;
}

/* Input Area - floating */
.input-area {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 60px);
  max-width: 1100px;
  z-index: 10;
}

.input-container {
  position: relative;
  display: flex;
  gap: 12px;
  background: linear-gradient(135deg, rgba(26, 16, 36, 0.95) 0%, rgba(18, 10, 24, 0.98) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(107, 76, 154, 0.2);
  border-radius: 18px;
  padding: 8px;
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.2s;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(107, 76, 154, 0.05);
}

.input-container:focus-within {
  border-color: var(--primary-purple);
  box-shadow: 0 8px 32px rgba(107, 76, 154, 0.3), 0 0 0 2px rgba(107, 76, 154, 0.2);
  transform: translateY(-1px);
}

.input-container input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 12px 16px;
  color: var(--text-primary);
  /* 16px prevents iOS zoom on focus */
  font-size: 16px;
}

.input-container input:focus {
  outline: none;
}

.input-container input::placeholder {
  color: transparent;
}

.input-container .placeholder-glow {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  font-size: 16px;
  background: linear-gradient(
    90deg,
    var(--text-muted) 0%,
    var(--text-muted) 40%,
    var(--primary-purple-light) 50%,
    var(--text-muted) 60%,
    var(--text-muted) 100%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: placeholder-glow 3s ease-in-out infinite;
}

.input-container input:focus ~ .placeholder-glow,
.input-container input:not(:placeholder-shown) ~ .placeholder-glow {
  display: none;
}

@keyframes placeholder-glow {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

.send-btn {
  padding: 12px 24px;
  background: linear-gradient(135deg, var(--primary-purple) 0%, var(--primary-purple-light) 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.send-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(107, 76, 154, 0.5);
}

.send-btn:hover:not(:disabled) svg {
  transform: translate(2px, -2px);
}

.send-btn svg {
  transition: transform 0.2s ease;
}

.send-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Welcome Screen (New Conversation) */
#no-conversation {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  position: relative;
}

.welcome-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 30px 100px;
}

.welcome-content {
  text-align: center;
  max-width: 500px;
}

.welcome-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
  border-radius: 16px;
  overflow: hidden;
  background: white;
  padding: 10px;
}

.welcome-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.welcome-content h2 {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.welcome-subtitle {
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1.5;
}

/* Suggested Prompts */
.suggested-prompts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  padding: 0 30px;
  margin-bottom: 120px;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.suggested-prompt-btn {
  padding: 14px 24px;
  background: rgba(107, 76, 154, 0.15);
  border: 1px solid rgba(107, 76, 154, 0.3);
  border-radius: 24px;
  color: var(--text-secondary);
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.suggested-prompt-btn:hover {
  background: rgba(107, 76, 154, 0.25);
  border-color: var(--primary-purple);
  color: var(--text-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(107, 76, 154, 0.3);
}

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

/* Status Messages */
.status {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 16px;
}

.status.success {
  background: rgba(76, 175, 80, 0.1);
  border: 1px solid rgba(76, 175, 80, 0.3);
  color: var(--success);
}

.status.error {
  background: rgba(229, 115, 115, 0.1);
  border: 1px solid rgba(229, 115, 115, 0.3);
  color: var(--error);
}

.status.info {
  background: rgba(107, 76, 154, 0.1);
  border: 1px solid rgba(107, 76, 154, 0.3);
  color: var(--primary-purple-light);
}

/* Debug Button in Header */
.debug-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: rgba(18, 10, 24, 0.8);
  border: 1px solid rgba(107, 76, 154, 0.15);
  border-radius: 10px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.debug-btn:hover {
  background: rgba(107, 76, 154, 0.2);
  border-color: rgba(107, 76, 154, 0.3);
  color: var(--text-primary);
}

.debug-btn:active {
  transform: scale(0.95);
}

/* Debug Modal specific styles */
.debug-modal-content {
  max-width: 900px;
}

.debug-modal-content .modal-body pre {
  max-height: 60vh;
  overflow: auto;
}

.hidden { display: none !important; }

/* Central Login Screen */
.login-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    145deg,
    #110a15 0%,
    #180f20 15%,
    #22162e 35%,
    #2c1d3c 55%,
    #352448 75%,
    #261a32 100%
  );
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.login-card {
  background: linear-gradient(145deg, rgba(30, 20, 42, 0.98) 0%, rgba(22, 14, 32, 0.98) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(107, 76, 154, 0.25);
  border-radius: 24px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(107, 76, 154, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  animation: messageSlideIn 0.4s ease-out;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  border-radius: 16px;
  overflow: hidden;
  background: white;
  padding: 10px;
}

.login-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.login-header h1 {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.login-header p {
  color: var(--text-muted);
  font-size: 14px;
}

.login-form label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.login-form select,
.login-form input {
  width: 100%;
  padding: 12px 16px;
  background: rgba(8, 5, 12, 0.8);
  border: 1px solid rgba(107, 76, 154, 0.35);
  border-radius: 10px;
  color: var(--text-primary);
  /* 16px prevents iOS zoom on focus */
  font-size: 16px;
  margin-bottom: 16px;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.login-form select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23A8A0B8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.login-form input:focus,
.login-form select:focus {
  outline: none;
  border-color: var(--primary-purple-light);
  background: rgba(12, 8, 18, 0.9);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3), 0 0 0 3px rgba(107, 76, 154, 0.25);
}

.login-form input:hover:not(:focus),
.login-form select:hover:not(:focus) {
  border-color: rgba(107, 76, 154, 0.5);
  background: rgba(10, 6, 14, 0.85);
}

.login-form input::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

.login-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--primary-purple) 0%, var(--primary-purple-light) 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(107, 76, 154, 0.5);
}

.login-btn:active {
  transform: translateY(0) scale(0.98);
}

.login-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.login-error {
  background: rgba(229, 115, 115, 0.1);
  border: 1px solid rgba(229, 115, 115, 0.3);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--error);
  font-size: 13px;
  margin-bottom: 16px;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar-overlay {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 499;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }

  .sidebar-overlay:not(.hidden) {
    opacity: 1;
    visibility: visible;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    z-index: 500;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .sidebar:not(.hidden) {
    transform: translateX(0);
  }

  .sidebar.hidden {
    transform: translateX(-100%);
  }

  /* Show toggle button on mobile - position inside header */
  .sidebar-toggle {
    opacity: 1;
    pointer-events: auto;
    top: 12px;
    left: 12px;
  }

  .chat-container {
    padding: 15px 20px;
  }

  .message {
    max-width: 95%;
  }

  .chat-header {
    padding: 12px 15px;
  }

  .input-area {
    bottom: 12px;
    width: calc(100% - 24px);
  }

  .input-container {
    padding: 6px;
  }

  .input-container input {
    padding: 10px 12px;
    /* 16px prevents iOS zoom on focus */
    font-size: 16px;
  }

  .send-btn {
    padding: 10px 16px;
  }

  .chat-container {
    padding: 15px 28px 120px;
  }

  .welcome-container {
    padding: 20px 20px 80px;
  }

  /* Hide debug button on mobile */
  .debug-btn {
    display: none;
  }

  /* Login screen mobile */
  .login-screen {
    padding: 20px;
    /* Safe area insets for notched devices */
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }

  .login-card {
    padding: 30px 24px;
    max-width: 100%;
    border-radius: 20px;
  }

  .login-header {
    margin-bottom: 24px;
  }

  .login-logo {
    width: 60px;
    height: 60px;
    margin-bottom: 16px;
  }

  .login-header h1 {
    font-size: 22px;
  }

  /* Suggested prompts mobile */
  .suggested-prompts {
    padding: 0 16px;
    gap: 8px;
  }

  .suggested-prompt-btn {
    padding: 10px 16px;
    font-size: 13px;
  }

  /* Welcome content mobile */
  .welcome-icon {
    width: 64px;
    height: 64px;
  }

  .welcome-content h2 {
    font-size: 22px;
  }

  .welcome-subtitle {
    font-size: 14px;
  }
}

/* Prevent touch-based zoom and scroll issues */
.chat-container,
.conversation-list {
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

/* Input areas should not trigger pan */
.input-container {
  touch-action: manipulation;
}
