/* Ash's Web Studio AI widget */
:root {
  --ash-ai-bg: #ffffff;
  --ash-ai-text: #111827;
  --ash-ai-muted: #8a8f98;
  --ash-ai-line: #e5e7eb;
  --ash-ai-soft: #f7f7f8;
  --ash-ai-shadow: 0 18px 48px rgba(15, 23, 42, 0.18), 0 2px 8px rgba(15, 23, 42, 0.08);
  --ash-ai-primary: #1f7a8c;
  --ash-ai-primary-dark: #145d6d;
  --ash-ai-radius: 999px;
  --ash-ai-font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.ash-ai-widget,
.ash-ai-widget * {
  box-sizing: border-box;
}

.ash-ai-widget {
  position: fixed;
  left: 50%;
  bottom: 12px;
  z-index: 999999;
  width: min(768px, calc(100vw - 28px));
  color: var(--ash-ai-text);
  font-family: var(--ash-ai-font);
  transform: translateX(-50%);
}

.ash-ai-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 64px;
  display: none;
  max-height: min(360px, calc(100svh - 104px));
  overflow: hidden;
  border: 1px solid var(--ash-ai-line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--ash-ai-shadow);
}

.ash-ai-widget.has-messages .ash-ai-panel {
  display: block;
}

.ash-ai-messages {
  max-height: min(312px, calc(100svh - 156px));
  overflow-y: auto;
  padding: 14px;
}

.ash-ai-message {
  display: flex;
  margin: 0 0 10px;
}

.ash-ai-message.is-user {
  justify-content: flex-end;
}

.ash-ai-bubble {
  width: fit-content;
  max-width: min(82%, 560px);
  padding: 10px 12px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: normal;
}

.ash-ai-message.is-assistant .ash-ai-bubble {
  border: 1px solid var(--ash-ai-line);
  background: #ffffff;
  color: var(--ash-ai-text);
}

.ash-ai-message.is-user .ash-ai-bubble {
  background: #111827;
  color: #ffffff;
}

.ash-ai-message.is-live .ash-ai-bubble {
  background: var(--ash-ai-primary);
  color: #ffffff;
  opacity: 0.92;
}

.ash-ai-message.is-error .ash-ai-bubble {
  border-color: rgba(220, 38, 38, 0.24);
  background: #fff5f5;
  color: #8a1f1f;
}

.ash-ai-thinking .ash-ai-bubble {
  color: var(--ash-ai-muted);
  font-style: italic;
}

.ash-ai-audio-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.ash-ai-play {
  height: 28px;
  border: 1px solid var(--ash-ai-line);
  border-radius: 999px;
  padding: 0 10px;
  background: #ffffff;
  color: #111827;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
}

.ash-ai-play:hover,
.ash-ai-play:focus-visible {
  border-color: #9ca3af;
  outline: 3px solid rgba(17, 24, 39, 0.1);
  outline-offset: 2px;
}

.ash-ai-note {
  min-height: 0;
  padding: 0 14px 12px;
  color: var(--ash-ai-muted);
  font-size: 12px;
  line-height: 1.35;
}

.ash-ai-note:empty {
  display: none;
}

.ash-ai-form {
  min-height: 52px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px 44px;
  align-items: center;
  gap: 6px;
  padding: 6px 7px 6px 18px;
  border: 1px solid var(--ash-ai-line);
  border-radius: var(--ash-ai-radius);
  background: var(--ash-ai-bg);
  box-shadow: var(--ash-ai-shadow);
}

.ash-ai-mic,
.ash-ai-send {
  border: 0;
  cursor: pointer;
  font: inherit;
  letter-spacing: 0;
  transition: background 140ms ease, color 140ms ease, opacity 140ms ease, transform 140ms ease;
}

.ash-ai-input {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  max-height: 86px;
  resize: none;
  border: 0;
  border-radius: 0;
  padding: 9px 10px 9px 0;
  background: transparent;
  color: var(--ash-ai-text);
  font: inherit;
  font-size: 15px;
  line-height: 1.35;
  outline: 0;
}

.ash-ai-input::placeholder {
  color: #8f949d;
}

.ash-ai-mic {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  color: #111827;
}

.ash-ai-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ash-ai-primary);
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(31, 122, 140, 0.34);
}

.ash-ai-mic svg,
.ash-ai-send svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ash-ai-mic:hover,
.ash-ai-mic:focus-visible {
  background: #f1f3f5;
  outline: 0;
}

.ash-ai-send:hover,
.ash-ai-send:focus-visible {
  background: var(--ash-ai-primary-dark);
  outline: 3px solid rgba(31, 122, 140, 0.16);
  outline-offset: 2px;
  transform: translateY(-1px);
}

.ash-ai-send:disabled,
.ash-ai-mic:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.ash-ai-mic.is-recording {
  background: #dc2626;
  color: #ffffff;
}

.ash-ai-mic.is-listening {
  background: var(--ash-ai-primary);
  color: #ffffff;
  animation: ash-ai-listening-pulse 1.25s ease-in-out infinite;
}

@keyframes ash-ai-listening-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(31, 122, 140, 0.34);
  }

  70% {
    box-shadow: 0 0 0 8px rgba(31, 122, 140, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(31, 122, 140, 0);
  }
}

@media (max-width: 620px) {
  .ash-ai-widget {
    bottom: 10px;
    width: calc(100vw - 20px);
  }

  .ash-ai-form {
    grid-template-columns: minmax(0, 1fr) 36px 42px;
    min-height: 50px;
    padding: 5px 6px 5px 14px;
  }

  .ash-ai-mic {
    width: 34px;
    height: 34px;
  }

  .ash-ai-send {
    width: 40px;
    height: 40px;
  }

  .ash-ai-input {
    font-size: 14px;
  }

  .ash-ai-panel {
    bottom: 62px;
    max-height: min(320px, calc(100svh - 96px));
  }
}
