:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #241c1d;
  background: #faf7f6;
  --accent: #8d152a;
  --accent-hover: #741224;
  --soft: #f8e9eb;
  --border: #deced0;
  --muted: #635356;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
a { color: var(--accent); }
button, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .66; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.page {
  width: min(100%, 54rem);
  margin-inline: auto;
  padding: 1.5rem clamp(1rem, 5vw, 3rem) 1.5rem;
}

.brand { display: flex; align-items: center; gap: .64rem; font-size: 1.1rem; font-weight: 730; }
.brand img { border-radius: .4rem; }

.chat {
  margin-top: 1.1rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 1.15rem;
  background: white;
  box-shadow: 0 .65rem 2rem #3d192011;
}

.chat-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .7rem 1rem;
  padding: 1rem clamp(.9rem, 4vw, 1.5rem);
  border-bottom: 1px solid var(--border);
}

.eyebrow { margin: 0 0 .15rem; color: var(--accent); font-size: .88rem; font-weight: 650; }
h1 { margin: 0; font-size: clamp(1.45rem, 5vw, 2rem); line-height: 1.15; }
.address { margin: .35rem 0 0; color: var(--muted); line-height: 1.4; }

.call, .jump, .send {
  min-height: 44px;
  padding: .57rem .86rem;
  border: 1px solid var(--border);
  border-radius: .66rem;
  font-weight: 650;
  line-height: 1.2;
}

.call { display: inline-flex; align-items: center; background: var(--soft); text-decoration: none; }
.call:hover, .jump:hover { background: #f3d9dd; }

.timeline { position: relative; background: #faf7f6; }
.log {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  block-size: clamp(14rem, 54vh, 36rem);
  block-size: clamp(14rem, 54dvh, 36rem);
  padding: 1rem clamp(.85rem, 4vw, 1.5rem);
  overflow-y: auto;
}
.log:focus-visible { outline-offset: -4px; }

.empty { display: grid; place-items: center; margin: auto; text-align: center; color: var(--muted); }
.empty p { max-inline-size: 21rem; margin: 0; line-height: 1.5; }

.message {
  max-inline-size: min(91%, 35rem);
  flex: none;
  align-self: flex-start;
  padding: .58rem .8rem;
  border: 1px solid var(--border);
  border-radius: .9rem .9rem .9rem .25rem;
  background: white;
}
.message.guest { align-self: flex-end; border-radius: .9rem .9rem .25rem .9rem; background: var(--soft); }
.message-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .6rem; color: var(--muted); font-size: .77rem; }
.message-by { font-weight: 700; }
.message p { margin: .28rem 0 0; line-height: 1.45; overflow-wrap: anywhere; white-space: pre-wrap; }

.jump { position: absolute; inset-inline-end: 1rem; inset-block-end: .75rem; background: white; color: var(--accent); font-size: .83rem; }

.composer { padding: .85rem clamp(.9rem, 4vw, 1.5rem); border-top: 1px solid var(--border); }
.composer form { display: flex; align-items: flex-end; gap: .55rem; }
.composer textarea {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  max-height: 14rem;
  padding: .56rem .65rem;
  border: 1px solid var(--border);
  border-radius: .66rem;
  color: inherit;
  font-size: 1rem;
  line-height: 1.35;
  resize: vertical;
}
.composer textarea::placeholder { color: var(--muted); }
.send { color: white; background: var(--accent); border-color: transparent; }
.send:disabled { cursor: default; }
.composer form[aria-busy="true"] .send { cursor: wait; }
.send:hover:enabled { background: var(--accent-hover); }
.status, .connection, .error, .composer noscript p { margin: 0 0 .55rem; line-height: 1.4; font-size: .9rem; overflow-wrap: anywhere; }
.status, .connection, .composer noscript p { color: var(--muted); }
.error { color: var(--accent-hover); }

.branches { margin-block-start: .75rem; color: var(--muted); }
.branches summary { display: list-item; inline-size: fit-content; min-height: 44px; padding: .66rem .1rem; cursor: pointer; }
.branches ul { display: flex; flex-wrap: wrap; gap: .2rem .9rem; margin: 0; padding: 0; list-style: none; }
.branches a { display: inline-flex; align-items: center; min-height: 44px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 34rem) {
  .page { padding: .75rem .65rem; }
  .chat { margin-top: .7rem; border-radius: .85rem; }
  .chat-header { align-items: flex-start; }
  .log { block-size: clamp(13rem, 48vh, 27rem); block-size: clamp(13rem, 48dvh, 27rem); }
}

.embedded .page { width: 100%; height: 100vh; height: 100dvh; padding: 0; }
.embedded .chat {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.embedded .chat-header, .embedded .composer { padding: .65rem .8rem; }
.embedded .chat-header { gap: .4rem .65rem; }
.embedded h1 { font-size: 1.12rem; }
.embedded .address { margin-block-start: .2rem; font-size: .8rem; }
.embedded .eyebrow { display: none; }
.embedded .call { padding: .35rem .52rem; font-size: .82rem; }
.embedded .log { block-size: 100%; padding: .75rem .8rem; }
.embedded .composer textarea { max-height: min(32vh, 8rem); }

@media (max-height: 14rem) {
  .embedded .chat-header { display: none; }
}
