.chat-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px 9px 9px;
  border-radius: 24px;
  background: #303f38;
  color: #fff;
  box-shadow: 0 6px 24px #203c3022;
  border: 1px solid #61746a;
}
.chat-launcher img {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border-radius: 50%;
}
.chat-launcher span {
  display: grid;
  text-align: left;
  font-size: 14px;
}
.chat-launcher small {
  font-size: 10px;
  color: #d1dfd7;
}
.chat-dialog {
  width: min(880px, calc(100vw - 32px));
  height: min(850px, calc(100dvh - 40px));
  max-height: calc(100dvh - 40px);
  padding: 0;
  border: 1px solid #dedbd2;
  border-radius: 24px;
  background: #faf9f5;
  color: #30332e;
  box-shadow: 0 24px 80px #17282033;
}
.chat-dialog[open] {
  display: flex;
  flex-direction: column;
}
.chat-dialog::backdrop {
  background: #27382f66;
  backdrop-filter: blur(5px);
}
.chat-header {
  display: flex;
  align-items: center;
  padding: 22px 26px;
  gap: 16px;
  border-bottom: 1px solid #e5e4db;
}
.chat-header img {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  object-fit: cover;
}
.chat-header > div {
  flex: 1;
  min-width: 0;
}
.chat-header span {
  font-size: 10px;
  letter-spacing: 1.4px;
  color: #708175;
}
.chat-header h2 {
  margin: 5px 0;
  font-size: 21px;
}
.chat-header p {
  font-size: 12px;
  color: #748072;
  margin: 0;
}
.chat-header > button {
  border: 0;
  background: transparent;
}
.chat-preferences {
  padding: 10px 26px;
  border-bottom: 1px solid #e5e4db;
  font-size: 12px;
  max-height: 32%;
  overflow: auto;
}
.chat-preferences summary {
  cursor: pointer;
  color: #647769;
}
.chat-preferences label {
  display: block;
  margin-top: 10px;
}
.chat-preferences textarea,
.chat-preferences select {
  display: block;
  width: 100%;
  margin: 5px 0;
}
.chat-preferences small {
  display: block;
  margin: 8px 0;
  color: #808577;
}
.chat-messages {
  flex: 1;
  overflow: auto;
  padding: 24px 32px;
  min-height: 100px;
  overscroll-behavior: contain;
}
.chat-user {
  margin: 0 0 24px auto;
  width: fit-content;
  max-width: 85%;
  background: #e9eee6;
  border-radius: 18px 18px 3px 18px;
  padding: 14px 18px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.chat-user small,
.chat-assistant > small {
  font-size: 10px;
  letter-spacing: 1px;
  color: #7b8576;
  display: block;
  margin-bottom: 8px;
}
.chat-assistant {
  margin: 0 0 30px;
  padding: 0 4px;
  line-height: 1.85;
  overflow-wrap: anywhere;
  font-size: 14px;
}
.chat-answer {
  white-space: pre-wrap;
}
.chat-references {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}
.chat-references button {
  font-size: 12px;
  border-radius: 18px;
  background: #f0f0e9;
}
.chat-proposal {
  border: 1px solid #dce2d6;
  background: #f2f4ec;
  border-radius: 12px;
  padding: 16px;
  margin-top: 14px;
}
.chat-proposal strong {
  font-size: 13px;
}
.chat-proposal p {
  white-space: pre-wrap;
  margin: 8px 0;
}
.chat-proposal small {
  display: block;
  color: #777b6b;
  font-size: 11px;
}
.chat-proposal button {
  margin-top: 10px;
  background: #fff;
}
.chat-status {
  padding: 0 28px;
  font-size: 12px;
  color: #74816b;
  min-height: 20px;
}
.chat-status.error {
  color: #a24f43;
}
.chat-composer {
  margin: 8px 22px 20px;
  background: white;
  border: 1px solid #d9ded3;
  border-radius: 16px;
  padding: 12px;
}
.chat-composer textarea {
  width: 100%;
  min-height: 60px;
  resize: none;
  border: 0;
  background: transparent;
  padding: 4px;
  box-shadow: none;
  font: inherit;
  font-size: 14px;
}
.chat-composer > div {
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-composer .chat-storage {
  flex: 1;
  text-align: center;
  font-size: 10px;
  color: #8a8c81;
}
.chat-composer small {
  display: block;
  margin: 8px 3px 0;
  color: #8a8c81;
  font-size: 10px;
}
.chat-welcome {
  padding: 30px 10px;
  color: #74816b;
}
.chat-welcome span {
  font-size: 11px;
  letter-spacing: 1px;
}
.chat-welcome h3 {
  font-size: 22px;
  color: #354d3c;
  margin: 12px 0;
}
.chat-welcome p {
  font-size: 13px;
  line-height: 1.8;
}
.chat-welcome button {
  font-size: 12px;
  margin: 12px 8px 0 0;
}
.cloud-orders {
  margin-top: 24px;
  border-top: 1px solid #ddd;
  padding-top: 18px;
}
.cloud-order {
  display: block;
  text-align: left;
  width: 100%;
  margin: 8px 0;
  padding: 14px;
  border: 1px solid #e1e1d7;
  background: #f7f8f0;
  border-radius: 12px;
}
.cloud-order small {
  display: block;
  margin-top: 5px;
  color: #818477;
}
.cloud-orders input {
  width: 100%;
  margin: 8px 0;
}
.company-rules textarea {
  width: 100%;
  min-height: 130px;
  margin: 12px 0;
}
.cloud-note {
  font-size: 12px;
  color: #818477;
}
.chat-main-entry {
  margin-bottom: 20px;
  padding: 22px;
  background: #eef1e7;
  border: 1px solid #dde3d4;
  border-radius: 18px;
}
.chat-main-entry p {
  font-size: 13px;
  color: #6c7767;
  margin: 8px 0 14px;
}
@media (max-width: 600px) {
  .chat-dialog {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    max-width: 100vw;
    border-radius: 0;
    border: 0;
  }
  .chat-header {
    padding: 16px;
  }
  .chat-header h2 {
    font-size: 18px;
  }
  .chat-header img {
    width: 44px;
    height: 44px;
  }
  .chat-messages {
    padding: 18px;
  }
  .chat-composer {
    margin: 8px 12px 12px;
  }
  .chat-composer .chat-storage {
    display: none;
  }
  .chat-composer > div {
    justify-content: space-between;
  }
  .chat-launcher {
    right: 16px;
    bottom: max(16px, env(safe-area-inset-bottom));
  }
  .chat-preferences {
    padding: 10px 18px;
  }
  .chat-welcome {
    padding: 18px 0;
  }
  .chat-user {
    max-width: 94%;
  }
}
.chat-dialog p { text-align: left; }
.chat-dialog .chat-header p { text-align: left; }

/* The Sculpy route is the conversation itself, not a launcher for a dialog. */
body.sculpy-chat-page .shell > footer { display: none; }
body.sculpy-chat-page #main { padding: 0 24px; }
body.sculpy-chat-page .tour-banner { margin: 12px 0; }
.chat-inline .chat-launcher, .chat-inline [data-close] { display: none; }
.chat-inline .chat-dialog {
  position: static;
  width: 100%; max-width: 1040px;
  height: calc(100dvh - 90px); max-height: none;
  margin: 0 auto; border: 0; border-radius: 0;
  background: transparent; box-shadow: none;
}
.chat-inline .chat-header { padding: 18px 16px 10px; border: 0; }
.chat-inline .chat-header img { width: 40px; height: 40px; margin: 0; }
.chat-inline .chat-header span { display: none; }
.chat-inline .chat-header h2 { font-family: var(--serif); font-size: 28px; font-weight: 400; }
.chat-inline .chat-header p { text-align: left; }
.chat-inline .chat-preferences { border: 0; padding: 0 16px 10px; }
.chat-inline .chat-messages { padding: 24px clamp(12px, 4vw, 64px); }
.chat-inline .chat-assistant { font-size: 16px; line-height: 1.9; }
.chat-inline .chat-welcome { text-align: center; padding: clamp(20px, 6vh, 70px) 8px; }
.chat-welcome-avatar { width: 84px; height: 84px; object-fit: cover; border-radius: 50%; margin: 0 auto 24px; display: block; }
.chat-inline .chat-welcome h3 { font-size: clamp(23px, 3vw, 32px); font-weight: 400; }
.chat-inline .chat-welcome p { text-align: center; }
.chat-inline .chat-welcome button { border-radius: 20px; }
.chat-inline .chat-composer { width: calc(100% - 32px); max-width: 850px; margin: 8px auto 16px; border-radius: 22px; padding: 16px; box-shadow: 0 4px 22px #263c3008; }
.chat-inline .chat-composer textarea { font-size: 16px; min-height: 58px; max-height: 160px; }
.chat-inline .chat-composer button { border-radius: 12px; }
.chat-inline .chat-status { max-width: 850px; width: 100%; margin: 0 auto; }
.chat-inline .chat-answer, .chat-inline .chat-proposal p { text-align: left; }
.chat-thinking { color: #74816b; }
.chat-inline .chat-preferences[open] { background: #eef0e8; border-radius: 14px; flex-shrink: 0; }
@media(max-width:850px) {
  body.sculpy-chat-page #main { padding: 0 8px; }
  .chat-inline .chat-dialog { height: calc(100dvh - 70px); }
  .chat-inline .chat-header { padding: 8px 12px; }
  .chat-inline .chat-header h2 { font-size: 24px; }
  .chat-inline .chat-messages { padding: 16px 12px; }
  .chat-inline .chat-composer { width: calc(100% - 8px); margin-bottom: max(8px, env(safe-area-inset-bottom)); padding: 12px; }
  .chat-inline .chat-composer .chat-storage { font-size: 9px; }
  .chat-inline .chat-welcome { padding: 16px 4px; }
  .chat-inline .chat-welcome-avatar { width: 64px; height: 64px; margin-bottom: 12px; }
}
body.sculpy-chat-page #main.sculpy-reveal { animation: none; }
.chat-inline .chat-dialog p { text-align: left; }
.chat-inline .chat-welcome p { text-align: center; }
.chat-header img, .chat-launcher img, .chat-welcome-avatar { object-position: 90% center; }
.chat-inline .chat-composer textarea:focus-visible { outline: none; }
.chat-inline .chat-composer:focus-within { border-color: #8eaa99; box-shadow: 0 0 0 3px #dfe8dd77; }
