.chat-shell { height: 100%; display: grid; grid-template-columns: 252px minmax(0, 1fr); border: 1px solid var(--line); border-radius: 26px; overflow: hidden; background: var(--bg); position: relative; }
.chat-sidebar { display: flex; flex-direction: column; min-width: 0; padding: 25px 17px 20px; background: var(--panel); border-right: 1px solid rgb(var(--contrast-rgb) / 3%); z-index: 5; }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; min-height: 32px; padding: 0 8px; }
.sidebar-title { font-size: 13px; font-weight: 500; }
.sidebar-close, .sidebar-toggle { display: none !important; }
.sidebar-content { flex: 1; min-height: 0; padding-top: 24px; overflow-y: auto; }
.sidebar-footer { margin-top: auto; padding: 18px 12px 0; border-top: 1px solid var(--line); color: var(--muted); }
.sidebar-brand { display: inline-block; margin-bottom: 12px; }
.sidebar-brand img { width: 90px; max-height: 30px; object-fit: contain; object-position: left; }
.sidebar-footer > span { display: block; font-size: 10px; }
.chat-workspace { min-width: 0; min-height: 0; display: flex; flex-direction: column; position: relative; isolation: isolate; background: radial-gradient(ellipse at 105% -8%, rgb(0 117 213 / 15%), transparent 43%), radial-gradient(ellipse at 2% 109%, rgb(0 117 213 / 8%), transparent 35%); }
.chat-header { height: 76px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 28px; position: relative; z-index: 4; }
.chat-heading, .chat-actions, .chat-language-options { display: flex; align-items: center; }
.chat-heading { gap: 9px; }
.chat-agent__icon { display: block; width: 112px; height: 112px; margin: 0 auto; object-fit: contain; }
.chat-agent__photo { width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%; object-fit: cover; }
.chat-agent__name { font-size: 15px; font-weight: 600; letter-spacing: -.4px; }
.chat-actions { gap: 12px; }
.chat-language-options { gap: 2px; }
.chat-language-option { border: none; background: transparent; color: var(--muted); width: 32px; height: 32px; border-radius: 9px; font-size: 10px; font-weight: 500; }
.chat-language-option:hover { color: var(--ink); background: rgb(var(--contrast-rgb) / 5%); }
.chat-language-option[aria-pressed="true"] { color: var(--blue-light); background: rgb(0 117 213 / 13%); }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 8px; border: 1px solid transparent; border-radius: 50%; background: transparent; color: var(--muted); flex-shrink: 0; }
.icon-button:hover { color: var(--ink); background: rgb(var(--contrast-rgb) / 7%); }
.chat-options { position: relative; }
.chat-options summary { list-style: none; }
.chat-options summary::-webkit-details-marker { display: none; }
.chat-options[open] summary { background: rgb(var(--contrast-rgb) / 7%); color: var(--ink); }
.chat-menu { position: absolute; right: 0; top: 45px; padding: 7px; min-width: 195px; border: 1px solid var(--line); background: var(--menu); border-radius: 14px; box-shadow: 0 16px 40px rgb(0 0 0 / 45%); }
.chat-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 10px; text-align: left; border: none; border-radius: 8px; background: transparent; font-size: 12px; }
.chat-menu button:hover { background: rgb(var(--contrast-rgb) / 7%); }
.chat-menu [data-action="theme"] { min-height: 44px; justify-content: space-between; }
.chat-menu [data-action="theme"]::after { content: ""; width: 16px; height: 16px; border: 1px solid var(--muted); border-radius: 4px; }
.chat-menu [data-action="theme"][aria-pressed="true"]::after { background: var(--blue-light); box-shadow: inset 0 0 0 3px var(--menu); }
.chat-menu svg { width: 17px; }
.chat-stage { min-height: 0; flex: 1; display: flex; flex-direction: column; padding: 12px 36px 35px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--scrollbar) transparent; }
.chat-shell[data-state="welcome"] .chat-stage { justify-content: center; }
.chat-welcome { flex-shrink: 0; text-align: center; padding: 0 12px 29px; }
.chat-welcome h1 { margin: 24px 0 13px; font-size: clamp(26px, 2.7vw, 34px); line-height: 1.25; font-weight: 600; letter-spacing: -1.25px; background: linear-gradient(110deg, var(--blue-light) 12%, var(--ink) 78%); color: var(--ink); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.chat-welcome p { max-width: 540px; margin: 0 auto; color: var(--muted); font-size: 12px; line-height: 1.9; }
.sophia-orb { width: 112px; height: 112px; margin: 0 auto; position: relative; border-radius: 50%; background: radial-gradient(circle at 47% 53%, var(--orb-core) 28%, rgb(0 117 213 / 38%) 56%, transparent 69%); filter: drop-shadow(0 0 21px rgb(0 117 213 / 20%)); }
.sophia-orb::before, .sophia-orb::after { content: ""; position: absolute; border-radius: 50%; }
.sophia-orb::before { inset: 5px; border: 1px solid rgb(var(--accent-rgb) / 48%); box-shadow: inset 1px 0 8px rgb(0 117 213 / 50%), 0 0 10px rgb(0 117 213 / 15%); transform: rotate(-24deg) scaleX(.92); }
.sophia-orb::after { inset: 14px; background: conic-gradient(from 24deg, transparent 2%, rgb(var(--accent-rgb) / 80%) 10%, rgb(0 117 213 / 12%) 20%, transparent 27%, rgb(0 117 213 / 65%) 44%, var(--blue-light) 48%, transparent 56%, rgb(0 117 213 / 55%) 77%, transparent 95%); mask-image: radial-gradient(ellipse, transparent 47%, #000 58%, transparent 72%); transform: rotate(-25deg); animation: orb-turn 22s linear infinite; }
.sophia-orb span { position: absolute; inset: 19px; border-radius: 39% 61% 53% 47%; border: 1px solid rgb(var(--accent-rgb) / 55%); box-shadow: 1px 2px 6px rgb(0 117 213 / 65%), inset -1px -1px 7px rgb(0 117 213 / 50%); transform: rotate(30deg) scaleX(.82); }
.sophia-orb span:nth-child(2) { inset: 22px; transform: rotate(105deg) scaleX(.83); border-color: rgb(0 117 213 / 90%); }
.sophia-orb span:nth-child(3) { inset: 15px; transform: rotate(159deg) scaleX(.77); opacity: .5; }
.sophia-orb span:nth-child(4) { inset: 31px; transform: rotate(-24deg) scaleX(.94); filter: blur(2px); border-color: var(--blue-light); }
@keyframes orb-turn { to { transform: rotate(335deg); } }
.chat-composer { flex-shrink: 0; width: min(100%, 720px); align-self: center; padding: 17px 18px 12px; margin: 0; border-radius: 25px; border: 1px solid rgb(var(--contrast-rgb) / 10%); background: var(--composer); box-shadow: 0 6px 24px rgb(0 0 0 / 15%); }
.chat-composer:focus-within { border-color: rgb(var(--accent-rgb) / 50%); }
.chat-composer__input { width: 100%; display: block; min-height: 54px; max-height: 140px; resize: none; padding: 2px 4px 8px; border: none; border-radius: 0; background: transparent; color: var(--ink); outline: none; font-size: 13px; line-height: 1.65; overflow-y: auto; scrollbar-width: thin; }
.chat-composer__input::placeholder { color: var(--placeholder); opacity: 1; }
.composer-toolbar, .composer-tools { display: flex; align-items: center; gap: 9px; }
.composer-toolbar { justify-content: space-between; min-height: 38px; }
.composer-tools { min-width: 0; gap: 4px; }
.chat-attach { border-color: var(--line); }
.chat-voice.is-listening { color: var(--blue-light); background: rgb(0 117 213 / 17%); border-color: rgb(var(--accent-rgb) / 40%); }
.voice-status { font-size: 10px; color: var(--blue-light); margin-left: 5px; }
.chat-send, .chat-stop { flex-shrink: 0; width: 37px; height: 37px; display: grid; place-items: center; padding: 8px; border: 1px solid rgb(var(--accent-rgb) / 15%); border-radius: 50%; background: var(--brand-blue); color: white; transition: background .15s; }
.chat-send:disabled { opacity: .45; }
.chat-send:not(:disabled):hover, .chat-stop:hover { background: var(--brand-hover); }
.composer-notice { color: var(--blue-light); font-size: 12px; margin: 10px 4px 1px; overflow-wrap: anywhere; }
.file-input { display: none; }
.file-preview { display: flex; flex-wrap: wrap; gap: 6px; max-height: 116px; overflow-y: auto; scrollbar-width: thin; }
.file-preview:not(:empty) { margin-bottom: 10px; }
.file-chip { max-width: 100%; display: inline-flex; align-items: center; gap: 5px; padding: 5px 6px 5px 10px; background: var(--chip); border: 1px solid var(--line); border-radius: 10px; font-size: 11px; }
.file-chip__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip__remove { flex-shrink: 0; width: 26px; height: 26px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 18px; }
.file-chip__remove:hover { color: var(--ink); background: rgb(var(--contrast-rgb) / 8%); }
.suggestions { width: 100%; }
.quick-replies { display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; padding-bottom: 20px; }
.quick-reply { min-height: 72px; width: 100%; overflow-wrap: anywhere; display: flex; gap: 11px; align-items: center; padding: 14px 13px; text-align: left; border: 1px solid rgb(var(--contrast-rgb) / 6%); border-radius: 16px; background: var(--suggestion); color: var(--suggestion-ink); font-size: 11px; line-height: 1.7; font-weight: 400; transition: border-color .15s, background .15s; }
.quick-reply::before { content: ""; flex-shrink: 0; width: 31px; height: 34px; border-radius: 50%; background: rgb(0 117 213 / 12%) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2375c7ff' stroke-width='1.5'%3E%3Cpath d='m12 4 2.4 5.6L20 12l-5.6 2.4L12 20l-2.4-5.6L4 12l5.6-2.4z'/%3E%3C/svg%3E") center/17px no-repeat; }
.quick-reply:nth-child(2)::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2375c7ff' stroke-width='1.5'%3E%3Cpath d='m12 4 8 4-8 4-8-4zM4 12l8 4 8-4M4 16l8 4 8-4'/%3E%3C/svg%3E"); }
.quick-reply:nth-child(3)::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2375c7ff' stroke-width='1.5'%3E%3Crect x='4' y='6' width='16' height='14' rx='2'/%3E%3Cpath d='M8 3v6m8-6v6M4 11h16'/%3E%3C/svg%3E"); }
.quick-reply:hover:not(:disabled) { border-color: rgb(var(--accent-rgb) / 35%); background: rgb(0 117 213 / 8%); }
.quick-reply:disabled { opacity: .45; cursor: wait; }
.chat-body { display: none; width: min(100%, 780px); align-self: center; flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: var(--scrollbar) transparent; padding: 14px 22px 25px; }
.chat-shell[data-state="conversation"] .chat-body { display: block; }
.chat-shell[data-state="conversation"] .chat-stage { overflow: hidden; padding-top: 0; }
.chat-message-row { display: flex; gap: 12px; margin: 0 0 24px; align-items: flex-start; }
.chat-message-row-user { justify-content: flex-end; }
.chat-message { min-width: 0; max-width: 100%; line-height: 1.9; font-size: 14px; }
.chat-message-user { max-width: 85%; border: 1px solid var(--line); border-radius: 19px 19px 5px 19px; padding: 11px 17px; background: var(--user-message); }
.chat-message-sophia { flex: 1; padding: 0; }
.chat-message__author { display: block; font-size: 12px; font-weight: 600; margin-bottom: 9px; }
.chat-message__text { display: block; overflow-wrap: anywhere; white-space: pre-wrap; }
.chat-message__text > :first-child { margin-top: 0; }
.chat-message__text p, .chat-message__text ul, .chat-message__text ol { margin-bottom: 12px; }
.chat-message__text ul, .chat-message__text ol { padding-left: 22px; }
.chat-message__text h1, .chat-message__text h2, .chat-message__text h3, .chat-message__text h4 { font-size: 17px; line-height: 1.6; font-weight: 600; margin: 18px 0 9px; }
.chat-message__text a { color: var(--blue-light); text-decoration: underline; text-underline-offset: 3px; }
.chat-message__text img { max-width: 100%; height: auto; border-radius: 10px; }
.chat-message__text table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; white-space: normal; margin: 12px 0; }
.chat-message__text th, .chat-message__text td { padding: 8px 12px; border: 1px solid var(--table-line); min-width: 100px; }
.chat-message__text pre { max-width: 100%; overflow-x: auto; background: var(--code); padding: 14px; border-radius: 10px; white-space: pre; }
.chat-message__text blockquote { border-left: 2px solid var(--brand-blue); padding-left: 14px; color: var(--muted); }
.chat-message__time { display: block; font-size: 10px; color: var(--muted); margin-top: 7px; }
.chat-message-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chat-message-attachment { max-width: 100%; overflow-wrap: anywhere; border: 1px solid var(--line); background: rgb(var(--contrast-rgb) / 4%); padding: 4px 9px; border-radius: 8px; font-size: 11px; }
.typing-row { display: flex; align-items: center; gap: 12px; margin: 6px 0 20px; }
.typing { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 11px; }
.typing__dots { display: flex; gap: 4px; }
.typing__dots span { width: 4px; height: 4px; border-radius: 50%; background: var(--blue-light); animation: typing-pulse 1.2s infinite alternate; }
.typing__dots span:nth-child(2) { animation-delay: .2s; }
.typing__dots span:nth-child(3) { animation-delay: .4s; }
@keyframes typing-pulse { to { opacity: .3; transform: translateY(-3px); } }
.chat-closed { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 18px; padding: 24px; }
.chat-closed h2 { font-size: 25px; margin: 0; }
.chat-closed p { color: var(--muted); }
.chat-closed__button { border: 1px solid rgb(117 199 255 / 30%); border-radius: 22px; background: var(--brand-blue); padding: 11px 20px; font-size: 13px; }
/* Keep white brand artwork intact on a dark backing, never recolor customer logos. */
:root[data-theme="light"] .sidebar-brand { background: #111; border-radius: 6px; padding: 8px; }
:root[data-theme="light"] .chat-agent__icon { background: #111; border-radius: 14px; padding: 8px; }
:root[data-theme="light"] .chat-closed__button { color: white; }
:root[data-theme="light"] .chat-message__text code { color: #8c2458; }
:root[data-theme="light"] .quick-reply::before { filter: brightness(.48); }
@media (min-width: 701px) and (max-height: 700px) {
  .chat-stage { padding-bottom: 18px; }
  .chat-welcome { padding-bottom: 19px; }
  .sophia-orb, .chat-agent__icon { width: 80px; height: 80px; }
  .chat-welcome h1 { margin-top: 15px; }
}
@media (max-width: 1050px) {
  .chat-shell { grid-template-columns: 220px minmax(0,1fr); }
  .chat-stage { padding-left: 24px; padding-right: 24px; }
  .quick-reply { padding: 12px 10px; gap: 7px; font-size: 10px; }
  .quick-reply::before { width: 23px; height: 29px; }
}
@media (max-width: 700px) {
  .chat-shell { display: block; border: none; border-radius: 0; }
  .chat-workspace { height: 100%; }
  .chat-header { height: 65px; padding: 0 14px; }
  .chat-heading { gap: 6px; }
  .chat-actions { gap: 3px; }
  .sidebar-toggle, .sidebar-close { display: inline-flex !important; }
  .chat-sidebar { position: absolute; inset: 0 auto 0 0; width: min(285px, calc(100% - 48px)); visibility: hidden; transform: translateX(-100%); transition: transform .2s, visibility .2s; border-right: 1px solid var(--line); }
  .chat-shell.is-sidebar-open .chat-sidebar { transform: none; visibility: visible; }
  .sidebar-backdrop { position: absolute; inset: 0; z-index: 4; background: rgb(0 0 0 / 65%); }
  .chat-stage { padding: 8px 18px max(20px, env(safe-area-inset-bottom)); }
  .chat-shell[data-state="welcome"] .chat-stage { justify-content: flex-start; }
  .chat-welcome { margin-top: auto; padding: 20px 5px 25px; }
  .sophia-orb, .chat-agent__icon { width: 92px; height: 92px; }
  .chat-welcome h1 { margin-top: 20px; font-size: 27px; letter-spacing: -1px; }
  .chat-welcome p { font-size: 11px; line-height: 1.85; }
  .chat-composer { padding: 14px 12px 10px; border-radius: 22px; }
  .chat-composer__input { font-size: 16px; min-height: 56px; }
  .quick-replies { grid-template-columns: 1fr; gap: 7px; }
  .quick-reply { min-height: 57px; padding: 10px 15px; border-radius: 18px; font-size: 11px; gap: 12px; }
  .quick-reply::before { width: 30px; height: 30px; }
  .chat-body { padding: 10px 3px 18px; }
  .chat-message { font-size: 13px; }
  .chat-message-row { gap: 8px; }
  .chat-message-user { max-width: 91%; padding: 10px 13px; }
}
@media (max-width: 700px) and (max-height: 580px) {
  .file-preview { max-height: 78px; }
  .chat-composer__input { max-height: 80px; }
  .chat-welcome { margin-top: 0; padding-top: 2px; }
  .chat-welcome .sophia-orb { display: none; }
  .chat-welcome h1 { margin-top: 10px; font-size: 23px; }
}

/* The opt-in WebView uses the host viewport directly without changing the full-page chat. */
body.compact-embed .app {
  width: 100%; height: 100dvh; margin: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
body.compact-embed .chat-shell { display: block; border: 0; border-radius: 0; }
body.compact-embed .chat-workspace { height: 100%; }
body.compact-embed .chat-sidebar { padding: 14px 12px; }
body.compact-embed .sidebar-toggle,
body.compact-embed .sidebar-close { display: inline-flex !important; }
body.compact-embed .chat-sidebar {
  position: absolute; inset: 0 auto 0 0; width: min(285px, calc(100% - 48px));
  visibility: hidden; transform: translateX(-100%);
  transition: transform .2s, visibility .2s; border-right: 1px solid var(--line);
}
body.compact-embed .chat-shell.is-sidebar-open .chat-sidebar { transform: none; visibility: visible; }
body.compact-embed .sidebar-backdrop { position: absolute; inset: 0; z-index: 4; background: rgb(0 0 0 / 65%); }
body.compact-embed .chat-header { height: 58px; padding: 0 12px; }
body.compact-embed .chat-stage { padding: 6px 12px max(8px, env(safe-area-inset-bottom)); }
body.compact-embed .chat-welcome { padding: 0 8px 12px; }
body.compact-embed .chat-welcome h1 { margin: 9px 0 6px; font-size: clamp(23px, 2.7vw, 30px); }
body.compact-embed .chat-welcome p { line-height: 1.55; }
body.compact-embed .sophia-orb { width: 64px; height: 64px; }
body.compact-embed .chat-composer { width: min(100%, 720px); padding: 8px 12px; border-radius: 18px; }
body.compact-embed .chat-composer__input { min-height: 44px; max-height: 100px; }
body.compact-embed .composer-toolbar { min-height: 44px; }
body.compact-embed .icon-button,
body.compact-embed .chat-language-option,
body.compact-embed .chat-send,
body.compact-embed .chat-stop { min-width: 44px; min-height: 44px; }
body.compact-embed .chat-language-option { width: 44px; }
body.compact-embed .composer-notice { margin: 6px 4px 0; }
body.compact-embed .chat-message-row { margin-bottom: 14px; }
body.compact-embed[data-spectra-prompts="true"] .quick-replies { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px; padding-bottom: 12px; }
body.compact-embed[data-spectra-prompts="true"] .quick-reply {
  min-height: 44px; width: auto; max-width: 100%; overflow-wrap: anywhere;
  justify-content: center; gap: 0; padding: 9px 12px; border-radius: 999px;
  font-size: 13px; line-height: 1.35; text-align: center;
}
body.compact-embed[data-spectra-prompts="true"] .quick-reply::before { display: none; content: none; }
@media (max-width: 700px) {
  body.compact-embed .chat-header { height: 56px; padding: 0 8px; }
  body.compact-embed .chat-heading { gap: 4px; }
  body.compact-embed .chat-actions { gap: 0; }
  body.compact-embed .chat-stage { padding: 4px 10px max(8px, env(safe-area-inset-bottom)); }
  body.compact-embed .chat-welcome { margin-top: auto; padding: 8px 4px 10px; }
  body.compact-embed .sophia-orb { width: 52px; height: 52px; }
  body.compact-embed .chat-composer { padding: 6px 10px; }
  body.compact-embed .chat-composer__input { min-height: 44px; }
}
@media (max-width: 700px) and (max-height: 500px) {
  body.compact-embed .chat-welcome { margin-top: 0; padding-top: 2px; }
  body.compact-embed .sophia-orb { display: none; }
}
