html,
body {
  margin: 0;
  height: 100%;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  background: #f7f7f7;
  color: #0b1d3a;
  overflow: hidden;
}

.app-shell {
  min-height: 100vh;
  height: 100vh;
  display: flex;
  background: #f7f7f7;
  overflow: hidden;
}

.sidebar {
  flex: 0 0 280px;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  gap: 1rem;
  background: #ffffff;
  border-right: 1px solid rgba(11, 29, 78, 0.1);
}

.brand span {
  font-weight: 700;
  font-size: 1.2rem;
  color: #0b1d3a;
}

.new-chat {
  width: 100%;
  padding: 0.75rem;
  border-radius: 0.8rem;
  border: 1px solid rgba(11, 29, 78, 0.2);
  background: #eef1ff;
  color: #0b1d3a;
  font-weight: 600;
  cursor: pointer;
}


.chat-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  overflow-y: auto;
  max-height: calc(100vh - 220px);
}

.chat-item {
  border: 1px solid rgba(11, 29, 78, 0.12);
  border-radius: 0.9rem;
  padding: 0.85rem 1rem;
  background: #fdfdfd;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-align: left;
  align-items: flex-start;
}

.chat-item.active {
  border-color: rgba(37, 99, 235, 0.5);
  background: #eef4ff;
}

.chat-item.closed {
  opacity: 0.5;
  border-color: rgba(107, 114, 128, 0.35);
  cursor: not-allowed;
}

.chat-item strong {
  display: block;
  margin-bottom: 0.3rem;
}

.chat-item small {
  padding: 0.2rem 0.5rem;
  border-radius: 0.7rem;
  font-size: 0.7rem;
  color: #0b1d3a;
}

.chat-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chat-categories span {
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: rgba(11, 29, 78, 0.08);
  font-size: 0.7rem;
}

.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #f7f7f7;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

.chat-header {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  background: #ffffff;
  border-bottom: 1px solid rgba(11, 29, 78, 0.1);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chat-title {
  margin: 0;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tab {
  padding: 0.45rem 0.9rem;
  border-radius: 0.7rem;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
}

.tab.active {
  border-color: rgba(59, 130, 246, 0.4);
  background: rgba(59, 130, 246, 0.1);
}

.chat-header {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  background: #ffffff;
  border-bottom: 1px solid rgba(11, 29, 78, 0.1);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chat-title {
  margin: 0;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tab {
  padding: 0.45rem 0.9rem;
  border-radius: 0.7rem;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
}

.tab.active {
  border-color: rgba(59, 130, 246, 0.4);
  background: rgba(59, 130, 246, 0.1);
}

.messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.5rem 1.5rem 2rem;
  overflow-y: auto;
}

.analytics-view {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.analytics-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

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

.metrics-grid article {
  border: 1px solid rgba(11, 29, 78, 0.1);
  border-radius: 0.75rem;
  padding: 1rem;
  background: #ffffff;
}

.metrics-grid .label {
  margin: 0;
  font-size: 0.75rem;
  color: rgba(11, 29, 78, 0.6);
}

.analytics-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.analytics-panels section {
  border: 1px solid rgba(11, 29, 78, 0.1);
  border-radius: 0.85rem;
  padding: 1rem;
  background: #ffffff;
}

.analytics-panels h3 {
  margin: 0 0 0.5rem 0;
  font-size: 0.95rem;
}

.analytics-panels ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.analytics-panels li {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.analytics-panels small {
  color: rgba(11, 29, 78, 0.5);
}

.history-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.history-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.history-controls button {
  border: 1px solid rgba(11, 29, 78, 0.2);
  border-radius: 0.75rem;
  background: #ffffff;
  padding: 0.35rem 0.8rem;
  cursor: pointer;
}

.history-controls button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.history-controls span {
  font-weight: 600;
}

.message-history {
  max-height: min(45vh, 360px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-right: 0.4rem;
}

.message-history article {
  border-radius: 0.75rem;
  border: 1px solid rgba(11, 29, 78, 0.1);
  background: #ffffff;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.message-history article ul {
  margin: 0;
  padding-left: 1.1rem;
  list-style: disc;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.message-history article ul li {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.composer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(11, 29, 78, 0.1);
  background: #ffffff;
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.composer textarea {
  flex: 1;
  border-radius: 0.85rem;
  border: 1px solid rgba(11, 29, 78, 0.2);
  background: #ffffff;
  color: #0b1d3a;
  padding: 0.85rem;
  resize: none;
  min-height: 70px;
}

.composer-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.composer button {
  border-radius: 0.85rem;
  padding: 0 1.5rem;
  min-height: 48px;
  font-weight: 600;
  cursor: pointer;
  border: none;
}

.composer button.submit {
  background: #1d4ed8;
  color: #ffffff;
}

.composer button.close-chat {
  background: #f97316;
  color: #ffffff;
}

.rating-panel {
  position: sticky;
  bottom: 0;
  padding: 1rem 1.5rem;
  background: #ffffff;
  border-top: 1px solid rgba(11, 29, 78, 0.1);
  box-shadow: 0 -10px 30px rgba(2, 16, 57, 0.09);
}

.rating-options {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.rating-options button {
  flex: 1;
  border-radius: 0.9rem;
  border: 1px solid rgba(11, 29, 78, 0.15);
  padding: 0.6rem 0;
  background: #f1f5f9;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.category-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 29, 78, 0.38);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.category-modal {
  width: min(420px, 90%);
  background: #ffffff;
  padding: 1.5rem;
  border-radius: 1rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.category-chip {
  border: 1px solid rgba(11, 29, 78, 0.15);
  border-radius: 0.7rem;
  padding: 0.75rem;
  background: #fefefe;
  cursor: pointer;
  font-weight: 500;
  text-align: left;
}

.category-overlay .ghost {
  align-self: flex-end;
  border-radius: 0.75rem;
  padding: 0.5rem 1rem;
  border: 1px solid rgba(11, 29, 78, 0.15);
  background: transparent;
  cursor: pointer;
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #f7f7f7;
}

.auth-card {
  width: min(360px, 90vw);
  padding: 2rem;
  border-radius: 1rem;
  background: #ffffff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.auth-card label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.95rem;
  width: 100%;
}

.auth-card input,
.auth-card button {
  padding: 0.8rem;
  border-radius: 0.7rem;
  border: 1px solid rgba(11, 29, 78, 0.2);
}

.auth-card button {
  border: none;
  background: #1d4ed8;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.auth-error {
  color: #dc2626;
  font-size: 0.9rem;
}

.chat-title {
  margin: 0;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.category-tag-list {
  display: flex;
  gap: 0.35rem;
}

.category-tag-list span {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: rgba(11, 29, 78, 0.08);
  font-size: 0.7rem;
}

.rating-badge {
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.15);
  font-size: 0.75rem;
}

.close-chat {
  border: 1px solid rgba(11, 29, 78, 0.2);
  border-radius: 0.85rem;
  padding: 0.35rem 0.9rem;
  background: transparent;
  cursor: pointer;
}

.messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.5rem 1.5rem 2rem;
  overflow-y: auto;
}

.message {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 1rem;
  border-radius: 1rem;
  background: #ffffff;
  border: 1px solid rgba(11, 29, 78, 0.08);
}

.message.user {
  background: rgba(37, 99, 235, 0.08);
  margin-left: auto;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: rgba(11, 29, 78, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.typing-dots {
  display: flex;
  gap: 0.25rem;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1d4ed8;
  animation: pulse 1s infinite;
}

.composer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(11, 29, 78, 0.1);
  display: flex;
  gap: 0.65rem;
  align-items: stretch;
  background: #ffffff;
}

.composer textarea {
  flex: 1;
  border-radius: 0.85rem;
  border: 1px solid rgba(11, 29, 78, 0.2);
  background: #ffffff;
  color: #0b1d3a;
  padding: 0.85rem;
  resize: none;
}

.composer button {
  border: none;
  border-radius: 0.85rem;
  padding: 0 1.5rem;
  background: #1d4ed8;
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
}

.rating-panel {
  position: sticky;
  bottom: 0;
  padding: 1rem 1.5rem;
  background: #ffffff;
  border-top: 1px solid rgba(11, 29, 78, 0.1);
  box-shadow: 0 -10px 30px rgba(2, 16, 57, 0.09);
}

.rating-options {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.rating-options button {
  flex: 1;
  border-radius: 0.9rem;
  border: 1px solid rgba(11, 29, 78, 0.15);
  padding: 0.6rem 0;
  background: #f1f5f9;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.category-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 29, 78, 0.38);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.category-modal {
  width: min(420px, 90%);
  background: #ffffff;
  padding: 1.5rem;
  border-radius: 1rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.category-chip {
  border: 1px solid rgba(11, 29, 78, 0.15);
  border-radius: 0.7rem;
  padding: 0.75rem;
  background: #fefefe;
  cursor: pointer;
  font-weight: 500;
  text-align: left;
}

.category-chip.selected {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.6);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.modal-actions .ghost {
  background: transparent;
  border-radius: 0.75rem;
  padding: 0.5rem 1rem;
  border: 1px solid rgba(11, 29, 78, 0.15);
  cursor: pointer;
}

.modal-actions .primary {
  background: #1d4ed8;
  color: white;
  border: none;
  border-radius: 0.75rem;
  padding: 0.5rem 1.2rem;
  cursor: pointer;
}

.helper {
  font-size: 0.85rem;
  color: rgba(11, 29, 78, 0.6);
  text-align: right;
}

@keyframes pulse {
  0% {
    transform: translateY(0);
    opacity: 0.4;
  }
  50% {
    transform: translateY(-3px);
    opacity: 1;
  }
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
}


.message p {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  flex: 1;
  min-width: 0;
}