/* Component audit: unslop by Damir Sokolovsky (@heydamir), CC BY 4.0. */
.cgw {
  --cw-ink: #17263b;
  --cw-muted: #4b5e76;
  --cw-brand: #0052d9;
  --cw-brand-hover: #0046ba;
  --cw-paper: #fff;
  --cw-field: #f1f5fa;
  --cw-tint: #dfecff;
  --cw-note: #edf2f8;
  --cw-corner: 24px;
  position: fixed;
  z-index: 50;
  inset-inline-end: max(var(--cw-corner), env(safe-area-inset-right));
  inset-block-end: max(var(--cw-corner), env(safe-area-inset-bottom));
  color: var(--cw-ink);
  font-size: 15px;
  line-height: 1.5;
}

.cgw-open { inline-size: min(392px, calc(100% - 2 * var(--cw-corner))); }

.cgw-panel {
  display: flex;
  flex-direction: column;
  inline-size: 100%;
  block-size: min(512px, calc(100dvh - 2 * var(--cw-corner)));
  min-block-size: 0;
  background: var(--cw-paper);
  border-radius: 16px;
  box-shadow: 0 12px 40px #17263b29, 0 0 0 1px #17263b18; /* taste-skill-ignore: floating overlay on the public page */
  overflow: hidden;
  animation: cgw-enter 160ms ease-out;
}

.cgw-panel:focus { outline: none; }

.cgw-header {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 16px 20px;
}

.cgw-mark {
  display: grid;
  place-items: center;
  inline-size: 40px;
  block-size: 40px;
  border-radius: 8px;
  color: var(--cw-brand);
  background: var(--cw-tint);
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.cgw-title, .cgw-detail { margin: 0; letter-spacing: normal; }
.cgw-title { font-size: 16px; line-height: 1.4; font-weight: 600; overflow-wrap: anywhere; }
.cgw-detail { margin-block-start: 2px; font-size: 13px; line-height: 1.45; color: var(--cw-muted); }

.cgw :is(.cgw-mini, .cgw-send, .cgw-launch) {
  display: grid;
  place-items: center;
  inline-size: 44px;
  block-size: 44px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 140ms ease-out, color 140ms ease-out;
}

.cgw .cgw-mini { background: transparent; color: var(--cw-muted); }
.cgw .cgw-mini:hover { background: var(--cw-field); color: var(--cw-ink); }
.cgw :is(.cgw-launch, .cgw-send) { background: var(--cw-brand); color: #fff; }
.cgw :is(.cgw-launch, .cgw-send):not(:disabled):hover { background: var(--cw-brand-hover); }
.cgw .cgw-launch { inline-size: 52px; block-size: 52px; border-radius: 12px; }
.cgw .cgw-send:disabled { background: #e3eaf4; color: #4b5e76; cursor: default; }

.cgw-transcript {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 16px;
  min-block-size: 0;
  padding: 20px;
  background: var(--cw-field);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.cgw-line {
  align-self: flex-start;
  max-inline-size: min(94%, 44ch);
  display: grid;
  gap: 4px;
}
.cgw-line-own { align-self: flex-end; justify-items: end; }
.cgw-author {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 8px;
  color: var(--cw-muted);
  font-size: 12px;
  line-height: 1.5;
  font-weight: 500;
}
.cgw-line-own .cgw-author { justify-content: flex-end; }
.cgw-time { font-weight: 400; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cgw-message {
  padding: 12px;
  border-radius: 8px;
  background: var(--cw-paper);
  color: var(--cw-ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.cgw-line-own .cgw-message { background: var(--cw-tint); }

.cgw-footer { flex: 0 0 auto; display: grid; gap: 8px; padding: 12px 16px 12px; }
.cgw-form { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 8px; align-items: center; }
.cgw .cgw-input {
  inline-size: 100%;
  min-inline-size: 0;
  block-size: 44px;
  padding: 0 12px;
  border: 1px solid #8396ad; /* taste-skill-ignore: form field boundary against white */
  border-radius: 8px;
  background: var(--cw-paper);
  color: var(--cw-ink);
  font-size: 16px;
  cursor: text;
}
.cgw-input::placeholder { color: var(--cw-muted); }
.cgw .cgw-input:focus { border-color: var(--cw-brand); }

.cgw-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  padding: 8px 12px;
  color: #354a63;
  background: var(--cw-note);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.cgw-note-send { background: #fff1ee; color: #862e27; }
.cgw .cgw-inline {
  padding: 0;
  min-block-size: 32px;
  border: 0;
  background: transparent;
  color: var(--cw-brand);
  text-align: start;
  font-size: inherit;
  font-weight: 600;
  cursor: pointer;
}
.cgw .cgw-inline:disabled { color: var(--cw-muted); cursor: default; }
.cgw-alternatives {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 12px;
  color: var(--cw-muted);
  font-size: 12px;
  line-height: 1.5;
}
.cgw-alternatives a { display: inline-flex; align-items: center; min-block-size: 28px; color: var(--cw-brand); font-weight: 500; }
.cgw :is(.cgw-inline, .cgw-alternatives a):hover:not(:disabled) { text-decoration: underline; text-underline-offset: 3px; }
.cgw :is(button, input, a):focus-visible { outline: 2px solid var(--cw-brand); outline-offset: 2px; }

.cgw-spin { animation: cgw-spin 800ms linear infinite; }
@keyframes cgw-enter { from { opacity: 0; transform: translateY(4px); } }
@keyframes cgw-spin { to { transform: rotate(360deg); } }

@media (max-width: 520px) {
  .cgw { --cw-corner: 12px; }
  .cgw-header { gap: 8px; padding: 12px; }
  .cgw-transcript { padding: 16px; }
  .cgw-footer { padding-inline: 12px; }
  .cgw-alternatives a { min-block-size: 36px; }
  .cgw .cgw-inline { min-block-size: 40px; }
}

@media (max-height: 450px) {
  .cgw { --cw-corner: 8px; }
  .cgw-header { padding-block: 8px; }
  .cgw-footer { padding-block: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .cgw-panel, .cgw-spin { animation: none; }
  .cgw :is(.cgw-mini, .cgw-send, .cgw-launch) { transition: none; }
}
