.seraphine-overlay {
  --seraphine-overlay-backdrop: rgb(0 2 7 / 9%);
  --seraphine-overlay-backdrop-blur: 0px;
  --seraphine-overlay-surface: transparent;
  --seraphine-overlay-text: #e9e9e7;
  --seraphine-overlay-muted: #929ba5;
  --seraphine-overlay-border: rgb(224 234 250 / 15%);
  --seraphine-overlay-chat-accent: #b7a8d8;
  --seraphine-overlay-voice-accent: #9cb9d9;
  --seraphine-overlay-active-accent: var(--seraphine-overlay-chat-accent);
  --seraphine-overlay-panel-width: 920px;
  --seraphine-overlay-panel-height: 820px;
  --seraphine-overlay-desktop-edge: 26px;
  --seraphine-overlay-mobile-edge: 7px;
  --seraphine-overlay-desktop-radius: 30px;
  --seraphine-overlay-mobile-radius: 21px;
  box-sizing: border-box;
  position: fixed;
  z-index: 2147483000;
  top: var(--seraphine-overlay-viewport-top, 0px);
  left: 0;
  display: grid;
  width: 100vw;
  height: var(--seraphine-overlay-viewport-height, 100dvh);
  max-width: none;
  max-height: none;
  place-items: center;
  margin: 0;
  padding: max(var(--seraphine-overlay-desktop-edge), env(safe-area-inset-top, 0px)) max(var(--seraphine-overlay-desktop-edge), env(safe-area-inset-right, 0px)) max(var(--seraphine-overlay-desktop-edge), env(safe-area-inset-bottom, 0px)) max(var(--seraphine-overlay-desktop-edge), env(safe-area-inset-left, 0px));
  overflow: hidden;
  border: 0;
  background: transparent;
  color: var(--seraphine-overlay-text);
  color-scheme: dark;
  font-family: inherit;
  opacity: 0;
  overscroll-behavior: none;
  transform: translateY(9px) scale(0.99);
  transition: opacity 260ms cubic-bezier(0.2, 0.7, 0.2, 1), transform 260ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.seraphine-overlay:not([open]) {
  display: none;
}

.seraphine-overlay *::-webkit-scrollbar { display: block; width: 6px; height: 6px; }
.seraphine-overlay *::-webkit-scrollbar-thumb { background: #5d708c; border-radius: 5px; }
.seraphine-overlay *::-webkit-scrollbar-track { background: transparent; }

.seraphine-overlay[open] {
  display: grid;
}

.seraphine-overlay[data-mode="chat"] {
  --seraphine-overlay-active-accent: var(--seraphine-overlay-chat-accent);
}

.seraphine-overlay[data-mode="voice"] {
  --seraphine-overlay-active-accent: var(--seraphine-overlay-voice-accent);
}

.seraphine-overlay[data-state="open"] {
  opacity: 1;
  transform: none;
}

.seraphine-overlay::backdrop {
  background: transparent;
}

.seraphine-overlay__shade {
  position: absolute;
  z-index: 0;
  inset: 0;
  background: var(--seraphine-overlay-backdrop);
  -webkit-backdrop-filter: blur(var(--seraphine-overlay-backdrop-blur));
  backdrop-filter: blur(var(--seraphine-overlay-backdrop-blur));
}

.seraphine-overlay__panel {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(100%, var(--seraphine-overlay-panel-width));
  height: min(100%, var(--seraphine-overlay-panel-height));
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--seraphine-overlay-border);
  border-radius: var(--seraphine-overlay-desktop-radius);
  background: var(--seraphine-overlay-surface);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 4%);
}

.seraphine-overlay__header {
  position: relative;
  z-index: 2;
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 25px clamp(22px, 3.2vw, 38px) 22px;
  border-bottom: 1px solid var(--seraphine-overlay-border);
  background: transparent;
}

.seraphine-overlay__heading {
  min-width: 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgb(1 4 10 / 28%);
}

.seraphine-overlay__mode {
  display: block;
  margin: 0 0 7px;
  color: var(--seraphine-overlay-active-accent);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.2em;
  line-height: 1.5;
  text-transform: uppercase;
}

.seraphine-overlay__title {
  overflow: hidden;
  margin: 0;
  color: var(--seraphine-overlay-text);
  font-size: clamp(22px, 3vw, 31px);
  font-weight: 400;
  letter-spacing: -0.045em;
  line-height: 1.1;
  text-overflow: ellipsis;
}

.seraphine-overlay__close {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 1px solid rgb(233 233 231 / 22%);
  border-radius: 50%;
  background: rgb(255 255 255 / 3%);
  color: var(--seraphine-overlay-text);
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.seraphine-overlay__close:hover {
  border-color: var(--seraphine-overlay-active-accent);
  background: color-mix(in srgb, var(--seraphine-overlay-active-accent), transparent 91%);
  color: var(--seraphine-overlay-active-accent);
}

.seraphine-overlay__close:focus-visible {
  outline: 2px solid var(--seraphine-overlay-active-accent);
  outline-offset: 4px;
}

.seraphine-overlay__close svg {
  display: block;
  width: 17px;
  height: 17px;
}

.seraphine-overlay__scroll {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: clamp(18px, 3vw, 34px);
  overscroll-behavior: contain;
  scrollbar-color: rgb(210 220 238 / 28%) transparent;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.seraphine-overlay__slot {
  display: grid;
  min-height: min(58dvh, 560px);
  place-items: center;
  padding: 22px;
  border: 1px solid var(--seraphine-overlay-border);
  border-radius: 20px;
  background: linear-gradient(145deg, rgb(255 255 255 / 2.5%), transparent 55%);
  color: var(--seraphine-overlay-muted);
  text-align: center;
}

.seraphine-overlay__slot:empty::before {
  max-width: 24ch;
  content: attr(data-placeholder);
  font-size: 12px;
  letter-spacing: 0.04em;
  line-height: 1.7;
}

.seraphine-overlay__close:focus:not(:focus-visible) {
  outline: none;
}

@media (max-width: 760px) {
  .seraphine-overlay {
    --seraphine-overlay-desktop-edge: var(--seraphine-overlay-mobile-edge);
    padding: max(var(--seraphine-overlay-mobile-edge), env(safe-area-inset-top, 0px)) max(var(--seraphine-overlay-mobile-edge), env(safe-area-inset-right, 0px)) max(var(--seraphine-overlay-mobile-edge), env(safe-area-inset-bottom, 0px)) max(var(--seraphine-overlay-mobile-edge), env(safe-area-inset-left, 0px));
  }

  .seraphine-overlay__panel {
    width: 100%;
    height: 100%;
    border-radius: var(--seraphine-overlay-mobile-radius);
  }

  .seraphine-overlay__header {
    padding: max(18px, env(safe-area-inset-top, 0px)) 18px 16px;
  }

  .seraphine-overlay__close {
    width: 46px;
    height: 46px;
  }

  .seraphine-overlay__scroll {
    padding: 16px 15px max(18px, env(safe-area-inset-bottom, 0px));
  }

  .seraphine-overlay__slot {
    min-height: min(58dvh, 520px);
    border-radius: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .seraphine-overlay,
  .seraphine-overlay__close {
    transition: none;
  }
}

@media (forced-colors: active) {
  .seraphine-overlay__panel {
    border: 1px solid CanvasText;
  }

  .seraphine-overlay__close {
    border: 1px solid ButtonText;
    color: ButtonText;
  }
}

.seraphine-overlay__slot[data-mounted="true"] {
  display: block;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.seraphine-overlay .seraphine-agent-surface {
  display: flex;
  min-height: min(58dvh, 560px);
  flex-direction: column;
  gap: 18px;
}

.seraphine-overlay .seraphine-agent-intro {
  display: grid;
  gap: 8px;
  align-self: flex-start;
  padding: 12px 15px;
  border-radius: 12px;
  background: rgb(1 4 10 / 28%);
}

.seraphine-overlay .seraphine-agent-kicker {
  margin: 0;
  color: var(--seraphine-overlay-active-accent);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.2em;
  line-height: 1.5;
  text-transform: uppercase;
}

.seraphine-overlay .seraphine-agent-copy {
  max-width: 64ch;
  margin: 0;
  color: var(--seraphine-overlay-muted);
  font-size: 13px;
  line-height: 1.65;
}

.seraphine-overlay .seraphine-agent-messages {
  display: flex;
  min-height: 260px;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  overflow: auto;
  border: 1px solid var(--seraphine-overlay-border);
  border-radius: 18px;
  background: transparent;
  overscroll-behavior: contain;
  scrollbar-color: rgb(210 220 238 / 28%) transparent;
  scrollbar-width: thin;
}

.seraphine-overlay .seraphine-agent-empty {
  margin: auto;
  color: var(--seraphine-overlay-muted);
  font-size: 12px;
  line-height: 1.7;
  text-align: center;
}

.seraphine-overlay .seraphine-agent-message {
  display: grid;
  max-width: min(78%, 660px);
  gap: 7px;
  padding: 13px 15px;
  border: 1px solid var(--seraphine-overlay-border);
  border-radius: 15px;
  background: rgb(1 5 13 / 48%);
}

.seraphine-overlay .seraphine-agent-message--user {
  align-self: flex-end;
  border-color: color-mix(in srgb, var(--seraphine-overlay-active-accent), transparent 70%);
  background: rgb(13 21 40 / 50%);
}

.seraphine-overlay .seraphine-agent-message__label,
.seraphine-overlay .seraphine-agent-exchange__label {
  color: var(--seraphine-overlay-active-accent);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.16em;
  line-height: 1.4;
  text-transform: uppercase;
}

.seraphine-overlay .seraphine-agent-message__content,
.seraphine-overlay .seraphine-agent-exchange__text {
  margin: 0;
  color: var(--seraphine-overlay-text);
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.seraphine-overlay .seraphine-agent-message__tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.seraphine-overlay .seraphine-agent-speak {
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--seraphine-overlay-border);
  border-radius: 9px;
  background: rgb(255 255 255 / 4%);
  color: var(--seraphine-overlay-muted);
  cursor: pointer;
  font: inherit;
  font-size: 10px;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, opacity 160ms ease;
}

.seraphine-overlay .seraphine-agent-speak:hover:not(:disabled),
.seraphine-overlay .seraphine-agent-speak:focus-visible {
  border-color: var(--seraphine-overlay-active-accent);
  background: color-mix(in srgb, var(--seraphine-overlay-active-accent), transparent 86%);
  color: var(--seraphine-overlay-text);
}

.seraphine-overlay .seraphine-agent-speak:disabled {
  cursor: wait;
  opacity: 0.58;
}

.seraphine-overlay .seraphine-agent-message__audio {
  width: min(100%, 260px);
  min-height: 30px;
}

.seraphine-overlay .seraphine-agent-composer {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding-top: 3px;
  background: var(--seraphine-overlay-surface);
}

.seraphine-overlay .seraphine-agent-input {
  box-sizing: border-box;
  width: 100%;
  min-height: 56px;
  resize: none;
  padding: 14px 15px;
  border: 1px solid var(--seraphine-overlay-border);
  border-radius: 14px;
  outline: 0;
  background: rgb(1 5 13 / 50%);
  color: var(--seraphine-overlay-text);
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
}

.seraphine-overlay .seraphine-agent-input::placeholder {
  color: var(--seraphine-overlay-muted);
}

.seraphine-overlay .seraphine-agent-input:focus-visible {
  border-color: var(--seraphine-overlay-active-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--seraphine-overlay-active-accent), transparent 82%);
}

.seraphine-overlay .seraphine-agent-submit {
  align-self: stretch;
  min-width: 82px;
  padding: 0 17px;
  border: 1px solid color-mix(in srgb, var(--seraphine-overlay-active-accent), transparent 52%);
  border-radius: 14px;
  background: color-mix(in srgb, var(--seraphine-overlay-active-accent), transparent 88%);
  color: var(--seraphine-overlay-text);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, opacity 160ms ease;
}

.seraphine-overlay .seraphine-agent-submit:hover:not(:disabled),
.seraphine-overlay .seraphine-agent-submit:focus-visible {
  border-color: var(--seraphine-overlay-active-accent);
  background: color-mix(in srgb, var(--seraphine-overlay-active-accent), transparent 78%);
  color: #fff;
}

.seraphine-overlay .seraphine-agent-submit:focus-visible,
.seraphine-overlay .seraphine-agent-record:focus-visible,
.seraphine-overlay .seraphine-agent-speak:focus-visible {
  outline: 2px solid var(--seraphine-overlay-active-accent);
  outline-offset: 4px;
}

.seraphine-overlay .seraphine-agent-submit:disabled,
.seraphine-overlay .seraphine-agent-input:disabled {
  cursor: wait;
  opacity: 0.52;
}

.seraphine-overlay .seraphine-agent-status {
  min-height: 1.4em;
  margin: 0;
  color: var(--seraphine-overlay-muted);
  font-size: 11px;
  line-height: 1.5;
  align-self: flex-start;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgb(1 4 10 / 28%);
}

.seraphine-overlay .seraphine-agent-status[data-status="error"] {
  color: #e6a8a8;
}

.seraphine-overlay .seraphine-agent-voice-stage {
  display: grid;
  min-height: min(37dvh, 330px);
  place-items: center;
  align-content: center;
  gap: 11px;
  padding: 28px;
  border: 1px solid var(--seraphine-overlay-border);
  border-radius: 20px;
  background: transparent;
  text-align: center;
}

.seraphine-overlay .seraphine-agent-voice-state {
  margin: 0;
  color: var(--seraphine-overlay-text);
  font-size: 16px;
  line-height: 1.4;
}

.seraphine-overlay .seraphine-agent-voice-help {
  max-width: 36ch;
  margin: 0 0 9px;
  color: var(--seraphine-overlay-muted);
  font-size: 12px;
  line-height: 1.65;
}

.seraphine-overlay .seraphine-agent-record {
  display: grid;
  width: 86px;
  height: 86px;
  place-items: center;
  align-content: center;
  gap: 7px;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--seraphine-overlay-active-accent), transparent 35%);
  border-radius: 50%;
  background: color-mix(in srgb, var(--seraphine-overlay-active-accent), transparent 87%);
  color: var(--seraphine-overlay-text);
  cursor: pointer;
  font: inherit;
  transition: background-color 160ms ease, border-color 160ms ease, opacity 160ms ease, transform 160ms ease;
}

.seraphine-overlay .seraphine-agent-record:hover:not(:disabled) {
  border-color: var(--seraphine-overlay-active-accent);
  background: color-mix(in srgb, var(--seraphine-overlay-active-accent), transparent 76%);
  transform: translateY(-2px);
}

.seraphine-overlay .seraphine-agent-record[data-recording="true"] {
  border-color: #e3a9af;
  background: rgb(176 83 96 / 24%);
}

.seraphine-overlay .seraphine-agent-record:disabled {
  cursor: wait;
  opacity: 0.55;
}

.seraphine-overlay .seraphine-agent-record__icon {
  display: block;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: currentColor;
}

.seraphine-overlay .seraphine-agent-record[data-recording="true"] .seraphine-agent-record__icon {
  width: 13px;
  height: 13px;
  border-radius: 3px;
}

.seraphine-overlay .seraphine-agent-record__label {
  max-width: 68px;
  font-size: 9px;
  line-height: 1.2;
  text-align: center;
}

.seraphine-overlay .seraphine-agent-voice-exchange {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px 14px;
  padding: 16px 17px;
  border: 1px solid var(--seraphine-overlay-border);
  border-radius: 16px;
  background: rgb(1 5 13 / 42%);
}

.seraphine-overlay .seraphine-agent-exchange__text[data-empty="true"] {
  color: var(--seraphine-overlay-muted);
}

.seraphine-overlay .seraphine-agent-audio {
  width: 100%;
  min-height: 38px;
}

@media (max-width: 760px) {
  .seraphine-overlay .seraphine-agent-surface {
    min-height: min(58dvh, 520px);
    gap: 15px;
  }

  .seraphine-overlay .seraphine-agent-messages {
    min-height: min(38dvh, 360px);
    padding: 14px;
    border-radius: 16px;
  }

  .seraphine-overlay .seraphine-agent-message {
    max-width: 88%;
  }

  .seraphine-overlay .seraphine-agent-message__audio {
    width: 100%;
  }

  .seraphine-overlay .seraphine-agent-composer {
    grid-template-columns: minmax(0, 1fr);
  }
  .seraphine-overlay .seraphine-agent-input { font-size: 16px; }

  .seraphine-overlay .seraphine-agent-submit {
    min-height: 48px;
  }

  .seraphine-overlay .seraphine-agent-voice-stage {
    min-height: min(44dvh, 420px);
    padding: 22px 16px;
    border-radius: 16px;
  }

  .seraphine-overlay .seraphine-agent-voice-exchange {
    grid-template-columns: 1fr;
    gap: 5px;
    padding: 14px;
  }

  .seraphine-overlay .seraphine-agent-exchange__label:not(:first-child) {
    margin-top: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .seraphine-overlay .seraphine-agent-submit,
  .seraphine-overlay .seraphine-agent-record,
  .seraphine-overlay .seraphine-agent-speak {
    transition: none;
  }
}
