:root{
  --rcd-bg: #e2e8f0;
  --rcd-chat: #fff;
  --rcd-text: #0f172a;
  --rcd-muted: #64748b;
  --rcd-line: #e2e8f0;
  --rcd-accent: #0ea5e9;
  --rcd-accent-dark: #0369a1;
  --rcd-user: #94a3b8;
  --rcd-ai: #4ade80;
}

*{ box-sizing: border-box; }

html, body{
  margin: 0;
  height: 100%;
  background: var(--rcd-bg);
  color: var(--rcd-text);
  font: 16px/1.45 "Iowan Old Style", Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

body.rcd{
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: 0 12px;
  background: var(--rcd-bg);
}

.rcd-header{
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 18px 12px;
  background: transparent;
}

.rcd-header h1{
  margin: 0;
  font-size: 1.25rem;
}

.rcd-main{
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
  max-width: 720px;
  margin: 0 auto 12px;
  background: var(--rcd-chat);
  border: 1px solid #cbd5e1;
  border-radius: 16px;
  overflow: hidden;
}

.rcd-scroll{
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  background: var(--rcd-chat);
}

.rcd-messages{
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 720px;
  margin: 0 auto;
}

.rcd-bubble{
  max-width: 85%;
  padding: 6px 9px;
  border-radius: 12px 12px 12px 3px;
}

.rcd-bubble--ai{
  align-self: flex-start;
  background: var(--rcd-ai);
  color: #14532d;
}

.rcd-bubble--user{
  align-self: flex-end;
  border-radius: 12px 12px 3px 12px;
  background: var(--rcd-user);
  color: #0f172a;
}

.rcd-bubble-meta{
  display: block;
  margin-bottom: 1px;
  font-size: 0.62rem;
  font-weight: 700;
}

.rcd-bubble-text{
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.35;
  font-size: 0.88rem;
}

.rcd-bubble-time{
  display: block;
  margin-top: 2px;
  font-size: 0.58rem;
  opacity: 0.85;
}

.rcd-composer{
  display: flex;
  gap: 8px;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom, 0px));
  width: 100%;
  margin: 0;
  background: var(--rcd-chat);
  border-top: 1px solid var(--rcd-line);
}

.rcd-composer input{
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  background: #fff;
  color: var(--rcd-text);
}

.rcd-btn{
  border: 1px solid #cbd5e1;
  background: #fff;
  color: var(--rcd-text);
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  cursor: pointer;
}

.rcd-btn--primary{
  background: var(--rcd-accent);
  border-color: var(--rcd-accent-dark);
  color: #fff;
}

.rcd-hint{
  margin: 0 18px 12px;
  color: #b91c1c;
}

.rcd-modal{
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.45);
  padding: 18px;
}

.rcd-modal[hidden]{ display: none; }

.rcd-modal__card{
  width: min(100%, 360px);
  background: #fff;
  color: var(--rcd-text);
  border-radius: 16px;
  padding: 22px;
  display: grid;
  gap: 16px;
}

.rcd-modal__card .rcd-btn--primary{ width: 100%; }
