:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
  color: #000;
  background: #f2f2f7;
  --ios-blue: #007aff;
  --ios-gray-6: #f2f2f7;
  --ios-gray-5: #e5e5ea;
  --ios-secondary: rgba(60, 60, 67, 0.6);
  --hairline: rgba(60, 60, 67, 0.12);
  --keyboard-offset: 0px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ios-gray-6); overscroll-behavior: none; }
button, textarea { font: inherit; }
button { -webkit-user-select: none; user-select: none; touch-action: manipulation; }
[hidden] { display: none !important; }

.shell {
  width: 100%;
  height: calc(100dvh - var(--keyboard-offset));
  display: grid;
  grid-template-rows: max-content minmax(0, 1fr) max-content;
  margin: auto;
  background: #fff;
  transition: height 180ms ease-out;
}

.web-navigation {
  grid-row: 1;
  min-height: 58px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 11px;
  align-items: center;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  border-bottom: 0.5px solid rgba(60, 60, 67, 0.18);
  background: rgba(249, 249, 249, 0.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  z-index: 2;
}

body.embedded .web-navigation { display: none; }
.embedded-close { display: none; }
body.embedded .embedded-close {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: calc(16px + env(safe-area-inset-left));
  z-index: 10;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  color: #1d2226;
  background: transparent;
}
body.embedded .embedded-close:active { opacity: .48; }
.embedded-close svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.8; stroke-linecap: round; }
.navigation-copy { min-width: 0; display: grid; gap: 1px; }
.web-navigation strong { overflow: hidden; font-size: 16px; font-weight: 600; letter-spacing: -0.2px; text-overflow: ellipsis; white-space: nowrap; }
.web-navigation span { overflow: hidden; color: var(--ios-secondary); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

.agent-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #fff;
  background: #111;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
  font-size: 15px;
  font-weight: 650;
}

.agent-mark--large { width: 48px; height: 48px; margin-bottom: 5px; font-size: 18px; }
.web-navigation i { width: 9px; height: 9px; border: 2px solid #fff; border-radius: 50%; background: #34c759; box-shadow: 0 0 0 0.5px rgba(0,0,0,.08); }

.messages {
  grid-row: 2;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 10px 12px 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fff;
  scroll-behavior: smooth;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

.conversation-status { align-self: center; display: grid; place-items: center; gap: 1px; max-width: 250px; margin: 10px 0 24px; text-align: center; }
.conversation-status strong { font-size: 16px; font-weight: 600; letter-spacing: -0.2px; }
.conversation-status span { color: var(--ios-secondary); font-size: 13px; line-height: 17px; }

.message-row { display: grid; max-width: min(80%, 520px); gap: 3px; animation: message-in 220ms ease-out; }
.message-row.agent { align-self: flex-start; justify-items: start; }
.message-row.user { align-self: flex-end; justify-items: end; }
.message {
  max-width: min(80%, 520px);
  padding: 8px 12px 9px;
  border-radius: 17px;
  font-size: 17px;
  line-height: 21px;
  letter-spacing: -0.08px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.message-row .message { max-width: 100%; }
.message-row.agent .message { border-bottom-left-radius: 6px; background: #f0f0f2; color: #111; }
.message-row.user .message { border-bottom-right-radius: 6px; background: var(--ios-blue); color: #fff; }
.message-meta { display: flex; gap: 5px; align-items: center; min-height: 13px; padding: 0 4px; color: rgba(60,60,67,.42); font-size: 10px; line-height: 12px; font-variant-numeric: tabular-nums; }
.message-delivery { display: inline-flex; gap: 4px; align-items: center; color: rgba(60,60,67,.42); }
.message-delivery:empty { display: none; }
.message-delivery.failed { color: #ff3b30; }
.message-delivery.sending i { width: 8px; height: 8px; border: 1px solid rgba(60,60,67,.22); border-top-color: rgba(60,60,67,.65); border-radius: 50%; animation: message-sending 700ms linear infinite; }

.composer {
  grid-row: 3;
  position: relative;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 0.5px solid var(--hairline);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  z-index: 3;
}

.kinds { display: flex; gap: 14px; margin: 0 38px 7px; }
.kinds label { position: relative; padding: 2px 0 4px; color: rgba(60,60,67,.46); background: transparent; font-size: 13px; font-weight: 500; cursor: pointer; }
.kinds label:has(input:checked) { color: var(--ios-blue); }
.kinds label:has(input:checked)::after { position: absolute; right: 0; bottom: 0; left: 0; height: 1.5px; border-radius: 2px; background: currentColor; content: ""; }
.kinds input { display: none; }

.composer-files { display: flex; overflow-x: auto; gap: 6px; margin: 0 38px 7px; scrollbar-width: none; }
.composer-files:empty { display: none; }
.file-chip { flex: none; display: inline-flex; align-items: center; gap: 5px; max-width: 240px; padding: 5px 6px 5px 10px; border-radius: 13px; background: rgba(118,118,128,.12); font-size: 12px; }
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip button { width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; color: var(--ios-secondary); background: rgba(118,118,128,.12); font-size: 15px; }
.voice-status {
  display: grid;
  grid-template-columns: auto auto minmax(40px, 1fr) auto;
  gap: 7px;
  align-items: center;
  margin: 0 38px 8px;
  padding: 7px 10px;
  border-radius: 14px;
  color: #ff3b30;
  background: rgba(255,59,48,.07);
  font-size: 12px;
  line-height: 15px;
}
.voice-status.processing { color: var(--ios-blue); background: rgba(0,122,255,.07); }
.voice-status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: voice-dot 1.15s ease-in-out infinite; }
.voice-status strong { min-width: 32px; font-size: 13px; font-variant-numeric: tabular-nums; letter-spacing: -.2px; }
.voice-status > span:last-child { overflow: hidden; color: rgba(60,60,67,.54); text-overflow: ellipsis; white-space: nowrap; }
.voice-wave { height: 18px; display: flex; gap: 2px; align-items: center; justify-content: center; }
.voice-wave i { width: 2px; height: 5px; border-radius: 2px; background: currentColor; animation: voice-wave 840ms ease-in-out infinite alternate; }
.voice-wave i:nth-child(2), .voice-wave i:nth-child(7) { animation-delay: -700ms; }
.voice-wave i:nth-child(3), .voice-wave i:nth-child(6) { animation-delay: -560ms; }
.voice-wave i:nth-child(4), .voice-wave i:nth-child(5) { animation-delay: -420ms; }
.voice-status.processing .voice-status-dot { animation: voice-spin 900ms linear infinite; background: transparent; border: 1.5px solid currentColor; border-top-color: transparent; }
.voice-status.processing .voice-wave i { animation-duration: 1.5s; opacity: .55; }

.input-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) 32px; gap: 6px; align-items: end; }
textarea { width: 100%; min-height: 38px; max-height: 120px; resize: none; overflow-y: auto; padding: 8px 13px; border: .5px solid rgba(60,60,67,.12); border-radius: 19px; outline: none; color: #000; background: #f2f2f4; font-size: 17px; line-height: 21px; -webkit-appearance: none; transition: border-color 140ms ease, background 140ms ease; }
textarea:focus { border-color: rgba(0,122,255,.28); background: #fff; }
textarea::placeholder { color: rgba(60,60,67,.34); }

.composer button { border: 0; cursor: pointer; }
.composer-action, .send-action { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border-radius: 50%; }
.composer-action { color: var(--ios-blue); background: transparent; }
.composer-action:active { background: rgba(118,118,128,.12); }
.voice-action.recording { color: #fff; background: #ff3b30; animation: voice-button 1.25s ease-in-out infinite; }
.send-action { color: #fff; background: var(--ios-blue); box-shadow: 0 1px 4px rgba(0,122,255,.2); }
.composer svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.primary-slot { position: relative; width: 32px; height: 32px; }
.primary-slot button { position: absolute; inset: 0; }

#status { min-height: 0; margin: 4px 36px 0; color: #ff3b30; font-size: 11px; line-height: 14px; text-align: center; }
#status:empty { display: none; }

@keyframes message-in { from { opacity: 0; transform: translateY(3px) scale(.98); } }
@keyframes message-sending { to { transform: rotate(360deg); } }
@keyframes voice-dot { 50% { opacity: .35; transform: scale(.72); } }
@keyframes voice-wave { to { height: 16px; } }
@keyframes voice-spin { to { transform: rotate(360deg); } }
@keyframes voice-button { 50% { box-shadow: 0 0 0 6px rgba(255,59,48,.13); transform: scale(.96); } }
@media (min-width: 700px) { .shell { max-width: 760px; border-right: .5px solid rgba(60,60,67,.18); border-left: .5px solid rgba(60,60,67,.18); } }
@media (prefers-reduced-motion: reduce) { .shell, .message-row, .message-delivery.sending i, .voice-status-dot, .voice-wave i, .voice-action.recording { transition: none; animation: none; } }
