/* =================================================== */
/* Sally CHAT FLYOUT - Liquid Glass Design             */
/* Talk to Sally: Chat, Voice, Avatar                  */
/* =================================================== */

/* ─── Backdrop ──────────────────────────────────────── */

.sally-chat-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.3);
  z-index: 99996;
  display: none;
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sally-chat-backdrop.show {
  display: block;
  opacity: 1;
}

/* ─── Flyout Container ──────────────────────────────── */

.sally-chat-flyout {
  position: fixed;
  top: 15px;
  right: 15px;
  bottom: 15px;
  width: var(--chat-flyout-width, 440px);
  max-width: 90vw;
  height: auto;
  max-height: calc(100vh - 30px);
  background: rgba(28, 28, 30, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.1) inset,
    0 1px 0 rgba(255, 255, 255, 0.2) inset,
    0 -1px 0 rgba(0, 0, 0, 0.2) inset;
  border-radius: 10px;
  z-index: 99997;
  display: none;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  box-sizing: border-box;
}

.sally-chat-flyout.show {
  display: flex;
  transform: translateX(0);
}

/* ─── Chat Inner Wrapper ──────────────────────────── */

.sally-chat-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* ─── Dev Mode — Full-width Preview + Kanban ────────── */
/* Preview uses full width (Sally overlays on top).
   Draggable divider between Preview and Kanban. */

/* Container for both panels */
.sally-dev-panel {
  display: none;
  flex-direction: column;
  gap: 0;
  position: fixed;
  top: 15px;
  bottom: 15px;
  left: 60px;
  right: var(--dev-panel-right, 470px); /* Stop at Sally's left edge (440px + 15px + 15px gap) */
  z-index: 99996;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none; /* Container is transparent */
}

.sally-chat-flyout.dev-mode .sally-dev-panel {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

/* ── Preview Panel (top, fills remaining space) ── */
.sally-dev-preview {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 100px;
  background: rgba(28, 28, 30, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  border-radius: 10px;
  pointer-events: auto;
}

.sally-dev-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.sally-dev-preview-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.45);
}

.sally-dev-preview-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.sally-dev-preview-mode,
.sally-dev-preview-refresh {
  background: none;
  border: 1px solid transparent;
  color: rgba(255, 255, 255, 0.3);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 0;
}

.sally-dev-preview-refresh {
  font-size: 14px;
  margin-left: 4px;
}

.sally-dev-preview-mode:hover,
.sally-dev-preview-refresh:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.7);
}

.sally-dev-preview-mode.active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.8);
}

/* Wrapper for scaled HD iframe */
.sally-dev-preview-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  border-radius: 0 0 10px 10px;
  background: #0a0a0a;
  min-height: 0;
}

.sally-dev-preview-frame {
  position: absolute;
  top: 0;
  left: 0;
  /* Width/height and scale set dynamically by JS based on user's screen resolution */
  border: none;
  transform-origin: 0 0;
}

/* ── Dual Device Frames (Mobile Mode) ── */
.sally-dev-devices {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 36px;
  width: 100%;
  height: 100%;
  padding: 12px 16px 4px;
  box-sizing: border-box;
}

.device-frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════
   iPhone 14 Pro — Space Black
   Real proportions: 71.5mm × 147.5mm
   Bezel: ~2mm sides, ~3mm top/bottom
   ═══════════════════════════════════════════ */
.device-phone .device-bezel {
  position: relative;
  background: #000;
  border-radius: 24px;
  /* Thin bezel: 5px sides, 8px top (Dynamic Island space), 6px bottom (home bar) */
  padding: 8px 5px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Titanium frame edge */
  border: 2px solid #4a4a4a;
  box-shadow:
    /* Outer titanium reflection */
    0 0 0 0.5px rgba(255, 255, 255, 0.12),
    /* Depth shadow */
    0 16px 56px rgba(0, 0, 0, 0.7),
    0 4px 16px rgba(0, 0, 0, 0.5),
    /* Subtle ambient light from above */
    0 -2px 8px rgba(255, 255, 255, 0.02);
}

/* Power button (right side) */
.device-phone .device-bezel::before {
  content: '';
  position: absolute;
  right: -4px;
  top: 22%;
  width: 3px;
  height: 28px;
  background: linear-gradient(90deg, #555, #3a3a3a);
  border-radius: 0 2px 2px 0;
}

/* Volume buttons (left side) */
.device-phone .device-bezel::after {
  content: '';
  position: absolute;
  left: -4px;
  top: 18%;
  width: 3px;
  height: 22px;
  background: linear-gradient(90deg, #3a3a3a, #555);
  border-radius: 2px 0 0 2px;
}

/* Dynamic Island — centered pill */
.device-notch {
  width: 62px;
  height: 16px;
  background: #000;
  border-radius: 10px;
  margin-bottom: 4px;
  border: 1px solid rgba(40, 40, 40, 0.6);
}

/* Home indicator */
.device-home-bar {
  width: 72px;
  height: 3px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 1.5px;
  margin-top: 4px;
}

/* Phone screen — proportional radius for rendered size */
.device-phone .device-screen {
  border-radius: 18px;
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.04);
}


/* ═══════════════════════════════════════════
   iPad Air — Space Gray (Landscape)
   Real proportions: 247.6mm × 178.5mm
   Bezel: ~8mm uniform
   ═══════════════════════════════════════════ */
.device-tablet .device-bezel {
  position: relative;
  background: #000;
  border-radius: 18px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Aluminum frame edge */
  border: 2px solid #4a4a4a;
  box-shadow:
    0 0 0 0.5px rgba(255, 255, 255, 0.12),
    0 16px 56px rgba(0, 0, 0, 0.7),
    0 4px 16px rgba(0, 0, 0, 0.5),
    0 -2px 8px rgba(255, 255, 255, 0.02);
}

/* Power button (top edge in landscape) */
.device-tablet .device-bezel::before {
  content: '';
  position: absolute;
  top: -4px;
  right: 12%;
  height: 3px;
  width: 24px;
  background: linear-gradient(0deg, #555, #3a3a3a);
  border-radius: 2px 2px 0 0;
}

/* FaceTime camera — landscape top center */
.device-camera {
  width: 4px;
  height: 4px;
  background: radial-gradient(circle, #1a1a1a 40%, #111 100%);
  border-radius: 50%;
  margin-bottom: 3px;
  border: 0.5px solid #333;
}

/* Tablet screen — inner radius = outer (18) - padding (6) = 12 */
.device-tablet .device-screen {
  border-radius: 12px;
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.04);
}


/* ═══════════════════════════════════════════
   Shared Device Screen + Labels
   ═══════════════════════════════════════════ */
.device-screen {
  overflow: hidden;
  position: relative;
  background: #000;
}

.device-screen iframe {
  position: absolute;
  top: 0;
  left: 0;
  border: none;
  transform-origin: 0 0;
}

/* Device label below frame */
.device-frame::after {
  content: attr(data-label);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.15);
  margin-top: 10px;
}

/* ── Drag Divider between Preview and Kanban ── */
.sally-dev-divider {
  flex: 0 0 6px;
  cursor: row-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  position: relative;
  z-index: 2;
}

.sally-dev-divider::after {
  content: '';
  width: 40px;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.15);
  transition: background 0.2s;
}

.sally-dev-divider:hover::after,
.sally-dev-divider.dragging::after {
  background: rgba(255, 255, 255, 0.4);
}

/* ── Horizontal Drag Divider between Dev Panel and Sally Chat ── */
.sally-dev-hdivider {
  display: none;
  position: fixed;
  top: 15px;
  bottom: 15px;
  width: 8px;
  cursor: col-resize;
  z-index: 99998;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.sally-dev-hdivider::after {
  content: '';
  width: 3px;
  height: 40px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.15);
  transition: background 0.2s;
}

.sally-dev-hdivider:hover::after,
.sally-dev-hdivider.dragging::after {
  background: rgba(255, 255, 255, 0.4);
}

/* ── Kanban Panel (bottom, ~25%) ── */
.sally-dev-kanban {
  flex: 0 0 200px; /* Default height, overridden by JS drag */
  overflow: hidden;
  min-height: 120px;
  max-height: 50%;
  background: rgba(28, 28, 30, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  border-radius: 10px;
  pointer-events: auto;
}

.sally-dev-kanban-frame {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 10px;
}

/* Dev Mode Toggle Active State */
.sally-dev-toggle.active {
  background: rgba(34, 197, 94, 0.15) !important;
  color: #22c55e !important;
}

.sally-dev-toggle.active:hover {
  background: rgba(34, 197, 94, 0.25) !important;
}

/* 3D glass depth effects */
.sally-chat-flyout::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.15) 0%,
    rgba(255, 255, 255, 0.08) 20%,
    rgba(255, 255, 255, 0.03) 40%,
    transparent 60%
  );
  border-radius: 10px 10px 0 0;
  pointer-events: none;
  z-index: 1;
}

.sally-chat-flyout::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.1) 0%,
    transparent 50%,
    rgba(0, 0, 0, 0.1) 100%
  );
  border-radius: 10px;
  pointer-events: none;
  z-index: 0;
}

.sally-chat-flyout > * {
  position: relative;
  z-index: 2;
}

/* ─── Header ────────────────────────────────────────── */

.sally-chat-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(28, 28, 30, 0.4);
  backdrop-filter: blur(10px);
}

.sally-chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sally-chat-avatar-mini {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(139, 92, 246, 0.3));
  border: 1px solid rgba(139, 92, 246, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sally-chat-header-info h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
}

.sally-chat-header-info .sally-chat-status {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  display: flex;
  align-items: center;
  gap: 4px;
}

.sally-chat-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #48bb78;
  display: inline-block;
}

.sally-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sally-chat-header-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sally-chat-header-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
}

/* Model Selector */
.sally-model-selector {
  position: relative;
}

.sally-model-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px !important;
  border-radius: 6px;
}

.sally-model-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.sally-model-dropdown {
  position: fixed;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 4px;
  min-width: 160px;
  z-index: 999999;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.15s, transform 0.15s;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.sally-model-dropdown.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.sally-model-option {
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  gap: 1px;
}

.sally-model-option:hover {
  background: rgba(255, 255, 255, 0.06);
}

.sally-model-option.selected {
  background: rgba(255, 255, 255, 0.08);
  border-left: 2px solid #48bb78;
}

.sally-model-btn.fallback-active {
  border: 1px solid #ed8936;
  background: rgba(237, 137, 54, 0.1);
}

.sally-model-btn.fallback-active .sally-model-label {
  color: #ed8936;
}

.sally-fallback-banner {
  padding: 8px 10px;
  margin-bottom: 4px;
  border-radius: 6px;
  background: rgba(237, 137, 54, 0.08);
  border-left: 2px solid #ed8936;
  font-size: 12px;
  line-height: 1.4;
}

.sally-model-name {
  font-size: 13px;
  font-weight: 500;
  color: #fff;
}

.sally-model-desc {
  font-size: 10px;
  color: #999;
}

.sally-model-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  margin: 4px 0;
}

.sally-costs-btn .sally-model-name {
  color: #a78bfa;
}

.sally-chat-close-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  transition: all 0.2s;
}

.sally-chat-close-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
}

/* ─── Conversations Sidebar ─────────────────────────── */

.sally-conversations-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(28, 28, 30, 0.98);
  z-index: 10;
  display: none;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sally-conversations-panel.show {
  display: flex;
  transform: translateX(0);
}

.sally-conversations-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sally-conversations-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
}

.sally-conversations-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.sally-conversation-item {
  padding: 12px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 2px;
}

.sally-conversation-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.sally-conversation-item.active {
  background: rgba(99, 102, 241, 0.15);
}

.sally-conversation-title {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sally-conversation-meta {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
}

/* ─── Avatar Split View ─────────────────────────────── */

.sally-avatar-split {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  margin: 12px 15px 8px;
  height: 200px;
}

.sally-avatar-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
  border-radius: 12px;
  padding: 4px;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Active indicator glow */
.sally-avatar-side.active {
  background: rgba(139, 92, 246, 0.04);
}

.sally-avatar-side.active::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 12px;
  border: 1.5px solid rgba(139, 92, 246, 0.3);
  pointer-events: none;
  animation: sally-active-glow 2s ease-in-out infinite;
}

.sally-avatar-side.user-side.active {
  background: rgba(72, 187, 120, 0.04);
}

.sally-avatar-side.user-side.active::after {
  border-color: rgba(72, 187, 120, 0.3);
  animation: user-active-glow 2s ease-in-out infinite;
}

@keyframes sally-active-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
  50% { box-shadow: 0 0 12px 2px rgba(139, 92, 246, 0.15); }
}

@keyframes user-active-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(72, 187, 120, 0); }
  50% { box-shadow: 0 0 12px 2px rgba(72, 187, 120, 0.15); }
}

.sally-avatar-label {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: color 0.3s ease;
}

.sally-avatar-side.active .sally-avatar-label {
  color: rgba(255, 255, 255, 0.8);
}

/* ─── Sally Avatar Container (inside split) ─────────── */

.sally-avatar-container {
  flex: 1;
  width: 100%;
  background: linear-gradient(180deg, rgba(16, 16, 22, 0.98) 0%, rgba(20, 20, 26, 0.85) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border-radius: 10px;
}

/* ─── User Avatar (right side — matching Sally's rectangle) ─── */

.sally-user-avatar-circle {
  flex: 1;
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  background: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.sally-user-avatar-circle img {
  width: 72%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 50%;
  display: none;
  flex-shrink: 0;
}

.sally-user-avatar-circle img.loaded {
  display: block;
}

.sally-user-avatar-fallback {
  font-size: 42px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.25);
  text-transform: uppercase;
}

/* ─── Thought Bubbles (thinking state) ──────────────── */

.sally-thought-bubbles {
  display: none;
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
}

.sally-avatar-container[data-state="thinking"] .sally-thought-bubbles {
  display: flex;
}

.sally-thought-dot {
  border-radius: 50%;
  background: rgba(139, 92, 246, 0.6);
  animation: sally-thought-float 1.5s ease-in-out infinite;
}

.sally-thought-dot.dot-1 {
  width: 6px;
  height: 6px;
  margin-right: 4px;
  margin-bottom: 3px;
  animation-delay: 0.3s;
}

.sally-thought-dot.dot-2 {
  width: 10px;
  height: 10px;
  margin-right: 0;
  margin-bottom: 4px;
  animation-delay: 0.15s;
}

.sally-thought-bubble {
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: 16px;
  padding: 6px 14px;
  animation: sally-thought-float 1.5s ease-in-out infinite;
}

.sally-thought-ellipsis {
  display: flex;
  gap: 4px;
  align-items: center;
}

.sally-thought-ellipsis span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(139, 92, 246, 0.7);
  animation: sally-thought-bounce 1.2s ease-in-out infinite;
}

.sally-thought-ellipsis span:nth-child(2) { animation-delay: 0.2s; }
.sally-thought-ellipsis span:nth-child(3) { animation-delay: 0.4s; }

@keyframes sally-thought-float {
  0%, 100% { transform: translateY(0); opacity: 0.7; }
  50% { transform: translateY(-3px); opacity: 1; }
}

@keyframes sally-thought-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* Three.js canvas inside avatar container (TalkingHead + procedural) */
.sally-avatar-container > canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
  z-index: 1;
  border-radius: 10px;
}

/* Placeholder avatar until Phase 5 */
.sally-avatar-placeholder {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
  border: 2px solid rgba(139, 92, 246, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  position: relative;
}

/* Halo ring animation */
.sally-avatar-placeholder::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid rgba(139, 92, 246, 0.2);
  animation: sally-halo-pulse 3s ease-in-out infinite;
}

@keyframes sally-halo-pulse {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.08); }
}

/* State indicators */
.sally-avatar-container[data-state="thinking"] .sally-avatar-placeholder {
  animation: sally-thinking 1.5s ease-in-out infinite;
}

@keyframes sally-thinking {
  0%, 100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
  50% { box-shadow: 0 0 20px 4px rgba(139, 92, 246, 0.3); }
}

.sally-avatar-container[data-state="talking"] .sally-avatar-placeholder::after {
  animation: sally-halo-talking 0.4s ease-in-out infinite alternate;
}

@keyframes sally-halo-talking {
  0% { transform: scale(1); border-color: rgba(139, 92, 246, 0.2); }
  100% { transform: scale(1.12); border-color: rgba(139, 92, 246, 0.5); }
}

/* Listening state — user is speaking */
.sally-avatar-container[data-state="listening"] .sally-avatar-placeholder {
  border-color: rgba(239, 68, 68, 0.5);
  animation: sally-listening 0.8s ease-in-out infinite alternate;
}

@keyframes sally-listening {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); transform: scale(1); }
  100% { box-shadow: 0 0 15px 3px rgba(239, 68, 68, 0.2); transform: scale(1.03); }
}

.sally-avatar-container[data-state="listening"]::before {
  content: '';
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 3px;
}

/* Voice recording bar animation */
.sally-voice-bars {
  display: none;
  position: absolute;
  bottom: 16px;
  z-index: 2;
  left: 50%;
  transform: translateX(-50%);
  gap: 2px;
  align-items: flex-end;
  height: 16px;
}

.sally-avatar-container[data-state="listening"] .sally-voice-bars {
  display: flex;
}

.sally-voice-bar {
  width: 3px;
  background: rgba(239, 68, 68, 0.6);
  border-radius: 2px;
  animation: sally-voice-bar 0.6s ease-in-out infinite alternate;
}

.sally-voice-bar:nth-child(1) { height: 4px; animation-delay: 0s; }
.sally-voice-bar:nth-child(2) { height: 8px; animation-delay: 0.1s; }
.sally-voice-bar:nth-child(3) { height: 12px; animation-delay: 0.2s; }
.sally-voice-bar:nth-child(4) { height: 6px; animation-delay: 0.3s; }
.sally-voice-bar:nth-child(5) { height: 10px; animation-delay: 0.15s; }

@keyframes sally-voice-bar {
  0% { height: 3px; }
  100% { height: 14px; }
}

/* ─── Messages Area ─────────────────────────────────── */

.sally-chat-messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scroll-behavior: smooth;
}

/* Custom scrollbar */
.sally-chat-messages::-webkit-scrollbar {
  width: 4px;
}

.sally-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.sally-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.sally-chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Message bubbles */
.sally-message {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
  animation: sally-msg-appear 0.2s ease-out;
}

@keyframes sally-msg-appear {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.sally-message.user {
  align-self: flex-end;
  background: rgba(99, 102, 241, 0.25);
  border: 1px solid rgba(99, 102, 241, 0.2);
  color: rgba(255, 255, 255, 0.95);
  border-bottom-right-radius: 4px;
}

.sally-message.assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
  border-bottom-left-radius: 4px;
}

.sally-message.error {
  align-self: center;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: rgba(239, 68, 68, 0.9);
  font-size: 12px;
  max-width: 90%;
}

/* Typing indicator */
.sally-typing-indicator {
  display: none;
  align-self: flex-start;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

.sally-typing-indicator.show {
  display: flex;
  gap: 4px;
  align-items: center;
}

.sally-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  animation: sally-typing-bounce 1.2s ease-in-out infinite;
}

.sally-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.sally-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes sally-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Action request card */
.sally-action-card {
  align-self: flex-start;
  max-width: 90%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  animation: sally-msg-appear 0.2s ease-out;
}

.sally-action-card-header {
  display: none;
}

.sally-action-card-desc {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 10px;
}

.sally-action-buttons {
  display: flex;
  gap: 8px;
}

.sally-action-btn {
  padding: 6px 14px;
  border-radius: 8px;
  border: none;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.sally-action-btn.approve {
  background: rgba(72, 187, 120, 0.2);
  color: #48bb78;
  border: 1px solid rgba(72, 187, 120, 0.3);
}

.sally-action-btn.approve:hover {
  background: rgba(72, 187, 120, 0.3);
}

.sally-action-btn.deny {
  background: rgba(239, 68, 68, 0.15);
  color: rgba(239, 68, 68, 0.8);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.sally-action-btn.deny:hover {
  background: rgba(239, 68, 68, 0.25);
}

/* Download button in chat */
.sally-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  margin: 6px 0;
  background: rgba(72, 187, 120, 0.15);
  color: #48bb78;
  border: 1px solid rgba(72, 187, 120, 0.3);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sally-download-btn:hover {
  background: rgba(72, 187, 120, 0.25);
  border-color: rgba(72, 187, 120, 0.5);
  color: #68d391;
}

.sally-download-btn span {
  font-size: 16px;
}

/* Welcome message */
.sally-welcome {
  text-align: center;
  padding: 40px 20px;
  color: rgba(255, 255, 255, 0.5);
}

.sally-welcome-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.sally-welcome h4 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
}

.sally-welcome p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

/* ─── Input Area ────────────────────────────────────── */

.sally-chat-input-area {
  flex-shrink: 0;
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(28, 28, 30, 0.6);
  backdrop-filter: blur(10px);
}

.sally-chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 6px 6px 6px 10px;
  transition: border-color 0.2s;
}

.sally-chat-input-row:focus-within {
  border-color: rgba(99, 102, 241, 0.4);
}

.sally-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: rgba(255, 255, 255, 0.95);
  font-size: 13px;
  line-height: 1.4;
  padding: 6px 0;
  resize: none;
  min-height: 20px;
  max-height: 100px;
  font-family: inherit;
}

.sally-chat-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.sally-chat-input-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.sally-chat-send-btn {
  background: rgba(99, 102, 241, 0.8);
  color: #fff;
}

.sally-chat-send-btn:hover {
  background: rgba(99, 102, 241, 1);
}

.sally-chat-send-btn:disabled {
  background: rgba(99, 102, 241, 0.3);
  cursor: not-allowed;
}

.sally-chat-mic-btn {
  background: transparent;
  color: rgba(255, 255, 255, 0.4);
}

.sally-chat-mic-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.8);
}

.sally-chat-mic-btn.recording {
  background: rgba(239, 68, 68, 0.2);
  color: #f56565;
  animation: sally-mic-pulse 1.5s ease-in-out infinite;
}

@keyframes sally-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
  50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.15); }
}

/* ─── Markdown in messages ──────────────────────────── */

.sally-message p:empty { display: none; }
.sally-message br + br { display: none; }

.sally-message.assistant p {
  margin: 0 0 10px;
}

.sally-message.assistant p:last-child {
  margin-bottom: 0;
}

.sally-message.assistant h2 {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  margin: 14px 0 6px;
}

.sally-message.assistant h3 {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  margin: 12px 0 4px;
}

.sally-message.assistant h4 {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  margin: 10px 0 4px;
}

.sally-message.assistant h2:first-child,
.sally-message.assistant h3:first-child,
.sally-message.assistant h4:first-child {
  margin-top: 0;
}

.sally-message.assistant code {
  background: rgba(255, 255, 255, 0.1);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'SF Mono', 'Monaco', 'Cascadia Code', monospace;
}

.sally-message.assistant pre {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  margin: 10px 0;
}

.sally-message.assistant pre code {
  background: none;
  padding: 0;
}

.sally-message.assistant ul,
.sally-message.assistant ol {
  margin: 6px 0;
  padding-left: 20px;
}

.sally-message.assistant li {
  margin-bottom: 3px;
}

.sally-message.assistant strong {
  color: #fff;
}

/* Markdown tables → Card layout */
.sally-message.assistant .sally-cards {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
}

.sally-message.assistant .sally-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 10px;
}

.sally-message.assistant .sally-card-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 2px 0;
}

.sally-message.assistant .sally-card-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

.sally-message.assistant .sally-card-value {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  text-align: right;
  word-break: break-word;
}

/* ─── Element Picker ─────────────────────────────────── */

.sally-picker-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 100;
  cursor: crosshair;
  background: rgba(0, 180, 216, 0.03);
}

.sally-picker-overlay-page {
  position: fixed;
  z-index: 99999;
}

#sally-element-picker-btn.active {
  background: rgba(0, 180, 216, 0.2) !important;
  color: #00b4d8 !important;
}

.sally-picked-element {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  margin: 0 12px 4px 12px;
  background: rgba(0, 180, 216, 0.08);
  border: 1px solid rgba(0, 180, 216, 0.2);
  border-radius: 8px;
  font-size: 11px;
  color: #00b4d8;
}

.sally-picked-icon {
  flex-shrink: 0;
}

.sally-picked-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: 'SF Mono', 'Monaco', 'Cascadia Code', monospace;
}

.sally-picked-remove {
  background: none;
  border: none;
  color: rgba(0, 180, 216, 0.5);
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  flex-shrink: 0;
}
.sally-picked-remove:hover {
  color: #00b4d8;
}

/* ─── Footer Button ─────────────────────────────────── */

#sally-chat-footer-btn {
  position: relative;
}

#sally-chat-footer-btn .sally-unread-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: #f56565;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  padding: 0 4px;
  box-sizing: border-box;
}

#sally-chat-footer-btn .sally-unread-badge.has-suggestions {
  animation: sally-badge-pulse 2s ease-in-out infinite;
}

@keyframes sally-badge-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* ─── Notification Bubble ──────────────────────────────── */

.sally-notif-bubble {
  position: fixed;
  bottom: 60px;
  right: 20px;
  background: rgba(30, 30, 40, 0.95);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 320px;
  z-index: 99995;
  cursor: pointer;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  animation: sally-bubble-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  transition: opacity 0.3s, transform 0.3s;
}

.sally-notif-bubble:hover {
  border-color: rgba(99, 102, 241, 0.5);
  transform: translateY(-2px);
}

.sally-notif-bubble-fade {
  opacity: 0;
  transform: translateY(10px);
}

@keyframes sally-bubble-in {
  from { opacity: 0; transform: translateY(20px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.sally-notif-bubble-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.sally-notif-bubble-text {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.4;
}

.sally-notif-bubble-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.3);
  font-size: 16px;
  cursor: pointer;
  padding: 0 2px;
  flex-shrink: 0;
  transition: color 0.15s;
}

.sally-notif-bubble-close:hover {
  color: rgba(255, 255, 255, 0.7);
}

/* ─── Suggestion Banner (in flyout) ────────────────────── */

#sally-suggestions-container {
  display: none;
}

.sally-suggestion-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 10px;
  margin: 8px 12px 4px;
}

.sally-suggestion-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.sally-suggestion-content {
  flex: 1;
  min-width: 0;
}

.sally-suggestion-title {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sally-suggestion-desc {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.sally-suggestion-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.sally-suggestion-act {
  padding: 4px 10px;
  border-radius: 6px;
  border: none;
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.sally-suggestion-act:hover {
  background: rgba(99, 102, 241, 0.35);
}

.sally-suggestion-dismiss {
  padding: 4px 8px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.3);
  font-size: 14px;
  cursor: pointer;
  transition: color 0.15s;
}

.sally-suggestion-dismiss:hover {
  color: rgba(255, 255, 255, 0.6);
}

.sally-suggestion-more {
  text-align: center;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.3);
  padding: 4px 12px 8px;
}

/* ─── Playbook Admin ────────────────────────────────── */

.sally-pb-section {
  margin-bottom: 4px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.sally-pb-section-header {
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
  transition: background 0.2s;
}

.sally-pb-section-header:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sally-pb-version {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.3);
  font-weight: 400;
}

.sally-pb-section-body {
  padding: 10px 14px 14px;
  background: rgba(0, 0, 0, 0.2);
}

.sally-pb-textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.9);
  font-family: 'SF Mono', 'Monaco', 'Cascadia Code', monospace;
  font-size: 11px;
  line-height: 1.5;
  padding: 10px 12px;
  resize: vertical;
  min-height: 80px;
  outline: none;
  box-sizing: border-box;
}

.sally-pb-textarea:focus {
  border-color: rgba(99, 102, 241, 0.4);
}

.sally-pb-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  justify-content: flex-end;
}

.sally-pb-save-btn {
  padding: 5px 14px;
  border-radius: 6px;
  border: none;
  background: rgba(72, 187, 120, 0.2);
  color: #48bb78;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.sally-pb-save-btn:hover {
  background: rgba(72, 187, 120, 0.3);
}

.sally-pb-reset-btn {
  padding: 5px 14px;
  border-radius: 6px;
  border: none;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.4);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.sally-pb-reset-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.6);
}

/* ─── Image Upload ─────────────────────────────────── */

.sally-chat-input-area {
  position: relative;
}

.sally-chat-upload-btn {
  color: rgba(255, 255, 255, 0.35);
  background: transparent !important;
  width: 24px;
  height: 24px;
  min-width: 24px;
  flex-shrink: 0;
  order: -1;
  padding: 0;
  align-self: center;
}

.sally-chat-upload-btn:hover {
  color: rgba(255, 255, 255, 0.7);
  background: transparent !important;
}

/* ─── Upload Menu (Paperclip Popup) ──────────────── */

.sally-upload-menu {
  display: none;
  position: absolute;
  bottom: calc(100% + 4px);
  left: 12px;
  min-width: 220px;
  background: rgba(28, 28, 30, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 110;
  overflow: hidden;
  animation: sally-menu-appear 0.15s ease-out;
}

.sally-upload-menu.show {
  display: block;
}

@keyframes sally-menu-appear {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.sally-upload-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.sally-upload-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sally-upload-menu-item + .sally-upload-menu-item {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sally-upload-menu-item i,
.sally-upload-menu-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.6;
}

.sally-chat-image-preview {
  display: none;
  gap: 4px;
  align-items: center;
  align-self: center;
  flex-shrink: 0;
}

.sally-chat-image-preview.has-images {
  display: flex;
}

.sally-chat-image-thumb {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  overflow: visible;
  border: 1px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
  cursor: pointer;
  transition: border-color 0.15s;
}

.sally-chat-image-thumb:hover {
  border-color: rgba(255, 255, 255, 0.35);
}

.sally-chat-image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 5px;
}

.sally-chat-image-thumb .sally-img-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(245, 101, 101, 0.9);
  color: #fff;
  border: none;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
  cursor: pointer;
  padding: 0;
  opacity: 0;
  transition: opacity 0.12s;
}

.sally-chat-image-thumb:hover .sally-img-remove {
  opacity: 1;
}

/* ─── Design Mode: Tool Status ────────────────────── */

.sally-tool-status {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 12px;
  font-size: 12px;
  color: rgba(99, 102, 241, 0.9);
  animation: sally-msg-appear 0.2s ease-out;
}

.sally-tool-status-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(99, 102, 241, 0.2);
  border-top-color: rgba(99, 102, 241, 0.8);
  border-radius: 50%;
  animation: sally-spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes sally-spin {
  to { transform: rotate(360deg); }
}

/* ─── Tool Activity Log (cumulative step list) ────── */

.sally-tool-log {
  align-self: flex-start;
  background: rgba(22, 22, 28, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 8px 12px;
  margin-bottom: 2px;
  animation: sally-msg-appear 0.2s ease-out;
  max-width: 400px;
  position: sticky;
  bottom: 0;
  z-index: 10;
}

/* Hide completed tool steps — only show the active one with spinner */
.sally-tool-step.done {
  display: none !important;
}

.sally-tool-collapsed {
  display: none !important;
}

.sally-tool-log.collapsed {
  padding: 2px 10px;
  margin-bottom: 2px;
  background: transparent;
  border: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.sally-tool-summary-line {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.25);
  padding: 0;
  line-height: 1.4;
}

.sally-tool-step {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.55);
  transition: opacity 0.3s, color 0.3s;
}

.sally-tool-step.active {
  color: rgba(255, 255, 255, 0.95);
}

.sally-tool-step.active span {
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  animation: sally-tool-type 0.4s steps(30) forwards, sally-tool-pulse 2s ease-in-out 0.4s infinite;
  max-width: 0;
}

@keyframes sally-tool-type {
  from { max-width: 0; }
  to { max-width: 350px; }
}

@keyframes sally-tool-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.sally-tool-step.preparing span {
  color: rgba(255, 255, 255, 0.6);
  font-style: italic;
}

.sally-tool-step.preparing .sally-tool-spinner {
  border-top-color: rgba(255, 255, 255, 0.4);
}

/* .sally-tool-step.done is hidden via display:none at line ~2004 */

.sally-tool-check {
  color: #48bb78;
  font-size: 12px;
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}

.sally-tool-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  animation: sally-spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes sally-spin {
  to { transform: rotate(360deg); }
}

.sally-tool-collapsed {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.3);
  padding: 2px 4px;
}

/* ─── Progress Panel (Live Reporting) ────────────── */

.sally-progress-panel {
  align-self: flex-start;
  max-width: 90%;
  padding: 12px 16px;
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.12);
  border-radius: 12px;
  font-size: 13px;
  animation: sally-msg-appear 0.2s ease-out;
  margin: 4px 0;
}

.sally-progress-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 8px;
}

.sally-progress-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(99, 102, 241, 0.2);
  border-top-color: rgba(99, 102, 241, 0.8);
  border-radius: 50%;
  animation: sally-spin 0.8s linear infinite;
  flex-shrink: 0;
  display: inline-block;
}

.sally-progress-title {
  color: rgba(255, 255, 255, 0.85);
}

.sally-progress-steps {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 4px;
}

.sally-progress-step {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  color: rgba(255, 255, 255, 0.5);
  transition: color 0.2s ease;
}

.sally-progress-step--running {
  color: rgba(99, 102, 241, 0.9);
}

.sally-progress-step--done {
  color: rgba(72, 187, 120, 0.9);
}

.sally-progress-step--error {
  color: rgba(245, 101, 101, 0.9);
}

.sally-progress-icon {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.sally-progress-label {
  flex: 1;
}

.sally-progress-detail {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  margin-left: 4px;
}

.sally-progress-panel--success {
  border-color: rgba(72, 187, 120, 0.2);
  background: rgba(72, 187, 120, 0.06);
}

.sally-progress-panel--error {
  border-color: rgba(245, 101, 101, 0.2);
  background: rgba(245, 101, 101, 0.06);
}

/* ─── Design Mode: Change Card + Undo ────────────── */

.sally-design-card {
  align-self: flex-start;
  max-width: 90%;
  padding: 10px 14px;
  background: rgba(72, 187, 120, 0.08);
  border: 1px solid rgba(72, 187, 120, 0.2);
  border-radius: 12px;
  animation: sally-msg-appear 0.2s ease-out;
}

.sally-design-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(72, 187, 120, 0.9);
  margin-bottom: 4px;
}

.sally-design-card-desc {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 8px;
}

.sally-design-card-actions {
  display: flex;
  gap: 8px;
}

/* ─── Design Mode: Pulse Highlight ───────────────── */

@keyframes sally-design-pulse {
  0% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.6); }
  40% { box-shadow: 0 0 0 6px rgba(251, 191, 36, 0.3); }
  100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); }
}

.sally-design-pulse {
  animation: sally-design-pulse 0.8s ease-out 3 !important;
  outline: 2px solid rgba(251, 191, 36, 0.5) !important;
  outline-offset: 2px;
  transition: outline 0.3s ease;
}

.sally-chat-drop-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(99, 102, 241, 0.12);
  border: 2px dashed rgba(99, 102, 241, 0.5);
  border-radius: 16px;
  z-index: 100;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: rgba(99, 102, 241, 0.9);
  pointer-events: none;
  backdrop-filter: blur(2px);
}

.sally-chat-flyout.drag-over .sally-chat-drop-overlay {
  display: flex;
}

/* ─── Responsive ────────────────────────────────────── */

@media (max-width: 500px) {
  .sally-chat-flyout {
    width: 100vw;
    max-width: 100vw;
    border-radius: 0;
  }

  .sally-chat-flyout::before {
    border-radius: 0;
  }

  .sally-avatar-split {
    height: 120px;
    gap: 4px;
    margin: 8px 10px 4px;
  }

  .sally-user-avatar-fallback {
    font-size: 24px;
  }
}

/* ─── Tool Result Badges ─────────────────────────── */

.sally-tool-result {
  background: rgba(72, 187, 120, 0.08) !important;
  border: 1px solid rgba(72, 187, 120, 0.2) !important;
  border-radius: 8px !important;
  padding: 8px 12px !important;
  font-size: 13px !important;
  color: rgba(255, 255, 255, 0.7) !important;
  margin: 4px 0 !important;
}

.sally-tool-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: rgba(72, 187, 120, 0.25);
  color: #48bb78;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  margin-right: 6px;
  vertical-align: middle;
}

/* ─── Live Stream: Tool Summary + Thinking Section ── */

.sally-tool-summary {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
  font-style: italic;
  margin-left: 2px;
}

.sally-tool-step.done .sally-tool-summary {
  opacity: 0.8;
}

.sally-tool-fail {
  color: #f56565 !important;
}

.sally-tool-step.failed {
  border-left-color: rgba(245, 101, 101, 0.4);
}

/* ─── Thinking Section (Live Reasoning) ──────────── */

.sally-thinking-section {
  align-self: flex-start;
  background: rgba(139, 92, 246, 0.06);
  border: 1px solid rgba(139, 92, 246, 0.15);
  border-left: 3px solid rgba(139, 92, 246, 0.4);
  border-radius: 0 12px 12px 0;
  padding: 12px 16px;
  margin: 2px 0 2px;
  max-width: 90%;
  animation: sally-msg-appear 0.2s ease-out;
  transition: opacity 0.3s, max-height 0.4s ease;
  overflow: hidden;
}

.sally-thinking-section.collapsed {
  cursor: pointer;
  max-height: 36px;
}

.sally-thinking-section.collapsed .sally-thinking-content {
  display: none;
}

.sally-thinking-section.collapsed:hover {
  background: rgba(139, 92, 246, 0.1);
}

.sally-thinking-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  cursor: pointer;
  user-select: none;
}

.sally-thinking-section.collapsed .sally-thinking-header {
  margin-bottom: 0;
}

.sally-thinking-toggle {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
  transition: transform 0.2s;
}

.sally-thinking-section.collapsed .sally-thinking-toggle {
  transform: rotate(-90deg);
}

.sally-thinking-dots {
  display: flex;
  gap: 3px;
}

.sally-thinking-dots span {
  width: 5px;
  height: 5px;
  background: #8b5cf6;
  border-radius: 50%;
  animation: sallyDotBounce 1.4s ease-in-out infinite;
}

.sally-thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.sally-thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes sallyDotBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.sally-thinking-label {
  font-size: 12px;
  color: rgba(139, 92, 246, 0.7);
  font-weight: 500;
}

.sally-thinking-content {
  font-size: 13.5px;
  color: rgba(255, 255, 255, 0.75);
  line-height: 1.6;
  max-height: 500px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sally-thinking-content code {
  font-size: 12px;
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 5px;
  border-radius: 3px;
  color: rgba(255, 255, 255, 0.85);
}

.sally-thinking-content strong {
  color: rgba(255, 255, 255, 0.9);
}

/* Visual connection: thinking section directly after tool log */
.sally-tool-log + .sally-thinking-section {
  margin-top: -6px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-top-color: transparent;
}

/* ─── Quick Reply Buttons (Liquid Glass) ─── */

.sally-quick-reply-container {
  display: flex;
  flex-direction: column;
  margin: 12px -12px -8px -12px;
  width: calc(100% + 24px);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 0;
  overflow: hidden;
}

.sally-quick-reply-question {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 16px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sally-quick-reply {
  display: block;
  width: 100%;
  padding: 11px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: rgba(255, 255, 255, 0.85);
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0;
  cursor: pointer;
  transition: background 0.12s ease;
  text-align: left;
  line-height: 1.4;
}

.sally-quick-reply:last-child {
  border-bottom: none;
}

.sally-quick-reply:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sally-quick-reply:active {
  background: rgba(255, 255, 255, 0.05);
}

/* Prevent empty elements from taking space */
.sally-message:empty,
.sally-tool-log:empty,
/* Hide tool-logs with no active steps (all done or empty) */
.sally-tool-log:not(:has(.sally-tool-step:not(.done))):not(:has(.sally-tool-summary-line)),
.sally-progress-panel:empty {
  display: none !important;
  margin: 0 !important;
  padding: 0 !important;
  height: 0 !important;
  border: none !important;
  overflow: hidden !important;
}
