/* ========================================================================
   AUDIO-TO-VIDEO CONVERTER - CROSS-CULTURAL DESIGN SYSTEM
   Target: RO / DACH / EN | Psychological: Trust + Clarity + Micro-reward
   ======================================================================== */

/* 1. VARIABLES & THEME =================================================== */
:root {
  /* Colors */
  --bg-page: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-surface: #F1F5F9;
  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --warm: #D97706;
  --success: #10B981;
  --error: #EF4444;
  --warning: #F59E0B;
  --border: #E2E8F0;
  --shadow-sm: 0 1px 3px rgba(15,23,42,0.08);
  --shadow-md: 0 4px 12px rgba(15,23,42,0.12);
  --focus-ring: 0 0 0 3px rgba(37,99,235,0.25);
  --error-hover: #DC2626;
  --success-hover: #059669;
  --focus-ring-subtle: 0 0 0 2px rgba(37,99,235,0.2);
  --shadow-lang-active: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --thumb-remove-bg: rgba(0,0,0,0.6);
  --video-preview-bg: #000;
  --donate-bg: #FFDD00;
  --donate-text: #111;
  --donate-shadow-hover: 0 8px 16px rgba(255,205,0,0.3);
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  /* Layout */
  --radius: 12px;
  --radius-sm: 8px;
  --max-width: 1200px;
  --header-height: 64px;
  /* Typography */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.8125rem, 0.75rem + 0.3vw, 0.9375rem);
  --text-base: clamp(0.875rem, 0.8rem + 0.3vw, 1rem);
  --text-lg: clamp(1rem, 0.9rem + 0.4vw, 1.125rem);
  --text-xl: clamp(1.25rem, 1rem + 1vw, 1.5rem);
  --text-2xl: clamp(1.5rem, 1.2rem + 1.2vw, 1.875rem);
  --text-3xl: clamp(1.875rem, 1.5rem + 1.5vw, 2.25rem);
  /* Motion */
  --ease: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --ease-slow: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  /* Tool-specific */
  --color-waveform: #6366F1;
  --color-spectrum: #8B5CF6;
  --color-particles: #EC4899;
  --dropzone-border: #CBD5E1;
  --dropzone-bg: #F8FAFC;
  --progress-bg: #E2E8F0;
  --progress-fill: #2563EB;
  --thumb-border: #E2E8F0;
  --thumb-selected: #2563EB;
  --step-active: #2563EB;
  --step-done: #10B981;
  --step-pending: #CBD5E1;
  --format-youtube: #FF0000;
  --format-tiktok: #00F2EA;
  --format-instagram: #E4405F;
  --format-twitter: #1DA1F2;
  --format-facebook: #1877F2;
  --format-custom: #6366F1;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-page: #0B1120;
    --bg-card: #111827;
    --bg-surface: #1E293B;
    --text-primary: #F1F5F9;
    --text-secondary: #CBD5E1;
    --text-muted: #64748B;
    --border: #334155;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --dropzone-border: #475569;
    --dropzone-bg: #1E293B;
    --progress-bg: #334155;
    --thumb-border: #475569;
    --focus-ring-subtle: 0 0 0 2px rgba(37,99,235,0.2);
    --shadow-lang-active: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --thumb-remove-bg: rgba(0,0,0,0.6);
    --donate-shadow-hover: 0 8px 16px rgba(255,205,0,0.3);
  }
}
html.theme-dark {
  --bg-page: #0B1120;
  --bg-card: #111827;
  --bg-surface: #1E293B;
  --text-primary: #F1F5F9;
  --text-secondary: #CBD5E1;
  --text-muted: #64748B;
  --border: #334155;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --dropzone-border: #475569;
  --dropzone-bg: #1E293B;
  --progress-bg: #334155;
  --thumb-border: #475569;
  --focus-ring-subtle: 0 0 0 2px rgba(37,99,235,0.2);
  --shadow-lang-active: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --thumb-remove-bg: rgba(255,255,255,0.3);
  --video-preview-bg: #000;
  --donate-shadow-hover: 0 8px 16px rgba(255,205,0,0.2);
}

/* 2. BASE & RESET ======================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1, "liga" 1;
}
body {
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 80px;
}
img, svg { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font: inherit; }
ul, ol { list-style: none; }

/* 3. LAYOUT & CONTAINERS ================================================ */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding-inline: var(--space-lg);
}
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--text-primary);
  font-size: var(--text-lg);
  line-height: 1.2;
  transition: opacity var(--ease);
}
.logo:hover { opacity: 0.9; }
.logo-img {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: block;
  border-radius: var(--radius-sm);
}
.logo strong {
  font-weight: 700;
  letter-spacing: -0.02em;
}
main { flex: 1; padding-block: var(--space-2xl); }

/* 4. TYPOGRAPHY & UTILITY =============================================== */
h1, h2, h3, h4 {
  text-wrap: balance;
  line-height: 1.2;
  font-weight: 600;
}
h1 { font-size: var(--text-3xl); margin-bottom: var(--space-md); }
h2 { font-size: var(--text-2xl); margin-bottom: var(--space-lg); }
h3 { font-size: var(--text-xl); }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* 5. COMPONENTS ========================================================= */
/* Language Switcher - Pill Design */
.lang-switch {
  display: inline-flex;
  background: var(--bg-surface);
  padding: 4px;
  border-radius: 999px;
  gap: 4px;
  align-items: center;
  width: auto;
}
.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.lang-btn:hover { color: var(--text-primary); }
.lang-btn[aria-current="true"] {
  background: var(--bg-card);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
}
/* Theme Toggle */
.theme-toggle {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  display: grid; place-items: center;
  font-size: 1.1rem;
}
/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  transition: var(--ease);
}
.btn:hover { background: var(--accent-hover); }
.btn--outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text-primary);
}
.btn--outline:hover { background: var(--bg-surface); }
.btn--danger {
  background: var(--error);
  color: #fff;
}
.btn--danger:hover { background: var(--error-hover); }
.btn--success {
  background: var(--success);
  color: #fff;
}
.btn--success:hover { background: var(--success-hover); }
.btn--sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-xs);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
/* Forms */
.form-group { margin-bottom: var(--space-md); }
.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  margin-bottom: var(--space-xs);
}
.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: var(--text-base);
  transition: var(--ease);
}
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23475569' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: var(--accent);
}
.form-input.is-error, .form-textarea.is-error {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(239,68,68,0.2);
}
.form-help { font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--space-xs); }
.form-error { font-size: var(--text-xs); color: var(--error); margin-top: var(--space-xs); }

/* Tool Card */
.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  transition: var(--ease-slow);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  position: relative;
  contain: layout style;
}
/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: 1;
}

/* 6. TOOL-SPECIFIC ====================================================== */

/* Admin Login / Setup Panel */
.admin-panel {
  max-width: 720px;
  margin: var(--space-xl) auto;
  padding: var(--space-xl);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.admin-panel h2 {
  text-align: center;
  margin-bottom: var(--space-lg);
  font-size: var(--text-xl);
}
.admin-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--bg-surface);
  display: grid;
  place-items: center;
  margin: 0 auto var(--space-lg);
  font-size: 1.8rem;
}
.admin-status {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  margin-bottom: var(--space-md);
}
/* Admin File Browser */
#adminFilesTable table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
#adminFilesTable th {
  text-align: left;
  padding: 8px;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}
#adminFilesTable td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
#adminFilesTable tr:hover td {
  background: var(--bg-surface);
}
#adminFilesTable .admin-file-cb {
  width: 16px;
  height: 16px;
  accent-color: var(--primary, #3b82f6);
}

/* Steps/Wizard */
.wizard-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  margin-bottom: var(--space-xl);
  flex-wrap: wrap;
}
.wizard-step {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
  padding: var(--space-xs) var(--space-sm);
  border-radius: 999px;
  transition: var(--ease);
}
.wizard-step.is-active {
  color: var(--accent);
  background: rgba(37,99,235,0.08);
}
.wizard-step.is-done {
  color: var(--success);
}
.wizard-step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: var(--text-xs);
  font-weight: 700;
  background: var(--step-pending);
  color: #fff;
}
.wizard-step.is-active .wizard-step-number {
  background: var(--step-active);
}
.wizard-step.is-done .wizard-step-number {
  background: var(--step-done);
}
.wizard-step-separator {
  width: 24px;
  height: 2px;
  background: var(--border);
}

/* Dropzone */
.dropzone {
  border: 2px dashed var(--dropzone-border);
  border-radius: var(--radius);
  padding: var(--space-xl);
  text-align: center;
  background: var(--dropzone-bg);
  transition: var(--ease);
  cursor: pointer;
  position: relative;
}
.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--accent);
  background: rgba(37,99,235,0.04);
}
.dropzone-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-sm);
}
.dropzone-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.dropzone-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* Audio file info */
.audio-info {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  margin-top: var(--space-md);
}
.audio-info-icon {
  font-size: 1.5rem;
}
.audio-info-details {
  flex: 1;
  min-width: 0;
}
.audio-info-name {
  font-size: var(--text-sm);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.audio-info-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.audio-info-remove {
  background: none;
  border: none;
  color: var(--error);
  font-size: 1.2rem;
  padding: var(--space-xs);
  border-radius: 50%;
  transition: var(--ease);
}
.audio-info-remove:hover {
  background: rgba(239,68,68,0.1);
}

/* Image thumbnails grid */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: var(--space-sm);
  margin-top: var(--space-md);
}
.image-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--thumb-border);
  transition: var(--ease);
}
.image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.image-thumb.is-selected {
  border-color: var(--thumb-selected);
  box-shadow: var(--focus-ring-subtle);
}
.image-thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--thumb-remove-bg);
  color: #fff;
  border: none;
  font-size: 12px;
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  transition: var(--ease);
}
.image-thumb:hover .image-thumb-remove { opacity: 1; }
.image-thumb-add {
  border: 2px dashed var(--dropzone-border);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 1.5rem;
  color: var(--text-muted);
  background: var(--dropzone-bg);
  transition: var(--ease);
}
.image-thumb-add:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Format cards */
.format-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-sm);
}
.format-card {
  padding: var(--space-md);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
  transition: var(--ease);
  background: var(--bg-card);
}
.format-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.format-card.is-selected {
  border-color: var(--accent);
  background: rgba(37,99,235,0.04);
  box-shadow: var(--focus-ring-subtle);
}
.format-card-icon {
  font-size: 1.5rem;
  margin-bottom: var(--space-xs);
}
.format-card-name {
  font-size: var(--text-sm);
  font-weight: 600;
}
.format-card-size {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

/* Visualization type selector */
.viz-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-sm);
}
.viz-card {
  padding: var(--space-md);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
  transition: var(--ease);
  background: var(--bg-card);
}
.viz-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.viz-card.is-selected {
  border-color: var(--accent);
  background: rgba(37,99,235,0.04);
  box-shadow: var(--focus-ring-subtle);
}
.viz-card-icon {
  font-size: 2rem;
  margin-bottom: var(--space-xs);
}
.viz-card-name {
  font-size: var(--text-sm);
  font-weight: 600;
}
.viz-card-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

/* Progress bar */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--progress-bg);
  border-radius: 999px;
  overflow: hidden;
  margin: var(--space-md) 0;
}
.progress-bar-fill {
  height: 100%;
  background: var(--progress-fill);
  border-radius: 999px;
  transition: width 0.3s ease;
  width: 0%;
}
.progress-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-align: center;
}

/* Video preview */
.video-preview {
  position: relative;
  background: var(--video-preview-bg);
  border-radius: var(--radius);
  overflow: hidden;
  margin: var(--space-md) 0;
  max-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.video-preview video {
  width: 100%;
  max-height: 400px;
  display: block;
}

/* Inline message (no alerts!) */
.inline-msg {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  margin: var(--space-sm) 0;
  display: none;
}
.inline-msg.is-visible { display: flex; align-items: center; gap: var(--space-sm); }
.inline-msg--error { background: rgba(239,68,68,0.08); color: var(--error); border: 1px solid rgba(239,68,68,0.2); }
.inline-msg--success { background: rgba(16,185,129,0.08); color: var(--success); border: 1px solid rgba(16,185,129,0.2); }
.inline-msg--info { background: rgba(37,99,235,0.08); color: var(--accent); border: 1px solid rgba(37,99,235,0.2); }
.inline-msg--warning { background: rgba(245,158,11,0.08); color: var(--warning); border: 1px solid rgba(245,158,11,0.2); }

/* Section card (step content wrapper) */
.step-section {
  display: none;
}
.step-section.is-active {
  display: block;
}

/* Conversion options */
.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-md);
}

/* Viz-specific options */
.viz-options {
  margin-top: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
}
.viz-options h4 {
  font-size: var(--text-sm);
  margin-bottom: var(--space-sm);
}

/* Color picker row */
.color-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.color-row input[type="color"] {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  cursor: pointer;
  background: var(--bg-card);
}

/* Range slider */
.range-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}
.range-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}
.range-value {
  font-size: var(--text-sm);
  font-weight: 600;
  min-width: 40px;
  text-align: right;
}

/* Duration / transition select */
.slide-duration-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

/* 7. STICKY DONATE ====================================================== */
.sticky-donate-wrapper {
  position: fixed;
  bottom: 44px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity var(--ease), transform var(--ease);
  pointer-events: none;
}
.sticky-donate-wrapper.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.sticky-donate-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--donate-bg);
  color: var(--donate-text);
  font-weight: 600;
  font-size: var(--text-sm);
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  border: none;
  text-decoration: none;
  transition: transform var(--ease), box-shadow var(--ease);
}
.sticky-donate-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: var(--donate-shadow-hover);
}
.sticky-donate-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.donate-icon { font-size: 1.2em; }

/* 8. MODAL ============================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.modal-overlay.is-active {
  opacity: 1;
  visibility: visible;
}
.modal-container {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  min-width: 320px;
}
.modal-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  z-index: 1;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s ease;
}
.modal-close:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}
.modal-content {
  padding: var(--space-2xl);
  overflow-y: auto;
  max-height: 80vh;
}
.modal-loading {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--text-muted);
}

/* 9. ANIMATIONS ========================================================= */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-fade-in {
  animation: fadeIn 0.3s ease forwards;
}
.animate-slide-up {
  animation: slideUp 0.4s ease forwards;
}
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* 10. RESPONSIVE ======================================================== */
@media (max-width: 640px) {
  :root {
    --space-xl: 1.5rem;
    --space-2xl: 2rem;
  }
  .tool-card { padding: var(--space-md); }
  .format-grid { grid-template-columns: repeat(2, 1fr); }
  .viz-grid { grid-template-columns: 1fr; }
  .image-grid { grid-template-columns: repeat(3, 1fr); }
  .options-grid { grid-template-columns: 1fr; }
  .wizard-steps { gap: 2px; }
  .wizard-step { font-size: var(--text-xs); padding: var(--space-xs); }
  .lang-btn span { display: none; }
  .lang-btn { padding: 6px 8px; font-size: 1.2rem; }
  .sticky-donate-wrapper { bottom: 16px; right: 16px; }
  .sticky-donate-btn { padding: 8px 14px; font-size: var(--text-xs); border-radius: 999px; }
  .sticky-donate-btn .donate-text { display: inline-flex !important; }
  .admin-panel { margin: var(--space-md) auto; padding: var(--space-md); }
  .dropzone { padding: var(--space-md); }
  .dropzone-icon { font-size: 2rem; }
}

/* 11. REDUCED MOTION ==================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .sticky-donate-wrapper, .sticky-donate-btn {
    transition: none !important;
    animation: none !important;
  }
}

/* 12. PRINT ============================================================= */
@media print {
  .site-header,
  .subsite-banner,
  .btn,
  .theme-toggle,
  .lang-switch,
  .sticky-donate-wrapper,
  .subsite-legal-footer,
  #pwaInstallBtn { display: none !important; }
  body {
    background: #fff;
    color: #000;
    padding-bottom: 0;
  }
  .tool-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #000;
  }
}
