/* Sofia ADHD/Dyslexia-First Compose Features
   Owned by Email robot. Loaded after the main Blod Bolge overlay. */

/* Sofia warm-paper polish: full-height flow, pressable actions, anchored footer. */
.bb-compose-sofia {
  display: flex;
  flex-direction: column;
  align-self: stretch;
  min-height: 0;
  background: linear-gradient(180deg, var(--bb-cream, #FAF7F3) 0%, var(--bb-white, #FFFDFB) 100%);
  color: var(--bb-warm-text, #5C4D43);
}

.bb-compose-sofia-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  padding: 7px 12px 7px 14px;
  border-bottom: 1px solid rgba(92, 77, 67, 0.06);
}

.bb-compose-sofia-title {
  margin: 0;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: rgb(140, 128, 116);
  text-transform: none;
  line-height: 1.2;
  user-select: none;
}

/* ── #2991: "Ny samtale" reset (quiet pill) ──────────────────
   Hidden in the welcome/empty state; revealed only during active chat via
   :has(.bb-compose-sofia-body--active-chat). margin-right:auto keeps it on the
   left while the title + fold chevron stay clustered on the right. */
.bb-sofia-reset-btn {
  display: none;
  align-items: center;
  gap: 6px;
  margin-right: auto;
  padding: 5px 10px;
  min-height: 44px;
  min-width: 44px;
  border: 1px solid rgba(228, 220, 212, 0.7);
  border-radius: 8px;
  background: var(--bb-cream, #FAF7F3);
  color: var(--bb-warm-text, #5C4D43);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.bb-sofia-reset-icon {
  flex: 0 0 auto;
}

.bb-compose-sofia:has(.bb-compose-sofia-body--active-chat) .bb-sofia-reset-btn {
  display: inline-flex;
}

.bb-sofia-reset-btn:hover {
  background: rgba(168, 197, 184, 0.18);
  border-color: rgba(110, 138, 126, 0.35);
  color: var(--bb-sage-dark, #4A7A68);
}

.bb-compose-sofia .bb-sofia-reset-btn:focus-visible {
  outline: none !important;
  border-color: var(--bb-sage-dark, #4A7A68) !important;
  box-shadow: 0 0 0 3px rgba(110, 138, 126, 0.25) !important;
}

.bb-compose-sofia-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.bb-compose-sofia .ask-ai-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px;
  background: #FBF8F2;
}

/* ── Row: transparent layout slot ────────────────────────── */
.bb-compose-sofia .ask-ai-input-row {
  display: block;
  padding: 0;
  margin: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  width: 100%;
}

/* ── Shell: single chrome surface ────────────────────────── */
.bb-compose-sofia .calm-input-shell {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 6px 6px 6px 14px;
  background: #FFFEFB;
  border: 1px solid rgba(228, 220, 212, 0.7);
  border-radius: 14px;
  margin: 8px 12px 12px;
  box-shadow: 0 1px 2px rgba(58, 47, 38, 0.04);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.bb-compose-sofia .calm-input-shell:focus-within {
  border-color: rgba(228, 220, 212, 0.7);
  outline: none;
  box-shadow: none;
}

.bb-compose-sofia .ask-ai-input.ask-ai-input-highlight {
  border-color: rgba(110, 138, 126, 0.45);
  box-shadow: 0 0 0 3px rgba(110, 138, 126, 0.12);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.bb-compose-sofia .ask-ai-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 32px;
  height: auto;
  padding: 6px 0;
  box-sizing: border-box;
  border: 0;
  border-radius: 0;
  outline: none;
  box-shadow: none;
  background: transparent;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.4;
  color: var(--bb-warm-text, #5C4D43);
  resize: none;
  max-height: 120px;
  overflow-y: auto;
}

.bb-compose-sofia .ask-ai-input::placeholder {
  color: #9A8E82;
  font-weight: 400;
}

.bb-compose-sofia .ask-ai-mic {
  position: relative;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease, color .15s ease, transform .15s ease;
  border: 0;
  background: transparent;
  color: rgb(92, 77, 67);
}

.bb-compose-sofia .ask-ai-mic svg,
.bb-compose-sofia .ask-ai-send svg {
  width: 18px;
  height: 18px;
}

.bb-compose-sofia .ask-ai-mic:hover {
  background: rgba(228, 220, 212, 0.35);
  color: #5C4D43;
}

.bb-compose-sofia .ask-ai-send {
  position: relative;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease, color .15s ease, transform .15s ease;
  border: none;
  background: #6E8A7E;
  color: #fff;
}

.bb-compose-sofia .ask-ai-send:hover {
  background: #4A7A68;
}

.email-page .bb-compose-sofia .ask-ai-send:hover:not(:disabled) {
  background: #4A7A68;
}

.bb-compose-sofia .ask-ai-send:active {
  transform: scale(0.96);
}

.bb-compose-sofia .ask-ai-mic:focus-visible,
.bb-compose-sofia .ask-ai-send:focus-visible,
.bb-compose-sofia .bb-sofia-tts-btn:focus-visible {
  outline: 2px solid var(--bb-sage-dark, #4A7A68) !important;
  outline-offset: 2px !important;
}

.bb-compose-sofia .ask-ai-send:disabled {
  background: #c9d3cd;
  cursor: default;
  transform: none;
}

/* ── Mic recording state ────────────────────────────────── */
.bb-compose-sofia .ask-ai-mic.recording,
.bb-compose-sofia .ask-ai-mic.ss-mic--listening,
.bb-compose-sofia .ask-ai-mic.ss-mic--recording,
.bb-compose-sofia .ask-ai-mic.is-recording {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.06);
}

.bb-compose-sofia .ask-ai-mic:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}


.bb-sofia-reply-chips {
  padding: 0 16px 12px;
}

.bb-sofia-chips-label {
  font-family: var(--font-family);
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--bb-warm-text-light, #8B7B6B);
  margin: 0 0 8px;
  letter-spacing: 0;
}

.bb-sofia-reply-chip {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 44px;
  padding: 12px 14px;
  margin-bottom: 8px;
  background: rgba(168, 197, 184, 0.08);
  border: 1.5px solid rgba(168, 197, 184, 0.25);
  border-radius: 14px;
  color: var(--bb-warm-text, #5C4D43);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
}

.bb-sofia-reply-chip:hover {
  border-color: var(--bb-sage-dark, #4A7A68);
  background: rgba(168, 197, 184, 0.14);
  transform: translateY(-1px);
}

.bb-sofia-reply-chip:focus-visible {
  outline: none;
  outline-offset: 2px;
}

.bb-sofia-reply-chip-label {
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--bb-sage-dark, #4A7A68);
  margin-bottom: 2px;
}

.bb-sofia-reply-chip-preview {
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  color: var(--bb-warm-text, #5C4D43);
  line-height: 1.4;
}

.bb-sofia-reply-chip--custom {
  background: transparent;
  border-style: dashed;
  opacity: 0.76;
}

.bb-sofia-reply-chip--custom:hover {
  opacity: 1;
}

.bb-sofia-chip-skeleton {
  display: block;
}

.bb-sofia-chip-skeleton-item {
  height: 52px;
  margin-bottom: 8px;
  background: linear-gradient(90deg, rgba(168, 197, 184, 0.08) 25%, rgba(168, 197, 184, 0.15) 50%, rgba(168, 197, 184, 0.08) 75%);
  background-size: 200% 100%;
  border-radius: 14px;
  animation: sofia-shimmer 1.5s infinite;
}

.bb-sofia-chip-skeleton--short {
  width: 70%;
  height: 44px;
}

/* Input-card rules removed — compose Sofia now uses .ask-ai-input-row contract */

/* ── Welcome loading state (#2282) ───────────────────────────── */

.ask-ai-welcome--loading .ask-ai-suggestion {
  pointer-events: none;
  opacity: 0.5;
}

.ask-ai-welcome--loading .ask-ai-suggestion[aria-busy="true"] {
  opacity: 1;
}

.ask-ai-suggestion__spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: ask-ai-spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

/* ── Skeleton bubble (#2282) ─────────────────────────────────── */

.ask-ai-message--skeleton {
  display: block;
  padding: 16px 18px;
  border-radius: 14px 14px 14px 4px;
  background: #FFFEFB;
  max-width: 320px;
  width: 88%;
  margin: 8px 0;
  box-sizing: border-box;
}

.bb-compose-sofia .ask-ai-message--skeleton {
  display: block;
  padding: 16px 18px;
  max-width: 320px;
  width: 88%;
  box-sizing: border-box;
}

.ask-ai-skeleton-line {
  height: 11px;
  border-radius: 6px;
  margin: 6px 0;
  width: 100%;
  background: linear-gradient(90deg, rgba(110,138,126,0.10) 25%, rgba(110,138,126,0.20) 50%, rgba(110,138,126,0.10) 75%);
  background-size: 200% 100%;
  animation: calmShimmer 1.4s ease-in-out infinite;
}

.ask-ai-skeleton-line:nth-child(1) { width: 55%; }
.ask-ai-skeleton-line:last-child { width: 80%; }

@keyframes calmShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Loading ──────────────────────────────────────────────────── */

.bb-sofia-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  margin: 0 16px 12px;
}

.bb-sofia-loading-text {
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  color: var(--bb-sage-dark, #4A7A68);
  animation: sofia-pulse 1.5s ease-in-out infinite;
}

/* ── Compose Flash Confirm ────────────────────────────────────── */

.bb-sofia-flash {
  animation: sofia-flash-confirm 0.3s ease-out;
}

@keyframes sofia-flash-confirm {
  0% { box-shadow: 0 0 0 0 rgba(139, 175, 156, 0.5); }
  50% { box-shadow: 0 0 0 4px rgba(139, 175, 156, 0.3); }
  100% { box-shadow: 0 0 0 0 rgba(139, 175, 156, 0); }
}

/* ── Calendar Warning ─────────────────────────────────────────── */

.bb-sofia-calendar-warn {
  margin: 0 16px 12px;
  padding: 10px 14px;
  background: rgba(255, 193, 7, 0.1);
  border: 1px solid rgba(255, 193, 7, 0.3);
  border-radius: 10px;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  color: #856404;
  animation: sofia-fade-in 0.2s ease-out;
}

/* ── TTS Button ─────────────────────────────────────────── */

.bb-sofia-tts-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: calc(100% - 32px);
  min-height: 44px;
  margin: 8px 16px;
  padding: 12px 14px;
  background: var(--bb-white, #FFFDFB);
  border: 1px solid rgba(92, 77, 67, 0.16);
  border-radius: 14px;
  color: var(--bb-warm-text, #5C4D43);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(92, 77, 67, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.76);
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.bb-sofia-tts-btn:hover {
  border-color: rgba(92, 77, 67, 0.24);
  background: var(--bb-cream, #FAF7F3);
  box-shadow: 0 4px 12px rgba(92, 77, 67, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.84);
}

.bb-sofia-tts-btn.is-playing {
  border-color: var(--bb-sage-dark, #4A7A68);
  background: rgba(168, 197, 184, 0.1);
}

.bb-sofia-tts-icon svg {
  width: 20px;
  height: 20px;
  stroke: var(--bb-sage-dark, #4A7A68);
}

.bb-sofia-tts-btn.is-playing .bb-sofia-tts-icon svg {
  stroke: var(--bb-sage-dark, #4A7A68);
  animation: sofia-pulse 1.5s infinite;
}

.bb-sofia-tts-label {
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--bb-warm-text, #5C4D43);
}

@keyframes sofia-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes sofia-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Context Bar ────────────────────────────────────────── */

.bb-sofia-context-bar {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 16px;
  margin: 4px 16px 12px;
  background: rgba(78, 83, 112, 0.05);
  border-radius: 10px;
  border-left: 3px solid var(--bb-slate-dark, #4E5370);
}

.bb-sofia-context-icon {
  flex-shrink: 0;
  margin-top: 1px;
}

.bb-sofia-context-icon svg {
  stroke: var(--bb-slate-dark, #4E5370);
}

.bb-sofia-context-text {
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  line-height: 1.4;
  color: var(--bb-warm-text, #5C4D43);
}

.bb-sofia-context-loading {
  font-family: var(--font-family);
  font-size: var(--font-size-xs);
  color: var(--bb-warm-text-light, #8B7B6B);
  font-style: italic;
}

/* ── Mic Recording ──────────────────────────────────────── */

.bb-compose-sofia .ask-ai-mic.is-recording,
.bb-compose-sofia .ask-ai-mic.ss-mic--listening,
.bb-compose-sofia .ask-ai-mic.ss-mic--recording {
  background: var(--bb-rose-dark, #9B6050);
  border-color: var(--bb-rose-dark, #9B6050);
  color: var(--bb-white, #F7F2EA);
}

.bb-compose-sofia .ask-ai-mic.is-recording svg,
.bb-compose-sofia .ask-ai-mic.ss-mic--listening svg,
.bb-compose-sofia .ask-ai-mic.ss-mic--recording svg {
  stroke: currentColor;
  animation: sofia-pulse 1s infinite;
}

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

.bb-sofia-message {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bb-sofia-message--success {
  background: rgba(168, 197, 184, 0.12);
  border-color: rgba(74, 122, 104, 0.2);
}

.bb-sofia-message--info {
  background: rgba(78, 83, 112, 0.08);
  border-color: rgba(78, 83, 112, 0.16);
}

.bb-sofia-message--error {
  background: rgba(212, 168, 154, 0.1);
  border-color: rgba(155, 96, 80, 0.2);
}

.bb-sofia-message-icon {
  flex: 0 0 auto;
  font-weight: var(--font-weight-bold);
}

.bb-sofia-message--success .bb-sofia-message-icon {
  color: var(--bb-sage-dark, #4A7A68);
}

.bb-sofia-message--error .bb-sofia-message-icon {
  color: var(--bb-rose-dark, #9B6050);
}

/* ── Reduced Motion ───────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .bb-compose-sofia .calm-input-shell,
  .bb-sofia-chip-skeleton,
  .bb-sofia-loading-text,
  .bb-compose-sofia .ask-ai-mic.is-recording,
  .bb-sofia-flash,
  .bb-sofia-calendar-warn,
  .bb-sofia-reply-chip,
  .bb-compose-sofia .ask-ai-mic,
  .bb-compose-sofia .ask-ai-send,
  .bb-sofia-tts-btn,
  .ask-ai-message--skeleton,
  .ask-ai-skeleton-line,
  .ask-ai-suggestion__spinner {
    transition: none !important;
    animation: none !important;
  }

  .bb-sofia-fold-btn,
  .bb-sofia-fold-icon,
  .email-compose-dialog.with-sofia.is-sofia-folded .bb-compose-sofia,
  .email-compose-dialog.with-sofia:not(.is-sofia-folded) .bb-compose-sofia {
    transition: none !important;
  }

  .is-sofia-folded .bb-sofia-fold-icon {
    transform: rotate(180deg) !important;
  }

  .bb-sofia-reply-chip:hover,
  .bb-compose-sofia .ask-ai-mic:hover,
  .bb-compose-sofia .ask-ai-send:hover,
  .bb-compose-sofia .ask-ai-mic,
  .bb-compose-sofia .ask-ai-send {
    transform: none !important;
  }

  @keyframes sofia-shimmer {
    0%, 100% { background-position: 0 0; }
  }

  @keyframes sofia-pulse {
    0%, 100% { opacity: 1; }
  }

  @keyframes calmShimmer {
    0%, 100% { background-position: 0 0; }
  }

  @keyframes ask-ai-spin {
    to { transform: rotate(0deg); }
  }
}

/* ── Mobile ───────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .bb-sofia-reply-chip {
    min-height: 48px;
    padding: 14px 16px;
  }
}

/* ── Sofia fold/unfold toggle ──────────────────────────── */

.bb-sofia-fold-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-right: -12px;
  padding: 8px;
  background: none;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  color: rgb(154, 142, 130);
  transition: background 140ms ease, color 140ms ease;
}

.bb-sofia-fold-btn:hover {
  background: rgba(92, 77, 67, 0.06);
  color: rgb(92, 77, 67);
}

.bb-compose-sofia .bb-sofia-fold-btn:focus-visible {
  border-color: var(--bb-sage-dark, #4A7A68) !important;
  box-shadow: 0 0 0 3px rgba(110, 138, 126, 0.25) !important;
  background: rgba(168, 197, 184, 0.18);
  color: var(--bb-sage-dark, #4A7A68);
}

.bb-sofia-fold-icon {
  transition: transform 200ms ease;
}

.is-sofia-folded .bb-sofia-fold-icon {
  transform: rotate(180deg);
}

/* ── Folded Sofia state ──────────────────────────────────── */

.email-compose-dialog.with-sofia.is-sofia-folded .bb-compose-sofia {
  box-sizing: border-box;
  width: 44px;
  min-width: 44px;
  max-width: 44px;
  overflow: hidden;
  transition: width 200ms ease;
}

.email-compose-dialog.with-sofia:not(.is-sofia-folded) .bb-compose-sofia {
  transition: width 200ms ease;
}

.email-compose-dialog.with-sofia.is-sofia-folded .bb-compose-sofia-header {
  justify-content: center;
  padding: 10px 4px;
  gap: 0;
}

.email-compose-dialog.with-sofia.is-sofia-folded .bb-compose-sofia-title {
  display: none;
}

/* #2991: collapse the reset pill into the 44px folded rail (only the chevron shows) */
.email-compose-dialog.with-sofia.is-sofia-folded .bb-sofia-reset-btn {
  display: none;
}

.email-compose-dialog.with-sofia.is-sofia-folded .bb-compose-sofia-body,
.email-compose-dialog.with-sofia.is-sofia-folded .bb-compose-sofia .ask-ai-input-row {
  display: none;
}

[data-theme="dark"] .bb-compose-sofia-actions button:hover {
  background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .bb-sofia-fold-btn {
  color: #B8A898;
}

[data-theme="dark"] .bb-sofia-fold-btn:hover,
[data-theme="dark"] .bb-sofia-fold-btn:focus-visible {
  background: rgba(255, 255, 255, 0.1);
  color: #E8DDD4;
}

[data-theme="dark"] .bb-sofia-reset-btn {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(232, 221, 212, 0.16);
  color: #B8A898;
}

[data-theme="dark"] .bb-sofia-reset-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(168, 197, 184, 0.4);
  color: #E8DDD4;
}

/* ── Dark Mode ──────────────────────────────────────────── */

[data-theme="dark"] .bb-compose-sofia-title {
  color: #E8DDD4;
}

[data-theme="dark"] .bb-compose-sofia .calm-input-shell {
  background: rgba(42, 38, 34, 0.6) !important;
  border-color: rgba(232, 221, 212, 0.16) !important;
  box-shadow: none !important;
}

[data-theme="dark"] .bb-compose-sofia .calm-input-shell:focus-within {
  border-color: rgba(168, 197, 184, 0.45) !important;
  box-shadow: 0 0 0 3px rgba(110, 138, 126, 0.2) !important;
}

[data-theme="dark"] .bb-compose-sofia .ask-ai-input {
  color: #e8ddd4 !important;
}

[data-theme="dark"] .bb-compose-sofia .ask-ai-input::placeholder {
  color: #a89888 !important;
}

[data-theme="dark"] .bb-compose-sofia .ask-ai-mic {
  color: #a89888 !important;
}

[data-theme="dark"] .bb-compose-sofia .ask-ai-send {
  background: rgba(232, 221, 212, 0.18) !important;
}

[data-theme="dark"] .bb-compose-sofia .ask-ai-send:hover {
  background: rgba(232, 221, 212, 0.26) !important;
}

[data-theme="dark"] .bb-compose-sofia .ask-ai-send:disabled {
  background: rgba(232, 221, 212, 0.10) !important;
}

[data-theme="dark"] .ask-ai-message--skeleton {
  background: rgba(168,197,184,0.06);
}

[data-theme="dark"] .ask-ai-skeleton-line {
  background: linear-gradient(90deg, rgba(110,138,126,0.10) 25%, rgba(110,138,126,0.18) 50%, rgba(110,138,126,0.10) 75%);
  background-size: 200% 100%;
}

[data-theme="dark"] .bb-sofia-reply-chip {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(232, 221, 212, 0.14);
}

[data-theme="dark"] .bb-sofia-reply-chip:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(232, 221, 212, 0.24);
}

[data-theme="dark"] .bb-sofia-reply-chip-label {
  color: var(--bb-warm-text-light, #C9BAAA);
}

[data-theme="dark"] .bb-sofia-reply-chip-preview,
[data-theme="dark"] .bb-sofia-context-text,
[data-theme="dark"] .bb-sofia-tts-label {
  color: #E8DDD4;
}

[data-theme="dark"] .bb-sofia-chip-preview {
  color: #a89888 !important;
}

[data-theme="dark"] .bb-sofia-loading-text {
  color: var(--bb-warm-text-light, #C9BAAA) !important;
}

[data-theme="dark"] .bb-sofia-calendar-warn {
  background: rgba(255, 193, 7, 0.08) !important;
  border-color: rgba(255, 193, 7, 0.2) !important;
  color: #ffc107 !important;
}

[data-theme="dark"] .bb-sofia-chips-label {
  color: #a89888 !important;
}

[data-theme="dark"] .bb-sofia-tts-btn {
  background: rgba(78, 83, 112, 0.08);
  border-color: rgba(78, 83, 112, 0.2);
}

[data-theme="dark"] .bb-sofia-tts-btn:hover {
  background: rgba(78, 83, 112, 0.14);
}

[data-theme="dark"] .bb-sofia-context-bar {
  background: rgba(78, 83, 112, 0.08);
  border-left-color: rgba(78, 83, 112, 0.4);
}

[data-theme="dark"] .bb-sofia-message--success {
  background: rgba(168, 197, 184, 0.08);
  border-color: rgba(168, 197, 184, 0.15);
  color: #E8DDD4;
}

[data-theme="dark"] .bb-sofia-message--info {
  background: rgba(78, 83, 112, 0.08);
  border-color: rgba(78, 83, 112, 0.2);
  color: #E8DDD4;
}

[data-theme="dark"] .bb-sofia-message--error {
  background: rgba(212, 168, 154, 0.06);
  border-color: rgba(212, 168, 154, 0.12);
  color: #E8DDD4;
}

@keyframes sofia-fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Smart Draft Button ───────────────────────────────── */

.bb-sofia-smart-draft {
  padding: 12px 16px 8px;
  animation: sofia-fade-in 0.25s ease;
}

.bb-sofia-smart-draft-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 14px 18px;
  background: var(--bb-sage-dark, #4A7A68);
  border: none;
  border-radius: 14px;
  color: var(--bb-white, #F7F2EA);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease, opacity 0.2s ease;
}

.bb-sofia-smart-draft-btn:hover {
  background: var(--bb-sage-text, #3D6B57);
  transform: translateY(-1px);
}

.bb-sofia-smart-draft-btn:active {
  transform: scale(0.98);
}

.bb-sofia-smart-draft-btn:disabled {
  opacity: 0.7;
  cursor: progress;
  transform: none;
}

.bb-sofia-smart-draft-btn.is-loading .bb-sofia-smart-draft-icon {
  animation: sofia-pulse 1s infinite;
}

.bb-sofia-smart-draft-icon {
  font-size: var(--font-size-lg);
  line-height: 1;
}

.bb-sofia-smart-draft-text {
  flex: 1;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: 600;
  text-align: left;
}

.bb-sofia-smart-draft-arrow {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  opacity: 0.7;
}

.bb-sofia-smart-draft-hint {
  font-family: var(--font-family);
  font-size: var(--font-size-xs);
  color: var(--bb-warm-text-light, #8B7B6B);
  margin: 8px 0 0;
  padding-left: 2px;
}

/* ── Refinement Chips ───────────────────────────────────── */

.bb-sofia-refinement-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px 12px;
  animation: sofia-fade-in 0.25s ease;
}

.bb-sofia-refinement-chip {
  min-height: 36px;
  padding: 8px 16px;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--bb-sage-dark, #4A7A68);
  background: transparent;
  border: 1px solid rgba(168, 197, 184, 0.4);
  border-radius: 20px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
}

.bb-sofia-refinement-chip:hover {
  background: rgba(168, 197, 184, 0.15);
  border-color: var(--bb-sage-dark, #4A7A68);
  transform: translateY(-1px);
}

.bb-sofia-refinement-chip:active {
  transform: scale(0.96);
}

.bb-sofia-refinement-chip.is-active {
  background: rgba(168, 197, 184, 0.3);
  border-color: var(--bb-sage-dark, #4A7A68);
  animation: sofia-pulse 1.2s infinite;
}

.bb-sofia-refinement-chip:disabled {
  opacity: 0.5;
  cursor: progress;
  transform: none;
}

/* ── Dark Mode — Smart Draft & Refinement ─────────────── */

[data-theme="dark"] .bb-sofia-smart-draft-btn {
  background: rgba(232, 221, 212, 0.16);
}

[data-theme="dark"] .bb-sofia-smart-draft-btn:hover {
  background: rgba(232, 221, 212, 0.24);
}

[data-theme="dark"] .bb-sofia-refinement-chip {
  color: var(--bb-warm-text-light, #C9BAAA) !important;
  background: transparent !important;
  border-color: rgba(232, 221, 212, 0.20) !important;
}

[data-theme="dark"] .bb-sofia-refinement-chip:hover {
  background: rgba(255, 255, 255, 0.10) !important;
  border-color: rgba(232, 221, 212, 0.28) !important;
}

[data-theme="dark"] .bb-sofia-refinement-chip.is-active {
  background: rgba(232, 221, 212, 0.18) !important;
  border-color: rgba(232, 221, 212, 0.34) !important;
}

[data-theme="dark"] .bb-sofia-smart-draft-hint {
  color: #B8A898;
}

/* ── Draft Cards ────────────────────────────────────────── */

.bb-sofia-draft-cards {
  padding: 4px 16px 12px;
  animation: sofia-fade-in 0.25s ease;
}

.bb-sofia-draft-cards-label {
  font-family: var(--font-family);
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--bb-sage-dark, #4A7A68);
  margin: 0 0 10px;
  letter-spacing: 0.02em;
}

.bb-sofia-draft-card {
  padding: 14px 16px;
  margin-bottom: 10px;
  background: rgba(168, 197, 184, 0.06);
  border: 1.5px solid rgba(168, 197, 184, 0.2);
  border-radius: 14px;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.bb-sofia-draft-card:hover {
  border-color: rgba(168, 197, 184, 0.4);
  background: rgba(168, 197, 184, 0.1);
}

.bb-sofia-draft-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.bb-sofia-draft-card-label {
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--bb-sage-dark, #4A7A68);
}

.bb-sofia-draft-card-badge {
  font-family: var(--font-family);
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--bb-sage-dark, #4A7A68);
  background: rgba(168, 197, 184, 0.15);
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.bb-sofia-draft-card-preview {
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  line-height: 1.5;
  color: var(--bb-warm-text, #5C4D43);
  margin: 0 0 10px;
}

.bb-sofia-draft-card-use {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 6px 14px;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--bb-sage-dark, #4A7A68);
  background: rgba(168, 197, 184, 0.12);
  border: 1.5px solid rgba(168, 197, 184, 0.3);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.bb-sofia-draft-card-use:hover {
  background: var(--bb-sage-dark, #4A7A68);
  border-color: var(--bb-sage-dark, #4A7A68);
  color: var(--bb-white, #F7F2EA);
  transform: translateY(-1px);
}

.bb-sofia-draft-card-use:focus-visible {
  outline: none;
  outline-offset: 2px;
}

.bb-sofia-draft-card-use:active {
  transform: scale(0.97);
}

.bb-sofia-draft-cards-skeleton {
  display: block;
}

.bb-sofia-draft-card-skeleton {
  height: 96px;
  margin-bottom: 10px;
  background: linear-gradient(90deg, rgba(168, 197, 184, 0.06) 25%, rgba(168, 197, 184, 0.12) 50%, rgba(168, 197, 184, 0.06) 75%);
  background-size: 200% 100%;
  border-radius: 14px;
  animation: sofia-shimmer 1.5s infinite;
}

/* ── Draft Cards Dark Mode ────────────────────────────── */

[data-theme="dark"] .bb-sofia-draft-card {
  background: rgba(168, 197, 184, 0.04);
  border-color: rgba(168, 197, 184, 0.12);
}

[data-theme="dark"] .bb-sofia-draft-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(232, 221, 212, 0.22);
}

[data-theme="dark"] .bb-sofia-draft-card-label {
  color: var(--bb-warm-text-light, #C9BAAA);
}

[data-theme="dark"] .bb-sofia-draft-card-badge {
  color: var(--bb-warm-text-light, #C9BAAA);
  background: rgba(232, 221, 212, 0.08);
}

[data-theme="dark"] .bb-sofia-draft-card-preview {
  color: #E8DDD4;
}

[data-theme="dark"] .bb-sofia-draft-cards-label {
  color: var(--bb-warm-text-light, #C9BAAA);
}

[data-theme="dark"] .bb-sofia-draft-card-use {
  color: var(--bb-warm-text-light, #C9BAAA);
  background: rgba(232, 221, 212, 0.08);
  border-color: rgba(232, 221, 212, 0.18);
}

[data-theme="dark"] .bb-sofia-draft-card-use:hover {
  background: rgba(232, 221, 212, 0.18);
  border-color: rgba(232, 221, 212, 0.28);
  color: #E8DDD4;
}

/* ── AI Snippet Loading ───────────────────────────────── */

.email-snippet-loading {
  display: inline;
  color: var(--bb-sage-dark, #4A7A68);
  font-size: var(--font-size-sm);
}

@media (prefers-reduced-motion: reduce) {
  .bb-sofia-smart-draft-btn,
  .bb-sofia-refinement-chip,
  .bb-sofia-refinement-chips,
  .bb-sofia-smart-draft,
  .bb-sofia-draft-card,
  .bb-sofia-draft-card-use,
  .bb-sofia-draft-cards {
    transition: none !important;
    animation: none !important;
  }

  .bb-sofia-smart-draft-btn:hover,
  .bb-sofia-refinement-chip:hover,
  .bb-sofia-draft-card-use:hover {
    transform: none !important;
  }

  .email-snippet-loading {
    animation: none !important;
  }
}

@media (max-width: 480px) {
  .bb-sofia-refinement-chip {
    min-height: 40px;
  }
}

html[data-theme="dark"] .bb-compose-sofia .ask-ai-mic.is-recording,
html[data-theme="dark"] .bb-compose-sofia .ask-ai-mic.ss-mic--listening,
html[data-theme="dark"] .bb-compose-sofia .ask-ai-mic.ss-mic--recording,
[data-theme="dark"] .bb-compose-sofia .ask-ai-mic.is-recording,
[data-theme="dark"] .bb-compose-sofia .ask-ai-mic.ss-mic--listening,
[data-theme="dark"] .bb-compose-sofia .ask-ai-mic.ss-mic--recording {
  -webkit-appearance: none !important;
  appearance: none !important;
  background: #c0392b !important;
  background-color: #c0392b !important;
  border-color: #c0392b !important;
  color: #fff !important;
}

/* ── Post-Draft Chips (calendar warning + task suggestion) ──── */

.sofia-post-draft-chips {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 16px;
  max-width: 100%;
  animation: sofia-chip-slide-in 0.2s ease;
}

@keyframes sofia-chip-slide-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.sofia-calendar-warning,
.sofia-task-suggestion,
.sofia-chip-success {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 12px;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  line-height: 1.4;
}

.sofia-calendar-warning {
  background: rgba(212, 168, 154, 0.15);
  border: 1.5px solid rgba(155, 96, 80, 0.2);
  color: var(--bb-warm-text, #5C4D43);
}

.sofia-task-suggestion {
  background: rgba(139, 175, 156, 0.15);
  border: 1.5px solid rgba(74, 122, 104, 0.2);
  color: var(--bb-warm-text, #5C4D43);
}

.sofia-chip-success {
  background: rgba(74, 160, 110, 0.12);
  border: 1.5px solid rgba(74, 160, 110, 0.25);
  color: var(--bb-sage-dark, #4A7A68);
  font-weight: 600;
  animation: sofia-chip-success-fade 3s ease forwards;
}

@keyframes sofia-chip-success-fade {
  0%, 70% { opacity: 1; }
  100%    { opacity: 0; }
}

.sofia-chip-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.sofia-calendar-warning .sofia-chip-icon svg {
  stroke: var(--bb-rose-dark, #9B6050);
}

.sofia-task-suggestion .sofia-chip-icon svg {
  stroke: var(--bb-sage-dark, #4A7A68);
}

.sofia-chip-success .sofia-chip-icon {
  font-size: var(--font-size-md);
  color: var(--bb-sage-dark, #4A7A68);
}

.sofia-chip-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sofia-chip-due {
  flex-shrink: 0;
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--bb-sage-dark, #4A7A68);
  background: rgba(139, 175, 156, 0.2);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

.sofia-chip-create {
  flex-shrink: 0;
  min-height: 32px;
  padding: 4px 14px;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--bb-white, #F7F2EA);
  background: var(--bb-sage-dark, #4A7A68);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.sofia-chip-create:hover {
  background: var(--bb-sage-text, #3D6B57);
  transform: translateY(-1px);
}

.sofia-chip-create:active {
  transform: scale(0.96);
}

.sofia-chip-create:disabled {
  opacity: 0.6;
  cursor: progress;
  transform: none;
}

.sofia-chip-dismiss {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-lg);
  line-height: 1;
  color: var(--bb-warm-text-light, #8B7B6B);
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s ease, background 0.2s ease;
}

.sofia-chip-dismiss:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.06);
}

/* ── Post-Draft Chips — Dark Mode ─────────────────────────── */

[data-theme="dark"] .sofia-calendar-warning {
  background: rgba(212, 168, 154, 0.1) !important;
  border-color: rgba(212, 168, 154, 0.18) !important;
  color: #E8DDD4 !important;
}

[data-theme="dark"] .sofia-task-suggestion {
  background: rgba(232, 221, 212, 0.08) !important;
  border-color: rgba(232, 221, 212, 0.18) !important;
  color: #E8DDD4 !important;
}

[data-theme="dark"] .sofia-chip-success {
  background: rgba(232, 221, 212, 0.08) !important;
  border-color: rgba(232, 221, 212, 0.18) !important;
  color: var(--bb-warm-text-light, #C9BAAA) !important;
}

[data-theme="dark"] .sofia-chip-icon svg {
  opacity: 0.9 !important;
}

[data-theme="dark"] .sofia-chip-due {
  background: rgba(232, 221, 212, 0.10) !important;
  color: var(--bb-warm-text-light, #C9BAAA) !important;
}

[data-theme="dark"] .sofia-chip-create {
  background: rgba(232, 221, 212, 0.18) !important;
  color: #E8DDD4 !important;
}

[data-theme="dark"] .sofia-chip-create:hover {
  background: rgba(232, 221, 212, 0.26) !important;
}

[data-theme="dark"] .sofia-chip-dismiss {
  color: #B8A898 !important;
}

[data-theme="dark"] .sofia-chip-dismiss:hover {
  background: rgba(255, 255, 255, 0.08) !important;
}

/* ── Post-Draft Chips — Mobile ─────────────────────────────── */

@media (max-width: 600px) {
  .sofia-calendar-warning,
  .sofia-task-suggestion,
  .sofia-chip-success {
    flex-wrap: wrap;
    min-height: 44px;
    padding: 10px 12px;
  }

  .sofia-chip-text {
    flex-basis: calc(100% - 60px);
  }

  .sofia-chip-due {
    order: 3;
  }

  .sofia-chip-create {
    min-height: 44px;
    flex-grow: 1;
    order: 4;
  }

  .sofia-chip-dismiss {
    min-width: 44px;
    min-height: 44px;
  }
}

/* ── Post-Draft Chips — Reduced Motion ─────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .sofia-post-draft-chips,
  .sofia-chip-create,
  .sofia-chip-success {
    transition: none !important;
    animation: none !important;
  }

  .sofia-chip-create:hover {
    transform: none !important;
  }
}

/* ── Sofia Trigger Button ────────────────────────────────── */

.bb-sofia-trigger-wrap {
  padding: 8px 16px 4px;
  position: relative;
}

.bb-sofia-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  min-height: 36px;
  background: transparent;
  border: 1px solid rgba(228, 220, 212, 0.4);
  border-radius: 20px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.bb-sofia-trigger-btn:hover {
  border-color: var(--bb-sage, #A8C5B8);
  background: var(--bb-sage-bg, #F2F8F5);
}

.bb-sofia-trigger-icon {
  width: 14px;
  height: 14px;
  stroke: var(--bb-sage, #A8C5B8);
  flex-shrink: 0;
}

.bb-sofia-trigger-text {
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--bb-warm-text-light, #8B7B6B);
}

/* ── Sofia Menu ──────────────────────────────────────────── */

.bb-sofia-menu {
  position: absolute;
  left: 16px;
  bottom: calc(100% + 4px);
  z-index: 100;
  min-width: 200px;
  background: var(--sk-bg-surface, #FFFEFB);
  border: 1px solid var(--sk-border, rgba(228, 220, 212, 0.72));
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  padding: 4px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.bb-sofia-menu.is-open {
  opacity: 1;
  transform: translateY(0);
}

.bb-sofia-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--bb-warm-text, #5C4D43);
  text-align: left;
  transition: background 0.15s ease;
}

.bb-sofia-menu-item:hover {
  background: rgba(168, 197, 184, 0.12);
}

.bb-sofia-menu-item svg {
  flex-shrink: 0;
  stroke: var(--bb-sage-dark, #4A7A68);
}

/* ── Single Draft Card Actions Row ───────────────────────── */

.bb-sofia-draft-card-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bb-sofia-draft-card-regen {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--bb-sage-dark, #4A7A68);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.bb-sofia-draft-card-regen:hover {
  color: var(--bb-sage-text, #3D6B57);
}

/* ── Inline Context Summary ──────────────────────────────── */

.bb-sofia-context-bar--inline {
  margin: 4px 16px 8px;
  border: none;
  background: transparent;
  border-left: none;
  padding: 0 0 0 2px;
}

.bb-sofia-context-bar--inline .bb-sofia-context-text {
  font-size: var(--font-size-sm);
  color: var(--sk-text-secondary, var(--bb-warm-text-light, #8B7B6B));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  cursor: default;
}

.bb-sofia-context-bar--inline .bb-sofia-context-text.is-expandable {
  cursor: pointer;
}

.bb-sofia-context-bar--inline .bb-sofia-context-text.is-expanded {
  white-space: normal;
}

/* ── Sofia Trigger — Dark Mode ───────────────────────────── */

[data-theme="dark"] .bb-sofia-trigger-btn {
  border-color: rgba(255, 255, 255, 0.1) !important;
}

[data-theme="dark"] .bb-sofia-trigger-btn:hover {
  border-color: var(--bb-sage, #A8C5B8) !important;
  background: rgba(168, 197, 184, 0.1) !important;
}

[data-theme="dark"] .bb-sofia-trigger-text {
  color: #B8A898 !important;
}

[data-theme="dark"] .bb-sofia-menu {
  background: #241F1B !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

[data-theme="dark"] .bb-sofia-menu-item {
  color: #E8DDD4 !important;
}

[data-theme="dark"] .bb-sofia-menu-item:hover {
  background: rgba(168, 197, 184, 0.1) !important;
}

[data-theme="dark"] .bb-sofia-draft-card-regen {
  color: #A8C5B8 !important;
}

[data-theme="dark"] .bb-sofia-context-bar--inline .bb-sofia-context-text {
  color: #B8A898 !important;
}

/* ── Sofia Trigger — Mobile ──────────────────────────────── */

@media (max-width: 768px) {
  .bb-sofia-trigger-btn {
    min-height: 44px;
    padding: 8px 16px;
  }

  .bb-sofia-menu-item {
    min-height: 48px;
  }
}

/* ── Sofia Trigger — Reduced Motion ──────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .bb-sofia-trigger-btn,
  .bb-sofia-menu {
    transition: none !important;
  }

  .bb-sofia-menu.is-open {
    transform: none !important;
  }
}

/* ── Compose Sofia post-draft frontier ─────────────────────── */

.email-page .bb-compose-sofia .ask-ai-welcome .ask-ai-suggestions {
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
  width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
  background: none !important;
  border: none !important;
}

.email-page .bb-compose-sofia .ask-ai-welcome .ask-ai-suggestion {
  display: flex !important;
  align-items: center !important;
  width: 100% !important;
  padding: 12px 14px !important;
  border-radius: 12px !important;
  border: 1px solid rgba(228, 220, 212, 0.9) !important;
  background: #FFFEFB !important;
  color: #3A2F26 !important;
  font-size: var(--font-size-sm) !important;
  font-weight: var(--font-weight-semibold) !important;
  line-height: 1.2 !important;
  letter-spacing: 0 !important;
  gap: 10px !important;
  box-shadow: none !important;
  cursor: pointer !important;
  text-align: left !important;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease !important;
}

.email-page .bb-compose-sofia .ask-ai-welcome .ask-ai-suggestion svg {
  width: 16px !important;
  height: 16px !important;
  flex-shrink: 0 !important;
  color: #5C4D43 !important;
}

.email-page .bb-compose-sofia .ask-ai-welcome .ask-ai-suggestion--primary {
  background: #4A7A68 !important;
  border-color: #4A7A68 !important;
  color: #FFFEFB !important;
}

.email-page .bb-compose-sofia .ask-ai-welcome .ask-ai-suggestion--primary svg {
  color: #FFFEFB !important;
}

.email-page .bb-compose-sofia .ask-ai-welcome .ask-ai-suggestion--primary:hover {
  background: #3F6A5A !important;
  border-color: #3F6A5A !important;
}

.email-page .bb-compose-sofia .ask-ai-welcome .ask-ai-suggestion:not(.ask-ai-suggestion--primary):hover {
  background: #FBF8F2 !important;
  border-color: #DCD3C5 !important;
}

.email-page .bb-compose-sofia .ask-ai-welcome .ask-ai-suggestion:active {
  transform: translateY(1px) !important;
}

.email-page .bb-compose-sofia .ask-ai-welcome .ask-ai-suggestion:focus-visible {
  outline: 2px solid #4A7A68 !important;
  outline-offset: 2px !important;
}

.email-page .bb-compose-sofia .ask-ai-welcome .ask-ai-suggestion:focus:not(:focus-visible) {
  outline: none !important;
}

/* ── Tone popover wrapper ─────────────────────────────────── */

.email-page .bb-compose-sofia .ask-ai-welcome .calm-tone-wrap {
  position: relative;
  width: 100%;
}

.email-page .bb-compose-sofia .ask-ai-welcome .calm-tone-chevron {
  margin-left: auto !important;
  flex-shrink: 0 !important;
  transition: transform 120ms ease !important;
}

.email-page .bb-compose-sofia .ask-ai-welcome .ask-ai-suggestion[aria-expanded="true"] .calm-tone-chevron {
  transform: rotate(180deg) !important;
}

.email-page .bb-compose-sofia .ask-ai-welcome .calm-tone-pop {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: #FFFEFB;
  border: 1px solid #E8E1D6;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(58, 47, 38, 0.08);
  z-index: 20;
}

/* ── Tone chips ───────────────────────────────────────────── */

.email-page .bb-compose-sofia .calm-tone-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 120ms ease;
}

.email-page .bb-compose-sofia .calm-tone-chip:hover {
  background: #FBF8F2;
}

.email-page .bb-compose-sofia .calm-tone-chip:focus-visible {
  outline: 2px solid #4A7A68;
  outline-offset: 2px;
}

.email-page .bb-compose-sofia .calm-tone-chip:focus:not(:focus-visible) {
  outline: none;
}

.email-page .bb-compose-sofia .calm-tone-label {
  color: #3A2F26;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  line-height: 1.2;
}

.email-page .bb-compose-sofia .calm-tone-sub {
  color: #9A8E82;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-normal);
  line-height: 1.3;
}

/* ── Reduced motion ───────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .email-page .bb-compose-sofia .ask-ai-welcome .ask-ai-suggestion:active {
    transform: none !important;
  }
  .email-page .bb-compose-sofia .ask-ai-welcome .calm-tone-chevron {
    transition: none !important;
  }
}

/* ── Dark theme ───────────────────────────────────────────── */

[data-theme="dark"] .email-page .bb-compose-sofia .ask-ai-welcome .ask-ai-suggestion {
  background: rgba(255, 255, 255, 0.06) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  color: #F0EBE5 !important;
}

[data-theme="dark"] .email-page .bb-compose-sofia .ask-ai-welcome .ask-ai-suggestion svg {
  color: #C4B8AB !important;
}

[data-theme="dark"] .email-page .bb-compose-sofia .ask-ai-welcome .ask-ai-suggestion--primary {
  background: #4A7A68 !important;
  border-color: #4A7A68 !important;
  color: #F0EBE5 !important;
}

[data-theme="dark"] .email-page .bb-compose-sofia .ask-ai-welcome .ask-ai-suggestion--primary svg {
  color: rgba(240, 235, 229, 0.85) !important;
}

[data-theme="dark"] .email-page .bb-compose-sofia .ask-ai-welcome .ask-ai-suggestion--primary:hover {
  background: #5A8A78 !important;
  border-color: #5A8A78 !important;
}

[data-theme="dark"] .email-page .bb-compose-sofia .ask-ai-welcome .ask-ai-suggestion:not(.ask-ai-suggestion--primary):hover {
  background: rgba(168, 197, 184, 0.1) !important;
  border-color: rgba(255, 255, 255, 0.18) !important;
}

[data-theme="dark"] .email-page .bb-compose-sofia .calm-tone-pop {
  background: #2A241E;
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .email-page .bb-compose-sofia .calm-tone-chip:hover {
  background: rgba(168, 197, 184, 0.1);
}

[data-theme="dark"] .email-page .bb-compose-sofia .calm-tone-label {
  color: #F0EBE5;
}

[data-theme="dark"] .email-page .bb-compose-sofia .calm-tone-sub {
  color: #9A8E82;
}
