:root {
  --bg: #f4f4f5;
  --card: #ffffff;
  --text: #111113;
  --muted: #6b6b73;
  --border: #ececef;
  --bot-bubble: #f2f2f4;
  --user-bubble: #111113;
  --user-text: #ffffff;
  --accent: #0ea5e9;
  --online: #22c55e;
  --shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0c0e;
    --card: #17171a;
    --text: #ededf0;
    --muted: #9a9aa3;
    --border: #26262b;
    --bot-bubble: #222227;
    --user-bubble: #ededf0;
    --user-text: #111113;
    --shadow: 0 2px 24px rgba(0, 0, 0, 0.5);
  }
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
}

.chat-container { width: 100%; max-width: 700px; }

.chat-card {
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: min(760px, calc(100dvh - 80px));
}

.chat-header { padding: 28px 24px 20px; text-align: center; border-bottom: 1px solid var(--border); }
.avatar { display: block; width: 64px; height: 64px; margin: 0 auto 14px; }
.avatar-photo, .avatar-letter { width: 64px; height: 64px; border-radius: 14px; display: block; object-fit: cover; }
.avatar-letter {
  display: flex; align-items: center; justify-content: center;
  background: var(--user-bubble); color: var(--user-text); font-size: 24px; font-weight: 600;
}
.chat-header h1 { font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.status { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 14px; color: var(--muted); }
.status-dot { width: 8px; height: 8px; background: var(--online); border-radius: 50%; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18); }

.chat-messages { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 14px; }

.message { display: flex; gap: 10px; align-items: flex-end; animation: fadeIn 0.25s ease; }
.message.user-message { flex-direction: row-reverse; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.message-avatar {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: var(--user-bubble); color: var(--user-text);
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600;
}
.message-bubble {
  max-width: 80%; padding: 11px 15px; border-radius: 16px; font-size: 15px; line-height: 1.5;
  background: var(--bot-bubble); overflow-wrap: anywhere; white-space: normal;
}
.user-message .message-bubble { background: var(--user-bubble); color: var(--user-text); white-space: pre-wrap; }
.bot-message .message-bubble { border-bottom-left-radius: 4px; }
.user-message .message-bubble { border-bottom-right-radius: 4px; }
.message-bubble.error { white-space: pre-wrap; color: #b91c1c; }
.message-bubble a { color: var(--accent); }

.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 24px 14px; }
.quick-btn {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 8px 14px; font-size: 14px; cursor: pointer; font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.quick-btn:hover { background: var(--bot-bubble); }
.meeting-btn { background: var(--user-bubble); color: var(--user-text); border-color: var(--user-bubble); }
.meeting-btn:hover { background: var(--user-bubble); opacity: 0.88; }

.chat-input { display: flex; gap: 10px; padding: 16px 24px 20px; border-top: 1px solid var(--border); }
.chat-input input {
  flex: 1; min-width: 0; padding: 12px 16px; border-radius: 12px; font-size: 15px; font-family: inherit;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); outline: none;
}
.chat-input input:focus { border-color: var(--muted); }
.chat-input button {
  padding: 0 20px; border: 0; border-radius: 12px; font-size: 15px; font-weight: 600; cursor: pointer;
  background: var(--user-bubble); color: var(--user-text); font-family: inherit;
}
.chat-input button:disabled, .chat-input input:disabled { opacity: 0.5; cursor: default; }

.footnote { text-align: center; color: var(--muted); font-size: 12px; margin-top: 12px; }

.modal {
  display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5);
  align-items: center; justify-content: center; padding: 16px; z-index: 10;
}
.modal.active { display: flex; }
.modal-content {
  background: var(--card); border-radius: 16px; width: 100%; max-width: 900px;
  height: min(720px, 90dvh); display: flex; flex-direction: column; overflow: hidden;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 18px; font-weight: 600; }
.modal-close { border: 0; background: none; font-size: 28px; line-height: 1; cursor: pointer; color: var(--muted); }
.modal-content iframe { flex: 1; width: 100%; border: 0; background: #fff; }

@media (max-width: 560px) {
  body { padding: 0; align-items: stretch; }
  .chat-card { height: 100dvh; border-radius: 0; box-shadow: none; }
  .footnote { display: none; }
  .chat-header { padding: 18px 16px 14px; }
  .avatar, .avatar-photo, .avatar-letter { width: 52px; height: 52px; }
  .chat-messages { padding: 16px; }
  .quick-actions { padding: 0 16px 12px; }
  .chat-input { padding: 12px 16px 16px; }
  .message-bubble { max-width: 85%; }
}
