#homecare-ai-chat-root {
  --hc-blue: #008bfe;
  --hc-blue-dark: #1f42a6;
  --hc-blue-soft: #e6f4ff;
  --hc-blue-surface: #cbe7ff;
  --hc-border: #e8eaef;
  --hc-text: #232c44;
  --hc-muted: #656f82;
  --hc-danger: #ca0020;
  --hc-danger-soft: #fff0f2;
  --hc-success: #21a36e;
  --hc-surface: #ffffff;
  --hc-background: #f9fafb;
  --hc-shadow: 0 20px 60px rgb(35 44 68 / 18%), 0 4px 16px rgb(35 44 68 / 10%);
}

#homecare-ai-chat-root {
  box-sizing: border-box;
  color: var(--hc-text);
  font-family: Roboto, Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

#homecare-ai-chat-root *,
#homecare-ai-chat-root *::before,
#homecare-ai-chat-root *::after { box-sizing: border-box; }

#homecare-ai-chat-root .hc-chat-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9998;
  display: inline-flex;
  min-height: 56px;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 17px;
  padding: 10px 18px 10px 12px;
  color: #fff;
  background: var(--hc-blue);
  box-shadow: 0 10px 30px rgb(0 139 254 / 32%);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

#homecare-ai-chat-root .hc-chat-launcher svg {
  width: 30px;
  height: 30px;
  padding: 4px;
  border-radius: 10px;
  background: rgb(255 255 255 / 18%);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#homecare-ai-chat-root .hc-chat-launcher:hover { background: #007ce3; box-shadow: 0 12px 36px rgb(0 139 254 / 40%); transform: translateY(-2px); }
#homecare-ai-chat-root .hc-chat-launcher:active { transform: translateY(0); }

.hc-chat-dialog {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;
  width: min(410px, calc(100vw - 32px));
  height: min(700px, calc(100dvh - 48px));
  overflow: hidden;
  border: 1px solid var(--hc-border);
  border-radius: 24px;
  color: var(--hc-text);
  background: var(--hc-surface);
  box-shadow: var(--hc-shadow);
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  transform-origin: right bottom;
}

.hc-chat-dialog:not([hidden]) { display: grid; animation: hc-chat-enter 180ms ease-out; }

.hc-chat-dialog--consent { grid-template-rows: auto minmax(0, 1fr); }
.hc-chat-dialog--consent .hc-chat-messages,
.hc-chat-dialog--consent .hc-chat-composer,
.hc-chat-dialog--consent .hc-chat-status { display: none; }
.hc-chat-dialog--consent .hc-chat-controls-panel {
  display: grid;
  max-height: none;
  align-items: center;
}
#homecare-ai-chat-root .hc-chat-dialog--consent .hc-chat-controls-toggle { display: none; }
.hc-chat-dialog--consent .hc-chat-controls {
  display: grid;
  max-height: none;
  align-items: center;
  padding: 20px;
}

@keyframes hc-chat-enter {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes hc-chat-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.hc-chat-header {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--hc-border);
  background: #fff;
}

.hc-chat-identity { display: flex; min-width: 0; align-items: center; gap: 11px; }
.hc-chat-heading { min-width: 0; }

.hc-chat-mark {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 14px;
  color: var(--hc-blue);
  background: var(--hc-blue-soft);
}

.hc-chat-mark svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hc-chat-header h2 {
  overflow: hidden;
  margin: 0;
  color: var(--hc-text);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hc-chat-presence { display: flex; align-items: center; gap: 6px; margin: 3px 0 0; color: var(--hc-muted); font-size: 12px; }
.hc-chat-presence-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--hc-success); box-shadow: 0 0 0 3px rgb(33 163 110 / 12%); }

#homecare-ai-chat-root .hc-chat-close {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 12px;
  padding: 0;
  color: var(--hc-text);
  background: var(--hc-background);
  cursor: pointer;
}

#homecare-ai-chat-root .hc-chat-close:hover { color: var(--hc-blue-dark); background: var(--hc-blue-soft); }
#homecare-ai-chat-root .hc-chat-close svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.hc-chat-messages {
  overflow-y: auto;
  padding: 18px 16px 8px;
  background: var(--hc-background);
  scrollbar-color: #cbd2dc transparent;
  scrollbar-width: thin;
}

.hc-chat-message { display: flex; align-items: flex-end; gap: 8px; margin: 0 0 14px; }

.hc-chat-message::before {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 9px;
  color: var(--hc-blue);
  background: var(--hc-blue-soft);
  content: "H";
  font-size: 11px;
  font-weight: 800;
}

.hc-chat-message p {
  max-width: 82%;
  margin: 0;
  padding: 11px 13px;
  border-radius: 16px 16px 16px 4px;
  line-height: 1.48;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.hc-chat-message--assistant p { border: 1px solid var(--hc-border); background: #fff; box-shadow: 0 2px 8px rgb(35 44 68 / 5%); }
.hc-chat-message--assistant strong { font-weight: 700; }
.hc-chat-message--user { flex-direction: row-reverse; }
.hc-chat-message--user::before { display: none; }
.hc-chat-message--user p { border-radius: 16px 16px 4px; color: #fff; background: var(--hc-blue); }

.hc-chat-controls-panel { min-height: 0; overflow: hidden; background: var(--hc-background); }
.hc-chat-controls { max-height: 46vh; overflow-y: auto; padding: 4px 16px 14px; background: var(--hc-background); }
#homecare-ai-chat-root .hc-chat-controls-toggle {
  display: block;
  width: calc(100% - 32px);
  min-height: 34px;
  margin: 4px 16px 8px;
  border: 0;
  border-radius: 10px;
  padding: 6px 10px;
  color: var(--hc-blue-dark);
  background: var(--hc-blue-soft);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
#homecare-ai-chat-root .hc-chat-controls-toggle:hover { background: var(--hc-blue-surface); }
#homecare-ai-chat-root .hc-chat-controls-toggle[hidden] { display: none; }
.hc-chat-actions { display: flex; flex-wrap: wrap; gap: 8px; }

#homecare-ai-chat-root .hc-chat-button,
#homecare-ai-chat-root .hc-chat-send {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--hc-blue);
  border-radius: 12px;
  padding: 9px 14px;
  color: var(--hc-blue-dark);
  background: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

#homecare-ai-chat-root .hc-chat-button:hover { border-color: var(--hc-blue-dark); background: var(--hc-blue-soft); }
#homecare-ai-chat-root .hc-chat-button:active,
#homecare-ai-chat-root .hc-chat-send:active { transform: scale(.98); }
#homecare-ai-chat-root .hc-chat-button--primary,
#homecare-ai-chat-root .hc-chat-send { border-color: var(--hc-blue); color: #fff; background: var(--hc-blue); }
#homecare-ai-chat-root .hc-chat-button--primary:hover,
#homecare-ai-chat-root .hc-chat-send:hover { border-color: #007ce3; background: #007ce3; }
#homecare-ai-chat-root .hc-chat-button--danger { border-color: #f3a7b2; color: var(--hc-danger); background: var(--hc-danger-soft); }
#homecare-ai-chat-root .hc-chat-button--danger:hover { border-color: var(--hc-danger); background: #ffe2e7; }
#homecare-ai-chat-root .hc-chat-button:disabled,
#homecare-ai-chat-root .hc-chat-send:disabled { border-color: #abbcec; color: #fff; background: #97ace7; cursor: wait; }
#homecare-ai-chat-root .hc-chat-button--loading { gap: 9px; }
#homecare-ai-chat-root .hc-chat-button--loading::before {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  border: 2px solid rgb(255 255 255 / 45%);
  border-top-color: #fff;
  border-radius: 50%;
  content: "";
  animation: hc-chat-spin 700ms linear infinite;
}

@keyframes hc-chat-spin {
  to { transform: rotate(360deg); }
}

.hc-chat-card-list { display: grid; gap: 10px; }
.hc-chat-card-list > h3 { margin: 6px 0 2px; color: var(--hc-text); font-size: 15px; font-weight: 700; }

.hc-chat-card {
  display: grid;
  gap: 9px;
  padding: 14px;
  border: 1px solid var(--hc-border);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 2px 10px rgb(35 44 68 / 5%);
}

.hc-chat-card h3, .hc-chat-card h4, .hc-chat-card p { margin: 0; }
.hc-chat-card h3, .hc-chat-card h4 { color: var(--hc-text); font-size: 15px; font-weight: 700; }
.hc-chat-card p { color: var(--hc-muted); font-size: 13px; }
#homecare-ai-chat-root .hc-chat-card .hc-chat-button { width: 100%; margin-top: 2px; }

.hc-chat-form {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--hc-border);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 2px 10px rgb(35 44 68 / 5%);
}

.hc-chat-form--nested { margin-top: 4px; border-color: #d8e0ea; box-shadow: none; }
.hc-chat-form h3, .hc-chat-form h4 { margin: 0; color: var(--hc-text); font-size: 15px; }
.hc-chat-form small { color: var(--hc-muted); }

.hc-chat-field { display: grid; gap: 6px; color: var(--hc-text); font-size: 12px; font-weight: 700; }
.hc-chat-field input,
.hc-chat-field select,
.hc-chat-form > input,
.hc-chat-form > select {
  width: 100%;
  min-height: 46px;
  border: 1px solid #ced2d9;
  border-radius: 14px;
  padding: 9px 12px;
  color: var(--hc-text);
  background: #fff;
  font: inherit;
  font-size: 14px;
}

.hc-chat-field input:hover, .hc-chat-field select:hover, .hc-chat-form > input:hover { border-color: #97a0af; }
#homecare-ai-chat-root .hc-chat-form > .hc-chat-button,
#homecare-ai-chat-root .hc-chat-form--nested > .hc-chat-button { width: 100%; }

.hc-chat-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px 12px 8px;
  border-top: 1px solid var(--hc-border);
  background: #fff;
}

.hc-chat-composer textarea {
  width: 100%;
  min-height: 46px;
  max-height: 100px;
  resize: none;
  border: 1px solid #ced2d9;
  border-radius: 16px;
  padding: 11px 13px;
  color: var(--hc-text);
  background: var(--hc-background);
  font: inherit;
}

.hc-chat-composer textarea::placeholder { color: #7c8799; }
#homecare-ai-chat-root .hc-chat-send { min-width: 68px; min-height: 46px; align-self: stretch; }
.hc-chat-status { min-height: 23px; padding: 0 14px 7px; color: var(--hc-muted); background: #fff; font-size: 11px; text-align: right; }

.hc-chat-consent {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--hc-border);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 4px 16px rgb(35 44 68 / 6%);
}

.hc-chat-consent::before {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 14px;
  color: var(--hc-blue-dark);
  background: var(--hc-blue-soft);
  content: "✓";
  font-size: 20px;
  font-weight: 800;
}

.hc-chat-consent h3, .hc-chat-consent p { margin: 0; }
.hc-chat-consent h3 { font-size: 17px; }
.hc-chat-consent p { color: var(--hc-muted); font-size: 13px; }
.hc-chat-consent a { color: var(--hc-blue-dark); font-size: 13px; font-weight: 700; }
#homecare-ai-chat-root .hc-chat-consent .hc-chat-button { width: 100%; min-height: 48px; }

#homecare-ai-chat-root .hc-chat-dialog :focus-visible,
#homecare-ai-chat-root .hc-chat-launcher:focus-visible {
  outline: 3px solid #f7b720;
  outline-offset: 2px;
}

@media (max-width: 600px) {
  .hc-chat-dialog { inset: 0; width: 100vw; height: 100dvh; max-width: none; border: 0; border-radius: 0; }
  .hc-chat-dialog:not([hidden]) { animation-name: hc-chat-fade; }
  .hc-chat-header { padding-top: max(12px, env(safe-area-inset-top)); }
  #homecare-ai-chat-root .hc-chat-launcher { right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); }
  .hc-chat-composer { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .hc-chat-status { padding-bottom: max(7px, env(safe-area-inset-bottom)); }
}

@media (max-width: 360px) {
  #homecare-ai-chat-root .hc-chat-launcher span { display: none; }
  #homecare-ai-chat-root .hc-chat-launcher { width: 56px; padding: 10px; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  #homecare-ai-chat-root * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
