:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #eef2f3;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: #eef2f3;
}

body.chat-active {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

[hidden] {
  display: none !important;
}

.form-view {
  min-height: 100vh;
  background: linear-gradient(180deg, #ffffff 0, #ffffff 38%, #f4f7f8 38%);
}

.form-view h1 {
  font-size: clamp(2rem, 6vw, 3.5rem);
  line-height: 1.05;
}

.form-view input[readonly] {
  color: #536171;
  background: #f5f7f8;
}

.form-view.page-shell {
  padding-top: 96px;
}

.form-view .intro {
  padding: 0 24px 48px;
}

button,
textarea {
  font: inherit;
  letter-spacing: 0;
}

.chat-page {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(100%, 1180px);
  height: var(--chat-viewport-height, 100vh);
  min-height: 0;
  margin: 0 auto;
  overflow: hidden;
  background: #ffffff;
}

.chat-header {
  position: relative;
  z-index: 3;
  display: flex;
  min-height: 86px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px;
  border-bottom: 1px solid #dce3e6;
  background: #ffffff;
}

.eyebrow {
  margin: 0 0 4px;
  color: #21416B;
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.new-chat {
  color: #21416B;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}

.new-chat:hover {
  text-decoration: underline;
}

.new-consultation-button {
  min-height: 42px;
  border: 1px solid #21416B;
  border-radius: 6px;
  padding: 0 18px;
  background: #ffffff;
  color: #21416B;
  cursor: pointer;
  font-weight: 750;
}

.new-consultation-button:hover:not(:disabled) {
  background: #EDF3FA;
}

.display-section {
  min-height: 0;
  overflow: hidden;
  padding: 16px 20px 0;
  background: #eef2f3;
}

#chat-display {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 1px solid #cfd8dc;
  border-radius: 6px;
  background: #F5F4F0;
}

.composer-section {
  position: relative;
  z-index: 3;
  padding: 14px 20px 18px;
  border-top: 1px solid #dce3e6;
  background: #ffffff;
}

#message-form {
  display: grid;
  grid-template-columns: repeat(4, 48px) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

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

.attach-button,
.remove-file-button {
  border: 0;
  background: transparent;
  color: #536171;
  cursor: pointer;
}

.attach-button {
  display: inline-flex;
  width: 48px;
  height: 48px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  padding: 0;
  font-size: 1.45rem;
}

.attach-button:hover:not(:disabled) {
  background: #E7EEF7;
  color: #21416B;
}

#message-input {
  width: 100%;
  min-height: 48px;
  max-height: 96px;
  resize: none;
  border: 1px solid #aeb9c1;
  border-radius: 24px;
  outline: none;
  padding: 12px 18px;
  color: #172033;
  background: #ffffff;
  line-height: 1.45;
}

#message-input:focus {
  border-color: #21416B;
  box-shadow: 0 0 0 3px rgb(33 65 107 / 14%);
}

.send-button {
  display: inline-flex;
  min-width: 112px;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 24px;
  padding: 0 18px;
  background: #21416B;
  color: #ffffff;
  cursor: pointer;
  font-weight: 750;
}

.file-preview {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 10px;
  max-width: 640px;
  margin: 0 0 10px 58px;
  border: 1px solid #D3DFEE;
  border-radius: 12px;
  padding: 8px 10px;
  background: #F3F6FB;
}

.file-preview-image,
.file-preview-icon {
  width: 44px;
  height: 44px;
  border-radius: 8px;
}

.file-preview-image {
  object-fit: cover;
  background: #ffffff;
}

.file-preview-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #E3EBF5;
  font-size: 1.35rem;
}

.file-preview-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.file-preview-copy strong,
.file-preview-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-preview-copy strong {
  font-size: 0.88rem;
}

.file-preview-copy span {
  color: #65727e;
  font-size: 0.76rem;
}

.remove-file-button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  padding: 0;
  font-size: 1.55rem;
  line-height: 1;
}

.remove-file-button:hover:not(:disabled) {
  background: #DCE6F3;
  color: #172033;
}

.send-button:hover:not(:disabled) {
  background: #172F50;
}

button:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.send-status {
  color: #65727e;
  font-size: 0.82rem;
}

.send-status {
  min-height: 20px;
  margin: 8px 0 0;
}

.send-status.is-error {
  color: #b42318;
}

.send-status.is-success {
  color: #21416B;
}

@media (max-width: 640px) {
  .form-view.page-shell {
    padding-top: 56px;
  }

  .form-view .intro {
    padding: 0 8px 36px;
  }

  .chat-page {
    width: 100%;
  }

  .chat-header {
    min-height: 74px;
    padding: 14px 16px;
  }

  .new-consultation-button {
    min-height: 38px;
    padding: 0 12px;
    font-size: 0.82rem;
  }

  h1 {
    font-size: 1.1rem;
  }

  .display-section {
    padding: 0;
  }

  #chat-display {
    border: 0;
    border-radius: 0;
  }

  .composer-section {
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  }

  #message-form {
    grid-template-columns: repeat(4, 44px) minmax(0, 1fr);
    gap: 6px;
  }

  .attach-button {
    width: 44px;
    height: 44px;
  }

  .send-button {
    min-width: 50px;
    width: 50px;
    min-height: 50px;
    padding: 0;
  }

  .send-button-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
  }

  .file-preview {
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* Integrated conversation viewer: the center scrolls, header/composer remain fixed. */
#chat-display { overflow-y: auto; overscroll-behavior: contain; padding: 16px; }
.viewer-list { display: flex; flex-direction: column; gap: 10px; }
.viewer-message { width: fit-content; max-width: min(82%, 580px); padding: 12px 14px 8px; border-radius: 12px; box-shadow: 0 1px 2px #00000012; overflow-wrap: anywhere; color: #172033; }
.viewer-team { align-self: flex-start; background: #fff; border-top-left-radius: 3px; }
.viewer-client { align-self: flex-end; background: #D9FDD3; border-top-right-radius: 3px; }
.viewer-text { white-space: pre-wrap; font-size: .94rem; line-height: 1.5; }
.viewer-template-title { display: block; margin-bottom: 8px; white-space: pre-wrap; }
.viewer-buttons { display: grid; gap: 7px; margin-top: 14px; }
.viewer-reply { min-height: 44px; border: 1px solid #21416B; border-radius: 7px; background: #F0F5FC; color: #21416B; font-weight: 650; padding: 10px 16px; cursor: pointer; }
.viewer-reply:hover:not(:disabled) { background: #E0EBF8; }
.viewer-reply:focus-visible, .viewer-older:focus-visible, .viewer-retry:focus-visible { outline: 3px solid #21416B; outline-offset: 2px; }
.viewer-time { display: block; text-align: right; color: #627187; font-size: .7rem; margin-top: 6px; }
.viewer-date { align-self: center; padding: 5px 12px; background: #ffffffc9; border-radius: 12px; font-size: .74rem; color: #536171; margin: 5px 0; }
.viewer-status { text-align: center; color: #536171; font-size: .85rem; }
.viewer-status:empty { display: none; }
.viewer-older, .viewer-retry { display: block; margin: 0 auto 14px; padding: 8px 14px; border: 1px solid #BCCDE3; border-radius: 16px; background: #fff; color: #21416B; cursor: pointer; }
.viewer-image { display: block; max-width: 100%; max-height: 330px; border-radius: 7px; object-fit: contain; }
.viewer-media { display: block; max-width: 100%; width: 320px; }
.viewer-link { color: #21416B; text-decoration: underline; overflow-wrap: anywhere; }
.viewer-carousel { display: flex; gap: 10px; overflow-x: auto; max-width: 100%; }
.viewer-carousel > a { flex: 0 0 200px; }
.viewer-legacy-button { border-top: 1px solid #dce3e6; padding: 8px; margin-top: 5px; text-align: center; }
@media (max-width: 640px) {
  #chat-display { padding: 12px 10px; }
  .viewer-message { max-width: 92%; padding: 10px 12px 7px; }
}

.flow-card { min-width: min(270px, 65vw); }
.flow-card p { white-space: pre-wrap; }
.flow-status { font-size: .88rem; color: #53647C; }
.flow-dialog { box-sizing: border-box; width: min(560px, 94vw); max-height: 90dvh; border: 0; border-radius: 20px; padding: 26px; color: #17252a; background: white; overflow-y: auto; }
.flow-dialog::backdrop { background: rgb(0 0 0 / .45); }
.flow-dialog h2 { padding-right: 32px; font-size: 1.35rem; }
.flow-close { float: right; border: 0; background: transparent; font-size: 1.8rem; cursor: pointer; }
.flow-progress { color: #21416B; border-bottom: 3px solid #21416B; padding-bottom: 14px; }
.flow-field { border: 0; margin: 22px 0; padding: 0; min-width: 0; }
.flow-field legend { font-weight: 600; margin-bottom: 10px; }
.flow-field input:not([type=radio]):not([type=checkbox]), .flow-field select, .flow-field textarea { box-sizing: border-box; width: 100%; padding: 12px; border: 1px solid #99ACC5; border-radius: 8px; font: inherit; background: white; color: inherit; }
.flow-field textarea { min-height: 110px; resize: vertical; }
.flow-option { display: flex; gap: 12px; align-items: center; padding: 12px 0; cursor: pointer; }
.flow-field input[type=checkbox], .flow-field input[type=radio] { width: 20px; height: 20px; accent-color: #21416B; }
.flow-actions { display: flex; justify-content: flex-end; gap: 12px; padding-top: 16px; }
.flow-actions button { border: 0; border-radius: 10px; padding: 13px 20px; background: #21416B; color: white; font: inherit; cursor: pointer; }
.flow-dialog button:disabled { opacity: .55; cursor: wait; }
.flow-error { color: #a02929; }
.flow-image { max-width: 100%; border-radius: 8px; }
.flow-dialog form { display: block; }
.flow-dialog .flow-close { color: #17252a; min-height: 36px; width: 36px; padding: 0; }
.flow-dialog .flow-close:hover { background: #EDF3FA; }
.flow-field input[type=checkbox], .flow-field input[type=radio] { min-height: 20px; padding: 0; flex-shrink: 0; }
.flow-option { font-weight: 400; }
.flow-field input:focus-visible, .flow-field select:focus-visible, .flow-field textarea:focus-visible { outline: 2px solid #21416B; outline-offset: 2px; }

.flow-field .flow-toggle { display: flex; flex-direction: row; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; }
.flow-toggle input[type=checkbox] { flex-shrink: 0; margin: 0; }

.flow-readonly input:disabled,
.flow-readonly select:disabled,
.flow-readonly textarea:disabled {
  color: #17252a;
  background: #F3F6FA;
  opacity: 1;
  cursor: default;
}
.flow-readonly input[type=checkbox]:disabled,
.flow-readonly input[type=radio]:disabled {
  opacity: 1;
  cursor: default;
}
.flow-readonly .flow-option { cursor: default; }
.flow-readonly-title { margin: 22px 0 6px; font-size: 1.05rem; color: #21416B; }
.flow-readonly-title:first-child { margin-top: 0; }

.camera-dialog {
  box-sizing: border-box;
  width: min(560px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  overflow: auto;
  padding: 20px;
  border: 0;
  border-radius: 16px;
  color: #243746;
}
.camera-dialog::backdrop { background: rgb(0 0 0 / 60%); }
.camera-dialog h2 { margin-top: 0; }
#camera-video { display: block; width: 100%; max-height: 55vh; background: #111; border-radius: 8px; }
.camera-actions { display: flex; justify-content: flex-end; gap: 12px; }
.camera-actions button { width: auto; min-height: 44px; padding: 10px 16px; }

#file-preview-audio { width: 100%; min-width: 0; grid-column: 1 / -1; }
@media (max-width: 600px) {
  #message-form { grid-template-columns: repeat(4, 44px) minmax(0, 1fr); }
  .message-entry { grid-column: 1 / -1; }
}

/* Material Symbols and the shared blue action palette. */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}
.attach-button, .remove-file-button, .file-preview-icon { color: #21416B; }
.attach-button { border: 1px solid #D3DFEE; background: #F3F6FB; border-radius: 14px; transition: background .15s, border-color .15s; }
.attach-button:hover:not(:disabled) { background: #E0EBF8; border-color: #A9BFDD; }
.attach-button:focus-visible, .remove-file-button:focus-visible, .send-button:focus-visible {
  outline: 3px solid #91AED3; outline-offset: 3px;
}
.attach-button:disabled { opacity: .45; cursor: default; }
.send-button:hover:not(:disabled) { background: #172F50; }
.send-button .material-symbols-outlined { color: #FFFFFF; font-size: 22px; }
.camera-actions button:first-child { color: #21416B; background: #EDF3FA; }

/* Shared writing field with an inset send action. */
.message-entry { position: relative; min-width: 0; width: 100%; }
.message-entry #message-input {
  display: block; box-sizing: border-box; width: 100%; min-height: 56px;
  padding: 16px 66px 16px 18px; border-radius: 28px;
}
.message-entry #send-button {
  position: absolute; right: 6px; bottom: 6px;
  width: 44px; min-width: 44px; height: 44px; min-height: 44px;
  padding: 0; border-radius: 50%;
}
.message-entry .send-button-label {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* All attachment actions share a single inset clip control. */
#message-form { display: block; }
.message-entry #message-input { padding-right: 112px; }
#attachment-toggle {
  position: absolute; right: 54px; bottom: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; min-width: 44px; min-height: 44px;
  padding: 0; border: 0; border-radius: 50%; background: transparent;
  color: #21416B; cursor: pointer;
}
#attachment-toggle:hover:not(:disabled), #attachment-toggle[aria-expanded=true] { background: #E7EEF7; }
#attachment-toggle:focus-visible { outline: 3px solid #91AED3; outline-offset: 1px; }
#attachment-toggle:disabled { opacity: .45; cursor: default; }
.attachment-panel {
  position: absolute; bottom: calc(100% + 12px); right: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px;
  box-sizing: border-box; width: min(360px, 100%); padding: 16px 12px;
  background: #FFFFFF; border: 1px solid #D3DFEE; border-radius: 20px;
  box-shadow: 0 8px 28px rgb(33 65 107 / 15%);
}
.attachment-panel[hidden] { display: none; }
.attachment-panel .attach-button {
  flex-direction: column; gap: 8px; width: 100%; height: auto; min-height: 76px;
  padding: 10px 2px; border: 0; border-radius: 12px;
}
.attachment-label { font-size: .75rem; line-height: 1.2; font-weight: 600; }
@media (max-width: 600px) {
  .attachment-panel { width: 100%; }
}
