.penny-chat {
  --penny-primary: #0064ff;
  --penny-primary-dark: #004dcc;
  --penny-primary-soft: #eaf2ff;
  --penny-ink: #16202a;
  --penny-muted: #526170;
  --penny-surface: #ffffff;
  --penny-canvas: #f4f8f9;
  --penny-border: #d9e0e5;
  --penny-success: #21ca00;
  --penny-success-ink: #176d06;
  --penny-danger: #ff0000;
  --penny-radius-sm: 8px;
  --penny-radius-md: 12px;
  --penny-radius-lg: 18px;
  --penny-shadow: 0 18px 50px rgba(22, 32, 42, 0.12);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #16202a;
  box-sizing: border-box;
  container-type: inline-size;
}

.penny-chat[style*="height"] {
  display: flex;
  flex-direction: column;
}

.penny-chat[style*="height"] .penny-chat-panel,
.penny-chat[style*="height"] .penny-chat-auth-panel {
  height: 100%;
}

.penny-chat *,
.penny-chat *::before,
.penny-chat *::after {
  box-sizing: border-box;
}

body.penny-chat-body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(145deg, #edf3ff 0%, #f7f9fa 48%, #eef2f5 100%);
}

.penny-chat button,
.penny-chat input,
.penny-chat textarea {
  font: inherit;
}

.penny-chat-page {
  width: min(880px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  align-items: center;
}

.penny-chat-auth-panel,
.penny-chat-panel {
  background: #ffffff;
  border: 1px solid #d9e0e5;
  border-radius: var(--penny-radius-lg);
  box-shadow: var(--penny-shadow);
}

.penny-chat-auth-panel {
  width: min(440px, 100%);
  margin: 0 auto;
  padding: 32px;
  display: grid;
  gap: 22px;
}

.penny-chat h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.penny-chat p {
  margin: 8px 0 0;
  color: #526170;
}

.penny-chat form {
  display: grid;
  gap: 14px;
}

.penny-chat label {
  display: grid;
  gap: 7px;
  color: #344250;
  font-weight: 600;
}

.penny-chat input {
  width: 100%;
  min-height: 44px;
  border: 1px solid #c8d2da;
  border-radius: 6px;
  padding: 10px 12px;
  color: #16202a;
  background: #ffffff;
}

.penny-chat input:hover,
.penny-chat textarea:hover {
  border-color: #9cabb5;
}

.penny-chat button,
.penny-chat a,
.penny-chat input,
.penny-chat textarea,
.penny-chat summary {
  outline: none;
}

.penny-chat button:focus-visible,
.penny-chat a:focus-visible,
.penny-chat input:focus-visible,
.penny-chat textarea:focus-visible,
.penny-chat summary:focus-visible {
  outline: 3px solid var(--penny-primary-dark);
  outline-offset: 2px;
}

.penny-chat button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 9px 16px;
  color: #ffffff;
  background: var(--penny-primary);
  font-weight: 700;
  cursor: pointer;
}

.penny-chat button:not([class]):not(:disabled):hover {
  background: var(--penny-primary-dark);
}

.penny-chat-secondary-link {
  min-height: 42px;
  border: 1px solid var(--penny-primary);
  border-radius: 6px;
  padding: 9px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--penny-primary);
  background: #ffffff;
  font-weight: 700;
  text-decoration: none;
}

.penny-chat button:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.penny-chat form[aria-busy="true"] button:disabled {
  cursor: wait;
}

.penny-chat-visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.penny-chat-auth-heading,
.penny-chat-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.penny-chat-avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  color: #ffffff;
  background: linear-gradient(145deg, var(--penny-primary), #2f8bff);
  box-shadow: 0 4px 12px rgba(0, 100, 255, 0.22);
  font-size: 19px;
  font-weight: 800;
}

.penny-chat-avatar-large {
  width: 52px;
  height: 52px;
  flex-basis: 52px;
  font-size: 23px;
}

.penny-chat-auth-heading p,
.penny-chat-identity p {
  margin-top: 3px;
}

.penny-chat-auth-intro {
  margin-top: -6px;
  padding: 12px 14px;
  border-radius: var(--penny-radius-md);
  background: var(--penny-primary-soft);
}

.penny-chat-auth-intro p {
  margin: 0;
}

.penny-chat-error {
  min-height: 20px;
  color: #a12c2c;
}

.penny-chat-auth-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 0.95rem;
}

.penny-chat-auth-links a {
  color: var(--penny-primary);
  font-weight: 600;
  text-decoration: none;
}

.penny-chat-auth-links a:hover,
.penny-chat-auth-links a:focus {
  text-decoration: underline;
}

.penny-chat-hidden {
  display: none !important;
}

.penny-chat-panel {
  position: relative;
  min-height: min(760px, calc(100vh - 48px));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.penny-chat-page .penny-chat-panel {
  height: min(760px, calc(100vh - 48px));
  height: min(760px, calc(100dvh - 48px));
  min-height: 0;
}

.penny-chat:not(.penny-chat-page) .penny-chat-panel {
  min-height: 520px;
  height: 100%;
}

.penny-chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid #d9e0e5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(100deg, #ffffff, #f3fafb);
}

.penny-chat-header .penny-chat-signout {
  min-height: 38px;
  border: 1px solid #cbd7dc;
  padding: 7px 12px;
  color: #344250;
  background: rgba(255, 255, 255, 0.78);
  font-size: 0.9rem;
}

.penny-chat-header .penny-chat-signout:hover {
  border-color: #9cabb5;
  background: #ffffff;
}

.penny-chat-impersonation {
  padding: 10px 16px;
  border-bottom: 1px solid #d5a33d;
  color: #5c3c00;
  background: #fff4d6;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.penny-chat-presence {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.86rem;
}

.penny-chat-presence > span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--penny-success);
  box-shadow: 0 0 0 3px rgba(33, 202, 0, 0.16);
}

.penny-chat-contact {
  border-bottom: 1px solid #d9e0e5;
  background: #fbfcfd;
}

.penny-chat-contact summary {
  min-height: 44px;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #344250;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  list-style: none;
}

.penny-chat-contact summary::-webkit-details-marker {
  display: none;
}

.penny-chat-contact summary::after {
  content: "";
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-right: 2px solid #617181;
  border-bottom: 2px solid #617181;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.16s ease;
}

.penny-chat-contact[open] summary::after {
  transform: rotate(225deg) translate(-1px, -1px);
}

.penny-chat-contact summary:hover {
  background: #f2f7f8;
}

.penny-chat-contact summary small {
  margin-left: auto;
  color: #617181;
  font-size: 0.82rem;
  font-weight: 500;
}

.penny-chat-contact-content {
  padding: 12px 20px 14px;
  border-top: 1px solid #e5eaee;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 14px;
  align-items: center;
  background: #ffffff;
}

.penny-chat-contact-main {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: baseline;
  color: #344250;
  font-size: 0.9rem;
}

.penny-chat-contact-main strong {
  color: #16202a;
}

.penny-chat-contact-main small {
  flex-basis: 100%;
  color: #617181;
}

.penny-chat-sms-optin {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  color: #344250;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}

.penny-chat .penny-chat-sms-optin input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--penny-primary);
}

.penny-chat-sms-status {
  grid-column: 2;
  color: #617181;
  font-size: 0.82rem;
}

.penny-chat-messages {
  min-width: 0;
  min-height: 0;
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: auto;
  background: var(--penny-canvas);
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.penny-chat-message {
  position: relative;
  max-width: min(72%, 600px);
  border-radius: 16px;
  padding: 12px 15px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.penny-chat-message.markdown {
  white-space: normal;
}

.penny-chat-message.penny.markdown {
  max-width: min(76%, 680px);
}

.penny-chat-message.markdown p {
  margin: 0;
}

.penny-chat-message.markdown p + p,
.penny-chat-message.markdown p + ul,
.penny-chat-message.markdown p + ol,
.penny-chat-message.markdown p + table,
.penny-chat-message.markdown p + pre,
.penny-chat-message.markdown p + .penny-chat-table-wrap,
.penny-chat-message.markdown ul + p,
.penny-chat-message.markdown ol + p,
.penny-chat-message.markdown pre + p,
.penny-chat-message.markdown .penny-chat-table-wrap + p,
.penny-chat-message.markdown table + p {
  margin-top: 8px;
}

.penny-chat-message.markdown .penny-chat-facts {
  margin: 8px 0 0;
  display: grid;
  border: 1px solid #d9e0e5;
  border-radius: 6px;
  overflow: hidden;
}

.penny-chat-message.markdown .penny-chat-facts div {
  display: grid;
  grid-template-columns: minmax(120px, 0.36fr) minmax(0, 1fr);
}

.penny-chat-message.markdown .penny-chat-facts div + div {
  border-top: 1px solid #d9e0e5;
}

.penny-chat-message.markdown .penny-chat-facts dt,
.penny-chat-message.markdown .penny-chat-facts dd {
  margin: 0;
  padding: 6px 8px;
  min-width: 0;
}

.penny-chat-message.markdown .penny-chat-facts dt {
  background: #eef4f6;
  color: #344250;
  font-weight: 700;
}

.penny-chat-message.markdown .penny-chat-facts dd {
  overflow-wrap: anywhere;
}

.penny-chat-message.markdown ul,
.penny-chat-message.markdown ol {
  margin: 6px 0 0;
  padding-left: 22px;
}

.penny-chat-message.markdown li + li {
  margin-top: 3px;
}

.penny-chat-message.markdown .penny-chat-action-row {
  margin-top: 6px;
}

.penny-chat-message.markdown .penny-chat-action-row .penny-chat-action {
  min-height: 40px;
  margin-left: 10px;
  padding: 7px 11px;
  font-size: 0.86rem;
  vertical-align: middle;
}

.penny-chat-message.markdown .penny-chat-table-wrap {
  margin: 8px 0 0;
  max-width: 100%;
  overflow-x: auto;
}

.penny-chat-message.markdown table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  font-size: 0.94em;
}

.penny-chat-message.markdown th,
.penny-chat-message.markdown td {
  padding: 6px 8px;
  border: 1px solid #d9e0e5;
  text-align: left;
  vertical-align: top;
}

.penny-chat-message.markdown th {
  background: #eef4f6;
  font-weight: 700;
}

.penny-chat-message.markdown a {
  color: var(--penny-primary);
  font-weight: 700;
}

.penny-chat-cards {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.penny-health-card {
  border: 1px solid #d9e0e5;
  border-left-width: 4px;
  border-radius: 8px;
  padding: 11px 12px;
  background: #fbfcfd;
}

.penny-health-card.status-good {
  border-left-color: var(--penny-success);
}

.penny-health-card.status-warning {
  border-left-color: #b36b00;
}

.penny-health-card.status-bad {
  border-left-color: var(--penny-danger);
}

.penny-health-card.status-unknown {
  border-left-color: #72808c;
}

.penny-health-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.penny-health-title {
  font-weight: 800;
}

.penny-health-badge {
  flex: none;
  border-radius: 999px;
  padding: 3px 8px;
  color: #ffffff;
  background: #72808c;
  font-size: 0.78rem;
  font-weight: 800;
}

.penny-health-card.status-good .penny-health-badge {
  background: var(--penny-success-ink);
}

.penny-health-card.status-warning .penny-health-badge {
  background: #b36b00;
}

.penny-health-card.status-bad .penny-health-badge {
  background: #b3261e;
}

.penny-health-summary {
  margin: 7px 0 0;
  color: #344250;
}

.penny-health-rows {
  display: grid;
  gap: 7px;
  margin: 10px 0 0;
}

.penny-health-row {
  display: grid;
  grid-template-columns: minmax(110px, .36fr) minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.penny-health-row dt {
  color: #526170;
  font-weight: 750;
}

.penny-health-row dd {
  margin: 0;
  min-width: 0;
}

.penny-health-row small {
  display: block;
  margin-top: 2px;
  color: #526170;
  overflow-wrap: anywhere;
}

.penny-chat-message.markdown code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.penny-chat-message.markdown :not(pre) > code {
  padding: 1px 4px;
  border-radius: 4px;
  background: #eef4f6;
  color: #24313d;
}

.penny-chat-message.markdown pre {
  margin: 8px 0 0;
  max-width: 100%;
  overflow-x: auto;
  border-radius: 6px;
  padding: 10px 12px;
  background: #17232e;
  color: #f6f8fa;
  white-space: pre;
}

.penny-chat-message.markdown pre code {
  display: block;
  color: inherit;
}

.penny-chat-message.customer {
  align-self: flex-end;
  border-bottom-right-radius: 5px;
  background: linear-gradient(145deg, var(--penny-primary), var(--penny-primary-dark));
  color: #ffffff;
}

.penny-chat-message.penny {
  align-self: flex-start;
  margin-left: 34px;
  border: 1px solid #d3e4e7;
  border-bottom-left-radius: 5px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(22, 32, 42, 0.04);
}

.penny-chat-message.penny::before {
  content: "P";
  position: absolute;
  left: -34px;
  bottom: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: var(--penny-primary);
  font-size: 0.72rem;
  font-weight: 800;
}

.penny-chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.penny-chat .penny-chat-action {
  min-height: 40px;
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 0.92rem;
  line-height: 1.2;
  border: 1px solid #c9d6dc;
  color: #24313d;
  background: #ffffff;
  transition: opacity .16s ease, background-color .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease;
}

.penny-chat .penny-chat-action.primary {
  border-color: var(--penny-primary);
  color: #ffffff;
  background: var(--penny-primary);
}

.penny-chat .penny-chat-action.secondary {
  color: #24313d;
  background: #f6f9fa;
}

.penny-chat .penny-chat-action.primary:not(:disabled):hover {
  border-color: var(--penny-primary-dark);
  background: var(--penny-primary-dark);
}

.penny-chat .penny-chat-action.secondary:not(:disabled):hover {
  border-color: #9fb5bd;
  color: var(--penny-primary-dark);
  background: var(--penny-primary-soft);
}

.penny-chat .penny-chat-action.selected,
.penny-chat .penny-chat-action.selected:disabled {
  border-color: var(--penny-primary);
  color: #ffffff;
  background: var(--penny-primary);
  opacity: 1;
  box-shadow: 0 0 0 2px rgba(0, 100, 255, 0.18);
}

.penny-chat .penny-chat-action.not-selected,
.penny-chat .penny-chat-action.not-selected:disabled {
  color: #8a969f;
  background: transparent;
  border-color: transparent;
  opacity: 0.22;
  box-shadow: none;
  filter: grayscale(1);
  pointer-events: none;
}

.penny-chat .penny-chat-actions-used .penny-chat-action:disabled {
  cursor: default;
}

.penny-chat .penny-chat-actions-used .penny-chat-action.not-selected:hover {
  color: #8a969f;
  background: transparent;
  border-color: transparent;
}

.penny-chat-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #526170;
  max-width: max-content;
}

.penny-chat-loading-text {
  font-weight: 600;
}

.penny-chat-loading-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.penny-chat-loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--penny-primary);
  animation: penny-chat-dot 1s ease-in-out infinite;
}

.penny-chat-loading-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.penny-chat-loading-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes penny-chat-dot {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  40% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .penny-chat-loading-dots span,
  .penny-chat-contact summary::after {
    animation: none;
    transition: none;
  }
}

.penny-chat form.penny-chat-composer {
  position: relative;
  z-index: 2;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #d9e0e5;
  background: #ffffff;
  box-shadow: 0 -6px 18px rgba(22, 32, 42, 0.04);
}

.penny-chat-composer textarea {
  width: 100%;
  min-height: 46px;
  max-height: 120px;
  resize: none;
  overflow-y: auto;
  border: 1px solid #c8d2da;
  border-radius: 23px;
  padding: 11px 16px;
  color: var(--penny-ink);
  background: #f8fafb;
  line-height: 1.45;
}

.penny-chat-composer textarea:focus-visible {
  border-color: var(--penny-primary);
  background: #ffffff;
}

.penny-chat-composer button {
  min-width: 82px;
  min-height: 46px;
  align-self: end;
  border-radius: 23px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #ffffff !important;
}

.penny-chat-composer button span {
  color: #ffffff !important;
}

.penny-chat-composer button svg {
  width: 18px;
  height: 18px;
  color: #ffffff !important;
  fill: #ffffff !important;
}

@media (max-width: 640px) {
  .penny-chat-page {
    padding: 0;
  }

  .penny-chat-page .penny-chat-auth-panel,
  .penny-chat-page .penny-chat-panel {
    min-height: 100vh;
    min-height: 100dvh;
    border-radius: 0;
    border: 0;
  }

  .penny-chat-page .penny-chat-panel {
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
  }

  .penny-chat-header {
    align-items: center;
    padding: 12px 14px;
  }

  .penny-chat-header h1 {
    font-size: 19px;
  }

  .penny-chat-avatar {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
    font-size: 17px;
  }

  .penny-chat-presence {
    font-size: 0.76rem;
  }

  .penny-chat-contact-content {
    grid-template-columns: 1fr;
  }

  .penny-chat-contact summary {
    padding: 9px 14px;
  }

  .penny-chat-contact summary small {
    display: none;
  }

  .penny-chat-contact-content {
    padding: 11px 14px 13px;
  }

  .penny-chat-sms-optin {
    white-space: normal;
  }

  .penny-chat-sms-status {
    grid-column: 1;
  }

  .penny-chat-message {
    max-width: 86%;
  }

  .penny-chat-message.penny.markdown {
    max-width: calc(100% - 34px);
  }

  .penny-chat-messages {
    padding: 18px 14px;
  }

  .penny-chat form.penny-chat-composer {
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  }

  .penny-chat-composer button {
    min-width: 46px;
    width: 46px;
    padding: 0;
  }

  .penny-chat-composer button span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .penny-chat-message.markdown .penny-chat-facts div {
    grid-template-columns: 1fr;
  }

  .penny-chat-message.markdown .penny-chat-facts dd {
    border-top: 1px solid #d9e0e5;
  }

  .penny-chat-auth-panel {
    padding: 24px 20px;
  }
}

@media (forced-colors: active) {
  .penny-chat button,
  .penny-chat input,
  .penny-chat textarea,
  .penny-chat-message,
  .penny-chat-action {
    border: 1px solid ButtonText;
  }
}
