/* Printall — styles.css
   Identité : le plateau d'impression (gris aluminium à trame de points), les repères
   de calage en magenta autour des zones, et la pastille CMJ du logo. Le reste reste sobre. */

:root {
  --platen: #E7E9EE;
  --paper: #FFFFFF;
  --ink: #1E2130;
  --ink-2: #4B4F63;
  --ink-3: #8A8FA3;
  --line: #D6D9E1;
  --magenta: #D1006F;
  --magenta-deep: #A3005A;
  --cyan: #0091D5;
  --yellow: #FFD400;
  --good: #1E8E3E;
  --ok: #B26A00;
  --bad: #C62828;
  --r-s: 10px;
  --r-m: 14px;
  --r-l: 20px;
  --sheet-h: 0px;
  --font: "Alexandria", "Cairo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--platen);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg {
  width: 22px; height: 22px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
svg .f { fill: currentColor; stroke: none; }
:focus-visible { outline: 2.5px solid var(--cyan); outline-offset: 2px; }

/* ---------- structure ---------- */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
body.sheet-open .app { padding-bottom: var(--sheet-h); }
body.sheet-open .toolbar,
body.sheet-open .ctxbar { display: none; }

/* ---------- en-tête ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 8px;
  padding-inline-start: 14px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.mark { position: relative; width: 26px; height: 22px; flex: none; }
.mark i { position: absolute; width: 14px; height: 14px; border-radius: 50%; mix-blend-mode: multiply; }
.mark i:nth-child(1) { background: var(--cyan); left: 0; top: 0; }
.mark i:nth-child(2) { background: var(--magenta); left: 10px; top: 0; }
.mark i:nth-child(3) { background: var(--yellow); left: 5px; top: 8px; }
.brand-name { font-weight: 800; font-size: 19px; letter-spacing: -0.02em; }
.brand-tag { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 2px; }
.icon-btn {
  position: relative;
  display: inline-grid; place-items: center;
  width: 44px; height: 44px;
  border: 0; border-radius: 12px; background: transparent; color: var(--ink);
}
.icon-btn:active { background: var(--platen); }
.icon-btn.danger { color: var(--bad); }
#btn-account.signed::after {
  content: ""; position: absolute; top: 9px; inset-inline-end: 9px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--good); border: 2px solid var(--paper);
}
.lang-btn {
  min-width: 44px; height: 36px; margin-inline-start: 4px; padding: 0 10px;
  border: 1.5px solid var(--line); border-radius: 999px; background: var(--paper); font-weight: 600;
}

/* ---------- zones ---------- */
.zonebar {
  display: flex; gap: 6px;
  padding: 8px 12px 2px;
  overflow-x: auto; scrollbar-width: none;
}
.zonebar::-webkit-scrollbar { display: none; }
.chip {
  position: relative; flex: none;
  height: 36px; padding: 0 15px;
  border: 1.5px solid var(--line); border-radius: 999px; background: var(--paper);
  font-size: 13.5px; font-weight: 600; color: var(--ink-2); white-space: nowrap;
}
.chip.on { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }
.chip.has::after {
  content: ""; position: absolute; top: 4px; inset-inline-end: 5px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--magenta);
}

/* ---------- plateau ---------- */
.stage {
  position: relative; flex: 1 1 auto; min-height: 120px; overflow: hidden;
  background-color: var(--platen);
  background-image: radial-gradient(circle at 1px 1px, rgba(30, 33, 48, 0.09) 1px, transparent 1.6px);
  background-size: 16px 16px;
}
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.banner {
  position: absolute; top: 8px; inset-inline: 8px; z-index: 3; margin: 0;
  padding: 10px 12px; border-radius: var(--r-s);
  background: #FDECEC; color: #8E1B1B; font-size: 13px; font-weight: 600;
}
.stage-ctrls {
  position: absolute; inset-inline: 8px; bottom: 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  pointer-events: none;
}
.stage-ctrls > * { pointer-events: auto; }
.grp { display: flex; gap: 6px; flex: none; }
.round, .pill {
  border: 0; background: var(--paper); color: var(--ink);
  box-shadow: 0 1px 2px rgba(30, 33, 48, 0.12), 0 4px 12px rgba(30, 33, 48, 0.08);
}
.round { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; }
.round:disabled { opacity: 0.4; }
.round[aria-pressed="true"] { background: var(--ink); color: #FFFFFF; }
.pill { height: 44px; padding: 0 16px; border-radius: 999px; display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.ctrl-preview { display: none; }
body.previewing .ctrl-edit { display: none; }
body.previewing .ctrl-preview { display: flex; }
.info {
  min-width: 0; display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 2px rgba(30, 33, 48, 0.1);
}
.info.hint { color: var(--ink-2); font-weight: 400; }
.q { display: inline-flex; align-items: center; gap: 5px; }
.q i { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.q.good i { background: var(--good); }
.q.ok i { background: var(--ok); }
.q.bad i { background: var(--bad); }
.q.bad { color: var(--bad); }

/* ---------- barre de l'élément sélectionné ---------- */
.ctxbar {
  display: flex; gap: 2px; padding: 6px 8px;
  overflow-x: auto; scrollbar-width: none;
  background: var(--paper); border-top: 1px solid var(--line);
}
.ctxbar::-webkit-scrollbar { display: none; }
.ctx-btn {
  flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 66px; padding: 6px 8px;
  border: 0; border-radius: var(--r-s); background: transparent;
  font-size: 11.5px; color: var(--ink-2);
}
.ctx-btn svg { width: 21px; height: 21px; color: var(--ink); }
.ctx-btn:active { background: var(--platen); }
.ctx-btn.danger, .ctx-btn.danger svg { color: var(--bad); }

/* ---------- barre d'outils ---------- */
.toolbar {
  display: grid; grid-template-columns: repeat(6, 1fr);
  padding: 4px; background: var(--paper); border-top: 1px solid var(--line);
}
.toolbar button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 60px; padding: 4px 2px;
  border: 0; border-radius: var(--r-s); background: transparent;
  font-size: 11.5px; font-weight: 600; color: var(--ink-2);
}
.toolbar button svg { width: 24px; height: 24px; color: var(--ink); }
.toolbar button:active { background: var(--platen); }
.toolbar button.primary { color: var(--magenta-deep); }
.toolbar button.primary svg {
  box-sizing: content-box; width: 18px; height: 18px; padding: 6px; margin: -4px 0 -2px;
  border-radius: 50%; background: var(--magenta); color: #FFFFFF;
}

/* ---------- panneaux ---------- */
.sheet {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 20;
  display: flex; flex-direction: column;
  max-height: 62vh; max-height: 62dvh;
  background: var(--paper);
  border-radius: var(--r-l) var(--r-l) 0 0;
  box-shadow: 0 -8px 30px rgba(30, 33, 48, 0.18);
  padding-bottom: env(safe-area-inset-bottom);
  transform: translateY(16px); opacity: 0;
  transition: transform 0.22s ease, opacity 0.18s ease;
}
.sheet[data-size="tall"] { max-height: 88vh; max-height: 88dvh; }
.sheet.open { transform: none; opacity: 1; }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 6px 4px; padding-inline-start: 18px;
}
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 800; }
.sheet-body { overflow-y: auto; padding: 0 18px 20px; overscroll-behavior: contain; }

.label { display: block; margin: 14px 0 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.row .label { margin-bottom: 4px; }
output { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
input[type="text"], input[type="email"], input[type="password"], textarea {
  display: block; width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--line); border-radius: var(--r-s); background: var(--paper);
  font-size: 16px;
}
textarea { resize: none; min-height: 66px; margin-top: 4px; }
input:focus, textarea:focus { border-color: var(--ink); outline: none; }
input[type="range"] { display: block; width: 100%; height: 30px; margin: 0; accent-color: var(--magenta); }
.note { margin: 10px 0 0; font-size: 13px; color: var(--ink-2); }
.empty { color: var(--ink-2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px;
  border: 1.5px solid var(--line); border-radius: 999px; background: var(--paper);
  font-weight: 600; color: var(--ink); text-decoration: none;
}
.btn svg { width: 20px; height: 20px; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }
.btn.block { width: 100%; margin-top: 16px; }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: 13.5px; }
.btn.sm svg { width: 18px; height: 18px; }
.btn:disabled { opacity: 0.45; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.btn-link {
  border: 0; background: none; padding: 12px 0;
  color: var(--magenta-deep); font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px;
}
.switch { display: flex; align-items: center; gap: 10px; margin-top: 16px; font-size: 14px; font-weight: 600; }
.switch input { width: 22px; height: 22px; margin: 0; accent-color: var(--magenta); }
.seg { display: flex; gap: 6px; }
.seg.wrap { flex-wrap: wrap; }
.seg button {
  min-height: 40px; padding: 0 14px;
  border: 1.5px solid var(--line); border-radius: 999px; background: var(--paper);
  font-size: 13.5px; font-weight: 600;
}
.seg button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }

/* couleurs */
.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px 8px; }
.swatch {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 6px 0; border: 0; background: none;
  font-size: 11.5px; color: var(--ink-2); text-align: center;
}
.swatch i { width: 44px; height: 44px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(30, 33, 48, 0.18); }
.swatch.on i { box-shadow: inset 0 0 0 1px rgba(30, 33, 48, 0.18), 0 0 0 3px var(--paper), 0 0 0 5px var(--ink); }
.swatch.on { color: var(--ink); font-weight: 600; }
.swatches.mini { display: flex; flex-wrap: wrap; gap: 9px; }
.sw {
  width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%;
  background: var(--c); box-shadow: inset 0 0 0 1px rgba(30, 33, 48, 0.22);
}
.sw.on { box-shadow: inset 0 0 0 1px rgba(30, 33, 48, 0.22), 0 0 0 2px var(--paper), 0 0 0 4px var(--ink); }
.sw.custom {
  position: relative; display: inline-block; overflow: hidden;
  background: conic-gradient(#E53935, #FDD835, #43A047, #00ACC1, #1E88E5, #8E24AA, #E53935);
}
.sw.custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.custom-color { display: flex; align-items: center; gap: 12px; margin-top: 16px; font-weight: 600; }
.custom-color input { width: 44px; height: 44px; padding: 0; border: 0; background: none; }

/* polices */
.font-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.font-chip {
  flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 86px; height: 66px; padding: 4px 10px;
  border: 1.5px solid var(--line); border-radius: var(--r-s); background: var(--paper);
}
.font-chip .sample { font-size: 22px; line-height: 1.15; color: var(--ink); }
.font-chip small { font-size: 10.5px; color: var(--ink-3); white-space: nowrap; }
.font-chip[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }

/* modèles */
.model-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.model-card {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 6px 10px;
  border: 1.5px solid var(--line); border-radius: var(--r-m); background: var(--platen);
  text-align: center;
}
.model-card canvas { width: 100%; max-width: 120px; aspect-ratio: 1; }
.model-card strong { font-size: 13.5px; }
.model-card span { font-size: 11.5px; color: var(--ink-3); }
.model-card.on { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); background: var(--paper); }

/* export */
.group { margin-top: 16px; }
.group h3, .ds-list h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.zone-list { display: grid; gap: 6px; }
.zone-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1.5px solid var(--line); border-radius: var(--r-s);
}
.zone-row input { width: 20px; height: 20px; margin: 0; accent-color: var(--ink); }
.zone-row .zn { flex: 1; font-weight: 600; }
.zone-row .zs { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.checks { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.checks li { display: flex; align-items: flex-start; gap: 8px; font-size: 13.5px; }
.checks li svg { width: 18px; height: 18px; margin-top: 1px; }
.checks .good svg { color: var(--good); }
.checks .warn svg { color: var(--ok); }
.checks .bad, .checks .bad svg { color: var(--bad); }
.ready { display: flex; align-items: center; gap: 8px; margin: 22px 0 6px; font-size: 15px; color: var(--good); }
.file-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.file-meta { display: flex; flex-direction: column; min-width: 0; }
.file-meta span { font-size: 12.5px; color: var(--ink-3); }
.file-meta .warn-text { color: var(--ok); }
.file-actions { display: flex; gap: 6px; }

/* créations */
.ds-list h3 { margin-top: 22px; }
.d-row {
  display: grid; grid-template-columns: 56px minmax(0, 1fr) auto auto; align-items: center; gap: 10px;
  padding: 8px 0; border-top: 1px solid var(--line);
}
.d-thumb { width: 56px; height: 56px; overflow: hidden; border-radius: var(--r-s); background: var(--platen); }
.d-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.d-meta { display: flex; flex-direction: column; min-width: 0; }
.d-meta strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d-meta span { font-size: 12px; color: var(--ink-3); }
.d-meta em { font-style: normal; font-size: 11.5px; font-weight: 600; color: var(--magenta-deep); }

/* fond transparent et aperçu */
.checker {
  background-color: #FFFFFF;
  background-image: conic-gradient(#E3E5EA 25%, transparent 0 50%, #E3E5EA 0 75%, transparent 0);
  background-size: 18px 18px;
  border-radius: var(--r-m);
}
.bg-preview { display: grid; place-items: center; min-height: 150px; padding: 10px; }
.bg-preview canvas { max-width: 100%; max-height: 32vh; }
.share-img { display: block; width: 100%; border-radius: var(--r-m); }

/* compte */
.account-line { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.form-error {
  margin: 12px 0 0; padding: 10px 12px; border-radius: var(--r-s);
  background: #FDECEC; color: #8E1B1B; font-size: 13.5px;
}
.form-error.ok { background: #E8F5EC; color: #165C2B; }

/* messages */
.toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 40;
  max-width: min(92vw, 460px); padding: 12px 16px; border-radius: var(--r-m);
  background: var(--ink); color: #FFFFFF; font-size: 14px;
  opacity: 0; pointer-events: none; transform: translate(-50%, 12px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #8E1B1B; }
.toast.warn { background: #6B4400; }
body.sheet-open .toast { bottom: calc(var(--sheet-h) + 12px); }
.busy {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(231, 233, 238, 0.74);
}
.busy-card {
  display: flex; align-items: center; gap: 12px; max-width: 86vw;
  padding: 16px 20px; border-radius: var(--r-m); background: var(--paper);
  box-shadow: 0 8px 30px rgba(30, 33, 48, 0.18); font-weight: 600;
}
.busy-card p { margin: 0; }
.spinner {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--magenta);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.noscript { margin: 24px; font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .sheet, .toast { transition: none; }
  .spinner { animation-duration: 2.4s; }
}
@media (max-width: 360px) {
  .brand-tag { display: none; }
  .toolbar button { font-size: 10.5px; }
  .ctx-btn { min-width: 58px; }
}
/* tablette et ordinateur : panneau sur le côté */
@media (min-width: 900px) {
  .sheet, .sheet[data-size="tall"] {
    top: 0; bottom: 0; inset-inline-start: auto; inset-inline-end: 0;
    width: 400px; max-height: none; border-radius: 0;
    padding-top: env(safe-area-inset-top);
    box-shadow: -8px 0 30px rgba(30, 33, 48, 0.12);
  }
  body.sheet-open .app { padding-bottom: env(safe-area-inset-bottom); padding-inline-end: 400px; }
  body.sheet-open .toolbar { display: grid; }
  body.sheet-open .ctxbar { display: flex; }
  body.sheet-open .toast { bottom: calc(86px + env(safe-area-inset-bottom)); }
  .toolbar { padding-inline: max(4px, calc(50% - 320px)); }
}
