.sdt-agent {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 160;
  font-family: var(--font-body, "Manrope", Arial, sans-serif);
  color: var(--ink, #151716);
  line-height: 1.45;
}

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

.sdt-agent button,
.sdt-agent textarea {
  font: inherit;
}

.sdt-agent button,
.sdt-agent a {
  touch-action: manipulation;
}

.sdt-agent__launcher {
  min-width: 210px;
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 15px 8px 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  background: #181b1a;
  box-shadow: 0 16px 38px rgba(25, 23, 20, 0.23);
  color: #fff;
  cursor: pointer;
  text-align: left;
  transition: transform 180ms var(--ease, ease), box-shadow 180ms ease, background 180ms ease;
}

.sdt-agent__launcher:hover {
  background: #242725;
  box-shadow: 0 20px 46px rgba(25, 23, 20, 0.29);
  transform: translateY(-2px);
}

.sdt-agent__launcher:active {
  transform: translateY(0);
}

.sdt-agent__seal,
.sdt-agent__identity-seal {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.38);
  background: #111312;
  color: #fff;
  font-weight: 750;
  letter-spacing: 0.06em;
}

.sdt-agent__seal {
  width: 46px;
  height: 46px;
  border-radius: 4px;
  font-size: 13px;
}

.sdt-agent__launcher-copy {
  display: grid;
  gap: 1px;
}

.sdt-agent__launcher-copy strong {
  font-size: 13px;
  line-height: 1.25;
}

.sdt-agent__launcher-copy small {
  color: #aeb2ac;
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sdt-agent__panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  width: min(400px, calc(100vw - 28px));
  height: min(680px, calc(100dvh - 108px));
  min-height: 480px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid rgba(24, 27, 25, 0.2);
  border-radius: 9px;
  background: var(--surface, #fbfaf6);
  box-shadow: 0 30px 80px rgba(24, 22, 19, 0.24);
  color: var(--ink, #151716);
  opacity: 0;
  transform: translateY(10px) scale(0.985);
  transform-origin: right bottom;
  transition: opacity 210ms var(--ease, ease), transform 210ms var(--ease, ease);
}

.sdt-agent__panel[hidden] {
  display: none;
}

.sdt-agent.is-open .sdt-agent__panel {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.sdt-agent__header {
  position: relative;
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 13px 12px 14px;
  overflow: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    #181b1a;
  background-size: 22px 22px;
  color: #fff;
}

.sdt-agent__header::after {
  position: absolute;
  right: 72px;
  bottom: -34px;
  width: 130px;
  height: 70px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  content: "";
  transform: skewX(-28deg);
  pointer-events: none;
}

.sdt-agent__identity {
  position: relative;
  z-index: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
}

.sdt-agent__identity-seal {
  width: 44px;
  height: 44px;
  border-radius: 4px;
  font-size: 12px;
}

.sdt-agent__identity h2 {
  margin: 0;
  color: #fff;
  font-family: var(--font-body, "Manrope", Arial, sans-serif);
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.sdt-agent__identity p {
  margin: 3px 0 0;
  color: #aeb2ac;
  font-size: 9px;
  font-weight: 600;
}

.sdt-agent__close {
  position: relative;
  z-index: 2;
  width: 44px;
  height: 44px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  cursor: pointer;
  font-size: 25px;
  font-weight: 350;
  line-height: 1;
  transition: background 160ms ease, border-color 160ms ease;
}

.sdt-agent__close:hover {
  border-color: rgba(255, 255, 255, 0.38);
  background: rgba(255, 255, 255, 0.12);
}

.sdt-agent__content {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--paper, #f3f0e9);
}

.sdt-agent__disclaimer {
  margin: 0;
  padding: 10px 15px;
  border-bottom: 1px solid var(--line, rgba(24, 27, 25, 0.14));
  background: #e9e5dc;
  color: #5e625d;
  font-size: 10px;
  line-height: 1.45;
}

.sdt-agent__transcript {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 17px 15px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: rgba(24, 27, 25, 0.28) transparent;
  scrollbar-width: thin;
}

.sdt-agent__message {
  width: fit-content;
  max-width: 88%;
  display: grid;
  gap: 5px;
  padding: 11px 13px;
  border: 1px solid var(--line, rgba(24, 27, 25, 0.14));
  border-radius: 4px 9px 9px 9px;
  background: #fff;
  box-shadow: 0 7px 20px rgba(38, 34, 28, 0.055);
}

.sdt-agent__message--user {
  align-self: flex-end;
  border-color: #181b1a;
  border-radius: 9px 4px 9px 9px;
  background: #181b1a;
  color: #fff;
}

.sdt-agent__message--error {
  border-color: rgba(168, 50, 40, 0.32);
  background: #fff7f5;
}

.sdt-agent__message--urgent {
  border-color: rgba(168, 50, 40, 0.5);
  background: #fff3ef;
}

.sdt-agent__message-label {
  color: var(--accent-strong, #785638);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.sdt-agent__message--user .sdt-agent__message-label {
  color: #b9bcb7;
}

.sdt-agent__message-copy {
  margin: 0;
  color: inherit;
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.sdt-agent__sources {
  display: grid;
  gap: 6px;
  margin-top: 4px;
  padding-top: 9px;
  border-top: 1px solid var(--line, rgba(24, 27, 25, 0.14));
}

.sdt-agent__sources-label,
.sdt-agent__quick-label {
  color: var(--muted, #686d68);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sdt-agent__source {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line, rgba(24, 27, 25, 0.14));
  border-radius: 4px;
  background: var(--paper, #f3f0e9);
  color: var(--ink, #151716);
  font-size: 10px;
  font-weight: 750;
  line-height: 1.35;
  text-decoration: none;
  transition: border-color 160ms ease, background 160ms ease;
}

.sdt-agent__source::after {
  margin-left: auto;
  padding-left: 10px;
  content: "↗";
  font-size: 13px;
}

.sdt-agent__source:hover {
  border-color: var(--line-strong, rgba(24, 27, 25, 0.3));
  background: #fff;
}

.sdt-agent__quick-prompts {
  display: grid;
  gap: 7px;
}

.sdt-agent__quick-prompts[hidden],
.sdt-agent__handoff[hidden] {
  display: none;
}

.sdt-agent__quick-label {
  margin: 3px 0 1px;
}

.sdt-agent__quick-prompt,
.sdt-agent__retry {
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong, rgba(24, 27, 25, 0.24));
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--ink, #151716);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease;
}

.sdt-agent__quick-prompt:hover,
.sdt-agent__retry:hover {
  border-color: var(--ink, #151716);
  background: #fff;
}

.sdt-agent__quick-prompt:disabled,
.sdt-agent__retry:disabled {
  cursor: wait;
  opacity: 0.5;
}

.sdt-agent__retry {
  width: fit-content;
  margin-top: 4px;
  color: var(--danger, #a83228);
}

.sdt-agent__typing {
  min-width: 46px;
  min-height: 22px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.sdt-agent__typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-strong, #785638);
  animation: sdt-agent-typing 900ms ease-in-out infinite;
}

.sdt-agent__typing span:nth-child(2) {
  animation-delay: 120ms;
}

.sdt-agent__typing span:nth-child(3) {
  animation-delay: 240ms;
}

.sdt-agent__handoff {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 6px;
  background: #181b1a;
  color: #fff;
}

.sdt-agent__handoff strong {
  font-size: 14px;
  line-height: 1.25;
}

.sdt-agent__handoff p {
  margin: 0;
  color: #b9bcb7;
  font-size: 10px;
  line-height: 1.5;
}

.sdt-agent__handoff-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 3px;
}

.sdt-agent__handoff-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 4px;
  color: #fff;
  font-size: 10px;
  font-weight: 750;
  text-decoration: none;
}

.sdt-agent__handoff-link--primary {
  border-color: #fff;
  background: #fff;
  color: #181b1a;
}

.sdt-agent__form {
  display: grid;
  gap: 6px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line, rgba(24, 27, 25, 0.14));
  background: var(--surface, #fbfaf6);
}

.sdt-agent__input-label {
  color: var(--muted, #686d68);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sdt-agent__input {
  width: 100%;
  min-height: 58px;
  max-height: 112px;
  resize: vertical;
  padding: 10px 11px;
  border: 1px solid var(--line-strong, rgba(24, 27, 25, 0.24));
  border-radius: 4px;
  background: #fff;
  color: var(--ink, #151716);
  font-size: 16px;
  line-height: 1.4;
}

.sdt-agent__input::placeholder {
  color: #8a8e88;
}

.sdt-agent__input:focus {
  border-color: var(--ink, #151716);
  box-shadow: 0 0 0 3px rgba(21, 23, 22, 0.1);
  outline: 0;
}

.sdt-agent__input:disabled {
  cursor: wait;
  opacity: 0.58;
}

.sdt-agent__form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sdt-agent__input-hint {
  color: var(--muted, #686d68);
  font-size: 8px;
  line-height: 1.35;
}

.sdt-agent__send {
  min-width: 104px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 15px;
  border: 1px solid var(--ink, #151716);
  border-radius: 4px;
  background: var(--ink, #151716);
  color: #fff;
  cursor: pointer;
  font-size: 10px;
  font-weight: 750;
  transition: background 160ms ease, opacity 160ms ease;
}

.sdt-agent__send:hover:not(:disabled) {
  background: #2b2e2c;
}

.sdt-agent__send:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.sdt-agent__sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes sdt-agent-typing {
  0%,
  70%,
  100% {
    opacity: 0.32;
    transform: translateY(0);
  }

  35% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@media (max-width: 680px) {
  body.sdt-agent-open {
    overflow: hidden;
  }

  .sdt-agent {
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
  }

  .sdt-agent__launcher {
    min-width: 190px;
    min-height: 58px;
  }

  .sdt-agent__seal {
    width: 42px;
    height: 42px;
  }

  .sdt-agent__panel {
    position: fixed;
    inset: max(4px, env(safe-area-inset-top)) max(4px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left));
    width: auto;
    height: auto;
    min-height: 0;
    border-radius: 8px;
    transform: translateY(14px);
    transform-origin: center bottom;
  }

  .sdt-agent.is-open .sdt-agent__panel {
    transform: translateY(0);
  }

  .sdt-agent__header {
    min-height: 72px;
  }

  .sdt-agent__transcript {
    padding-inline: 13px;
  }

  .sdt-agent__message {
    max-width: 92%;
  }

  .sdt-agent__form {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 374px) {
  .sdt-agent__launcher {
    min-width: 174px;
  }

  .sdt-agent__launcher-copy strong {
    font-size: 12px;
  }

  .sdt-agent__input-hint {
    max-width: 130px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sdt-agent__launcher,
  .sdt-agent__panel,
  .sdt-agent__close,
  .sdt-agent__source,
  .sdt-agent__quick-prompt,
  .sdt-agent__retry,
  .sdt-agent__send {
    transition-duration: 0.01ms !important;
  }

  .sdt-agent__typing span {
    animation: none;
    opacity: 0.72;
    transform: none;
  }
}

@media (forced-colors: active) {
  .sdt-agent__launcher,
  .sdt-agent__panel,
  .sdt-agent__message,
  .sdt-agent__quick-prompt,
  .sdt-agent__handoff,
  .sdt-agent__input,
  .sdt-agent__send {
    border: 1px solid CanvasText;
  }
}

@media print {
  .sdt-agent {
    display: none !important;
  }
}
