html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  /* Page background with subtle vertical gradient */
  /*background: linear-gradient(to bottom, white, #f2f6ff, #e7ebf4);*/
  background: linear-gradient(135deg, #432e5b, #5a4b7a, #6b5b7a) !important;
  background-attachment: fixed;
  /* keep it subtle on scroll */
  overflow: hidden;
  /* Prevent page scrolling */
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.footer {
  position: relative;
  width: 100%;
  white-space: nowrap;
  line-height: 60px;
  background: transparent;
  border-top: 1px solid #dee2e6;
  margin-top: 32px;
}

/* Override Bootstrap navbar styles - Hidden for user selection page */
.navbar {
  display: none !important;
}

/* Pancake menu trigger – always visible and tappable */
.altu-pancake-trigger {
  min-width: 44px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  font-weight: 500;
  font-size: 0.9375rem;
}
.altu-pancake-trigger .fa-bars {
  font-size: 1.125rem;
}
.altu-pancake-trigger:hover {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.25);
  color: #111;
}
@media (max-width: 575.98px) {
  .altu-pancake-label { display: none; }
}

/* Pancake dropdown: only show when opened; keep Theme inside the menu panel */
#altu-pancake-menu .dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  left: auto;
  top: 100%;
  margin-top: 4px;
  z-index: 1050;
  min-width: 260px;
  padding: 8px 0;
  list-style: none;
  padding-left: 0;
}
#altu-pancake-menu .dropdown-menu li {
  list-style: none;
}
#altu-pancake-menu.dropdown.show .dropdown-menu {
  display: block;
}
.altu-pancake-section-title {
  font-size: 0.875rem;
  font-weight: 600;
  display: block;
  padding: 8px 16px 4px;
}
#altu-pancake-menu .dropdown-item {
  padding: 8px 16px;
  font-size: 0.9375rem;
}
#altu-pancake-menu .dropdown-divider {
  margin: 8px 12px;
  border-top-width: 1px;
  opacity: 1;
}
#altu-pancake-menu button.dropdown-item {
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

/* Chat Container Layout - Fixed to Viewport Height */
.chat-container {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: transparent;
  /* let page gradient show through */
  position: relative;
  top: 0;
  left: 0;
}

/* User Selection Page Styles */
.user-selection-container {
  min-height: 100vh;
  padding: 24px 5%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

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

.user-selection-header .altu-title {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: clamp(48px, 10vw, 72px);
  font-weight: 900;
  letter-spacing: 0.01em;
  line-height: 1.05;
  color: #274c77;
  margin: 0 0 8px 0;
}

.user-selection-header .welcome-subtitle {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 1.25rem;
  font-weight: 400;
  color: #6c757d;
  margin: 0;
}

.user-selection-card {
  background: #e7ebf4;
  border-radius: 0.375rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 600px;
  overflow: hidden;
}

.card-header-section {
  background: linear-gradient(to bottom, white, #f2f6ff, #e7ebf4);
  padding: 20px 24px;
  border-bottom: 1px solid #cdd9ff;
  border-top: 1px solid #cdd9ff;
}

.card-header-section .card-title {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: #274c77;
  margin: 0;
  display: flex;
  align-items: center;
}

.card-body-section {
  padding: 24px;
}

.description-text {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 1rem;
  color: #6c757d;
  margin-bottom: 24px;
  line-height: 1.5;
}

.existing-users-section,
.create-user-section {
  margin-bottom: 24px;
}

.section-title {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 1.125rem;
  font-weight: 600;
  color: #274c77;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
}

.user-form {
  margin-bottom: 16px;
}

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

.form-label {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-weight: 500;
  color: #495057;
  margin-bottom: 8px;
  display: block;
}

/* Chat Header - White with Rounded Bottom Corners, Full Width */
.chat-header {
  flex-shrink: 0;
  background: linear-gradient(180deg, #ffffff 0%, #f2f4fa 60%, #e7ebf4 100%) !important;
  /* original direction, slightly grayer */
  color: #333 !important;
  border-bottom: none;
  height: auto;
  box-shadow: inset 0 1px 0 0 #e5ecff, inset 0 -1px 0 0 #cdd9ff, 0 2px 10px rgba(0, 0, 0, 0.08);
  /* subtle top+bottom borders */
  border-radius: 0 0 0.375rem 0.375rem;
  /* match chat input */
  width: auto !important;
  /* let margins define the exact width */
  margin: 0 3% 16px 3% !important;
  /* wider header: smaller side margins */
  padding: 16px;
  /* match chat input */
  position: relative;
  z-index: 10;
}

/* Conspicuous rate limit overlay centered in header */
.chat-header .rate-limit-overlay {
  position: absolute;
  inset: 0;
  display: none; /* toggled by JS */
  align-items: center;
  justify-content: center;
  pointer-events: none; /* allow clicks to pass except for box */
}

.chat-header .rate-limit-box {
  pointer-events: all;
  background: rgba(255, 230, 156, 0.98);
  border: 1px solid #e0b200;
  color: #5c4400;
  padding: 10px 16px;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  font-weight: 600;
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.chat-header .rate-limit-box .spinner-border {
  width: 1rem;
  height: 1rem;
}

/* Ensure header content is arranged horizontally */
.chat-header .d-flex {
  align-items: center;
  flex-wrap: nowrap;
}

.chat-header .d-flex.gap-2 {
  gap: 0.5rem;
  flex-direction: row;
  /* Force horizontal layout */
}

/* Override for stacked header controls */
.chat-header .d-flex.flex-column {
  flex-direction: column !important;
  gap: 0.5rem !important;
  align-items: flex-end !important;
}

.chat-header h5 {
  color: #432e5b !important;
  margin-bottom: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Noto Sans", "Liberation Sans", sans-serif;
}

/* Prominent ALTU title */
.chat-title {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Noto Sans", "Liberation Sans", sans-serif;
  font-weight: 900;
  letter-spacing: 0.01em;
  line-height: 1.05;
  font-size: clamp(32px, 7vw, 52px);
  margin-top: 0;
  /* remove default h1 top margin to match bottom spacing */
  color: #3c3c79;
}

.chat-header small {
  color: #666 !important;
  opacity: 1 !important;
  display: block;
  margin-top: 2px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Noto Sans", "Liberation Sans", sans-serif;
}

.chat-header .btn-outline-light {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  color: #495057;
  border-radius: 0.375rem;
  /* match composer buttons */
  padding: 8px 16px;
  font-size: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Noto Sans", "Liberation Sans", sans-serif;
  /* normalize font */
  font-weight: 600;
  transition: all 0.2s ease-in-out;
  white-space: nowrap;
  /* Prevent text wrapping */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 140px;
  /* uniform width */
  height: 40px;
  /* uniform height */
  box-sizing: border-box;
}

.chat-header .btn-outline-light:hover {
  background: #e9ecef;
  border-color: #adb5bd;
  color: #495057;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Chat Area - White Rounded Rectangle with Margins */
.chat-area-wrapper {
  flex: 1;
  padding: 0 20px 20px 20px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* Important for flex children */
  overflow: hidden;
}

.chat-messages-container {
  flex: 1;
  min-height: 0;
  max-height: 80%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #e7ebf4;
  /* match gradient bottom color */
  border-radius: 0.375rem;
  /* match chat input */
  margin: 0 5% 16px 5%;
  /* equal spacing top/bottom to composer */
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

#chatMessages {
  flex: 1;
  padding: 20px;
  background: transparent;
  overflow-y: auto;
  height: 100%;
  /* Hide scrollbar */
  scrollbar-width: none;
  /* Firefox */
  -ms-overflow-style: none;
  /* Internet Explorer 10+ */
}

/* Hide scrollbar for WebKit browsers */
#chatMessages::-webkit-scrollbar {
  display: none;
}

/* Message Styling - Correct Colors and Alignment */
.message-wrapper {
  display: flex;
  margin-bottom: 1rem;
  width: 100%;
}

/* User Messages - Blue, Right Aligned, Square Bottom Right */
.message-user {
  justify-content: flex-end;
}

.message-user .message-bubble {
  background: linear-gradient(135deg, #a6b1e1, #4a63a6);
  /* cooler contemporary gradient */
  color: white;
  max-width: 70%;
  border-radius: 18px 18px 4px 18px;
  /* Square bottom right */
  padding: 12px 16px;
  box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
  border: 1px solid #a8bdee;
  margin-left: auto;
}

.message-user .message-meta small {
  color: rgba(255, 255, 255, 0.8);
}

/* AI/Partner Messages - White, Left Aligned, Square Bottom Left */
.message-ai {
  justify-content: flex-start;
}

.message-ai .message-bubble {
  background: #f7f9fc;
  /* light neutral for AI bubble */
  color: #333;
  max-width: 70%;
  border-radius: 18px 18px 18px 4px;
  /* Square bottom left */
  padding: 12px 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border: 1px solid #e9ecef;
  margin-right: auto;
}

.message-ai .message-meta small {
  color: #6c757d;
}

/* Message Content */
.message-content {
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 15px;
}

.message-content.rendered-html {
  white-space: normal;
}

.message-content.rendered-html > *:first-child {
  margin-top: 0;
}

.message-content.rendered-html > *:last-child {
  margin-bottom: 0;
}

.message-content.rendered-html p,
.message-content.rendered-html ul,
.message-content.rendered-html ol,
.message-content.rendered-html blockquote,
.message-content.rendered-html pre,
.message-content.rendered-html table {
  margin-bottom: 0.75rem;
}

.message-content.rendered-html ul,
.message-content.rendered-html ol {
  padding-left: 1.5rem;
}

.message-content.rendered-html pre {
  padding: 0.75rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  background: rgba(15, 23, 42, 0.08);
}

.message-content.rendered-html code {
  padding: 0.1rem 0.3rem;
  border-radius: 0.25rem;
  background: rgba(15, 23, 42, 0.08);
}

.message-content.rendered-html pre code {
  padding: 0;
  background: transparent;
}

.message-content.rendered-html table {
  width: 100%;
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
}

.message-content.rendered-html th,
.message-content.rendered-html td {
  padding: 0.4rem 0.5rem;
  border: 1px solid rgba(108, 117, 125, 0.35);
}

.message-content.rendered-html th {
  font-weight: 600;
  background: rgba(108, 117, 125, 0.08);
}

.message-content.rendered-html a {
  text-decoration: underline;
}

.message-meta {
  margin-top: 8px;
  opacity: 0.9;
}

.message-meta small {
  font-size: 0.75rem;
}

/* Prompt Section Styling */
.prompt-section {
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  padding-top: 8px;
  margin-top: 8px;
}

.message-ai .prompt-section {
  border-top: 1px solid #e9ecef;
}

.prompt-toggle {
  text-decoration: none !important;
  opacity: 0.95;
  transition: opacity 0.2s ease;
}

.prompt-toggle:hover {
  opacity: 1;
  text-decoration: none !important;
}

.prompt-toggle:focus {
  box-shadow: none;
  outline: none;
}

.prompt-content {
  margin-top: 4px;
}

.prompt-text {
  background: rgba(0, 0, 0, 0.05) !important;
  border: 1px solid rgba(0, 0, 0, 0.1);
  font-size: 0.85rem;
  line-height: 1.4;
  padding: 12px;
  border-radius: 8px;
  max-height: 400px;
  overflow-y: auto;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.message-user .prompt-text {
  background: rgba(255, 255, 255, 0.15) !important;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(21, 17, 17, 0.9);
}

.message-user .prompt-text .text-muted {
  color: rgba(21, 17, 17, 0.7) !important;
}

/* Enhanced prompt content styling for better readability */
.prompt-text .message-content {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.4;
  color: inherit;
}

/* Markdown-style formatting within prompts */
.prompt-text h1,
.prompt-text h2,
.prompt-text h3,
.prompt-text h4,
.prompt-text h5,
.prompt-text h6 {
  margin-top: 16px;
  margin-bottom: 8px;
  font-weight: 600;
  color: inherit;
}

.prompt-text h1 {
  font-size: 1.4rem;
  border-bottom: 2px solid currentColor;
  padding-bottom: 4px;
  color: #333 !important;
  background: rgba(0, 123, 255, 0.1);
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 16px;
  margin-top: 0;
  /* First header shouldn't have top margin */
}

.prompt-text h2 {
  font-size: 1.2rem;
  border-bottom: 1px solid currentColor;
  padding-bottom: 2px;
  color: #495057 !important;
}

.prompt-text h3 {
  font-size: 1.1rem;
  color: #6c757d !important;
  font-weight: 600;
}

.prompt-text p {
  margin-bottom: 12px;
  line-height: 1.4;
}

.prompt-text ul,
.prompt-text ol {
  margin-bottom: 12px;
  padding-left: 20px;
}

.prompt-text li {
  margin-bottom: 4px;
  line-height: 1.4;
}

/* Add spacing between sections */
.prompt-text .classification-section,
.prompt-text .tag-list,
.prompt-text .json-content,
.prompt-text pre,
.prompt-text blockquote {
  margin-top: 12px;
  margin-bottom: 12px;
}

/* Fix white text on white background for user messages */
.message-user .prompt-text h1 {
  color: rgba(23, 17, 17, 0.9) !important;
  background: rgba(233, 227, 227, 0.81);
}

.message-user .prompt-text h2 {
  color: rgba(23, 17, 17, 0.9) !important;
}

.message-user .prompt-text h3 {
  color: rgba(23, 17, 17, 0.9) !important;
}

.message-user .prompt-text h4 {
  color: rgba(23, 17, 17, 0.9) !important;
}

.prompt-text code {
  background: rgba(0, 0, 0, 0.1);
  padding: 2px 4px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
}

.prompt-text pre {
  background: rgba(0, 0, 0, 0.05);
  padding: 8px;
  border-radius: 4px;
  overflow-x: auto;
  margin: 6px 0;
  line-height: 1.3;
}

.prompt-text blockquote {
  border-left: 3px solid currentColor;
  padding-left: 12px;
  margin: 6px 0;
  font-style: italic;
}

/* JSON formatting within prompts */
.prompt-text .json-content {
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 4px;
  padding: 8px;
  font-family: 'Courier New', monospace;
  font-size: 0.8em;
  overflow-x: auto;
}

/* Tag lists and classifications */
.prompt-text .tag-list {
  background: rgba(0, 123, 255, 0.05);
  border: 1px solid rgba(0, 123, 255, 0.2);
  border-radius: 4px;
  padding: 8px;
  margin: 6px 0;
}

.prompt-text .classification-section {
  background: rgba(40, 167, 69, 0.05);
  border: 1px solid rgba(40, 167, 69, 0.2);
  border-radius: 4px;
  padding: 8px;
  margin: 6px 0;
}

/* Timestamp formatting */
.prompt-text .timestamp {
  color: #6c757d;
  font-size: 0.8em;
  font-style: italic;
}

.prompt-message {
  margin-top: 4px;
  font-style: italic;
  word-wrap: break-word;
  white-space: pre-wrap;
}

/* Enhanced prompt and response containers */
.prompt-container,
.response-container {
  border: 1px solid #e9ecef;
  background: #f8f9fa !important;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.prompt-container {
  max-height: 400px;
  overflow-y: auto;
}

.response-container {
  max-height: 300px;
  overflow-y: auto;
  background: #f1f3f4 !important;
  border-color: #dee2e6;
}

.prompt-container::-webkit-scrollbar,
.response-container::-webkit-scrollbar {
  width: 6px;
}

.prompt-container::-webkit-scrollbar-track,
.response-container::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.prompt-container::-webkit-scrollbar-thumb,
.response-container::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.prompt-container::-webkit-scrollbar-thumb:hover,
.response-container::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Response section styling */
.response-content {
  margin-top: 0.5rem;
}

.response-content pre {
  background: transparent !important;
  border: none;
  padding: 0;
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.4;
  color: #495057;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.response-content code {
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: inherit;
}

/* Empty Chat State */
.empty-chat-state {
  padding: 60px 20px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #6c757d;
}

/* Chat Input Container - At Bottom with Margins */
.chat-input-container {
  flex-shrink: 0;
  background: #e7ebf4;
  /* match gradient bottom color */
  border-radius: 0.375rem;
  /* Bootstrap default radius */
  padding: 16px;
  margin: 0 5% 16px 5%;
  /* match chat messages container spacing */
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  position: relative;
  z-index: 10;
}

/* Ensure slight spacing between prompt action buttons */
.prompt-section .btn-link+.btn-link {
  margin-left: 2px !important;
}

/* Dev Time Section - Proper spacing and layout */
.dev-time-section {
  margin-bottom: 1rem !important;
}

/* New grid-based dev time layout */
.dev-time-grid {
  display: grid;
  grid-template-columns: max-content 220px;
  /* keep input directly next to label */
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.dev-time-grid label {
  white-space: nowrap;
}

.dev-time-grid input {
  border-radius: 0.375rem;
  width: 220px;
}

.dev-time-grid label,
.dev-time-grid input,
#devTimeShiftBanner,
.input-hints,
.chat-input-container label {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Noto Sans", "Liberation Sans", sans-serif;
}

/* Ensure composer section inherits modern font */
.chat-input-container,
.chat-input-container * {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Noto Sans", "Liberation Sans", sans-serif;
}

/* Boxed label to match input */
.dev-time-grid label {
  display: inline-flex;
  align-items: center;
  border: 1px solid #ced4da;
  border-radius: 0.375rem;
  padding: 0.25rem 0.5rem;
  /* match .form-control-sm vertical rhythm */
  min-height: 31px;
  /* align with Bootstrap .form-control-sm height */
  background: #f8f9fa;
  /* light gray */
}

/* Fallback for existing markup when server hasn't recompiled views */
#devTimeShiftBanner+.mb-4 .d-flex {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
}

.chat-input-container .mb-4 .d-flex {
  justify-content: flex-start !important;
}

.chat-input-container .mb-4 label {
  display: inline-block;
  margin-bottom: 0;
  white-space: nowrap;
}

#devTimeShiftBanner+.mb-4 input[type="datetime-local"] {
  width: 220px;
}

.chat-input-container .mb-4 input[type="datetime-local"] {
  width: 220px;
}

.chat-input-container .mb-4 {
  margin-bottom: 16px !important;
}

/* Dev banner polish */
#devTimeShiftBanner {
  color: #6c757d;
  background: #f8f9fa;
  border-color: #e2e6ea;
}

.message-input {
  /* Fallback styling for existing class names */
  border: 1px solid #ced4da !important;
  border-radius: 0.375rem !important;
  padding: 10px 12px !important;
  resize: none !important;
  overflow: hidden !important;
  min-height: 112px !important;
  /* matches two buttons + gap */
  box-shadow: none !important;
}

.message-input:focus {
  box-shadow: none !important;
  outline: none !important;
  border-color: #6c757d !important;
}

/* New chat composer layout */
.chat-composer {
  margin-top: 4px;
}

.chat-input-grid {
  --composer-button-size: 52px;
  --composer-gap: 12px;
  display: grid;
  grid-template-columns: 1fr var(--composer-button-size);
  gap: var(--composer-gap);
  align-items: stretch;
}

.button-stack {
  display: grid;
  grid-template-rows: var(--composer-button-size) var(--composer-button-size);
  gap: var(--composer-gap);
}

/* Message textarea - single border, no scrollbars, matches buttons column height */
.message-textarea {
  border: 1px solid #ced4da;
  border-radius: 0.375rem;
  padding: 10px 12px;
  font-size: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Noto Sans", "Liberation Sans", sans-serif;
  line-height: 1.4;
  resize: none;
  overflow: hidden;
  /* hide default scrollbars */
  min-height: calc(var(--composer-button-size) * 2 + var(--composer-gap));
  max-height: 160px;
  width: 100%;
  background: white;
  box-sizing: border-box;
}

.message-textarea:focus {
  border-color: #6c757d;
  box-shadow: none;
  outline: none;
}

.message-textarea::placeholder {
  color: #6c757d;
  opacity: 0.8;
}

/* Action Buttons - Uniform Size and Styling */
.action-button {
  width: var(--composer-button-size);
  height: var(--composer-button-size);
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease-in-out;
  font-size: 16px;
  font-weight: 500;
  padding: 0;
  white-space: nowrap;
  border: 1px solid #dee2e6;
}

.action-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.action-button:active {
  transform: translateY(0);
}

.action-button.btn-primary {
  box-shadow: 0 1px 4px rgba(0, 123, 255, 0.3);
}

.action-button.btn-primary:hover {
  box-shadow: 0 2px 8px rgba(0, 123, 255, 0.4);
}

.action-button.btn-success {
  background-color: #28a745 !important;
  border-color: #28a745 !important;
  transform: scale(1.02);
}

/* Input Hints */
.input-hints {
  padding-left: 20px;
  margin-top: 12px;
  text-align: left;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Noto Sans", "Liberation Sans", sans-serif;
}

/* Context Info */
.context-info {
  background: linear-gradient(90deg, #e3f2fd, #f3e5f5);
  border-top: 1px solid #dee2e6;
  animation: slideDown 0.3s ease-out;
  flex-shrink: 0;
  border-radius: 0 0 20px 20px;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
}

.loading-content {
  text-align: center;
  background: white;
  padding: 30px;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Noto Sans", "Liberation Sans", sans-serif;
}

/* Keyboard Shortcuts Styling */
kbd {
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 0.25rem;
  color: #495057;
  font-size: 0.75rem;
  padding: 0.1rem 0.4rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  font-family: monospace;
}

/* Badge Styling */
.badge {
  font-size: 0.65rem;
  padding: 0.25em 0.5em;
  border-radius: 12px;
}

/* Dev Console polish */
.card-header h5 {
  font-weight: 600;
}

.toast .toast-body {
  font-size: 0.95rem;
}

.badge.bg-secondary {
  font-weight: 500;
}

/* Dev Console polish */
.dev-console .card-header {
  background-color: #f8f9fa;
}

.dev-console .progress {
  height: 12px;
}

.dev-console .progress-bar {
  transition: width .3s ease;
}

.dev-console .btn {
  white-space: nowrap;
}

.toast .toast-header {
  background-color: #f8f9fa;
}

/* Animation for New Messages */
.message-wrapper {
  animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Typing Indicator Styles */
.typing-indicator-wrapper {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 1rem;
  animation: fadeInUp 0.3s ease-out;
}

.typing-indicator-bubble {
  background: #f7f9fc;
  /* Match assistant message bubble */
  color: #333;
  width: 100px;
  /* Narrow bubble */
  min-width: 100px;
  max-width: 100px;
  border-radius: 18px 18px 18px 4px;
  /* Square bottom left like AI messages */
  padding: 12px 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border: 1px solid #e9ecef;
  margin-right: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.typing-indicator-dots {
  display: flex;
  align-items: center;
  gap: 4px;
}

.typing-indicator-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #666;
  opacity: 0.4;
  animation: typingDotPulse 1.4s infinite ease-in-out;
}

.typing-indicator-dots span:nth-child(1) {
  animation-delay: 0s;
}

.typing-indicator-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingDotPulse {
  0%, 60%, 100% {
    opacity: 0.4;
    transform: scale(1);
  }
  30% {
    opacity: 1;
    transform: scale(1.2);
  }
}

/* Responsive Design */
@media (max-width: 768px) {

  .message-user .message-bubble,
  .message-ai .message-bubble {
    max-width: 85%;
  }

  #chatMessages {
    padding: 15px;
  }

  .chat-input-container {
    margin: 0 2% 15px 2%;
    /* Smaller margins on mobile */
    padding: 15px;
  }

  .chat-messages-container {
    margin: 0 2%;
    /* Smaller margins on mobile */
  }

  .chat-input-grid {
    --composer-button-size: 48px;
    --composer-gap: 12px;
  }

  .button-stack {
    grid-template-rows: var(--composer-button-size) var(--composer-button-size);
  }

  .action-button {
    width: var(--composer-button-size);
    height: var(--composer-button-size);
    font-size: 14px;
  }

  .message-textarea {
    font-size: 16px;
    padding: 10px 16px;
    min-height: calc(var(--composer-button-size)*2 + var(--composer-gap));
  }

  /* Mobile navbar adjustments */
  .chat-header .d-flex.gap-2 {
    flex-direction: column;
    gap: 0.25rem;
  }

  .chat-header .btn-outline-light {
    font-size: 12px;
    padding: 6px 12px;
  }
}

@media (max-width: 480px) {

  .message-user .message-bubble,
  .message-ai .message-bubble {
    max-width: 90%;
  }

  .chat-input-grid {
    --composer-button-size: 44px;
    --composer-gap: 10px;
  }

  .action-button {
    width: var(--composer-button-size);
    height: var(--composer-button-size);
    font-size: 12px;
  }

  .message-textarea {
    min-height: calc(var(--composer-button-size)*2 + var(--composer-gap));
  }

  .chat-input-container {
    margin: 0 1% 10px 1%;
    /* Even smaller margins on very small screens */
    padding: 10px;
  }

  .chat-messages-container {
    margin: 0 1%;
    /* Even smaller margins on very small screens */
  }
}

/* Focus Indicators for Accessibility */
.message-input:focus-visible {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

.action-button:focus-visible {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .message-user .message-bubble {
    background: white;
    border: 2px solid #333;
  }

  .message-ai .message-bubble {
    background: #e3f2fd;
    border: 2px solid #1565c0;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .message-wrapper {
    animation: none;
  }

  .action-button:hover,
  .chat-header .btn-outline-light:hover {
    transform: none;
  }

  .context-info {
    animation: none;
  }
}

/* User Selection Page Styles */
.user-selection-container {
  min-height: 100vh;
  padding: 24px 5%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

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

.user-selection-header .altu-title {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: clamp(48px, 10vw, 72px);
  font-weight: 900;
  letter-spacing: 0.01em;
  line-height: 1.05;
  color: #274c77;
  margin: 0 0 8px 0;
}

.user-selection-header .welcome-subtitle {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 1.25rem;
  font-weight: 400;
  color: #6c757d;
  margin: 0;
}

.user-selection-card {
  background: #e7ebf4;
  border-radius: 0.375rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 600px;
  overflow: hidden;
}

.card-header-section {
  background: linear-gradient(to bottom, white, #f2f6ff, #e7ebf4);
  padding: 20px 24px;
  border-bottom: 1px solid #cdd9ff;
  border-top: 1px solid #cdd9ff;
}

.card-header-section .card-title {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: #274c77;
  margin: 0;
  display: flex;
  align-items: center;
}

.card-body-section {
  padding: 24px;
}

.description-text {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 1rem;
  color: #6c757d;
  margin-bottom: 24px;
  line-height: 1.5;
}

.existing-users-section,
.create-user-section {
  margin-bottom: 24px;
}

.section-title {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 1.125rem;
  font-weight: 600;
  color: #274c77;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
}

.user-form {
  margin-bottom: 16px;
}

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

.form-label {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-weight: 500;
  color: #495057;
  margin-bottom: 8px;
  display: block;
}

.form-control,
.form-select {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  border: 1px solid #ced4da;
  border-radius: 0.375rem;
  padding: 12px 16px;
  font-size: 1rem;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus,
.form-select:focus {
  border-color: #274c77;
  box-shadow: 0 0 0 0.2rem rgba(39, 76, 119, 0.25);
  outline: none;
}

.btn-action {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-weight: 500;
  padding: 12px 24px;
  border-radius: 0.375rem;
  border: none;
  font-size: 1rem;
  transition: all 0.15s ease-in-out;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 140px;
}

.btn-primary {
  background: linear-gradient(135deg, #274c77, #345c86);
  color: white;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1e3a5f, #2a4a6d);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-success {
  background: linear-gradient(135deg, #28a745, #20c997);
  color: white;
}

.btn-success:hover {
  background: linear-gradient(135deg, #218838, #1ea085);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.divider {
  height: 1px;
  background: linear-gradient(to right, transparent, #dee2e6, transparent);
  margin: 24px 0;
}

.info-alert {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  padding: 16px;
  color: #6c757d;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  display: flex;
  align-items: center;
}

.footer-note {
  margin-top: 32px;
  text-align: center;
}

.footer-text {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #6c757d;
  font-size: 0.875rem;
  display: flex;
  align-items: left;
  justify-content: left;
  gap: 4px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .user-selection-container {
    padding: 16px 3%;
  }

  .user-selection-header .altu-title {
    font-size: clamp(36px, 8vw, 56px);
  }

  .user-selection-header .welcome-subtitle {
    font-size: 1.125rem;
  }

  .card-body-section {
    padding: 20px;
  }

  .btn-action {
    width: 100%;
    margin-top: 8px;
  }
}

/* Override user selection styles for modern design */
.user-selection-container .card-header-section {
  background: linear-gradient(135deg, #3d2756, #302352, #41255c) !important;
  border-bottom: 1px solid #3d2d4f !important;
  border-top: 1px solid #3d2d4f !important;
}

.user-selection-container .card-header-section .card-title {
  color: white !important;
}

.user-selection-container .user-selection-card {
  background: linear-gradient(135deg, #f8f9fa, #e9ecef, #dee2e6) !important;
}

/* Better form control alignment */
.user-selection-container .form-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.user-selection-container .form-control,
.user-selection-container .form-select {
  width: 100%;
  max-width: 400px;
}

.user-selection-container .btn-action {
  margin-top: 8px;
}

/* Ensure consistent spacing */
.user-selection-container .existing-users-section,
.user-selection-container .create-user-section {
  width: 100%;
}

.user-selection-container .user-form {
  width: 100%;
}

/* Override user selection header for chat-page-style header */
.user-selection-container {
  padding: 0 !important;
}

.user-selection-header {
  width: 45% !important;
  background: linear-gradient(135deg, #3d2756, #302352, #41255c) !important;
  padding: 32px 5% 40px 5% !important;
  text-align: center !important;
  border-radius: 0 0 0.375rem 0.375rem !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
  margin: 0 5% 32px 5% !important;
}

.user-selection-header .altu-title {
  color: white !important;
}

.user-selection-header .welcome-subtitle {
  color: rgba(255, 255, 255, 0.9) !important;
}

/* Public homepage shell and structure */
html.public-home-page,
html.public-home-page body {
  min-height: 100%;
  height: auto;
}

html.public-home-page {
  overflow-y: auto !important;
  overflow-x: hidden;
  background-attachment: scroll;
}

body.public-home-page {
  overflow-y: auto !important;
  overflow-x: hidden;
}

body.public-home-page .layout-shell-public-home {
  padding: 0;
}

body.public-home-page .layout-main-public-home {
  padding-bottom: 0 !important;
}

.public-home {
  --public-home-gap: clamp(20px, 2.4vw, 28px);
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--public-home-gap);
  padding: clamp(24px, 4vw, 48px) 0 clamp(40px, 6vw, 72px);
}

.public-home__hero,
.public-home__trust {
  padding: clamp(24px, 4vw, 40px);
}

.public-home__hero {
  position: relative;
  display: flex;
  min-height: clamp(420px, 47vw, 560px);
  overflow: hidden;
}

.public-home__hero-content {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(17rem, 0.72fr);
  gap: clamp(24px, 3vw, 40px);
  margin-top: auto;
  position: relative;
  z-index: 1;
  align-items: end;
}

.public-home__hero-copy {
  max-width: min(100%, 30rem);
}

.public-home__hero-note {
  margin: 0;
  max-width: 23ch;
  font-size: clamp(0.98rem, 1.35vw, 1.04rem);
  line-height: 1.6;
  align-self: end;
}

.public-home__title {
  margin: 0;
  max-width: 9ch;
  font-size: clamp(2.7rem, 5.9vw, 4.45rem);
  line-height: 0.94;
}

.public-home__title-line {
  display: block;
}

.public-home__cue-copy,
.public-home__trust-copy {
  margin: 0;
  line-height: 1.65;
}

.public-home__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 24px;
  min-height: 52px;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
}

.public-home__cues {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  align-items: stretch;
  column-gap: calc(var(--public-home-gap) + 12px);
  row-gap: var(--public-home-gap);
}

.public-home__cue {
  display: flex;
  flex-direction: column;
  gap: 5px;
  height: 100%;
  min-height: 0;
  padding: 10px 16px 8px;
}

.public-home__cue-title,
.public-home__trust-title {
  margin: 0;
}

.public-home__cue-title {
  font-size: 0.92rem;
  line-height: 1.25;
}

.public-home__cue-copy {
  font-size: 0.84rem;
  line-height: 1.36;
}

.public-home__cue--cta {
  gap: 7px;
}

.public-home__cue-cta {
  width: min(100%, 172px);
  align-self: center;
  margin-top: auto;
  min-height: 36px;
  padding: 7px 14px;
  font-size: 0.9rem;
}

.public-home__trust {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  margin-top: 16px;
}

.public-home__trust-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  font-size: 1.35rem;
  border-radius: 999px;
  flex-shrink: 0;
}

.public-home__trust-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.public-home__trust-copy {
  font-size: 0.97rem;
  line-height: 1.6;
}

@media (max-width: 991.98px) {
  .public-home__hero {
    min-height: clamp(420px, 64vw, 540px);
  }

  .public-home__hero-content {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .public-home__hero-copy,
  .public-home__hero-note {
    max-width: min(100%, 30rem);
  }

  .public-home__cues {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767.98px) {
  .public-home {
    width: min(100% - 24px, 100%);
    padding-top: 20px;
  }

  .public-home__hero {
    min-height: clamp(400px, 118vw, 520px);
  }

  .public-home__cta {
    width: 100%;
  }

  .public-home__title,
  .public-home__hero-note {
    max-width: none;
  }

  .public-home__trust {
    grid-template-columns: 1fr;
  }
}
