/* =====================================================================
   _visual-chat.css — Premium Chat Panel Visual Overhaul
   Kvill Mobile — "Гена" AI Assistant

   Dependencies: style.css (tokens), mobile.css (base chat layout)
   Loaded AFTER mobile.css — overrides chat section styles.

   ─── HTML CHANGES NEEDED ─────────────────────────────────────────────

   1. In .m-chat-panel, ADD an empty-state div inside #mChatMessages
      (shown when no messages exist, hidden when messages appear):

      <div class="m-chat-empty" id="mChatEmpty">
        <div class="m-chat-empty-avatar">
          <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
               stroke-linecap="round" stroke-linejoin="round">
            <polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/>
          </svg>
        </div>
        <div class="m-chat-empty-title">Гена</div>
        <div class="m-chat-empty-text">Скинь данные, Excel, PDF или опиши задачу — соберу презентацию</div>
        <div class="m-chat-empty-chips">
          <button class="m-chat-chip" data-prompt="Квартальный отчёт с KPI и графиками">Отчёт с KPI</button>
          <button class="m-chat-chip" data-prompt="Коммерческое предложение для клиента">КП для клиента</button>
          <button class="m-chat-chip" data-prompt="Питч-дек для инвесторов с метриками">Питч-дек</button>
        </div>
      </div>

   2. The .m-chat-close button currently uses class "m-chat-close" in HTML.
      CSS below targets both .m-chat-close and .m-chat-close-btn for compat.

   3. The textarea currently has class "m-composer-input" in HTML.
      CSS below targets both .m-composer-input and .m-chat-input.

   4. The send button has class "m-composer-send" in HTML.
      CSS below targets both .m-composer-send and .m-chat-send.

   5. "Гена" status indicator:
      <div class="m-chat-subtitle">
        <span class="m-chat-status-dot"></span>
        презентации из данных
      </div>

   ═══════════════════════════════════════════════════════════════════ */


/* ─────────────────────────────────────────────
   CHAT PANEL — Container
   ───────────────────────────────────────────── */

.m-chat-panel {
  background: var(--m-panel-bg);
  border: 1px solid var(--m-panel-border);
  border-radius: 16px;
  box-shadow: var(--m-panel-shadow);
  transition: transform 0.4s var(--ease-spring),
              opacity 0.3s var(--ease),
              height 0.3s var(--ease-spring),
              border-radius 0.3s var(--ease);
}

/* No specular highlight */
.m-chat-panel::before {
  display: none;
}

/* No inner glow */
.m-chat-panel::after {
  display: none;
}

/* Keyboard-open: softer transition */
.m-chat-panel.keyboard-open {
  border-radius: 16px 16px 0 0;
}


/* ─────────────────────────────────────────────
   DRAG HANDLE
   ───────────────────────────────────────────── */

.m-chat-drag-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--text-3);
  margin: 0 auto;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}

.m-chat-drag-handle::before {
  content: '';
  position: absolute;
  inset: -10px -20px;
}

@media (hover: none) and (pointer: coarse) {
  .m-chat-drag-handle {
    opacity: 0.5;
    margin-top: 10px;
    margin-bottom: -2px;
  }
}


/* ─────────────────────────────────────────────
   HEADER — Branded Гена header
   ───────────────────────────────────────────── */

.m-chat-header {
  display: none;
  align-items: center;
  padding: 14px 14px 12px 16px;
  gap: 10px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  position: relative;
  z-index: 2;
  background: transparent;
}

[data-theme="dark"] .m-chat-header {
  background: transparent;
  border-bottom-color: rgba(255, 255, 255, 0.04);
}

/* Avatar — gradient orb */
.m-chat-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0071e3 0%, #2997ff 100%);
  box-shadow:
    0 2px 8px rgba(0, 113, 227, 0.25),
    inset 0 1px 1px rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
  position: relative;
}

.m-chat-avatar svg { display: none; }

/* Title group */
.m-chat-title-group {
  flex: 1;
  min-width: 0;
}

.m-chat-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-0);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.m-chat-subtitle {
  font-size: 11px;
  color: var(--text-2);
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Online status dot */
.m-chat-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
  animation: vc-status-pulse 2s ease-in-out infinite;
}

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

/* Close button — targets both class variants */
.m-chat-close,
.m-chat-close-btn {
  width: 32px;
  height: 32px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: none;
  border-radius: 10px;
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s var(--ease);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.m-chat-close:hover,
.m-chat-close-btn:hover {
  background: var(--bg-input);
  color: var(--text-0);
}

.m-chat-close:active,
.m-chat-close-btn:active {
  background: var(--bg-input-hover);
  transform: scale(0.92);
}


/* ─────────────────────────────────────────────
   MESSAGES AREA
   ───────────────────────────────────────────── */

.m-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: none; /* Hide scrollbar Firefox */
  overscroll-behavior: contain;
  position: relative;
  z-index: 1;
}

/* Hide scrollbar — WebKit */
.m-chat-messages::-webkit-scrollbar {
  width: 0;
  display: none;
}


/* ─────────────────────────────────────────────
   EMPTY STATE — When no messages
   ───────────────────────────────────────────── */

.m-chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  padding: 20px 16px 12px;
  flex: 1;
  gap: 0;
  animation: vc-empty-in 0.5s var(--ease-spring);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@keyframes vc-empty-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Large avatar in empty state — gradient orb with glow */
.m-chat-empty-avatar {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0071e3 0%, #2997ff 100%);
  box-shadow: 0 1px 4px rgba(0, 113, 227, 0.25);
  margin-right: 6px;
  flex-shrink: 0;
  position: relative;
}

.m-chat-empty-avatar svg { display: none; }

.m-chat-empty-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}

.m-chat-empty-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-0);
  margin-bottom: 0;
  letter-spacing: -0.02em;
}

.m-chat-empty-text {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
  max-width: 240px;
  margin-bottom: 14px;
}

/* Quick-action chips */
.m-chat-empty-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.m-chat-chip {
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-1);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  white-space: nowrap;
}

.m-chat-chip:hover {
  background: var(--bg-input-hover);
  border-color: var(--border-hover);
  color: var(--text-0);
}

.m-chat-chip:active {
  transform: scale(0.95);
}

[data-theme="dark"] .m-chat-chip {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .m-chat-chip:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.14);
}


/* ─────────────────────────────────────────────
   DEMO PREVIEW WIDGET
   ───────────────────────────────────────────── */

.m-demo-chat {
  width: 100%;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border-radius: 12px;
  background: var(--canvas);
  border: 1px solid var(--border);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.04);
  text-align: left;
  margin-top: 6px;
  min-height: 80px;
}

.m-demo-bubble {
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 11.5px;
  line-height: 1.4;
  max-width: 92%;
}

.m-demo-bubble-user {
  align-self: flex-end;
  background: var(--bg-input);
  border: 1px solid var(--border);
}

.m-demo-bubble-ai {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  position: relative;
  padding-left: 22px;
}

/* AI avatar dot */
.m-demo-bubble-ai::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 10px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0071e3 0%, #2997ff 100%);
  box-shadow: 0 0 4px rgba(0, 113, 227, 0.25);
}

.m-demo-files {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}

.m-demo-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--canvas);
  border: 1px solid var(--border);
  font-size: 9.5px;
  font-family: var(--font-body);
  font-weight: 500;
  color: var(--text-1);
  white-space: nowrap;
}

/* file icon in demo chips handled by .file-icon-wrap */

.m-demo-text {
  font-family: var(--font-body);
  font-size: 11.5px;
  color: var(--text-0);
  line-height: 1.4;
}

.m-demo-chat .m-demo-slides {
  display: flex;
  flex-direction: row;
  gap: 4px;
  margin-top: 5px;
  width: auto;
  max-width: none;
}

.m-demo-slide {
  width: 42px;
  height: 28px;
  border-radius: 3px;
  background: var(--canvas);
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  padding: 3px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.m-demo-slide-bar {
  width: 55%;
  height: 3px;
  border-radius: 1.5px;
  background: var(--text-3);
  opacity: 0.4;
}

.m-demo-slide-line {
  height: 2px;
  border-radius: 1px;
  background: var(--border);
}

.m-demo-slide-chart {
  flex: 1;
  border-radius: 2px;
  background: linear-gradient(135deg, rgba(0, 113, 227, 0.08), rgba(41, 151, 255, 0.04));
  border: 1px solid rgba(0, 113, 227, 0.06);
}

/* Animation states */
.m-demo-bubble {
  opacity: 0;
  transform: translateY(8px);
}

.m-demo-bubble.show {
  animation: mDemoBubbleIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes mDemoBubbleIn {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.m-demo-chip {
  opacity: 0;
  transform: translateY(4px) scale(0.92);
}

.m-demo-chip.show {
  animation: mDemoChipIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: calc(var(--i, 0) * 0.12s);
}

@keyframes mDemoChipIn {
  from { opacity: 0; transform: translateY(4px) scale(0.92); }
  65%  { opacity: 1; transform: translateY(-1px) scale(1.02); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Caret */
.m-demo-caret {
  display: inline-block;
  width: 1.5px;
  height: 12px;
  background: var(--accent, #0071e3);
  margin-left: 1px;
  vertical-align: text-bottom;
  opacity: 0;
}

.m-demo-caret.blink {
  animation: mDemoBlink 0.55s step-end infinite;
}

@keyframes mDemoBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Thinking dots */
.m-demo-thinking {
  display: none;
  gap: 3px;
  padding: 2px 0;
}

.m-demo-thinking.show {
  display: flex;
}

.m-demo-think-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-2);
  opacity: 0;
}

.m-demo-thinking.show .m-demo-think-dot {
  animation: mDemoDotPulse 1.2s ease-in-out infinite;
  animation-delay: calc(var(--d) * 0.15s);
}

@keyframes mDemoDotPulse {
  0%, 80%, 100% { transform: scale(0.5); opacity: 0.2; }
  40% { transform: scale(1); opacity: 1; }
}

/* Slides animation */
.m-demo-chat .m-demo-slides {
  opacity: 0;
  transform: translateY(3px);
}

.m-demo-chat .m-demo-slides.show {
  animation: mDemoSlidesIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes mDemoSlidesIn {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: translateY(0); }
}

.m-demo-slide {
  opacity: 0;
  transform: scale(0.9);
}

.m-demo-chat .m-demo-slides.show .m-demo-slide {
  animation: mDemoCardPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: calc(var(--s, 0) * 0.08s);
}

@keyframes mDemoCardPop {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

/* Fade out between scenarios */
.m-demo-chat.fade-out {
  animation: mDemoFadeOut 0.45s ease forwards;
}

@keyframes mDemoFadeOut {
  to { opacity: 0; transform: translateY(-3px) scale(0.98); }
}


/* Dark theme — demo */
[data-theme="dark"] .m-demo-chat {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.12);
}

[data-theme="dark"] .m-demo-bubble-user {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .m-demo-bubble-ai {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.06);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.10);
}

[data-theme="dark"] .m-demo-chip {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .m-demo-slide {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .m-demo-slide-chart {
  background: linear-gradient(135deg, rgba(41, 151, 255, 0.10), rgba(100, 210, 255, 0.06));
  border-color: rgba(41, 151, 255, 0.08);
}


/* ─────────────────────────────────────────────
   MESSAGE BUBBLES
   ───────────────────────────────────────────── */

.m-chat-msg {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.008em;
  max-width: 85%;
  word-wrap: break-word;
  white-space: pre-wrap;
  animation: vc-msg-in 0.3s var(--ease-spring);
  position: relative;
}

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

/* ── User message — iMessage-style pill ── */
.m-chat-msg.user {
  background: #E9E9EB;
  color: #1a1a1a;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  border: none;
  box-shadow: none;
  max-width: 78%;
  font-size: 14px;
}

[data-theme="dark"] .m-chat-msg.user {
  background: #3A3A3C;
  color: #f0f0f0;
  box-shadow: none;
}

/* ── AI message — clean, no bubble, left-aligned ── */
.m-chat-msg.ai {
  background: transparent;
  color: #2c2c2e;
  align-self: flex-start;
  border: none;
  border-radius: 0;
  box-shadow: none;
  max-width: 100%;
  padding: 6px 4px;
  font-size: 14px;
  line-height: 1.6;
  letter-spacing: -0.01em;
  white-space: pre-wrap;
  word-break: break-word;
}

[data-theme="dark"] .m-chat-msg.ai {
  background: transparent;
  color: #d4d4d8;
  border: none;
  box-shadow: none;
}

/* Message timestamp — add .m-msg-time span inside messages if needed */
.m-msg-time {
  font-size: 11px;
  color: var(--text-2);
  margin-top: 4px;
  display: block;
  text-align: right;
}

.m-chat-msg.ai .m-msg-time {
  text-align: left;
}

.m-chat-msg.user .m-msg-time {
  color: rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .m-chat-msg.user .m-msg-time {
  color: rgba(255, 255, 255, 0.40);
}


/* ─────────────────────────────────────────────
   TYPING INDICATOR
   ───────────────────────────────────────────── */

.m-chat-typing {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  align-self: flex-start;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  animation: vc-msg-in 0.3s var(--ease-spring);
}

[data-theme="dark"] .m-chat-typing {
  background: transparent;
  border: none;
}

.m-typing-dots {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

.m-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-blue);
  opacity: 0.4;
  animation: vc-typing 1.4s ease-in-out infinite;
}

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

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

.m-typing-status {
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

@keyframes vc-typing {
  0%, 60%, 100% {
    transform: translateY(0) scale(1);
    opacity: 0.3;
  }
  30% {
    transform: translateY(-5px) scale(1.15);
    opacity: 1;
  }
}


/* ─────────────────────────────────────────────
   COMPOSER — Custom Properties
   ───────────────────────────────────────────── */

:root {
  --m-composer-bg: rgba(0, 0, 0, 0.03);
  --m-composer-border: rgba(0, 0, 0, 0.08);
  --m-composer-radius: 16px;
  --m-composer-send-radius: 8px;
}
[data-theme="dark"] {
  --m-composer-bg: rgba(255, 255, 255, 0.04);
  --m-composer-border: rgba(255, 255, 255, 0.10);
}


/* ─────────────────────────────────────────────
   PLUS MENU — popup from + button
   ───────────────────────────────────────────── */

.m-plus-menu-wrap {
  position: relative;
}

.m-plus-popup {
  position: absolute;
  bottom: calc(100% + 10px);
  left: -2px;
  min-width: 192px;
  background: var(--bg-solid, #fff);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 13px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.10),
    0 1px 3px rgba(0, 0, 0, 0.04);
  padding: 4px;
  z-index: 100;
  opacity: 0;
  transform: translateY(4px) scale(0.94);
  transform-origin: bottom left;
  pointer-events: none;
  transition: opacity 0.16s ease-out, transform 0.16s ease-out;
}
.m-plus-popup.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Menu items */
.m-plus-popup-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: 9px;
  font-family: var(--font-body, -apple-system, BlinkMacSystemFont, sans-serif);
  font-size: 13px;
  font-weight: 400;
  color: var(--text-0, #1d1d1f);
  cursor: pointer;
  transition: background 0.1s;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: -0.01em;
}
.m-plus-popup-item:active {
  background: rgba(0, 0, 0, 0.04);
}
.m-plus-popup-item svg {
  color: var(--text-2, #86868b);
  flex-shrink: 0;
  opacity: 0.7;
}

/* Divider */
.m-plus-popup-divider {
  height: 1px;
  background: rgba(0, 0, 0, 0.05);
  margin: 3px 6px;
}

/* Effort section */
.m-plus-popup-effort {
  padding: 6px 6px 4px;
}
.m-plus-popup-label {
  display: block;
  font-family: var(--font-body, -apple-system, BlinkMacSystemFont, sans-serif);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-3, #aeaeb2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 5px;
  padding-left: 4px;
}

/* Effort segmented control */
.m-effort-track {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 7px;
  padding: 2px;
}
.m-effort-indicator {
  position: absolute;
  top: 2px; bottom: 2px; left: 2px;
  width: calc(33.333% - 1.33px);
  background: var(--bg-solid, #fff);
  border-radius: 5px;
  box-shadow: 0 0.5px 2px rgba(0, 0, 0, 0.10), 0 0.5px 1px rgba(0, 0, 0, 0.06);
  transition: transform 0.2s var(--ease, ease);
  z-index: 0;
  /* Default: High (index 2) */
  transform: translateX(200%);
}
.m-effort-option {
  position: relative;
  z-index: 1;
  background: none;
  border: none;
  padding: 4px 0;
  font-family: var(--font-body, -apple-system, BlinkMacSystemFont, sans-serif);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2, #86868b);
  cursor: pointer;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
  text-align: center;
}
.m-effort-option.active {
  color: var(--text-0, #1d1d1f);
}

/* Plus button rotation when open */
.m-plus-menu-wrap .m-composer-circle-btn svg {
  transition: transform 0.2s var(--ease, ease);
}
.m-plus-menu-wrap.open .m-composer-circle-btn svg {
  transform: rotate(45deg);
}

/* Dark theme */
[data-theme="dark"] .m-plus-popup {
  background: #2c2c2e;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.35),
    0 1px 3px rgba(0, 0, 0, 0.15);
}
[data-theme="dark"] .m-plus-popup-item:active {
  background: rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] .m-plus-popup-divider {
  background: rgba(255, 255, 255, 0.07);
}
[data-theme="dark"] .m-effort-track {
  background: rgba(255, 255, 255, 0.07);
}
[data-theme="dark"] .m-effort-indicator {
  background: rgba(255, 255, 255, 0.14);
  box-shadow: 0 0.5px 2px rgba(0, 0, 0, 0.25);
}
[data-theme="dark"] .m-effort-option.active {
  color: var(--text-0, #f5f5f7);
}


/* ─────────────────────────────────────────────
   COMPOSER — Premium input bar
   ───────────────────────────────────────────── */

.m-chat-composer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  margin: 0 8px;
  margin-bottom: max(8px, var(--m-safe-bottom));
  border: 1px solid var(--m-composer-border);
  border-radius: var(--m-composer-radius);
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  background: var(--m-composer-bg);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.m-chat-composer:focus-within {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ── @keyframes ── */
@keyframes m-rec-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}
@keyframes m-transcribe-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}
@keyframes m-transcribe-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Circle buttons (plus + mic) ── */
.m-composer-circle-btn {
  width: 30px;
  height: 30px;
  min-width: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--m-composer-border);
  border-radius: 8px;
  color: var(--text-3);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: color 0.15s var(--ease), background 0.15s var(--ease), border-color 0.15s var(--ease);
  padding: 0;
  flex-shrink: 0;
  position: relative;
}
.m-composer-circle-btn svg {
  width: 14px;
  height: 14px;
}
.m-composer-circle-btn:hover {
  color: var(--text-1);
  border-color: var(--text-3);
  background: rgba(0, 0, 0, 0.03);
}
.m-composer-circle-btn:active {
  transform: scale(0.92);
  background: rgba(0, 0, 0, 0.06);
  transition: transform 0.08s ease-out;
}
[data-theme="dark"] .m-composer-circle-btn:active {
  background: rgba(255, 255, 255, 0.10);
}
/* ── Recording state — composer transforms ── */
.m-chat-composer.recording {
  border-color: rgba(0, 0, 0, 0.15);
}
[data-theme="dark"] .m-chat-composer.recording {
  border-color: rgba(255, 255, 255, 0.15);
}
/* Hide normal elements during recording */
.m-chat-composer.recording > .m-composer-circle-btn,
.m-chat-composer.recording > .m-composer-input,
.m-chat-composer.recording > .m-chat-input,
.m-chat-composer.recording > .m-composer-send,
.m-chat-composer.recording > .m-chat-send {
  display: none;
}
/* Recording indicator (inside pill) */
.m-recording-indicator {
  display: none;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.m-chat-composer.recording .m-recording-indicator {
  display: flex;
}
.m-recording-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-2, #666);
  flex-shrink: 0;
  animation: m-rec-pulse 1.5s ease-in-out infinite;
}
.m-recording-waveform {
  flex: 1;
  height: 24px;
  min-width: 0;
}
.m-recording-time {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-2, #666);
  font-weight: 500;
  flex-shrink: 0;
  min-width: 28px;
  text-align: center;
}
.m-recording-cancel-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  min-width: 30px;
  border-radius: 8px;
  border: 1px solid var(--m-composer-border);
  background: none;
  color: var(--text-3);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.m-recording-cancel-btn:hover {
  color: var(--text-1);
  border-color: var(--text-3);
  background: rgba(0, 0, 0, 0.03);
}
.m-recording-cancel-btn:active {
  transform: scale(0.92);
}
[data-theme="dark"] .m-recording-cancel-btn {
  border-color: rgba(255, 255, 255, 0.12);
}
[data-theme="dark"] .m-recording-cancel-btn:hover {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.06);
}
.m-recording-stop-btn {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: var(--text-1, #1a1a1a);
  border: none;
  border-radius: 8px;
  padding: 0 12px;
  height: 30px;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
}
.m-recording-stop-btn:hover {
  opacity: 0.85;
}
.m-recording-stop-btn:active {
  transform: scale(0.96);
}
[data-theme="dark"] .m-recording-stop-btn {
  background: rgba(255, 255, 255, 0.9);
  color: #1a1a1a;
}

/* ── Transcribing state — shimmer on textarea ── */
.m-chat-composer.transcribing .m-composer-input,
.m-chat-composer.transcribing .m-chat-input {
  background: linear-gradient(90deg, var(--bg-input) 25%, rgba(0, 0, 0, 0.06) 50%, var(--bg-input) 75%);
  background-size: 200% 100%;
  animation: m-transcribe-shimmer 1.5s ease-in-out infinite;
}
[data-theme="dark"] .m-chat-composer.transcribing .m-composer-input,
[data-theme="dark"] .m-chat-composer.transcribing .m-chat-input {
  background: linear-gradient(90deg, var(--bg-input) 25%, rgba(255, 255, 255, 0.06) 50%, var(--bg-input) 75%);
  background-size: 200% 100%;
}
/* Mic button transcribing state */
.m-composer-circle-btn.transcribing {
  color: var(--text-2);
  animation: m-transcribe-pulse 1s ease-in-out infinite;
}
/* Touch targets on touch devices */
@media (pointer: coarse) {
  .m-composer-circle-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
  }
  .m-composer-circle-btn svg {
    width: 15px;
    height: 15px;
  }
}
/* Dark theme */
[data-theme="dark"] .m-composer-circle-btn {
  border-color: rgba(255, 255, 255, 0.18);
  color: var(--text-2);
}
[data-theme="dark"] .m-composer-circle-btn:hover {
  border-color: rgba(255, 255, 255, 0.30);
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.08);
}

/* Text input — targets both class variants */
.m-composer-input,
.m-chat-input {
  flex: 1;
  min-height: 30px;
  max-height: 120px;
  padding: 6px 10px;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-0);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.4;
  letter-spacing: -0.01em;
  resize: none;
  outline: none;
  overflow-y: auto;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
  -webkit-appearance: none;
  appearance: none;
}
/* Override generic textarea:focus from style.css */
.m-composer-input:focus,
.m-chat-input:focus {
  background: var(--bg-input-hover);
  border-color: transparent;
  box-shadow: none;
  outline: none;
}
/* CSS auto-resize (with @supports guard — JS fallback for older browsers) */
@supports (field-sizing: content) {
  .m-composer-input,
  .m-chat-input {
    field-sizing: content;
  }
}
/* iOS auto-zoom prevention — disabled: viewport has maximum-scale=1.0 */
/* Base 13px applies to all devices */

.m-composer-input::placeholder,
.m-chat-input::placeholder {
  color: var(--text-3);
}

/* Send button — targets both class variants */
.m-composer-send,
.m-chat-send {
  width: 30px;
  height: 30px;
  min-width: 30px;
  border-radius: var(--m-composer-send-radius);
  border: none;
  background: var(--accent);
  color: var(--canvas);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--ease);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  position: relative;
  overflow: hidden;
}
.m-composer-send svg,
.m-chat-send svg {
  width: 12px;
  height: 12px;
  position: relative;
  z-index: 1;
}
.m-composer-send:hover,
.m-chat-send:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}
.m-composer-send:active,
.m-chat-send:active {
  transform: scale(0.85);
  box-shadow: none;
  transition: transform 0.1s ease-out;
}
.m-composer-send.disabled,
.m-chat-send.disabled {
  opacity: 0.25;
  pointer-events: none;
  box-shadow: none;
}
/* Touch targets */
@media (pointer: coarse) {
  .m-composer-send,
  .m-chat-send {
    width: 34px;
    height: 34px;
    min-width: 34px;
  }
  .m-composer-send svg,
  .m-chat-send svg {
    width: 14px;
    height: 14px;
  }
}
/* Dark theme */
[data-theme="dark"] .m-composer-send:hover,
[data-theme="dark"] .m-chat-send:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

/* ── Abort mode — stop generation ── */
.m-composer-send.abort-mode,
.m-chat-send.abort-mode {
  background: #1a1a1a;
  border: none;
  box-shadow: none;
  opacity: 1;
  pointer-events: auto;
  cursor: pointer;
  animation: none;
}
.m-composer-send.abort-mode svg,
.m-chat-send.abort-mode svg {
  color: #fff;
  width: 14px;
  height: 14px;
}
.m-composer-send.abort-mode:hover,
.m-chat-send.abort-mode:hover {
  background: #000;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.m-composer-send.abort-mode:active,
.m-chat-send.abort-mode:active {
  transform: scale(0.85);
  box-shadow: none;
}
[data-theme="dark"] .m-composer-send.abort-mode,
[data-theme="dark"] .m-chat-send.abort-mode {
  background: #f0f0f0;
}
[data-theme="dark"] .m-composer-send.abort-mode svg,
[data-theme="dark"] .m-chat-send.abort-mode svg {
  color: #1a1a1a;
}
[data-theme="dark"] .m-composer-send.abort-mode:hover,
[data-theme="dark"] .m-chat-send.abort-mode:hover {
  background: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}


/* ─────────────────────────────────────────────
   SCRIM — darker backdrop when chat open
   ───────────────────────────────────────────── */

.m-scrim.active {
  background: rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .m-scrim.active {
  background: rgba(0, 0, 0, 0.25);
}


/* ─────────────────────────────────────────────
   GENERATION PROGRESS — inline in chat
   Shows when AI is generating slides
   ───────────────────────────────────────────── */

.m-chat-progress {
  align-self: flex-start;
  max-width: 82%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  animation: vc-msg-in 0.3s var(--ease-spring);
}

.m-chat-progress-label {
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 8px;
  font-weight: 500;
}

.m-chat-progress-bar {
  height: 3px;
  background: var(--bg-input);
  border-radius: 2px;
  overflow: hidden;
}

.m-chat-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-hover));
  border-radius: 2px;
  transition: width 0.3s var(--ease);
  position: relative;
}

.m-chat-progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 30px;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4));
  animation: vc-progress-shimmer 1.5s ease-in-out infinite;
}

@keyframes vc-progress-shimmer {
  0%   { opacity: 0; }
  50%  { opacity: 1; }
  100% { opacity: 0; }
}

[data-theme="dark"] .m-chat-progress {
  background: transparent;
  border: none;
}

[data-theme="dark"] .m-chat-progress-bar {
  background: rgba(255, 255, 255, 0.06);
}


/* ─────────────────────────────────────────────
   PAYWALL BANNER — Opportunity Card (C2 Cobalt)
   ───────────────────────────────────────────── */

.m-paywall-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 0 10px 4px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.06) 0%, rgba(59, 130, 246, 0.04) 100%);
  border: 1px solid rgba(37, 99, 235, 0.12);
  border-radius: 12px;
  font-size: 13px;
  color: var(--text-1);
  animation: vc-paywall-in 0.4s var(--ease-spring);
}

@keyframes vc-paywall-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.m-paywall-icon {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #0071e3, #2997ff);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.m-paywall-icon svg {
  width: 16px;
  height: 16px;
  color: #fff;
}

.m-paywall-body {
  flex: 1;
  min-width: 0;
}

.m-paywall-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-0);
  line-height: 1.3;
}

.m-paywall-sub {
  font-size: 11px;
  color: var(--text-2);
  margin-top: 1px;
}

.m-paywall-topup-btn {
  padding: 6px 16px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: var(--canvas);
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.2s var(--ease);
}

.m-paywall-topup-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.m-paywall-topup-btn:active {
  transform: scale(0.96);
}

[data-theme="dark"] .m-paywall-banner {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.10) 0%, rgba(59, 130, 246, 0.06) 100%);
  border-color: rgba(37, 99, 235, 0.18);
}

[data-theme="dark"] .m-paywall-topup-btn {
  background: var(--accent);
  color: var(--canvas);
}


/* ─────────────────────────────────────────────
   BREAKPOINT OVERRIDES
   ───────────────────────────────────────────── */

/* Compact mobile (iPhone SE, narrow) */
@media (max-width: 380px) {
  .m-chat-composer { gap: 4px; padding: 5px 6px; }
  .m-composer-circle-btn { width: 30px; height: 30px; min-width: 30px; }
  .m-composer-send, .m-chat-send { width: 30px; height: 30px; min-width: 30px; }
}

@media (min-width: 480px) {
  .m-chat-msg {
    font-size: 14px;
  }

  .m-chat-msg.ai {
    font-size: 14px;
  }

  .m-composer-input,
  .m-chat-input {
    font-size: 15px;
  }
}


/* ─────────────────────────────────────────────
   ACCESSIBILITY — Reduced motion
   ───────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .m-chat-panel,
  .m-chat-msg,
  .m-chat-empty,
  .m-typing-dot,
  .m-chat-chip,
  .m-composer-send,
  .m-chat-send,
  .m-composer-circle-btn,
  .m-composer-send.abort-mode,
  .m-chat-send.abort-mode,
  .m-chat-progress-fill::after,
  .m-chat-avatar::after,
  .m-chat-empty-avatar::after,
  .m-chat-status-dot {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }

  .m-typing-dot:nth-child(1) { opacity: 0.35; }
  .m-typing-dot:nth-child(2) { opacity: 0.55; }
  .m-typing-dot:nth-child(3) { opacity: 0.75; }
}


/* ─────────────────────────────────────────────
   iOS SAFARI FIXES
   ───────────────────────────────────────────── */

@supports (-webkit-touch-callout: none) {
  .m-chat-messages {
    -webkit-overflow-scrolling: touch;
  }
}


/* ─────────────────────────────────────────────
   DESKTOP BREAKPOINTS — Chat Panel
   Floating window on right side instead of bottom sheet
   ───────────────────────────────────────────── */

@media (min-width: 768px) {

  /* Chat panel: floating window, fixed size */
  .m-chat-panel {
    border-radius: 16px;
    box-shadow:
      0 8px 40px rgba(0, 0, 0, 0.12),
      0 0 0 1px var(--m-panel-border);
  }

  [data-theme="dark"] .m-chat-panel {
    box-shadow:
      0 8px 40px rgba(0, 0, 0, 0.45),
      0 0 0 1px var(--m-panel-border);
  }

  /* Chat header: keep hidden on desktop too (same as mobile) */

  /* Hide drag handle on desktop */
  .m-chat-drag-handle {
    display: none;
  }

  /* Keyboard-open: don't go full-width on desktop */
  .m-chat-panel.keyboard-open {
    border-radius: 16px;
  }

  /* Composer: floating pill on desktop, no safe-area */
  .m-chat-composer {
    margin: 0 8px 8px;
    padding: 6px 8px;
    border-radius: var(--m-composer-radius);
  }

  /* Messages: show subtle scrollbar, proper spacing */
  .m-chat-messages {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    gap: 16px;
    padding: 16px;
  }

  .m-chat-messages::-webkit-scrollbar {
    width: 4px;
    display: block;
  }

  .m-chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
  }

  /* Messages on desktop */
  .m-chat-msg {
    max-width: 85%;
    font-size: 14px;
    padding: 8px 12px;
  }

  .m-chat-msg.ai {
    font-size: 14px;
    line-height: 1.6;
    max-width: 100%;
    padding: 6px 4px;
  }

  /* Compact empty state */
  .m-chat-empty {
    padding: 14px 12px 8px;
  }

  .m-chat-empty-title {
    font-size: 15px;
  }

  .m-chat-empty-text {
    font-size: 11.5px;
    max-width: 240px;
    margin-bottom: 10px;
  }

  .m-chat-chip {
    font-size: 11px;
    padding: 5px 10px;
  }

  /* Compact composer */
  .m-composer-input,
  .m-chat-input {
    font-size: 13px;
  }

  /* Demo widget compact */
  .m-demo-chat {
    max-width: 280px;
  }
}

/* =====================================================================
   THINKING BUBBLE — Real-time AI reasoning display
   Replaces fake shimmer for interactive mode.
   ===================================================================== */

.m-thinking-block {
  background: var(--surface-1, #f4f4f5);
  border-radius: 10px;
  padding: 8px 12px;
  margin: 4px 0;
  max-width: 100%;
  align-self: flex-start;
}

[data-theme="dark"] .m-thinking-block {
  background: rgba(255, 255, 255, 0.04);
}

.m-think-header {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  padding: 2px 0;
}

.m-think-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-3, #999);
  flex-shrink: 0;
}

.m-thinking-block[data-state="thinking"] .m-think-indicator,
.m-thinking-block[data-state="tools"] .m-think-indicator {
  background: var(--accent, #7c3aed);
  animation: think-pulse 1.5s ease-in-out infinite;
}

@keyframes think-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.75); }
}

.m-think-label {
  font-weight: 500;
  font-size: 13px;
  color: var(--text-2, #666);
  flex: 1;
  min-width: 0;
}

.m-think-timer {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-3, #999);
  flex-shrink: 0;
}

.m-think-chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  transition: transform 0.25s ease;
  color: var(--text-3, #999);
}

.m-thinking-block[data-state="expanded"] .m-think-chevron,
.m-thinking-block[data-state="thinking"] .m-think-chevron,
.m-thinking-block[data-state="tools"] .m-think-chevron {
  transform: rotate(180deg);
}

/* Content wrapper — single element handles expand/collapse animation */
.m-think-content {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.25s ease, opacity 0.2s ease, margin-top 0.2s ease;
  opacity: 0.7;
  margin-top: 8px;
}

.m-thinking-block[data-state="collapsed"] .m-think-content {
  grid-template-rows: 0fr;
  opacity: 0;
  margin-top: 0;
}

/* Children must have overflow: hidden for grid animation */
.m-think-content > * {
  overflow: hidden;
  min-height: 0;
}

/* Thinking text */
.m-think-text {
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-2, #666);
  white-space: pre-wrap;
  word-break: break-word;
  padding-right: 4px;
}

.m-thinking-block[data-state="expanded"] .m-think-text,
.m-thinking-block[data-state="thinking"] .m-think-text,
.m-thinking-block[data-state="tools"] .m-think-text {
  max-height: 40vh;
}

.m-think-text::-webkit-scrollbar {
  width: 4px;
}

.m-think-text::-webkit-scrollbar-thumb {
  background: var(--border, #ddd);
  border-radius: 2px;
}

.m-think-tools {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  transition: max-height 0.3s ease, opacity 0.2s ease;
}

.m-think-tool-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-2, #666);
  padding: 3px 0;
}

.m-think-tool-status {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.m-think-tool-status.spinning::after {
  content: '';
  width: 12px;
  height: 12px;
  border: 2px solid var(--border, #ddd);
  border-top-color: var(--accent, #7c3aed);
  border-radius: 50%;
  animation: tool-spin 0.8s linear infinite;
}

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

.m-think-tool-status.done { color: #22c55e; }
.m-think-tool-status.error { color: #ef4444; }

/* ─── Dark mode ─────────────────────────────── */

[data-theme="dark"] .m-think-text {
  color: var(--text-2, #aaa);
}

[data-theme="dark"] .m-think-tool-item {
  color: var(--text-2, #aaa);
}

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

@media (prefers-reduced-motion: reduce) {
  .m-think-indicator { animation: none; }
  .m-think-tool-status.spinning::after { animation: none; }
  .m-think-content { transition: none; }
  .m-think-chevron { transition: none; }
}

/* ─── Action bar on AI messages (copy + like + dislike) ─── */

.m-action-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.m-chat-msg.ai:hover .m-action-bar,
.m-chat-msg.ai:focus-within .m-action-bar { opacity: 1; }

/* Always show on touch (mobile) */
@media (hover: none) { .m-action-bar { opacity: 0.5; } }

/* Keep visible when feedback is active */
.m-action-bar:has(.m-action-btn.active) { opacity: 1; }

.m-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-3, #999);
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease, color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.m-action-btn:hover { background: rgba(0, 0, 0, 0.05); color: var(--text-1, #666); }
.m-action-btn:disabled { opacity: 0.3; pointer-events: none; }
.m-action-btn.copied { color: #22c55e; }
.m-action-btn.active[data-action="like"] { color: #22c55e; }
.m-action-btn.active[data-action="dislike"] { color: #ef4444; }

[data-theme="dark"] .m-action-btn:hover { background: rgba(255, 255, 255, 0.08); }

/* ─── Feedback modal ─── */

.m-feedback-overlay {
  position: fixed;
  inset: 0;
  z-index: 9500;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: vc-feedback-overlay-in 0.2s ease;
}

@keyframes vc-feedback-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.m-feedback-modal {
  width: 90%;
  max-width: 440px;
  background: var(--bg-surface, #fff);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  animation: vc-feedback-modal-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes vc-feedback-modal-in {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

[data-theme="dark"] .m-feedback-modal {
  background: var(--bg-2, #2a2a2c);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.m-feedback-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-0);
  margin-bottom: 16px;
}

.m-feedback-select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border, #e0e0e0);
  border-radius: 10px;
  background: var(--bg-input, #f5f5f5);
  color: var(--text-0);
  font-family: var(--font-body);
  font-size: 14px;
  margin-bottom: 12px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s ease;
}

.m-feedback-select:focus { border-color: var(--accent-blue, #0071e3); }

[data-theme="dark"] .m-feedback-select {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

.m-feedback-textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px 12px;
  border: 1.5px solid var(--border, #e0e0e0);
  border-radius: 10px;
  background: var(--bg-input, #f5f5f5);
  color: var(--text-0);
  font-family: var(--font-body);
  font-size: 14px;
  resize: vertical;
  outline: none;
  margin-bottom: 16px;
  transition: border-color 0.15s ease;
  box-sizing: border-box;
}

.m-feedback-textarea:focus { border-color: var(--accent-blue, #0071e3); }

[data-theme="dark"] .m-feedback-textarea {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

.m-feedback-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.m-feedback-cancel,
.m-feedback-submit {
  padding: 8px 20px;
  border-radius: 10px;
  border: none;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.m-feedback-cancel {
  background: var(--bg-input, #f5f5f5);
  color: var(--text-1);
}

.m-feedback-cancel:hover { background: var(--bg-input-hover, #eee); }

.m-feedback-submit {
  background: var(--accent, #0071e3);
  color: #fff;
}

.m-feedback-submit:hover { opacity: 0.9; }

[data-theme="dark"] .m-feedback-cancel {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-1);
}

[data-theme="dark"] .m-feedback-cancel:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* Mobile: bottom sheet */
@media (max-width: 768px) {
  .m-feedback-overlay { align-items: flex-end; }
  .m-feedback-modal {
    width: 100%;
    max-width: none;
    border-radius: 20px 20px 0 0;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }
}

/* ─── Text streaming ─── */
.m-text-streaming { opacity: 1; }
