/* =========================================================
   SnapCard Studio — style.css (Phase 3 — launch build)
   ========================================================= */

/* ---------- Design tokens ---------- */
:root {
  --font-en: 'Inter', 'Cairo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-ar: 'Cairo', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --nav-h: 66px;
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --primary: #6c5ce7;
  --primary-2: #a855f7;
  --primary-soft: rgba(108, 92, 231, 0.14);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f4fb;
  --bg-glow-1: rgba(108, 92, 231, 0.16);
  --bg-glow-2: rgba(236, 72, 153, 0.10);
  --surface: #ffffff;
  --surface-2: #f7f8fd;
  --nav-bg: rgba(255, 255, 255, 0.78);
  --text: #12142a;
  --muted: #666b88;
  --border: #e2e4f0;
  --input-bg: #f7f8fd;
  --switch-off: rgba(102, 107, 136, 0.35);
  --canvas-bg: #e9ebf7;
  --canvas-dot: rgba(18, 20, 42, 0.10);
  --ad-stripe: rgba(102, 107, 136, 0.07);
  --shadow-panel: 0 18px 40px rgba(40, 44, 90, 0.10);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0c18;
  --bg-glow-1: rgba(108, 92, 231, 0.22);
  --bg-glow-2: rgba(236, 72, 153, 0.10);
  --surface: #14162b;
  --surface-2: #1a1d38;
  --nav-bg: rgba(12, 13, 26, 0.78);
  --text: #eceefb;
  --muted: #9a9ebd;
  --border: #272a48;
  --input-bg: #1a1d38;
  --switch-off: rgba(154, 158, 189, 0.35);
  --canvas-bg: #10122a;
  --canvas-dot: rgba(255, 255, 255, 0.07);
  --ad-stripe: rgba(154, 158, 189, 0.07);
  --shadow-panel: 0 18px 40px rgba(0, 0, 0, 0.35);
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-en);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 85% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(700px 480px at -5% 105%, var(--bg-glow-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  transition: background-color 0.3s ease, color 0.3s ease;
}

html[lang="ar"] body { font-family: var(--font-ar); }
html[lang="en"] body { font-family: var(--font-en); }

h1, h2, h3, p { margin: 0; }

button, input, select, textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

svg.lucide, i[data-lucide] { width: 18px; height: 18px; flex-shrink: 0; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- Navbar ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  background: var(--nav-bg);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  backdrop-filter: blur(16px) saturate(160%);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 1320px;
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2) 60%, #ec4899);
  box-shadow: 0 8px 20px rgba(108, 92, 231, 0.4);
}

.brand-name {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  direction: ltr;
  unicode-bidi: isolate;
}

.brand-light { font-weight: 500; color: var(--muted); }

.nav-actions { display: flex; align-items: center; gap: 10px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.9rem;
  transition: transform 0.2s var(--ease), border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.btn:hover {
  border-color: var(--primary);
  box-shadow: 0 6px 18px rgba(108, 92, 231, 0.18);
  transform: translateY(-1px);
}

.btn:active { transform: translateY(0); }

.btn:disabled {
  opacity: 0.6;
  cursor: progress;
  transform: none;
  box-shadow: none;
}

.btn-pill { border-radius: 999px; }

.btn-icon {
  width: 40px;
  padding: 0;
  border-radius: 50%;
}

.btn-icon span { display: inline-flex; }

.btn-sm {
  height: 36px;
  padding: 0 14px;
  font-size: 0.84rem;
  border-radius: var(--radius-sm);
}

.btn-sm svg.lucide, .btn-sm i[data-lucide] { width: 16px; height: 16px; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover { color: #ef4444; border-color: #ef4444; box-shadow: none; }

/* Support Us (nav) */
.btn-support {
  color: #ec4899;
  border-color: rgba(236, 72, 153, 0.4);
  background: rgba(236, 72, 153, 0.08);
}

.btn-support:hover {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #ec4899, var(--primary-2));
  box-shadow: 0 8px 22px rgba(236, 72, 153, 0.35);
}

.btn-support svg.lucide { fill: currentColor; }

:root[data-theme="dark"] .icon-moon { display: none; }
:root[data-theme="light"] .icon-sun { display: none; }

/* Export action buttons */
.btn-primary {
  flex: 1 1 240px;
  height: 52px;
  padding: 0 24px;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--primary-2) 70%, #ec4899);
  box-shadow: 0 12px 28px rgba(108, 92, 231, 0.42);
}

.btn-primary:hover {
  border-color: transparent;
  box-shadow: 0 16px 34px rgba(108, 92, 231, 0.55);
  filter: brightness(1.06);
}

.btn-primary svg.lucide, .btn-primary i[data-lucide] { width: 20px; height: 20px; }

.btn-secondary {
  flex: 0 1 auto;
  height: 52px;
  padding: 0 20px;
  border-radius: var(--radius-md);
}

/* Loading spinner for export buttons */
.btn.is-loading svg.lucide,
.btn.is-loading i[data-lucide] { display: none; }

.btn.is-loading::before {
  content: "";
  width: 18px;
  height: 18px;
  border: 2.5px solid currentColor;
  border-inline-end-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ---------- Workspace ---------- */
.workspace {
  width: 100%;
  flex: 1 0 auto;
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 24px 56px;
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

/* ---------- Controls panel ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-panel);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel-head h1 {
  font-size: 1.2rem;
  font-weight: 800;
}

.panel-head p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.88rem;
}

.field { display: flex; flex-direction: column; gap: 8px; }

.field label,
.field-label {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text);
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.counter {
  font-size: 0.76rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  direction: ltr;
}

.hint {
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--muted);
}

.hint.is-error { color: #ef4444; font-weight: 600; }

input[type="text"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: 11px 14px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

input::placeholder,
textarea::placeholder { color: var(--muted); opacity: 0.75; }

input:hover, select:hover, textarea:hover { border-color: var(--muted); }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

textarea {
  resize: vertical;
  min-height: 110px;
  line-height: 1.7;
}

#fieldReply { min-height: 80px; }

select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  padding-inline-end: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239a9ebd' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
}

html[dir="rtl"] select { background-position: left 14px center; }

select option { background: var(--surface); color: var(--text); }

input[type="datetime-local"] { min-height: 44px; }

/* ---------- Aspect ratio selector ---------- */
.ratio-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.ratio-option {
  position: relative;
  display: block;
}

.ratio-option input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.ratio-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 96px;
  padding: 10px 6px;
  text-align: center;
  color: var(--muted);
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease, transform 0.2s var(--ease);
}

.ratio-box strong {
  direction: ltr;
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}

.ratio-box small {
  font-size: 0.7rem;
  line-height: 1.3;
}

.ratio-icon {
  height: 28px;
  display: grid;
  place-items: center;
}

.ratio-shape {
  display: block;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.shape-square { width: 20px; height: 20px; }
.shape-story  { width: 14px; height: 25px; }
.shape-wide   { width: 28px; height: 16px; }

.ratio-option:hover .ratio-box { border-color: var(--muted); transform: translateY(-1px); }

.ratio-option input:checked + .ratio-box {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: var(--primary);
}

.ratio-option input:focus-visible + .ratio-box {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- Avatar uploader ---------- */
.avatar-upload {
  display: flex;
  align-items: center;
  gap: 14px;
}

.avatar-thumb {
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.2rem;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--border);
}

.avatar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.avatar-inner {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

.avatar-inner img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  -webkit-user-drag: none;
  user-select: none;
}

/* ---------- Switches ---------- */
.switch-group {
  display: flex;
  flex-direction: column;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
}

.switch-row + .switch-row { border-top: 1px solid var(--border); }

.switch-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.switch-text label {
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

.switch-text small {
  font-size: 0.76rem;
  line-height: 1.45;
  color: var(--muted);
}

.switch {
  position: relative;
  flex: none;
  display: block;
  width: 46px;
  height: 26px;
}

.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--switch-off);
  transition: background-color 0.2s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  inset-inline-start: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: inset-inline-start 0.22s var(--ease);
}

.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { inset-inline-start: 23px; }

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- Gradient swatches ---------- */
.swatches {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.swatch {
  position: relative;
  display: block;
  height: 56px;
}

.swatch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.swatch-fill {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18), 0 6px 14px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s var(--ease), box-shadow 0.2s ease;
}

.swatch:hover .swatch-fill { transform: translateY(-2px) scale(1.03); }

.swatch input:checked + .swatch-fill {
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--primary), 0 8px 18px rgba(0, 0, 0, 0.25);
}

.swatch input:checked + .swatch-fill::after { content: "✓"; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }

.swatch input:focus-visible + .swatch-fill {
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--primary-2);
}

/* ---------- Ad placeholders ---------- */
.ad-slot {
  position: relative;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  background:
    repeating-linear-gradient(135deg, transparent 0 12px, var(--ad-stripe) 12px 24px),
    var(--surface);
}

.ad-inner {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.ad-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.ad-label {
  font-size: 0.74rem;
  font-weight: 300;
  letter-spacing: 0.08em;
  color: var(--muted);
  opacity: 0.85;
  text-transform: uppercase;
}

html[lang="ar"] .ad-label { letter-spacing: 0; text-transform: none; font-size: 0.8rem; }

.ad-horizontal {
  min-height: 90px;
  margin-top: 16px;
}

.ad-square {
  width: min(100%, 300px);
  aspect-ratio: 1 / 1;
  margin-inline: auto;
}

/* ---------- Preview pane ---------- */
.preview-pane {
  position: sticky;
  top: calc(var(--nav-h) + 24px);
  min-width: 0;
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.preview-head h2 { font-size: 1.2rem; font-weight: 800; }

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #16a34a;
  background: rgba(34, 197, 94, 0.13);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
  70%  { box-shadow: 0 0 0 9px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.preview-canvas {
  display: grid;
  place-items: center;
  min-height: 440px;
  padding: 24px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background-color: var(--canvas-bg);
  background-image: radial-gradient(var(--canvas-dot) 1.2px, transparent 1.2px);
  background-size: 22px 22px;
  overflow: hidden;
}

.preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

/* =========================================================
   Card stage (artboard)
   The stage is a fixed-size design canvas (1080px wide base) that
   JavaScript scales down to fit the preview. Every size inside is
   therefore written in artboard pixels, which keeps text sharp and
   undistorted for every aspect ratio, and gives the PNG export a
   pixel-exact source.
   ========================================================= */
.stage-frame {
  position: relative;
  flex: none;
}

.card-stage {
  --fit: 1;           /* text shrink factor, set by JS when content is tall */
  --tm: 1;            /* per-ratio text multiplier */
  --pad-x: 110px;
  --pad-top: 90px;
  --pad-bottom: 150px;

  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  display: grid;
  align-content: center;
  justify-items: stretch;
  padding: var(--pad-top) var(--pad-x) var(--pad-bottom);
  border-radius: 68px;
  overflow: hidden;
  isolation: isolate;
  background: linear-gradient(135deg, #667eea, #764ba2);
  box-shadow: 0 68px 160px rgba(10, 10, 40, 0.40), 0 18px 45px rgba(10, 10, 40, 0.25);
}

.card-stage[data-ratio="1:1"] {
  width: 1080px;
  height: 1080px;
  --tm: 1;
  --pad-x: 110px;
  --pad-top: 90px;
  --pad-bottom: 150px;
}

.card-stage[data-ratio="9:16"] {
  width: 1080px;
  height: 1920px;
  --tm: 1.15;
  --pad-x: 90px;
  --pad-top: 170px;
  --pad-bottom: 280px;
}

.card-stage[data-ratio="16:9"] {
  width: 1600px;
  height: 900px;
  --tm: 0.92;
  --pad-x: 230px;
  --pad-top: 50px;
  --pad-bottom: 100px;
}

/* Blobs use soft radial gradients (not CSS filters) so the PNG export is identical to the preview */
.blob {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

.blob-1 {
  width: 760px;
  height: 760px;
  top: -280px;
  inset-inline-start: -230px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0) 70%);
}

.blob-2 {
  width: 880px;
  height: 880px;
  bottom: -360px;
  inset-inline-end: -270px;
  background: radial-gradient(circle, rgba(0, 0, 0, 0.34) 0%, rgba(0, 0, 0, 0) 70%);
}

.blob-3 {
  width: 520px;
  height: 520px;
  top: 30%;
  inset-inline-end: -200px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.30) 0%, rgba(255, 255, 255, 0) 70%);
}

.watermark {
  position: absolute;
  inset-inline: 0;
  bottom: 48px;
  z-index: 1;
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
  direction: ltr;
}

/* ---------- Glass card ---------- */
.glass-card {
  --q-base: 64px;     /* quote text size */
  --m-base: 42px;     /* chat message text size */
  --privacy-blur: 11px; /* ≈ 5px at on-screen preview scale. The PNG export renders this same CSS blur natively */

  position: relative;
  z-index: 1;
  width: 100%;
  padding: 68px 64px;
  border-radius: 58px;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.18);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.30), rgba(255, 255, 255, 0.10));
  border: 2px solid rgba(255, 255, 255, 0.38);
  /* No backdrop-filter on purpose: it cannot be captured in the exported PNG, and the stage behind the
     card is only smooth gradients, so the translucent fill gives the same glass look in preview AND export. */
  box-shadow:
    0 50px 112px rgba(8, 8, 40, 0.32),
    0 9px 27px rgba(8, 8, 40, 0.18),
    inset 0 2px 0 rgba(255, 255, 255, 0.5);
}

.glass-card[data-size="md"] { --q-base: 52px; --m-base: 38px; }
.glass-card[data-size="sm"] { --q-base: 42px; --m-base: 34px; }

.glass-card[data-type="chat"] {
  padding: 0;
  overflow: hidden;
}

.is-placeholder { opacity: 0.6; }

.glass-card svg.lucide { width: 40px; height: 40px; }

/* Avatar inside the card */
.glass-card .avatar {
  flex-shrink: 0;
  width: 108px;
  height: 108px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 50px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.16));
  border: 2px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 9px 27px rgba(0, 0, 0, 0.18);
}

/* Name + verified badge */
.name-row {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.name-row strong { overflow-wrap: anywhere; }

.verified-badge {
  flex: none;
  width: 38px;
  height: 38px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}

/* Privacy blur: sender name, avatar and (in quote cards) the @username.
   The PNG export is rendered by the browser itself (SVG foreignObject), so this exact CSS filter
   is what ends up in the saved image: the name stays visible, just blurred. */
.glass-card[data-blur="true"] .avatar-inner,
.glass-card[data-blur="true"] .name-row strong,
.glass-card[data-blur="true"] .q-author .handle {
  filter: blur(var(--privacy-blur));
}

.glass-card[data-blur="true"] .avatar-inner {
  transform: scale(1.25);
}

/* Quote layout */
.glass-card svg.quote-mark,
.glass-card i.quote-mark {
  display: block;
  width: 86px;
  height: 86px;
  opacity: 0.85;
  stroke-width: 2;
}

.q-text {
  margin: 32px 0 58px;
  font-size: calc(var(--q-base) * var(--tm) * var(--fit));
  font-weight: 700;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-align: start;
}

.q-author {
  display: flex;
  align-items: center;
  gap: 32px;
}

.author-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.4;
}

.author-meta .name-row {
  font-size: 38px;
  font-weight: 700;
}

.author-meta .handle {
  font-size: 31px;
  opacity: 0.82;
  overflow-wrap: anywhere;
}

.q-date {
  display: block;
  margin-top: 50px;
  padding-top: 32px;
  border-top: 2px solid rgba(255, 255, 255, 0.28);
  font-size: 28px;
  opacity: 0.85;
}

/* WhatsApp chat layout */
.chat-header {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 32px 40px;
  background: rgba(6, 78, 70, 0.62);
  border-bottom: 2px solid rgba(255, 255, 255, 0.18);
}

.chat-header .avatar {
  width: 94px;
  height: 94px;
  font-size: 44px;
}

.chat-id {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}

.chat-id .name-row {
  font-size: 36px;
  font-weight: 700;
}

.chat-id .verified-badge {
  width: 34px;
  height: 34px;
}

.chat-id .handle {
  font-size: 28px;
  opacity: 0.85;
  overflow-wrap: anywhere;
}

.chat-actions {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 42px;
  opacity: 0.92;
}

.chat-actions svg.lucide,
.chat-actions i[data-lucide] { width: 44px; height: 44px; }

.chat-body {
  display: flex;
  flex-direction: column;
  gap: 32px;
  min-height: 380px;
  padding: 50px 40px 60px;
  background-color: rgba(0, 0, 0, 0.12);
  background-image: radial-gradient(rgba(255, 255, 255, 0.09) 2.5px, transparent 2.5px);
  background-size: 40px 40px;
}

.date-chip {
  align-self: center;
  padding: 8px 32px;
  border-radius: 22px;
  font-size: 26px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.30);
  border: 2px solid rgba(255, 255, 255, 0.14);
}

.bubble {
  max-width: 90%;
  padding: 22px 32px 18px;
  border-radius: 40px;
  color: #0c1f1b;
  text-shadow: none;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.18);
}

.bubble-in {
  align-self: flex-start;
  border-start-start-radius: 9px;
  background: rgba(255, 255, 255, 0.92);
}

.bubble-out {
  align-self: flex-end;
  border-start-end-radius: 9px;
  background: rgba(217, 253, 211, 0.96);
}

.msg-text {
  font-size: calc(var(--m-base) * var(--tm) * var(--fit));
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-align: start;
}

.msg-time {
  display: block;
  margin-top: 10px;
  text-align: end;
  font-size: 24px;
  color: #5b6f69;
}

.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
  font-size: 24px;
  color: #5b6f69;
}

.glass-card svg.ticks,
.glass-card i.ticks {
  width: 36px;
  height: 36px;
  color: #53bdeb;
  stroke-width: 2.4;
}

/* ---------- Footer ---------- */
.site-footer {
  flex: none;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.footer-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 36px 24px 20px;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

.footer-brand { display: flex; flex-direction: column; gap: 14px; }

.footer-tagline {
  max-width: 52ch;
  font-size: 0.9rem;
  line-height: 1.8;
  color: var(--muted);
}

.trust-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.trust-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.88rem;
  line-height: 1.6;
}

.trust-list svg.lucide,
.trust-list i[data-lucide] {
  width: 32px;
  height: 32px;
  padding: 7px;
  border-radius: 10px;
  color: var(--primary);
  background: var(--primary-soft);
}

.footer-copy {
  max-width: 1320px;
  margin: 0 auto;
  padding: 16px 24px 28px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

.footer-inner + .footer-copy { margin-top: 8px; }

/* ---------- Support dialog ---------- */
.dialog {
  width: min(92vw, 440px);
  padding: 0;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 26px;
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.45);
  overflow: visible;
}

.dialog[open] { animation: dialogIn 0.28s var(--ease); }

.dialog::backdrop {
  background: rgba(8, 9, 20, 0.62);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

@keyframes dialogIn {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.dialog-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 28px 28px;
  text-align: center;
}

.dialog-card h2 { font-size: 1.3rem; font-weight: 800; }

.dialog-text {
  max-width: 34ch;
  font-size: 0.92rem;
  line-height: 1.8;
  color: var(--muted);
}

.dialog-close {
  position: absolute;
  top: 14px;
  inset-inline-end: 14px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.dialog-close:hover { color: var(--text); border-color: var(--muted); }

.dialog-heart {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  color: #fff;
  border-radius: 20px;
  background: linear-gradient(135deg, #ec4899, var(--primary-2));
  box-shadow: 0 14px 30px rgba(236, 72, 153, 0.4);
}

.dialog-heart svg.lucide { width: 30px; height: 30px; fill: currentColor; }

.share-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.share-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  height: 52px;
  padding: 0 14px;
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  text-align: start;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: transform 0.2s var(--ease), border-color 0.2s ease, box-shadow 0.2s ease;
}

.share-btn:hover {
  border-color: var(--primary);
  box-shadow: 0 8px 20px rgba(108, 92, 231, 0.18);
  transform: translateY(-1px);
}

.share-icon {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: #fff;
  border-radius: 10px;
}

.share-icon svg.lucide { width: 18px; height: 18px; }

.share-whatsapp .share-icon { background: #25d366; }
.share-twitter .share-icon  { background: #14171a; }
.share-link .share-icon     { background: var(--primary); }
.share-support .share-icon  { background: linear-gradient(135deg, #f59e0b, #ec4899); }

/* ---------- Toasts ---------- */
.toast-region {
  position: fixed;
  inset-inline: 0;
  bottom: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(92vw, 460px);
  padding: 13px 18px;
  color: #fff;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.5;
  background: #1c1f3d;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.25s ease, transform 0.3s var(--ease);
}

.toast.is-visible { opacity: 1; transform: none; }

.toast::before {
  flex: none;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 800;
  color: #fff;
  background: var(--primary);
  content: "i";
}

.toast-success::before { content: "✓"; background: #22c55e; }
.toast-error::before   { content: "✕"; background: #ef4444; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
    padding: 20px 16px 40px;
    gap: 22px;
  }

  .preview-pane {
    position: static;
    order: -1;
  }

  .preview-canvas { min-height: 0; padding: 20px 12px; }
  .nav-inner { padding: 0 16px; }

  .footer-inner {
    grid-template-columns: 1fr;
    padding: 28px 16px 16px;
  }
}

@media (max-width: 520px) {
  .brand-name { font-size: 1.02rem; }
  .btn-pill { padding: 0 12px; }
  .btn-support { width: 40px; padding: 0; }
  .btn-support .btn-label { display: none; }
  .nav-actions { gap: 8px; }
  .panel { padding: 18px; }
  .btn-primary, .btn-secondary { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }

  .btn.is-loading::before { animation: spin 1.6s linear infinite !important; }
}
