:root {
  --page: #f5f7fa;
  --surface: #ffffff;
  --ink: #1d2938;
  --muted: #7d8998;
  --line: #e4e9ef;
  --blue: #2f72d6;
  --blue-soft: #eaf2ff;
  --green: #209765;
  --danger: #bd6b49;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
button:focus-visible, textarea:focus-visible { outline: 2px solid rgba(47, 114, 214, .45); outline-offset: 2px; }

.customer-app {
  width: min(100%, 640px);
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.customer-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: rgba(255, 255, 255, .97);
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 18px;
  font-weight: 800;
}

.brand-copy { min-width: 0; flex: 1; }
.brand-copy h1 { margin: 0; font-size: 16px; line-height: 1.3; font-weight: 750; }
.brand-copy p { display: flex; align-items: center; gap: 5px; margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.online-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.channel-label { color: var(--blue); background: var(--blue-soft); border-radius: 5px; padding: 5px 7px; font-size: 10px; white-space: nowrap; }

.conversation {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px 10px;
  background: #fbfcfd;
  overscroll-behavior: contain;
}

.day-note { margin: 0 auto 16px; color: #a2acb8; text-align: center; font-size: 10px; }
.message { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 14px; }
.message.user { flex-direction: row-reverse; }
.message-avatar { width: 28px; height: 28px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: #dceaff; color: #37649c; font-size: 11px; font-weight: 750; }
.message.assistant .message-avatar { background: #e2f4eb; color: var(--green); }
.message-body { max-width: min(82%, 460px); }
.message-bubble { padding: 9px 11px; border: 1px solid #e3e8ee; border-radius: 4px 9px 9px 9px; background: #fff; color: #405066; font-size: 13px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.message.user .message-bubble { border-color: #d7e5fb; border-radius: 9px 4px 9px 9px; background: var(--blue-soft); color: #345779; }
.message-meta { margin-top: 3px; color: #a4aeba; font-size: 10px; }
.message.user .message-meta { text-align: right; }
.message-meta.escalate { color: var(--danger); }

.typing .message-bubble { color: var(--muted); }

.quick-replies {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 8px 14px 7px;
  border-top: 1px solid var(--line);
  background: #fff;
  scrollbar-width: none;
}
.quick-replies::-webkit-scrollbar { display: none; }
.quick-replies button { flex: 0 0 auto; padding: 6px 9px; border: 1px solid #dbe4ef; border-radius: 6px; background: #fff; color: #58708d; font-size: 11px; white-space: nowrap; }
.quick-replies button:active { background: var(--blue-soft); border-color: #bad0ef; }

.composer { padding: 8px 12px max(11px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #fff; }
.composer textarea { width: 100%; min-height: 40px; max-height: 120px; resize: none; padding: 9px 10px; border: 1px solid #dce3eb; border-radius: 7px; background: #fbfcfd; color: #35475d; font-size: 13px; line-height: 1.45; }
.composer textarea::placeholder { color: #a4afbc; }
.composer textarea:focus { border-color: #8db1e6; outline: none; box-shadow: 0 0 0 3px rgba(47, 114, 214, .1); }
.send-button { width: 100%; height: 38px; margin-top: 7px; border-radius: 7px; background: var(--blue); color: #fff; font-size: 13px; font-weight: 650; }
.send-button:disabled { background: #a9bedc; cursor: wait; }
.composer-note { margin: 6px 2px 0; color: #9aa6b4; font-size: 10px; line-height: 1.45; }

@media (min-width: 641px) {
  body { padding: 16px 0; }
  .customer-app { min-height: calc(100vh - 32px); border: 1px solid var(--line); box-shadow: 0 8px 28px rgba(31, 49, 73, .08); }
  .customer-header { position: static; }
}
