/* ---------- Material Design 3 tokens ----------
   Color roles, shape scale and elevation follow M3 (m3.material.io)'s
   structure — anchored on the actual Mégafun logo red (#902010, sampled
   directly from the PNG) as the "primary" seed instead of a generic Google
   blue, so this reads as the brand wearing Material, not a swap to a
   different product's colors. Every existing rule below already references
   these custom properties by name (--accent, --radius, --shadow-md, etc.),
   so redefining the tokens here cascades the whole app without having to
   touch every selector individually. */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

:root {
  /* Surface roles */
  --bg: #fff8f6;            /* surface */
  --panel: #fffbff;         /* surface container (cards, panels) */
  --border: #e7d6d1;        /* outline-variant */
  --text: #271815;          /* on-surface */
  --muted: #6f5b57;         /* on-surface-variant */

  /* Primary role (brand red) */
  --accent: #8a2115;        /* primary */
  --accent-dark: #641004;   /* primary, pressed/hover tone */
  --accent-soft: #ffdad2;   /* primary-container */

  /* Semantic roles */
  --success: #146c2e;
  --success-bg: #d7f2dc;
  --warning: #8a5000;
  --warning-bg: #ffe3b3;
  --danger: #ba1a1a;        /* M3 standard error red */
  --danger-bg: #ffdad6;

  /* Shape scale (M3 uses generous, systematic rounding) */
  --radius-xs: 8px;         /* text fields, chips, small controls */
  --radius-sm: 12px;        /* icon buttons, tool-rail buttons */
  --radius: 16px;           /* cards, panels, dialogs, flyouts */
  --radius-lg: 24px;        /* large surfaces */
  --radius-pill: 100px;     /* filled/outlined buttons */

  /* Elevation (M3's two-layer key + ambient shadow) */
  --shadow-sm: 0 1px 2px rgba(39, 24, 21, 0.15), 0 1px 3px 1px rgba(39, 24, 21, 0.10);
  --shadow-md: 0 1px 3px rgba(39, 24, 21, 0.15), 0 4px 8px 3px rgba(39, 24, 21, 0.12);
  --shadow-lg: 0 2px 3px rgba(39, 24, 21, 0.15), 0 6px 10px 4px rgba(39, 24, 21, 0.12);
}

/* ---------- Dark theme (Téléfun-style) ----------
   Every rule in this file and admin.css already reads color through the
   custom properties above rather than hardcoded hex — that's what makes a
   single override block here enough to re-skin the whole app (topbar, cards,
   buttons, tables, badges...) instead of needing a parallel dark rule next
   to every single light one. Activated by [data-theme="dark"] on <html>,
   toggled/persisted by assets/js/theme.js. Palette matches the dark client
   gallery (assets/css/gallery.css's --gal-* tokens) so the whole product
   shares one dark identity, not two different near-black grays. A few
   editor-canvas-specific pieces in this file (checkerboard transparency
   pattern, text-effect preview swatches) are intentionally left as neutral
   fixed colors — they're indicators, not surfaces, and stay legible/correct
   in either theme. */
[data-theme="dark"] {
  --bg: #0f0f0f;
  --panel: #1a1a1a;
  --border: #2c2c2c;
  --text: #f4efe9;
  --muted: #9c8f86;

  --accent: #c62a1f;
  --accent-dark: #e0362a;
  --accent-soft: #3a1512;

  --success: #3ecf6e;
  --success-bg: #123a22;
  --warning: #e0a24a;
  --warning-bg: #3a2a10;
  --danger: #ff5449;
  --danger-bg: #3a1210;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px 1px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 8px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 2px 3px rgba(0, 0, 0, 0.4), 0 6px 10px 4px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button, input, textarea, select { font-family: inherit; }

a { color: var(--accent); }

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

header.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 10px 24px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 40;
}

header.topbar h1 {
  font-size: 18px;
  margin: 0;
}

header.topbar .sub {
  color: var(--muted);
  font-size: 13px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
/* Flex items don't shrink below their own content size by default — without
   this, the title/subtitle block refused to shrink even though its parent
   (.topbar-brand, above) was told it's allowed to, and would silently
   overflow the header on narrow screens instead of truncating. */
.topbar-brand > div { min-width: 0; }
header.topbar h1,
header.topbar .sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-logo {
  height: 32px;
  width: auto;
  display: block;
  flex: none;
}

/* Undo/redo + zoom cluster — centered in the top bar (Photoshop-style),
   grouped into a pill "chip" so it reads as one deliberate toolbar instead
   of floating controls next to the logo. */
.topbar-tools {
  display: flex;
  align-items: center;
  background: var(--surface-alt, #f4f2ec);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px 8px;
  gap: 4px;
  justify-self: center;
}
.topbar-tools .zoom-label { min-width: 42px; text-align: center; color: var(--muted); font-size: 12px; }
.topbar-divider { width: 1px; height: 20px; background: var(--border); margin: 0 6px; flex: none; }
/* Flatten the individual buttons inside the chip — the chip itself supplies
   the border/background now, so double-bordered circles would look heavy. */
.topbar-tools .icon-btn { border-color: transparent; background: transparent; width: 28px; height: 28px; }
.topbar-tools .icon-btn:hover:not(:disabled) { background: var(--accent-soft); }

/* Save indicator + tour-replay button, side by side (previously stacked —
   the save-indicator's block-level div pushed the button onto its own line
   because this container had no flex declaration). */
.topbar-actions { justify-self: end; display: flex; align-items: center; gap: 10px; }

.login-logo {
  display: block;
  height: 36px;
  width: auto;
  margin: 0 auto 18px;
}

nav.steps a {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  margin-left: 16px;
}

/* --- Template gallery --- */
#templateGallery {
  max-width: 980px;
  margin: 40px auto;
  padding: 0 20px;
}

#templateGallery h2 {
  font-size: 20px;
  margin-bottom: 4px;
}

#templateGallery p.hint {
  color: var(--muted);
  margin-top: 0;
  margin-bottom: 24px;
}

.gallery-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.gallery-tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 4px;
  margin-right: 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.gallery-tab:hover {
  color: var(--text);
}

.gallery-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.gallery-search {
  position: relative;
  max-width: 360px;
  margin-bottom: 18px;
}

.gallery-search input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-family: inherit;
  background: var(--panel);
  box-sizing: border-box;
}

.gallery-search input:focus {
  outline: none;
  border-color: var(--accent);
}

.gallery-search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.template-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .15s;
  box-shadow: var(--shadow-sm);
}

.template-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.template-card .thumb {
  width: 100%;
  height: 220px;
  background: #eee repeating-conic-gradient(#f0f0f0 0% 25%, #e6e6e6 0% 50%) 50% / 20px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Overlay-imported templates (background.jpg + overlay.png) need both
   images stacked exactly on top of each other to preview correctly — an
   overlay PNG alone is mostly transparent (just the decorative bits), so
   without its background underneath the card shows floating decorations on
   a checkerboard instead of the actual finished look. */
.template-card .thumb img.thumb-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 1;
}

/* Bug fix: this used to have no `position`, which made it a normal in-flow
   element — but per CSS stacking rules, a `position:absolute` sibling (the
   background above) always paints ABOVE non-positioned content regardless of
   DOM order, even though this overlay <img> comes second in the markup. The
   result: every overlay-imported template's gallery thumbnail silently showed
   just the plain background, with the actual decorative overlay art invisible
   underneath it. Giving this its own stacking context (position:relative)
   with a higher z-index than .thumb-bg fixes the paint order so the overlay
   actually shows on top, as intended. */
.template-card .thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  position: relative;
  z-index: 2;
}

.template-card .meta {
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
}

.template-card .meta span {
  display: block;
  font-weight: 400;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* --- Editor layout --- */
#editor {
  display: none;
  height: calc(100vh - 57px);
}

#editor.active {
  display: grid;
  grid-template-columns: 64px 1fr 320px;
}

.panel {
  background: var(--panel);
  overflow-y: auto;
  padding: 16px;
}

.panel.right { border-left: 1px solid var(--border); }

.panel h3, .layers-section h3, .extra-section h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin: 18px 0 10px;
}
.panel h3:first-child, .layers-section h3:first-child { margin-top: 0; }

/* Right panel is three stacked sections, Photoshop-style: contextual
   properties on top, layers below that (near the bottom, like Photoshop's
   Layers panel), then note + finish anchored at the very bottom as the
   final call to action — a light divider between each keeps them visually
   distinct without needing separate scroll areas. */
#propsPanel, .layers-section, .extra-section {
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.extra-section { border-bottom: none; margin-bottom: 0; }
.layers-section ul#layersList { max-height: 220px; overflow-y: auto; }

/* ---------- Left tool rail (Photoshop-style icon toolbar) ---------- */
.tool-rail {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 0;
}
.tool-btn-wrap { position: relative; }
.tool-btn {
  position: relative;
  width: 42px; height: 42px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: none;
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.tool-btn svg, .tool-btn i { width: 20px; height: 20px; font-size: 18px; }
.tool-btn:hover { background: var(--accent-soft); }
.tool-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Tooltip on hover — small dark bubble to the right of the icon */
.tool-btn::after {
  content: attr(data-tooltip);
  position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  background: #1f2430; color: #fff; font-size: 12px; padding: 5px 10px; border-radius: var(--radius-xs);
  white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s;
  z-index: 55;
}
.tool-btn:hover::after, .tool-btn:focus-visible::after { opacity: 1; }

/* Flyout panel — opens beside the tool-rail icon that triggered it */
.flyout-panel {
  display: none;
  position: absolute; left: calc(100% + 10px); top: -12px; z-index: 46;
  width: 260px; max-height: 70vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: 14px;
}
.flyout-panel.open { display: block; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  justify-content: center;
  width: 100%;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 8px;
  transition: background .12s, border-color .12s, transform .05s;
}

.btn svg { flex: none; width: 15px; height: 15px; }
.btn i { flex: none; font-size: 14px; }

.btn:hover { background: var(--border); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 500;
}

.btn.primary:hover { background: var(--accent-dark); }

.btn.small { width: auto; padding: 6px 14px; font-size: 12px; margin-bottom: 0; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--accent-soft); }

/* Circular icon-only helper button (e.g. "?" tour replay) */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--panel); color: var(--muted);
  cursor: pointer; flex: none; font-size: 13px; font-weight: 700;
  transition: background .12s, color .12s;
}
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn i { font-size: 14px; }
.icon-btn:hover { background: var(--accent-soft); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn:disabled:hover { background: var(--panel); }

/* Light/dark toggle button (data-theme-toggle, see assets/js/theme.js) — one
   button contains both a sun and a moon icon stacked, CSS shows only the one
   relevant to the theme you'd switch TO (sun while dark = "tap to go light",
   moon while light = "tap to go dark"), same [data-theme]-driven convention
   as every other color override in this file. Shared by .icon-btn (cadre.php)
   and .admin-icon-btn (admin panel/login) since both use the same markup. */
[data-theme-toggle] { position: relative; }
[data-theme-toggle] .theme-icon-sun,
[data-theme-toggle] .theme-icon-moon { display: none; }
html:not([data-theme="dark"]) [data-theme-toggle] .theme-icon-moon { display: block; }
html[data-theme="dark"] [data-theme-toggle] .theme-icon-sun { display: block; }

/* login.php has no shared topbar to dock the toggle in, so it floats it
   top-right of the viewport instead. */
.login-theme-toggle { position: fixed; top: 18px; right: 18px; z-index: 10; }

/* Status badges (used in admin tables) */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-nouveau, .badge-pending { background: var(--warning-bg); color: var(--warning); }
.badge-en_cours, .badge-opened { background: #e6eef7; color: #2563a8; }
.badge-termine, .badge-completed { background: var(--success-bg); color: var(--success); }
.badge-expired { background: var(--danger-bg); color: var(--danger); }

/* Layers list */
#layersList { list-style: none; margin: 0; padding: 0; }

.layer-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 8px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-size: 13px;
  border: 1px solid transparent;
}

.layer-row.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.layer-row .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-row button {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  padding: 2px 4px;
}

.layer-row button:hover { color: var(--text); }

.layer-row .drag-handle {
  cursor: grab;
  color: var(--muted);
  font-size: 13px;
  padding: 0 2px;
}
.layer-row.dragging { opacity: 0.4; }
.layer-row.drag-over { border-color: var(--accent); background: var(--accent-soft); }

/* Image bank (reuse already-uploaded images without re-selecting a file) */
.image-bank {
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 4px;
}
.image-bank.has-items { display: flex; }
.bank-thumb {
  width: 42px; height: 42px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  overflow: hidden;
  cursor: pointer;
  background: var(--panel);
}
.bank-thumb:hover { border-color: var(--accent); }
.bank-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Canvas area */
.canvas-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  background:
    linear-gradient(45deg, #eee 25%, transparent 25%),
    linear-gradient(-45deg, #eee 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eee 75%),
    linear-gradient(-45deg, transparent 75%, #eee 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

#canvasHolder {
  border: 1px solid var(--border);
}

/* Form fields */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input[type=text],
.field input[type=email],
.field input[type=number],
.field textarea,
.field select {
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  font-size: 13px;
  font-family: inherit;
}
.field textarea { resize: vertical; min-height: 60px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field input[type=color] { width: 100%; height: 34px; padding: 2px; }

.bg-swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.bg-swatch, .bg-gradient-swatch {
  width: 26px; height: 26px;
  border-radius: 4px;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 0;
  transition: transform .1s, border-color .1s;
}
.bg-swatch:hover, .bg-gradient-swatch:hover { border-color: var(--accent); transform: scale(1.08); }
.bg-subheading {
  display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin: 12px 0 6px;
}

/* Custom font picker — searchable, each name previewed in its own font */
.font-picker { position: relative; }
.font-picker-trigger {
  width: 100%; text-align: left; padding: 8px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--panel); font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.font-picker-trigger::after { content: '▾'; color: var(--muted); font-size: 11px; margin-left: 6px; flex: none; }
.font-picker-trigger:hover { border-color: var(--accent); }
.font-picker-panel {
  display: none; position: absolute; top: 100%; left: 0; right: 0; margin-top: 4px; z-index: 45;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); max-height: 320px; flex-direction: column; overflow: hidden;
}
.font-picker-panel.open { display: flex; }
.font-picker-search {
  margin: 8px; padding: 7px 9px; border-radius: var(--radius-sm); border: 1px solid var(--border); font-size: 13px;
}
.font-picker-list { overflow-y: auto; padding: 0 4px 8px; }
.font-picker-group-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 8px 4px;
}
.font-picker-item {
  display: block; width: 100%; text-align: left; padding: 7px 10px; border: none; background: none;
  font-size: 16px; cursor: pointer; border-radius: var(--radius-sm); color: var(--text);
}
.font-picker-item:hover { background: var(--accent-soft); }
.font-picker-item.selected { background: var(--accent-soft); font-weight: 600; }

/* Text effects grid */
.effect-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.effect-swatch {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 4px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--panel); cursor: pointer;
}
.effect-swatch:hover { border-color: var(--accent); }
.effect-swatch.selected { border-color: var(--accent); background: var(--accent-soft); }
.effect-preview { font-size: 19px; font-weight: 700; color: var(--text); line-height: 1; }
.effect-preview-shadow { text-shadow: 2px 2px 3px rgba(0,0,0,.5); }
.effect-preview-outline { -webkit-text-stroke: 1px var(--text); color: var(--panel); text-shadow: 0 0 1px rgba(0,0,0,.3); }
.effect-preview-highlight { background: #fff59d; padding: 1px 5px; border-radius: 3px; }
.effect-preview-neon { color: #ff2fd0; text-shadow: 0 0 6px #ff2fd0, 0 0 12px #ff2fd0; }
.effect-name { font-size: 10px; color: var(--muted); }

.empty-hint {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 20px 0;
}

/* Modal (success) */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: none; align-items: center; justify-content: center; z-index: 50;
}
.overlay.active { display: flex; }
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 28px; max-width: 420px; text-align: center;
}
.modal h2 { margin-top: 0; }
.modal .links { display: flex; gap: 10px; justify-content: center; margin: 16px 0; }
.modal .links a {
  padding: 8px 14px; border-radius: var(--radius-xs); border: 1px solid var(--border); text-decoration: none; color: var(--text); font-size: 13px;
}

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #1f2430; color: white; padding: 10px 18px; border-radius: var(--radius-xs); font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
  z-index: 60;
}
.toast.show { opacity: 1; }

/* Section headers inside the editor panels — icon + label */
.panel h3, .layers-section h3, .extra-section h3 { display: flex; align-items: center; gap: 7px; }
.panel h3 svg, .layers-section h3 svg, .extra-section h3 svg { width: 14px; height: 14px; opacity: .7; }
.panel h3 i, .layers-section h3 i, .extra-section h3 i { font-size: 13px; opacity: .7; }

/* Autosave status indicator (replaces the old manual "save" button) */
.save-indicator {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--muted);
  padding: 8px 2px;
}
.save-indicator .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--border); flex: none;
  transition: background .2s;
}
.save-indicator.saving .dot { background: var(--warning); animation: pulse-dot 1s ease-in-out infinite; }
.save-indicator.saved .dot { background: var(--success); }
.save-indicator.error .dot { background: var(--danger); }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- Guided tour ---------- */
.tour-overlay {
  position: fixed; inset: 0; z-index: 200; display: none;
}
.tour-overlay.active { display: block; }
.tour-scrim {
  position: absolute; inset: 0;
  background: rgba(26, 24, 20, 0.55);
  transition: clip-path .25s ease;
}
.tour-bubble {
  position: absolute; z-index: 201;
  background: var(--panel); border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 16px 18px; width: 290px; max-width: calc(100vw - 32px);
  font-size: 13px; line-height: 1.5;
}
.tour-bubble .tour-step-count {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px;
}
.tour-bubble h4 { margin: 0 0 6px; font-size: 14px; }
.tour-bubble p { margin: 0 0 14px; color: var(--text); }
.tour-bubble .tour-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tour-bubble .tour-skip { background: none; border: none; color: var(--muted); font-size: 12px; cursor: pointer; padding: 4px 0; }
.tour-bubble .tour-skip:hover { color: var(--text); text-decoration: underline; }
.tour-bubble .tour-next { padding: 7px 14px; }
.tour-spotlight-ring {
  position: absolute; z-index: 201; pointer-events: none;
  border: 2px solid #fff; border-radius: var(--radius-sm);
  box-shadow: 0 0 0 4px rgba(255,255,255,.25), 0 0 0 2000px rgba(26, 24, 20, 0.55);
  transition: all .25s ease;
}

/* Drag-and-drop image upload onto the canvas */
.canvas-wrap.drag-over::after {
  content: 'Déposez l\'image ici';
  position: absolute; inset: 12px;
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  background: rgba(255,255,255,.85);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 600; color: var(--accent);
  pointer-events: none;
}
.canvas-wrap { position: relative; }

/* ---------- Responsive: narrower screens stack the editor vertically ---------- */
@media (max-width: 900px) {
  /* header.topbar's 3-column grid (brand / tools chip / actions) was never
     given a mobile treatment — on a phone-width viewport the fixed-content
     tools chip plus both flexible side columns don't fit, causing overflow
     or a squashed title. Clients open their personalization link by email,
     very plausibly on a phone, so this needed a real fix rather than an
     assumption it "probably" scales down fine. */
  header.topbar { padding: 8px 12px; gap: 8px; }
  header.topbar .sub { display: none; }
  header.topbar h1 { font-size: 15px; }
  .topbar-tools { padding: 3px 5px; gap: 2px; }
  .topbar-tools .zoom-label { display: none; }
  .topbar-divider { margin: 0 3px; }

  #editor.active {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
    height: auto;
    min-height: calc(100vh - 57px);
  }
  .tool-rail {
    width: auto;
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 8px;
    overflow-x: auto;
  }
  .flyout-panel {
    left: 0;
    top: 100%;
    right: 0;
    width: auto;
  }
  .panel.right {
    border: none;
    border-bottom: 1px solid var(--border);
    max-height: 320px;
  }
  .layers-section ul#layersList { max-height: 140px; }
  .canvas-col { min-height: 360px; }
}
