:root {
  --page-margin: 10vw;
  --page-width: 80vw;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: #f6f9fc;
  color: #0f172a;
  overflow: hidden;
  font-size: 14px;
}

.hidden {
  display: none !important;
}

.app-shell {
  height: 100vh;
}

.top-shell {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  background: rgba(246, 249, 252, 0.92);
  z-index: 120;
  border-bottom: none;
  box-shadow: none;
  backdrop-filter: blur(6px);
}

.top-shell-inner {
  width: var(--page-width);
  margin-left: var(--page-margin);
  margin-right: var(--page-margin);
  padding: 14px 0 12px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.logo-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-img {
  height: 54px;
  width: auto;
  border-radius: 12px;
  object-fit: cover;
}

.logo-img.hidden {
  display: none;
}

.logo-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.logo-brand {
  font-size: 1rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  color: #0f4471;
}

.logo-title {
  font-size: 1.35rem;
  font-weight: 650;
  color: #0f4471;
  letter-spacing: 0.01em;
}

.upload-label {
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 20px;
  font-weight: 500;
  border: 1px dashed #a3b8d1;
  color: #0f4471;
  background: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  font-size: 0.88rem;
}

.upload-label:hover {
  border-color: #0f74bc;
  color: #0f74bc;
}

.upload-label input {
  display: none;
}

.sticky-docs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
  min-height: 32px;
}

.clear-docs {
  margin-top: 4px;
  background: transparent;
  border: none;
  color: #d64747;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 0 0;
  font-size: 0.85rem;
  align-self: flex-start;
}

.clear-docs:hover {
  text-decoration: underline;
}

.doc-placeholder {
  color: #6b7280;
  font-size: 0.95rem;
}

.doc-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(15, 116, 188, 0.08);
  border-radius: 999px;
  padding: 6px 16px;
  border: 1px solid transparent;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.2;
}

.doc-chip:focus-visible {
  box-shadow: 0 0 0 2px rgba(15, 116, 188, 0.2);
}

.doc-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

.remove-doc {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
}

.remove-doc:hover {
  background: rgba(15, 116, 188, 0.16);
}

.doc-chip.active {
  border-color: #0f74bc;
  background: rgba(15, 116, 188, 0.15);
  color: #0f4471;
}

.doc-chip:not(.active) {
  opacity: 0.6;
}

.chat-container {
  position: fixed;
  top: 198px;
  bottom: 130px;
  left: var(--page-margin);
  width: var(--page-width);
  overflow-y: auto;
  padding: 26px 24px 32px 24px;
  transform: none;
  background: #fbf7ff;
  border-radius: 32px;
  box-shadow: 0 18px 55px rgba(15, 23, 42, 0.12);
  box-sizing: border-box;
}

.qa-row {
  display: flex;
  width: 100%;
}

.question-row {
  justify-content: flex-end;
}

.answer-row {
  justify-content: flex-start;
}

.bubble {
  padding: 14px 18px;
  border-radius: 20px;
  max-width: 72%;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.1);
  line-height: 1.35;
  font-size: 0.88rem;
  word-break: break-word;
}

.question-bubble {
  background: #ffeaea;
  border: 1px solid #ffd3d3;
  color: #842525;
}

.answer-bubble {
  background: #eaffea;
  border: 1px solid #c2f0c2;
  color: #0c4a0c;
  margin-bottom: 24px;
}

.answer-bubble.error-state {
  background: #fff1f1;
  border-color: #ffbcbc;
  color: #a32020;
}

.loader-bubble {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.loader-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1f9b1f;
  animation: loaderBlink 1.2s infinite ease-in-out;
}

.loader-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.loader-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes loaderBlink {
  0%,
  80%,
  100% {
    opacity: 0.2;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

.input-bar {
  position: fixed;
  bottom: 18px;
  left: var(--page-margin);
  width: var(--page-width);
  z-index: 150;
  transform: none;
}

.input-inner {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  width: 100%;
  background: #fff;
  border-radius: 30px;
  padding: 12px 20px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
}

.input-inner textarea {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 0.88rem;
  min-height: 76px;
  max-height: 200px;
  resize: none;
  padding: 4px;
  font-family: inherit;
}

.input-inner textarea:focus {
  outline: none;
}

.send-button {
  background: linear-gradient(135deg, #ff7d7d, #ffb347);
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  font-size: 20px;
  box-shadow: 0 12px 30px rgba(255, 146, 128, 0.4);
  cursor: pointer;
}

.send-button:hover {
  filter: brightness(0.95);
}

.error-banner {
  position: fixed;
  bottom: 120px;
  left: var(--page-margin);
  transform: none;
  margin: 6px auto 0 auto;
  background: #fff0f0;
  color: #a83232;
  border-left: 4px solid #f5a9a9;
  padding: 12px 16px;
  border-radius: 12px;
  width: var(--page-width);
  z-index: 140;
}

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-thumb {
  background: #d7dee8;
  border-radius: 8px;
}

@media (max-width: 900px) {
  :root {
    --page-margin: 5vw;
    --page-width: 90vw;
  }

  .chat-container {
    top: 200px;
  }
}

