/* ---------------------------------------------------------------------------
   Cleaned & formatted stylesheet — duplicate selectors consolidated
   Changes: merged duplicate `.container`, `#query`, `.form-row`, and `.msg` rules
------------------------------------------------------------------------------- */

* {
  box-sizing: border-box;
}

body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial;
  background: #ffffff;
  color: #0b1221;
  margin: 0;
  padding: 24px;
}

/* Container: final layout settings */
.container {
  max-width: 980px;
  margin: 0 auto;
  background: transparent; /* final design: transparent container */
  padding: 24px;
  border-radius: 0; /* flat layout */
  box-shadow: none;
  padding-bottom: 200px; /* space for sticky footer */
  transition: transform 260ms cubic-bezier(0.2, 0.9, 0.2, 1), opacity 180ms ease;
}

h1 {
  text-align: center;
  margin-top: 0;
  margin-bottom: 4px;
}

.subtitle {
  text-align: center;
  font-size: 0.8rem;
  margin-bottom: 38px;
  color: #7e7e7e;
  font-weight: 400;
}

/* Service menu */
.service-menu {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 24px;
}
.menu-chip {
  border: 1px solid rgba(3, 40, 75, 0.08);
  background: #ffffff;
  color: #03284b;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(2, 6, 23, 0.06);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.menu-chip:hover,
.menu-chip:focus {
  background: rgba(3, 40, 75, 0.06);
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.08);
}

/* Controls */
.controls {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  align-items: center;
}
.controls label {
  font-size: 0.85rem;
  color: #445;
}
.controls input[type="text"] {
  flex: 1;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #e6e9ee;
}
.controls input[type="number"] {
  width: 92px;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #e6e9ee;
}

/* Query input / textarea (consolidated) */
#query {
  background: #f9f9f90e;
  width: 100%;
  flex: 1;
  min-height: 48px; /* compact default; media queries adjust for small screens */
  padding: 12px 14px;
  resize: vertical;
  border-radius: 15px;
  border: none;
  font-size: 1rem;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial;
  color: #000000;
}
#query:focus {
  outline: none;
  box-shadow: none;
}

/* Cross-browser placeholder color */
#query::placeholder,
#query::-webkit-input-placeholder,
#query::-moz-placeholder,
#query:-ms-input-placeholder,
#query:-moz-placeholder {
  color: rgba(3, 40, 75, 0.45);
}

/* Form row (single consolidated rule) */
.form-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.send-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #000000, #646464);
  color: #fff;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(100, 100, 100, 0.18);
}
.send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Running / stop state for send button */
.send-btn.running {
  width: 36px;
  height: 36px;
  background: linear-gradient(180deg, #000000, #646464);
  border: none;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 14px rgba(100, 100, 100, 0.18);
}
.send-btn.running svg rect {
  fill: #ffffff;
}
.send-btn.running[title="Stop generation"] {
  /* make sure pointer cursor stays clickable */
  cursor: pointer;
}

/* Spinner used while thinking */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.status {
  font-size: 0.9rem;
  color: #666;
}

.result {
  margin-top: 60px;
}
.result.hidden {
  display: none;
}

/* Message / answer styles */
.answer {
  white-space: normal; /* allow paragraphs and lists to flow naturally */
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #eef2f6;
}
.answer-body {
  /* wrapper inside message for custom formatting */
}
.answer-gap {
  height: 12px;
}
.answer-cards {
  margin-top: 8px;
}
.card-carousel {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding: 8px 4px 12px;
  scroll-snap-type: x mandatory;
}
.card-carousel::-webkit-scrollbar {
  height: 8px;
}
.card-carousel::-webkit-scrollbar-thumb {
  background: rgba(3, 40, 75, 0.12);
  border-radius: 999px;
}
.menu-card {
  flex: 0 0 240px;
  max-width: 260px;
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid rgba(3, 40, 75, 0.08);
  box-shadow: 0 10px 28px rgba(2, 6, 23, 0.08);
  overflow: hidden;
  scroll-snap-align: start;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
}
.menu-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(2, 6, 23, 0.12);
}
.card-media {
  width: 100%;
  height: 140px;
  background: linear-gradient(135deg, #f2f4f8, #e8eef6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #607089;
  font-size: 0.85rem;
  font-weight: 600;
}
.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card-body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: #03284b;
  margin: 0;
}
.card-desc {
  font-size: 0.88rem;
  color: #4a5a70;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-price {
  font-size: 0.85rem;
  font-weight: 700;
  color: #0b1221;
}
.card-price.empty {
  font-weight: 500;
  color: #7a8797;
}
.card-action {
  align-self: flex-start;
  padding: 6px 12px;
  border-radius: 999px;
  border: none;
  background: #000000;
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.action-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 0;
}
.action-btn {
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(3, 40, 75, 0.12);
  background: #ffffff;
  color: #03284b;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(2, 6, 23, 0.08);
}
.cmd-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(3, 40, 75, 0.16);
  background: linear-gradient(180deg, #ffffff 0%, #f1f5fb 100%);
  color: #03284b;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(2, 6, 23, 0.1);
  text-decoration: none;
  margin: 4px 6px 4px 0;
  white-space: nowrap;
  transition: transform 160ms ease, box-shadow 160ms ease,
    background 160ms ease, border-color 160ms ease;
}
.cmd-btn:hover,
.cmd-btn:focus {
  background: #ffffff;
  border-color: rgba(3, 40, 75, 0.24);
  box-shadow: 0 10px 22px rgba(2, 6, 23, 0.14);
  transform: translateY(-1px);
}
.cmd-btn:active {
  transform: translateY(0);
  box-shadow: 0 6px 14px rgba(2, 6, 23, 0.12);
}
.cmd-btn:focus-visible {
  outline: 2px solid #0b1221;
  outline-offset: 2px;
}
.answer-title {
  font-weight: 800;
  margin-top: 25px;
  margin-bottom: 15px;
  color: #03284b;
}
.answer-para {
  margin: 15px 0;
  color: #03284b;
}
.answer-para.thinking {
  color: #7b8794;
}
.answer-para.thinking::after {
  content: "...";
  display: inline-block;
  width: 0;
  overflow: hidden;
  vertical-align: bottom;
  animation: dots 1.1s steps(4, end) infinite;
}

@keyframes dots {
  to {
    width: 1.2em;
  }
}

.custom-list {
  list-style: none;
  margin: 0px 0 0px 0;
  padding: 0;
}
.custom-olist {
  margin: 12px 0 12px 0;
  padding-left: 1.4em;
}
.custom-list li {
  margin: 0px 0;
  padding-left: 0;
  display: flex;
  align-items: flex-start;
}
.custom-olist li {
  margin: 12px 0;
  color: #03284b;
}
.custom-olist li::marker {
  content: counter(list-item) ") ";
  color: #03284b;
  font-weight: 600;
}
.custom-list li::before {
  content: "●";
  color: #000000;
  display: inline-block;
  width: 1.2em;
  margin-right: 8px;
  line-height: 1.5;
  font-size: 0.9rem;
}

.url-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: #000000;
  color: #ffffff;
  text-decoration: none;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0 4px;
  transition: all 0.2s ease;
}
.url-badge svg {
  flex-shrink: 0;
}
.url-badge:hover {
  background: #333333;
}

.url-badge.map-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px 4px 8px;
  background: #000000;
  color: #ffffff;
  text-decoration: none;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0 4px;
  transition: all 0.2s ease;
}

.url-badge.map-badge:hover {
  background: #333333;
}

.url-badge.inline-badge {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin: 0 4px;
  white-space: nowrap;
}

.url-badge.website-badge {
  background: #000000;
  background-clip: padding-box;
  color: #ffffff;
  padding: 2px 8px 4px 8px;
  border-radius: 100px;
  text-decoration: none;
  font-size: 0.9em;
  transition: background 0.2s;
}

.url-badge.website-badge:hover {
  background: #333333;
  color: white;
}

.image-gallery {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: wrap;
  gap: 4px;
  margin: 8px 0;
  width: 100%;
  align-items: flex-start;
}
.image-preview-link {
  display: inline-block;
  flex-shrink: 0;
  margin: 6px 2px 6px 0;
  border-radius: 15px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease;
  border: 2px solid #ffffff;
  vertical-align: middle;
}
.image-preview-link:hover {
  transform: scale(1.05);
}
.url-image-preview {
  display: block;
  width: 100px;
  height: 100px;
  object-fit: cover;
  background: #f5f5f5;
}

.sources {
  list-style: none;
  padding-left: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.sources li {
  padding: 2px 6px;
  /* background: #f5f5f5; */
  color: #4d4d4d;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* --- Sources folder UI --- */
.sources-wrap {
  position: relative;
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.sources-btn {
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  padding: 7px 10px;
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 20px rgba(2, 6, 23, 0.06);
}

.sources-btn:hover {
  transform: translateY(-1px);
}

.sources-count {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.06);
  font-weight: 700;
}

.sources-pop {
  position: absolute;
  left: 0;
  /* top: calc(100% + 10px); */
  top: auto;
  bottom: calc(100% + 10px);
  width: min(420px, 85vw);
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  padding: 10px;
  z-index: 9999;
  box-shadow: 0 20px 60px rgba(2, 6, 23, 0.14);
  backdrop-filter: blur(6px) saturate(120%);
  pointer-events: auto;
  -webkit-backdrop-filter: blur(10px) saturate(120%);
}

.sources-pop.hidden {
  display: none;
}

.sources-pop-title {
  font-weight: 800;
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.sources-pop-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.sources-pop-item {
  display: inline-flex;
  align-items: center;
}

.source-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.05);
  font-size: 0.82rem;
  color: #111827;
}

.pill {
  display: inline-block;
  padding: 5px 8px;
  background: #eeeeee;
  color: #0366d6;
  border-radius: 12px;
  font-size: 0.85rem;
  margin-left: 8px;
}
small.note {
  display: block;
  margin-top: 8px;
  color: #666;
}

/* Accessibility helper */
.visually-hidden {
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
  border: 0;
  padding: 0;
  margin: -1px;
}

/* AI message area */
.ai-message {
  background: #f0f8ff;
  border-left: 4px solid #0366d6;
  padding: 12px 16px;
  margin: 12px 0;
  border-radius: 8px;
  color: #03284b;
  font-weight: 500;
}
.ai-message.hidden {
  display: none;
}
.hidden {
  display: none !important;
}

/* Hero centered input */
.hero-form {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 12px;
  margin: 28px 0;
}
.hero-row {
  background: #ffffff3a;
  padding: 18px 20px;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(11, 18, 33, 0.06);
  width: min(820px, 100% - 48px);
  display: flex;
  gap: 12px;
  border: 1px solid rgba(3, 40, 75, 0.06);
  align-items: center;
}
.hero-row input#heroQuery {
  flex: 1;
  border: none;
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 1rem;
  box-shadow: none;
  outline: none;
}

/* Prompt suggestions dropdown */
.suggestions {
  margin: 0;
  background: #ffffffef;
  color: #03284b;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(11, 18, 33, 0.06);
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  padding: 0;
  list-style: none;
  max-width: 820px;
  width: min(820px, calc(100% - 48px));
  border: 1px solid rgba(3, 40, 75, 0.04);
  z-index: 10000;
  overflow: hidden;
}
.suggestions.hidden {
  display: none !important;
}
.suggestions.fade-in {
  animation: fadeIn 180ms ease both;
}
.suggestion-item {
  padding: 12px 18px;
  font-size: 0.95rem;
  color: #03284b;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.suggestion-item + .suggestion-item {
  border-top: 1px solid rgba(3, 40, 75, 0.04);
}
.suggestion-item:hover,
.suggestion-item.highlighted {
  background: rgba(3, 40, 75, 0.06);
  color: #02203a;
}

/* Positioning near the hero input */
.hero-row {
  position: relative;
}
.hero-row .suggestions {
  position: absolute;
  left: 18px;
  right: 18px;
  top: calc(100% + 8px);
  width: auto;
  max-width: none;
}

/* Sticky footer suggestion position */
.sticky-footer {
  position: relative;
}
.sticky-footer .suggestions {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(100% + 8px);
  width: auto;
  max-width: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Sticky footer specific width override (kept for safety) */
.sticky-footer .suggestions {
  width: calc(100% - 56px);
}

body.hero-centered {
  margin: 0;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 0;
  padding-bottom: 0;
}
body.hero-centered .container {
  margin-top: 0;
  max-width: 980px;
  width: -webkit-fill-available;
  padding-bottom: 24px;
  transform: translateY(0);
}

.hero-form,
.hero-row {
  transition: opacity 220ms ease, transform 260ms cubic-bezier(0.2, 0.9, 0.2, 1);
  transform: translateY(-20px);
}
body.hero-centered .hero-form,
body.hero-centered .hero-row {
  transform: translateY(0);
}
body.no-anim .container,
body.no-anim .hero-form,
body.no-anim .hero-row {
  transition: none !important;
}
body.hero-centered .hero-row {
  width: min(960px, 100% - 48px);
}

/* Chat messages */
.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 0;
  min-height: auto;
}
.msg {
  max-width: none;
  padding: 16px;
  border-radius: 12px;
  box-sizing: border-box;
}
.msg.user {
  align-self: flex-end;
  background: #eeeeee;
  color: #000000;
  border-bottom-right-radius: 4px;
  max-width: 42%;
}
.msg-wrap.user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  align-self: stretch;
  width: 100%;
  gap: 6px;
}
.msg-wrap.user .msg-text {
  white-space: pre-wrap;
}
.msg-wrap.user .msg-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  max-height: 0;
  margin-top: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}
.msg-wrap.user:hover .msg-actions,
.msg-wrap.user:focus-within .msg-actions {
  opacity: 1;
  pointer-events: auto;
  max-height: 42px;
}
.msg-action-btn {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid #d7d7d7;
  background: #f7f7f7;
  color: #1f1f1f;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.msg-action-btn svg {
  width: 16px;
  height: 16px;
}
.msg-action-btn:hover {
  background: #ffffff;
}
.msg-action-btn.copied {
  background: #00000017;
  color: #000000;
}

@media (hover: none) {
  .msg-wrap.user .msg-actions {
    opacity: 1;
    pointer-events: auto;
    max-height: 32px;
    margin-top: 6px;
    transform: none;
  }
}
.msg.ai {
  white-space: pre-wrap;
  align-self: stretch;
  width: 100%;
  color: #03284b;
  border-bottom-left-radius: 4px;
  margin-left: 0;
  transition: all 0.2s ease;
}
.msg.ai:not(.entered) .answer-para:last-child::after {
  content: "";
  animation: blink 1.5s steps(2, start) infinite;
}

.msg .sources {
  margin-top: 8px;
  padding-left: 0;
  display: flex;
  gap: 8px;
  align-items: center;
}

/* new source button */
.source-item {
  position: relative;
  display: inline-block;
}
.source-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(3, 40, 75, 0.08);
  background: linear-gradient(180deg, #ffffff, #fbfdff);
  color: #02203a;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(2, 6, 23, 0.06);
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.source-btn:focus {
  outline: 2px solid rgba(3, 102, 214, 0.18);
}
.source-btn::before {
  content: "📁";
  display: inline-block;
  font-size: 15px;
  margin-right: 2px;
}

.source-btn-label {
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0.2px;
}

.source-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.08);
}

.source-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  min-width: 160px;
  max-width: 320px;
  background: #ffffff;
  color: #03284b;
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.12);
  font-size: 0.9rem;
  line-height: 1.35;
  white-space: normal;
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 180ms cubic-bezier(0.2, 0.9, 0.2, 1);
  z-index: 10002;
}
.source-tooltip div:first-child {
  font-weight: 700;
  margin-bottom: 6px;
}

/* show tooltip on hover or focus or when button has .open */
.source-btn:hover .source-tooltip,
.source-btn:focus .source-tooltip,
.source-btn.open .source-tooltip {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

/* small screens: make tooltip a block below the button for readability */
@media (max-width: 520px) {
  .source-btn {
    padding: 8px 14px;
    font-size: 1rem;
  }
  .source-tooltip {
    position: static;
    transform: none;
    opacity: 0;
    pointer-events: none;
    box-shadow: none;
    background: transparent;
    padding: 0;
    max-width: 100%;
    margin-top: 8px;
  }
  .source-btn.open .source-tooltip {
    opacity: 1;
    pointer-events: auto;
  }
  .sources {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .source-btn-label {
    font-weight: 600;
  }
}
.msg .meta {
  font-size: 0.8rem;
  color: #666;
  margin-top: 6px;
}
.msg.ai .meta {
  text-align: left;
}
.msg.user .meta {
  text-align: right;
}

/* Hide the main UI while the page finishes its initial restore so users don't see a flash of the hero view */
body.initializing .container,
body.initializing .hero-form,
body.initializing .hero-row {
  visibility: hidden;
  opacity: 0;
}

/* Wider hero row when centered (matches larger container) */
body.hero-centered .hero-row {
  width: min(960px, 100% - 48px);
}

/* ----- Chat messages ----- */
.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  /* Let messages flow naturally and allow page-level scrolling (like ChatGPT) */
  padding: 8px 0;
  min-height: auto;
}
.msg {
  max-width: none; /* allow individual messages to define their own width */
  padding: 16px;
  border-radius: 12px;
  box-sizing: border-box;
}
/* User messages remain compact on the right */
.msg.user {
  align-self: flex-end;
  background: #eeeeee;
  color: #000000;
  border-bottom-right-radius: 4px;
  max-width: 42%;
}
/* AI messages take full available width of the container */
.msg.ai {
  align-self: stretch;
  width: 100%;
  color: #03284b;
}

/* Smooth entry animation for newly appended AI messages */
/* Use `animate-in` on the element, then add `entered` to trigger the transition. */
.msg.ai.animate-in {
  opacity: 0;
  transform: translateY(10px) scale(0.995);
  transition: opacity 320ms ease, transform 360ms cubic-bezier(0.2, 0.9, 0.2, 1);
}
.msg.ai.animate-in.entered {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Slight subtle emphasis (optional) when hovered */
.msg.ai.animate-in.entered:hover {
  /* transform: translateY(-1px) scale(1.002); */
}
.msg .sources {
  margin-top: 8px;
  padding-left: 0;
  /* Source items now use `.source-item` + `.source-btn` styles defined earlier */
}
.msg .meta {
  font-size: 0.8rem;
  color: #666;
  margin-top: 6px;
  text-align: right;
}

/* ----- Sticky input footer ----- */
.container {
  max-width: 980px;
  margin: 0 auto;
  background: transparent; /* removed white card background */
  padding: 24px;
  border-radius: 0; /* remove rounded corners */
  box-shadow: none; /* remove drop shadow */
  padding-bottom: 200px; /* extra space for sticky footer and page scroll */
}
.sticky-footer {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 20px;
  z-index: 9999;
  width: min(980px, calc(100% - 48px));
  padding: 12px 16px;
  border-radius: 14px 14px 8px 8px;
  background-color: rgba(255, 255, 255, 0.2);
  color: #000000;

  /* Liquid glass / frosted background */
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.52),
    rgba(255, 255, 255, 0.38)
  );
  border: 1px solid rgba(235, 235, 235, 0.8);
  box-shadow: 0 -10px 40px rgba(2, 6, 23, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  background-clip: padding-box;
  -webkit-background-clip: padding-box;
  transition: transform 180ms cubic-bezier(0.2, 0.9, 0.2, 1),
    box-shadow 180ms ease;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  margin: 0;
}
.sticky-footer:hover,
.sticky-footer:focus-within {
  transform: translateX(-50%) translateY(-6px);
  box-shadow: 0 -14px 50px rgba(2, 6, 23, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* Toggle Switch Styles */
.streaming-toggle-container {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 10px 16px;
  background: #000000;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
}

.streaming-toggle-container:hover {
  background: rgba(0, 0, 0, 0.75);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #555;
  transition: 0.3s;
  border-radius: 26px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background: #0366d6;
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(22px);
}

.toggle-label {
  color: #e0e0e0;
  user-select: none;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.toggle-icon {
  width: 18px;
  height: 18px;
  opacity: 0.8;
}

/* Animation for streaming indicator */
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.streaming-active .toggle-icon {
  animation: pulse 2s ease-in-out infinite;
}

/* Siem Reap AI mini modal */
.sr-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999; /* ensure above transforms and other UI */
}
.sr-modal.hidden {
  display: none;
}
.sr-modal-backdrop {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(8, 16, 30, 0.65),
    rgba(0, 0, 0, 0.58)
  );
  backdrop-filter: blur(4px) saturate(120%);
  -webkit-backdrop-filter: blur(4px) saturate(120%);
}
.sr-modal-panel {
  position: relative;
  z-index: 100000;
  background: #ffffff;
  color: #03284b;
  width: min(760px, 92%);
  max-width: 820px;
  border-radius: 12px;
  padding: 20px 22px;
  box-shadow: 0 18px 50px rgba(2, 6, 23, 0.5), 0 6px 18px rgba(2, 6, 23, 0.12);
  transform: translateY(-6px) scale(0.995);
  opacity: 0;
  transition: transform 240ms cubic-bezier(0.2, 0.9, 0.2, 1), opacity 200ms ease;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 18px;
}
.sr-modal:not(.hidden) .sr-modal-panel {
  transform: translateY(0) scale(1);
  opacity: 1;
}
.sr-modal-header {
  margin-bottom: 4px;
}
.sr-modal-header h2 {
  text-align: center;
  margin: 0;
  font-size: 1.15rem;
  color: #03284b;
}
.sr-modal-content p {
  margin: 18px 0;
  color: #334;
  line-height: 1.45;
  font-size: 0.98rem;
}
.sr-modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}
.sr-dont-show {
  font-size: 0.95rem;
  color: #445;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sr-actions-right {
  display: flex;
  gap: 12px;
  align-items: center;
}
#srAIModalClose.send-btn {
  padding: 8px 14px;
  border-radius: 8px;
  width: auto;
  height: auto;
  box-shadow: 0 6px 16px rgba(2, 6, 23, 0.12);
  background: #000000;
  color: #fff;
  font-weight: 600;
}
#srAIModalClose.send-btn svg {
  display: none;
}

/* top-right X close button */
.sr-modal-close-x {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 100001;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: none;
  background: rgba(0, 0, 0, 0.06);
  color: #03284b;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.sr-modal-close-x:active {
  transform: translateY(1px);
}

/* for medium screens (<= 768px) */
@media (max-width: 768px) {
  body {
    padding: 18px;
  }
  .container {
    padding: 0 12px;
  }
  .msg.user {
    padding: 12px;
    max-width: 80%;
  }
  .streaming-toggle-container {
    top: 10px;
    right: 10px;
    padding: 8px 12px;
  }

  .toggle-label span {
    display: none;
  }

  .toggle-switch {
    width: 42px;
    height: 24px;
  }

  .toggle-slider:before {
    height: 18px;
    width: 18px;
  }

  .toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(18px);
  }
}

/* =========================================================
  MOBILE (<= 520px) — unified layout for 0..520px
========================================================= */
@media (max-width: 520px) {
  body {
    padding: 12px !important;
  }

  h1 {
    font-size: 1.5rem !important;
  }

  .container {
    padding: 8px !important;
    padding-bottom: 120px !important;
  }

  /* hero input row width */
  .hero-row {
    width: calc(100% - 24px) !important;
    padding: 12px !important;
    margin: 0 auto !important;
  }

  /* messages */
  .msg {
    padding: 10px !important;
  }

  .msg.user {
    max-width: 92% !important;
    padding: 8px !important;
    font-size: 0.9rem !important;
  }

  /*remove AI padding */
  .msg.ai {
    padding: 0 !important;
    margin-bottom: 90px !important;
  }

  /*remove padding INSIDE answer (this is the real padding you still see) */
  .msg.ai .answer {
    padding: 0 !important;
    border: none !important;
  }

  .sticky-footer {
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    transform: none !important;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 8px) !important;
    padding: 0 12px !important;
    border-radius: 12px !important;
  }
  .url-badge.website-badge {
    font-size: 0.8em !important;
    padding: 2px 6px 4px 6px !important;
  }

  #query {
    min-height: 44px !important;
    padding: 10px !important;
    font-size: 16px !important;
  }

  .send-btn {
    width: 32px !important;
    height: 32px !important;
  }
  .subtitle {
    font-size: 0.75rem !important;
    margin-bottom: 28px !important;
    border-bottom: 1px solid #e6e9ee !important;
    padding-bottom: 12px !important;
  }

  .sr-modal-header h2 {
    font-size: 1.2rem;
  }
  .sr-modal-content p {
    font-size: 0.85rem;
  }
  .sr-dont-show {
    font-size: 0.75rem;
  }

  #srAIModalClose.send-btn {
    width: auto !important;
    padding: 10px 12px !important;
    font-size: 0.75rem !important;
  }

  .service-menu {
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }
  .service-menu::-webkit-scrollbar {
    height: 6px;
  }
  .menu-card {
    flex: 0 0 78%;
  }
}

/*Smaller bullet dot */
.custom-list li::before {
  font-size: 0.65rem !important;
  width: 0.9em !important;
  margin-right: 6px !important;
  line-height: 1.9 !important;
}
