/* TD Digital Agent - a bottom-docked sheet that overlays the app screen.
   Every selector is prefixed .cpb so it can be dropped onto a host page without colliding. */

.cpb {
  position: absolute;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  font-family: var(--td-font, "Helvetica Neue", Arial, sans-serif);
  --cpb-green: #008a00;
  --cpb-green-dark: #006300;
  --cpb-orange: #e8730c;
  --cpb-orange-dark: #cf6309;
  --cpb-ink: #1c1c1c;
  --cpb-soft: #5a6066;
  --cpb-line: #e4e8ea;
  --cpb-bot: #eef1f2;
  --cpb-wash: #eaf5ea;
  --cpb-keyboard-height: 290px;
  --cpb-keyboard-dock: 50%;

  --cpb-dock: 34%;
  --cpb-tall: 78%;
}

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

/* Several elements below set display:flex, which otherwise beats the UA rule for [hidden]. */
.cpb [hidden] {
  display: none !important;
}

/* ---------------------------------------------------------------- the sheet */

.cpb-panel {
  pointer-events: auto;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--cpb-dock);
  background: #fff;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 34px rgba(0, 30, 10, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: height 0.26s cubic-bezier(0.22, 1, 0.36, 1);
  animation: cpb-sheet-up 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}

.cpb[data-size="tall"] .cpb-panel {
  height: var(--cpb-tall);
}

/* With the keyboard open, the assistant rests at a midpoint and can still be pulled fully up. */
.cpb[data-keyboard="open"] .cpb-panel {
  left: 6px;
  right: 6px;
  bottom: var(--cpb-keyboard-height);
  height: var(--cpb-keyboard-dock);
  max-height: calc(100% - var(--cpb-keyboard-height));
  border-radius: 34px 34px 58px 58px;
  box-shadow:
    0 6px 8px rgba(28, 28, 28, 0.04),
    0 1px 14px rgba(28, 28, 28, 0.06);
}

.cpb[data-keyboard="open"][data-size="tall"] .cpb-panel {
  left: 0;
  right: 0;
  height: calc(100% - var(--cpb-keyboard-height));
  border-radius: 0;
}

/* Collapsed to the header bar - the design's minimize control. */
.cpb[data-size="min"] .cpb-panel {
  height: auto;
}

.cpb[data-size="min"] .cpb-context,
.cpb[data-size="min"] .cpb-log,
.cpb[data-size="min"] .cpb-composer,
.cpb[data-size="min"] .cpb-listening,
.cpb[data-size="min"] .cpb-fineprint {
  display: none;
}

.cpb[data-size="min"] .cpb-head {
  border-bottom: none;
  cursor: pointer;
}

.cpb[data-size="min"] .cpb-chev {
  transform: rotate(180deg);
  transform-origin: 12px 12px;
}

.cpb[data-dragging="true"] .cpb-panel {
  animation: none;
  transition: none;
}

@keyframes cpb-sheet-up {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.cpb-grab {
  flex: none;
  padding: 7px 0 4px;
  display: grid;
  place-items: center;
  cursor: grab;
  touch-action: none;
  background: #fff;
}

.cpb-grab:active {
  cursor: grabbing;
}

.cpb-grab::before {
  content: "";
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: #ccd3d7;
}

.cpb[data-keyboard="open"] .cpb-grab {
  padding: 5px 0 6px;
}

.cpb[data-keyboard="open"] .cpb-grab::before {
  height: 5px;
  border-radius: 100px;
  background: #ccc;
}

/* ---------------------------------------------------------------- header */

.cpb-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 1px 8px 9px 14px;
  color: var(--cpb-ink);
  flex: none;
  border-bottom: 1px solid var(--cpb-line);
}

.cpb-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cpb-green) 0%, #00ab14 100%);
  color: #fff;
  display: grid;
  place-items: center;
  flex: none;
}

.cpb-avatar svg {
  width: 19px;
  height: 19px;
}

.cpb-titles {
  flex: 1;
  min-width: 0;
}

.cpb-titles h2 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -0.005em;
}

.cpb-sub {
  margin: 0;
  font-size: 11.5px;
  color: var(--cpb-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cpb-head-actions {
  display: flex;
  gap: 1px;
  flex: none;
}

.cpb-iconbtn {
  position: relative;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: #8d959b;
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.cpb-iconbtn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.cpb-iconbtn:hover {
  background: #f0f2f3;
  color: var(--cpb-ink);
}

.cpb-iconbtn.is-on {
  background: var(--cpb-wash);
  color: var(--cpb-green-dark);
}

.cpb-iconbtn[data-act="tts"]:not(.is-on) .cpb-wave {
  opacity: 0.3;
}

.cpb-min {
  color: var(--cpb-ink);
}

.cpb-min-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #c3202b;
  box-shadow: 0 0 0 2px #fff;
}

.cpb.is-nudging .cpb-panel {
  animation: cpb-nudge 1.6s ease-in-out 3;
}

@keyframes cpb-nudge {
  0%,
  100% {
    box-shadow: 0 -8px 34px rgba(0, 30, 10, 0.2);
  }
  50% {
    box-shadow:
      0 -8px 34px rgba(0, 30, 10, 0.2),
      0 -2px 0 3px rgba(0, 138, 0, 0.45);
  }
}

/* ---------------------------------------------------------------- context strip */

.cpb-context {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 15px;
  background: var(--cpb-wash);
  border-bottom: 1px solid #d9e8d9;
  font-size: 11px;
  color: #2c5a2c;
  flex: none;
}

.cpb-ctx-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cpb-green);
  flex: none;
  animation: cpb-blink 2.4s ease-in-out infinite;
}

@keyframes cpb-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

.cpb-ctx-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cpb-ctx-step {
  font-weight: 700;
  font-size: 10px;
  background: #fff;
  border: 1px solid #cfe3cf;
  border-radius: 9px;
  padding: 1px 7px;
  flex: none;
}

/* ---------------------------------------------------------------- transcript */

.cpb-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 11px 15px 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}

.cpb-log::-webkit-scrollbar {
  width: 5px;
}

.cpb-log::-webkit-scrollbar-thumb {
  background: #d4d9dc;
  border-radius: 3px;
}

.cpb-msg {
  display: flex;
  max-width: 100%;
}

.cpb-bubble {
  max-width: 88%;
  padding: 10px 13px;
  font-size: 13.5px;
  line-height: 1.45;
  border-radius: 15px;
  word-wrap: break-word;
  animation: cpb-rise 0.22s ease;
}

@keyframes cpb-rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cpb-bubble p {
  margin: 0 0 7px;
}

.cpb-bubble p:last-child {
  margin-bottom: 0;
}

.cpb-bubble ol {
  margin: 5px 0 2px;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cpb-msg-bot .cpb-bubble {
  background: var(--cpb-bot);
  color: var(--cpb-ink);
  border-bottom-left-radius: 4px;
}

.cpb-msg-user {
  justify-content: flex-end;
}

.cpb-msg-user .cpb-bubble {
  background: var(--cpb-green);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.cpb-note {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 11.5px;
  color: var(--cpb-soft);
  background: #fafbfb;
  border: 1px dashed var(--cpb-line);
  border-radius: 9px;
  padding: 7px 10px;
}

.cpb-note-icon {
  color: var(--cpb-green);
  font-weight: 700;
  flex: none;
}

.cpb-card {
  border: 1px solid #cfe3cf;
  background: linear-gradient(180deg, #ffffff 0%, var(--cpb-wash) 100%);
  border-radius: 11px;
  padding: 10px 12px;
}

.cpb-card-text {
  margin: 0 0 8px;
  font-size: 12.5px;
  color: var(--cpb-ink);
}

.cpb-card-btn {
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 16px;
  border: none;
  background: var(--cpb-green);
  color: #fff;
  cursor: pointer;
}

.cpb-card-btn:disabled {
  background: #a9cfa9;
  cursor: default;
}

.cpb-figure {
  margin: 0;
  /* Kept narrow so the figure and the reply that follows it both fit the transcript. */
  align-self: flex-start;
  max-width: 240px;
  /* overflow:hidden zeroes a flex item's automatic minimum size, so without this the transcript
     crushes the picture to a sliver as soon as it scrolls. */
  flex: none;
  border: 1px solid var(--cpb-line);
  border-radius: 11px;
  overflow: hidden;
  background: #fff;
  animation: cpb-rise 0.22s ease;
}

.cpb-figure img {
  display: block;
  width: 100%;
  height: auto;
}

.cpb-figure figcaption {
  padding: 7px 11px 8px;
  font-size: 11.5px;
  color: var(--cpb-soft);
  border-top: 1px solid var(--cpb-line);
}

.cpb-typing .cpb-bubble {
  display: flex;
  gap: 4px;
  padding: 13px;
}

.cpb-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9aa2a8;
  animation: cpb-bounce 1.25s infinite ease-in-out;
}

.cpb-typing i:nth-child(2) {
  animation-delay: 0.16s;
}

.cpb-typing i:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes cpb-bounce {
  0%,
  70%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  35% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* ---------------------------------------------------------------- suggested actions

   Pills sit in the transcript directly under the reply they belong to. */

.cpb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  animation: cpb-rise 0.22s ease;
}

.cpb-chips-context {
  padding-top: 7px;
  border-top: 1px dashed var(--cpb-line);
}

.cpb-chip {
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 16px;
  border: 1.5px solid var(--cpb-green);
  background: #fff;
  color: var(--cpb-green-dark);
  cursor: pointer;
  transition:
    background 0.14s ease,
    transform 0.14s ease;
}

.cpb-chip:hover:not(:disabled) {
  background: var(--cpb-wash);
  transform: translateY(-1px);
}

.cpb-chip-ghost {
  border-color: #cfd5d9;
  color: var(--cpb-soft);
  font-weight: 500;
}

.cpb-chip-ghost:hover:not(:disabled) {
  background: #f4f6f7;
}

.cpb-starters {
  animation: cpb-rise 0.22s ease;
}

.cpb-starters-label {
  display: block;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #9aa2a8;
  margin-bottom: 5px;
  font-weight: 700;
}

.cpb-starters-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.cpb-starter {
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  padding: 8px 30px 8px 11px;
  border-radius: 9px;
  border: 1px solid var(--cpb-line);
  background: #fbfcfc;
  color: var(--cpb-ink);
  cursor: pointer;
  position: relative;
  width: 100%;
}

.cpb-starter::after {
  content: "✎";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #9aa2a8;
  font-size: 12px;
}

.cpb-starter:hover:not(:disabled) {
  border-color: var(--cpb-green);
  background: var(--cpb-wash);
}

/* Answered - kept in the transcript as history, but no longer actionable. */
.cpb-chips.is-spent,
.cpb-starters.is-spent {
  opacity: 0.4;
}

.cpb-chips.is-spent button,
.cpb-starters.is-spent button {
  cursor: default;
}

/* ---------------------------------------------------------------- composer */

.cpb-composer {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 9px;
  padding: 8px 12px 4px;
  border-top: 1px solid var(--cpb-line);
}

.cpb-composer.is-disabled {
  opacity: 0.55;
}

.cpb-inputwrap {
  flex: 1;
  min-width: 0;
  position: relative;
  display: flex;
}

.cpb-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 13.5px;
  padding: 10px 40px 10px 14px;
  border: 1px solid #c8ced2;
  border-radius: 20px;
  resize: none;
  max-height: 84px;
  line-height: 1.4;
  font-family: inherit;
  background: #fff;
}

.cpb-input:focus {
  outline: none;
  border-color: var(--cpb-green);
  box-shadow: 0 0 0 3px rgba(0, 138, 0, 0.15);
}

.cpb-send {
  position: absolute;
  right: 5px;
  bottom: 4px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--cpb-green);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.cpb-send:hover:not(:disabled) {
  background: var(--cpb-green-dark);
}

.cpb-send svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

/* The prominent voice control the design puts at the lower right. */
.cpb-mic {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  background: linear-gradient(135deg, var(--cpb-orange) 0%, #f08a2b 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(232, 115, 12, 0.4);
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

.cpb-mic:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(232, 115, 12, 0.5);
}

.cpb-mic svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

.cpb-mic:disabled,
.cpb-send:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
}

.cpb.is-listening .cpb-mic {
  background: #c3202b;
  box-shadow: 0 0 0 4px rgba(195, 32, 43, 0.18);
}

/* ---------------------------------------------------------------- simulated mobile keyboard */

.cpb-keyboard {
  pointer-events: auto;
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 0;
  width: 412px;
  max-width: 100%;
  height: var(--cpb-keyboard-height);
  padding: 0;
  color: #101513;
  background: #d1d3d9;
  -webkit-backdrop-filter: blur(54.3656px);
  backdrop-filter: blur(54.3656px);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
}

.cpb-keyboard-head {
  display: none;
}

.cpb-keyboard-head button {
  padding: 4px 7px;
  border: 0;
  color: #0879e1;
  background: transparent;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.cpb-keyboard-rows {
  position: absolute;
  top: 8px;
  left: 3px;
  right: 3px;
  height: 204px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cpb-keyboard-row {
  flex: none;
  height: 42px;
  display: flex;
  justify-content: center;
  gap: 4px;
}

.cpb-keyboard-row:nth-child(2) {
  margin-inline: 19px;
}

.cpb-keyboard-row:nth-child(4) {
  gap: 6px;
}

.cpb-key {
  flex: 1 1 0;
  min-width: 0;
  border: 0;
  height: 42px;
  border-radius: 4.6px;
  color: #111;
  background: #fff;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
  font-family: "SF Pro", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  font-size: 22px;
  font-weight: 400;
  line-height: 28px;
  letter-spacing: 0.35px;
  cursor: pointer;
}

.cpb-key:active {
  transform: translateY(1px);
  box-shadow: none;
}

.cpb-key-action {
  flex-grow: 1.35;
  color: #1f2328;
  background: #abb0bc;
  font-size: 16px;
  line-height: 21px;
  letter-spacing: -0.32px;
}

.cpb-key-space {
  flex-grow: 5;
  font-size: 16px;
  line-height: 21px;
  letter-spacing: -0.32px;
}

.cpb-keyboard-row:nth-child(4) .cpb-key-action {
  flex: 0 0 22%;
}

.cpb-keyboard-row:nth-child(4) .cpb-key-space {
  flex: 1 1 auto;
}

.cpb-keyboard-footer {
  position: absolute;
  top: 235px;
  left: 31px;
  right: 31px;
  height: 28px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  color: #50555c;
}

.cpb-keyboard-emoji {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border: 1.8px solid currentColor;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
}

.cpb-keyboard-dictation {
  width: 19px;
  height: 28px;
}

.cpb-keyboard-home {
  position: absolute;
  width: 134px;
  height: 5px;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  background: #000;
  border-radius: 100px;
}

/* Conversation on, but the mic is closed while the agent talks. The ring says "still yours". */
.cpb.is-convo:not(.is-listening) .cpb-mic {
  box-shadow: 0 0 0 4px rgba(232, 115, 12, 0.25);
}

.cpb-listening.is-speaking {
  background: var(--cpb-wash);
  color: var(--cpb-green-dark);
}

.cpb-listening.is-speaking .cpb-bars i {
  background: var(--cpb-green-dark);
  animation-duration: 1.4s;
}

.cpb-listening.is-speaking .cpb-listening-stop {
  border-color: #b7d5c1;
  color: var(--cpb-green-dark);
}

/* ---------------------------------------------------------------- listening state */

.cpb-listening {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 12px 2px;
  padding: 7px 12px;
  border-radius: 11px;
  background: #fdeced;
  color: #8e1821;
  font-size: 12px;
  font-weight: 600;
}

.cpb-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 17px;
}

.cpb-bars i {
  width: 3px;
  background: #c3202b;
  border-radius: 2px;
  animation: cpb-eq 0.9s ease-in-out infinite;
}

.cpb-bars i:nth-child(1) {
  animation-delay: 0s;
}
.cpb-bars i:nth-child(2) {
  animation-delay: 0.12s;
}
.cpb-bars i:nth-child(3) {
  animation-delay: 0.24s;
}
.cpb-bars i:nth-child(4) {
  animation-delay: 0.36s;
}
.cpb-bars i:nth-child(5) {
  animation-delay: 0.48s;
}

@keyframes cpb-eq {
  0%,
  100% {
    height: 4px;
  }
  50% {
    height: 16px;
  }
}

.cpb-listening-text {
  flex: 1;
}

.cpb-listening-stop {
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  border: 1px solid #e6b3b7;
  background: #fff;
  color: #8e1821;
  border-radius: 13px;
  padding: 3px 10px;
  cursor: pointer;
}

.cpb-fineprint {
  flex: none;
  margin: 0;
  padding: 1px 15px 7px;
  font-size: 9.5px;
  color: #a2a9ae;
  text-align: center;
}

/* ---------------------------------------------------------------- inspector

   Lives outside the device frame - a developer tool, not part of the app. */

.cpb-inspector {
  position: fixed;
  top: 44px;
  right: 16px;
  bottom: 16px;
  width: 300px;
  overflow-y: auto;
  background: #16191c;
  color: #cfd6db;
  border-radius: 14px;
  padding: 16px 18px;
  font-size: 12px;
  line-height: 1.5;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
  z-index: 60;
  font-family: var(--td-font, "Helvetica Neue", Arial, sans-serif);
}

.cpb-inspector[hidden] {
  display: none;
}

@media (max-width: 1080px) {
  .cpb-inspector {
    display: none !important;
  }
}

.cpb-ins-head {
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.cpb-ins-head span {
  color: #6fcf6f;
  font-weight: 500;
}

.cpb-ins-block {
  margin-bottom: 14px;
}

.cpb-ins-block h4 {
  margin: 0 0 6px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7f8a92;
  font-weight: 700;
}

.cpb-ins-node b {
  color: #fff;
}

.cpb-inspector code {
  background: #23282c;
  border-radius: 3px;
  padding: 1px 5px;
  color: #8fd48f;
  font-size: 11px;
}

.cpb-inspector p {
  margin: 0;
}

.cpb-inspector table {
  width: 100%;
  border-collapse: collapse;
}

.cpb-inspector th {
  text-align: left;
  font-weight: 600;
  color: #9aa5ad;
  padding: 2px 8px 2px 0;
  vertical-align: top;
  white-space: nowrap;
}

.cpb-inspector td {
  padding: 2px 0;
  color: #e4e9ed;
  word-break: break-word;
}

.cpb-inspector ul {
  margin: 0;
  padding-left: 15px;
}

.cpb-ins-empty {
  color: #656f76;
  font-style: italic;
}

.cpb-ins-warn {
  border: 1px solid #5c4410;
  background: #241d0c;
  border-radius: 8px;
  padding: 10px 12px;
}

.cpb-ins-warn h4 {
  color: #e0b24a;
}

.cpb-ins-warn p {
  margin-top: 6px;
  color: #a08b4f;
}
