:root {
  --bg: #faf6f0;
  --ink: #2b2b2b;
  --accent: #a4262c;
  --accent-ink: #ffffff;
  --bubble-bot: #ffffff;
  --bubble-user: #a4262c;
  --border: #e5ddd0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-emoji { font-size: 28px; }
.topbar h1 { font-size: 17px; margin: 0; }
.subtitle { font-size: 12px; margin: 2px 0 0; color: #6b6257; }

#new-chat {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-size: 18px;
  cursor: pointer;
  color: var(--accent);
}

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  font-size: 15px;
}

.msg.bot {
  align-self: flex-start;
  background: var(--bubble-bot);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg.user {
  align-self: flex-end;
  background: var(--bubble-user);
  color: var(--accent-ink);
  border-bottom-right-radius: 4px;
}

.msg.typing {
  color: #8a8177;
  font-style: italic;
}

.msg.notice {
  align-self: center;
  background: transparent;
  border: none;
  color: #8a8177;
  font-size: 13px;
  text-align: center;
}

#error-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 auto;
  width: calc(100% - 32px);
  max-width: 688px;
  padding: 10px 14px;
  background: #fdecea;
  border: 1px solid #f5c6c2;
  border-radius: 12px;
  font-size: 14px;
}

#retry {
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.composer {
  padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid var(--border);
}

#chat-form {
  display: flex;
  gap: 8px;
  max-width: 720px;
  margin: 0 auto;
}

#input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 11px 16px;
  font-size: 16px; /* évite le zoom iOS */
  outline: none;
  background: var(--bg);
}

#input:focus { border-color: var(--accent); }

#send {
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 17px;
  cursor: pointer;
  flex-shrink: 0;
}

#send:disabled { opacity: 0.5; cursor: default; }
