.chat-panel,
.chat-panel *,
.chat-launcher,
.chat-launcher * {
  box-sizing: border-box;
}

.chat-panel {
  color: var(--ink, #192c39);
  background: var(--surface, #fff);
  border: 1px solid var(--border, #dce5e4);
  border-radius: 24px;
  font-family: inherit;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  text-align: left;
  box-shadow: 0 16px 52px -30px var(--shadow, rgb(25 44 57 / .12));
}


.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}


.chat-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.chat-title {
  color: var(--ink, #192c39);
  font-size: clamp(1.5rem, 2.5vw, 1.9rem);
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.045em;
  margin: 0;
}


.chat-panel button,
.chat-panel textarea,
.chat-launcher {
  font: inherit;
}

.chat-panel button,
.chat-launcher {
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.chat-panel button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.chat-panel :focus-visible,
.chat-launcher:focus-visible {
  outline: 3px solid var(--accent, #176b66);
  outline-offset: 3px;
}

.chat-text-button,
.chat-close-button {
  background: transparent;
  border: 0;
  color: var(--muted, #596975);
  min-height: 44px;
  border-radius: 8px;
}

.chat-text-button {
  min-width: 44px;
  padding: 0;
  font-size: 23px !important;
}

.chat-text-button:hover,
.chat-close-button:hover {
  color: var(--ink, #192c39);
  background: var(--surface-hover, #e7efec);
}

.chat-close-button {
  min-width: 44px;
  padding: 0;
  font-size: 26px !important;
  line-height: 1;
}


.chat-log {
  flex: 1 1 auto;
  min-height: 130px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 24px 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong, #b2c7c0) transparent;
}

.chat-log:focus-visible {
  outline-offset: -4px;
  border-radius: 8px;
}


.chat-launcher-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: -0.03em;
}



.chat-message {
  max-width: 94%;
  width: fit-content;
  border-radius: 14px;
  padding: 11px 14px;
  margin: 0 0 12px;
  background: var(--surface-muted, #edf3ef);
  border: 1px solid var(--border, #dce5e4);
  overflow-wrap: anywhere;
}

.chat-message--user {
  margin-left: auto;
  background: var(--surface-selected, #e5efeb);
  border-color: var(--border-strong, #b2c7c0);
}

.chat-speaker {
  display: block;
  font-size: 10px;
  color: var(--muted, #596975);
  font-weight: 700;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}

.chat-message-text {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.7;
  margin: 0;
}

.chat-status {
  flex-shrink: 0;
  min-height: 22px;
  max-height: 96px;
  overflow-y: auto;
  margin: 0;
  padding: 0 24px 7px;
  color: var(--muted, #596975);
  font-size: 11px;
  line-height: 1.5;
}

.chat-status:empty { display: none; }

.chat-status--error {
  color: var(--error, #8b3434);
  font-size: 12px;
}

.chat-form {
  flex-shrink: 0;
  border-top: 1px solid var(--border, #dce5e4);
  padding: 13px 24px 0;
  margin: 0;
}

.chat-label,
.chat-input-hint {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.chat-input-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.chat-question {
  display: block;
  flex: 1;
  min-width: 0;
  width: 100%;
  border: 1px solid var(--border-strong, #b2c7c0);
  border-radius: 11px;
  background: var(--surface, #fff);
  color: var(--ink, #192c39);
  padding: 11px 12px;
  font-size: 14px !important;
  line-height: 1.5;
  resize: none;
}

.chat-question::placeholder {
  color: var(--muted, #596975);
  opacity: 1;
}

.chat-question:read-only {
  background: var(--surface-muted, #edf3ef);
}

.chat-send-button {
  align-self: stretch;
  border: 1px solid var(--accent, #176b66);
  border-radius: 11px;
  color: var(--on-accent, #fff);
  background: var(--accent, #176b66);
  padding: 10px 15px;
  min-width: 46px;
  min-height: 46px;
  font-size: 22px !important;
  font-weight: 650 !important;
}

.chat-send-button:hover:not(:disabled) {
  background: var(--accent-hover, #10534f);
  border-color: var(--accent-hover, #10534f);
}


.chat-privacy {
  flex-shrink: 0;
  margin: 0;
  padding: 10px 24px 18px;
  color: var(--muted, #596975);
  font-size: 10px;
  line-height: 1.6;
}

.chat-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 17px 10px 10px;
  min-height: 54px;
  background: var(--accent, #176b66);
  color: var(--on-accent, #fff);
  border: 1px solid var(--accent, #176b66);
  border-radius: 100px;
  box-shadow: 0 8px 28px var(--shadow, rgb(25 44 57 / .12));
  font-size: 13px;
  font-weight: 650;
  animation: chat-launcher-pop 550ms cubic-bezier(.2, .8, .3, 1.2) backwards;
  transition: transform 180ms ease, background-color 150ms ease, box-shadow 150ms ease;
}

.chat-launcher::before {
  content: '';
  position: absolute;
  inset: -5px;
  border: 2px solid var(--accent, #176b66);
  border-radius: inherit;
  opacity: 0;
  pointer-events: none;
  animation: chat-launcher-pulse 2s ease-out 550ms 3;
}

@keyframes chat-launcher-pop {
  from { opacity: 0; transform: translateY(12px) scale(.8); }
  70% { opacity: 1; transform: translateY(-3px) scale(1.06); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes chat-launcher-pulse {
  from { opacity: .55; transform: scale(1); }
  to { opacity: 0; transform: scale(1.18, 1.35); }
}

.chat-launcher:hover {
  background: var(--accent-hover, #10534f);
  box-shadow: 0 10px 30px var(--shadow, rgb(25 44 57 / .12));
  transform: translateY(-3px);
}

.chat-launcher-badge {
  width: 32px;
  height: 32px;
  border: 1px solid var(--badge-border, rgb(255 255 255 / .3));
  border-radius: 50%;
  background: var(--badge-background, rgb(255 255 255 / .12));
}

.chat-panel--compact {
  position: fixed;
  inset: auto 24px 92px auto;
  margin: 0;
  width: min(440px, calc(100vw - 48px));
  height: min(520px, calc(100vh - 116px));
  height: min(520px, calc(100dvh - 116px));
  max-width: none;
  max-height: none;
  box-shadow: 0 20px 80px var(--shadow, rgb(25 44 57 / .12));
  padding: 0;
}

.chat-panel--compact:not([open]) {
  display: none;
}

.chat-panel--compact::backdrop {
  background: var(--backdrop, rgb(25 44 57 / .3));
}

.chat-panel--compact .chat-title {
  font-size: 1.2rem;
}


@media (max-width: 600px) {

  .chat-panel-header {
    padding: 14px 18px;
  }



  .chat-log {
    padding-left: 18px;
    padding-right: 18px;
  }

  .chat-status {
    padding-left: 18px;
    padding-right: 18px;
  }

  .chat-form {
    padding-left: 18px;
    padding-right: 18px;
  }

  .chat-question {
    font-size: 16px !important;
  }

  .chat-privacy {
    padding-left: 18px;
    padding-right: 18px;
  }

  .chat-launcher {
    right: 16px;
    bottom: max(16px, env(safe-area-inset-bottom));
  }

  .chat-panel--compact {
    inset: 12px;
    width: calc(100% - 24px);
    height: calc(100vh - 24px);
    height: calc(100dvh - 24px);
    border-radius: 20px;
  }

  .chat-panel--compact .chat-log {
    min-height: 60px;
  }
}

@media (max-height: 650px) and (min-width: 601px) {
  .chat-panel--compact {
    inset: 12px 24px 12px auto;
    height: calc(100vh - 24px);
    height: calc(100dvh - 24px);
  }

  .chat-panel--compact .chat-log {
    min-height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-panel button,
  .chat-launcher {
    transition: none;
  }
  .chat-launcher,
  .chat-launcher::before {
    animation: none;
  }
}
