/* =====================================================================
   EXPORT PROGRESS MODAL
   Foreground modal shown during PPTX AI export (1-3 min job).
   Built on existing tokens (style.css :root + [data-theme="dark"]).
   No hard-coded colours — adapts to theme via CSS variables.
   ===================================================================== */

.m-export-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 16, 20, 0.55);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  opacity: 0;
  animation: m-export-fade-in 220ms cubic-bezier(0.32, 0.72, 0, 1) forwards;
  letter-spacing: -0.01em;
  font-feature-settings: "cv11", "ss01", "ss03";
}

[data-theme="dark"] .m-export-overlay {
  background: rgba(0, 0, 0, 0.62);
}

@keyframes m-export-fade-in {
  to { opacity: 1; }
}

.m-export-card {
  width: 100%;
  max-width: 460px;
  background: var(--bg-solid);
  color: var(--text-1);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 28px 24px;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.06),
    0 12px 32px rgba(0, 0, 0, 0.10),
    0 32px 80px rgba(0, 0, 0, 0.14);
  transform: translateY(8px) scale(0.985);
  opacity: 0;
  animation: m-export-card-in 320ms cubic-bezier(0.32, 0.72, 0, 1) 60ms forwards;
}

[data-theme="dark"] .m-export-card {
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.30),
    0 16px 40px rgba(0, 0, 0, 0.50),
    0 40px 96px rgba(0, 0, 0, 0.55);
}

@keyframes m-export-card-in {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ────────── Header (with minimize button — Lane B) ────────── */

.m-export-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 22px;
}

.m-export-header-text {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.m-export-title {
  margin: 0;
  font-size: 19px;
  line-height: 1.25;
  font-weight: 600;
  color: var(--text-0, var(--text-1));
  letter-spacing: -0.015em;
}

.m-export-subtitle {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text-2);
  font-weight: 400;
}

/* Minimize button — header right slot. Disabled until SSE phase becomes
   claude_thinking|writing|testing|fixing|packaging (real background work). */
.m-export-minimize-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  margin-top: -2px;          /* Optical alignment with title baseline */
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-3);
  cursor: pointer;
  transition: background 200ms cubic-bezier(0.32, 0.72, 0.36, 1),
              color 200ms cubic-bezier(0.32, 0.72, 0.36, 1),
              opacity 200ms cubic-bezier(0.32, 0.72, 0.36, 1),
              transform 120ms cubic-bezier(0.32, 0.72, 0.36, 1);
  -webkit-tap-highlight-color: transparent;
}

.m-export-minimize-btn:hover:not(:disabled) {
  background: var(--bg-input);
  color: var(--text-1);
}

.m-export-minimize-btn:active:not(:disabled) {
  transform: scale(0.92);
}

.m-export-minimize-btn:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}

.m-export-minimize-btn:focus-visible {
  outline: 2px solid var(--accent-blue, var(--accent));
  outline-offset: 2px;
}

.m-export-minimize-btn svg {
  display: block;
}

/* ────────── Progress bar ────────── */

.m-export-bar {
  position: relative;
  height: 4px;
  border-radius: 999px;
  background: var(--bg-input);
  overflow: hidden;
  margin-bottom: 22px;
}

.m-export-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 320ms cubic-bezier(0.32, 0.72, 0, 1);
}

.m-export-bar.is-indeterminate .m-export-bar-fill {
  width: 35%;
  animation: m-export-bar-slide 1.6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes m-export-bar-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(340%); }
}

/* ────────── Phases list ────────── */

.m-export-phases {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.m-export-phase {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14.5px;
  line-height: 1.35;
  color: var(--text-3);
  transition: color 280ms cubic-bezier(0.32, 0.72, 0, 1);
}

.m-export-phase.is-current {
  color: var(--text-1);
  font-weight: 500;
}

.m-export-phase.is-done {
  color: var(--text-2);
}

.m-export-phase-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Pending — empty ring */
.m-export-phase .m-export-dot-pending {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--border-hover);
  background: transparent;
}

/* Current — pulsing soft dot */
.m-export-phase.is-current .m-export-dot-pending {
  display: none;
}

.m-export-phase .m-export-dot-current {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent-glow);
  display: none;
  animation: m-export-pulse 1.4s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.m-export-phase.is-current .m-export-dot-current {
  display: block;
}

@keyframes m-export-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 var(--accent-glow);
    opacity: 1;
  }
  50% {
    box-shadow: 0 0 0 6px transparent;
    opacity: 0.72;
  }
}

/* Done — checkmark */
.m-export-phase .m-export-check {
  width: 14px;
  height: 14px;
  display: none;
  color: var(--accent);
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 220ms cubic-bezier(0.32, 0.72, 0, 1),
              transform 220ms cubic-bezier(0.32, 0.72, 0, 1);
}

.m-export-phase.is-done .m-export-dot-pending,
.m-export-phase.is-done .m-export-dot-current {
  display: none;
}

.m-export-phase.is-done .m-export-check {
  display: block;
  opacity: 1;
  transform: scale(1);
}

/* ────────── Footnote ────────── */

.m-export-footnote {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-3);
  text-align: center;
}

/* ────────── Error state ────────── */

.m-export-card.is-error .m-export-bar,
.m-export-card.is-error .m-export-phases,
.m-export-card.is-error .m-export-footnote {
  display: none;
}

.m-export-error {
  display: none;
  flex-direction: column;
  gap: 14px;
  padding-top: 4px;
}

.m-export-card.is-error .m-export-error {
  display: flex;
}

.m-export-error-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-1);
  margin: 4px 0 4px;
}

.m-export-error-message {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text-1);
}

.m-export-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.m-export-btn {
  flex: 1;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--text-1);
  font-size: 14.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: background 180ms var(--ease, ease),
              border-color 180ms var(--ease, ease),
              transform 120ms var(--ease, ease);
  font-family: inherit;
}

.m-export-btn:hover {
  background: var(--bg-input);
  border-color: var(--border-hover);
}

.m-export-btn:active {
  transform: scale(0.98);
}

.m-export-btn.is-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-solid);
}

.m-export-btn.is-primary:hover {
  background: var(--accent-hover, var(--accent));
  border-color: var(--accent-hover, var(--accent));
}

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

@media (max-width: 480px) {
  .m-export-overlay { padding: 16px; }
  .m-export-card { padding: 24px 22px 22px; border-radius: 18px; }
  .m-export-title { font-size: 18px; }
  .m-export-subtitle { font-size: 13px; }
  .m-export-phase { font-size: 14px; gap: 11px; }
}

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

@media (prefers-reduced-motion: reduce) {
  .m-export-overlay,
  .m-export-card,
  .m-export-phase,
  .m-export-bar-fill,
  .m-export-check,
  .m-export-btn { animation: none !important; transition: none !important; }
  .m-export-bar.is-indeterminate .m-export-bar-fill {
    animation: none;
    width: 100%;
    opacity: 0.5;
  }
  .m-export-phase .m-export-dot-current { animation: none; }
}

/* =====================================================================
   STAGE 2 — HISTORY + ACTIVE BANNER inside Download FAB popup
   Persists across reload via /api/export-pptx/active + /history.
   ===================================================================== */

/* Allow the download popup to wrap so banner + history sit on a new
   row beneath the existing PDF / PPTX action buttons. The banner/history
   take full width via flex-basis: 100%. Long history lists scroll inside
   the popup instead of overflowing the viewport (mirrors .m-preset-popup). */
.m-fab-popup.m-download-popup {
  flex-wrap: wrap;
  align-items: stretch;
  max-width: min(360px, calc(100vw - 96px));
  min-width: 240px;
  max-height: 70vh;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Header row + the two format buttons inside m-download-popup keep
   their natural baseline; only banner/history elements claim full row. */
.m-download-popup > .m-export-active-banner,
.m-download-popup > .m-export-history {
  flex-basis: 100%;
  width: 100%;
}

/* ────────── Active banner ────────── */

/* Specificity fix: .m-export-active-banner перебивает *[hidden] (одинаковая
 * специфичность, но class-rule загружается позже). Без override пустой banner
 * рендерится как серая полоса. */
.m-export-active-banner[hidden],
.m-export-history[hidden] {
  display: none !important;
}

.m-export-active-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--accent-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 10px);
  font-size: 13px;
  line-height: 1.35;
  color: var(--text-1);
  margin-top: 4px;
  letter-spacing: -0.005em;
  position: relative;
  overflow: hidden;
}

/* Soft live shimmer behind the banner — signals "in progress". */
.m-export-active-banner::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, var(--accent-glow) 50%, transparent 100%);
  opacity: 0.55;
  transform: translateX(-100%);
  animation: m-export-banner-shimmer 2.4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  pointer-events: none;
}

@keyframes m-export-banner-shimmer {
  0%   { transform: translateX(-100%); }
  60%  { transform: translateX(140%); }
  100% { transform: translateX(140%); }
}

.m-export-banner-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-solid);
  color: var(--text-0);
  position: relative;
  z-index: 1;
}

.m-export-banner-icon svg {
  width: 13px;
  height: 13px;
  display: block;
  animation: m-export-banner-icon-spin 6s linear infinite;
}

@keyframes m-export-banner-icon-spin {
  to { transform: rotate(360deg); }
}

.m-export-banner-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.m-export-banner-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-0);
  letter-spacing: -0.01em;
}

.m-export-banner-when {
  font-size: 11.5px;
  color: var(--text-3);
  letter-spacing: -0.005em;
}

.m-export-banner-action {
  flex: 0 0 auto;
  background: var(--accent);
  color: var(--bg-solid);
  border: none;
  border-radius: 8px;
  padding: 0 12px;
  height: 30px;
  min-width: 64px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: background 180ms cubic-bezier(0.32, 0.72, 0, 1),
              transform 120ms cubic-bezier(0.32, 0.72, 0, 1);
  position: relative;
  z-index: 1;
}

.m-export-banner-action:hover { background: var(--accent-hover); }
.m-export-banner-action:active { transform: scale(0.96); }

/* ────────── History list ────────── */

.m-export-history {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 8px;
  margin-top: 6px;
  border-top: 1px solid var(--border);
}

.m-export-history-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  padding: 4px 6px 6px;
}

.m-export-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 6px;
  border-radius: 8px;
  transition: background 180ms cubic-bezier(0.32, 0.72, 0, 1);
}

.m-export-history-item:hover {
  background: var(--bg-input);
}

.m-export-history-info {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.m-export-history-when {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-0);
  letter-spacing: -0.005em;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.m-export-history-meta {
  font-size: 11.5px;
  color: var(--text-3);
  letter-spacing: -0.005em;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.m-export-history-download {
  flex: 0 0 auto;
  background: transparent;
  color: var(--text-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  height: 30px;
  min-width: 70px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: background 160ms cubic-bezier(0.32, 0.72, 0, 1),
              border-color 160ms cubic-bezier(0.32, 0.72, 0, 1),
              color 160ms cubic-bezier(0.32, 0.72, 0, 1),
              transform 120ms cubic-bezier(0.32, 0.72, 0, 1);
}

.m-export-history-download:hover:not(:disabled) {
  background: var(--bg-input);
  border-color: var(--border-hover);
  color: var(--text-0);
}

.m-export-history-download:active:not(:disabled) { transform: scale(0.96); }

.m-export-history-download:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ────────── Recent-ready toast (page-load surfaced) ────────── */

.m-export-toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, calc(100% + 32px));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px 12px 12px;
  background: var(--bg-solid);
  color: var(--text-0);
  border: 1px solid var(--border);
  border-radius: 14px;
  min-width: 300px;
  max-width: calc(100vw - 32px);
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.06),
    0 8px 28px rgba(0, 0, 0, 0.10),
    0 24px 64px rgba(0, 0, 0, 0.12);
  z-index: 9750;            /* recent-toast: above sidebar 9500/9499, above confirm 9700 */
  opacity: 0;
  letter-spacing: -0.01em;
  font-feature-settings: "cv11", "ss01", "ss03";
  transition: transform 320ms cubic-bezier(0.32, 0.72, 0, 1),
              opacity 240ms cubic-bezier(0.32, 0.72, 0, 1);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
}

[data-theme="dark"] .m-export-toast {
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.30),
    0 12px 36px rgba(0, 0, 0, 0.50),
    0 32px 80px rgba(0, 0, 0, 0.55);
}

.m-export-toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

.m-export-toast.is-hidden {
  transform: translate(-50%, calc(100% + 32px));
  opacity: 0;
}

.m-export-toast-icon {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--success, #3daa5c);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.m-export-toast-icon svg {
  width: 14px;
  height: 14px;
  display: block;
}

.m-export-toast-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.m-export-toast-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-0);
  letter-spacing: -0.01em;
}

.m-export-toast-sub {
  font-size: 12.5px;
  color: var(--text-2);
  letter-spacing: -0.005em;
}

.m-export-toast-action {
  flex: 0 0 auto;
  background: var(--accent);
  color: var(--bg-solid);
  border: none;
  border-radius: 9px;
  padding: 0 14px;
  height: 34px;
  min-width: 76px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: background 180ms cubic-bezier(0.32, 0.72, 0, 1),
              transform 120ms cubic-bezier(0.32, 0.72, 0, 1);
}

.m-export-toast-action:hover { background: var(--accent-hover); }
.m-export-toast-action:active { transform: scale(0.96); }

.m-export-toast-close {
  flex: 0 0 auto;
  background: transparent;
  border: none;
  color: var(--text-3);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 160ms cubic-bezier(0.32, 0.72, 0, 1),
              color 160ms cubic-bezier(0.32, 0.72, 0, 1);
  -webkit-tap-highlight-color: transparent;
}

.m-export-toast-close svg {
  width: 12px;
  height: 12px;
  display: block;
}

.m-export-toast-close:hover {
  background: var(--bg-input);
  color: var(--text-1);
}

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

@media (max-width: 480px) {
  .m-fab-popup.m-download-popup { max-width: calc(100vw - 80px); }
  .m-export-active-banner { font-size: 12.5px; padding: 9px 10px; }
  .m-export-banner-action { padding: 0 10px; min-width: 56px; }
  .m-export-history-when { font-size: 12.5px; }
  .m-export-history-meta { font-size: 11px; }
  .m-export-toast { min-width: 0; padding: 11px 12px; gap: 10px; }
  .m-export-toast-title { font-size: 13.5px; }
  .m-export-toast-sub { font-size: 12px; }
}

/* Ensure 44px+ touch targets on mobile (WCAG 2.5.5). */
@media (pointer: coarse) {
  .m-export-banner-action,
  .m-export-history-download,
  .m-export-toast-action {
    min-height: 44px;
    height: 44px;
  }
  .m-export-toast-close {
    width: 44px;
    height: 44px;
  }
}

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

@media (prefers-reduced-motion: reduce) {
  .m-export-active-banner::after,
  .m-export-banner-icon svg,
  .m-export-toast,
  .m-export-banner-action,
  .m-export-history-download,
  .m-export-history-item {
    animation: none !important;
    transition: none !important;
  }
}

/* ════════════════════════════════════════════════════
   Billing footer (Stage 2.1) — отображение списания после done
   ════════════════════════════════════════════════════ */

.m-export-billing-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-top: 16px;
  padding: 10px 14px;
  background: var(--m-color-success-soft, rgba(16, 185, 129, 0.08));
  border-radius: 10px;
  font-size: 13px;
  letter-spacing: -0.005em;
  animation: mBillingFadeIn 320ms cubic-bezier(0.32, 0.72, 0.36, 1);
}

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

.m-export-billing-cost {
  font-weight: 600;
  color: var(--m-color-success, #10b981);
}

.m-export-billing-balance {
  color: var(--m-color-text-muted, #6b7280);
}

.m-export-billing-meta {
  flex: 1 1 100%;
  font-size: 12px;
  color: var(--m-color-text-muted, #6b7280);
  opacity: 0.85;
}

/* S2 fix: empty state в History когда у юзера нет прошлых экспортов */
.m-export-history-empty {
  padding: 16px 14px;
  font-size: 13px;
  color: var(--m-color-text-muted, #6b7280);
  text-align: center;
  letter-spacing: -0.005em;
  opacity: 0.78;
}

/* ════════════════════════════════════════════════════
   Cancel export button (Stage 2.2)
   ════════════════════════════════════════════════════ */

.m-export-cancel-btn {
  display: block;
  margin: 14px auto 0;
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--m-color-divider, rgba(0, 0, 0, 0.1));
  border-radius: 10px;
  color: var(--m-color-text-muted, #6b7280);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 36px;
}

.m-export-cancel-btn:hover:not(:disabled) {
  color: var(--m-color-danger, #dc2626);
  border-color: var(--m-color-danger, #dc2626);
  background: var(--m-color-danger-soft, rgba(220, 38, 38, 0.06));
}

.m-export-cancel-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.m-export-cancel-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.m-export-cancel-btn.is-confirming {
  color: var(--m-color-danger, #dc2626);
  border-color: var(--m-color-danger, #dc2626);
  background: var(--m-color-danger-soft, rgba(220, 38, 38, 0.08));
  font-weight: 600;
  animation: mCancelPulse 1.6s ease-in-out infinite;
}

@keyframes mCancelPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.02); }
}

.m-export-cancel-btn.is-cancelling {
  color: var(--m-color-text-muted, #6b7280);
  background: var(--m-color-hover, rgba(0, 0, 0, 0.04));
  border-color: var(--m-color-divider, rgba(0, 0, 0, 0.1));
}

.m-export-cancelled-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px 24px;
  text-align: center;
}

.m-export-cancelled-icon {
  width: 48px;
  height: 48px;
  color: var(--text-3);
  opacity: 0.6;
}

.m-export-card.is-cancelled .m-export-title { margin-top: 0; }

@media (prefers-reduced-motion: reduce) {
  .m-export-cancel-btn.is-confirming { animation: none; }
}

/* =====================================================================
   LANE B — NON-BLOCKING EXPORT (03.05.2026)

   Minimize affordance — the modal stays in DOM but visually disappears
   while SSE keeps streaming. A floating pill remains as the only
   reminder; the rest of the UI is interactive again.
   ===================================================================== */

/* ────────── Minimized state of the main modal ──────────
   When `.is-minimized` is set on .m-export-overlay, we just hide the
   overlay+card visually without removing them from DOM. SSE consumer
   keeps reading because the closure is alive. */
.m-export-overlay.is-minimized {
  display: none;
}

/* ────────── Mini-pill (running state) ──────────
   Position: bottom-left of FAB stack so it doesn't cover the action
   buttons. On narrow screens (<=480px) we shift up to clear FABs. */
.m-export-mini-pill {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom, 0px));
  /* Right of viewport ~ FAB column width (16px right + 56px chat FAB +
     safe gap to clear secondary FABs). Pill sits to the LEFT of FABs. */
  right: 88px;
  z-index: 9100;            /* Above FAB group (9000) but below toasts (9500) */

  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 10px 12px;
  background: var(--bg-solid);
  color: var(--text-0);
  border: 1px solid var(--border);
  border-radius: 999px;
  min-height: 40px;
  max-width: min(320px, calc(100vw - 120px));

  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.01em;
  font-feature-settings: "cv11", "ss01", "ss03";

  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;

  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.06),
    0 8px 24px -8px rgba(0, 0, 0, 0.18),
    0 16px 40px -12px rgba(0, 0, 0, 0.18);

  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);

  /* Off-stage start position; .is-visible slides it in */
  opacity: 0;
  transform: translate3d(0, 14px, 0) scale(0.94);
  transition:
    opacity 280ms cubic-bezier(0.32, 0.72, 0.36, 1),
    transform 320ms cubic-bezier(0.32, 0.72, 0.36, 1),
    background 220ms cubic-bezier(0.32, 0.72, 0.36, 1),
    border-color 220ms cubic-bezier(0.32, 0.72, 0.36, 1),
    color 220ms cubic-bezier(0.32, 0.72, 0.36, 1);
}

[data-theme="dark"] .m-export-mini-pill {
  background: rgba(28, 28, 32, 0.92);
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.32),
    0 12px 32px -8px rgba(0, 0, 0, 0.55),
    0 24px 56px -16px rgba(0, 0, 0, 0.55);
}

.m-export-mini-pill.is-visible {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
}

.m-export-mini-pill.is-dismissing {
  opacity: 0;
  transform: translate3d(0, 14px, 0) scale(0.94);
  pointer-events: none;
}

.m-export-mini-pill:hover {
  border-color: var(--border-hover);
  background: color-mix(in srgb, var(--bg-solid) 92%, var(--text-0));
  transform: translate3d(0, -1px, 0) scale(1);
}

[data-theme="dark"] .m-export-mini-pill:hover {
  background: rgba(36, 36, 40, 0.96);
}

.m-export-mini-pill:active {
  transform: translate3d(0, 0, 0) scale(0.97);
  transition-duration: 120ms;
}

.m-export-mini-pill:focus-visible {
  outline: 2px solid var(--accent-blue, var(--accent));
  outline-offset: 3px;
}

/* ────────── Pill innards ────────── */

.m-export-pill-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--accent);
}

.m-export-pill-icon svg { display: block; }

/* Pure-CSS rotating ring — no setInterval, no jitter */
.m-export-pill-spinner {
  animation: m-export-pill-spin 900ms linear infinite;
  transform-origin: center;
}

@keyframes m-export-pill-spin {
  to { transform: rotate(360deg); }
}

.m-export-pill-body {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.m-export-pill-status {
  color: var(--text-0);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.m-export-pill-sep {
  color: var(--text-3);
  font-weight: 400;
  font-size: 13px;
}

/* Tabular numerals — timer never causes layout shift */
.m-export-pill-timer {
  color: var(--text-1);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "cv11", "ss01", "ss03";
  letter-spacing: 0;
  white-space: nowrap;
  transition: color 240ms cubic-bezier(0.32, 0.72, 0.36, 1);
}

.m-export-pill-chevron {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: var(--text-3);
  margin-left: 2px;
  transition: color 220ms cubic-bezier(0.32, 0.72, 0.36, 1),
              transform 220ms cubic-bezier(0.32, 0.72, 0.36, 1);
}

.m-export-pill-chevron svg { display: block; }

.m-export-mini-pill:hover .m-export-pill-chevron {
  color: var(--text-1);
  transform: translateY(-1px);
}

/* ────────── Timer tier — color shift as elapsed grows ──────────
   neutral (<15min) → warning amber tint (15-25min) → critical (≥25min). */

.m-export-mini-pill[data-tier="warning"] .m-export-pill-timer {
  color: var(--warning);
}

.m-export-mini-pill[data-tier="critical"] .m-export-pill-timer {
  color: var(--warning);
  font-weight: 600;
}

.m-export-mini-pill[data-tier="critical"] .m-export-pill-icon {
  color: var(--warning);
}

/* ────────── Watchdog states (pill turns amber/red) ────────── */

.m-export-mini-pill.is-watchdog-stalled .m-export-pill-icon {
  color: var(--warning);
}

.m-export-mini-pill.is-watchdog-stalled .m-export-pill-status {
  color: var(--warning);
}

.m-export-mini-pill.is-watchdog-lost {
  border-color: var(--warning);
  background: color-mix(in srgb, var(--bg-solid) 86%, var(--warning));
}

[data-theme="dark"] .m-export-mini-pill.is-watchdog-lost {
  background: color-mix(in srgb, rgba(28, 28, 32, 0.92) 80%, var(--warning));
}

.m-export-mini-pill.is-watchdog-lost .m-export-pill-icon,
.m-export-mini-pill.is-watchdog-lost .m-export-pill-status {
  color: var(--warning);
  font-weight: 600;
}

/* ────────── Success pill (after `done`) ──────────
   Soft-tinted background using --success token. Click = download. */

.m-export-mini-pill.is-success {
  border-color: color-mix(in srgb, var(--success) 38%, var(--border));
  background: color-mix(in srgb, var(--bg-solid) 88%, var(--success));
  color: var(--text-0);
}

[data-theme="dark"] .m-export-mini-pill.is-success {
  background: color-mix(in srgb, rgba(28, 28, 32, 0.92) 80%, var(--success));
}

.m-export-mini-pill.is-success .m-export-pill-icon-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
}

.m-export-mini-pill.is-success .m-export-pill-icon-check svg {
  width: 12px;
  height: 12px;
}

.m-export-mini-pill.is-success:hover {
  background: color-mix(in srgb, var(--bg-solid) 80%, var(--success));
}

[data-theme="dark"] .m-export-mini-pill.is-success:hover {
  background: color-mix(in srgb, rgba(28, 28, 32, 0.92) 70%, var(--success));
}

/* ────────── Error pill (after `error` while minimized) ────────── */

.m-export-mini-pill.is-error {
  border-color: color-mix(in srgb, var(--error) 38%, var(--border));
  background: color-mix(in srgb, var(--bg-solid) 88%, var(--error));
  color: var(--text-0);
}

[data-theme="dark"] .m-export-mini-pill.is-error {
  background: color-mix(in srgb, rgba(28, 28, 32, 0.92) 80%, var(--error));
}

.m-export-mini-pill.is-error .m-export-pill-icon-alert {
  color: var(--error);
}

.m-export-mini-pill.is-error .m-export-pill-status {
  color: var(--error);
  font-weight: 600;
}

.m-export-mini-pill.is-error:hover {
  background: color-mix(in srgb, var(--bg-solid) 80%, var(--error));
}

[data-theme="dark"] .m-export-mini-pill.is-error:hover {
  background: color-mix(in srgb, rgba(28, 28, 32, 0.92) 70%, var(--error));
}

/* ────────── Stale-edit warning toast ──────────
   Top-right of viewport. Amber/warning tint to clearly signal "heads up,
   your edits won't be in this export". Auto-dismisses after 6s. */

.m-export-stale-toast {
  position: fixed;
  top: max(20px, env(safe-area-inset-top, 0px));
  right: 20px;
  z-index: 9800;            /* stale-toast: top of cascade, above brand-picker 9600 + recent-toast 9750 */

  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  background: var(--bg-solid);
  color: var(--text-0);
  border: 1px solid color-mix(in srgb, var(--warning) 35%, var(--border));
  border-left: 3px solid var(--warning);
  border-radius: 12px;
  min-width: 280px;
  max-width: min(380px, calc(100vw - 40px));

  font-family: inherit;
  font-size: 13px;
  line-height: 1.42;
  letter-spacing: -0.01em;
  font-feature-settings: "cv11", "ss01", "ss03";

  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.06),
    0 12px 36px -10px rgba(0, 0, 0, 0.18),
    0 24px 56px -16px rgba(0, 0, 0, 0.16);

  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);

  opacity: 0;
  transform: translate3d(0, -12px, 0);
  transition:
    opacity 280ms cubic-bezier(0.32, 0.72, 0.36, 1),
    transform 320ms cubic-bezier(0.32, 0.72, 0.36, 1);
}

[data-theme="dark"] .m-export-stale-toast {
  background: rgba(30, 30, 34, 0.94);
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.32),
    0 16px 40px -10px rgba(0, 0, 0, 0.55),
    0 32px 80px -20px rgba(0, 0, 0, 0.55);
}

.m-export-stale-toast.is-visible {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

.m-export-stale-toast.is-dismissing {
  opacity: 0;
  transform: translate3d(0, -12px, 0);
  pointer-events: none;
}

.m-export-stale-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--warning);
  margin-top: 1px;
}

.m-export-stale-icon svg { display: block; }

.m-export-stale-text {
  flex: 1 1 auto;
  color: var(--text-0);
  font-weight: 500;
}

.m-export-stale-close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  margin: -4px -4px -4px 4px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-3);
  cursor: pointer;
  transition: background 180ms cubic-bezier(0.32, 0.72, 0.36, 1),
              color 180ms cubic-bezier(0.32, 0.72, 0.36, 1);
  -webkit-tap-highlight-color: transparent;
}

.m-export-stale-close:hover {
  background: var(--bg-input);
  color: var(--text-1);
}

.m-export-stale-close:focus-visible {
  outline: 2px solid var(--accent-blue, var(--accent));
  outline-offset: 1px;
}

.m-export-stale-close svg { display: block; }

/* ────────── Responsive — narrow phones ────────── */

@media (max-width: 480px) {
  .m-export-mini-pill {
    /* FX-C Q2-F3 — pill уходит в LEFT-bottom corner на мобиле, чтобы не
       перекрывать 5-FAB column (Download / Preset / Cost / Share / Edit + chat
       FAB снизу). Раньше pill стоял в right column @ bottom:80px и блокировал
       вторичные FABs. Теперь pill снизу-слева, FAB column остаётся доступной. */
    right: auto;
    left: 12px;
    bottom: max(12px, calc(12px + env(safe-area-inset-bottom, 0px)));
    max-width: calc(100vw - 24px);
    font-size: 12.5px;
    padding: 9px 12px 9px 10px;
    min-height: 38px;
  }

  .m-export-stale-toast {
    right: 12px;
    left: 12px;
    min-width: 0;
    max-width: none;
    top: max(12px, env(safe-area-inset-top, 0px));
  }
}

/* ────────── Touch targets (WCAG 2.5.5) ────────── */

@media (pointer: coarse) {
  .m-export-minimize-btn,
  .m-export-stale-close {
    width: 44px;
    height: 44px;
  }

  .m-export-mini-pill {
    min-height: 44px;
    padding: 12px 16px 12px 14px;
  }
}

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

@media (prefers-reduced-motion: reduce) {
  .m-export-mini-pill,
  .m-export-stale-toast,
  .m-export-minimize-btn,
  .m-export-pill-chevron {
    animation: none !important;
    transition: none !important;
  }
  .m-export-pill-spinner {
    animation: m-export-pill-spin 1800ms linear infinite;
  }
}
