*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --navy: #2b3743;
  --navy-deep: #1a2634;
  --orange: #f68d2e;
  --orange-light: #fff3e0;
  --white: #ffffff;
  --gray-50: #f8f9fa;
  --gray-100: #f0f2f5;
  --gray-200: #e4e6ea;
  --gray-500: #65676b;
  --gray-700: #3a3b3c;
  --radius: 18px;
  --radius-sm: 12px;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-100);
  color: var(--gray-700);
  display: flex;
  justify-content: center;
  align-items: center;
}

.chat-container {
  width: 100%;
  height: 100%;
  max-width: 480px;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--white);
  position: relative;
}

@media (min-width: 520px) {
  .chat-container {
    height: 90vh;
    max-height: 750px;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    overflow: hidden;
  }
}

.chat-header {
  background: var(--navy);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.header-logo {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 10px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.logo {
  height: 32px;
  width: auto;
}

.header-text h1 {
  font-size: 16px;
  font-weight: 700;
  color: var(--white);
  line-height: 1.2;
}

.header-text p {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 2px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.message {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.45;
  word-wrap: break-word;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.assistant {
  align-self: flex-start;
  background: var(--gray-100);
  color: var(--gray-700);
  border-bottom-left-radius: 6px;
}

.message.user {
  align-self: flex-end;
  background: var(--navy);
  color: var(--white);
  border-bottom-right-radius: 6px;
}

.typing-indicator {
  align-self: flex-start;
  padding: 12px 18px;
  background: var(--gray-100);
  border-radius: var(--radius);
  border-bottom-left-radius: 6px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--gray-500);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

.chat-input-area {
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  flex-shrink: 0;
}

.chat-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--gray-200);
  border-radius: 24px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  background: var(--gray-50);
}

.chat-input:focus {
  border-color: var(--orange);
  background: var(--white);
}

.chat-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--orange);
  color: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.1s;
}

.chat-send:hover {
  background: #e07d1e;
}

.chat-send:active {
  transform: scale(0.95);
}

.chat-send:disabled {
  background: var(--gray-200);
  cursor: not-allowed;
}

.chat-complete {
  padding: 20px 16px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  text-align: center;
  flex-shrink: 0;
}

.complete-message p {
  font-size: 14px;
  color: var(--gray-500);
  margin-bottom: 12px;
}

.restart-btn {
  padding: 10px 24px;
  background: var(--orange);
  color: var(--white);
  border: none;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}

.restart-btn:hover {
  background: #e07d1e;
}
