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

/* Password overlay */
.password-overlay {
  position: fixed; inset: 0;
  background: #eef0f3;
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.password-overlay.hidden { display: none; }
.password-card {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 8px 40px rgba(0,0,0,.12);
  padding: 40px 36px;
  width: 100%; max-width: 360px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  text-align: center;
}
.password-logo {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: #1b2240;
  color: #e8b84b;
  font-weight: 800; font-size: 1.2rem;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
}
.password-card h2 { font-size: 1.15rem; color: #1b2240; font-weight: 700; }
.password-card p { font-size: .85rem; color: #666; line-height: 1.5; }
.password-card form {
  display: flex; flex-direction: column; gap: 10px;
  width: 100%; margin-top: 8px;
}
.password-card input[type="password"] {
  width: 100%;
  padding: 11px 16px;
  border: 1.5px solid #e0e3ea;
  border-radius: 12px;
  font-size: .95rem;
  outline: none;
  transition: border-color .2s;
  color: #1b2240;
}
.password-card input[type="password"]:focus { border-color: #1b2240; }
.password-card button[type="submit"] {
  width: 100%;
  padding: 11px;
  background: #1b2240; color: #fff;
  border: none; border-radius: 12px;
  font-size: .95rem; font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.password-card button[type="submit"]:hover { background: #2a3560; }
.password-error {
  display: none;
  color: #c0392b;
  font-size: .82rem;
  text-align: left;
}
.password-error.visible { display: block; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #eef0f3;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-container {
  width: 100%;
  max-width: 780px;
  height: 100dvh;
  background: #fff;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,.12);
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 24px;
  background: #1b2240;
  color: #fff;
  flex-shrink: 0;
}
.header-logo {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: #e8b84b;
  color: #1b2240;
  font-weight: 800;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.chat-header h1 { font-size: 1.05rem; font-weight: 700; }
.subtitle { font-size: 0.75rem; opacity: .65; }

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.message { display: flex; max-width: 78%; }
.message.user  { align-self: flex-end; }
.message.assistant { align-self: flex-start; }

.message-content {
  padding: 11px 16px;
  border-radius: 18px;
  line-height: 1.65;
  font-size: .93rem;
  word-break: break-word;
}
.message.user .message-content {
  background: #1b2240;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.message.assistant .message-content {
  background: #f1f3f6;
  color: #1b2240;
  border-bottom-left-radius: 4px;
}

.message-content img {
  display: block;
  max-width: 260px;
  border-radius: 10px;
  margin-bottom: 8px;
}

/* Markdown */
.message-content p { margin-bottom: .5em; }
.message-content p:last-child { margin-bottom: 0; }
.message-content strong { font-weight: 700; }
.message-content em { font-style: italic; }
.message-content ul, .message-content ol { padding-left: 18px; margin: .4em 0; }
.message-content li { margin-bottom: .2em; }
.message-content code {
  background: rgba(0,0,0,.08);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: monospace;
  font-size: .88em;
}

/* Typing cursor */
.cursor {
  display: inline-block;
  width: 2px; height: 1em;
  background: currentColor;
  margin-left: 2px;
  vertical-align: middle;
  animation: blink .9s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* Typing indicator (three bouncing dots) */
.typing-indicator {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 5px;
  background: #f1f3f6;
  padding: 14px 18px;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
}
.typing-indicator span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #9aa0b0;
  animation: typing-bounce 1.2s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: .2s; }
.typing-indicator span:nth-child(3) { animation-delay: .4s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .6; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Tool indicator */
.tool-indicator {
  align-self: flex-start;
  display: flex; align-items: center; gap: 8px;
  font-size: .8rem; color: #666;
  background: #f1f3f6;
  padding: 7px 14px;
  border-radius: 20px;
  animation: pulse 1.4s ease-in-out infinite;
}
.tool-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #e8b84b;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.45} }

/* Image preview */
.image-preview {
  display: none;
  padding: 6px 24px;
  position: relative;
  align-self: flex-start;
}
.image-preview.visible { display: block; }
.image-preview img {
  height: 72px;
  border-radius: 8px;
  border: 2px solid #1b2240;
}
.remove-image {
  position: absolute; top: 2px; right: 20px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #1b2240; color: #fff;
  border: none; cursor: pointer;
  font-size: .7rem;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}

/* Footer */
.chat-footer {
  padding: 14px 20px 18px;
  border-top: 1px solid #e8eaed;
  flex-shrink: 0;
}
.input-area {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: #f1f3f6;
  border-radius: 24px;
  padding: 8px 8px 8px 14px;
  transition: box-shadow .2s;
}
.input-area:focus-within {
  box-shadow: 0 0 0 2px #1b2240;
}

.attach-btn {
  cursor: pointer; color: #888;
  display: flex; align-items: center;
  padding: 4px; border-radius: 50%;
  transition: color .15s;
  flex-shrink: 0;
}
.attach-btn:hover { color: #1b2240; }
.attach-btn svg { width: 20px; height: 20px; }
.attach-btn input { display: none; }

textarea {
  flex: 1;
  border: none; background: transparent;
  resize: none; outline: none;
  font-family: inherit; font-size: .93rem;
  line-height: 1.5; max-height: 130px;
  padding: 3px 0;
  color: #1b2240;
}
textarea::placeholder { color: #aaa; }

.send-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: #1b2240; color: #fff;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}
.send-btn:hover:not(:disabled) { background: #2a3560; }
.send-btn:active:not(:disabled) { transform: scale(.93); }
.send-btn:disabled { background: #c8ccd4; cursor: not-allowed; }
.send-btn svg { width: 16px; height: 16px; }

/* Drag over */
body.drag-over .chat-container { outline: 3px dashed #1b2240; outline-offset: -4px; }

/* Scrollbar */
.messages::-webkit-scrollbar { width: 5px; }
.messages::-webkit-scrollbar-thumb { background: #d0d3da; border-radius: 4px; }
