: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%; }

/* ======================================================================================
   The new design (html.ad-on): the portal's approved Conversations chat (agent-home.css,
   "The open chat", "Messages", "Composer"). <html> always carries ad-on; the rules above are the base
   the new design builds on.
   ====================================================================================== */

html.ad-on{
  --ad-ink: #0f1b2d;
  --ad-ink-2: #3d4a5c;
  --ad-mute: #6b7686;
  --ad-line: #ebe7df;
  --ad-line-2: #f1eee8;
  --ad-paper: #ffffff;
  --ad-bg: #f9f7f3;
  --ad-navy: #102d4e;
  --ad-navy-2: #1c4471;
  --ad-gold: #c48a2c;
  --ad-gold-bg: #fbf0dc;
  --ad-blue: #2563eb;
  --ad-rose: #e11d48;
  --ad-rose-bg: #fde8ec;
  --ad-radius: 18px;
  --ad-shadow: 0 1px 2px rgba(15, 27, 45, 0.04), 0 8px 24px -14px rgba(15, 27, 45, 0.18);
  --ad-sans: "Geist", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --ad-serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --ad-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ad-i-send: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 19V5M5 12l7-7 7 7'/%3E%3C/svg%3E");
  --ad-i-plus: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E");
  --ad-i-spark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M12 2.5c.4 4.6 2.9 7.1 7.5 7.5-4.6.4-7.1 2.9-7.5 7.5-.4-4.6-2.9-7.1-7.5-7.5 4.6-.4 7.1-2.9 7.5-7.5Z'/%3E%3Cpath d='M19 15.5c.2 2 1.1 2.9 3 3-1.9.2-2.8 1.1-3 3-.2-1.9-1.1-2.8-3-3 1.9-.1 2.8-1 3-3Z'/%3E%3C/svg%3E");
}

html.ad-on,
html.ad-on body{
  background: var(--ad-bg);
  color: var(--ad-ink);
  font: 400 15px/1.5 var(--ad-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html.ad-on body.rcd{
  height: 100dvh;
  min-height: 0;
  padding: 20px 24px 24px;
  background: var(--ad-bg);
}

html.ad-on .rcd :is(button, input){
  font-family: var(--ad-sans);
}

/* ---------- Above the chat: avatar, title, New chat ---------- */

html.ad-on .rcd-header{
  max-width: 920px;
  padding: 4px 4px 16px;
}

html.ad-on .rcd-header h1{
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ad-ink);
  font: 400 2rem/1.1 var(--ad-serif);
  letter-spacing: -0.015em;
}

/* The AI's avatar: gold tint with the spark, the colour of the AI's turns. */
html.ad-on .rcd-header h1::before{
  content: "";
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--ad-gold-bg);
  box-shadow: inset 0 0 0 1px #f1e2c2;
}

html.ad-on .rcd-header h1::after{
  content: "";
  position: absolute;
  top: 50%;
  left: 11px;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  background: #a26a17;
  -webkit-mask: var(--ad-i-spark) center / contain no-repeat;
  mask: var(--ad-i-spark) center / contain no-repeat;
}

/* ---------- Buttons ---------- */

html.ad-on .rcd-btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 18px 0 14px;
  border: 1px solid var(--ad-line);
  border-radius: 999px;
  background: var(--ad-paper);
  color: var(--ad-ink);
  font: 600 0.875rem/1 var(--ad-sans);
  box-shadow: 0 1px 2px rgba(15, 27, 45, 0.05);
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s var(--ad-ease);
}

html.ad-on #rcdNewChatBtn::before{
  content: "";
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: var(--ad-i-plus) center / contain no-repeat;
  mask: var(--ad-i-plus) center / contain no-repeat;
}

html.ad-on .rcd-btn:hover{
  border-color: color-mix(in srgb, var(--ad-line) 40%, var(--ad-mute));
  background: #fbfaf7;
}

html.ad-on .rcd-btn--primary{
  padding: 0 20px;
  border-color: var(--ad-navy);
  background: var(--ad-navy);
  color: #fff;
  box-shadow: 0 8px 20px -12px rgba(16, 45, 78, 0.75);
}

html.ad-on .rcd-btn--primary:hover:not(:disabled){
  border-color: var(--ad-navy-2);
  background: var(--ad-navy-2);
}

html.ad-on .rcd :is(button, [tabindex]):focus-visible{
  outline: 3px solid color-mix(in srgb, var(--ad-blue) 45%, white);
  outline-offset: 2px;
}

/* ---------- The chat card ---------- */

html.ad-on .rcd-main{
  max-width: 920px;
  margin: 0 auto;
  border: 1px solid var(--ad-line);
  border-radius: var(--ad-radius);
  background: var(--ad-paper);
  box-shadow: var(--ad-shadow);
}

html.ad-on .rcd-scroll{
  padding: 0;
  /* Paper grain, as in Conversations: warm and white specks balance out to --ad-bg. */
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' seed='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.36 0 0 0 0 0.29 0 0 0 0 0.18 0 0 0 0.9 -0.36'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E") 0 0 / 200px 200px,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' seed='9' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1.1 -0.42'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E") 0 0 / 200px 200px,
    var(--ad-bg);
}

/* ---------- Messages ---------- */

html.ad-on .rcd-messages{
  gap: 14px;
  max-width: 880px;
  padding: 24px 28px 28px;
}

html.ad-on .rcd-bubble{
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: min(76%, 600px);
  padding: 11px 15px 9px;
  border: 1px solid #f1e2c2;
  border-radius: 6px 18px 18px 18px;
  background: #fdf7ea;
  color: var(--ad-ink);
  box-shadow: 0 1px 2px rgba(15, 27, 45, 0.04);
  animation: ad-rcd-in 0.2s var(--ad-ease);
}

html.ad-on .rcd-bubble--user{
  border-color: var(--ad-navy);
  border-radius: 18px 6px 18px 18px;
  background: var(--ad-navy);
  color: #fff;
  box-shadow: 0 8px 22px -14px rgba(16, 45, 78, 0.8);
}

html.ad-on .rcd-bubble-meta{
  margin: 0;
  color: #a26a17;
  font: 650 0.74rem/1.2 var(--ad-sans);
  letter-spacing: 0.01em;
}

html.ad-on .rcd-bubble--user .rcd-bubble-meta{
  color: rgba(255, 255, 255, 0.7);
}

html.ad-on .rcd-bubble-text{
  color: inherit;
  font: 400 0.95rem/1.5 var(--ad-sans);
  overflow-wrap: anywhere;
}

html.ad-on .rcd-bubble-time{
  align-self: flex-end;
  margin: 0;
  color: var(--ad-mute);
  font: 500 0.68rem/1 var(--ad-sans);
  font-variant-numeric: tabular-nums;
  opacity: 1;
}

html.ad-on .rcd-bubble--user .rcd-bubble-time{
  color: rgba(255, 255, 255, 0.6);
}

@keyframes ad-rcd-in{
  from{ opacity: 0; transform: translateY(4px); }
  to{ opacity: 1; transform: none; }
}

/* ---------- Composer ---------- */

html.ad-on .rcd-composer{
  gap: 6px;
  width: auto;
  max-width: 880px;
  margin: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  padding: 6px 6px 6px 8px;
  border: 1px solid var(--ad-line);
  border-radius: 16px;
  background: var(--ad-bg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

/* The hairline above the composer, as in Conversations. */
html.ad-on .rcd-scroll{
  border-bottom: 1px solid var(--ad-line-2);
}

@media (min-width: 940px){
  html.ad-on .rcd-composer{
    width: calc(100% - 32px);
    margin-left: auto;
    margin-right: auto;
  }
}

html.ad-on .rcd-composer:focus-within{
  border-color: color-mix(in srgb, var(--ad-navy-2) 45%, white);
  background: var(--ad-paper);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ad-blue) 12%, transparent);
}

html.ad-on .rcd-composer input{
  min-width: 0;
  height: 40px;
  padding: 0 6px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ad-ink);
  font: 400 0.95rem/1 var(--ad-sans);
  outline: none;
}

html.ad-on .rcd-composer input::placeholder{
  color: var(--ad-mute);
}

html.ad-on .rcd-composer input:disabled{
  cursor: default;
}

/* Send: the navy square with the arrow; the word stays for screen readers. */
html.ad-on .rcd-composer #rcdSendBtn{
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--ad-navy);
  color: #fff;
  font-size: 0;
  box-shadow: none;
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

html.ad-on .rcd-composer #rcdSendBtn::before{
  content: "";
  width: 19px;
  height: 19px;
  background: currentColor;
  -webkit-mask: var(--ad-i-send) center / contain no-repeat;
  mask: var(--ad-i-send) center / contain no-repeat;
}

html.ad-on .rcd-composer #rcdSendBtn:hover:not(:disabled){
  background: var(--ad-navy-2);
}

html.ad-on .rcd-composer #rcdSendBtn:disabled{
  opacity: 0.4;
  cursor: default;
}

html.ad-on .rcd-hint{
  margin: -4px 16px 14px;
  color: var(--ad-rose);
  font: 500 0.8rem/1.3 var(--ad-sans);
  text-align: center;
}

/* ---------- Handed to staff: a small dialog, centred on the chat ---------- */

html.ad-on .rcd-modal{
  padding: 24px;
  background: rgba(15, 27, 45, 0.32);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

html.ad-on .rcd-modal__card{
  gap: 20px;
  width: min(100%, 400px);
  padding: 28px 26px 22px;
  border: 1px solid var(--ad-line);
  border-radius: 22px;
  background: var(--ad-paper);
  box-shadow: 0 2px 6px rgba(15, 27, 45, 0.06), 0 40px 80px -30px rgba(15, 27, 45, 0.45);
  color: var(--ad-ink);
  animation: ad-rcd-pop 0.16s ease-out;
}

html.ad-on .rcd-modal__card p{
  margin: 0;
  font: 400 1.65rem/1.15 var(--ad-serif);
  letter-spacing: -0.01em;
}

html.ad-on .rcd-modal__card .rcd-btn--primary{
  width: 100%;
  height: 44px;
}

@keyframes ad-rcd-pop{
  from{ opacity: 0; transform: translateY(6px) scale(0.98); }
  to{ opacity: 1; transform: none; }
}

/* ---------- Phones ---------- */

@media (max-width: 640px){
  html.ad-on body.rcd{
    padding: 0;
  }

  html.ad-on .rcd-header{
    padding: 12px 16px;
  }

  html.ad-on .rcd-header h1{
    gap: 10px;
    font-size: 1.6rem;
  }

  html.ad-on .rcd-header h1::before{
    width: 36px;
    height: 36px;
  }

  html.ad-on .rcd-header h1::after{
    left: 9px;
  }

  html.ad-on .rcd-main{
    border-width: 1px 0 0;
    border-radius: 18px 18px 0 0;
  }

  html.ad-on .rcd-messages{
    padding: 18px 14px 20px;
  }

  html.ad-on .rcd-bubble{
    max-width: 86%;
  }

  html.ad-on .rcd-composer{
    margin: 10px 10px calc(10px + env(safe-area-inset-bottom, 0px));
  }

  html.ad-on .rcd-composer input{
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce){
  html.ad-on *,
  html.ad-on *::before,
  html.ad-on *::after{
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
