:root {
  --bg: #FFFBF7;
  --surface: #FFFFFF;
  --sunk: #F6F1F3;
  --ink: #1E1A2B;
  --muted: #6E6578;
  --line: #EDE6EA;
  --cyan: #19A7E0;
  --cyan-d: #0C7DB0;
  --cyan-l: #E5F5FD;
  --pink: #E0478F;
  --pink-d: #C42E73;
  --pink-l: #FDEBF3;
  --yellow: #F7C431;
  --green: #16A06A;
  --green-l: #E3F6EE;
  --red: #C8364B;
  --display: 'Outfit', system-ui, sans-serif;
  --serif: 'Fraunces', Georgia, serif;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --radius: 20px;
  --shadow: 0 1px 2px rgba(30, 26, 43, .04), 0 8px 24px rgba(30, 26, 43, .06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 500 17px/1.45 var(--display);
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, textarea { font: inherit; color: inherit; }
img, video { max-width: 100%; display: block; }

.top {
  display: flex; justify-content: center;
  padding: calc(14px + env(safe-area-inset-top)) 16px 6px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { width: 112px; height: auto; }
.brand-sub {
  font: italic 600 26px/1 var(--serif); color: var(--pink);
  transform: translateY(4px);
}

main { max-width: 560px; margin: 0 auto; padding: 8px 16px 48px; }

h1 { font-size: 30px; line-height: 1.1; font-weight: 800; letter-spacing: -.02em; margin: 18px 0 6px; }
h1 em { font: italic 600 1em/1 var(--serif); color: var(--pink); }
h2 { font-size: 19px; font-weight: 700; margin: 0 0 10px; }
.lead { color: var(--muted); margin: 0 0 18px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.step-n {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--pink-l); color: var(--pink-d); font-weight: 800; font-size: 14px; margin-right: 8px;
}

/* boutons */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 56px; padding: 14px 20px; border-radius: 16px; border: 0;
  background: var(--pink); color: #fff; font-weight: 700; font-size: 18px; cursor: pointer;
  text-decoration: none; transition: transform .15s var(--ease), background .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn:hover { background: var(--pink-d); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.secondary { background: var(--cyan-l); color: var(--cyan-d); }
.btn.secondary:hover { background: #d4eefb; }
.btn.ghost { background: transparent; color: var(--muted); min-height: 44px; font-weight: 600; font-size: 16px; }
.btn.ghost:hover { color: var(--ink); background: var(--sunk); }
.btn.danger { color: var(--red); }
.btn svg { width: 22px; height: 22px; flex: none; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* gros bouton nouvelle vidéo */
.hero-new {
  display: flex; align-items: center; gap: 16px; text-decoration: none; color: #fff;
  background: linear-gradient(135deg, var(--pink) 0%, #EE6FA8 100%);
  border-radius: 24px; padding: 22px; margin: 6px 0 26px; box-shadow: 0 10px 30px rgba(224, 71, 143, .28);
}
.hero-new .plus {
  width: 58px; height: 58px; border-radius: 18px; background: rgba(255,255,255,.22);
  display: grid; place-items: center; flex: none;
}
.hero-new .plus svg { width: 30px; height: 30px; }
.hero-new b { display: block; font-size: 22px; font-weight: 800; }
.hero-new span { opacity: .9; font-size: 15px; }

/* puces de choix */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 2px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 10px 16px; font-weight: 600; font-size: 16px; cursor: pointer; min-height: 46px;
  transition: transform .15s var(--ease); -webkit-tap-highlight-color: transparent;
}
.chip[aria-pressed="true"] { border-color: var(--pink); background: var(--pink-l); color: var(--pink-d); }
.types { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.type {
  border: 2px solid var(--line); background: var(--surface); border-radius: 16px; padding: 14px;
  text-align: left; cursor: pointer; min-height: 92px; -webkit-tap-highlight-color: transparent;
  transition: transform .15s var(--ease);
}
.type b { display: block; font-size: 16px; margin: 6px 0 2px; }
.type span { font-size: 13px; color: var(--muted); line-height: 1.3; display: block; }
.type .ico { font-size: 24px; line-height: 1; }
.type[aria-pressed="true"] { border-color: var(--pink); background: var(--pink-l); }
.ratio { display: block; height: 30px; width: auto; border: 2.5px solid var(--pink); border-radius: 5px; background: var(--pink-l); }
.fmt { display: flex; flex-direction: column; align-items: flex-start; }
.fmt b { margin-top: 8px; }

textarea, input[type=text] {
  width: 100%; border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px;
  background: var(--surface); font-size: 17px; resize: vertical; outline: none;
}
textarea:focus, input[type=text]:focus { border-color: var(--pink); }
textarea { min-height: 84px; }

/* sélection de fichiers */
.picker {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border: 2px dashed #E7BCD2; background: var(--pink-l); border-radius: 18px; padding: 22px 16px;
  text-align: center; cursor: pointer; color: var(--pink-d); font-weight: 700;
}
.picker svg { width: 36px; height: 36px; }
.picker small { color: var(--muted); font-weight: 500; }
.thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.thumb { position: relative; aspect-ratio: 9/16; border-radius: 12px; overflow: hidden; background: var(--sunk); }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; }
.thumb .x {
  position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0;
  background: rgba(30,26,43,.7); color: #fff; font-size: 16px; line-height: 1; cursor: pointer;
}
.thumb .badge {
  position: absolute; bottom: 4px; left: 4px; background: rgba(30,26,43,.7); color: #fff;
  font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 6px;
}

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { opacity: 0; position: absolute; inset: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: background .2s; pointer-events: none; }
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s var(--ease);
}
.switch input:checked + span { background: var(--pink); }
.switch input:checked + span::after { transform: translateX(20px); }

/* progression */
.bar { height: 10px; background: var(--sunk); border-radius: 999px; overflow: hidden; margin: 14px 0 6px; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--pink), #F59BC4); border-radius: 999px; transition: width .4s var(--ease); }
.steps { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 12px; }
.steps li { display: flex; align-items: center; gap: 12px; color: var(--muted); font-weight: 600; }
.steps .dot {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--sunk); font-size: 14px;
}
.steps li.done { color: var(--ink); }
.steps li.done .dot { background: var(--green-l); color: var(--green); }
.steps li.now { color: var(--ink); }
.steps li.now .dot { background: var(--pink-l); }
.steps li.now .dot::after {
  content: ""; width: 14px; height: 14px; border-radius: 50%; border: 3px solid var(--pink); border-right-color: transparent;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.whisk { font-size: 54px; text-align: center; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-6deg); } }

/* résultat */
.player {
  background: #000; border-radius: 22px; overflow: hidden; margin: 6px auto 14px;
  max-width: 340px; aspect-ratio: 9/16; box-shadow: 0 16px 40px rgba(30,26,43,.22);
}
.player video { width: 100%; height: 100%; object-fit: contain; }
.versions { display: flex; gap: 8px; justify-content: center; margin-bottom: 14px; flex-wrap: wrap; }
.caption {
  white-space: pre-wrap; background: var(--sunk); border-radius: 14px; padding: 14px; font-size: 15px;
  margin: 0 0 12px; font-weight: 500;
}
.tip { background: #FFF6DA; border-radius: 14px; padding: 12px 14px; font-size: 15px; margin-bottom: 14px; }
.warn { background: var(--pink-l); color: var(--pink-d); border-radius: 14px; padding: 12px 14px; font-size: 15px; margin-bottom: 14px; }
.error { background: #FCE8EB; color: var(--red); border-radius: 14px; padding: 14px; margin: 10px 0; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(30px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600; opacity: 0;
  transition: all .3s var(--ease); z-index: 10; pointer-events: none; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* historique */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.item { text-decoration: none; color: inherit; min-width: 0; }
.item .pic {
  aspect-ratio: 9/16; border-radius: 16px; overflow: hidden; background: var(--sunk); position: relative;
  display: grid; place-items: center; font-size: 34px;
}
.item .pic img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.item b { display: block; font-size: 15px; margin-top: 6px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item small { color: var(--muted); font-size: 13px; }
.status {
  position: absolute; top: 8px; left: 8px; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  background: rgba(255,255,255,.92); color: var(--ink);
}
.status.work { color: var(--pink-d); }
.status.err { color: var(--red); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.login { text-align: center; padding-top: 30px; }
.login input { text-align: center; font-size: 22px; letter-spacing: .04em; margin: 16px 0 12px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-weight: 600; margin-top: 6px; }
.footer-note { text-align: center; color: var(--muted); font-size: 13px; margin-top: 28px; }

@media (min-width: 520px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .thumbs { grid-template-columns: repeat(5, 1fr); }
}

/* vidéos modèles enregistrées */
.refs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.ref { position: relative; border: 2px solid var(--line); border-radius: 14px; overflow: hidden; cursor: pointer; background: var(--surface); -webkit-tap-highlight-color: transparent; }
.ref img { width: 100%; aspect-ratio: 3/4; object-fit: cover; opacity: .55; }
.ref span { display: block; font-size: 12px; font-weight: 600; padding: 6px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.ref[aria-pressed="true"] { border-color: var(--pink); }
.ref[aria-pressed="true"] img { opacity: 1; }
.ref[aria-pressed="true"] span { color: var(--pink-d); }
.ref[aria-pressed="true"]::after { content: "✓"; position: absolute; top: 6px; left: 6px; width: 24px; height: 24px; border-radius: 50%; background: var(--pink); color: #fff; font-size: 14px; display: grid; place-items: center; font-weight: 800; }
.ref .x { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(30,26,43,.7); color: #fff; font-size: 15px; cursor: pointer; }

[hidden] { display: none !important; }

.story { margin: 0; padding-left: 22px; display: grid; gap: 6px; font-weight: 600; }
.story li::marker { color: var(--pink); font-weight: 800; }

.styles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.styles .type { min-height: 108px; padding: 12px 10px; }

/* réglages utilisés */
.settings { margin-top: 14px; }
.settings dl { margin: 0; display: grid; gap: 0; }
.settings dl > div { display: grid; grid-template-columns: 128px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; }
.settings dl > div:first-child { border-top: 0; }
.settings dt { color: var(--muted); font-weight: 600; }
.settings dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
