:root {
  --primary: #2563eb;
  --secondary: #7c3aed;
  --light-blue: #eff6ff;
  --text: #172554;
  --white: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, #dbeafe, #ede9fe, #fce7f3);
}

.app {
  width: 100%;
  max-width: 760px;
  height: min(85vh, 780px);
  min-height: 480px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(65, 76, 160, 0.18);
}

.header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px;
  background: linear-gradient(120deg, #ffffff, #f5f3ff);
  border-bottom: 1px solid #e5e7eb;
}

.logo {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 27px;
  border-radius: 16px;
  color: white;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  box-shadow: 0 5px 15px #2563eb35;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  color: #2563eb;
}

.brand p {
  margin: 4px 0 0;
  font-size: 13px;
  color: #64748b;
}

.status {
  margin-left: auto;
  white-space: nowrap;
  font-size: 12px;
  color: #16a34a;
}

.chat-box {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 22px;
  background: linear-gradient(180deg, #ffffff, #fafaff);
  scroll-behavior: smooth;
}

.message {
  width: fit-content;
  max-width: 88%;
  margin: 0 0 16px;
  padding: 13px 16px;
  border-radius: 17px;
  line-height: 1.65;
  overflow-wrap: anywhere;
  box-shadow: 0 3px 10px rgba(30, 64, 175, 0.05);
}

.message strong {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
}

.message-content,
.message p {
  margin: 0;
  font-size: 15px;
}

.message.user {
  margin-left: auto;
  color: white;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  border-bottom-right-radius: 5px;
}

.message.bot {
  margin-right: auto;
  color: #1e3a8a;
  background: linear-gradient(135deg, #eff6ff, #f3f0ff);
  border: 1px solid #e0e7ff;
  border-bottom-left-radius: 5px;
}

.message-content h1,
.message-content h2,
.message-content h3 {
  margin: 16px 0 8px;
  line-height: 1.4;
}

.message-content h1:first-child,
.message-content h2:first-child,
.message-content h3:first-child {
  margin-top: 0;
}

.message-content p {
  margin: 8px 0;
}

.message-content ul,
.message-content ol {
  padding-left: 24px;
  margin: 8px 0 12px;
}

.message-content li {
  margin: 5px 0;
}

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

.message-content th,
.message-content td {
  padding: 9px 12px;
  border: 1px solid #dbeafe;
  text-align: left;
  vertical-align: top;
  min-width: 100px;
}

.message-content th {
  color: #ffffff;
  background: #4f46e5;
}

.message-content pre {
  overflow-x: auto;
  padding: 14px;
  border-radius: 12px;
  color: #e0e7ff;
  background: #172554;
}

.message-content code {
  overflow-wrap: anywhere;
}

.message-content a {
  color: #2563eb;
}

.typing {
  padding: 0 22px 12px;
  color: #7c3aed;
  font-size: 13px;
  font-style: italic;
}

.chat-form {
  display: flex;
  gap: 10px;
  padding: 15px;
  background: white;
  border-top: 1px solid #e5e7eb;
}

.chat-form input {
  flex: 1;
  min-width: 0;
  padding: 14px 15px;
  border: 1px solid #c7d2fe;
  border-radius: 13px;
  outline: none;
  font: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-form input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px #6366f120;
}

.chat-form button {
  padding: 0 22px;
  border: none;
  border-radius: 13px;
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  transition: transform 0.2s, opacity 0.2s;
}

.chat-form button:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 15px #6366f140;
}

.chat-form button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

footer {
  padding: 0 12px 14px;
  text-align: center;
  color: #94a3b8;
  font-size: 11px;
  background: white;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

/* Mobile responsive design */
@media (max-width: 600px) {
  body {
    padding: 0;
    align-items: stretch;
  }

  .app {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    border: none;
    border-radius: 0;
  }

  .header {
    padding: 15px;
  }

  .brand h1 {
    font-size: 19px;
  }

  .chat-box {
    padding: 15px;
  }

  .message {
    max-width: 94%;
  }

  .chat-form {
    padding: 12px;
  }

  .chat-form input {
    padding: 12px;
  }

  .chat-form button {
    padding: 0 16px;
  }
}
