/* Default, restyleable styles for CoryEmbed (cory_embed.js). Every class is
   prefixed .cory-embed* so it can't collide with a host page. Override freely. */

.cory-embed {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  width: 100%;
  max-width: 460px;
  margin-inline: auto;
}

.cory-embed-frame {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 60vh;
  border: 0;
  border-radius: 24px;
  background: transparent;
  display: block;
}

.cory-embed-chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cory-embed-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 2px;
  scrollbar-width: thin;
}
.cory-embed-log:empty { display: none; }

.cory-embed-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}
.cory-embed-msg-user {
  align-self: flex-end;
  background: var(--cory-embed-user-bg, #6366f1);
  color: var(--cory-embed-user-fg, #fff);
  border-bottom-right-radius: 4px;
}
.cory-embed-msg-cory {
  align-self: flex-start;
  background: var(--cory-embed-cory-bg, rgba(120, 120, 140, 0.14));
  color: var(--cory-embed-cory-fg, inherit);
  border-bottom-left-radius: 4px;
}

/* Pasted / dropped images waiting to be sent, shown above the input bar. */
.cory-embed-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 2px;
}
.cory-embed-attachments[hidden] { display: none; }

.cory-embed-attachment {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--cory-embed-bar-bg, rgba(120, 120, 140, 0.12));
}
.cory-embed-attachment img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cory-embed-attachment-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
}

/* An image carried inside a sent message bubble. */
.cory-embed-msg-image {
  display: block;
  max-width: 100%;
  border-radius: 10px;
  margin-top: 6px;
}
.cory-embed-msg-image:first-child { margin-top: 0; }
.cory-embed-msg-text + .cory-embed-msg-image { margin-top: 8px; }

.cory-embed-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: var(--cory-embed-bar-bg, rgba(120, 120, 140, 0.12));
}

.cory-embed-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 15px;
  padding: 8px 12px;
  outline: none;
}
.cory-embed-input::placeholder { color: currentColor; opacity: 0.55; }

.cory-embed-mic,
.cory-embed-send {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: grid;
  place-items: center;
  background: var(--cory-embed-btn-bg, rgba(120, 120, 140, 0.18));
  color: inherit;
  transition: transform 0.12s ease, background 0.2s ease;
}
.cory-embed-mic:hover,
.cory-embed-send:hover { transform: scale(1.06); }
.cory-embed-send { background: var(--cory-embed-accent, #6366f1); color: #fff; }
.cory-embed-mic.on {
  background: #ef4444; color: #fff;
  animation: cory-embed-pulse 1.1s ease-in-out infinite;
}

@keyframes cory-embed-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  50%      { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* Subtle state cue on the stage (optional; orb already animates internally). */
.cory-embed[data-state="thinking"] .cory-embed-frame,
.cory-embed[data-state="working"] .cory-embed-frame { opacity: 0.98; }

@media (prefers-color-scheme: dark) {
  .cory-embed-msg-cory { background: var(--cory-embed-cory-bg, rgba(255, 255, 255, 0.10)); }
  .cory-embed-bar { background: var(--cory-embed-bar-bg, rgba(255, 255, 255, 0.08)); }
}
