:root {
  --bg: #f4f1ec;
  --surface: #ffffff;
  --text: #1f2933;
  --muted: #667085;
  --brand: #b4531f;
  --brand-text: #ffffff;
  --bot: #ece7df;
  --user: #b4531f;
  --user-text: #ffffff;
  --border: #ddd6cb;
  --danger-bg: #fdecea;
  --danger: #a12622;
  --chip: #f1e3d6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --surface: #1e2125;
    --text: #eceff3;
    --muted: #9aa3ad;
    --brand: #e07a3d;
    --brand-text: #1a1208;
    --bot: #2a2e33;
    --user: #e07a3d;
    --user-text: #1a1208;
    --border: #343a40;
    --danger-bg: #3a1f1d;
    --danger: #ff9a93;
    --chip: #3a2a1f;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Heebo", "Arial Hebrew", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}
[hidden] { display: none !important; }
#app { height: 100%; display: flex; align-items: center; justify-content: center; padding: 0 16px; }
h1 { margin: 0 0 4px; font-size: 1.6rem; }
.sub { color: var(--muted); font-size: 0.9rem; }

.card {
  width: calc(100% - 32px); max-width: 380px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 24px;
}
label { display: block; margin: 16px 0 6px; font-weight: 600; }
input, textarea {
  width: 100%; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 12px;
}
input:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
button {
  font: inherit; cursor: pointer; border: 0; border-radius: 12px;
  background: var(--brand); color: var(--brand-text);
  padding: 10px 18px; font-weight: 600; min-height: 44px;
}
button:disabled { opacity: 0.55; cursor: default; }
button.ghost { background: transparent; color: var(--brand); border: 1px solid var(--border); padding: 6px 12px; min-height: 36px; }
form button[type="submit"] { margin-top: 16px; width: 100%; }
.error { color: var(--danger); margin: 12px 0 0; }

.chat {
  width: 100%; max-width: 640px; height: 100dvh; max-height: 900px;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; overflow: hidden;
}
@media (max-width: 640px) {
  #app { padding: 0; }
  .chat { border-radius: 0; border: 0; max-height: none; }
}
.chat header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.chat header .sub { margin-inline-start: 8px; }
.messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.msg { max-width: 85%; display: flex; flex-direction: column; gap: 4px; }
.msg .bubble {
  padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg.bot { align-self: flex-start; }
.msg.bot .bubble { background: var(--bot); border-end-start-radius: 4px; }
.msg.user { align-self: flex-end; }
.msg.user .bubble { background: var(--user); color: var(--user-text); border-end-end-radius: 4px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; padding-inline: 4px; }
.chip {
  font-size: 0.78rem; background: var(--chip); color: var(--text);
  border-radius: 999px; padding: 2px 10px;
}
.chip.flag { background: var(--brand); color: var(--brand-text); }
.typing { color: var(--muted); font-style: italic; }
.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--danger-bg); color: var(--danger);
  padding: 10px 16px; border-top: 1px solid var(--border);
}
.composer {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}
.composer textarea { resize: none; max-height: 140px; }
.composer button { margin: 0; width: auto; }
